CalcExportController.java
6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package com.bsth.controller.calc;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.bsth.common.ResponseCode;
import com.bsth.entity.calc.CalcWaybill;
import com.bsth.entity.mcy_forms.Waybillday;
import com.bsth.service.calc.CalcMixService;
import com.bsth.service.calc.CalcWaybillService;
import com.bsth.util.ReportUtils;
@RestController
@RequestMapping("calc_export")
public class CalcExportController {
@Autowired
CalcWaybillService service;
@Autowired
CalcMixService clacMixService;
@RequestMapping(value = "/waybilldayExport", method = RequestMethod.GET)
public Map<String, Object> calcjsyspyExport(@RequestParam Map<String, Object> map) {
String line="";
if(map.get("line")!=null){
line=map.get("line").toString().trim();
}
String lineName="";
if(map.get("lineName")!=null){
lineName=map.get("lineName").toString().trim();
}
String startDate="";
if(map.get("startDate")!=null){
startDate=map.get("startDate").toString().trim();
}
String endDate="";
if(map.get("endDate")!=null){
endDate=map.get("endDate").toString().trim();
}
String cont="";
if(map.get("cont")!=null){
cont=map.get("cont").toString().trim();
}
String empnames="";
if(map.get("empnames")!=null){
empnames=map.get("empnames").toString().trim();
}
String gsdmManth="";
if(map.get("gsdmManth")!=null){
gsdmManth=map.get("gsdmManth").toString().trim();
}
String fgsdmManth="";
if(map.get("fgsdmManth")!=null){
fgsdmManth=map.get("fgsdmManth").toString().trim();
}
Map<String, Object> resMap = new HashMap<String, Object>();
List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> list = clacMixService.calcjsyspy(line, startDate, endDate, empnames, cont, gsdmManth, fgsdmManth);
Map<String, Object> temp = new HashMap<String, Object>();
temp.put("i", "序号");
temp.put("jName", empnames);
temp.put("jhyybc", "计划营运班次");
temp.put("jhfyybc", "计划空驶班次");
temp.put("sjyybc", "实际营运班次");
temp.put("sjfyybc", "实际空驶班次");
temp.put("lbbc", "烂班班次");
temp.put("ljbc", "临加班次");
temp.put("jhzlc", "计划总里程");
temp.put("jhyylc", "计划营运里程");
temp.put("jhfyylc", "计划空驶里程");
temp.put("sjzlc", "实际总里程");
temp.put("sjyylc", "实际营运里程");
temp.put("sjfyylc", "实际空驶里程");
temp.put("lblc", "烂班里程");
temp.put("ljyylc", "临加营运里程");
temp.put("ljfyylc", "临加空驶里程");
resList.add(temp);
for(int i = 0; i < list.size(); i++){
temp = list.get(i);
temp.put("i", i+1);
resList.add(temp);
}
String date = startDate.replaceAll("-", "");
if(!startDate.equals(endDate)){
date = startDate.replaceAll("-", "") + "-" + endDate.replaceAll("-", "");
}
SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
sdfSimple = new SimpleDateFormat("yyyyMMdd");
List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
Map<String,Object> mm = new HashMap<String, Object>();
ReportUtils ee = new ReportUtils();
try {
listI.add(resList.iterator());
String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
ee.excelReplace(listI, new Object[] { mm }, path+"mould/calcjsyspy.xls",
path+"export/"+date+"-"+lineName+"-人车班次公里统计.xls");
resMap.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resMap.put("status", ResponseCode.ERROR);
}
return resMap;
}
@RequestMapping(value = "/singledataExportTj", method = RequestMethod.GET)
public Map<String, Object> singledataExportTj(@RequestParam Map<String, Object> map) {
String line="";
if(map.get("line")!=null){
line=map.get("line").toString().trim();
}
String lineName="";
if(map.get("lineName")!=null){
lineName=map.get("lineName").toString().trim();
}
String startDate="";
if(map.get("startDate")!=null){
startDate=map.get("startDate").toString().trim();
}
String endDate="";
if(map.get("endDate")!=null){
endDate=map.get("endDate").toString().trim();
}
String tjtype="";
if(map.get("tjtype")!=null){
tjtype=map.get("tjtype").toString().trim();
}
String cont="";
if(map.get("cont")!=null){
cont=map.get("cont").toString().trim();
}
String gsdmSing="";
if(map.get("gsdmSing")!=null){
gsdmSing=map.get("gsdmSing").toString().trim();
}
String fgsdmSing="";
if(map.get("fgsdmSing")!=null){
fgsdmSing=map.get("fgsdmSing").toString().trim();
}
Map<String, Object> resMap = new HashMap<String, Object>();
List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> list = clacMixService.singledatatj(line, startDate, endDate, tjtype, cont, gsdmSing, fgsdmSing);
Map<String, Object> temp = new HashMap<String, Object>();
temp.put("i", "序号");
temp.put("gS", "所属公司");
temp.put("xlName", "线路");
temp.put("jName", tjtype);
temp.put("jhzlc", "计划公里");
temp.put("sjzlc", "行驶里程(包括空放)");
temp.put("sjfyylc", "空驶里程");
temp.put("hyl", "耗油量");
temp.put("jzl", "加注量");
temp.put("sh", "非营业用油");
resList.add(temp);
for(int i = 0; i < list.size(); i++){
temp = list.get(i);
temp.put("i", i+1);
if(temp.get("xlName") == null){
temp.put("xlName", "");
}
resList.add(temp);
}
String date = startDate.replaceAll("-", "");
if(!startDate.equals(endDate)){
date = startDate.replaceAll("-", "") + "-" + endDate.replaceAll("-", "");
}
SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
sdfSimple = new SimpleDateFormat("yyyyMMdd");
List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
Map<String,Object> mm = new HashMap<String, Object>();
ReportUtils ee = new ReportUtils();
try {
listI.add(resList.iterator());
String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
ee.excelReplace(listI, new Object[] { mm }, path+"mould/calcsingledata.xls",
path+"export/"+date+"-"+lineName+"-路单数据(统计).xls");
resMap.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resMap.put("status", ResponseCode.ERROR);
}
return resMap;
}
}