Commit abc1fae7bce68dd67a2ffa8388504aa4ff351019

Authored by 游瑞烽
2 parents 26dd0e0b 54c3fcd2

Merge remote-tracking branch 'origin/jiading' into jiading

Too many changes to show.

To preserve performance only 15 of 24 files are displayed.

src/main/java/com/bsth/controller/calc/CalcDlbController.java 0 → 100644
  1 +package com.bsth.controller.calc;
  2 +
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.Date;
  5 +import java.util.HashMap;
  6 +import java.util.Map;
  7 +
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import com.bsth.common.ResponseCode;
  14 +import com.bsth.service.calc.CalcDlbService;
  15 +
  16 +/**
  17 + * Created by 20/05/27.
  18 + */
  19 +@RestController
  20 +@RequestMapping("calc_dlb")
  21 +public class CalcDlbController {
  22 +
  23 + @Autowired
  24 + CalcDlbService service;
  25 +
  26 + @RequestMapping(value="/updateDlb")
  27 + public Map<String, Object> generateDaliy(@RequestParam Map<String, Object> map) throws Exception{
  28 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  29 + Date d = new Date();
  30 + d.setTime(d.getTime() - (1l*1000*60*60*24)); //默认前一天
  31 + String date = "";
  32 + if(map.containsKey("date") && map.get("date")!=null){
  33 + date=map.get("date").toString().trim();
  34 + }
  35 +
  36 + Map<String, Object> m = new HashMap<String, Object>();
  37 + m.put("date", date);
  38 + try {
  39 + sdf.format(sdf.parse(date)); //校验日期格式
  40 +
  41 +// m.put("status", service.impElectric(date));
  42 + service.impElectric(date);
  43 + m.put("status", ResponseCode.SUCCESS);
  44 +
  45 + } catch (Exception e) {
  46 + // TODO: handle exception
  47 + e.printStackTrace();
  48 + m.put("status", ResponseCode.ERROR);
  49 + return m;
  50 + }
  51 + return m;
  52 + }
  53 +
  54 +}
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
1 -package com.bsth.controller.realcontrol;  
2 -  
3 -import java.io.ByteArrayOutputStream;  
4 -import java.io.IOException;  
5 -import java.io.InputStream;  
6 -import java.io.OutputStream;  
7 -import java.net.HttpURLConnection;  
8 -import java.net.URL;  
9 -import java.util.ArrayList;  
10 -import java.util.Collection;  
11 -import java.util.HashMap;  
12 -import java.util.List;  
13 -import java.util.Map;  
14 -  
15 -import org.apache.commons.io.IOUtils;  
16 -import org.apache.commons.lang3.StringEscapeUtils;  
17 -import org.joda.time.format.DateTimeFormat;  
18 -import org.joda.time.format.DateTimeFormatter;  
19 -import org.springframework.beans.factory.annotation.Autowired;  
20 -import org.springframework.web.bind.annotation.PathVariable;  
21 -import org.springframework.web.bind.annotation.RequestMapping;  
22 -import org.springframework.web.bind.annotation.RequestMethod;  
23 -import org.springframework.web.bind.annotation.RequestParam;  
24 -import org.springframework.web.bind.annotation.RestController;  
25 -  
26 -import com.alibaba.fastjson.JSONArray;  
27 -import com.bsth.common.ResponseCode;  
28 -import com.bsth.controller.BaseController;  
29 -import com.bsth.controller.realcontrol.dto.ChangePersonCar;  
30 -import com.bsth.controller.realcontrol.dto.DfsjChange;  
31 -import com.bsth.data.BasicData;  
32 -import com.bsth.data.schedule.DayOfSchedule;  
33 -import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;  
34 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
35 -import com.bsth.entity.schedule.SchedulePlanInfo;  
36 -import com.bsth.entity.sys.SysUser;  
37 -import com.bsth.security.util.SecurityUtils;  
38 -import com.bsth.service.realcontrol.ScheduleRealInfoService;  
39 -import com.bsth.util.ConfigUtil;  
40 -import com.fasterxml.jackson.databind.ObjectMapper;  
41 -  
42 -@RestController  
43 -@RequestMapping("/realSchedule")  
44 -public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {  
45 -  
46 - @Autowired  
47 - ScheduleRealInfoService scheduleRealInfoService;  
48 -  
49 - @Autowired  
50 - DayOfSchedule dayOfSchedule;  
51 -  
52 - @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST)  
53 - public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){  
54 - return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm);  
55 - }  
56 -  
57 - @RequestMapping(value = "/lines")  
58 - public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {  
59 - return scheduleRealInfoService.findByLines(lines);  
60 - }  
61 -  
62 - @RequestMapping(value = "/car")  
63 - public List<ScheduleRealInfo> findByCar(String nbbm){  
64 - return dayOfSchedule.findByNbbm(nbbm);  
65 - }  
66 -  
67 - /**  
68 - *  
69 - * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id  
70 - * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws  
71 - */  
72 - @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)  
73 - public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,  
74 - @RequestParam String dfsj,String bcType,  
75 - @RequestParam(defaultValue = "") String opType) {  
76 - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType, null);  
77 - }  
78 -  
79 - /**  
80 - *  
81 - * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔  
82 - */  
83 - @RequestMapping(value = "/destroy", method = RequestMethod.POST)  
84 - public Map<String, Object> destroy(@RequestParam String idsStr  
85 - /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,  
86 - @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {  
87 - return scheduleRealInfoService.destroy(idsStr, remarks, adjustExps, null);  
88 - }  
89 -  
90 - /**  
91 - *  
92 - * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws  
93 - */  
94 - @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)  
95 - public Map<String, String> carDeviceMapp() {  
96 - return BasicData.deviceId2NbbmMap.inverse();  
97 - }  
98 -  
99 - /**  
100 - *  
101 - * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param  
102 - * lineId @throws  
103 - */  
104 - @RequestMapping(value = "/driver", method = RequestMethod.GET)  
105 - public List<Map<String, String>> findDriverByLine(@RequestParam String lineCode) {  
106 - return scheduleRealInfoService.findDriverByLine(lineCode);  
107 - }  
108 -  
109 - /**  
110 - *  
111 - * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param  
112 - * lineId @throws  
113 - */  
114 - @RequestMapping(value = "/conductor", method = RequestMethod.GET)  
115 - public List<Map<String, String>> findConductorByLine(@RequestParam String lineCode) {  
116 - return scheduleRealInfoService.findConductorByLine(lineCode);  
117 - }  
118 -  
119 - /**  
120 - *  
121 - * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param  
122 - * lineId @throws  
123 - */  
124 - @RequestMapping(value = "/cars", method = RequestMethod.GET)  
125 - public List<Map<String, String>> findCarByLine(@RequestParam String lineCode) {  
126 - return scheduleRealInfoService.findCarByLine(lineCode);  
127 - }  
128 -  
129 - /**  
130 - *  
131 - * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws  
132 - */  
133 - @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)  
134 - public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {  
135 - return scheduleRealInfoService.sreachVehic(nbbm);  
136 - }  
137 - /**  
138 - *  
139 - * @Title: realOutAdjust  
140 - * @Description: TODO(实发调整)  
141 - * @param @param id 班次ID  
142 - * @param @param fcsjActual 实际发车时间 HH:mm  
143 - * @param @param remarks 备注  
144 - * @throws  
145 - */  
146 - @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)  
147 - public Map<String, Object> realOutAdjust(@RequestParam Long id, @RequestParam String fcsjActual,  
148 - @RequestParam String remarks) {  
149 - return scheduleRealInfoService.realOutAdjust(id, fcsjActual, remarks);  
150 - }  
151 -  
152 - /**  
153 - *  
154 - * @Title: revokeDestroy  
155 - * @Description: TODO(撤销烂班)  
156 - * @param @param id  
157 - * @throws  
158 - */  
159 - @RequestMapping(value = "/revokeDestroy", method = RequestMethod.POST)  
160 - public Map<String, Object> revokeDestroy(@RequestParam Long id){  
161 - return scheduleRealInfoService.revokeDestroy(id);  
162 - }  
163 -  
164 - /**  
165 - *  
166 - * @Title: revokeRealOutgo  
167 - * @Description: TODO(撤销实发)  
168 - * @param @param id  
169 - * @throws  
170 - */  
171 - @RequestMapping(value = "/revokeRealOutgo", method = RequestMethod.POST)  
172 - public Map<String, Object> revokeRealOutgo(@RequestParam Long id){  
173 - return scheduleRealInfoService.revokeRealOutgo(id);  
174 - }  
175 -  
176 - /**  
177 - * 撤销执行  
178 - * @param id  
179 - * @return  
180 - */  
181 - @RequestMapping(value = "/revokeRealArrive", method = RequestMethod.POST)  
182 - public Map<String, Object> revokeRealArrive(@RequestParam Long id){  
183 - return scheduleRealInfoService.revokeRealArrive(id);  
184 - }  
185 -  
186 - /**  
187 - *  
188 - * @Title: spaceAdjust  
189 - * @Description: TODO(间隔调整)  
190 - * @param @param ids 要调整的班次数组ID  
191 - * @param @param space 间隔  
192 - * @throws  
193 - */  
194 - @RequestMapping(value = "/spaceAdjust", method = RequestMethod.POST)  
195 - public Map<String, Object> spaceAdjust(Long[] ids, Integer space){  
196 - return scheduleRealInfoService.spaceAdjust(ids, space);  
197 - }  
198 -  
199 - /**  
200 - *  
201 - * @Title: schInfoFineTune  
202 - * @Description: TODO(发车信息微调)  
203 - * @param @param map  
204 - * @throws  
205 - */  
206 - @RequestMapping(value = "/schInfoFineTune", method = RequestMethod.POST)  
207 - public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){  
208 - return scheduleRealInfoService.schInfoFineTune(map);  
209 - }  
210 -  
211 - /**  
212 - *  
213 - * @Title: outgoAdjustAll  
214 - * @Description: TODO(批量待发调整)  
215 - * @param @param list  
216 - * @throws  
217 - */  
218 - @RequestMapping(value = "/outgoAdjustAll", method = RequestMethod.POST)  
219 - public Map<String, Object> outgoAdjustAll(@RequestParam String params){  
220 - //反转义  
221 - params = StringEscapeUtils.unescapeHtml4(params);  
222 - return scheduleRealInfoService.outgoAdjustAll(params);  
223 - }  
224 -  
225 - /**  
226 - *  
227 - * @Title: findByLineAndUpDown  
228 - * @Description: TODO(根据线路和走向获取班次)  
229 - * @param @param line  
230 - * @param @param upDown  
231 - */  
232 - @RequestMapping(value = "/findByLineAndUpDown")  
233 - public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){  
234 - return dayOfSchedule.findByLineAndUpDown(line, upDown);  
235 - }  
236 -  
237 - /**  
238 - *  
239 - * @Title: findRouteByLine  
240 - * @Description: TODO(获取线路的站点,路段路由)  
241 - * @param @param lineCode  
242 - * @throws  
243 - */  
244 - @RequestMapping(value = "/findRouteByLine")  
245 - public Map<String, Object> findRouteByLine(@RequestParam String lineCode){  
246 - return scheduleRealInfoService.findRouteByLine(lineCode);  
247 - }  
248 -  
249 - /**  
250 - *  
251 - * @Title: removeChildTask  
252 - * @Description: TODO(删除子任务)  
253 - * @param @param taskId 子任务ID  
254 - * @throws  
255 - */  
256 - @RequestMapping(value = "/childTask/{taskId}", method = RequestMethod.DELETE)  
257 - public Map<String, Object> removeChildTask(@PathVariable("taskId") Long taskId){  
258 - return scheduleRealInfoService.removeChildTask(taskId);  
259 - }  
260 -  
261 - /**  
262 - *  
263 - * @Title: findByLineCode  
264 - * @Description: TODO(根据线路获取班次信息)  
265 - * @param @param lineCode  
266 - */  
267 - @RequestMapping(value = "/lineCode/{lineCode}")  
268 - public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){  
269 - return dayOfSchedule.findByLineCode(lineCode);  
270 - }  
271 -  
272 - @RequestMapping(value = "/queryUserInfo")  
273 - public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,  
274 - @RequestParam String date,@RequestParam String state) {  
275 - return scheduleRealInfoService.queryUserInfo(line, date,state);  
276 - }  
277 -  
278 - @RequestMapping(value = "/queryUserInfoPx")  
279 - public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,  
280 - @RequestParam String date,@RequestParam String state,@RequestParam String type) {  
281 - return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);  
282 - }  
283 -  
284 - @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)  
285 - public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName,@RequestParam String jGh, @RequestParam String clZbh,  
286 - @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {  
287 - return scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);  
288 - }  
289 -  
290 - @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)  
291 - public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh  
292 - ,@RequestParam String date,@RequestParam String line) {  
293 - return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);  
294 - }  
295 -  
296 -  
297 - @RequestMapping(value = "/dailyInfo")  
298 - public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {  
299 - return scheduleRealInfoService.dailyInfo(line, date, type);  
300 - }  
301 -  
302 - @RequestMapping(value = "/historyMessage")  
303 - public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,  
304 - @RequestParam String code, @RequestParam String type) {  
305 - return scheduleRealInfoService.historyMessage(line, date, code, type);  
306 - }  
307 -  
308 - @RequestMapping(value="/findLine")  
309 - public List<Map<String,String>> findLine(@RequestParam String line){  
310 - return scheduleRealInfoService.findLine(line);  
311 - }  
312 -  
313 - @RequestMapping(value="/findKMBC",method = RequestMethod.GET)  
314 - public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName  
315 - ,@RequestParam String date,@RequestParam String line){  
316 - return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);  
317 - }  
318 -  
319 - /**  
320 - * 路单公里统计 (闵行审计专用)  
321 - * @param jGh  
322 - * @param clZbh  
323 - * @param lpName  
324 - * @param date  
325 - * @param line  
326 - * @return  
327 - */  
328 - @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)  
329 - public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName  
330 - ,@RequestParam String date,@RequestParam String line){  
331 - return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);  
332 - }  
333 -  
334 - @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)  
335 - public Map<String,Object> findKMBCQp(@RequestParam String clZbh  
336 - ,@RequestParam String date,@RequestParam String line){  
337 - return scheduleRealInfoService.findKMBCQp(clZbh,date,line);  
338 - }  
339 -  
340 - @RequestMapping(value="/findLpName")  
341 - public List<Map<String,String>> findLpName(@RequestParam String lpName){  
342 - return scheduleRealInfoService.findLpName(lpName);  
343 - }  
344 -  
345 - @RequestMapping(value = "/account")  
346 - public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,  
347 - @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {  
348 - return scheduleRealInfoService.account(line, date, code, xlName, type);  
349 - }  
350 -  
351 - @RequestMapping(value = "/accountPx")  
352 - public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,  
353 - @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {  
354 - return scheduleRealInfoService.accountPx(line, date, code, xlName, px);  
355 - }  
356 -  
357 - @RequestMapping(value = "/correctForm")  
358 - public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,  
359 - @RequestParam String endDate,  
360 - @RequestParam String lpName, @RequestParam String code,  
361 - @RequestParam String type,@RequestParam String changType) {  
362 - return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);  
363 - }  
364 - /**  
365 - * @Title queryListWaybill  
366 - * @Description 查询行车路单列表  
367 - * @param jName 驾驶员名字  
368 - * @param clZbh 车辆自编号(内部编号)  
369 - * @param lpName 路牌  
370 - * @return  
371 - */  
372 - @RequestMapping(value="/queryListWaybill",method = RequestMethod.GET)  
373 - public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName  
374 - ,@RequestParam String date,@RequestParam String line){  
375 - return scheduleRealInfoService.queryListWaybill(jGh, clZbh,lpName,date,line);  
376 - }  
377 -  
378 - /**  
379 - * @Title queryListWaybill  
380 - * @Description 查询行车路单列表(闵行审计专用路单)  
381 - * @param jName 驾驶员名字  
382 - * @param clZbh 车辆自编号(内部编号)  
383 - * @param lpName 路牌  
384 - * @return  
385 - */  
386 - @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)  
387 - public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName  
388 - ,@RequestParam String date,@RequestParam String line){  
389 - return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);  
390 - }  
391 -  
392 - @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)  
393 - public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,  
394 - @RequestParam String date,@RequestParam String line){  
395 - return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);  
396 - }  
397 -  
398 - @RequestMapping(value="/statisticsDaily")  
399 - public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,  
400 - @RequestParam String xlName, @RequestParam String type){  
401 - return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);  
402 - }  
403 -  
404 - @RequestMapping(value="/statisticsDaily_mh_2")  
405 - public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,  
406 - @RequestParam String xlName, @RequestParam String type){  
407 - return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);  
408 - }  
409 -  
410 - @RequestMapping(value="/statisticsDailyTj")  
411 - public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){  
412 - String gsdm="";  
413 - if(map.get("gsdm")!=null){  
414 - gsdm=map.get("gsdm").toString();  
415 - }  
416 - String fgsdm="";  
417 - if(map.get("fgsdm")!=null){  
418 - fgsdm=map.get("fgsdm").toString();  
419 - }  
420 - String line="";  
421 - if(map.get("line")!=null){  
422 - line=map.get("line").toString();  
423 - }  
424 - String date="";  
425 - if(map.get("date")!=null){  
426 - date=map.get("date").toString();  
427 - }  
428 - String date2="";  
429 - if(map.get("date2")!=null){  
430 - date2=map.get("date2").toString();  
431 - }  
432 - String xlName="";  
433 - if(map.get("xlName")!=null){  
434 - xlName=map.get("xlName").toString();  
435 - }  
436 - String type="";  
437 - if(map.get("type")!=null){  
438 - type=map.get("type").toString();  
439 - }  
440 - String nature="0";  
441 - if(map.get("nature")!=null){  
442 - nature=map.get("nature").toString();  
443 - }  
444 - return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);  
445 - }  
446 -  
447 - /*  
448 - * 公里修正报表  
449 - */  
450 - @RequestMapping(value="/mileageReportTj")  
451 - public List<Map<String,Object>> mileageReport(@RequestParam Map<String, Object> map){  
452 - String gsdm="";  
453 - if(map.get("gsdm")!=null){  
454 - gsdm=map.get("gsdm").toString();  
455 - }  
456 - String fgsdm="";  
457 - if(map.get("fgsdm")!=null){  
458 - fgsdm=map.get("fgsdm").toString();  
459 - }  
460 - String line="";  
461 - if(map.get("line")!=null){  
462 - line=map.get("line").toString();  
463 - }  
464 - String date="";  
465 - if(map.get("date")!=null){  
466 - date=map.get("date").toString();  
467 - }  
468 - String date2="";  
469 - if(map.get("date2")!=null){  
470 - date2=map.get("date2").toString();  
471 - }  
472 - String xlName="";  
473 - if(map.get("xlName")!=null){  
474 - xlName=map.get("xlName").toString();  
475 - }  
476 - return scheduleRealInfoService.mileageReport(gsdm,fgsdm,line, date,date2);  
477 - }  
478 -  
479 - /*  
480 - * 班次修正报表  
481 - */  
482 - @RequestMapping(value="/scheduleCorrectionReport")  
483 - public List<Map<String,Object>> scheduleCorrectionReport(@RequestParam Map<String, Object> map){  
484 - String gsdm="";  
485 - if(map.get("gsdm")!=null){  
486 - gsdm=map.get("gsdm").toString();  
487 - }  
488 - String fgsdm="";  
489 - if(map.get("fgsdm")!=null){  
490 - fgsdm=map.get("fgsdm").toString();  
491 - }  
492 - String line="";  
493 - if(map.get("line")!=null){  
494 - line=map.get("line").toString();  
495 - }  
496 - String date="";  
497 - if(map.get("date")!=null){  
498 - date=map.get("date").toString();  
499 - }  
500 - String date2="";  
501 - if(map.get("date2")!=null){  
502 - date2=map.get("date2").toString();  
503 - }  
504 - String xlName="";  
505 - if(map.get("xlName")!=null){  
506 - xlName=map.get("xlName").toString();  
507 - }  
508 - return scheduleRealInfoService.scheduleCorrectionReport(gsdm,fgsdm,line, date,date2);  
509 - }  
510 -  
511 - @RequestMapping(value="/MapById",method = RequestMethod.GET)  
512 - public Map<String, Object> MapById(@RequestParam("id") Long id){  
513 - return scheduleRealInfoService.MapById(id);  
514 - }  
515 -  
516 - @RequestMapping(value="/MapByIdQp",method = RequestMethod.GET)  
517 - public Map<String, Object> MapByIdQp(@RequestParam("id") Long id){  
518 - return scheduleRealInfoService.MapByIdQp(id);  
519 - }  
520 -  
521 - /**  
522 - * @Title: scheduleDaily  
523 - * @Description: TODO(调度日报表)  
524 - * @param line 线路  
525 - * @param date 时间  
526 - * @return  
527 - */  
528 - @RequestMapping(value="/scheduleDaily")  
529 - public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){  
530 - return scheduleRealInfoService.scheduleDaily(line,date);  
531 - }  
532 -  
533 - @RequestMapping(value="/realScheduleList")  
534 - public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){  
535 - return scheduleRealInfoService.realScheduleList(line,date);  
536 - }  
537 -  
538 - @RequestMapping(value="/realScheduleList_zrw")  
539 - public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){  
540 - return scheduleRealInfoService.realScheduleList_zrw(line,date);  
541 - }  
542 -  
543 - @RequestMapping(value="/realScheduleList_mh_2")  
544 - public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){  
545 - return scheduleRealInfoService.realScheduleList_mh_2(line,date);  
546 - }  
547 -  
548 - @RequestMapping(value="/realScheduleListQp")  
549 - public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){  
550 - return scheduleRealInfoService.realScheduleListQp(line,date);  
551 - }  
552 -  
553 - @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)  
554 - public Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){  
555 - cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);  
556 - List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);  
557 - return scheduleRealInfoService.multi_tzrc(cpcs, null);  
558 - }  
559 -  
560 - @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)  
561 - public Map<String, Object> multi_dftz(@RequestParam String dcsJson){  
562 - dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);  
563 - List<DfsjChange> dfsjcs = JSONArray.parseArray(dcsJson, DfsjChange.class);  
564 - return scheduleRealInfoService.multi_dftz(dfsjcs);  
565 - }  
566 -  
567 - @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)  
568 - public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){  
569 - return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);  
570 - }  
571 -  
572 - @RequestMapping(value="/history", method=RequestMethod.POST)  
573 - public Map<String,Object> historySave(ScheduleRealInfo sch){  
574 - return scheduleRealInfoService.historySave(sch);  
575 - }  
576 -  
577 -  
578 - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");  
579 - private final static long ONE_DAY = 1000 * 60 * 60 * 24;  
580 - /**  
581 - * 获取可编辑的历史班次日期  
582 - * @return  
583 - */  
584 - @RequestMapping("dateArray")  
585 - public List<String> dateArray(@RequestParam(defaultValue = "0") int c){  
586 - List<String> rs = new ArrayList<>();  
587 -  
588 - long t = System.currentTimeMillis();  
589 - if(c != 1)  
590 - t -= (ONE_DAY + (1000 * 60 * 60 * 6));  
591 - for(int i = 0; i < 3; i ++){  
592 - rs.add(fmtyyyyMMdd.print(t));  
593 - t -= ONE_DAY;  
594 - }  
595 - return rs;  
596 - }  
597 -  
598 - @RequestMapping(value = "svgAttr", method = RequestMethod.POST)  
599 - public Map<String, Object> svgAttr(@RequestParam String jsonStr){  
600 - return scheduleRealInfoService.svgAttr(jsonStr);  
601 - }  
602 -  
603 - @RequestMapping(value = "svgAttr", method = RequestMethod.GET)  
604 - public Map<String, Object> findSvgAttr(@RequestParam String idx){  
605 - return scheduleRealInfoService.findSvgAttr(idx);  
606 - }  
607 -  
608 - @RequestMapping(value = "addRemarks", method = RequestMethod.POST)  
609 - public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){  
610 - return scheduleRealInfoService.addRemarks(id, remarks);  
611 - }  
612 -  
613 - @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET)  
614 - public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){  
615 - return scheduleRealInfoService.scheduleDailyQp(line,date);  
616 - }  
617 -  
618 - @RequestMapping(value = "scheduleDailyExport", method = RequestMethod.GET)  
619 - public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){  
620 - return scheduleRealInfoService.scheduleDailyExport(map);  
621 - }  
622 -  
623 - @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)  
624 - public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){  
625 - return scheduleRealInfoService.exportWaybillMore(map);  
626 - }  
627 -  
628 - /**  
629 - * 获取当日计划排班 , 从计划表抓取数据  
630 - * @return  
631 - */  
632 - @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)  
633 - public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){  
634 - return scheduleRealInfoService.currentSchedulePlan(lineCode);  
635 - }  
636 -  
637 - @RequestMapping(value = "lpChangeMulti", method = RequestMethod.POST)  
638 - public Map<String, Object> lpChangeMulti(@RequestParam String leftIdx, @RequestParam String rightIdx,@RequestParam int type){  
639 - return scheduleRealInfoService.lpChangeMulti(leftIdx, rightIdx, type);  
640 - }  
641 -  
642 - /**  
643 - * 删除当日实际排班  
644 - * @return  
645 - */  
646 - @RequestMapping(value = "deleteRealSchedule", method = RequestMethod.POST)  
647 - public Map<String, Object> deleteRealSchedule(@RequestParam String lineCode){  
648 - return dayOfSchedule.deleteRealSchedule(lineCode);  
649 - }  
650 -  
651 - /**  
652 - * 从计划表重新加载当日排班  
653 - * @param lineCode  
654 - * @return  
655 - */  
656 - @RequestMapping(value = "reLoadRealSchedule", method = RequestMethod.POST)  
657 - public Map<String, Object> reLoadRealSchedule(@RequestParam String lineCode){  
658 - Map<String, Object> rs = new HashMap<>();  
659 - List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);  
660 - if(list != null && list.size() > 0){  
661 - rs.put("status", ResponseCode.ERROR);  
662 - rs.put("msg", "失败," + list.get(0).getXlName() + "当日存在实际排班,无法重新加载。");  
663 - return rs;  
664 - }  
665 -  
666 - int code = dayOfSchedule.reloadSch(lineCode);  
667 -  
668 - //重新按公司编码索引数据  
669 - dayOfSchedule.groupByGsbm();  
670 - rs.put("status", code==0? ResponseCode.SUCCESS: ResponseCode.ERROR);  
671 - return rs;  
672 - }  
673 -  
674 - /**  
675 - * 误点调整  
676 - * @param idx  
677 - * @param minute  
678 - * @return  
679 - */  
680 - @RequestMapping(value = "lateAdjust", method = RequestMethod.POST)  
681 - public Map<String, Object> lateAdjust(@RequestParam String idx,@RequestParam float minute ){  
682 - return scheduleRealInfoService.lateAdjust(idx, minute);  
683 - }  
684 -  
685 - /**  
686 - * 获取所有应发未到的班次  
687 - * @param idx  
688 - * @return  
689 - */  
690 - @RequestMapping(value = "allLate2")  
691 - public List<ScheduleRealInfo> allLate2(@RequestParam String idx){  
692 - return scheduleRealInfoService.allLate2(idx);  
693 - }  
694 -  
695 - /**  
696 - * 添加一个临加到历史库  
697 - * @param sch  
698 - * @return  
699 - */  
700 - @RequestMapping(value = "history/add", method = RequestMethod.POST)  
701 - public Map<String, Object> addToHistory(ScheduleRealInfo sch){  
702 - return scheduleRealInfoService.addToHistory(sch);  
703 - }  
704 -  
705 - /**  
706 - * 从历史库里删除临加班次  
707 - * @param sch  
708 - * @return  
709 - */  
710 - @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)  
711 - public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){  
712 - return scheduleRealInfoService.deleteToHistory(id);  
713 - }  
714 -  
715 - @RequestMapping(value = "isCircleQdz", method = RequestMethod.POST)  
716 - public Map<String, Object> isCircleQdz(@RequestParam String line, String nbbm, String ts, String qdzCode){  
717 - Map<String, Object> map =new HashMap<>();  
718 - map.put("isExist",scheduleRealInfoService.isCircleQdz(nbbm, ts, line, qdzCode));  
719 - return map;  
720 - }  
721 -  
722 - /**  
723 - * 从历史库里删除临加班次  
724 - * @param sch  
725 - * @return  
726 - */  
727 - @RequestMapping(value = "wxsb", method = RequestMethod.POST)  
728 - public Map<String, Object> deleteToHistory(@RequestParam Map<String, Object> param){  
729 - SysUser user = SecurityUtils.getCurrentUser();  
730 - String uname = user.getUserName();  
731 - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url"));  
732 - url.append("?nbbm=").append(param.get("nbbm")).append("&bxy=").append(uname).append("&bxbm=").append(param.get("bxType"));  
733 - // 分公司保存格式 分公司编码_公司编码  
734 - String val = BasicData.nbbm2FgsCompanyCodeMap.get(param.get("nbbm"));  
735 - String[] arr = val.split("_");  
736 - if (!"22".equals(arr[1])) {  
737 - Map<String, Object> res = new HashMap<String, Object>();  
738 - res.put("status", ResponseCode.ERROR);  
739 - res.put("msg", "除金高公司外暂未开通此功能");  
740 -  
741 - return res;  
742 - }  
743 - url.append("&fgs=").append(arr[0]);  
744 -  
745 - return request(url.toString());  
746 - }  
747 -  
748 - @SuppressWarnings("unchecked")  
749 - private static Map<String, Object> request(String url) {  
750 - Map<String, Object> res = new HashMap<String, Object>();  
751 - res.put("status", ResponseCode.SUCCESS);  
752 - InputStream in = null;  
753 - HttpURLConnection con = null;  
754 - try {  
755 - con = (HttpURLConnection)new URL(url).openConnection();  
756 - con.setRequestMethod("POST");  
757 - con.setRequestProperty("keep-alive", "true");  
758 - con.setRequestProperty("accept", "application/json");  
759 - con.setRequestProperty("content-type", "application/json");  
760 - con.setDoInput(true);  
761 - con.setReadTimeout(2500);  
762 - con.setConnectTimeout(2500);  
763 -  
764 - con.connect();  
765 - if (con.getResponseCode() == 200) {  
766 - in = con.getInputStream();  
767 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
768 - IOUtils.copy(in, bout); bout.close();  
769 - Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
770 - if (!"报修成功".equals(response.get("msg"))) {  
771 - res.put("status", ResponseCode.ERROR);  
772 - res.putAll(response);  
773 - }  
774 - }  
775 - } catch (IOException e) {  
776 - // TODO Auto-generated catch block  
777 - res.put("status", ResponseCode.ERROR);  
778 - res.put("msg", "调用上报接口异常");  
779 - } finally {  
780 - try {  
781 - if (in != null) in.close();  
782 - if (con != null) con.disconnect();  
783 - } catch (IOException e) {  
784 - // TODO Auto-generated catch block  
785 - e.printStackTrace();  
786 - }  
787 - }  
788 -  
789 - return res;  
790 - }  
791 -} 1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import java.io.ByteArrayOutputStream;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +import java.io.OutputStream;
  7 +import java.net.HttpURLConnection;
  8 +import java.net.URL;
  9 +import java.util.ArrayList;
  10 +import java.util.Collection;
  11 +import java.util.HashMap;
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +
  15 +import org.apache.commons.io.IOUtils;
  16 +import org.apache.commons.lang3.StringEscapeUtils;
  17 +import org.joda.time.format.DateTimeFormat;
  18 +import org.joda.time.format.DateTimeFormatter;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.web.bind.annotation.PathVariable;
  21 +import org.springframework.web.bind.annotation.RequestMapping;
  22 +import org.springframework.web.bind.annotation.RequestMethod;
  23 +import org.springframework.web.bind.annotation.RequestParam;
  24 +import org.springframework.web.bind.annotation.RestController;
  25 +
  26 +import com.alibaba.fastjson.JSONArray;
  27 +import com.bsth.common.ResponseCode;
  28 +import com.bsth.controller.BaseController;
  29 +import com.bsth.controller.realcontrol.dto.ChangePersonCar;
  30 +import com.bsth.controller.realcontrol.dto.DfsjChange;
  31 +import com.bsth.data.BasicData;
  32 +import com.bsth.data.schedule.DayOfSchedule;
  33 +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
  34 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  35 +import com.bsth.entity.schedule.SchedulePlanInfo;
  36 +import com.bsth.entity.sys.SysUser;
  37 +import com.bsth.security.util.SecurityUtils;
  38 +import com.bsth.service.realcontrol.ScheduleRealInfoService;
  39 +import com.bsth.util.ConfigUtil;
  40 +import com.fasterxml.jackson.databind.ObjectMapper;
  41 +
  42 +@RestController
  43 +@RequestMapping("/realSchedule")
  44 +public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
  45 +
  46 + @Autowired
  47 + ScheduleRealInfoService scheduleRealInfoService;
  48 +
  49 + @Autowired
  50 + DayOfSchedule dayOfSchedule;
  51 +
  52 + @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST)
  53 + public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){
  54 + return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm);
  55 + }
  56 +
  57 + @RequestMapping(value = "/lines")
  58 + public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {
  59 + return scheduleRealInfoService.findByLines(lines);
  60 + }
  61 +
  62 + @RequestMapping(value = "/car")
  63 + public List<ScheduleRealInfo> findByCar(String nbbm){
  64 + return dayOfSchedule.findByNbbm(nbbm);
  65 + }
  66 +
  67 + /**
  68 + *
  69 + * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
  70 + * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws
  71 + */
  72 + @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
  73 + public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
  74 + @RequestParam String dfsj,String bcType,
  75 + @RequestParam(defaultValue = "") String opType) {
  76 + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType, null);
  77 + }
  78 +
  79 + /**
  80 + *
  81 + * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔
  82 + */
  83 + @RequestMapping(value = "/destroy", method = RequestMethod.POST)
  84 + public Map<String, Object> destroy(@RequestParam String idsStr
  85 + /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,
  86 + @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {
  87 + return scheduleRealInfoService.destroy(idsStr, remarks, adjustExps, null);
  88 + }
  89 +
  90 + /**
  91 + *
  92 + * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws
  93 + */
  94 + @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)
  95 + public Map<String, String> carDeviceMapp() {
  96 + return BasicData.deviceId2NbbmMap.inverse();
  97 + }
  98 +
  99 + /**
  100 + *
  101 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param
  102 + * lineId @throws
  103 + */
  104 + @RequestMapping(value = "/driver", method = RequestMethod.GET)
  105 + public List<Map<String, String>> findDriverByLine(@RequestParam String lineCode) {
  106 + return scheduleRealInfoService.findDriverByLine(lineCode);
  107 + }
  108 +
  109 + /**
  110 + *
  111 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param
  112 + * lineId @throws
  113 + */
  114 + @RequestMapping(value = "/conductor", method = RequestMethod.GET)
  115 + public List<Map<String, String>> findConductorByLine(@RequestParam String lineCode) {
  116 + return scheduleRealInfoService.findConductorByLine(lineCode);
  117 + }
  118 +
  119 + /**
  120 + *
  121 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param
  122 + * lineId @throws
  123 + */
  124 + @RequestMapping(value = "/cars", method = RequestMethod.GET)
  125 + public List<Map<String, String>> findCarByLine(@RequestParam String lineCode) {
  126 + return scheduleRealInfoService.findCarByLine(lineCode);
  127 + }
  128 +
  129 + /**
  130 + *
  131 + * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws
  132 + */
  133 + @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)
  134 + public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {
  135 + return scheduleRealInfoService.sreachVehic(nbbm);
  136 + }
  137 + /**
  138 + *
  139 + * @Title: realOutAdjust
  140 + * @Description: TODO(实发调整)
  141 + * @param @param id 班次ID
  142 + * @param @param fcsjActual 实际发车时间 HH:mm
  143 + * @param @param remarks 备注
  144 + * @throws
  145 + */
  146 + @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)
  147 + public Map<String, Object> realOutAdjust(@RequestParam Long id, @RequestParam String fcsjActual,
  148 + @RequestParam String remarks) {
  149 + return scheduleRealInfoService.realOutAdjust(id, fcsjActual, remarks);
  150 + }
  151 +
  152 + /**
  153 + *
  154 + * @Title: revokeDestroy
  155 + * @Description: TODO(撤销烂班)
  156 + * @param @param id
  157 + * @throws
  158 + */
  159 + @RequestMapping(value = "/revokeDestroy", method = RequestMethod.POST)
  160 + public Map<String, Object> revokeDestroy(@RequestParam Long id){
  161 + return scheduleRealInfoService.revokeDestroy(id);
  162 + }
  163 +
  164 + /**
  165 + *
  166 + * @Title: revokeRealOutgo
  167 + * @Description: TODO(撤销实发)
  168 + * @param @param id
  169 + * @throws
  170 + */
  171 + @RequestMapping(value = "/revokeRealOutgo", method = RequestMethod.POST)
  172 + public Map<String, Object> revokeRealOutgo(@RequestParam Long id){
  173 + return scheduleRealInfoService.revokeRealOutgo(id);
  174 + }
  175 +
  176 + /**
  177 + * 撤销执行
  178 + * @param id
  179 + * @return
  180 + */
  181 + @RequestMapping(value = "/revokeRealArrive", method = RequestMethod.POST)
  182 + public Map<String, Object> revokeRealArrive(@RequestParam Long id){
  183 + return scheduleRealInfoService.revokeRealArrive(id);
  184 + }
  185 +
  186 + /**
  187 + *
  188 + * @Title: spaceAdjust
  189 + * @Description: TODO(间隔调整)
  190 + * @param @param ids 要调整的班次数组ID
  191 + * @param @param space 间隔
  192 + * @throws
  193 + */
  194 + @RequestMapping(value = "/spaceAdjust", method = RequestMethod.POST)
  195 + public Map<String, Object> spaceAdjust(Long[] ids, Integer space){
  196 + return scheduleRealInfoService.spaceAdjust(ids, space);
  197 + }
  198 +
  199 + /**
  200 + *
  201 + * @Title: schInfoFineTune
  202 + * @Description: TODO(发车信息微调)
  203 + * @param @param map
  204 + * @throws
  205 + */
  206 + @RequestMapping(value = "/schInfoFineTune", method = RequestMethod.POST)
  207 + public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){
  208 + return scheduleRealInfoService.schInfoFineTune(map);
  209 + }
  210 +
  211 + /**
  212 + *
  213 + * @Title: outgoAdjustAll
  214 + * @Description: TODO(批量待发调整)
  215 + * @param @param list
  216 + * @throws
  217 + */
  218 + @RequestMapping(value = "/outgoAdjustAll", method = RequestMethod.POST)
  219 + public Map<String, Object> outgoAdjustAll(@RequestParam String params){
  220 + //反转义
  221 + params = StringEscapeUtils.unescapeHtml4(params);
  222 + return scheduleRealInfoService.outgoAdjustAll(params);
  223 + }
  224 +
  225 + /**
  226 + *
  227 + * @Title: findByLineAndUpDown
  228 + * @Description: TODO(根据线路和走向获取班次)
  229 + * @param @param line
  230 + * @param @param upDown
  231 + */
  232 + @RequestMapping(value = "/findByLineAndUpDown")
  233 + public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){
  234 + return dayOfSchedule.findByLineAndUpDown(line, upDown);
  235 + }
  236 +
  237 + /**
  238 + *
  239 + * @Title: findRouteByLine
  240 + * @Description: TODO(获取线路的站点,路段路由)
  241 + * @param @param lineCode
  242 + * @throws
  243 + */
  244 + @RequestMapping(value = "/findRouteByLine")
  245 + public Map<String, Object> findRouteByLine(@RequestParam String lineCode){
  246 + return scheduleRealInfoService.findRouteByLine(lineCode);
  247 + }
  248 +
  249 + /**
  250 + *
  251 + * @Title: removeChildTask
  252 + * @Description: TODO(删除子任务)
  253 + * @param @param taskId 子任务ID
  254 + * @throws
  255 + */
  256 + @RequestMapping(value = "/childTask/{taskId}", method = RequestMethod.DELETE)
  257 + public Map<String, Object> removeChildTask(@PathVariable("taskId") Long taskId){
  258 + return scheduleRealInfoService.removeChildTask(taskId);
  259 + }
  260 +
  261 + /**
  262 + *
  263 + * @Title: findByLineCode
  264 + * @Description: TODO(根据线路获取班次信息)
  265 + * @param @param lineCode
  266 + */
  267 + @RequestMapping(value = "/lineCode/{lineCode}")
  268 + public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){
  269 + return dayOfSchedule.findByLineCode(lineCode);
  270 + }
  271 +
  272 + @RequestMapping(value = "/queryUserInfo")
  273 + public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,
  274 + @RequestParam String date,@RequestParam String state) {
  275 + return scheduleRealInfoService.queryUserInfo(line, date,state);
  276 + }
  277 +
  278 + @RequestMapping(value = "/queryUserInfoPx")
  279 + public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,
  280 + @RequestParam String date,@RequestParam String state,@RequestParam String type) {
  281 + return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);
  282 + }
  283 +
  284 + @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)
  285 + public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName,@RequestParam String jGh, @RequestParam String clZbh,
  286 + @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
  287 + return scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);
  288 + }
  289 +
  290 + @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)
  291 + public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh
  292 + ,@RequestParam String date,@RequestParam String line) {
  293 + return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);
  294 + }
  295 +
  296 +
  297 + @RequestMapping(value = "/dailyInfo")
  298 + public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
  299 + return scheduleRealInfoService.dailyInfo(line, date, type);
  300 + }
  301 +
  302 + @RequestMapping(value = "/historyMessage")
  303 + public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,
  304 + @RequestParam String code, @RequestParam String type) {
  305 + return scheduleRealInfoService.historyMessage(line, date, code, type);
  306 + }
  307 +
  308 + @RequestMapping(value="/findLine")
  309 + public List<Map<String,String>> findLine(@RequestParam String line){
  310 + return scheduleRealInfoService.findLine(line);
  311 + }
  312 +
  313 + @RequestMapping(value="/findKMBC",method = RequestMethod.GET)
  314 + public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  315 + ,@RequestParam String date,@RequestParam String line){
  316 + return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
  317 + }
  318 +
  319 + /**
  320 + * 路单公里统计 (闵行审计专用)
  321 + * @param jGh
  322 + * @param clZbh
  323 + * @param lpName
  324 + * @param date
  325 + * @param line
  326 + * @return
  327 + */
  328 + @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)
  329 + public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  330 + ,@RequestParam String date,@RequestParam String line){
  331 + return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);
  332 + }
  333 +
  334 + @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
  335 + public Map<String,Object> findKMBCQp(@RequestParam String clZbh
  336 + ,@RequestParam String date,@RequestParam String line){
  337 + return scheduleRealInfoService.findKMBCQp(clZbh,date,line);
  338 + }
  339 +
  340 + @RequestMapping(value="/findLpName")
  341 + public List<Map<String,String>> findLpName(@RequestParam String lpName){
  342 + return scheduleRealInfoService.findLpName(lpName);
  343 + }
  344 +
  345 + @RequestMapping(value = "/account")
  346 + public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,
  347 + @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {
  348 + return scheduleRealInfoService.account(line, date, code, xlName, type);
  349 + }
  350 +
  351 + @RequestMapping(value = "/accountPx")
  352 + public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,
  353 + @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {
  354 + return scheduleRealInfoService.accountPx(line, date, code, xlName, px);
  355 + }
  356 +
  357 + @RequestMapping(value = "/correctForm")
  358 + public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,
  359 + @RequestParam String endDate,
  360 + @RequestParam String lpName, @RequestParam String code,
  361 + @RequestParam String type,@RequestParam String changType) {
  362 + return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);
  363 + }
  364 + /**
  365 + * @Title queryListWaybill
  366 + * @Description 查询行车路单列表
  367 + * @param jName 驾驶员名字
  368 + * @param clZbh 车辆自编号(内部编号)
  369 + * @param lpName 路牌
  370 + * @return
  371 + */
  372 + @RequestMapping(value="/queryListWaybill",method = RequestMethod.GET)
  373 + public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  374 + ,@RequestParam String date,@RequestParam String line){
  375 + return scheduleRealInfoService.queryListWaybill(jGh, clZbh,lpName,date,line);
  376 + }
  377 +
  378 + /**
  379 + * @Title queryListWaybill
  380 + * @Description 查询行车路单列表(闵行审计专用路单)
  381 + * @param jName 驾驶员名字
  382 + * @param clZbh 车辆自编号(内部编号)
  383 + * @param lpName 路牌
  384 + * @return
  385 + */
  386 + @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)
  387 + public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
  388 + ,@RequestParam String date,@RequestParam String line){
  389 + return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);
  390 + }
  391 +
  392 + @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)
  393 + public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
  394 + @RequestParam String date,@RequestParam String line){
  395 + return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);
  396 + }
  397 +
  398 + @RequestMapping(value="/statisticsDaily")
  399 + public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,
  400 + @RequestParam String xlName, @RequestParam String type){
  401 + return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);
  402 + }
  403 +
  404 + @RequestMapping(value="/statisticsDaily_mh_2")
  405 + public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,
  406 + @RequestParam String xlName, @RequestParam String type){
  407 + return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);
  408 + }
  409 +
  410 + @RequestMapping(value="/statisticsDailyTj")
  411 + public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
  412 + String gsdm="";
  413 + if(map.get("gsdm")!=null){
  414 + gsdm=map.get("gsdm").toString();
  415 + }
  416 + String fgsdm="";
  417 + if(map.get("fgsdm")!=null){
  418 + fgsdm=map.get("fgsdm").toString();
  419 + }
  420 + String line="";
  421 + if(map.get("line")!=null){
  422 + line=map.get("line").toString();
  423 + }
  424 + String date="";
  425 + if(map.get("date")!=null){
  426 + date=map.get("date").toString();
  427 + }
  428 + String date2="";
  429 + if(map.get("date2")!=null){
  430 + date2=map.get("date2").toString();
  431 + }
  432 + String xlName="";
  433 + if(map.get("xlName")!=null){
  434 + xlName=map.get("xlName").toString();
  435 + }
  436 + String type="";
  437 + if(map.get("type")!=null){
  438 + type=map.get("type").toString();
  439 + }
  440 + String nature="0";
  441 + if(map.get("nature")!=null){
  442 + nature=map.get("nature").toString();
  443 + }
  444 + return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);
  445 + }
  446 +
  447 + /*
  448 + * 公里修正报表
  449 + */
  450 + @RequestMapping(value="/mileageReportTj")
  451 + public List<Map<String,Object>> mileageReport(@RequestParam Map<String, Object> map){
  452 + String gsdm="";
  453 + if(map.get("gsdm")!=null){
  454 + gsdm=map.get("gsdm").toString();
  455 + }
  456 + String fgsdm="";
  457 + if(map.get("fgsdm")!=null){
  458 + fgsdm=map.get("fgsdm").toString();
  459 + }
  460 + String line="";
  461 + if(map.get("line")!=null){
  462 + line=map.get("line").toString();
  463 + }
  464 + String date="";
  465 + if(map.get("date")!=null){
  466 + date=map.get("date").toString();
  467 + }
  468 + String date2="";
  469 + if(map.get("date2")!=null){
  470 + date2=map.get("date2").toString();
  471 + }
  472 + String xlName="";
  473 + if(map.get("xlName")!=null){
  474 + xlName=map.get("xlName").toString();
  475 + }
  476 + return scheduleRealInfoService.mileageReport(gsdm,fgsdm,line, date,date2);
  477 + }
  478 +
  479 + /*
  480 + * 班次修正报表
  481 + */
  482 + @RequestMapping(value="/scheduleCorrectionReport")
  483 + public List<Map<String,Object>> scheduleCorrectionReport(@RequestParam Map<String, Object> map){
  484 + String gsdm="";
  485 + if(map.get("gsdm")!=null){
  486 + gsdm=map.get("gsdm").toString();
  487 + }
  488 + String fgsdm="";
  489 + if(map.get("fgsdm")!=null){
  490 + fgsdm=map.get("fgsdm").toString();
  491 + }
  492 + String line="";
  493 + if(map.get("line")!=null){
  494 + line=map.get("line").toString();
  495 + }
  496 + String date="";
  497 + if(map.get("date")!=null){
  498 + date=map.get("date").toString();
  499 + }
  500 + String date2="";
  501 + if(map.get("date2")!=null){
  502 + date2=map.get("date2").toString();
  503 + }
  504 + String xlName="";
  505 + if(map.get("xlName")!=null){
  506 + xlName=map.get("xlName").toString();
  507 + }
  508 + return scheduleRealInfoService.scheduleCorrectionReport(gsdm,fgsdm,line, date,date2);
  509 + }
  510 +
  511 + @RequestMapping(value="/MapById",method = RequestMethod.GET)
  512 + public Map<String, Object> MapById(@RequestParam("id") Long id){
  513 + return scheduleRealInfoService.MapById(id);
  514 + }
  515 +
  516 + @RequestMapping(value="/MapByIdQp",method = RequestMethod.GET)
  517 + public Map<String, Object> MapByIdQp(@RequestParam("id") Long id){
  518 + return scheduleRealInfoService.MapByIdQp(id);
  519 + }
  520 +
  521 + /**
  522 + * @Title: scheduleDaily
  523 + * @Description: TODO(调度日报表)
  524 + * @param line 线路
  525 + * @param date 时间
  526 + * @return
  527 + */
  528 + @RequestMapping(value="/scheduleDaily")
  529 + public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
  530 + return scheduleRealInfoService.scheduleDaily(line,date);
  531 + }
  532 +
  533 + @RequestMapping(value="/realScheduleList")
  534 + public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){
  535 + return scheduleRealInfoService.realScheduleList(line,date);
  536 + }
  537 +
  538 + @RequestMapping(value="/realScheduleList_zrw")
  539 + public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){
  540 + return scheduleRealInfoService.realScheduleList_zrw(line,date);
  541 + }
  542 +
  543 + @RequestMapping(value="/realScheduleList_mh_2")
  544 + public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
  545 + return scheduleRealInfoService.realScheduleList_mh_2(line,date);
  546 + }
  547 +
  548 + @RequestMapping(value="/realScheduleListQp")
  549 + public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){
  550 + return scheduleRealInfoService.realScheduleListQp(line,date);
  551 + }
  552 +
  553 + @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)
  554 + public Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){
  555 + cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);
  556 + List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);
  557 + return scheduleRealInfoService.multi_tzrc(cpcs, null);
  558 + }
  559 +
  560 + @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)
  561 + public Map<String, Object> multi_dftz(@RequestParam String dcsJson){
  562 + dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);
  563 + List<DfsjChange> dfsjcs = JSONArray.parseArray(dcsJson, DfsjChange.class);
  564 + return scheduleRealInfoService.multi_dftz(dfsjcs);
  565 + }
  566 +
  567 + @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)
  568 + public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){
  569 + return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);
  570 + }
  571 +
  572 + @RequestMapping(value="/history", method=RequestMethod.POST)
  573 + public Map<String,Object> historySave(ScheduleRealInfo sch){
  574 + return scheduleRealInfoService.historySave(sch);
  575 + }
  576 +
  577 +
  578 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  579 + private final static long ONE_DAY = 1000 * 60 * 60 * 24;
  580 + /**
  581 + * 获取可编辑的历史班次日期
  582 + * @return
  583 + */
  584 + @RequestMapping("dateArray")
  585 + public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
  586 + List<String> rs = new ArrayList<>();
  587 +
  588 + long t = System.currentTimeMillis();
  589 + if(c != 1)
  590 + t -= (ONE_DAY + (1000 * 60 * 60 * 6));
  591 + for(int i = 0; i < 10; i ++){
  592 + rs.add(fmtyyyyMMdd.print(t));
  593 + t -= ONE_DAY;
  594 + }
  595 + return rs;
  596 + }
  597 +
  598 + @RequestMapping(value = "svgAttr", method = RequestMethod.POST)
  599 + public Map<String, Object> svgAttr(@RequestParam String jsonStr){
  600 + return scheduleRealInfoService.svgAttr(jsonStr);
  601 + }
  602 +
  603 + @RequestMapping(value = "svgAttr", method = RequestMethod.GET)
  604 + public Map<String, Object> findSvgAttr(@RequestParam String idx){
  605 + return scheduleRealInfoService.findSvgAttr(idx);
  606 + }
  607 +
  608 + @RequestMapping(value = "addRemarks", method = RequestMethod.POST)
  609 + public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){
  610 + return scheduleRealInfoService.addRemarks(id, remarks);
  611 + }
  612 +
  613 + @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET)
  614 + public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){
  615 + return scheduleRealInfoService.scheduleDailyQp(line,date);
  616 + }
  617 +
  618 + @RequestMapping(value = "scheduleDailyExport", method = RequestMethod.GET)
  619 + public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){
  620 + return scheduleRealInfoService.scheduleDailyExport(map);
  621 + }
  622 +
  623 + @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)
  624 + public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){
  625 + return scheduleRealInfoService.exportWaybillMore(map);
  626 + }
  627 +
  628 + /**
  629 + * 获取当日计划排班 , 从计划表抓取数据
  630 + * @return
  631 + */
  632 + @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)
  633 + public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){
  634 + return scheduleRealInfoService.currentSchedulePlan(lineCode);
  635 + }
  636 +
  637 + @RequestMapping(value = "lpChangeMulti", method = RequestMethod.POST)
  638 + public Map<String, Object> lpChangeMulti(@RequestParam String leftIdx, @RequestParam String rightIdx,@RequestParam int type){
  639 + return scheduleRealInfoService.lpChangeMulti(leftIdx, rightIdx, type);
  640 + }
  641 +
  642 + /**
  643 + * 删除当日实际排班
  644 + * @return
  645 + */
  646 + @RequestMapping(value = "deleteRealSchedule", method = RequestMethod.POST)
  647 + public Map<String, Object> deleteRealSchedule(@RequestParam String lineCode){
  648 + return dayOfSchedule.deleteRealSchedule(lineCode);
  649 + }
  650 +
  651 + /**
  652 + * 从计划表重新加载当日排班
  653 + * @param lineCode
  654 + * @return
  655 + */
  656 + @RequestMapping(value = "reLoadRealSchedule", method = RequestMethod.POST)
  657 + public Map<String, Object> reLoadRealSchedule(@RequestParam String lineCode){
  658 + Map<String, Object> rs = new HashMap<>();
  659 + List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);
  660 + if(list != null && list.size() > 0){
  661 + rs.put("status", ResponseCode.ERROR);
  662 + rs.put("msg", "失败," + list.get(0).getXlName() + "当日存在实际排班,无法重新加载。");
  663 + return rs;
  664 + }
  665 +
  666 + int code = dayOfSchedule.reloadSch(lineCode);
  667 +
  668 + //重新按公司编码索引数据
  669 + dayOfSchedule.groupByGsbm();
  670 + rs.put("status", code==0? ResponseCode.SUCCESS: ResponseCode.ERROR);
  671 + return rs;
  672 + }
  673 +
  674 + /**
  675 + * 误点调整
  676 + * @param idx
  677 + * @param minute
  678 + * @return
  679 + */
  680 + @RequestMapping(value = "lateAdjust", method = RequestMethod.POST)
  681 + public Map<String, Object> lateAdjust(@RequestParam String idx,@RequestParam float minute ){
  682 + return scheduleRealInfoService.lateAdjust(idx, minute);
  683 + }
  684 +
  685 + /**
  686 + * 获取所有应发未到的班次
  687 + * @param idx
  688 + * @return
  689 + */
  690 + @RequestMapping(value = "allLate2")
  691 + public List<ScheduleRealInfo> allLate2(@RequestParam String idx){
  692 + return scheduleRealInfoService.allLate2(idx);
  693 + }
  694 +
  695 + /**
  696 + * 添加一个临加到历史库
  697 + * @param sch
  698 + * @return
  699 + */
  700 + @RequestMapping(value = "history/add", method = RequestMethod.POST)
  701 + public Map<String, Object> addToHistory(ScheduleRealInfo sch){
  702 + return scheduleRealInfoService.addToHistory(sch);
  703 + }
  704 +
  705 + /**
  706 + * 从历史库里删除临加班次
  707 + * @param sch
  708 + * @return
  709 + */
  710 + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)
  711 + public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){
  712 + return scheduleRealInfoService.deleteToHistory(id);
  713 + }
  714 +
  715 + @RequestMapping(value = "isCircleQdz", method = RequestMethod.POST)
  716 + public Map<String, Object> isCircleQdz(@RequestParam String line, String nbbm, String ts, String qdzCode){
  717 + Map<String, Object> map =new HashMap<>();
  718 + map.put("isExist",scheduleRealInfoService.isCircleQdz(nbbm, ts, line, qdzCode));
  719 + return map;
  720 + }
  721 +
  722 + /**
  723 + * 从历史库里删除临加班次
  724 + * @param sch
  725 + * @return
  726 + */
  727 + @RequestMapping(value = "wxsb", method = RequestMethod.POST)
  728 + public Map<String, Object> deleteToHistory(@RequestParam Map<String, Object> param){
  729 + SysUser user = SecurityUtils.getCurrentUser();
  730 + String uname = user.getUserName();
  731 + StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url"));
  732 + url.append("?nbbm=").append(param.get("nbbm")).append("&bxy=").append(uname).append("&bxbm=").append(param.get("bxType"));
  733 + // 分公司保存格式 分公司编码_公司编码
  734 + String val = BasicData.nbbm2FgsCompanyCodeMap.get(param.get("nbbm"));
  735 + String[] arr = val.split("_");
  736 + if (!"22".equals(arr[1])) {
  737 + Map<String, Object> res = new HashMap<String, Object>();
  738 + res.put("status", ResponseCode.ERROR);
  739 + res.put("msg", "除金高公司外暂未开通此功能");
  740 +
  741 + return res;
  742 + }
  743 + url.append("&fgs=").append(arr[0]);
  744 +
  745 + return request(url.toString());
  746 + }
  747 +
  748 + @SuppressWarnings("unchecked")
  749 + private static Map<String, Object> request(String url) {
  750 + Map<String, Object> res = new HashMap<String, Object>();
  751 + res.put("status", ResponseCode.SUCCESS);
  752 + InputStream in = null;
  753 + HttpURLConnection con = null;
  754 + try {
  755 + con = (HttpURLConnection)new URL(url).openConnection();
  756 + con.setRequestMethod("POST");
  757 + con.setRequestProperty("keep-alive", "true");
  758 + con.setRequestProperty("accept", "application/json");
  759 + con.setRequestProperty("content-type", "application/json");
  760 + con.setDoInput(true);
  761 + con.setReadTimeout(2500);
  762 + con.setConnectTimeout(2500);
  763 +
  764 + con.connect();
  765 + if (con.getResponseCode() == 200) {
  766 + in = con.getInputStream();
  767 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  768 + IOUtils.copy(in, bout); bout.close();
  769 + Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  770 + if (!"报修成功".equals(response.get("msg"))) {
  771 + res.put("status", ResponseCode.ERROR);
  772 + res.putAll(response);
  773 + }
  774 + }
  775 + } catch (IOException e) {
  776 + // TODO Auto-generated catch block
  777 + res.put("status", ResponseCode.ERROR);
  778 + res.put("msg", "调用上报接口异常");
  779 + } finally {
  780 + try {
  781 + if (in != null) in.close();
  782 + if (con != null) con.disconnect();
  783 + } catch (IOException e) {
  784 + // TODO Auto-generated catch block
  785 + e.printStackTrace();
  786 + }
  787 + }
  788 +
  789 + return res;
  790 + }
  791 +}
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
1 -package com.bsth.data.gpsdata_v2;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.bsth.data.gpsdata_v2.cache.GpsCacheData;  
5 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
6 -import com.bsth.data.gpsdata_v2.handlers.*;  
7 -import com.google.common.collect.ArrayListMultimap;  
8 -import org.apache.commons.lang3.StringUtils;  
9 -import org.slf4j.Logger;  
10 -import org.slf4j.LoggerFactory;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.stereotype.Component;  
13 -  
14 -import java.util.*;  
15 -import java.util.concurrent.CountDownLatch;  
16 -import java.util.concurrent.ExecutorService;  
17 -import java.util.concurrent.Executors;  
18 -  
19 -/**  
20 - * 实时信号数据处理  
21 - * Created by panzhao on 2017/11/15.  
22 - */  
23 -@Component  
24 -public class DataHandleProcess {  
25 -  
26 - @Autowired  
27 - GpsStateProcess gpsStateProcess;  
28 - @Autowired  
29 - StationInsideProcess stationInsideProcess;  
30 - @Autowired  
31 - AbnormalStateProcess abnormalStateProcess;  
32 - @Autowired  
33 - InStationProcess inStationProcess;  
34 - @Autowired  
35 - OutStationProcess outStationProcess;  
36 - @Autowired  
37 - ReverseRouteProcess reverseRouteProcess;  
38 - @Autowired  
39 - GpsRealData gpsRealData;  
40 -  
41 -  
42 - static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class);  
43 -  
44 - final static int POOL_SIZE = 9;  
45 -  
46 - static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1);  
47 - public static CountDownLatch count;  
48 -  
49 - static long lastTime;  
50 -  
51 - public static boolean isBlock() {  
52 - return System.currentTimeMillis() - lastTime > 1000 * 30;  
53 - }  
54 -  
55 - public void handle(List<GpsEntity> list) {  
56 - try {  
57 - if (list.size() == 0)  
58 - return;  
59 - lastTime = System.currentTimeMillis();  
60 - //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑)  
61 - ArrayListMultimap multimap = ArrayListMultimap.create();  
62 - for (GpsEntity gps : list) {  
63 - multimap.put(gps.getDeviceId(), gps);  
64 - }  
65 - List<String> deviceList = new ArrayList<>(multimap.keySet());  
66 -  
67 - //数据均分给线程  
68 - ArrayListMultimap dataListMap = ArrayListMultimap.create();  
69 - int size = deviceList.size(), threadIndex = 0, threadSize = size / POOL_SIZE;  
70 - if(threadSize==0)  
71 - threadSize = size;  
72 - for (int i = 0; i < size; i++) {  
73 - if (i % threadSize == 0)  
74 - threadIndex++;  
75 - dataListMap.putAll(threadIndex, multimap.get(deviceList.get(i)));  
76 - }  
77 - Set<Integer> ks = dataListMap.keySet();  
78 - logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());  
79 - count = new CountDownLatch(ks.size());  
80 -  
81 - logger.info(JSON.toJSONString(ks));  
82 - for (Integer index : ks) {  
83 - threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));  
84 - }  
85 -  
86 -  
87 - //等待子线程结束  
88 - count.await();  
89 -  
90 - //加入实时gps对照  
91 - for (GpsEntity gps : list)  
92 - gpsRealData.put(gps);  
93 -  
94 - logger.info("time , " + (System.currentTimeMillis() - lastTime));  
95 - } catch (Exception e) {  
96 - logger.error("", e);  
97 - }  
98 - }  
99 -  
100 - static GpsComp comp = new GpsComp();  
101 -  
102 - public class SignalHandleThread implements Runnable {  
103 -  
104 - List<GpsEntity> list;  
105 - CountDownLatch count;  
106 -  
107 - SignalHandleThread(List<GpsEntity> gpsList, CountDownLatch count) {  
108 - this.list = gpsList;  
109 - this.count = count;  
110 - }  
111 -  
112 - @Override  
113 - public void run() {  
114 - try {  
115 - Collections.sort(list, comp);  
116 - GpsEntity gps;  
117 - for(int i = 0,len = list.size(); i< len ;i ++){  
118 - gps = list.get(i);  
119 -  
120 - try {  
121 - if (StringUtils.isEmpty(gps.getNbbm()))  
122 - continue;  
123 - if (Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20)  
124 - continue;  
125 -  
126 - gpsStateProcess.process(gps);//状态处理  
127 - stationInsideProcess.process(gps);//场站内外判定  
128 - reverseRouteProcess.process(gps);//反向路由处理  
129 - abnormalStateProcess.process(gps);//超速越界  
130 -  
131 - inStationProcess.process(gps);//进站  
132 - outStationProcess.process(gps);//出站  
133 -  
134 -  
135 - GpsCacheData.putGps(gps);//历史gps缓存  
136 - } catch (Throwable e) {  
137 - logger.error("", e);  
138 - }  
139 - }  
140 - } finally {  
141 - if (count != null)  
142 - count.countDown();  
143 - }  
144 - }  
145 - }  
146 -  
147 - public static class GpsComp implements Comparator<GpsEntity> {  
148 -  
149 - @Override  
150 - public int compare(GpsEntity g1, GpsEntity g2) {  
151 - return g1.getTimestamp().compareTo(g2.getTimestamp());  
152 - }  
153 - } 1 +package com.bsth.data.gpsdata_v2;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.handlers.*;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import org.apache.commons.lang3.StringUtils;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.*;
  15 +import java.util.concurrent.CountDownLatch;
  16 +import java.util.concurrent.ExecutorService;
  17 +import java.util.concurrent.Executors;
  18 +
  19 +/**
  20 + * 实时信号数据处理
  21 + * Created by panzhao on 2017/11/15.
  22 + */
  23 +@Component
  24 +public class DataHandleProcess {
  25 +
  26 + @Autowired
  27 + GpsStateProcess gpsStateProcess;
  28 + @Autowired
  29 + StationInsideProcess stationInsideProcess;
  30 + @Autowired
  31 + AbnormalStateProcess abnormalStateProcess;
  32 + @Autowired
  33 + InStationProcess inStationProcess;
  34 + @Autowired
  35 + OutStationProcess outStationProcess;
  36 + @Autowired
  37 + ReverseRouteProcess reverseRouteProcess;
  38 + @Autowired
  39 + GpsRealData gpsRealData;
  40 +
  41 +
  42 + static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class);
  43 +
  44 + final static int POOL_SIZE = 9;
  45 +
  46 + static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1);
  47 + public static CountDownLatch count;
  48 +
  49 + static long lastTime;
  50 +
  51 + public static boolean isBlock() {
  52 + return System.currentTimeMillis() - lastTime > 1000 * 30;
  53 + }
  54 +
  55 + public void handle(List<GpsEntity> list) {
  56 + try {
  57 + if (list.size() == 0)
  58 + return;
  59 + lastTime = System.currentTimeMillis();
  60 + //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑)
  61 + ArrayListMultimap multimap = ArrayListMultimap.create();
  62 + for (GpsEntity gps : list) {
  63 + multimap.put(gps.getDeviceId(), gps);
  64 + }
  65 + List<String> deviceList = new ArrayList<>(multimap.keySet());
  66 +
  67 + //数据均分给线程
  68 + ArrayListMultimap dataListMap = ArrayListMultimap.create();
  69 + int size = deviceList.size(), threadIndex = 0, threadSize = size / POOL_SIZE;
  70 + if(threadSize==0)
  71 + threadSize = size;
  72 + for (int i = 0; i < size; i++) {
  73 + if (i % threadSize == 0)
  74 + threadIndex++;
  75 + dataListMap.putAll(threadIndex, multimap.get(deviceList.get(i)));
  76 + }
  77 + Set<Integer> ks = dataListMap.keySet();
  78 + logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());
  79 + count = new CountDownLatch(ks.size());
  80 +
  81 + logger.info(JSON.toJSONString(ks));
  82 + for (Integer index : ks) {
  83 + threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));
  84 + }
  85 +
  86 +
  87 + //等待子线程结束
  88 + count.await();
  89 +
  90 + //加入实时gps对照
  91 + for (GpsEntity gps : list)
  92 + gpsRealData.put(gps);
  93 +
  94 + logger.info("time , " + (System.currentTimeMillis() - lastTime));
  95 + } catch (Exception e) {
  96 + logger.error("", e);
  97 + }
  98 + }
  99 +
  100 + static GpsComp comp = new GpsComp();
  101 +
  102 + public class SignalHandleThread implements Runnable {
  103 +
  104 + List<GpsEntity> list;
  105 + CountDownLatch count;
  106 +
  107 + SignalHandleThread(List<GpsEntity> gpsList, CountDownLatch count) {
  108 + this.list = gpsList;
  109 + this.count = count;
  110 + }
  111 +
  112 + @Override
  113 + public void run() {
  114 + try {
  115 + Collections.sort(list, comp);
  116 + GpsEntity gps;
  117 + for(int i = 0,len = list.size(); i< len ;i ++){
  118 + gps = list.get(i);
  119 +
  120 + try {
  121 + if (StringUtils.isEmpty(gps.getNbbm()))
  122 + continue;
  123 + if (Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20)
  124 + continue;
  125 +
  126 + gpsStateProcess.process(gps);//状态处理
  127 + stationInsideProcess.process(gps);//场站内外判定
  128 + reverseRouteProcess.process(gps);//反向路由处理
  129 + abnormalStateProcess.process(gps);//超速越界
  130 +
  131 + inStationProcess.process(gps);//进站
  132 + outStationProcess.process(gps);//出站
  133 +
  134 +
  135 + GpsCacheData.putGps(gps);//历史gps缓存
  136 + } catch (Throwable e) {
  137 + logger.error("", e);
  138 + }
  139 + }
  140 + } finally {
  141 + if (count != null)
  142 + count.countDown();
  143 + }
  144 + }
  145 + }
  146 +
  147 + public static class GpsComp implements Comparator<GpsEntity> {
  148 +
  149 + @Override
  150 + public int compare(GpsEntity g1, GpsEntity g2) {
  151 + return g1.getTimestamp().compareTo(g2.getTimestamp());
  152 + }
  153 + }
154 } 154 }
155 \ No newline at end of file 155 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java
1 -package com.bsth.data.gpsdata_v2.cache;  
2 -  
3 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
4 -import com.bsth.data.gpsdata_v2.entity.StationRoute;  
5 -import com.bsth.data.gpsdata_v2.entity.trail.GpsExecTrail;  
6 -import com.bsth.data.gpsdata_v2.utils.CircleQueue;  
7 -import com.google.common.collect.ArrayListMultimap;  
8 -import org.slf4j.Logger;  
9 -import org.slf4j.LoggerFactory;  
10 -  
11 -import java.util.*;  
12 -import java.util.concurrent.ConcurrentHashMap;  
13 -import java.util.concurrent.ConcurrentMap;  
14 -  
15 -/**  
16 - * gps 数据缓存  
17 - * Created by panzhao on 2017/11/15.  
18 - */  
19 -public class GpsCacheData {  
20 -  
21 - /**  
22 - * 每辆车缓存最后200条gps  
23 - */  
24 - private static final int CACHE_SIZE = 200;  
25 - private static ConcurrentMap<String, CircleQueue<GpsEntity>> gpsCacheMap = new ConcurrentHashMap<>();  
26 -  
27 - /**  
28 - * 车辆执行班次的详细 进出站数据  
29 - */  
30 - private static ArrayListMultimap<String, GpsExecTrail> trailListMultimap = ArrayListMultimap.create();  
31 -  
32 - static Logger logger = LoggerFactory.getLogger(GpsCacheData.class);  
33 -  
34 - public static CircleQueue<GpsEntity> getGps(String device) {  
35 - return gpsCacheMap.get(device);  
36 - }  
37 -  
38 - /**  
39 - * 清除车辆的轨迹数据  
40 - * @param nbbm  
41 - */  
42 - public static void remove(String nbbm){  
43 - //logger.info("清除车辆到离站轨迹, " + nbbm);  
44 - trailListMultimap.removeAll(nbbm);  
45 - }  
46 -  
47 - public static GpsExecTrail gpsExecTrail(String nbbm){  
48 - List<GpsExecTrail> list = trailListMultimap.get(nbbm);  
49 -  
50 - GpsExecTrail trail;  
51 - if(null == list || list.size() == 0  
52 - || list.get(list.size() - 1).isEnd()){  
53 - trail = new GpsExecTrail();  
54 -  
55 - trailListMultimap.put(nbbm, trail);  
56 - }  
57 - else{  
58 - trail = list.get(list.size() - 1);  
59 - }  
60 -  
61 - return trail;  
62 - }  
63 -  
64 - public static void out(GpsEntity gps){  
65 - GpsExecTrail trail = gpsExecTrail(gps.getNbbm());  
66 - trail.getSrs().add(gps);  
67 -  
68 - }  
69 -  
70 - public static void in(GpsEntity gps, boolean end){  
71 - GpsExecTrail trail = gpsExecTrail(gps.getNbbm());  
72 - trail.getSrs().add(gps);  
73 - trail.setEnd(end);  
74 - }  
75 -  
76 - public static GpsEntity getPrev(GpsEntity gps){  
77 - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());  
78 - if(queue != null)  
79 - return queue.getTail();  
80 - return null;  
81 - }  
82 -  
83 - public static void putGps(GpsEntity gps) {  
84 - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());  
85 - if (queue == null) {  
86 - queue = new CircleQueue<>(CACHE_SIZE);  
87 - gpsCacheMap.put(gps.getDeviceId(), queue);  
88 - }  
89 - queue.add(gps);  
90 - }  
91 -  
92 - public static void clear(String deviceId) {  
93 - try {  
94 - CircleQueue<GpsEntity> queue = gpsCacheMap.get(deviceId);  
95 - if (queue != null)  
96 - queue.clear();  
97 - } catch (Exception e) {  
98 - logger.error("", e);  
99 - }  
100 - }  
101 -  
102 - public static StationRoute prevStation(GpsEntity gps) {  
103 - List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());  
104 - if(null == trails || trails.size() == 0)  
105 - return null;  
106 -  
107 - GpsEntity prev;  
108 - for(int i = trails.size() - 1; i > 0; i--){  
109 - prev = trails.get(i).getSrs().peekLast();  
110 -  
111 - if(prev != null){  
112 - return GeoCacheData.getRouteCode(prev);  
113 - }  
114 - }  
115 - return null;  
116 - }  
117 -  
118 - /**  
119 - * 最后一段轨迹  
120 - * @param gps  
121 - * @return  
122 - */  
123 - public static int lastInTrailsSize(GpsEntity gps) {  
124 - //int size = 0;  
125 - List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());  
126 - if(null == trails || trails.size() == 0)  
127 - return 0;  
128 -  
129 - GpsExecTrail gs = trails.get(trails.size() - 1);  
130 - if(gs.isEnd())  
131 - return 0;  
132 -  
133 - Set<String> set = new HashSet<>();  
134 - for(GpsEntity g : gs.getSrs()){  
135 - if(g.getInstation() == 1)  
136 - set.add(g.getStation().getName());  
137 - }  
138 - return set.size();  
139 - }  
140 -  
141 - public static List<StationRoute> prevMultiStation(GpsEntity gps) {  
142 - List<StationRoute> rs = new ArrayList<>();  
143 - List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());  
144 - if(null == trails || trails.size() == 0)  
145 - return null;  
146 -  
147 - for(int i = trails.size() - 1; i > 0; i--){  
148 - rs.addAll(searchLinked(trails.get(i).getSrs(), gps.getUpDown()));  
149 - if(rs.size() > 3)  
150 - break;  
151 - }  
152 - return rs;  
153 - }  
154 -  
155 - private static List<StationRoute> searchLinked(LinkedList<GpsEntity> list, int upDown){  
156 - List<StationRoute> rs = new ArrayList<>();  
157 -  
158 - GpsEntity gps;  
159 - int prevCode=0;  
160 - for(int i = list.size() - 1; i > 0; i --){  
161 - gps = list.get(i);  
162 - if(gps.getInstation()!=1)  
163 - continue;  
164 -  
165 - if(gps.getUpDown() != upDown)  
166 - break;  
167 -  
168 - if(gps.getStation().getRouteSort() != prevCode)  
169 - rs.add(gps.getStation());  
170 -  
171 - prevCode = gps.getStation().getRouteSort();  
172 -  
173 - if(rs.size() >= 3)  
174 - break;  
175 - }  
176 - return rs;  
177 - }  
178 -} 1 +package com.bsth.data.gpsdata_v2.cache;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  5 +import com.bsth.data.gpsdata_v2.entity.trail.GpsExecTrail;
  6 +import com.bsth.data.gpsdata_v2.utils.CircleQueue;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +
  11 +import java.util.*;
  12 +import java.util.concurrent.ConcurrentHashMap;
  13 +import java.util.concurrent.ConcurrentMap;
  14 +import java.util.concurrent.CopyOnWriteArrayList;
  15 +
  16 +/**
  17 + * gps 数据缓存
  18 + * Created by panzhao on 2017/11/15.
  19 + */
  20 +public class GpsCacheData {
  21 +
  22 + /**
  23 + * 每辆车缓存最后200条gps
  24 + */
  25 + private static final int CACHE_SIZE = 200;
  26 + private static ConcurrentMap<String, CircleQueue<GpsEntity>> gpsCacheMap = new ConcurrentHashMap<>();
  27 +
  28 + /**
  29 + * 车辆执行班次的详细 进出站数据
  30 + */
  31 + //private static ArrayListMultimap<String, GpsExecTrail> trailListMultimap = ArrayListMultimap.create();
  32 + private static Map<String, List<GpsExecTrail>> trailListMultimap = new ConcurrentHashMap<>();
  33 +
  34 + static Logger logger = LoggerFactory.getLogger(GpsCacheData.class);
  35 +
  36 + public static CircleQueue<GpsEntity> getGps(String device) {
  37 + return gpsCacheMap.get(device);
  38 + }
  39 +
  40 + /**
  41 + * 清除车辆的轨迹数据
  42 + * @param nbbm
  43 + */
  44 + public static void remove(String nbbm){
  45 + //logger.info("清除车辆到离站轨迹, " + nbbm);
  46 + trailListMultimap.remove(nbbm);
  47 + }
  48 +
  49 + public static GpsExecTrail gpsExecTrail(String nbbm){
  50 + List<GpsExecTrail> list = trailListMultimap.get(nbbm);
  51 +
  52 + GpsExecTrail trail;
  53 + if (null == list || list.size() == 0 || list.get(list.size() - 1).isEnd()) {
  54 + if (null == list) {
  55 + list = new CopyOnWriteArrayList<>();
  56 + trailListMultimap.put(nbbm, list);
  57 + }
  58 + trail = new GpsExecTrail();
  59 + list.add(trail);
  60 + } else{
  61 + trail = list.get(list.size() - 1);
  62 + }
  63 +
  64 + return trail;
  65 + }
  66 +
  67 + public static void out(GpsEntity gps){
  68 + GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
  69 + trail.getSrs().add(gps);
  70 +
  71 + }
  72 +
  73 + public static void in(GpsEntity gps, boolean end){
  74 + GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
  75 + trail.getSrs().add(gps);
  76 + trail.setEnd(end);
  77 + }
  78 +
  79 + public static GpsEntity getPrev(GpsEntity gps){
  80 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
  81 + if(queue != null)
  82 + return queue.getTail();
  83 + return null;
  84 + }
  85 +
  86 + public static void putGps(GpsEntity gps) {
  87 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
  88 + if (queue == null) {
  89 + queue = new CircleQueue<>(CACHE_SIZE);
  90 + gpsCacheMap.put(gps.getDeviceId(), queue);
  91 + }
  92 + queue.add(gps);
  93 + }
  94 +
  95 + public static void clear(String deviceId) {
  96 + try {
  97 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(deviceId);
  98 + if (queue != null)
  99 + queue.clear();
  100 + } catch (Exception e) {
  101 + logger.error("", e);
  102 + }
  103 + }
  104 +
  105 + public static StationRoute prevStation(GpsEntity gps) {
  106 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  107 + if(null == trails || trails.size() == 0)
  108 + return null;
  109 +
  110 + GpsEntity prev;
  111 + for(int i = trails.size() - 1; i > 0; i--){
  112 + prev = trails.get(i).getSrs().peekLast();
  113 +
  114 + if(prev != null){
  115 + return GeoCacheData.getRouteCode(prev);
  116 + }
  117 + }
  118 + return null;
  119 + }
  120 +
  121 + /**
  122 + * 最后一段轨迹
  123 + * @param gps
  124 + * @return
  125 + */
  126 + public static int lastInTrailsSize(GpsEntity gps) {
  127 + //int size = 0;
  128 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  129 + if(null == trails || trails.size() == 0)
  130 + return 0;
  131 +
  132 + GpsExecTrail gs = trails.get(trails.size() - 1);
  133 + if(gs.isEnd())
  134 + return 0;
  135 +
  136 + Set<String> set = new HashSet<>();
  137 + for(GpsEntity g : gs.getSrs()){
  138 + if(g.getInstation() == 1)
  139 + set.add(g.getStation().getName());
  140 + }
  141 + return set.size();
  142 + }
  143 +
  144 + public static List<StationRoute> prevMultiStation(GpsEntity gps) {
  145 + List<StationRoute> rs = new ArrayList<>();
  146 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  147 + if(null == trails || trails.size() == 0)
  148 + return null;
  149 +
  150 + for(int i = trails.size() - 1; i > 0; i--){
  151 + rs.addAll(searchLinked(trails.get(i).getSrs(), gps.getUpDown()));
  152 + if(rs.size() > 3)
  153 + break;
  154 + }
  155 + return rs;
  156 + }
  157 +
  158 + private static List<StationRoute> searchLinked(LinkedList<GpsEntity> list, int upDown){
  159 + List<StationRoute> rs = new ArrayList<>();
  160 +
  161 + GpsEntity gps;
  162 + int prevCode=0;
  163 + for(int i = list.size() - 1; i > 0; i --){
  164 + gps = list.get(i);
  165 + if(gps.getInstation()!=1)
  166 + continue;
  167 +
  168 + if(gps.getUpDown() != upDown)
  169 + break;
  170 +
  171 + if(gps.getStation().getRouteSort() != prevCode)
  172 + rs.add(gps.getStation());
  173 +
  174 + prevCode = gps.getStation().getRouteSort();
  175 +
  176 + if(rs.size() >= 3)
  177 + break;
  178 + }
  179 + return rs;
  180 + }
  181 +}
src/main/java/com/bsth/entity/oil/Dlb.java
@@ -39,11 +39,13 @@ public class Dlb { @@ -39,11 +39,13 @@ public class Dlb {
39 private String jhsj; 39 private String jhsj;
40 //耗电 40 //耗电
41 private Double hd=0.0; 41 private Double hd=0.0;
  42 + //损耗
42 private Double sh=0.0; 43 private Double sh=0.0;
43 private String shyy; 44 private String shyy;
44 private Double zlc=0.0; 45 private Double zlc=0.0;
45 private int yhlx; 46 private int yhlx;
46 - 47 +
  48 + //当前存入百公里油耗
47 private Double ns=0.0; 49 private Double ns=0.0;
48 private Double fyylc=0.0; 50 private Double fyylc=0.0;
49 private Double jhzlc=0.0; 51 private Double jhzlc=0.0;
src/main/java/com/bsth/repository/oil/DlbRepository.java
@@ -26,13 +26,22 @@ public interface DlbRepository extends BaseRepository&lt;Dlb, Integer&gt;{ @@ -26,13 +26,22 @@ public interface DlbRepository extends BaseRepository&lt;Dlb, Integer&gt;{
26 List<Dlb> obtainYlbefore(String rq,String gsdm,String fgsdm,String xlbm,String nbbm); 26 List<Dlb> obtainYlbefore(String rq,String gsdm,String fgsdm,String xlbm,String nbbm);
27 /** 27 /**
28 * 当天DLB信息 28 * 当天DLB信息
29 - * @param rq 29 + * @param rq, xlbm(like)
30 * @return 30 * @return
31 */ 31 */
32 @Query(value="SELECT * FROM bsth_c_dlb where rq=?1 and ssgsdm like %?2% " 32 @Query(value="SELECT * FROM bsth_c_dlb where rq=?1 and ssgsdm like %?2% "
33 + " and fgsdm like %?3%" 33 + " and fgsdm like %?3%"
34 + " and xlbm like %?4% and nbbm like %?5% order by ?6 asc",nativeQuery=true) 34 + " and xlbm like %?4% and nbbm like %?5% order by ?6 asc",nativeQuery=true)
35 List<Dlb> obtainDl(String rq,String gsbm,String fgsdm,String xlbm,String nbbm,String px); 35 List<Dlb> obtainDl(String rq,String gsbm,String fgsdm,String xlbm,String nbbm,String px);
  36 + /**
  37 + * 当天DLB信息
  38 + * @param rq, xlbm(=)
  39 + * @return
  40 + */
  41 + @Query(value="SELECT * FROM bsth_c_dlb where rq=?1 and ssgsdm like %?2% "
  42 + + " and fgsdm like %?3%"
  43 + + " and xlbm = ?4 and nbbm like %?5% order by ?6 asc",nativeQuery=true)
  44 + List<Dlb> obtainDlEq(String rq,String gsbm,String fgsdm,String xlbm,String nbbm,String px);
36 45
37 @Query(value="select s from Dlb s " 46 @Query(value="select s from Dlb s "
38 + " where to_days(s.rq)=to_days(?1) " 47 + " where to_days(s.rq)=to_days(?1) "
src/main/java/com/bsth/service/calc/CalcDlbService.java 0 → 100644
  1 +package com.bsth.service.calc;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +/**
  7 + * Created by 20/05/27.
  8 + */
  9 +public interface CalcDlbService {
  10 +
  11 + public void impElectric(String date) throws Exception;
  12 +
  13 +}
src/main/java/com/bsth/service/calc/impl/CalcDlbServiceImpl.java 0 → 100644
  1 +package com.bsth.service.calc.impl;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.InputStreamReader;
  5 +import java.math.BigDecimal;
  6 +import java.net.HttpURLConnection;
  7 +import java.net.URL;
  8 +import java.sql.PreparedStatement;
  9 +import java.sql.ResultSet;
  10 +import java.sql.SQLException;
  11 +import java.text.SimpleDateFormat;
  12 +import java.util.ArrayList;
  13 +import java.util.Calendar;
  14 +import java.util.Collections;
  15 +import java.util.Comparator;
  16 +import java.util.Date;
  17 +import java.util.HashMap;
  18 +import java.util.HashSet;
  19 +import java.util.Iterator;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +import java.util.Set;
  23 +
  24 +import com.alibaba.fastjson.JSONObject;
  25 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  26 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  27 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  28 +import com.bsth.service.calc.CalcDlbService;
  29 +import com.bsth.util.Arith;
  30 +
  31 +import org.joda.time.format.DateTimeFormat;
  32 +import org.joda.time.format.DateTimeFormatter;
  33 +import org.slf4j.Logger;
  34 +import org.slf4j.LoggerFactory;
  35 +import org.springframework.beans.factory.annotation.Autowired;
  36 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  37 +import org.springframework.jdbc.core.JdbcTemplate;
  38 +import org.springframework.jdbc.core.RowMapper;
  39 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  40 +import org.springframework.stereotype.Service;
  41 +import org.springframework.transaction.TransactionDefinition;
  42 +import org.springframework.transaction.TransactionStatus;
  43 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  44 +
  45 +/**
  46 + * Created by 20/05/27.
  47 + */
  48 +@Service
  49 +public class CalcDlbServiceImpl implements CalcDlbService {
  50 +
  51 + @Autowired
  52 + JdbcTemplate jdbcTemplate;
  53 +
  54 + @Autowired
  55 + ScheduleRealInfoRepository scheRepository;
  56 +
  57 + Logger logger = LoggerFactory.getLogger(this.getClass());
  58 +
  59 + final DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  60 +
  61 +
  62 + /**
  63 + * @throws Exception
  64 + */
  65 + public void impElectric(String date) throws Exception{
  66 + try {
  67 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  68 + Calendar calendar2 = Calendar.getInstance();
  69 + calendar2.setTime(new Date());
  70 + int hours= calendar2.get(Calendar.HOUR_OF_DAY);
  71 +
  72 +// if(hoursC>=8 && hours<9){//每天8点到9点间执行
  73 + if(true){ //无更新时点限制
  74 + //查询所有车辆
  75 + String sql = "select inside_code,branche_company_code, ny_type from bsth_c_cars";
  76 +
  77 + List<Map<String, String>> listMap= jdbcTemplate.query(sql, new RowMapper<Map<String,String>>(){
  78 + @Override
  79 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  80 + Map<String, String> m=new HashMap<String, String>();
  81 + m.put("insideCode", rs.getString("inside_code"));
  82 + m.put("brancheCompanyCode", rs.getString("branche_company_code"));
  83 + m.put("nyType", rs.getString("ny_type"));
  84 + return m;
  85 + }
  86 + });
  87 + Map<String, String> map=new HashMap<String, String>();
  88 + Map<String, String> nyTypeMap=new HashMap<String, String>();
  89 + for (int i = 0; i < listMap.size(); i++) {
  90 + Map<String, String> m=listMap.get(i);
  91 + map.put(m.get("insideCode"), m.get("brancheCompanyCode"));
  92 + nyTypeMap.put(m.get("insideCode"), m.get("nyType"));
  93 + }
  94 +// Date dNow = new Date();
  95 +// Calendar calendar = Calendar.getInstance();
  96 +// calendar.setTime(dNow);
  97 +// calendar.add(Calendar.DAY_OF_MONTH, -1);
  98 +// Date dBefore = calendar.getTime();
  99 +// String date = sdf.format(dBefore);
  100 + String json = this.getHttpInterface("https://web.enneagon.com/exchange/pub/rest/vehicle/getJiaDingBusDailyData?scheduleDate="+date);
  101 + List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(json);
  102 + if(list.size()>0){
  103 + savePush(list, date, map);
  104 + }
  105 +
  106 + //第一步获取从排班表获取日期,人,车,线,路牌,里程
  107 + List<ScheduleRealInfo> findByDate = scheRepository.findByDate(date);
  108 + Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>();
  109 + for(ScheduleRealInfo s : findByDate){
  110 + String key = s.getGsBm() + "/" + s.getFgsBm() + "/" + s.getXlBm() + "/" + s.getLpName() + "/" + s.getClZbh() + "/" + s.getjGh();
  111 + if(!(keyMap.containsKey(key))){
  112 + keyMap.put(key, new ArrayList<ScheduleRealInfo>());
  113 + }
  114 + keyMap.get(key).add(s);
  115 + }
  116 +
  117 + List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();
  118 + List<Map<String, Object>> list2 = (List<Map<String, Object>>) JSONObject.parse(json);
  119 + Set<String> set = new HashSet<String>();
  120 + Map<String, List<Map<String, Object>>> keyMap1 = new HashMap<String, List<Map<String, Object>>>();
  121 + Map<String, List<Map<String, Object>>> keyMap2 = new HashMap<String, List<Map<String, Object>>>();
  122 +
  123 + for(String key : keyMap.keySet()){
  124 + Map<String, Object> m = new HashMap<String, Object>();
  125 + List<ScheduleRealInfo> list3 = keyMap.get(key);
  126 + double sjzgl = 0;
  127 + String gsName = "", fgsName = "", xlName = "", jName = "", red = "", fcsj = "";
  128 + for (ScheduleRealInfo scheduleRealInfo : list3) {
  129 +
  130 + //取最小的发车时间
  131 + String fcsjA = "", redA = "";
  132 + if(scheduleRealInfo.getFcsjActual() != null && scheduleRealInfo.getFcsjActual().trim().length() > 0){
  133 + fcsjA = scheduleRealInfo.getFcsjActual();
  134 + } else if(scheduleRealInfo.getFcsj() != null && scheduleRealInfo.getFcsj().trim().length() > 0){
  135 + fcsjA = scheduleRealInfo.getFcsj();
  136 + }
  137 + if(scheduleRealInfo.getRealExecDate() != null && scheduleRealInfo.getRealExecDate().trim().length() > 0){
  138 + redA = scheduleRealInfo.getRealExecDate();
  139 + } else {
  140 + redA = date;
  141 + }
  142 + if(fcsjA.trim().length() > 0){
  143 + if(fcsj.length() == 0 || dtf.parseMillis(redA+fcsjA) < dtf.parseMillis(red+fcsj)){
  144 + fcsj = fcsjA;
  145 + red = redA;
  146 + }
  147 + }
  148 +
  149 + if(scheduleRealInfo.getGsName() != null && scheduleRealInfo.getGsName().trim().length() > 0){
  150 + gsName = scheduleRealInfo.getGsName();
  151 + }
  152 + if(scheduleRealInfo.getFgsName() != null && scheduleRealInfo.getFgsName().trim().length() > 0){
  153 + fgsName = scheduleRealInfo.getFgsName();
  154 + }
  155 + if(scheduleRealInfo.getXlName() != null && scheduleRealInfo.getXlName().trim().length() > 0){
  156 + xlName = scheduleRealInfo.getXlName();
  157 + }
  158 + if(scheduleRealInfo.getjName() != null && scheduleRealInfo.getjName().trim().length() > 0){
  159 + jName = scheduleRealInfo.getjName();
  160 + }
  161 +
  162 + //开始算里程
  163 + if (!isInOut(scheduleRealInfo)) {
  164 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  165 + if(!scheduleRealInfo.isSflj()){
  166 + if(childTaskPlans.isEmpty()){
  167 + if(!scheduleRealInfo.isDestroy()){
  168 + //非子任务 实际里程
  169 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  170 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  171 + if(jhlc-jhlcOrig>0){
  172 + sjzgl=Arith.add(sjzgl,jhlcOrig);
  173 + }else{
  174 + sjzgl=Arith.add(sjzgl,jhlc);
  175 + }
  176 + }
  177 + //临加里程
  178 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  179 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  180 + double zjlc=Arith.sub(jhlc, jhlcOrig);
  181 + if(zjlc>0){
  182 + sjzgl=Arith.add(zjlc, sjzgl);
  183 + }
  184 + } else {
  185 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  186 + while (it.hasNext()) {
  187 + ChildTaskPlan childTaskPlan = it.next();
  188 + if(childTaskPlan.getMileageType().equals("service")
  189 + &&"正常".equals(childTaskPlan.getType1())
  190 + && childTaskPlan.getCcId()==null){
  191 + //子任务 实际里程
  192 + if (!childTaskPlan.isDestroy()) {
  193 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  194 + sjzgl=Arith.add(sjzgl,jhgl);
  195 + }
  196 + } else if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){
  197 + //空驶公里
  198 + if (!childTaskPlan.isDestroy()) {
  199 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  200 + sjzgl=Arith.add(sjzgl,jhgl);
  201 + }
  202 + } else if("service".equals(childTaskPlan.getMileageType())&&"临加".equals(childTaskPlan.getType1())
  203 + && childTaskPlan.getCcId()==null){
  204 + //临加里程
  205 + if (!childTaskPlan.isDestroy()) {
  206 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  207 + sjzgl=Arith.add(sjzgl,jhgl);
  208 + }
  209 + }
  210 + }
  211 + }
  212 + } else {
  213 + //临加里程
  214 + if(childTaskPlans.isEmpty()){
  215 + sjzgl=Arith.add(sjzgl,scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  216 + }else{
  217 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  218 + while (it.hasNext()) {
  219 + ChildTaskPlan childTaskPlan = it.next();
  220 + if(childTaskPlan.getMileageType().equals("service") && childTaskPlan.getCcId()==null){
  221 + if (!childTaskPlan.isDestroy()) {
  222 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  223 + sjzgl=Arith.add(sjzgl,jhgl);
  224 + }
  225 + }
  226 + }
  227 + }
  228 + }
  229 + } else {
  230 + //进出场里程
  231 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  232 + if(childTaskPlans.isEmpty()){
  233 + if(!scheduleRealInfo.isDestroy()){
  234 + sjzgl=Arith.add(sjzgl, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  235 + }
  236 + }else{
  237 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  238 + while (it.hasNext()) {
  239 + ChildTaskPlan childTaskPlan = it.next();
  240 + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){
  241 + if (!childTaskPlan.isDestroy()) {
  242 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  243 + sjzgl=Arith.add(sjzgl,jhgl);
  244 + }
  245 + }
  246 + }
  247 + }
  248 + }
  249 + }
  250 + String[] split = key.split("/");
  251 + m.put("red", red);
  252 + m.put("fcsj", fcsj);
  253 + m.put("gsName", gsName);
  254 + m.put("fgsName", fgsName);
  255 + m.put("date", date);
  256 + m.put("gsBm", split[0]);
  257 + m.put("fgsBm", split[1]);
  258 + m.put("xlBm", split[2]);
  259 + m.put("xlName", xlName);
  260 + m.put("lpName", split[3]);
  261 + m.put("clZbh", split[4]);
  262 + m.put("jGh", split[5]);
  263 + m.put("jName", jName);
  264 + m.put("sjzgl", sjzgl);
  265 + list1.add(m);
  266 + }
  267 +
  268 + //第二步根据日期,车辆匹配
  269 + for(Map<String, Object> m : list1){//里程
  270 + String key = m.get("date").toString() + "/" + m.get("clZbh").toString();
  271 + if(!(keyMap1.containsKey(key))){
  272 + keyMap1.put(key, new ArrayList<Map<String, Object>>());
  273 + }
  274 + keyMap1.get(key).add(m);
  275 + set.add(key);
  276 + }
  277 + for(Map<String, Object> m : list2){//加电量
  278 + String key = m.get("scheduleDate").toString() + "/" + m.get("insideCode").toString();
  279 + if(!(keyMap2.containsKey(key))){
  280 + keyMap2.put(key, new ArrayList<Map<String, Object>>());
  281 + }
  282 + keyMap2.get(key).add(m);
  283 + set.add(key);
  284 + }
  285 +
  286 + //第三步 一车多单进行拆分
  287 + final List<Map<String, Object>> list5 = new ArrayList<Map<String, Object>>();
  288 +
  289 + for(String key : set){
  290 +// Map<String, Object> resMap = new HashMap<String, Object>();
  291 + List<Map<String, Object>> list3 = keyMap1.get(key);
  292 + List<Map<String, Object>> list4 = keyMap2.get(key);
  293 +
  294 + double jdl = 0d;
  295 + if(list4 != null){
  296 + for(Map<String, Object> m : list4){
  297 + jdl = Arith.add(jdl, m.get("sum").toString());
  298 + }
  299 + }
  300 +
  301 + String clZbh = key.split("/")[1];
  302 + if(jdl < 0.01d){
  303 + if(nyTypeMap.get(clZbh) != null
  304 + && "1".equals(nyTypeMap.get(clZbh).toString()) //1:全电;2:油电混合
  305 + && "2".equals(nyTypeMap.get(clZbh).toString())){
  306 + //加电量为0情况下,只取电车
  307 + } else {
  308 + continue;
  309 + }
  310 + }
  311 +
  312 + if(list3 != null && list3.size() > 0){
  313 +
  314 + if(list3.size() > 1){ //多条时,排序
  315 + Collections.sort(list3, new Comparator<Map<String, Object>>() {
  316 + @Override
  317 + public int compare(Map<String, Object> c1, Map<String, Object> c2) {
  318 + String k1 = c1.get("red").toString() + c1.get("fcsj").toString();
  319 + String k2 = c2.get("red").toString() + c2.get("fcsj").toString();
  320 +
  321 + if(c1.get("fcsj").toString().length() == 0){
  322 + return -1;
  323 + }
  324 + if(c2.get("fcsj").toString().length() == 0){
  325 + return 1;
  326 + }
  327 +
  328 + long l1 = dtf.parseMillis(k1);
  329 + long l2 = dtf.parseMillis(k2);
  330 +
  331 + long diff = l1 - l2;
  332 + if (diff > 0l) {
  333 + return 1;
  334 + } else if (diff < 0l) {
  335 + return -1;
  336 + }
  337 + return 0; //相等为0
  338 + }
  339 + });
  340 + }
  341 +
  342 + double zgl = 0;
  343 + for(Map<String, Object> m : list3){
  344 + zgl = Arith.add(zgl, m.get("sjzgl").toString());
  345 + }
  346 + double jdl_ = Arith.add(0, jdl);//为保精度计算最后总数不变,一车多单情况最后一条直接用减剩下的值
  347 + for(int i = 0; i < list3.size(); i++){
  348 + Map<String, Object> m = list3.get(i);
  349 + m.put("jcsx", i + 1); //顺序
  350 +
  351 + if(i == (list3.size() - 1)){ //最后一条
  352 + m.put("jdl", jdl_);
  353 + } else {
  354 + if(m.get("sjzgl") != null && !("0".equals(m.get("sjzgl").toString()))){
  355 + double mul = Arith.mul(jdl, Arith.div(m.get("sjzgl").toString(), zgl, 2));
  356 + double div = Arith.div(mul, 1, 2); //除1,利用工具类以去除小数点
  357 + jdl_ = Arith.sub(jdl_, div);
  358 + m.put("jdl", div);
  359 + } else {
  360 + m.put("jdl", "0");
  361 + }
  362 + }
  363 +
  364 + if(m.get("sjzgl") != null && new BigDecimal(m.get("sjzgl").toString()).doubleValue() > 0d
  365 + && new BigDecimal(m.get("jdl").toString()).doubleValue() > 0d){
  366 + double mul = Arith.mul(Arith.div(m.get("jdl").toString(), m.get("sjzgl").toString(), 4), 100);
  367 + m.put("hdl",mul);
  368 + } else {
  369 + m.put("hdl", 0);
  370 + }
  371 + list5.add(m);
  372 + }
  373 + } else if(list4 != null && list4.size() > 0){
  374 + Map<String, Object> map2 = list4.get(0);
  375 + Map<String, Object> m = new HashMap<String, Object>();
  376 + m.put("fcsj", "");
  377 + m.put("jcsx", "1");
  378 + m.put("gsName", "");
  379 + m.put("fgsName", "");
  380 + m.put("date", date);
  381 + m.put("gsBm", "24");
  382 + m.put("fgsBm", map.get(map2.get("insideCode").toString())==null?"":map.get(map2.get("insideCode").toString()).toString());
  383 + m.put("xlBm", "");
  384 + m.put("xlName", "");
  385 + m.put("lpName", "");
  386 + m.put("clZbh", map2.get("insideCode").toString());
  387 + m.put("jGh", "");
  388 + m.put("jName", "");
  389 + m.put("sjzgl", 0); //总里程
  390 + m.put("jdl", jdl); //加电量(耗电量)
  391 + m.put("hdl", 0); //百公里耗电
  392 + list5.add(m);
  393 + }
  394 + }
  395 +
  396 + //第四部保存入库
  397 + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  398 + String createDate = sdf2.format(new Date());
  399 + for(Map<String, Object> m : list5){
  400 + m.put("created", "aotu"); //代表定时器自动生成
  401 + m.put("createDate", createDate);
  402 + }
  403 +// String deleteSql = "delete from bsth_c_hdl where date='" + date + "' and created = 'aotu'";
  404 + String deleteSql = "delete from bsth_c_dlb where rq = '" + date + "'";
  405 + jdbcTemplate.batchUpdate(deleteSql); //先删除这一天的数据
  406 +// String insertSql = "insert into bsth_c_hdl(gs_bm, fgs_bm, gs_name, fgs_name, date, nbbm, j_gh, j_name,"
  407 +// + " xl_bm, xl_name, lp_name, jdl, sjzgl, hdl, created, create_date) "
  408 +// + " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  409 + String insertSql = "insert into bsth_c_dlb(ssgsdm, fgsdm, rq, czcd, jzcd, nbbm, jsy, jname,"
  410 + + " xlbm, linename, lp, cdl, hd, zlc, ns, createtime, jhsj, jcsx, nylx, yhlx, jhbc, jhzbc,"
  411 + + " fyylc, jhfyylc, jhzlc, jzlc, sfkt, sh, sjbc, sjzbc) "
  412 + + " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  413 + jdbcTemplate.batchUpdate(insertSql, new BatchPreparedStatementSetter() {
  414 +
  415 + @Override
  416 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  417 + Map<String, Object> m = list5.get(i);
  418 + ps.setString(1, "24");
  419 + ps.setString(2, m.get("fgsBm").toString());
  420 + ps.setString(3, m.get("date").toString());
  421 + ps.setString(4, "100");
  422 + ps.setString(5, "100");
  423 + ps.setString(6, m.get("clZbh").toString());
  424 + ps.setString(7, m.get("jGh").toString());
  425 + ps.setString(8, m.get("jName").toString());
  426 + ps.setString(9, m.get("xlBm").toString());
  427 + ps.setString(10, m.get("xlName").toString());
  428 + ps.setString(11, m.get("lpName").toString());
  429 + ps.setString(12, m.get("jdl").toString());
  430 + ps.setString(13, m.get("jdl").toString());
  431 + ps.setString(14, m.get("sjzgl").toString());
  432 + ps.setString(15, m.get("hdl").toString());
  433 + ps.setString(16, m.get("createDate").toString());
  434 + ps.setString(17, m.get("fcsj").toString());
  435 + ps.setString(18, m.get("jcsx").toString());
  436 + ps.setString(19, "0");
  437 + ps.setString(20, "0");
  438 + ps.setString(21, "0");
  439 + ps.setString(22, "0");
  440 + ps.setString(23, "0");
  441 + ps.setString(24, "0");
  442 + ps.setString(25, "0");
  443 + ps.setString(26, "0");
  444 + ps.setString(27, "0");
  445 + ps.setString(28, "0");
  446 + ps.setString(29, "0");
  447 + ps.setString(30, "0");
  448 + }
  449 +
  450 + @Override
  451 + public int getBatchSize() {
  452 + return list5.size();
  453 + }
  454 + });
  455 + }
  456 + }catch (Exception e) {
  457 + // TODO Auto-generated catch block
  458 + throw e;
  459 + }finally{
  460 + logger.info("setDDRB:");
  461 + }
  462 + }
  463 +
  464 + private void savePush(final List<Map<String, Object>> list,final String rq,final Map<String, String> map) {
  465 + String sql = "insert into bsth_c_jdl(rq, gs_bm, fgs_bm,jdl, "
  466 + + " nbbm,adding_time,remarks) " +
  467 + " VALUES(?,?,?,?,?,?,?)";
  468 +
  469 + //编程式事务
  470 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  471 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  472 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  473 + TransactionStatus status = tran.getTransaction(def);
  474 + try {
  475 + String sql2="delete from bsth_c_jdl where rq='"+rq+"' and remarks='JKSJ'";
  476 + jdbcTemplate.batchUpdate(sql2);
  477 + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
  478 +
  479 + @Override
  480 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  481 + Map<String, Object> t = list.get(i);
  482 + ps.setString(1, t.get("scheduleDate").toString());
  483 + ps.setString(2, "24");
  484 + ps.setString(3, map.get(t.get("insideCode").toString())==null?"":map.get(t.get("insideCode").toString()).toString());
  485 + ps.setString(4, t.get("sum").toString());
  486 + ps.setString(5, t.get("insideCode").toString());
  487 + ps.setString(6, t.get("addingTime").toString());
  488 + ps.setString(7, "JKSJ"); //代表来源接口数据
  489 +
  490 + }
  491 +
  492 + @Override
  493 + public int getBatchSize() {
  494 + return list.size();
  495 + }
  496 + });
  497 +
  498 + tran.commit(status);
  499 + } catch (Exception e) {
  500 + tran.rollback(status);
  501 + logger.error("", e);
  502 + }
  503 + }
  504 +
  505 + public static boolean isInOut(ScheduleRealInfo s){
  506 + boolean fage=false;
  507 + if(s.getBcType().equals("in")){
  508 + fage=true;
  509 + }
  510 + if(s.getBcType().equals("out")){
  511 + fage=true;
  512 + }
  513 + if(s.getBcType().equals("ldks")){
  514 + fage=true;
  515 + }
  516 +
  517 + return fage;
  518 + }
  519 +
  520 + public static String getHttpInterface(String path){
  521 + BufferedReader in = null;
  522 + StringBuffer result = null;
  523 + try {
  524 + URL url = new URL(path);
  525 + //打开和url之间的连接
  526 + HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  527 + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  528 + connection.setRequestProperty("Charset", "utf-8");
  529 + connection.connect();
  530 +
  531 + result = new StringBuffer();
  532 + //读取URL的响应
  533 + in = new BufferedReader(new InputStreamReader(
  534 + connection.getInputStream(),"utf-8"));
  535 + String line;
  536 + while ((line = in.readLine()) != null) {
  537 +
  538 + result.append(line);
  539 + }
  540 + return result.toString();
  541 + } catch (Exception e) {
  542 + e.printStackTrace();
  543 + }finally {
  544 + try {
  545 + if (in != null) {
  546 + in.close();
  547 + }
  548 + } catch (Exception e2) {
  549 + e2.printStackTrace();
  550 + }
  551 + }
  552 + return null;
  553 + }
  554 +
  555 +}
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
@@ -2682,6 +2682,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -2682,6 +2682,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2682 double jzl = 0.0; 2682 double jzl = 0.0;
2683 double zlc = 0.0; 2683 double zlc = 0.0;
2684 String rylx=""; 2684 String rylx="";
  2685 + double ccyl_ = 0.0;
  2686 + double jcyl_ = 0.0;
  2687 + double yh_ = 0.0;
  2688 + double jzl_ = 0.0;
2685 // List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); 2689 // List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);
2686 // List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); 2690 // List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);
2687 List<Ylb> listYlb = ylbMap.get(jsy + nbbm); 2691 List<Ylb> listYlb = ylbMap.get(jsy + nbbm);
@@ -2690,57 +2694,105 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -2690,57 +2694,105 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2690 // List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh()); 2694 // List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh());
2691 List<Cars> listCars = carMap.get(s.getClZbh()); 2695 List<Cars> listCars = carMap.get(s.getClZbh());
2692 if (listCars != null && listCars.size() > 0) { 2696 if (listCars != null && listCars.size() > 0) {
2693 - if(listCars.get(0).getSfdc()!=null){  
2694 - if (listCars.get(0).getSfdc()) {  
2695 - type = 1;  
2696 - if(listDlb != null)  
2697 - for (int i = 0; i < listDlb.size(); i++) {  
2698 - Dlb d = listDlb.get(i);  
2699 - if (d.getLp() == null) {  
2700 - ccyl = Arith.add(ccyl, d.getCzcd());  
2701 - jcyl = Arith.add(jcyl, d.getJzcd());  
2702 - yh = Arith.add(yh, d.getHd());  
2703 - jzl = Arith.add(jzl, d.getCdl());  
2704 - zlc = Arith.add(zlc, d.getZlc());  
2705 - } else {  
2706 - if (d.getLp().equals(s.getLpName())) {  
2707 - ccyl = Arith.add(ccyl, d.getCzcd());  
2708 - jcyl = Arith.add(jcyl, d.getJzcd());  
2709 - yh = Arith.add(yh, d.getHd());  
2710 - jzl = Arith.add(jzl, d.getCdl());  
2711 - zlc = Arith.add(zlc, d.getZlc());  
2712 - }  
2713 - }  
2714 -  
2715 - }  
2716 - } else {  
2717 - type = 0;  
2718 - if(listYlb != null)  
2719 - for (int i = 0; i < listYlb.size(); i++) {  
2720 - Ylb y = listYlb.get(i);  
2721 - if (y.getLp() == null) {  
2722 - ccyl = Arith.add(ccyl, y.getCzyl());  
2723 - jcyl = Arith.add(jcyl, y.getJzyl());  
2724 - yh = Arith.add(yh, y.getYh());  
2725 - jzl = Arith.add(jzl, y.getJzl());  
2726 - zlc = Arith.add(zlc, y.getZlc());  
2727 - if(dMap.get(y.getRylx())!=null)  
2728 - rylx=dMap.get(y.getRylx()).toString();  
2729 - } else {  
2730 - if (y.getLp().equals(s.getLpName())) {  
2731 - ccyl = Arith.add(ccyl, y.getCzyl());  
2732 - jcyl = Arith.add(jcyl, y.getJzyl());  
2733 - yh = Arith.add(yh, y.getYh());  
2734 - jzl = Arith.add(jzl, y.getJzl());  
2735 - zlc = Arith.add(zlc, y.getZlc());  
2736 - if(dMap.get(y.getRylx())!=null)  
2737 - rylx=dMap.get(y.getRylx()).toString();  
2738 -  
2739 - }  
2740 - }  
2741 - }  
2742 - }  
2743 - } 2697 + if (listCars.get(0).getNyType() != null) {
  2698 + if ("1".equals(listCars.get(0).getNyType().toString())) { //全电
  2699 +// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  2700 + type = 1;
  2701 + if(listDlb != null){
  2702 + for (int i = 0; i < listDlb.size(); i++) {
  2703 + Dlb d = listDlb.get(i);
  2704 + if (d.getLp() == null) {
  2705 + ccyl = Arith.add(ccyl, d.getCzcd());
  2706 + jcyl = Arith.add(jcyl, d.getJzcd());
  2707 + yh = Arith.add(yh, d.getHd());
  2708 + jzl = Arith.add(jzl, d.getCdl());
  2709 + zlc = Arith.add(zlc, d.getZlc());
  2710 + } else {
  2711 + if (d.getLp().equals(s.getLpName())) {
  2712 + ccyl = Arith.add(ccyl, d.getCzcd());
  2713 + jcyl = Arith.add(jcyl, d.getJzcd());
  2714 + yh = Arith.add(yh, d.getHd());
  2715 + jzl = Arith.add(jzl, d.getCdl());
  2716 + zlc = Arith.add(zlc, d.getZlc());
  2717 + }
  2718 + }
  2719 + }
  2720 + }
  2721 + } else if("2".equals(listCars.get(0).getNyType().toString())){ //油点混合
  2722 +// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  2723 +// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  2724 + type = 2;
  2725 + if(listYlb != null){
  2726 + for (int i = 0; i < listYlb.size(); i++) {
  2727 + Ylb y = listYlb.get(i);
  2728 + if (y.getLp() == null) {
  2729 + ccyl = Arith.add(ccyl, y.getCzyl());
  2730 + jcyl = Arith.add(jcyl, y.getJzyl());
  2731 + yh = Arith.add(yh, y.getYh());
  2732 + jzl = Arith.add(jzl, y.getJzl());
  2733 + zlc = Arith.add(zlc, y.getZlc());
  2734 + if(dMap.get(y.getRylx())!=null)
  2735 + rylx =dMap.get(y.getRylx()).toString();
  2736 + } else {
  2737 + if (y.getLp().equals(s.getLpName())) {
  2738 + ccyl = Arith.add(ccyl, y.getCzyl());
  2739 + jcyl = Arith.add(jcyl, y.getJzyl());
  2740 + yh = Arith.add(yh, y.getYh());
  2741 + jzl = Arith.add(jzl, y.getJzl());
  2742 + zlc = Arith.add(zlc, y.getZlc());
  2743 + if(dMap.get(y.getRylx())!=null)
  2744 + rylx =dMap.get(y.getRylx()).toString();
  2745 + }
  2746 + }
  2747 + }
  2748 + }
  2749 + if(listDlb != null){
  2750 + for (int i = 0; i < listDlb.size(); i++) {
  2751 + Dlb d = listDlb.get(i);
  2752 + if (d.getLp() == null) {
  2753 + ccyl_ = Arith.add(ccyl_, d.getCzcd());
  2754 + jcyl_ = Arith.add(jcyl_, d.getJzcd());
  2755 + yh_ = Arith.add(yh_, d.getHd());
  2756 + jzl_ = Arith.add(jzl, d.getCdl());
  2757 + } else {
  2758 + if (d.getLp().equals(s.getLpName())) {
  2759 + ccyl_ = Arith.add(ccyl_, d.getCzcd());
  2760 + jcyl_ = Arith.add(jcyl_, d.getJzcd());
  2761 + yh_ = Arith.add(yh_, d.getHd());
  2762 + jzl_ = Arith.add(jzl_, d.getCdl());
  2763 + }
  2764 + }
  2765 + }
  2766 + }
  2767 + } else {
  2768 +// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  2769 + type = 0;
  2770 + if(listYlb != null){
  2771 + for (int i = 0; i < listYlb.size(); i++) {
  2772 + Ylb y = listYlb.get(i);
  2773 + if (y.getLp() == null) {
  2774 + ccyl = Arith.add(ccyl, y.getCzyl());
  2775 + jcyl = Arith.add(jcyl, y.getJzyl());
  2776 + yh = Arith.add(yh, y.getYh());
  2777 + jzl = Arith.add(jzl, y.getJzl());
  2778 + zlc = Arith.add(zlc, y.getZlc());
  2779 + if(dMap.get(y.getRylx())!=null)
  2780 + rylx =dMap.get(y.getRylx()).toString();
  2781 + } else {
  2782 + if (y.getLp().equals(s.getLpName())) {
  2783 + ccyl = Arith.add(ccyl, y.getCzyl());
  2784 + jcyl = Arith.add(jcyl, y.getJzyl());
  2785 + yh = Arith.add(yh, y.getYh());
  2786 + jzl = Arith.add(jzl, y.getJzl());
  2787 + zlc = Arith.add(zlc, y.getZlc());
  2788 + if(dMap.get(y.getRylx())!=null)
  2789 + rylx =dMap.get(y.getRylx()).toString();
  2790 + }
  2791 + }
  2792 + }
  2793 + }
  2794 + }
  2795 + }
2744 } 2796 }
2745 double jylc=ylbMapJylc.get(line+"-"+jGh+"-"+nbbm+"-"+lpName)==null?0.0:ylbMapJylc.get(line+"-"+jGh+"-"+nbbm+"-"+lpName); 2797 double jylc=ylbMapJylc.get(line+"-"+jGh+"-"+nbbm+"-"+lpName)==null?0.0:ylbMapJylc.get(line+"-"+jGh+"-"+nbbm+"-"+lpName);
2746 Map.put("jylc", jylc); 2798 Map.put("jylc", jylc);
@@ -2749,6 +2801,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -2749,6 +2801,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2749 Map.put("yh", yh); 2801 Map.put("yh", yh);
2750 Map.put("ccyl", ccyl); 2802 Map.put("ccyl", ccyl);
2751 Map.put("jcyl", jcyl); 2803 Map.put("jcyl", jcyl);
  2804 + Map.put("jzl_", jzl_);
  2805 + Map.put("yh_", yh_);
  2806 + Map.put("ccyl_", ccyl_);
  2807 + Map.put("jcyl_", jcyl_);
2752 Map.put("type", type); 2808 Map.put("type", type);
2753 Map.put("zlc", zlc); 2809 Map.put("zlc", zlc);
2754 Map.put("xlName", s.getXlName()); 2810 Map.put("xlName", s.getXlName());
@@ -2964,8 +3020,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -2964,8 +3020,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2964 String xls=""; 3020 String xls="";
2965 if(Map.get("type").toString().equals("0")){ 3021 if(Map.get("type").toString().equals("0")){
2966 xls="waybill_minhang.xls"; 3022 xls="waybill_minhang.xls";
2967 - }else{ 3023 + } else if(Map.get("type").toString().equals("1")){
2968 xls="waybill_minhang_dl.xls"; 3024 xls="waybill_minhang_dl.xls";
  3025 + } else {
  3026 + xls="waybill_minhang_yd.xls";
2969 } 3027 }
2970 Map.put("sheetName", jName + "-" + clZbh + "-" + lpName); 3028 Map.put("sheetName", jName + "-" + clZbh + "-" + lpName);
2971 ee.excelReplace(list1, new Object[]{Map}, path1 + "mould/"+xls, 3029 ee.excelReplace(list1, new Object[]{Map}, path1 + "mould/"+xls,
src/main/java/com/bsth/service/jdtest/impl/JdtestServiceImpl.java
@@ -14,13 +14,13 @@ import org.springframework.jdbc.core.JdbcTemplate; @@ -14,13 +14,13 @@ import org.springframework.jdbc.core.JdbcTemplate;
14 import org.springframework.jdbc.core.RowMapper; 14 import org.springframework.jdbc.core.RowMapper;
15 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
16 16
17 -import com.bsth.entity.mcy_forms.Daily;  
18 import com.bsth.entity.oil.Dlb; 17 import com.bsth.entity.oil.Dlb;
19 import com.bsth.entity.oil.Ylb; 18 import com.bsth.entity.oil.Ylb;
20 import com.bsth.entity.oil.Ylxxb; 19 import com.bsth.entity.oil.Ylxxb;
21 import com.bsth.entity.realcontrol.ChildTaskPlan; 20 import com.bsth.entity.realcontrol.ChildTaskPlan;
22 import com.bsth.entity.realcontrol.ScheduleRealInfo; 21 import com.bsth.entity.realcontrol.ScheduleRealInfo;
23 import com.bsth.entity.sys.Dictionary; 22 import com.bsth.entity.sys.Dictionary;
  23 +import com.bsth.repository.oil.DlbRepository;
24 import com.bsth.repository.oil.YlbRepository; 24 import com.bsth.repository.oil.YlbRepository;
25 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 25 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
26 import com.bsth.service.jdtest.JdtestService; 26 import com.bsth.service.jdtest.JdtestService;
@@ -40,6 +40,8 @@ public class JdtestServiceImpl implements JdtestService { @@ -40,6 +40,8 @@ public class JdtestServiceImpl implements JdtestService {
40 @Autowired 40 @Autowired
41 YlbRepository ylbRepository; 41 YlbRepository ylbRepository;
42 @Autowired 42 @Autowired
  43 + DlbRepository dlbRepository;
  44 + @Autowired
43 DictionaryService dictionaryService; 45 DictionaryService dictionaryService;
44 @Override 46 @Override
45 public List<Ylxxb> cwjyList(Map<String, Object> map) { 47 public List<Ylxxb> cwjyList(Map<String, Object> map) {
@@ -159,13 +161,26 @@ public class JdtestServiceImpl implements JdtestService { @@ -159,13 +161,26 @@ public class JdtestServiceImpl implements JdtestService {
159 }else{ 161 }else{
160 listYlb=ylbRepository.obtainYlEq(map.get("date").toString(), "", "", xlbm, "", "xlbm"); 162 listYlb=ylbRepository.obtainYlEq(map.get("date").toString(), "", "", xlbm, "", "xlbm");
161 } 163 }
162 - Map<String, Ylb> mapYlb=new HashMap<>(); 164 + Map<String, Ylb> mapYlb=new HashMap<String, Ylb>();
163 for (int j = 0; j < listYlb.size(); j++) { 165 for (int j = 0; j < listYlb.size(); j++) {
164 Ylb y=listYlb.get(j); 166 Ylb y=listYlb.get(j);
165 if(mapYlb.get(y.getXlbm()+y.getJsy()+y.getNbbm()+y.getLp())==null){ 167 if(mapYlb.get(y.getXlbm()+y.getJsy()+y.getNbbm()+y.getLp())==null){
166 mapYlb.put(y.getXlbm()+y.getJsy()+y.getNbbm()+y.getLp(), y); 168 mapYlb.put(y.getXlbm()+y.getJsy()+y.getNbbm()+y.getLp(), y);
167 } 169 }
168 } 170 }
  171 + List<Dlb> listDlb=new ArrayList<Dlb>();
  172 + if(xlbm.equals("")){
  173 + listDlb=dlbRepository.obtainDl(map.get("date").toString(), gsbm, fgsbm, xlbm, "", "xlbm");
  174 + }else{
  175 + listDlb=dlbRepository.obtainDlEq(map.get("date").toString(), "", "", xlbm, "", "xlbm");
  176 + }
  177 + Map<String, Dlb> mapDlb=new HashMap<String, Dlb>();
  178 + for (int i = 0; i < listDlb.size(); i++) {
  179 + Dlb d = listDlb.get(i);
  180 + if(mapDlb.get(d.getXlbm()+d.getJsy()+d.getNbbm()+d.getLp()) == null){
  181 + mapDlb.put(d.getXlbm()+d.getJsy()+d.getNbbm()+d.getLp(), d);
  182 + }
  183 + }
169 184
170 List<ScheduleRealInfo> sList; 185 List<ScheduleRealInfo> sList;
171 List<ScheduleRealInfo> jList; 186 List<ScheduleRealInfo> jList;
@@ -180,6 +195,7 @@ public class JdtestServiceImpl implements JdtestService { @@ -180,6 +195,7 @@ public class JdtestServiceImpl implements JdtestService {
180 double czyl_z=0.0; 195 double czyl_z=0.0;
181 double jzl_z=0.0; 196 double jzl_z=0.0;
182 double yh_z=0.0; 197 double yh_z=0.0;
  198 + double dh_z=0.0;
183 int jhbc_z=0; 199 int jhbc_z=0;
184 double jhlc_z=0.0; 200 double jhlc_z=0.0;
185 int sjbc_z=0; 201 int sjbc_z=0;
@@ -193,6 +209,7 @@ public class JdtestServiceImpl implements JdtestService { @@ -193,6 +209,7 @@ public class JdtestServiceImpl implements JdtestService {
193 double czyl_line=0.0; 209 double czyl_line=0.0;
194 double jzl_line=0.0; 210 double jzl_line=0.0;
195 double yh_line=0.0; 211 double yh_line=0.0;
  212 + double dh_line=0.0;
196 int jhbc_line=0; 213 int jhbc_line=0;
197 double jhlc_line=0.0; 214 double jhlc_line=0.0;
198 int sjbc_line=0; 215 int sjbc_line=0;
@@ -209,6 +226,7 @@ public class JdtestServiceImpl implements JdtestService { @@ -209,6 +226,7 @@ public class JdtestServiceImpl implements JdtestService {
209 double czyl=0.0; 226 double czyl=0.0;
210 double jzl=0.0; 227 double jzl=0.0;
211 double yh=0.0; 228 double yh=0.0;
  229 + double dh=0.0; //电耗
212 String rylx=""; 230 String rylx="";
213 if(mapYlb.get(m.get("xlBm").toString()+m.get("jGh").toString()+m.get("clZbh").toString()+m.get("lp").toString())!=null){ 231 if(mapYlb.get(m.get("xlBm").toString()+m.get("jGh").toString()+m.get("clZbh").toString()+m.get("lp").toString())!=null){
214 Ylb t=mapYlb.get(m.get("xlBm").toString()+m.get("jGh").toString()+m.get("clZbh").toString()+m.get("lp").toString()); 232 Ylb t=mapYlb.get(m.get("xlBm").toString()+m.get("jGh").toString()+m.get("clZbh").toString()+m.get("lp").toString());
@@ -225,6 +243,10 @@ public class JdtestServiceImpl implements JdtestService { @@ -225,6 +243,10 @@ public class JdtestServiceImpl implements JdtestService {
225 } 243 }
226 } 244 }
227 } 245 }
  246 + if(mapDlb.get(m.get("xlBm").toString()+m.get("jGh").toString()+m.get("clZbh").toString()+m.get("lp").toString())!=null){
  247 + Dlb d=mapDlb.get(m.get("xlBm").toString()+m.get("jGh").toString()+m.get("clZbh").toString()+m.get("lp").toString());
  248 + dh = d.getHd();
  249 + }
228 m.put("jylc",jylc); 250 m.put("jylc",jylc);
229 jylc_z=Arith.add(jylc, jylc_z); 251 jylc_z=Arith.add(jylc, jylc_z);
230 m.put("jzyl",jzyl); 252 m.put("jzyl",jzyl);
@@ -236,7 +258,8 @@ public class JdtestServiceImpl implements JdtestService { @@ -236,7 +258,8 @@ public class JdtestServiceImpl implements JdtestService {
236 m.put("yh", yh); 258 m.put("yh", yh);
237 yh_z=Arith.add(yh, yh_z); 259 yh_z=Arith.add(yh, yh_z);
238 m.put("rylx", rylx); 260 m.put("rylx", rylx);
239 - m.put("dh", ""); 261 + m.put("dh", dh);
  262 + dh_z=Arith.add(dh, dh_z);
240 for (int j = 0; j < lists.size(); j++) { 263 for (int j = 0; j < lists.size(); j++) {
241 ScheduleRealInfo s=lists.get(j); 264 ScheduleRealInfo s=lists.get(j);
242 if(m.get("xlBm").toString().equals(s.getXlBm()) && 265 if(m.get("xlBm").toString().equals(s.getXlBm()) &&
@@ -263,6 +286,7 @@ public class JdtestServiceImpl implements JdtestService { @@ -263,6 +286,7 @@ public class JdtestServiceImpl implements JdtestService {
263 double jhlc=culateMileageService.culateJhgl(jList); 286 double jhlc=culateMileageService.culateJhgl(jList);
264 jhlc_z=Arith.add(jhlc, jhlc_z); 287 jhlc_z=Arith.add(jhlc, jhlc_z);
265 int sjbc=culateMileageService.culateSjbc(sList, "")+culateMileageService.culateLjbc(sList, ""); 288 int sjbc=culateMileageService.culateSjbc(sList, "")+culateMileageService.culateLjbc(sList, "");
  289 + sjbc_z=sjbc+sjbc_z;
266 double ljgl=culateMileageService.culateLjgl(sList); 290 double ljgl=culateMileageService.culateLjgl(sList);
267 double sjgl=culateMileageService.culateSjgl(sList); 291 double sjgl=culateMileageService.culateSjgl(sList);
268 double sjzlc=Arith.add(ljgl, sjgl); 292 double sjzlc=Arith.add(ljgl, sjgl);
@@ -284,127 +308,154 @@ public class JdtestServiceImpl implements JdtestService { @@ -284,127 +308,154 @@ public class JdtestServiceImpl implements JdtestService {
284 m.put("zlc2", zlc2); 308 m.put("zlc2", zlc2);
285 listAll.add(m); 309 listAll.add(m);
286 //线路小计 310 //线路小计
287 - if (i < list.size() - 1) {  
288 - if ((list.get(i+1).get("xlBm").toString()).equals(list.get(i).get("xlBm").toString())) {  
289 - jylc_line=Arith.add(jylc_line, jylc);  
290 - jzyl_line=Arith.add(jzyl_line, jzyl);  
291 - czyl_line=Arith.add(czyl_line, czyl);  
292 - jzl_line=Arith.add(jzl_line, jzl);  
293 - yh_line=Arith.add(yh_line, yh);  
294 - jhbc_line=jhbc_line+jhbc;  
295 - jhlc_line=Arith.add(jhlc_line,jhlc);  
296 - sjbc_line=sjbc_line+sjbc;  
297 - sjzlc_line=Arith.add(sjzlc_line, sjzlc);  
298 - kszlc_line=Arith.add(kszlc_line,kszlc);  
299 - zlc_line=Arith.add(zlc_line, zlc);  
300 - zlc_line2=Arith.add(zlc_line2, zlc2);  
301 - } else {  
302 - jylc_line=Arith.add(jylc_line, jylc);  
303 - jzyl_line=Arith.add(jzyl_line, jzyl);  
304 - czyl_line=Arith.add(czyl_line, czyl);  
305 - jzl_line=Arith.add(jzl_line, jzl);  
306 - yh_line=Arith.add(yh_line, yh);  
307 - jhbc_line=jhbc_line+jhbc;  
308 - jhlc_line=Arith.add(jhlc_line,jhlc);  
309 - sjbc_line=sjbc_line+sjbc;  
310 - sjzlc_line=Arith.add(sjzlc_line, sjzlc);  
311 - kszlc_line=Arith.add(kszlc_line,kszlc);  
312 - zlc_line=Arith.add(zlc_line, zlc);  
313 - zlc_line2=Arith.add(zlc_line2, zlc2);  
314 -  
315 - Map<String, Object> mmm=new HashMap<>();  
316 - mmm.put("xlName", "小计");  
317 - mmm.put("lp", "");  
318 - mmm.put("jGh", "");  
319 - mmm.put("clZbh", "");  
320 - mmm.put("jName", "");  
321 - mmm.put("jhbc", jhbc_line);  
322 - mmm.put("jhlc", jhlc_line);  
323 - mmm.put("sjbc", sjbc_line);  
324 - mmm.put("sjzlc", sjzlc_line);  
325 - mmm.put("kszlc",kszlc_line);  
326 - mmm.put("jylc", jylc_line);  
327 - mmm.put("zlc", zlc_line);  
328 - mmm.put("zlc2", zlc_line2);  
329 - mmm.put("jzyl",jzyl_line);  
330 - mmm.put("czyl",czyl_line);  
331 - mmm.put("jzl", jzl_line);  
332 - mmm.put("yh", yh_line);  
333 - mmm.put("rylx", "");  
334 - mmm.put("dh","");  
335 - listAll.add(mmm);  
336 - jylc_line=0.0;  
337 - jzyl_line=0.0;  
338 - czyl_line=0.0;  
339 - jzl_line=0.0;  
340 - yh_line=0.0;  
341 - jhbc_line=0;  
342 - jhlc_line=0.0;  
343 - sjbc_line=0;  
344 - sjzlc_line=0.0;  
345 - kszlc_line=0.0;  
346 - zlc_line=0.0;  
347 - zlc_line2=0.0;  
348 - }  
349 - } else {  
350 - if ((list.get(i).get("xlBm").toString()).equals(list.get(i - 1).get("xlBm").toString())) {  
351 - jylc_line=Arith.add(jylc_line, jylc);  
352 - jzyl_line=Arith.add(jzyl_line, jzyl);  
353 - czyl_line=Arith.add(czyl_line, czyl);  
354 - jzl_line=Arith.add(jzl_line, jzl);  
355 - yh_line=Arith.add(yh_line, yh);  
356 - jhbc_line=jhbc_line+jhbc;  
357 - jhlc_line=Arith.add(jhlc_line,jhlc);  
358 - sjbc_line=sjbc_line+sjbc;  
359 - sjzlc_line=Arith.add(sjzlc_line, sjzlc);  
360 - kszlc_line=Arith.add(kszlc_line,kszlc);  
361 - zlc_line=Arith.add(zlc_line, zlc);  
362 - zlc_line2=Arith.add(zlc_line2, zlc2);  
363 - Map<String, Object> mmm=new HashMap<>();  
364 - mmm.put("xlName", "小计");  
365 - mmm.put("lp", "");  
366 - mmm.put("jGh", "");  
367 - mmm.put("clZbh", "");  
368 - mmm.put("jName", "");  
369 - mmm.put("jhbc", jhbc_line);  
370 - mmm.put("jhlc", jhlc_line);  
371 - mmm.put("sjbc", sjbc_line);  
372 - mmm.put("sjzlc", sjzlc_line);  
373 - mmm.put("kszlc",kszlc_line);  
374 - mmm.put("jylc", jylc_line);  
375 - mmm.put("zlc", zlc_line);  
376 - mmm.put("zlc2", zlc_line2);  
377 - mmm.put("jzyl",jzyl_line);  
378 - mmm.put("czyl",czyl_line);  
379 - mmm.put("jzl", jzl_line);  
380 - mmm.put("yh", yh_line);  
381 - mmm.put("rylx", "");  
382 - mmm.put("dh","");  
383 - listAll.add(mmm);  
384 - } else {  
385 -  
386 - Map<String, Object> mmm=new HashMap<>();  
387 - mmm.put("xlName", "小计");  
388 - mmm.put("lp", "");  
389 - mmm.put("jGh", "");  
390 - mmm.put("clZbh", "");  
391 - mmm.put("jName", "");  
392 - mmm.put("jhbc", jhbc);  
393 - mmm.put("jhlc", jhlc);  
394 - mmm.put("sjbc", sjbc);  
395 - mmm.put("sjzlc", sjzlc);  
396 - mmm.put("kszlc",kszlc);  
397 - mmm.put("jylc", jylc_line);  
398 - mmm.put("zlc", zlc);  
399 - mmm.put("zlc2", zlc2);  
400 - mmm.put("jzyl",jzyl);  
401 - mmm.put("czyl",czyl);  
402 - mmm.put("jzl", jzl);  
403 - mmm.put("yh", yh);  
404 - mmm.put("rylx", "");  
405 - mmm.put("dh","");  
406 - listAll.add(mmm);  
407 - } 311 + if(list.size()==1){
  312 + Map<String, Object> mmm=new HashMap<>();
  313 + mmm.put("xlName", "小计");
  314 + mmm.put("lp", "");
  315 + mmm.put("jGh", "");
  316 + mmm.put("clZbh", "");
  317 + mmm.put("jName", "");
  318 + mmm.put("jhbc", jhbc);
  319 + mmm.put("jhlc", jhlc);
  320 + mmm.put("sjbc", sjbc);
  321 + mmm.put("sjzlc", sjzlc);
  322 + mmm.put("kszlc",kszlc);
  323 + mmm.put("jylc", jylc_line);
  324 + mmm.put("zlc", zlc);
  325 + mmm.put("zlc2", zlc2);
  326 + mmm.put("jzyl",jzyl);
  327 + mmm.put("czyl",czyl);
  328 + mmm.put("jzl", jzl);
  329 + mmm.put("yh", yh);
  330 + mmm.put("rylx", "");
  331 + mmm.put("dh", dh);
  332 + listAll.add(mmm);
  333 + }else{
  334 + if (i < list.size() - 1) {
  335 + if ((list.get(i+1).get("xlBm").toString()).equals(list.get(i).get("xlBm").toString())) {
  336 + jylc_line=Arith.add(jylc_line, jylc);
  337 + jzyl_line=Arith.add(jzyl_line, jzyl);
  338 + czyl_line=Arith.add(czyl_line, czyl);
  339 + jzl_line=Arith.add(jzl_line, jzl);
  340 + yh_line=Arith.add(yh_line, yh);
  341 + dh_line=Arith.add(dh_line, dh);
  342 + jhbc_line=jhbc_line+jhbc;
  343 + jhlc_line=Arith.add(jhlc_line,jhlc);
  344 + sjbc_line=sjbc_line+sjbc;
  345 + sjzlc_line=Arith.add(sjzlc_line, sjzlc);
  346 + kszlc_line=Arith.add(kszlc_line,kszlc);
  347 + zlc_line=Arith.add(zlc_line, zlc);
  348 + zlc_line2=Arith.add(zlc_line2, zlc2);
  349 + } else {
  350 + jylc_line=Arith.add(jylc_line, jylc);
  351 + jzyl_line=Arith.add(jzyl_line, jzyl);
  352 + czyl_line=Arith.add(czyl_line, czyl);
  353 + jzl_line=Arith.add(jzl_line, jzl);
  354 + yh_line=Arith.add(yh_line, yh);
  355 + dh_line=Arith.add(dh_line, dh);
  356 + jhbc_line=jhbc_line+jhbc;
  357 + jhlc_line=Arith.add(jhlc_line,jhlc);
  358 + sjbc_line=sjbc_line+sjbc;
  359 + sjzlc_line=Arith.add(sjzlc_line, sjzlc);
  360 + kszlc_line=Arith.add(kszlc_line,kszlc);
  361 + zlc_line=Arith.add(zlc_line, zlc);
  362 + zlc_line2=Arith.add(zlc_line2, zlc2);
  363 +
  364 + Map<String, Object> mmm=new HashMap<>();
  365 + mmm.put("xlName", "小计");
  366 + mmm.put("lp", "");
  367 + mmm.put("jGh", "");
  368 + mmm.put("clZbh", "");
  369 + mmm.put("jName", "");
  370 + mmm.put("jhbc", jhbc_line);
  371 + mmm.put("jhlc", jhlc_line);
  372 + mmm.put("sjbc", sjbc_line);
  373 + mmm.put("sjzlc", sjzlc_line);
  374 + mmm.put("kszlc",kszlc_line);
  375 + mmm.put("jylc", jylc_line);
  376 + mmm.put("zlc", zlc_line);
  377 + mmm.put("zlc2", zlc_line2);
  378 + mmm.put("jzyl",jzyl_line);
  379 + mmm.put("czyl",czyl_line);
  380 + mmm.put("jzl", jzl_line);
  381 + mmm.put("yh", yh_line);
  382 + mmm.put("rylx", "");
  383 + mmm.put("dh", dh_line);
  384 + listAll.add(mmm);
  385 + jylc_line=0.0;
  386 + jzyl_line=0.0;
  387 + czyl_line=0.0;
  388 + jzl_line=0.0;
  389 + yh_line=0.0;
  390 + dh_line=0.0;
  391 + jhbc_line=0;
  392 + jhlc_line=0.0;
  393 + sjbc_line=0;
  394 + sjzlc_line=0.0;
  395 + kszlc_line=0.0;
  396 + zlc_line=0.0;
  397 + zlc_line2=0.0;
  398 + }
  399 + } else {
  400 + if ((list.get(i).get("xlBm").toString()).equals(list.get(i - 1).get("xlBm").toString())) {
  401 + jylc_line=Arith.add(jylc_line, jylc);
  402 + jzyl_line=Arith.add(jzyl_line, jzyl);
  403 + czyl_line=Arith.add(czyl_line, czyl);
  404 + jzl_line=Arith.add(jzl_line, jzl);
  405 + yh_line=Arith.add(yh_line, yh);
  406 + dh_line=Arith.add(dh_line, dh);
  407 + jhbc_line=jhbc_line+jhbc;
  408 + jhlc_line=Arith.add(jhlc_line,jhlc);
  409 + sjbc_line=sjbc_line+sjbc;
  410 + sjzlc_line=Arith.add(sjzlc_line, sjzlc);
  411 + kszlc_line=Arith.add(kszlc_line,kszlc);
  412 + zlc_line=Arith.add(zlc_line, zlc);
  413 + zlc_line2=Arith.add(zlc_line2, zlc2);
  414 + Map<String, Object> mmm=new HashMap<>();
  415 + mmm.put("xlName", "小计");
  416 + mmm.put("lp", "");
  417 + mmm.put("jGh", "");
  418 + mmm.put("clZbh", "");
  419 + mmm.put("jName", "");
  420 + mmm.put("jhbc", jhbc_line);
  421 + mmm.put("jhlc", jhlc_line);
  422 + mmm.put("sjbc", sjbc_line);
  423 + mmm.put("sjzlc", sjzlc_line);
  424 + mmm.put("kszlc",kszlc_line);
  425 + mmm.put("jylc", jylc_line);
  426 + mmm.put("zlc", zlc_line);
  427 + mmm.put("zlc2", zlc_line2);
  428 + mmm.put("jzyl",jzyl_line);
  429 + mmm.put("czyl",czyl_line);
  430 + mmm.put("jzl", jzl_line);
  431 + mmm.put("yh", yh_line);
  432 + mmm.put("rylx", "");
  433 + mmm.put("dh", dh_line);
  434 + listAll.add(mmm);
  435 + } else {
  436 + Map<String, Object> mmm=new HashMap<>();
  437 + mmm.put("xlName", "小计");
  438 + mmm.put("lp", "");
  439 + mmm.put("jGh", "");
  440 + mmm.put("clZbh", "");
  441 + mmm.put("jName", "");
  442 + mmm.put("jhbc", jhbc);
  443 + mmm.put("jhlc", jhlc);
  444 + mmm.put("sjbc", sjbc);
  445 + mmm.put("sjzlc", sjzlc);
  446 + mmm.put("kszlc",kszlc);
  447 + mmm.put("jylc", jylc_line);
  448 + mmm.put("zlc", zlc);
  449 + mmm.put("zlc2", zlc2);
  450 + mmm.put("jzyl",jzyl);
  451 + mmm.put("czyl",czyl);
  452 + mmm.put("jzl", jzl);
  453 + mmm.put("yh", yh);
  454 + mmm.put("rylx", "");
  455 + mmm.put("dh", dh);
  456 + listAll.add(mmm);
  457 + }
  458 + }
408 } 459 }
409 } 460 }
410 Map<String, Object> mmp=new HashMap<>(); 461 Map<String, Object> mmp=new HashMap<>();
@@ -426,7 +477,7 @@ public class JdtestServiceImpl implements JdtestService { @@ -426,7 +477,7 @@ public class JdtestServiceImpl implements JdtestService {
426 mmp.put("jzl", jzl_z); 477 mmp.put("jzl", jzl_z);
427 mmp.put("yh", yh_z); 478 mmp.put("yh", yh_z);
428 mmp.put("rylx", ""); 479 mmp.put("rylx", "");
429 - mmp.put("dh",""); 480 + mmp.put("dh", dh_z);
430 listAll.add(mmp); 481 listAll.add(mmp);
431 return listAll; 482 return listAll;
432 } 483 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -1162,8 +1162,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1162,8 +1162,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1162 String xls = ""; 1162 String xls = "";
1163 if (map.get("type").toString().equals("0")) { 1163 if (map.get("type").toString().equals("0")) {
1164 xls = "waybill_minhang.xls"; 1164 xls = "waybill_minhang.xls";
  1165 + } else if (map.get("type").toString().equals("1")){
  1166 + xls = "waybill_minhang_dl.xls";
1165 } else { 1167 } else {
1166 - xls = "waybill_minhang_dl.xls"; 1168 + xls = "waybill_minhang_yd.xls";
1167 } 1169 }
1168 1170
1169 1171
@@ -4610,10 +4612,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4610,10 +4612,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4610 Double jzl = 0.0; 4612 Double jzl = 0.0;
4611 Double zlc = 0.0; 4613 Double zlc = 0.0;
4612 String rylx=""; 4614 String rylx="";
  4615 + Double ccyl_ = 0.0;
  4616 + Double jcyl_ = 0.0;
  4617 + Double yh_ = 0.0;
  4618 + Double jzl_ = 0.0;
4613 List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh()); 4619 List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh());
4614 if (listCars.size() > 0) { 4620 if (listCars.size() > 0) {
4615 - if (listCars.get(0).getSfdc() != null) {  
4616 - if (listCars.get(0).getSfdc()) { 4621 + if (listCars.get(0).getNyType() != null) {
  4622 + if ("1".equals(listCars.get(0).getNyType().toString())) { //全电
4617 List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); 4623 List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
4618 type = 1; 4624 type = 1;
4619 for (int i = 0; i < listDlb.size(); i++) { 4625 for (int i = 0; i < listDlb.size(); i++) {
@@ -4633,7 +4639,48 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4633,7 +4639,48 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4633 zlc = Arith.add(zlc, d.getZlc()); 4639 zlc = Arith.add(zlc, d.getZlc());
4634 } 4640 }
4635 } 4641 }
4636 - 4642 + }
  4643 + } else if("2".equals(listCars.get(0).getNyType().toString())){ //油点混合
  4644 + List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  4645 + List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  4646 + type = 2;
  4647 + for (int i = 0; i < listYlb.size(); i++) {
  4648 + Ylb y = listYlb.get(i);
  4649 + if (y.getLp() == null) {
  4650 + ccyl = Arith.add(ccyl, y.getCzyl());
  4651 + jcyl = Arith.add(jcyl, y.getJzyl());
  4652 + yh = Arith.add(yh, y.getYh());
  4653 + jzl = Arith.add(jzl, y.getJzl());
  4654 + zlc = Arith.add(zlc, y.getZlc());
  4655 + if(dMap.get(y.getRylx())!=null)
  4656 + rylx =dMap.get(y.getRylx()).toString();
  4657 + } else {
  4658 + if (y.getLp().equals(s.getLpName())) {
  4659 + ccyl = Arith.add(ccyl, y.getCzyl());
  4660 + jcyl = Arith.add(jcyl, y.getJzyl());
  4661 + yh = Arith.add(yh, y.getYh());
  4662 + jzl = Arith.add(jzl, y.getJzl());
  4663 + zlc = Arith.add(zlc, y.getZlc());
  4664 + if(dMap.get(y.getRylx())!=null)
  4665 + rylx =dMap.get(y.getRylx()).toString();
  4666 + }
  4667 + }
  4668 + }
  4669 + for (int i = 0; i < listDlb.size(); i++) {
  4670 + Dlb d = listDlb.get(i);
  4671 + if (d.getLp() == null) {
  4672 + ccyl_ = Arith.add(ccyl_, d.getCzcd());
  4673 + jcyl_ = Arith.add(jcyl_, d.getJzcd());
  4674 + yh_ = Arith.add(yh_, d.getHd());
  4675 + jzl_ = Arith.add(jzl, d.getCdl());
  4676 + } else {
  4677 + if (d.getLp().equals(s.getLpName())) {
  4678 + ccyl_ = Arith.add(ccyl_, d.getCzcd());
  4679 + jcyl_ = Arith.add(jcyl_, d.getJzcd());
  4680 + yh_ = Arith.add(yh_, d.getHd());
  4681 + jzl_ = Arith.add(jzl_, d.getCdl());
  4682 + }
  4683 + }
4637 } 4684 }
4638 } else { 4685 } else {
4639 List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); 4686 List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
@@ -4661,6 +4708,49 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4661,6 +4708,49 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4661 } 4708 }
4662 } 4709 }
4663 } 4710 }
  4711 + } else {
  4712 + //油点混合
  4713 + List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  4714 + List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  4715 + type = 2;
  4716 + for (int i = 0; i < listYlb.size(); i++) {
  4717 + Ylb y = listYlb.get(i);
  4718 + if (y.getLp() == null) {
  4719 + ccyl = Arith.add(ccyl, y.getCzyl());
  4720 + jcyl = Arith.add(jcyl, y.getJzyl());
  4721 + yh = Arith.add(yh, y.getYh());
  4722 + jzl = Arith.add(jzl, y.getJzl());
  4723 + zlc = Arith.add(zlc, y.getZlc());
  4724 + if(dMap.get(y.getRylx())!=null)
  4725 + rylx =dMap.get(y.getRylx()).toString();
  4726 + } else {
  4727 + if (y.getLp().equals(s.getLpName())) {
  4728 + ccyl = Arith.add(ccyl, y.getCzyl());
  4729 + jcyl = Arith.add(jcyl, y.getJzyl());
  4730 + yh = Arith.add(yh, y.getYh());
  4731 + jzl = Arith.add(jzl, y.getJzl());
  4732 + zlc = Arith.add(zlc, y.getZlc());
  4733 + if(dMap.get(y.getRylx())!=null)
  4734 + rylx =dMap.get(y.getRylx()).toString();
  4735 + }
  4736 + }
  4737 + }
  4738 + for (int i = 0; i < listDlb.size(); i++) {
  4739 + Dlb d = listDlb.get(i);
  4740 + if (d.getLp() == null) {
  4741 + ccyl_ = Arith.add(ccyl_, d.getCzcd());
  4742 + jcyl_ = Arith.add(jcyl_, d.getJzcd());
  4743 + yh_ = Arith.add(yh_, d.getHd());
  4744 + jzl_ = Arith.add(jzl, d.getCdl());
  4745 + } else {
  4746 + if (d.getLp().equals(s.getLpName())) {
  4747 + ccyl_ = Arith.add(ccyl_, d.getCzcd());
  4748 + jcyl_ = Arith.add(jcyl_, d.getJzcd());
  4749 + yh_ = Arith.add(yh_, d.getHd());
  4750 + jzl_ = Arith.add(jzl_, d.getCdl());
  4751 + }
  4752 + }
  4753 + }
4664 } 4754 }
4665 } 4755 }
4666 4756
@@ -4669,6 +4759,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4669,6 +4759,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4669 map.put("yh", yh); 4759 map.put("yh", yh);
4670 map.put("ccyl", ccyl); 4760 map.put("ccyl", ccyl);
4671 map.put("jcyl", jcyl); 4761 map.put("jcyl", jcyl);
  4762 + map.put("jzl_", jzl_);
  4763 + map.put("yh_", yh_);
  4764 + map.put("ccyl_", ccyl_);
  4765 + map.put("jcyl_", jcyl_);
4672 map.put("type", type); 4766 map.put("type", type);
4673 map.put("zlc", zlc); 4767 map.put("zlc", zlc);
4674 map.put("xlName", s.getXlName()); 4768 map.put("xlName", s.getXlName());
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
@@ -348,7 +348,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail @@ -348,7 +348,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
348 for (int r = 1; r < sheet.getRows(); r++) { 348 for (int r = 1; r < sheet.getRows(); r++) {
349 List<FcInfo> fcInfos = new ArrayList<>(); 349 List<FcInfo> fcInfos = new ArrayList<>();
350 // 每行第一列都是路牌 350 // 每行第一列都是路牌
351 - fcInfos.add(new FcInfo(null, null, sheet.getCell(0, r).getContents(), null, null, null, null, null)); // 用fcsj放置路牌显示 351 + fcInfos.add(new FcInfo(null, null, sheet.getCell(0, r).getContents(), null, null, null, null, null, null)); // 用fcsj放置路牌显示
352 352
353 int bc_ks = 0; // 空驶班次 353 int bc_ks = 0; // 空驶班次
354 int bc_yy = 0; // 营运班次 354 int bc_yy = 0; // 营运班次
@@ -373,7 +373,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail @@ -373,7 +373,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
373 373
374 String ists = content == null ? "" : content[9]; // 是否停驶 374 String ists = content == null ? "" : content[9]; // 是否停驶
375 375
376 - FcInfo fcInfo = new FcInfo(ttdid_str, bctype, fcsj, xldir, isfb, qdzCode, zdzCode, ists); 376 + String bcsj = content == null ? "" : content[10]; // 班次时间
  377 +
  378 + FcInfo fcInfo = new FcInfo(ttdid_str, bctype, fcsj, xldir, isfb, qdzCode, zdzCode, ists, bcsj);
377 379
378 if (StringUtils.isNotEmpty(fzdname)) 380 if (StringUtils.isNotEmpty(fzdname))
379 headarrays[c] = fzdname; 381 headarrays[c] = fzdname;
@@ -407,10 +409,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail @@ -407,10 +409,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
407 } 409 }
408 410
409 // 添加一列 空驶班次/空驶里程,fcsj放置数据 411 // 添加一列 空驶班次/空驶里程,fcsj放置数据
410 - fcInfos.add(new FcInfo(null, null, String.format("%d/%.3f", bc_ks, lc_ks), null, null, null, null, null)); 412 + fcInfos.add(new FcInfo(null, null, String.format("%d/%.3f", bc_ks, lc_ks), null, null, null, null, null, null));
411 413
412 // 添加一列 营运班次/营运里程,fcsj放置数据 414 // 添加一列 营运班次/营运里程,fcsj放置数据
413 - fcInfos.add(new FcInfo(null, null, String.format("%d/%.3f", bc_yy, lc_yy), null, null, null, null, null)); 415 + fcInfos.add(new FcInfo(null, null, String.format("%d/%.3f", bc_yy, lc_yy), null, null, null, null, null, null));
414 416
415 editInfo.getContents().add(fcInfos); 417 editInfo.getContents().add(fcInfos);
416 } 418 }
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailForEdit.java
@@ -31,6 +31,8 @@ public interface TTInfoDetailForEdit { @@ -31,6 +31,8 @@ public interface TTInfoDetailForEdit {
31 private String zdzCode; 31 private String zdzCode;
32 /** 是否停驶 */ 32 /** 是否停驶 */
33 private Boolean ists; 33 private Boolean ists;
  34 + /** 班次时间 */
  35 + private String bcsj;
34 36
35 public FcInfo() { 37 public FcInfo() {
36 } 38 }
@@ -43,7 +45,8 @@ public interface TTInfoDetailForEdit { @@ -43,7 +45,8 @@ public interface TTInfoDetailForEdit {
43 String isfb, 45 String isfb,
44 String qdzCode, 46 String qdzCode,
45 String zdzCode, 47 String zdzCode,
46 - String ists) { 48 + String ists,
  49 + String bcsj) {
47 this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); 50 this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str);
48 this.bc_type = bc_type; 51 this.bc_type = bc_type;
49 this.fcsj = fcsj; 52 this.fcsj = fcsj;
@@ -69,6 +72,10 @@ public interface TTInfoDetailForEdit { @@ -69,6 +72,10 @@ public interface TTInfoDetailForEdit {
69 else 72 else
70 this.ists = false; 73 this.ists = false;
71 74
  75 + if (StringUtils.isNotEmpty(bcsj) && !"null".equals(bcsj)) {
  76 + this.bcsj = bcsj;
  77 + }
  78 +
72 } 79 }
73 80
74 public Long getTtdid() { 81 public Long getTtdid() {
@@ -134,6 +141,14 @@ public interface TTInfoDetailForEdit { @@ -134,6 +141,14 @@ public interface TTInfoDetailForEdit {
134 public void setIsts(Boolean ists) { 141 public void setIsts(Boolean ists) {
135 this.ists = ists; 142 this.ists = ists;
136 } 143 }
  144 +
  145 + public String getBcsj() {
  146 + return bcsj;
  147 + }
  148 +
  149 + public void setBcsj(String bcsj) {
  150 + this.bcsj = bcsj;
  151 + }
137 } 152 }
138 153
139 /** 154 /**
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/timetable/ErrorBcCountFunction.java
@@ -59,10 +59,16 @@ public class ErrorBcCountFunction implements AccumulateFunction { @@ -59,10 +59,16 @@ public class ErrorBcCountFunction implements AccumulateFunction {
59 return; 59 return;
60 } 60 }
61 61
  62 + // 判定条件(数据库中的对应字段没有非空约束),与界面saTimeTable.js的validInfo方法对应
  63 + // 1、起点站编码,名字为空
  64 + // 2、终点站编码,名字为空
  65 + // 3、班次时间
  66 + // TODO:其他再议
62 if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) || 67 if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
63 StringUtils.isEmpty(ttInfoDetail.getQdzName()) || 68 StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
64 StringUtils.isEmpty(ttInfoDetail.getZdzCode()) || 69 StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
65 - StringUtils.isEmpty(ttInfoDetail.getZdzName()) ) { 70 + StringUtils.isEmpty(ttInfoDetail.getZdzName()) ||
  71 + (ttInfoDetail.getBcsj() == null) ) {
66 72
67 errorCountData.errorcount ++; 73 errorCountData.errorcount ++;
68 } 74 }
src/main/resources/META-INF/drools.packagebuilder.conf 0 → 100644
  1 +# 貌似用import accumulate报错,使用配置文件方式
  2 +
  3 +drools.accumulate.function.gidscount = com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidsCountFunction
  4 +drools.accumulate.function.gidfbtime = com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbTimeFunction
  5 +drools.accumulate.function.gidfbfcno = com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbFcnoFunction
  6 +
  7 +drools.accumulate.function.lpinforesult = com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResultsFunction
  8 +drools.accumulate.function.minruleqyrq = com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.MinRuleQyrqFunction
  9 +
  10 +drools.accumulate.function.vrb = com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidRepeatBcFunction
  11 +drools.accumulate.function.vwrb = com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWholeRerunBcFunction
  12 +drools.accumulate.function.vwlp = com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWantLpFunction