Commit adc1270feca1af854703b8614ddb0ab96f46ba6f

Authored by 王通
1 parent a4f3a849

1.应急预案平台与调度系统联通

Too many changes to show.

To preserve performance only 4 of 10 files are displayed.

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.MalformedURLException;  
9 -import java.net.URL;  
10 -import java.net.URLEncoder;  
11 -import java.sql.Connection;  
12 -import java.sql.Date;  
13 -import java.sql.PreparedStatement;  
14 -import java.sql.ResultSet;  
15 -import java.util.*;  
16 -  
17 -import com.bsth.data.forecast.entity.ArrivalEntity;  
18 -import com.bsth.entity.sys.SysUser;  
19 -import com.bsth.security.util.SecurityUtils;  
20 -import com.bsth.util.ReportUtils;  
21 -import com.bsth.util.db.DBUtils_MS;  
22 -import com.bsth.util.db.DBUtils_control;  
23 -import com.fasterxml.jackson.databind.ObjectMapper;  
24 -import org.apache.commons.io.IOUtils;  
25 -import org.apache.commons.lang3.StringEscapeUtils;  
26 -import org.joda.time.DateTime;  
27 -import org.joda.time.format.DateTimeFormat;  
28 -import org.joda.time.format.DateTimeFormatter;  
29 -import org.springframework.beans.factory.annotation.Autowired;  
30 -import org.springframework.web.bind.annotation.*;  
31 -  
32 -import com.alibaba.fastjson.JSONArray;  
33 -import com.bsth.common.ResponseCode;  
34 -import com.bsth.controller.BaseController;  
35 -import com.bsth.controller.realcontrol.dto.ChangePersonCar;  
36 -import com.bsth.controller.realcontrol.dto.DfsjChange;  
37 -import com.bsth.data.BasicData;  
38 -import com.bsth.data.schedule.DayOfSchedule;  
39 -import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;  
40 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
41 -import com.bsth.entity.report.RepairReport;  
42 -import com.bsth.entity.schedule.SchedulePlanInfo;  
43 -import com.bsth.service.realcontrol.ScheduleRealInfoService;  
44 -  
45 -@RestController  
46 -@RequestMapping("/realSchedule")  
47 -public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {  
48 -  
49 - @Autowired  
50 - ScheduleRealInfoService scheduleRealInfoService;  
51 -  
52 - @Autowired  
53 - DayOfSchedule dayOfSchedule;  
54 -  
55 - @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST)  
56 - public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){  
57 - return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm);  
58 - }  
59 -  
60 - @RequestMapping(value = "/lines")  
61 - public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {  
62 - return scheduleRealInfoService.findByLines(lines);  
63 - }  
64 -  
65 - @RequestMapping(value = "/car")  
66 - public List<ScheduleRealInfo> findByCar(String nbbm){  
67 - return dayOfSchedule.findByNbbm(nbbm);  
68 - }  
69 -  
70 - /**  
71 - *  
72 - * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id  
73 - * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws  
74 - */  
75 - @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)  
76 - public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,  
77 - @RequestParam String dfsj,String bcType,  
78 - @RequestParam(defaultValue = "") String opType) {  
79 - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType, null);  
80 - }  
81 -  
82 - /**  
83 - *  
84 - * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔  
85 - */  
86 - @RequestMapping(value = "/destroy", method = RequestMethod.POST)  
87 - public Map<String, Object> destroy(@RequestParam String idsStr  
88 - /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,  
89 - @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {  
90 - return scheduleRealInfoService.destroy(idsStr, remarks, adjustExps, null);  
91 - }  
92 -  
93 - /**  
94 - *  
95 - * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws  
96 - */  
97 - @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)  
98 - public Map<String, String> carDeviceMapp() {  
99 - return BasicData.deviceId2NbbmMap.inverse();  
100 - }  
101 -  
102 - /**  
103 - *  
104 - * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param  
105 - * lineId @throws  
106 - */  
107 - @RequestMapping(value = "/driver", method = RequestMethod.GET)  
108 - public List<Map<String, String>> findDriverByLine(@RequestParam String lineCode) {  
109 - return scheduleRealInfoService.findDriverByLine(lineCode);  
110 - }  
111 -  
112 - /**  
113 - *  
114 - * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param  
115 - * lineId @throws  
116 - */  
117 - @RequestMapping(value = "/conductor", method = RequestMethod.GET)  
118 - public List<Map<String, String>> findConductorByLine(@RequestParam String lineCode) {  
119 - return scheduleRealInfoService.findConductorByLine(lineCode);  
120 - }  
121 -  
122 - /**  
123 - *  
124 - * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param  
125 - * lineId @throws  
126 - */  
127 - @RequestMapping(value = "/cars", method = RequestMethod.GET)  
128 - public List<Map<String, String>> findCarByLine(@RequestParam String lineCode) {  
129 - return scheduleRealInfoService.findCarByLine(lineCode);  
130 - }  
131 -  
132 - /**  
133 - *  
134 - * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws  
135 - */  
136 - @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)  
137 - public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {  
138 - return scheduleRealInfoService.sreachVehic(nbbm);  
139 - }  
140 - /**  
141 - *  
142 - * @Title: realOutAdjust  
143 - * @Description: TODO(实发调整)  
144 - * @param @param id 班次ID  
145 - * @param @param fcsjActual 实际发车时间 HH:mm  
146 - * @param @param remarks 备注  
147 - * @throws  
148 - */  
149 - @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)  
150 - public Map<String, Object> realOutAdjust(@RequestParam Map<String, String> map) {  
151 - return scheduleRealInfoService.realOutAdjust(map);  
152 - }  
153 -  
154 - /**  
155 - *  
156 - * @Title: revokeDestroy  
157 - * @Description: TODO(撤销烂班)  
158 - * @param @param id  
159 - * @throws  
160 - */  
161 - @RequestMapping(value = "/revokeDestroy", method = RequestMethod.POST)  
162 - public Map<String, Object> revokeDestroy(@RequestParam Long id){  
163 - return scheduleRealInfoService.revokeDestroy(id);  
164 - }  
165 -  
166 - /**  
167 - *  
168 - * @Title: revokeRealOutgo  
169 - * @Description: TODO(撤销实发)  
170 - * @param @param id  
171 - * @throws  
172 - */  
173 - @RequestMapping(value = "/revokeRealOutgo", method = RequestMethod.POST)  
174 - public Map<String, Object> revokeRealOutgo(@RequestParam Long id){  
175 - return scheduleRealInfoService.revokeRealOutgo(id);  
176 - }  
177 -  
178 - /**  
179 - * 撤销执行  
180 - * @param id  
181 - * @return  
182 - */  
183 - @RequestMapping(value = "/revokeRealArrive", method = RequestMethod.POST)  
184 - public Map<String, Object> revokeRealArrive(@RequestParam Long id){  
185 - return scheduleRealInfoService.revokeRealArrive(id);  
186 - }  
187 -  
188 - /**  
189 - *  
190 - * @Title: spaceAdjust  
191 - * @Description: TODO(间隔调整)  
192 - * @param @param ids 要调整的班次数组ID  
193 - * @param @param space 间隔  
194 - * @throws  
195 - */  
196 - @RequestMapping(value = "/spaceAdjust", method = RequestMethod.POST)  
197 - public Map<String, Object> spaceAdjust(Long[] ids, Integer space){  
198 - return scheduleRealInfoService.spaceAdjust(ids, space);  
199 - }  
200 -  
201 - /**  
202 - *  
203 - * @Title: schInfoFineTune  
204 - * @Description: TODO(发车信息微调)  
205 - * @param @param map  
206 - * @throws  
207 - */  
208 - @RequestMapping(value = "/schInfoFineTune", method = RequestMethod.POST)  
209 - public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){  
210 - return scheduleRealInfoService.schInfoFineTune(map);  
211 - }  
212 -  
213 - /**  
214 - *  
215 - * @Title: outgoAdjustAll  
216 - * @Description: TODO(批量待发调整)  
217 - * @param @param list  
218 - * @throws  
219 - */  
220 - @RequestMapping(value = "/outgoAdjustAll", method = RequestMethod.POST)  
221 - public Map<String, Object> outgoAdjustAll(@RequestParam String params){  
222 - //反转义  
223 - params = StringEscapeUtils.unescapeHtml4(params);  
224 - return scheduleRealInfoService.outgoAdjustAll(params);  
225 - }  
226 -  
227 - /**  
228 - *  
229 - * @Title: findByLineAndUpDown  
230 - * @Description: TODO(根据线路和走向获取班次)  
231 - * @param @param line  
232 - * @param @param upDown  
233 - */  
234 - @RequestMapping(value = "/findByLineAndUpDown")  
235 - public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){  
236 - return dayOfSchedule.findByLineAndUpDown(line, upDown);  
237 - }  
238 -  
239 - /**  
240 - *  
241 - * @Title: findRouteByLine  
242 - * @Description: TODO(获取线路的站点,路段路由)  
243 - * @param @param lineCode  
244 - * @throws  
245 - */  
246 - @RequestMapping(value = "/findRouteByLine")  
247 - public Map<String, Object> findRouteByLine(@RequestParam String lineCode){  
248 - return scheduleRealInfoService.findRouteByLine(lineCode);  
249 - }  
250 -  
251 - /**  
252 - *  
253 - * @Title: removeChildTask  
254 - * @Description: TODO(删除子任务)  
255 - * @param @param taskId 子任务ID  
256 - * @throws  
257 - */  
258 - @RequestMapping(value = "/childTask/{taskId}", method = RequestMethod.DELETE)  
259 - public Map<String, Object> removeChildTask(@PathVariable("taskId") Long taskId){  
260 - return scheduleRealInfoService.removeChildTask(taskId);  
261 - }  
262 -  
263 - /**  
264 - *  
265 - * @Title: findByLineCode  
266 - * @Description: TODO(根据线路获取班次信息)  
267 - * @param @param lineCode  
268 - */  
269 - @RequestMapping(value = "/lineCode/{lineCode}")  
270 - public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){  
271 - return dayOfSchedule.findByLineCode(lineCode);  
272 - }  
273 -  
274 - @RequestMapping(value = "/queryUserInfo")  
275 - public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,  
276 - @RequestParam String date,@RequestParam String state) {  
277 - return scheduleRealInfoService.queryUserInfo(line, date,state);  
278 - }  
279 -  
280 - @RequestMapping(value = "/queryUserInfoPx")  
281 - public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,  
282 - @RequestParam String date,@RequestParam String state,@RequestParam String type) {  
283 - return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);  
284 - }  
285 -  
286 - @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)  
287 - public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName,@RequestParam String jGh, @RequestParam String clZbh,  
288 - @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {  
289 - return scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);  
290 - }  
291 -  
292 - @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)  
293 - public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh  
294 - ,@RequestParam String date,@RequestParam String line) {  
295 - return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);  
296 - }  
297 -  
298 -  
299 - @RequestMapping(value = "/dailyInfo")  
300 - public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {  
301 - return scheduleRealInfoService.dailyInfo(line, date, type);  
302 - }  
303 -  
304 - @RequestMapping(value = "/historyMessage")  
305 - public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,  
306 - @RequestParam String code, @RequestParam String type) {  
307 - return scheduleRealInfoService.historyMessage(line, date, code, type);  
308 - }  
309 -  
310 - @RequestMapping(value="/findLine")  
311 - public List<Map<String,String>> findLine(@RequestParam String line){  
312 - return scheduleRealInfoService.findLine(line);  
313 - }  
314 -  
315 - @RequestMapping(value="/findKMBC",method = RequestMethod.GET)  
316 - public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName  
317 - ,@RequestParam String date,@RequestParam String line){  
318 - return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);  
319 - }  
320 -  
321 - /**  
322 - * 路单公里统计 (闵行审计专用)  
323 - * @param jGh  
324 - * @param clZbh  
325 - * @param lpName  
326 - * @param date  
327 - * @param line  
328 - * @return  
329 - */  
330 - @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)  
331 - public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName  
332 - ,@RequestParam String date,@RequestParam String line){  
333 - return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);  
334 - }  
335 -  
336 - @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)  
337 - public Map<String,Object> findKMBCQp(@RequestParam String clZbh  
338 - ,@RequestParam String date,@RequestParam String line){  
339 - return scheduleRealInfoService.findKMBCQp(clZbh,date,line);  
340 - }  
341 -  
342 - @RequestMapping(value="/findLpName")  
343 - public List<Map<String,String>> findLpName(@RequestParam String lpName){  
344 - return scheduleRealInfoService.findLpName(lpName);  
345 - }  
346 -  
347 - @RequestMapping(value = "/account")  
348 - public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,  
349 - @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {  
350 - return scheduleRealInfoService.account(line, date, code, xlName, type);  
351 - }  
352 -  
353 - @RequestMapping(value = "/accountPx")  
354 - public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,  
355 - @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {  
356 - return scheduleRealInfoService.accountPx(line, date, code, xlName, px);  
357 - }  
358 -  
359 - @RequestMapping(value = "/correctForm")  
360 - public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,  
361 - @RequestParam String endDate,  
362 - @RequestParam String lpName, @RequestParam String code,  
363 - @RequestParam String type,@RequestParam String changType) {  
364 - return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);  
365 - }  
366 - /**  
367 - * @Title queryListWaybill  
368 - * @Description 查询行车路单列表  
369 - * @param jGh 驾驶员名字  
370 - * @param clZbh 车辆自编号(内部编号)  
371 - * @param lpName 路牌  
372 - * @return  
373 - */  
374 - @RequestMapping(value="/queryListWaybill",method = RequestMethod.GET)  
375 - public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName  
376 - ,@RequestParam String date,@RequestParam String line){  
377 - return scheduleRealInfoService.queryListWaybill(jGh, clZbh,lpName,date,line);  
378 - }  
379 -  
380 - /**  
381 - * @Title queryListWaybill  
382 - * @Description 查询行车路单列表(闵行审计专用路单)  
383 - * @param jName 驾驶员名字  
384 - * @param clZbh 车辆自编号(内部编号)  
385 - * @param lpName 路牌  
386 - * @return  
387 - */  
388 - @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)  
389 - public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName  
390 - ,@RequestParam String date,@RequestParam String line){  
391 - return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);  
392 - }  
393 -  
394 - @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)  
395 - public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,  
396 - @RequestParam String date,@RequestParam String line){  
397 - return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);  
398 - }  
399 -  
400 - @RequestMapping(value="/statisticsDaily")  
401 - public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,  
402 - @RequestParam String xlName, @RequestParam String type){  
403 - return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);  
404 - }  
405 -  
406 - @RequestMapping(value="/statisticsDaily_mh_2")  
407 - public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,  
408 - @RequestParam String xlName, @RequestParam String type){  
409 - return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);  
410 - }  
411 -  
412 - @RequestMapping(value="/dispatchDailySum")  
413 - public List<Map<String,Object>> dispatchDailySum(@RequestParam Map<String, Object> map){  
414 - String date="";  
415 - if(map.get("date")!=null){  
416 - date=map.get("date").toString();  
417 - }  
418 - String date2="";  
419 - if(map.get("date2")!=null){  
420 - date2=map.get("date2").toString();  
421 - }  
422 - String nature="0";  
423 - if(map.get("nature")!=null){  
424 - nature=map.get("nature").toString();  
425 - }  
426 - String type="";  
427 - if(map.get("type")!=null){  
428 - type=map.get("type").toString();  
429 - }  
430 - return scheduleRealInfoService.dispatchDailySum(date, date2, nature, type);  
431 - }  
432 -  
433 - @RequestMapping(value="/statisticsDailyTj")  
434 - public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){  
435 - String gsdm="";  
436 - if(map.get("gsdm")!=null){  
437 - gsdm=map.get("gsdm").toString();  
438 - }  
439 - String fgsdm="";  
440 - if(map.get("fgsdm")!=null){  
441 - fgsdm=map.get("fgsdm").toString();  
442 - }  
443 - String line="";  
444 - if(map.get("line")!=null){  
445 - line=map.get("line").toString();  
446 - }  
447 - String date="";  
448 - if(map.get("date")!=null){  
449 - date=map.get("date").toString();  
450 - }  
451 - String date2="";  
452 - if(map.get("date2")!=null){  
453 - date2=map.get("date2").toString();  
454 - }  
455 - String xlName="";  
456 - if(map.get("xlName")!=null){  
457 - xlName=map.get("xlName").toString();  
458 - }  
459 - String type="";  
460 - if(map.get("type")!=null){  
461 - type=map.get("type").toString();  
462 - }  
463 - String nature="0";  
464 - if(map.get("nature")!=null){  
465 - nature=map.get("nature").toString();  
466 - }  
467 - return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);  
468 - }  
469 -  
470 - /*  
471 - * 公里修正报表  
472 - */  
473 - @RequestMapping(value="/mileageReportTj")  
474 - public List<Map<String,Object>> mileageReport(@RequestParam Map<String, Object> map){  
475 - String gsdm="";  
476 - if(map.get("gsdm")!=null){  
477 - gsdm=map.get("gsdm").toString();  
478 - }  
479 - String fgsdm="";  
480 - if(map.get("fgsdm")!=null){  
481 - fgsdm=map.get("fgsdm").toString();  
482 - }  
483 - String line="";  
484 - if(map.get("line")!=null){  
485 - line=map.get("line").toString();  
486 - }  
487 - String date="";  
488 - if(map.get("date")!=null){  
489 - date=map.get("date").toString();  
490 - }  
491 - String date2="";  
492 - if(map.get("date2")!=null){  
493 - date2=map.get("date2").toString();  
494 - }  
495 - String xlName="";  
496 - if(map.get("xlName")!=null){  
497 - xlName=map.get("xlName").toString();  
498 - }  
499 - return scheduleRealInfoService.mileageReport(gsdm,fgsdm,line, date,date2);  
500 - }  
501 -  
502 - /*  
503 - * 班次修正报表  
504 - */  
505 - @RequestMapping(value="/scheduleCorrectionReport")  
506 - public List<Map<String,Object>> scheduleCorrectionReport(@RequestParam Map<String, Object> map){  
507 - String gsdm="";  
508 - if(map.get("gsdm")!=null){  
509 - gsdm=map.get("gsdm").toString();  
510 - }  
511 - String fgsdm="";  
512 - if(map.get("fgsdm")!=null){  
513 - fgsdm=map.get("fgsdm").toString();  
514 - }  
515 - String line="";  
516 - if(map.get("line")!=null){  
517 - line=map.get("line").toString();  
518 - }  
519 - String date="";  
520 - if(map.get("date")!=null){  
521 - date=map.get("date").toString();  
522 - }  
523 - String date2="";  
524 - if(map.get("date2")!=null){  
525 - date2=map.get("date2").toString();  
526 - }  
527 - String xlName="";  
528 - if(map.get("xlName")!=null){  
529 - xlName=map.get("xlName").toString();  
530 - }  
531 - return scheduleRealInfoService.scheduleCorrectionReport(gsdm,fgsdm,line, date,date2);  
532 - }  
533 -  
534 - @RequestMapping(value="/MapById",method = RequestMethod.GET)  
535 - public Map<String, Object> MapById(@RequestParam("id") Long id){  
536 - return scheduleRealInfoService.MapById(id);  
537 - }  
538 -  
539 - @RequestMapping(value="/MapByIdQp",method = RequestMethod.GET)  
540 - public Map<String, Object> MapByIdQp(@RequestParam("id") Long id){  
541 - return scheduleRealInfoService.MapByIdQp(id);  
542 - }  
543 -  
544 - /**  
545 - * @Title: scheduleDaily  
546 - * @Description: TODO(调度日报表)  
547 - * @param line 线路  
548 - * @param date 时间  
549 - * @return  
550 - */  
551 - @RequestMapping(value="/scheduleDaily")  
552 - public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){  
553 - return scheduleRealInfoService.scheduleDaily(line,date);  
554 - }  
555 -  
556 - @RequestMapping(value="/realScheduleList")  
557 - public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){  
558 - return scheduleRealInfoService.realScheduleList(line,date);  
559 - }  
560 -  
561 - @RequestMapping(value="/realScheduleList_zrw")  
562 - public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){  
563 - return scheduleRealInfoService.realScheduleList_zrw(line,date);  
564 - }  
565 -  
566 - @RequestMapping(value="/realScheduleList_mh_2")  
567 - public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){  
568 - return scheduleRealInfoService.realScheduleList_mh_2(line,date);  
569 - }  
570 -  
571 - @RequestMapping(value="/realScheduleListQp")  
572 - public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){  
573 - return scheduleRealInfoService.realScheduleListQp(line,date);  
574 - }  
575 -  
576 - @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)  
577 - public synchronized Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){  
578 - cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);  
579 - List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);  
580 - return scheduleRealInfoService.multi_tzrc(cpcs, null);  
581 - }  
582 -  
583 - @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)  
584 - public Map<String, Object> multi_dftz(@RequestParam String dcsJson){  
585 - dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);  
586 - List<DfsjChange> dfsjcs = JSONArray.parseArray(dcsJson, DfsjChange.class);  
587 - return scheduleRealInfoService.multi_dftz(dfsjcs);  
588 - }  
589 -  
590 - @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)  
591 - public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){  
592 - return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);  
593 - }  
594 -  
595 - @RequestMapping(value="/history", method=RequestMethod.POST)  
596 - public Map<String,Object> historySave(ScheduleRealInfo sch){  
597 - return scheduleRealInfoService.historySave(sch);  
598 - }  
599 -  
600 -  
601 - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");  
602 - private final static long ONE_DAY = 1000 * 60 * 60 * 24;  
603 - /**  
604 - * 获取可编辑的历史班次日期  
605 - * @return  
606 - */  
607 - @RequestMapping("dateArray")  
608 - public List<String> dateArray(@RequestParam(defaultValue = "0") int c){  
609 - List<String> rs = new ArrayList<>();  
610 -  
611 - long t = System.currentTimeMillis();  
612 - if(c != 1)  
613 - t -= (ONE_DAY + (1000 * 60 * 60 * 6));  
614 - for(int i = 0; i < 3; i ++){  
615 - rs.add(fmtyyyyMMdd.print(t));  
616 - t -= ONE_DAY;  
617 - }  
618 - return rs;  
619 - }  
620 -  
621 - @RequestMapping(value = "svgAttr", method = RequestMethod.POST)  
622 - public Map<String, Object> svgAttr(@RequestParam String jsonStr){  
623 - return scheduleRealInfoService.svgAttr(jsonStr);  
624 - }  
625 -  
626 - @RequestMapping(value = "svgAttr", method = RequestMethod.GET)  
627 - public Map<String, Object> findSvgAttr(@RequestParam String idx){  
628 - return scheduleRealInfoService.findSvgAttr(idx);  
629 - }  
630 -  
631 - @RequestMapping(value = "addRemarks", method = RequestMethod.POST)  
632 - public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){  
633 - return scheduleRealInfoService.addRemarks(id, remarks);  
634 - }  
635 -  
636 - @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET)  
637 - public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){  
638 - return scheduleRealInfoService.scheduleDailyQp(line,date);  
639 - }  
640 -  
641 - @RequestMapping(value = "scheduleDailyExport", method = RequestMethod.GET)  
642 - public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){  
643 - return scheduleRealInfoService.scheduleDailyExport(map);  
644 - }  
645 -  
646 - @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)  
647 - public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){  
648 - return scheduleRealInfoService.exportWaybillMore(map);  
649 - }  
650 -  
651 - /**  
652 - * 获取当日计划排班 , 从计划表抓取数据  
653 - * @return  
654 - */  
655 - @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)  
656 - public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){  
657 - return scheduleRealInfoService.currentSchedulePlan(lineCode);  
658 - }  
659 -  
660 - @RequestMapping(value = "lpChangeMulti", method = RequestMethod.POST)  
661 - public Map<String, Object> lpChangeMulti(@RequestParam String leftIdx, @RequestParam String rightIdx,@RequestParam int type){  
662 - return scheduleRealInfoService.lpChangeMulti(leftIdx, rightIdx, type);  
663 - }  
664 -  
665 - /**  
666 - * 删除当日实际排班  
667 - * @return  
668 - */  
669 - @RequestMapping(value = "deleteRealSchedule", method = RequestMethod.POST)  
670 - public Map<String, Object> deleteRealSchedule(@RequestParam String lineCode){  
671 - return dayOfSchedule.deleteRealSchedule(lineCode);  
672 - }  
673 -  
674 - /**  
675 - * 从计划表重新加载当日排班  
676 - * @param lineCode  
677 - * @return  
678 - */  
679 - @RequestMapping(value = "reLoadRealSchedule", method = RequestMethod.POST)  
680 - public Map<String, Object> reLoadRealSchedule(@RequestParam String lineCode){  
681 - Map<String, Object> rs = new HashMap<>();  
682 - List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);  
683 - if(list != null && list.size() > 0){  
684 - rs.put("status", ResponseCode.ERROR);  
685 - rs.put("msg", "失败," + list.get(0).getXlName() + "当日存在实际排班,无法重新加载。");  
686 - return rs;  
687 - }  
688 -  
689 - int code = dayOfSchedule.reloadSch(lineCode);  
690 -  
691 - //重新按公司编码索引数据  
692 - dayOfSchedule.groupByGsbm();  
693 - rs.put("status", code==0? ResponseCode.SUCCESS: ResponseCode.ERROR);  
694 - return rs;  
695 - }  
696 -  
697 - /**  
698 - * 误点调整  
699 - * @param idx  
700 - * @param minute  
701 - * @return  
702 - */  
703 - @RequestMapping(value = "lateAdjust", method = RequestMethod.POST)  
704 - public Map<String, Object> lateAdjust(@RequestParam String idx,@RequestParam float minute ){  
705 - return scheduleRealInfoService.lateAdjust(idx, minute);  
706 - }  
707 -  
708 - /**  
709 - * 获取所有应发未到的班次  
710 - * @param idx  
711 - * @return  
712 - */  
713 - @RequestMapping(value = "allLate2")  
714 - public List<ScheduleRealInfo> allLate2(@RequestParam String idx){  
715 - return scheduleRealInfoService.allLate2(idx);  
716 - }  
717 -  
718 - /**  
719 - * 添加一个临加到历史库  
720 - * @param sch  
721 - * @return  
722 - */  
723 - @RequestMapping(value = "history/add", method = RequestMethod.POST)  
724 - public Map<String, Object> addToHistory(ScheduleRealInfo sch){  
725 - return scheduleRealInfoService.addToHistory(sch);  
726 - }  
727 -  
728 - /**  
729 - * 从历史库里删除临加班次  
730 - * @param id  
731 - * @return  
732 - */  
733 - @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)  
734 - public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){  
735 - return scheduleRealInfoService.deleteToHistory(id);  
736 - }  
737 -  
738 - @RequestMapping(value = "isCircleQdz", method = RequestMethod.POST)  
739 - public Map<String, Object> isCircleQdz(@RequestParam String line, String nbbm, String ts, String qdzCode){  
740 - Map<String, Object> map =new HashMap<>();  
741 - map.put("isExist",scheduleRealInfoService.isCircleQdz(nbbm, ts, line, qdzCode));  
742 - return map;  
743 - }  
744 -  
745 - /**  
746 - * 从历史库里删除临加班次  
747 - * @param param  
748 - * @return  
749 - */  
750 - @RequestMapping(value = "wxsb", method = RequestMethod.POST)  
751 - public Map<String, Object> repairReport(@RequestParam Map<String, Object> param){  
752 - return scheduleRealInfoService.repairReport(param, true);  
753 - }  
754 -  
755 - @RequestMapping(value = "wxsb", method = RequestMethod.GET)  
756 - public List<RepairReport> repairReportList(@RequestParam String line, @RequestParam String date, @RequestParam String code, @RequestParam String type){  
757 - return scheduleRealInfoService.repairReportList(line, date, code, type);  
758 - }  
759 -  
760 - @RequestMapping(value = "lineLevel", method = RequestMethod.GET)  
761 - public Map<String, String> lineLevel(@RequestParam String idx){  
762 - return scheduleRealInfoService.getLevelsByLines(Arrays.asList(idx.split(",")));  
763 - }  
764 -  
765 - /**  
766 - * 反馈安全驾驶系统  
767 - * @param param  
768 - * @return  
769 - */  
770 - @RequestMapping(value = "ackDsm", method = RequestMethod.POST)  
771 - public Map<String, Object> ackDsm(@RequestParam Map<String, Object> param){  
772 - Map<String, Object> res = new HashMap<>();  
773 - InputStream in = null;  
774 - SysUser user = SecurityUtils.getCurrentUser();  
775 - DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");  
776 - StringBuilder url = new StringBuilder("http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm?"), uri = new StringBuilder();  
777 - HttpURLConnection con = null;  
778 - try {  
779 - uri.append("ddyName=").append(URLEncoder.encode(user == null ? "admin" : user.getUserName(), "UTF-8"));  
780 - uri.append("&checkTime=").append(URLEncoder.encode(fmt.print(System.currentTimeMillis()), "UTF-8"));  
781 - uri.append("&nbbm=").append(URLEncoder.encode(param.get("nbbm").toString(), "UTF-8"));  
782 - uri.append("&starttime=").append(URLEncoder.encode(fmt.print(Long.parseLong(param.get("ts").toString())), "UTF-8"));  
783 - url.append(uri);  
784 - con = (HttpURLConnection)new URL(url.toString()).openConnection();  
785 - con.setDoInput(true);  
786 - con.setRequestMethod("POST");  
787 - con.setConnectTimeout(5000);  
788 - con.setReadTimeout(5000);  
789 - con.setRequestProperty("keep-alive", "true");  
790 - con.setRequestProperty("accept", "*/*");  
791 - con.setRequestProperty("content-type", "application/x-www-form-urlencoded");  
792 - con.connect();  
793 -  
794 - if (con.getResponseCode() == 200) {  
795 - in = con.getInputStream();  
796 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
797 - IOUtils.copy(in, bout);  
798 - Map<String, Object> map = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
799 - System.out.println(map);  
800 - }  
801 - } catch (MalformedURLException e) {  
802 - // TODO Auto-generated catch block  
803 - e.printStackTrace();  
804 - } catch (IOException e) {  
805 - // TODO Auto-generated catch block  
806 - e.printStackTrace();  
807 - } finally {  
808 - if (con != null) {  
809 - con.disconnect();  
810 - }  
811 - }  
812 -  
813 - return res;  
814 - }  
815 -  
816 - @RequestMapping(value = "exportPlan", method = RequestMethod.GET)  
817 - public Map<String, Object> exportPlan(@RequestParam String date){  
818 - Map<String, Object> res = new HashMap<>();  
819 - DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");  
820 - Connection conn = null;  
821 - PreparedStatement ps = null;  
822 - ResultSet rs = null;  
823 -  
824 - List<Map<String, Object>> list = new ArrayList<>();  
825 - String sql = "select xl_name,xl_dir,schedule_date,fcsj,cl_zbh,j_name,bcsj from bsth_c_s_sp_info where schedule_date = ? and xl_bm in (22205, 202104, 202105, 202106, 202107, 210415) and bc_type = 'normal'";  
826 - try{  
827 - conn = DBUtils_control.getConnection();  
828 - ps = conn.prepareStatement(sql);  
829 - ps.setString(1, date);  
830 - rs = ps.executeQuery();  
831 - ObjectMapper mapper = new ObjectMapper();  
832 -  
833 - while (rs.next()) {  
834 - SchedulePlan schedulePlan = new SchedulePlan();  
835 - schedulePlan.setXlName(rs.getString("xl_name"));  
836 - schedulePlan.setXlDir(rs.getInt("xl_dir"));  
837 - Date scheduleDate = rs.getDate("schedule_date");  
838 - schedulePlan.setScheduleDate(new DateTime(scheduleDate.getTime()).toString("yyyy-MM-dd"));  
839 - String fcsj = rs.getString("fcsj");  
840 - int bcsj = rs.getInt("bcsj");  
841 - DateTime fcsjDt = dateTimeFormatter.parseDateTime(schedulePlan.getScheduleDate() + " " + fcsj);  
842 - schedulePlan.setFcsj(fcsjDt.toString("HH:mm:00"));  
843 - DateTime ddsjDt = fcsjDt.plusMinutes(bcsj);  
844 - schedulePlan.setDdsj(ddsjDt.toString("HH:mm:00"));  
845 - schedulePlan.setSjdStart(fcsjDt.toString("HH:00:00"));  
846 - DateTime endDt = fcsjDt.plusHours(1);  
847 - schedulePlan.setSjdEnd(endDt.toString("HH:00:00"));  
848 - schedulePlan.setClZbh(rs.getString("cl_zbh"));  
849 - schedulePlan.setJsy(rs.getString("j_name"));  
850 - schedulePlan.setBcsj(bcsj);  
851 -  
852 - list.add(mapper.readValue(mapper.writeValueAsString(schedulePlan), HashMap.class));  
853 - }  
854 - List<Iterator<?>> iterators = new ArrayList<Iterator<?>>();  
855 - iterators.add(list.iterator());  
856 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
857 - String sourcePath = path + "mould/schedulePlan.xls";  
858 -  
859 - new ReportUtils().excelReplace(iterators, new Object[]{}, sourcePath, path + "export/" + date + "-花博会专线班次.xls");  
860 -  
861 - res.put("status", ResponseCode.SUCCESS);  
862 - res.put("msg", "成功");  
863 - } catch (Exception e) {  
864 - res.put("status", ResponseCode.ERROR);  
865 - res.put("msg", e.getMessage());  
866 - } finally {  
867 - DBUtils_control.close(rs, ps, conn);  
868 - }  
869 -  
870 - return res;  
871 - }  
872 -  
873 - public final static class SchedulePlan {  
874 - private String company = "浦东公司[46]";  
875 -  
876 - private String xlName = "";  
877 -  
878 - private int xlDir;  
879 -  
880 - private String xlDirStr = "";  
881 -  
882 - private String scheduleDate = "";  
883 -  
884 - private String sjdStart = "";  
885 -  
886 - private String sjdEnd = "";  
887 -  
888 - private String fcsj = "";  
889 -  
890 - private int bcsj;  
891 -  
892 - private String ddsj = "";  
893 -  
894 - private int yys = 25;  
895 -  
896 - private String clZbh = "";  
897 -  
898 - private String cph = "";  
899 -  
900 - private String color = "绿牌";  
901 -  
902 - private String jsy = "";  
903 -  
904 - private String jsydh = "";  
905 -  
906 - private int pj = 10;  
907 -  
908 - public String getCompany() {  
909 - return company;  
910 - }  
911 -  
912 - public void setCompany(String company) {  
913 - this.company = company;  
914 - }  
915 -  
916 - public String getXlName() {  
917 - return xlName;  
918 - }  
919 -  
920 - public void setXlName(String xlName) {  
921 - this.xlName = xlName;  
922 - }  
923 -  
924 - public int getXlDir() {  
925 - return xlDir;  
926 - }  
927 -  
928 - public void setXlDir(int xlDir) {  
929 - this.xlDir = xlDir;  
930 - }  
931 -  
932 - public String getXlDirStr() {  
933 - xlDirStr = "";  
934 - if (xlDir == 0) {  
935 - xlDirStr = "上行";  
936 - } else if (xlDir == 1) {  
937 - xlDirStr = "下行";  
938 - }  
939 - return xlDirStr;  
940 - }  
941 -  
942 - public void setXlDirStr(String xlDirStr) {  
943 - this.xlDirStr = xlDirStr;  
944 - }  
945 -  
946 - public String getScheduleDate() {  
947 - return scheduleDate;  
948 - }  
949 -  
950 - public void setScheduleDate(String scheduleDate) {  
951 - this.scheduleDate = scheduleDate;  
952 - }  
953 -  
954 - public String getSjdStart() {  
955 - return sjdStart;  
956 - }  
957 -  
958 - public void setSjdStart(String sjdStart) {  
959 - this.sjdStart = sjdStart;  
960 - }  
961 -  
962 - public String getSjdEnd() {  
963 - return sjdEnd;  
964 - }  
965 -  
966 - public void setSjdEnd(String sjdEnd) {  
967 - this.sjdEnd = sjdEnd;  
968 - }  
969 -  
970 - public String getFcsj() {  
971 - return fcsj;  
972 - }  
973 -  
974 - public void setFcsj(String fcsj) {  
975 - this.fcsj = fcsj;  
976 - }  
977 -  
978 - public int getBcsj() {  
979 - return bcsj;  
980 - }  
981 -  
982 - public void setBcsj(int bcsj) {  
983 - this.bcsj = bcsj;  
984 - }  
985 -  
986 - public String getDdsj() {  
987 - return ddsj;  
988 - }  
989 -  
990 - public void setDdsj(String ddsj) {  
991 - this.ddsj = ddsj;  
992 - }  
993 -  
994 - public int getYys() {  
995 - return yys;  
996 - }  
997 -  
998 - public void setYys(int yys) {  
999 - this.yys = yys;  
1000 - }  
1001 -  
1002 - public String getClZbh() {  
1003 - return clZbh;  
1004 - }  
1005 -  
1006 - public void setClZbh(String clZbh) {  
1007 - this.clZbh = clZbh;  
1008 - }  
1009 -  
1010 - public String getCph() {  
1011 - cph = BasicData.nbbmCompanyPlateMap.get(clZbh);  
1012 - if (cph == null) {  
1013 - cph = "";  
1014 - }  
1015 - return cph;  
1016 - }  
1017 -  
1018 - public void setCph(String cph) {  
1019 - this.cph = cph;  
1020 - }  
1021 -  
1022 - public String getColor() {  
1023 - return color;  
1024 - }  
1025 -  
1026 - public void setColor(String color) {  
1027 - this.color = color;  
1028 - }  
1029 -  
1030 - public String getJsy() {  
1031 - return jsy;  
1032 - }  
1033 -  
1034 - public void setJsy(String jsy) {  
1035 - this.jsy = jsy;  
1036 - }  
1037 -  
1038 - public String getJsydh() {  
1039 - return jsydh;  
1040 - }  
1041 -  
1042 - public void setJsydh(String jsydh) {  
1043 - this.jsydh = jsydh;  
1044 - }  
1045 -  
1046 - public int getPj() {  
1047 - return pj;  
1048 - }  
1049 -  
1050 - public void setPj(int pj) {  
1051 - this.pj = pj;  
1052 - }  
1053 - }  
1054 -} 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.MalformedURLException;
  9 +import java.net.URL;
  10 +import java.net.URLEncoder;
  11 +import java.sql.Connection;
  12 +import java.sql.Date;
  13 +import java.sql.PreparedStatement;
  14 +import java.sql.ResultSet;
  15 +import java.util.*;
  16 +
  17 +import com.bsth.data.forecast.entity.ArrivalEntity;
  18 +import com.bsth.entity.sys.SysUser;
  19 +import com.bsth.security.util.SecurityUtils;
  20 +import com.bsth.util.ReportUtils;
  21 +import com.bsth.util.db.DBUtils_MS;
  22 +import com.bsth.util.db.DBUtils_control;
  23 +import com.fasterxml.jackson.databind.ObjectMapper;
  24 +import org.apache.commons.io.IOUtils;
  25 +import org.apache.commons.lang3.StringEscapeUtils;
  26 +import org.joda.time.DateTime;
  27 +import org.joda.time.format.DateTimeFormat;
  28 +import org.joda.time.format.DateTimeFormatter;
  29 +import org.springframework.beans.factory.annotation.Autowired;
  30 +import org.springframework.beans.factory.annotation.Value;
  31 +import org.springframework.web.bind.annotation.*;
  32 +
  33 +import com.alibaba.fastjson.JSONArray;
  34 +import com.bsth.common.ResponseCode;
  35 +import com.bsth.controller.BaseController;
  36 +import com.bsth.controller.realcontrol.dto.ChangePersonCar;
  37 +import com.bsth.controller.realcontrol.dto.DfsjChange;
  38 +import com.bsth.data.BasicData;
  39 +import com.bsth.data.schedule.DayOfSchedule;
  40 +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
  41 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  42 +import com.bsth.entity.report.RepairReport;
  43 +import com.bsth.entity.schedule.SchedulePlanInfo;
  44 +import com.bsth.service.realcontrol.ScheduleRealInfoService;
  45 +
  46 +@RestController
  47 +@RequestMapping("/realSchedule")
  48 +public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
  49 +
  50 + @Autowired
  51 + ScheduleRealInfoService scheduleRealInfoService;
  52 +
  53 + @Autowired
  54 + DayOfSchedule dayOfSchedule;
  55 +
  56 + @Value("${dsm.ack.url}")
  57 + private String dsmUrl;
  58 +
  59 + @Value("${cp.ack.url}")
  60 + private String cpUrl;
  61 +
  62 + @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST)
  63 + public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){
  64 + return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm);
  65 + }
  66 +
  67 + @RequestMapping(value = "/lines")
  68 + public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {
  69 + return scheduleRealInfoService.findByLines(lines);
  70 + }
  71 +
  72 + @RequestMapping(value = "/car")
  73 + public List<ScheduleRealInfo> findByCar(String nbbm){
  74 + return dayOfSchedule.findByNbbm(nbbm);
  75 + }
  76 +
  77 + /**
  78 + *
  79 + * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
  80 + * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws
  81 + */
  82 + @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
  83 + public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
  84 + @RequestParam String dfsj,String bcType,
  85 + @RequestParam(defaultValue = "") String opType) {
  86 + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType, null);
  87 + }
  88 +
  89 + /**
  90 + *
  91 + * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔
  92 + */
  93 + @RequestMapping(value = "/destroy", method = RequestMethod.POST)
  94 + public Map<String, Object> destroy(@RequestParam String idsStr
  95 + /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,
  96 + @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {
  97 + return scheduleRealInfoService.destroy(idsStr, remarks, adjustExps, null);
  98 + }
  99 +
  100 + /**
  101 + *
  102 + * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws
  103 + */
  104 + @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)
  105 + public Map<String, String> carDeviceMapp() {
  106 + return BasicData.deviceId2NbbmMap.inverse();
  107 + }
  108 +
  109 + /**
  110 + *
  111 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param
  112 + * lineId @throws
  113 + */
  114 + @RequestMapping(value = "/driver", method = RequestMethod.GET)
  115 + public List<Map<String, String>> findDriverByLine(@RequestParam String lineCode) {
  116 + return scheduleRealInfoService.findDriverByLine(lineCode);
  117 + }
  118 +
  119 + /**
  120 + *
  121 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param
  122 + * lineId @throws
  123 + */
  124 + @RequestMapping(value = "/conductor", method = RequestMethod.GET)
  125 + public List<Map<String, String>> findConductorByLine(@RequestParam String lineCode) {
  126 + return scheduleRealInfoService.findConductorByLine(lineCode);
  127 + }
  128 +
  129 + /**
  130 + *
  131 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param
  132 + * lineId @throws
  133 + */
  134 + @RequestMapping(value = "/cars", method = RequestMethod.GET)
  135 + public List<Map<String, String>> findCarByLine(@RequestParam String lineCode) {
  136 + return scheduleRealInfoService.findCarByLine(lineCode);
  137 + }
  138 +
  139 + /**
  140 + *
  141 + * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws
  142 + */
  143 + @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)
  144 + public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {
  145 + return scheduleRealInfoService.sreachVehic(nbbm);
  146 + }
  147 + /**
  148 + *
  149 + * @Title: realOutAdjust
  150 + * @Description: TODO(实发调整)
  151 + * @param @param id 班次ID
  152 + * @param @param fcsjActual 实际发车时间 HH:mm
  153 + * @param @param remarks 备注
  154 + * @throws
  155 + */
  156 + @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)
  157 + public Map<String, Object> realOutAdjust(@RequestParam Map<String, String> map) {
  158 + return scheduleRealInfoService.realOutAdjust(map);
  159 + }
  160 +
  161 + /**
  162 + *
  163 + * @Title: revokeDestroy
  164 + * @Description: TODO(撤销烂班)
  165 + * @param @param id
  166 + * @throws
  167 + */
  168 + @RequestMapping(value = "/revokeDestroy", method = RequestMethod.POST)
  169 + public Map<String, Object> revokeDestroy(@RequestParam Long id){
  170 + return scheduleRealInfoService.revokeDestroy(id);
  171 + }
  172 +
  173 + /**
  174 + *
  175 + * @Title: revokeRealOutgo
  176 + * @Description: TODO(撤销实发)
  177 + * @param @param id
  178 + * @throws
  179 + */
  180 + @RequestMapping(value = "/revokeRealOutgo", method = RequestMethod.POST)
  181 + public Map<String, Object> revokeRealOutgo(@RequestParam Long id){
  182 + return scheduleRealInfoService.revokeRealOutgo(id);
  183 + }
  184 +
  185 + /**
  186 + * 撤销执行
  187 + * @param id
  188 + * @return
  189 + */
  190 + @RequestMapping(value = "/revokeRealArrive", method = RequestMethod.POST)
  191 + public Map<String, Object> revokeRealArrive(@RequestParam Long id){
  192 + return scheduleRealInfoService.revokeRealArrive(id);
  193 + }
  194 +
  195 + /**
  196 + *
  197 + * @Title: spaceAdjust
  198 + * @Description: TODO(间隔调整)
  199 + * @param @param ids 要调整的班次数组ID
  200 + * @param @param space 间隔
  201 + * @throws
  202 + */
  203 + @RequestMapping(value = "/spaceAdjust", method = RequestMethod.POST)
  204 + public Map<String, Object> spaceAdjust(Long[] ids, Integer space){
  205 + return scheduleRealInfoService.spaceAdjust(ids, space);
  206 + }
  207 +
  208 + /**
  209 + *
  210 + * @Title: schInfoFineTune
  211 + * @Description: TODO(发车信息微调)
  212 + * @param @param map
  213 + * @throws
  214 + */
  215 + @RequestMapping(value = "/schInfoFineTune", method = RequestMethod.POST)
  216 + public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){
  217 + return scheduleRealInfoService.schInfoFineTune(map);
  218 + }
  219 +
  220 + /**
  221 + *
  222 + * @Title: outgoAdjustAll
  223 + * @Description: TODO(批量待发调整)
  224 + * @param @param list
  225 + * @throws
  226 + */
  227 + @RequestMapping(value = "/outgoAdjustAll", method = RequestMethod.POST)
  228 + public Map<String, Object> outgoAdjustAll(@RequestParam String params){
  229 + //反转义
  230 + params = StringEscapeUtils.unescapeHtml4(params);
  231 + return scheduleRealInfoService.outgoAdjustAll(params);
  232 + }
  233 +
  234 + /**
  235 + *
  236 + * @Title: findByLineAndUpDown
  237 + * @Description: TODO(根据线路和走向获取班次)
  238 + * @param @param line
  239 + * @param @param upDown
  240 + */
  241 + @RequestMapping(value = "/findByLineAndUpDown")
  242 + public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){
  243 + return dayOfSchedule.findByLineAndUpDown(line, upDown);
  244 + }
  245 +
  246 + /**
  247 + *
  248 + * @Title: findRouteByLine
  249 + * @Description: TODO(获取线路的站点,路段路由)
  250 + * @param @param lineCode
  251 + * @throws
  252 + */
  253 + @RequestMapping(value = "/findRouteByLine")
  254 + public Map<String, Object> findRouteByLine(@RequestParam String lineCode){
  255 + return scheduleRealInfoService.findRouteByLine(lineCode);
  256 + }
  257 +
  258 + /**
  259 + *
  260 + * @Title: removeChildTask
  261 + * @Description: TODO(删除子任务)
  262 + * @param @param taskId 子任务ID
  263 + * @throws
  264 + */
  265 + @RequestMapping(value = "/childTask/{taskId}", method = RequestMethod.DELETE)
  266 + public Map<String, Object> removeChildTask(@PathVariable("taskId") Long taskId){
  267 + return scheduleRealInfoService.removeChildTask(taskId);
  268 + }
  269 +
  270 + /**
  271 + *
  272 + * @Title: findByLineCode
  273 + * @Description: TODO(根据线路获取班次信息)
  274 + * @param @param lineCode
  275 + */
  276 + @RequestMapping(value = "/lineCode/{lineCode}")
  277 + public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){
  278 + return dayOfSchedule.findByLineCode(lineCode);
  279 + }
  280 +
  281 + @RequestMapping(value = "/queryUserInfo")
  282 + public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,
  283 + @RequestParam String date,@RequestParam String state) {
  284 + return scheduleRealInfoService.queryUserInfo(line, date,state);
  285 + }
  286 +
  287 + @RequestMapping(value = "/queryUserInfoPx")
  288 + public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,
  289 + @RequestParam String date,@RequestParam String state,@RequestParam String type) {
  290 + return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);
  291 + }
  292 +
  293 + @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)
  294 + public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName,@RequestParam String jGh, @RequestParam String clZbh,
  295 + @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
  296 + return scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);
  297 + }
  298 +
  299 + @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)
  300 + public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh
  301 + ,@RequestParam String date,@RequestParam String line) {
  302 + return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);
  303 + }
  304 +
  305 +
  306 + @RequestMapping(value = "/dailyInfo")
  307 + public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
  308 + return scheduleRealInfoService.dailyInfo(line, date, type);
  309 + }
  310 +
  311 + @RequestMapping(value = "/historyMessage")
  312 + public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,
  313 + @RequestParam String code, @RequestParam String type) {
  314 + return scheduleRealInfoService.historyMessage(line, date, code, type);
  315 + }
  316 +
  317 + @RequestMapping(value="/findLine")
  318 + public List<Map<String,String>> findLine(@RequestParam String line){
  319 + return scheduleRealInfoService.findLine(line);
  320 + }
  321 +
  322 + @RequestMapping(value="/findKMBC",method = RequestMethod.GET)
  323 + public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  324 + ,@RequestParam String date,@RequestParam String line){
  325 + return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
  326 + }
  327 +
  328 + /**
  329 + * 路单公里统计 (闵行审计专用)
  330 + * @param jGh
  331 + * @param clZbh
  332 + * @param lpName
  333 + * @param date
  334 + * @param line
  335 + * @return
  336 + */
  337 + @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)
  338 + public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  339 + ,@RequestParam String date,@RequestParam String line){
  340 + return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);
  341 + }
  342 +
  343 + @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
  344 + public Map<String,Object> findKMBCQp(@RequestParam String clZbh
  345 + ,@RequestParam String date,@RequestParam String line){
  346 + return scheduleRealInfoService.findKMBCQp(clZbh,date,line);
  347 + }
  348 +
  349 + @RequestMapping(value="/findLpName")
  350 + public List<Map<String,String>> findLpName(@RequestParam String lpName){
  351 + return scheduleRealInfoService.findLpName(lpName);
  352 + }
  353 +
  354 + @RequestMapping(value = "/account")
  355 + public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,
  356 + @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {
  357 + return scheduleRealInfoService.account(line, date, code, xlName, type);
  358 + }
  359 +
  360 + @RequestMapping(value = "/accountPx")
  361 + public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,
  362 + @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {
  363 + return scheduleRealInfoService.accountPx(line, date, code, xlName, px);
  364 + }
  365 +
  366 + @RequestMapping(value = "/correctForm")
  367 + public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,
  368 + @RequestParam String endDate,
  369 + @RequestParam String lpName, @RequestParam String code,
  370 + @RequestParam String type,@RequestParam String changType) {
  371 + return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);
  372 + }
  373 + /**
  374 + * @Title queryListWaybill
  375 + * @Description 查询行车路单列表
  376 + * @param jGh 驾驶员名字
  377 + * @param clZbh 车辆自编号(内部编号)
  378 + * @param lpName 路牌
  379 + * @return
  380 + */
  381 + @RequestMapping(value="/queryListWaybill",method = RequestMethod.GET)
  382 + public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  383 + ,@RequestParam String date,@RequestParam String line){
  384 + return scheduleRealInfoService.queryListWaybill(jGh, clZbh,lpName,date,line);
  385 + }
  386 +
  387 + /**
  388 + * @Title queryListWaybill
  389 + * @Description 查询行车路单列表(闵行审计专用路单)
  390 + * @param jName 驾驶员名字
  391 + * @param clZbh 车辆自编号(内部编号)
  392 + * @param lpName 路牌
  393 + * @return
  394 + */
  395 + @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)
  396 + public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
  397 + ,@RequestParam String date,@RequestParam String line){
  398 + return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);
  399 + }
  400 +
  401 + @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)
  402 + public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
  403 + @RequestParam String date,@RequestParam String line){
  404 + return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);
  405 + }
  406 +
  407 + @RequestMapping(value="/statisticsDaily")
  408 + public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,
  409 + @RequestParam String xlName, @RequestParam String type){
  410 + return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);
  411 + }
  412 +
  413 + @RequestMapping(value="/statisticsDaily_mh_2")
  414 + public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,
  415 + @RequestParam String xlName, @RequestParam String type){
  416 + return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);
  417 + }
  418 +
  419 + @RequestMapping(value="/dispatchDailySum")
  420 + public List<Map<String,Object>> dispatchDailySum(@RequestParam Map<String, Object> map){
  421 + String date="";
  422 + if(map.get("date")!=null){
  423 + date=map.get("date").toString();
  424 + }
  425 + String date2="";
  426 + if(map.get("date2")!=null){
  427 + date2=map.get("date2").toString();
  428 + }
  429 + String nature="0";
  430 + if(map.get("nature")!=null){
  431 + nature=map.get("nature").toString();
  432 + }
  433 + String type="";
  434 + if(map.get("type")!=null){
  435 + type=map.get("type").toString();
  436 + }
  437 + return scheduleRealInfoService.dispatchDailySum(date, date2, nature, type);
  438 + }
  439 +
  440 + @RequestMapping(value="/statisticsDailyTj")
  441 + public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
  442 + String gsdm="";
  443 + if(map.get("gsdm")!=null){
  444 + gsdm=map.get("gsdm").toString();
  445 + }
  446 + String fgsdm="";
  447 + if(map.get("fgsdm")!=null){
  448 + fgsdm=map.get("fgsdm").toString();
  449 + }
  450 + String line="";
  451 + if(map.get("line")!=null){
  452 + line=map.get("line").toString();
  453 + }
  454 + String date="";
  455 + if(map.get("date")!=null){
  456 + date=map.get("date").toString();
  457 + }
  458 + String date2="";
  459 + if(map.get("date2")!=null){
  460 + date2=map.get("date2").toString();
  461 + }
  462 + String xlName="";
  463 + if(map.get("xlName")!=null){
  464 + xlName=map.get("xlName").toString();
  465 + }
  466 + String type="";
  467 + if(map.get("type")!=null){
  468 + type=map.get("type").toString();
  469 + }
  470 + String nature="0";
  471 + if(map.get("nature")!=null){
  472 + nature=map.get("nature").toString();
  473 + }
  474 + return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);
  475 + }
  476 +
  477 + /*
  478 + * 公里修正报表
  479 + */
  480 + @RequestMapping(value="/mileageReportTj")
  481 + public List<Map<String,Object>> mileageReport(@RequestParam Map<String, Object> map){
  482 + String gsdm="";
  483 + if(map.get("gsdm")!=null){
  484 + gsdm=map.get("gsdm").toString();
  485 + }
  486 + String fgsdm="";
  487 + if(map.get("fgsdm")!=null){
  488 + fgsdm=map.get("fgsdm").toString();
  489 + }
  490 + String line="";
  491 + if(map.get("line")!=null){
  492 + line=map.get("line").toString();
  493 + }
  494 + String date="";
  495 + if(map.get("date")!=null){
  496 + date=map.get("date").toString();
  497 + }
  498 + String date2="";
  499 + if(map.get("date2")!=null){
  500 + date2=map.get("date2").toString();
  501 + }
  502 + String xlName="";
  503 + if(map.get("xlName")!=null){
  504 + xlName=map.get("xlName").toString();
  505 + }
  506 + return scheduleRealInfoService.mileageReport(gsdm,fgsdm,line, date,date2);
  507 + }
  508 +
  509 + /*
  510 + * 班次修正报表
  511 + */
  512 + @RequestMapping(value="/scheduleCorrectionReport")
  513 + public List<Map<String,Object>> scheduleCorrectionReport(@RequestParam Map<String, Object> map){
  514 + String gsdm="";
  515 + if(map.get("gsdm")!=null){
  516 + gsdm=map.get("gsdm").toString();
  517 + }
  518 + String fgsdm="";
  519 + if(map.get("fgsdm")!=null){
  520 + fgsdm=map.get("fgsdm").toString();
  521 + }
  522 + String line="";
  523 + if(map.get("line")!=null){
  524 + line=map.get("line").toString();
  525 + }
  526 + String date="";
  527 + if(map.get("date")!=null){
  528 + date=map.get("date").toString();
  529 + }
  530 + String date2="";
  531 + if(map.get("date2")!=null){
  532 + date2=map.get("date2").toString();
  533 + }
  534 + String xlName="";
  535 + if(map.get("xlName")!=null){
  536 + xlName=map.get("xlName").toString();
  537 + }
  538 + return scheduleRealInfoService.scheduleCorrectionReport(gsdm,fgsdm,line, date,date2);
  539 + }
  540 +
  541 + @RequestMapping(value="/MapById",method = RequestMethod.GET)
  542 + public Map<String, Object> MapById(@RequestParam("id") Long id){
  543 + return scheduleRealInfoService.MapById(id);
  544 + }
  545 +
  546 + @RequestMapping(value="/MapByIdQp",method = RequestMethod.GET)
  547 + public Map<String, Object> MapByIdQp(@RequestParam("id") Long id){
  548 + return scheduleRealInfoService.MapByIdQp(id);
  549 + }
  550 +
  551 + /**
  552 + * @Title: scheduleDaily
  553 + * @Description: TODO(调度日报表)
  554 + * @param line 线路
  555 + * @param date 时间
  556 + * @return
  557 + */
  558 + @RequestMapping(value="/scheduleDaily")
  559 + public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
  560 + return scheduleRealInfoService.scheduleDaily(line,date);
  561 + }
  562 +
  563 + @RequestMapping(value="/realScheduleList")
  564 + public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){
  565 + return scheduleRealInfoService.realScheduleList(line,date);
  566 + }
  567 +
  568 + @RequestMapping(value="/realScheduleList_zrw")
  569 + public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){
  570 + return scheduleRealInfoService.realScheduleList_zrw(line,date);
  571 + }
  572 +
  573 + @RequestMapping(value="/realScheduleList_mh_2")
  574 + public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
  575 + return scheduleRealInfoService.realScheduleList_mh_2(line,date);
  576 + }
  577 +
  578 + @RequestMapping(value="/realScheduleListQp")
  579 + public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){
  580 + return scheduleRealInfoService.realScheduleListQp(line,date);
  581 + }
  582 +
  583 + @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)
  584 + public synchronized Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){
  585 + cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);
  586 + List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);
  587 + return scheduleRealInfoService.multi_tzrc(cpcs, null);
  588 + }
  589 +
  590 + @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)
  591 + public Map<String, Object> multi_dftz(@RequestParam String dcsJson){
  592 + dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);
  593 + List<DfsjChange> dfsjcs = JSONArray.parseArray(dcsJson, DfsjChange.class);
  594 + return scheduleRealInfoService.multi_dftz(dfsjcs);
  595 + }
  596 +
  597 + @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)
  598 + public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){
  599 + return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);
  600 + }
  601 +
  602 + @RequestMapping(value="/history", method=RequestMethod.POST)
  603 + public Map<String,Object> historySave(ScheduleRealInfo sch){
  604 + return scheduleRealInfoService.historySave(sch);
  605 + }
  606 +
  607 +
  608 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  609 + private final static long ONE_DAY = 1000 * 60 * 60 * 24;
  610 + /**
  611 + * 获取可编辑的历史班次日期
  612 + * @return
  613 + */
  614 + @RequestMapping("dateArray")
  615 + public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
  616 + List<String> rs = new ArrayList<>();
  617 +
  618 + long t = System.currentTimeMillis();
  619 + if(c != 1)
  620 + t -= (ONE_DAY + (1000 * 60 * 60 * 6));
  621 + for(int i = 0; i < 3; i ++){
  622 + rs.add(fmtyyyyMMdd.print(t));
  623 + t -= ONE_DAY;
  624 + }
  625 + return rs;
  626 + }
  627 +
  628 + @RequestMapping(value = "svgAttr", method = RequestMethod.POST)
  629 + public Map<String, Object> svgAttr(@RequestParam String jsonStr){
  630 + return scheduleRealInfoService.svgAttr(jsonStr);
  631 + }
  632 +
  633 + @RequestMapping(value = "svgAttr", method = RequestMethod.GET)
  634 + public Map<String, Object> findSvgAttr(@RequestParam String idx){
  635 + return scheduleRealInfoService.findSvgAttr(idx);
  636 + }
  637 +
  638 + @RequestMapping(value = "addRemarks", method = RequestMethod.POST)
  639 + public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){
  640 + return scheduleRealInfoService.addRemarks(id, remarks);
  641 + }
  642 +
  643 + @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET)
  644 + public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){
  645 + return scheduleRealInfoService.scheduleDailyQp(line,date);
  646 + }
  647 +
  648 + @RequestMapping(value = "scheduleDailyExport", method = RequestMethod.GET)
  649 + public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){
  650 + return scheduleRealInfoService.scheduleDailyExport(map);
  651 + }
  652 +
  653 + @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)
  654 + public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){
  655 + return scheduleRealInfoService.exportWaybillMore(map);
  656 + }
  657 +
  658 + /**
  659 + * 获取当日计划排班 , 从计划表抓取数据
  660 + * @return
  661 + */
  662 + @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)
  663 + public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){
  664 + return scheduleRealInfoService.currentSchedulePlan(lineCode);
  665 + }
  666 +
  667 + @RequestMapping(value = "lpChangeMulti", method = RequestMethod.POST)
  668 + public Map<String, Object> lpChangeMulti(@RequestParam String leftIdx, @RequestParam String rightIdx,@RequestParam int type){
  669 + return scheduleRealInfoService.lpChangeMulti(leftIdx, rightIdx, type);
  670 + }
  671 +
  672 + /**
  673 + * 删除当日实际排班
  674 + * @return
  675 + */
  676 + @RequestMapping(value = "deleteRealSchedule", method = RequestMethod.POST)
  677 + public Map<String, Object> deleteRealSchedule(@RequestParam String lineCode){
  678 + return dayOfSchedule.deleteRealSchedule(lineCode);
  679 + }
  680 +
  681 + /**
  682 + * 从计划表重新加载当日排班
  683 + * @param lineCode
  684 + * @return
  685 + */
  686 + @RequestMapping(value = "reLoadRealSchedule", method = RequestMethod.POST)
  687 + public Map<String, Object> reLoadRealSchedule(@RequestParam String lineCode){
  688 + Map<String, Object> rs = new HashMap<>();
  689 + List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);
  690 + if(list != null && list.size() > 0){
  691 + rs.put("status", ResponseCode.ERROR);
  692 + rs.put("msg", "失败," + list.get(0).getXlName() + "当日存在实际排班,无法重新加载。");
  693 + return rs;
  694 + }
  695 +
  696 + int code = dayOfSchedule.reloadSch(lineCode);
  697 +
  698 + //重新按公司编码索引数据
  699 + dayOfSchedule.groupByGsbm();
  700 + rs.put("status", code==0? ResponseCode.SUCCESS: ResponseCode.ERROR);
  701 + return rs;
  702 + }
  703 +
  704 + /**
  705 + * 误点调整
  706 + * @param idx
  707 + * @param minute
  708 + * @return
  709 + */
  710 + @RequestMapping(value = "lateAdjust", method = RequestMethod.POST)
  711 + public Map<String, Object> lateAdjust(@RequestParam String idx,@RequestParam float minute ){
  712 + return scheduleRealInfoService.lateAdjust(idx, minute);
  713 + }
  714 +
  715 + /**
  716 + * 获取所有应发未到的班次
  717 + * @param idx
  718 + * @return
  719 + */
  720 + @RequestMapping(value = "allLate2")
  721 + public List<ScheduleRealInfo> allLate2(@RequestParam String idx){
  722 + return scheduleRealInfoService.allLate2(idx);
  723 + }
  724 +
  725 + /**
  726 + * 添加一个临加到历史库
  727 + * @param sch
  728 + * @return
  729 + */
  730 + @RequestMapping(value = "history/add", method = RequestMethod.POST)
  731 + public Map<String, Object> addToHistory(ScheduleRealInfo sch){
  732 + return scheduleRealInfoService.addToHistory(sch);
  733 + }
  734 +
  735 + /**
  736 + * 从历史库里删除临加班次
  737 + * @param id
  738 + * @return
  739 + */
  740 + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)
  741 + public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){
  742 + return scheduleRealInfoService.deleteToHistory(id);
  743 + }
  744 +
  745 + @RequestMapping(value = "isCircleQdz", method = RequestMethod.POST)
  746 + public Map<String, Object> isCircleQdz(@RequestParam String line, String nbbm, String ts, String qdzCode){
  747 + Map<String, Object> map =new HashMap<>();
  748 + map.put("isExist",scheduleRealInfoService.isCircleQdz(nbbm, ts, line, qdzCode));
  749 + return map;
  750 + }
  751 +
  752 + /**
  753 + * 从历史库里删除临加班次
  754 + * @param param
  755 + * @return
  756 + */
  757 + @RequestMapping(value = "wxsb", method = RequestMethod.POST)
  758 + public Map<String, Object> repairReport(@RequestParam Map<String, Object> param){
  759 + return scheduleRealInfoService.repairReport(param, true);
  760 + }
  761 +
  762 + @RequestMapping(value = "wxsb", method = RequestMethod.GET)
  763 + public List<RepairReport> repairReportList(@RequestParam String line, @RequestParam String date, @RequestParam String code, @RequestParam String type){
  764 + return scheduleRealInfoService.repairReportList(line, date, code, type);
  765 + }
  766 +
  767 + @RequestMapping(value = "lineLevel", method = RequestMethod.GET)
  768 + public Map<String, String> lineLevel(@RequestParam String idx){
  769 + return scheduleRealInfoService.getLevelsByLines(Arrays.asList(idx.split(",")));
  770 + }
  771 +
  772 + /**
  773 + * 反馈安全驾驶系统
  774 + * @param param
  775 + * @return
  776 + */
  777 + @RequestMapping(value = "ackDsm", method = RequestMethod.POST)
  778 + public Map<String, Object> ackDsm(@RequestParam Map<String, Object> param){
  779 + Map<String, Object> res = new HashMap<>();
  780 + InputStream in = null;
  781 + SysUser user = SecurityUtils.getCurrentUser();
  782 + DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
  783 + StringBuilder url = new StringBuilder(dsmUrl), uri = new StringBuilder();
  784 + HttpURLConnection con = null;
  785 + try {
  786 + uri.append("ddyName=").append(URLEncoder.encode(user == null ? "admin" : user.getUserName(), "UTF-8"));
  787 + uri.append("&checkTime=").append(URLEncoder.encode(fmt.print(System.currentTimeMillis()), "UTF-8"));
  788 + uri.append("&nbbm=").append(URLEncoder.encode(param.get("nbbm").toString(), "UTF-8"));
  789 + uri.append("&starttime=").append(URLEncoder.encode(fmt.print(Long.parseLong(param.get("ts").toString())), "UTF-8"));
  790 + url.append(uri);
  791 + con = (HttpURLConnection)new URL(url.toString()).openConnection();
  792 + con.setDoInput(true);
  793 + con.setRequestMethod("POST");
  794 + con.setConnectTimeout(5000);
  795 + con.setReadTimeout(5000);
  796 + con.setRequestProperty("keep-alive", "true");
  797 + con.setRequestProperty("accept", "*/*");
  798 + con.setRequestProperty("content-type", "application/x-www-form-urlencoded");
  799 + con.connect();
  800 +
  801 + if (con.getResponseCode() == 200) {
  802 + in = con.getInputStream();
  803 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  804 + IOUtils.copy(in, bout);
  805 + Map<String, Object> map = new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  806 + System.out.println(map);
  807 + }
  808 + } catch (MalformedURLException e) {
  809 + // TODO Auto-generated catch block
  810 + e.printStackTrace();
  811 + } catch (IOException e) {
  812 + // TODO Auto-generated catch block
  813 + e.printStackTrace();
  814 + } finally {
  815 + if (con != null) {
  816 + con.disconnect();
  817 + }
  818 + }
  819 +
  820 + return res;
  821 + }
  822 +
  823 + /**
  824 + * 反馈应急预案系统
  825 + * @param param
  826 + * @return
  827 + */
  828 + @RequestMapping(value = "ackCp", method = RequestMethod.POST)
  829 + public Map<String, Object> ackCp(@RequestParam Map<String, Object> param){
  830 + Map<String, Object> res = new HashMap<>();
  831 + InputStream in = null;
  832 + SysUser user = SecurityUtils.getCurrentUser();
  833 + DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
  834 + StringBuilder url = new StringBuilder(cpUrl);
  835 + HttpURLConnection con = null;
  836 + try {
  837 + con = (HttpURLConnection)new URL(url.append(param.get("id")).toString()).openConnection();
  838 + con.setDoInput(true);
  839 + con.setRequestMethod("GET");
  840 + con.setConnectTimeout(5000);
  841 + con.setReadTimeout(5000);
  842 + con.setRequestProperty("keep-alive", "true");
  843 + con.setRequestProperty("accept", "*/*");
  844 +
  845 + if (con.getResponseCode() == 200) {
  846 + in = con.getInputStream();
  847 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  848 + IOUtils.copy(in, bout);
  849 + Map<String, Object> map = new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  850 + System.out.println(map);
  851 + }
  852 + } catch (MalformedURLException e) {
  853 + // TODO Auto-generated catch block
  854 + e.printStackTrace();
  855 + } catch (IOException e) {
  856 + // TODO Auto-generated catch block
  857 + e.printStackTrace();
  858 + } finally {
  859 + if (con != null) {
  860 + con.disconnect();
  861 + }
  862 + }
  863 +
  864 + return res;
  865 + }
  866 +
  867 + @RequestMapping(value = "exportPlan", method = RequestMethod.GET)
  868 + public Map<String, Object> exportPlan(@RequestParam String date){
  869 + Map<String, Object> res = new HashMap<>();
  870 + DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
  871 + Connection conn = null;
  872 + PreparedStatement ps = null;
  873 + ResultSet rs = null;
  874 +
  875 + List<Map<String, Object>> list = new ArrayList<>();
  876 + String sql = "select xl_name,xl_dir,schedule_date,fcsj,cl_zbh,j_name,bcsj from bsth_c_s_sp_info where schedule_date = ? and xl_bm in (22205, 202104, 202105, 202106, 202107, 210415) and bc_type = 'normal'";
  877 + try{
  878 + conn = DBUtils_control.getConnection();
  879 + ps = conn.prepareStatement(sql);
  880 + ps.setString(1, date);
  881 + rs = ps.executeQuery();
  882 + ObjectMapper mapper = new ObjectMapper();
  883 +
  884 + while (rs.next()) {
  885 + SchedulePlan schedulePlan = new SchedulePlan();
  886 + schedulePlan.setXlName(rs.getString("xl_name"));
  887 + schedulePlan.setXlDir(rs.getInt("xl_dir"));
  888 + Date scheduleDate = rs.getDate("schedule_date");
  889 + schedulePlan.setScheduleDate(new DateTime(scheduleDate.getTime()).toString("yyyy-MM-dd"));
  890 + String fcsj = rs.getString("fcsj");
  891 + int bcsj = rs.getInt("bcsj");
  892 + DateTime fcsjDt = dateTimeFormatter.parseDateTime(schedulePlan.getScheduleDate() + " " + fcsj);
  893 + schedulePlan.setFcsj(fcsjDt.toString("HH:mm:00"));
  894 + DateTime ddsjDt = fcsjDt.plusMinutes(bcsj);
  895 + schedulePlan.setDdsj(ddsjDt.toString("HH:mm:00"));
  896 + schedulePlan.setSjdStart(fcsjDt.toString("HH:00:00"));
  897 + DateTime endDt = fcsjDt.plusHours(1);
  898 + schedulePlan.setSjdEnd(endDt.toString("HH:00:00"));
  899 + schedulePlan.setClZbh(rs.getString("cl_zbh"));
  900 + schedulePlan.setJsy(rs.getString("j_name"));
  901 + schedulePlan.setBcsj(bcsj);
  902 +
  903 + list.add(mapper.readValue(mapper.writeValueAsString(schedulePlan), HashMap.class));
  904 + }
  905 + List<Iterator<?>> iterators = new ArrayList<Iterator<?>>();
  906 + iterators.add(list.iterator());
  907 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  908 + String sourcePath = path + "mould/schedulePlan.xls";
  909 +
  910 + new ReportUtils().excelReplace(iterators, new Object[]{}, sourcePath, path + "export/" + date + "-花博会专线班次.xls");
  911 +
  912 + res.put("status", ResponseCode.SUCCESS);
  913 + res.put("msg", "成功");
  914 + } catch (Exception e) {
  915 + res.put("status", ResponseCode.ERROR);
  916 + res.put("msg", e.getMessage());
  917 + } finally {
  918 + DBUtils_control.close(rs, ps, conn);
  919 + }
  920 +
  921 + return res;
  922 + }
  923 +
  924 + public final static class SchedulePlan {
  925 + private String company = "浦东公司[46]";
  926 +
  927 + private String xlName = "";
  928 +
  929 + private int xlDir;
  930 +
  931 + private String xlDirStr = "";
  932 +
  933 + private String scheduleDate = "";
  934 +
  935 + private String sjdStart = "";
  936 +
  937 + private String sjdEnd = "";
  938 +
  939 + private String fcsj = "";
  940 +
  941 + private int bcsj;
  942 +
  943 + private String ddsj = "";
  944 +
  945 + private int yys = 25;
  946 +
  947 + private String clZbh = "";
  948 +
  949 + private String cph = "";
  950 +
  951 + private String color = "绿牌";
  952 +
  953 + private String jsy = "";
  954 +
  955 + private String jsydh = "";
  956 +
  957 + private int pj = 10;
  958 +
  959 + public String getCompany() {
  960 + return company;
  961 + }
  962 +
  963 + public void setCompany(String company) {
  964 + this.company = company;
  965 + }
  966 +
  967 + public String getXlName() {
  968 + return xlName;
  969 + }
  970 +
  971 + public void setXlName(String xlName) {
  972 + this.xlName = xlName;
  973 + }
  974 +
  975 + public int getXlDir() {
  976 + return xlDir;
  977 + }
  978 +
  979 + public void setXlDir(int xlDir) {
  980 + this.xlDir = xlDir;
  981 + }
  982 +
  983 + public String getXlDirStr() {
  984 + xlDirStr = "";
  985 + if (xlDir == 0) {
  986 + xlDirStr = "上行";
  987 + } else if (xlDir == 1) {
  988 + xlDirStr = "下行";
  989 + }
  990 + return xlDirStr;
  991 + }
  992 +
  993 + public void setXlDirStr(String xlDirStr) {
  994 + this.xlDirStr = xlDirStr;
  995 + }
  996 +
  997 + public String getScheduleDate() {
  998 + return scheduleDate;
  999 + }
  1000 +
  1001 + public void setScheduleDate(String scheduleDate) {
  1002 + this.scheduleDate = scheduleDate;
  1003 + }
  1004 +
  1005 + public String getSjdStart() {
  1006 + return sjdStart;
  1007 + }
  1008 +
  1009 + public void setSjdStart(String sjdStart) {
  1010 + this.sjdStart = sjdStart;
  1011 + }
  1012 +
  1013 + public String getSjdEnd() {
  1014 + return sjdEnd;
  1015 + }
  1016 +
  1017 + public void setSjdEnd(String sjdEnd) {
  1018 + this.sjdEnd = sjdEnd;
  1019 + }
  1020 +
  1021 + public String getFcsj() {
  1022 + return fcsj;
  1023 + }
  1024 +
  1025 + public void setFcsj(String fcsj) {
  1026 + this.fcsj = fcsj;
  1027 + }
  1028 +
  1029 + public int getBcsj() {
  1030 + return bcsj;
  1031 + }
  1032 +
  1033 + public void setBcsj(int bcsj) {
  1034 + this.bcsj = bcsj;
  1035 + }
  1036 +
  1037 + public String getDdsj() {
  1038 + return ddsj;
  1039 + }
  1040 +
  1041 + public void setDdsj(String ddsj) {
  1042 + this.ddsj = ddsj;
  1043 + }
  1044 +
  1045 + public int getYys() {
  1046 + return yys;
  1047 + }
  1048 +
  1049 + public void setYys(int yys) {
  1050 + this.yys = yys;
  1051 + }
  1052 +
  1053 + public String getClZbh() {
  1054 + return clZbh;
  1055 + }
  1056 +
  1057 + public void setClZbh(String clZbh) {
  1058 + this.clZbh = clZbh;
  1059 + }
  1060 +
  1061 + public String getCph() {
  1062 + cph = BasicData.nbbmCompanyPlateMap.get(clZbh);
  1063 + if (cph == null) {
  1064 + cph = "";
  1065 + }
  1066 + return cph;
  1067 + }
  1068 +
  1069 + public void setCph(String cph) {
  1070 + this.cph = cph;
  1071 + }
  1072 +
  1073 + public String getColor() {
  1074 + return color;
  1075 + }
  1076 +
  1077 + public void setColor(String color) {
  1078 + this.color = color;
  1079 + }
  1080 +
  1081 + public String getJsy() {
  1082 + return jsy;
  1083 + }
  1084 +
  1085 + public void setJsy(String jsy) {
  1086 + this.jsy = jsy;
  1087 + }
  1088 +
  1089 + public String getJsydh() {
  1090 + return jsydh;
  1091 + }
  1092 +
  1093 + public void setJsydh(String jsydh) {
  1094 + this.jsydh = jsydh;
  1095 + }
  1096 +
  1097 + public int getPj() {
  1098 + return pj;
  1099 + }
  1100 +
  1101 + public void setPj(int pj) {
  1102 + this.pj = pj;
  1103 + }
  1104 + }
  1105 +}
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
1 -package com.bsth.controller.realcontrol;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONArray;  
5 -import com.alibaba.fastjson.JSONObject;  
6 -import com.bsth.controller.realcontrol.dto.ChangePersonCar;  
7 -import com.bsth.controller.realcontrol.dto.DftzAndDestroy;  
8 -import com.bsth.data.BasicData;  
9 -import com.bsth.data.directive.DayOfDirectives;  
10 -import com.bsth.data.directive.DirectiveCreator;  
11 -import com.bsth.data.directive.GatewayHttpUtils;  
12 -import com.bsth.data.gpsdata_v2.GpsRealData;  
13 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
14 -import com.bsth.data.schedule.DayOfSchedule;  
15 -import com.bsth.data.schedule.external.TccExternalService;  
16 -import com.bsth.entity.directive.D60;  
17 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
18 -import com.bsth.repository.directive.D60Repository;  
19 -import com.google.common.base.Splitter;  
20 -import org.apache.commons.lang3.StringEscapeUtils;  
21 -import org.apache.commons.lang3.StringUtils;  
22 -import org.slf4j.Logger;  
23 -import org.slf4j.LoggerFactory;  
24 -import org.springframework.beans.factory.annotation.Autowired;  
25 -import org.springframework.web.bind.annotation.*;  
26 -  
27 -import java.util.*;  
28 -  
29 -/**  
30 - * 对外的营运数据接口  
31 - * Created by panzhao on 2017/3/15.  
32 - */  
33 -@RestController  
34 -@RequestMapping("/companyService")  
35 -public class ServiceDataInterface {  
36 -  
37 - private final static String SECRE_KEY = "dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki";  
38 -  
39 - Logger logger = LoggerFactory.getLogger(this.getClass());  
40 -  
41 - @Autowired  
42 - DayOfSchedule dayOfSchedule;  
43 -  
44 - @Autowired  
45 - DayOfDirectives dayOfDirectives;  
46 -  
47 - @Autowired  
48 - D60Repository d60Repository;  
49 -  
50 - @Autowired  
51 - GpsRealData gpsRealData;  
52 -  
53 - @Autowired  
54 - TccExternalService tccExternalService;  
55 -  
56 - /**  
57 - * 获取车辆 和 当前执行班次对照信息  
58 - *  
59 - * @return  
60 - */  
61 - @RequestMapping("/execSchList")  
62 - public List<Map<String, Object>> execSchList(@RequestParam String secretKey) {  
63 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
64 - return null;  
65 -  
66 - List<Map<String, Object>> rs = new ArrayList<>();  
67 - Collection<ScheduleRealInfo> list = dayOfSchedule.execPlanMap().values();  
68 -  
69 - Map<String, Object> map;  
70 - for (ScheduleRealInfo sch : list) {  
71 - if (null == sch)  
72 - continue;  
73 - map = new HashMap<>();  
74 - map.put("clZbh", sch.getClZbh());  
75 - map.put("jGh", sch.getjGh());  
76 - map.put("jName", sch.getjName());  
77 - map.put("sGh", sch.getsGh());  
78 - map.put("sName", sch.getsName());  
79 - map.put("lpName", sch.getLpName());  
80 - map.put("xlBm", sch.getXlBm());  
81 - map.put("xlName", sch.getXlName());  
82 - map.put("xlDir", sch.getXlDir());  
83 - map.put("qdzName", sch.getQdzName());  
84 - map.put("zdzName", sch.getZdzName());  
85 - map.put("fcsj", sch.getFcsj());  
86 - map.put("dfsj", sch.getDfsj());  
87 - map.put("zdsj", sch.getZdsj());  
88 - map.put("bcType", sch.getBcType());  
89 - map.put("remarks", sch.getRemark());  
90 - map.put("status", sch.getStatus());  
91 -  
92 - //放站班次,放到的站点  
93 - map.put("majorStationName", sch.getMajorStationName());  
94 - rs.add(map);  
95 - }  
96 - return rs;  
97 - }  
98 -  
99 - @RequestMapping("/getCurrentDayPlan")  
100 - public List<ScheduleRealInfo> getCurrentDayPlan(  
101 - @RequestParam String companyId,  
102 - @RequestParam String workId,  
103 - @RequestParam String secretKey) {  
104 -  
105 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
106 - return null;  
107 -  
108 - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findByGsbm(companyId)), rs = new ArrayList<>();  
109 - for (ScheduleRealInfo sch : all) {  
110 - if (sch.getGsBm() != null  
111 - && sch.getGsBm().equals(companyId)  
112 - && sch.getjGh().equals(workId)) {  
113 - rs.add(sch);  
114 - }  
115 - }  
116 - return rs;  
117 - }  
118 -  
119 - @RequestMapping("/returnCCInfo")  
120 - public List<ScheduleRealInfo> returnCCInfo(@RequestParam String companyId, @RequestParam String secretKey) {  
121 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
122 - return null;  
123 -  
124 -  
125 - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();  
126 - for (ScheduleRealInfo sch : all) {  
127 -  
128 - if (sch.getBcType().equals("out")  
129 - && sch.getGsBm() != null  
130 - && sch.getGsBm().equals(companyId)) {  
131 - rs.add(sch);  
132 - }  
133 - }  
134 - return rs;  
135 - }  
136 -  
137 - @RequestMapping("/returnJCInfo")  
138 - public List<ScheduleRealInfo> returnJCInfo(@RequestParam String companyId, @RequestParam String secretKey) {  
139 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
140 - return null;  
141 -  
142 -  
143 - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();  
144 - for (ScheduleRealInfo sch : all) {  
145 - if (sch.getBcType().equals("in")  
146 - && sch.getGsBm() != null  
147 - && sch.getGsBm().equals(companyId)) {  
148 - rs.add(sch);  
149 - }  
150 - }  
151 - return rs;  
152 - }  
153 -  
154 - /**  
155 - * 获取全量的进出场数据, 仅供接口项目调用。 由接口项目负责对外所有场站输出  
156 - *  
157 - * @return  
158 - */  
159 - @RequestMapping("/findCurrInAndOut")  
160 - public List<ScheduleRealInfo> findCurrInAndOut(@RequestParam String secretKey) {  
161 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
162 - return null;  
163 -  
164 -  
165 - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();  
166 - for (ScheduleRealInfo sch : all) {  
167 - if (sch.getBcType().equals("in")  
168 - || sch.getBcType().equals("out")) {  
169 - rs.add(sch);  
170 - }  
171 - }  
172 - return rs;  
173 - }  
174 -  
175 - /**  
176 - * 向指定的车辆下发消息短语  
177 - *  
178 - * @return  
179 - */  
180 - @RequestMapping(value = "/send60Phrase", method = RequestMethod.POST)  
181 - public int send60Phrase(@RequestBody Map<String, String> map, @RequestParam String secretKey) {  
182 - try {  
183 - String nbbm = map.get("nbbm");  
184 - String txt = map.get("txt");  
185 - String sender = map.get("sender");  
186 - if (txt.length() > 50)  
187 - txt = txt.substring(0, 50);  
188 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
189 - return -500;  
190 -  
191 - //车辆和设备号对照  
192 - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
193 - if (StringUtils.isEmpty(deviceId))  
194 - return -404;  
195 -  
196 - //检查设备是否在线  
197 - long t = System.currentTimeMillis();  
198 - GpsEntity gps = gpsRealData.get(deviceId);  
199 - if (null == gps || (t - gps.getServerTimestamp()) > 1000 * 60 * 5)  
200 - return -405;  
201 -  
202 - Short dispatchInstruct = 0;//消息短语  
203 - D60 d60 = new DirectiveCreator().createD60(nbbm, txt, dispatchInstruct, gps.getUpDown(), gps.getState(), gps.getLineId());  
204 - d60.setSender(sender);  
205 - // 发送指令  
206 - int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));  
207 - d60.setHttpCode(code);  
208 -  
209 - if (code != 0)  
210 - d60.setErrorText("网关通讯失败, code: " + code);  
211 -  
212 - dayOfDirectives.put60(d60);  
213 - return d60.getMsgId();  
214 - } catch (Exception e) {  
215 - logger.error("", e);  
216 - return -500;  
217 - }  
218 - }  
219 -  
220 - /**  
221 - * 根据msg id 查询指令响应情况  
222 - *  
223 - * @param msgIds  
224 - * @return  
225 - */  
226 - @RequestMapping("/findD60Reply")  
227 - public List<Map<String, Object>> findD60Reply(@RequestParam String msgIds) {  
228 - List<Map<String, Object>> rs = new ArrayList<>();  
229 - try {  
230 - Map<String, Object> map = new HashMap();  
231 -  
232 - List<String> ids = Splitter.on(",").splitToList(msgIds);  
233 - D60 d60;  
234 - for (String id : ids) {  
235 - if (StringUtils.isEmpty(id))  
236 - continue;  
237 -  
238 - d60 = dayOfDirectives.get(Integer.parseInt(id));  
239 - if (null == d60)  
240 - continue;  
241 -  
242 - map.put("msgId", d60.getMsgId());  
243 - map.put("deviceReplyTime", d60.getReply46Time());  
244 - map.put("jsyReplyTime", d60.getReply47Time());  
245 - rs.add(map);  
246 - }  
247 - } catch (Exception e) {  
248 - logger.error("", e);  
249 - }  
250 - return rs;  
251 - }  
252 -  
253 - /**  
254 - * 获取路牌下所有班次  
255 - *  
256 - * @param lineCode  
257 - * @param lpName  
258 - * @return  
259 - */  
260 - @RequestMapping("/findByLpName")  
261 - public List<ScheduleRealInfo> findByLpName(@RequestParam String lineCode, @RequestParam String lpName, @RequestParam String secretKey) {  
262 - try {  
263 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
264 - return null;  
265 -  
266 - List<ScheduleRealInfo> list = dayOfSchedule.getLpScheduleMap().get(lineCode + "_" + lpName);  
267 - return list;  
268 - } catch (Exception e) {  
269 - logger.error("", e);  
270 - }  
271 - return null;  
272 - }  
273 -  
274 - /**  
275 - * 调整出场班次待发,并烂掉后续班次(调派用)  
276 - *  
277 - * @param dad  
278 - * @return  
279 - */  
280 - @RequestMapping(value = "/dftzAndDestroy", method = RequestMethod.POST)  
281 - public Map<String, Object> dftzAndDestroy(@RequestBody DftzAndDestroy dad, @RequestParam String secretKey) {  
282 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
283 - return null;  
284 - return tccExternalService.dftz(dad);  
285 - }  
286 -  
287 - /**  
288 - * 换人换车,(调派用)  
289 - * @return  
290 - */  
291 - @RequestMapping(value = "/tccHrhc", method = RequestMethod.POST)  
292 - public Map<String, Object> hrhc(@RequestBody String jsonStr, @RequestParam String secretKey){  
293 -  
294 - if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))  
295 - return null;  
296 -  
297 - jsonStr = StringEscapeUtils.unescapeHtml4(jsonStr);  
298 - JSONObject rootObj = JSON.parseObject(jsonStr);  
299 -  
300 - List<ChangePersonCar> cpcs = JSONArray.parseArray(rootObj.getString("cpcs"), ChangePersonCar.class);  
301 - return tccExternalService.hrhc(cpcs, rootObj.getString("tccCode"), rootObj.getString("userId"));  
302 - }  
303 -} 1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import com.bsth.controller.realcontrol.dto.ChangePersonCar;
  7 +import com.bsth.controller.realcontrol.dto.DftzAndDestroy;
  8 +import com.bsth.data.BasicData;
  9 +import com.bsth.data.directive.DayOfDirectives;
  10 +import com.bsth.data.directive.DirectiveCreator;
  11 +import com.bsth.data.directive.GatewayHttpUtils;
  12 +import com.bsth.data.gpsdata_v2.GpsRealData;
  13 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  14 +import com.bsth.data.schedule.DayOfSchedule;
  15 +import com.bsth.data.schedule.external.TccExternalService;
  16 +import com.bsth.entity.directive.D60;
  17 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  18 +import com.bsth.repository.directive.D60Repository;
  19 +import com.bsth.websocket.handler.SendUtils;
  20 +import com.fasterxml.jackson.databind.ObjectMapper;
  21 +import com.google.common.base.Splitter;
  22 +import org.apache.commons.lang3.StringEscapeUtils;
  23 +import org.apache.commons.lang3.StringUtils;
  24 +import org.slf4j.Logger;
  25 +import org.slf4j.LoggerFactory;
  26 +import org.springframework.beans.factory.annotation.Autowired;
  27 +import org.springframework.web.bind.annotation.*;
  28 +
  29 +import java.io.IOException;
  30 +import java.util.*;
  31 +
  32 +/**
  33 + * 对外的营运数据接口
  34 + * Created by panzhao on 2017/3/15.
  35 + */
  36 +@RestController
  37 +@RequestMapping("/companyService")
  38 +public class ServiceDataInterface {
  39 +
  40 + private final static String SECRE_KEY = "dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki";
  41 +
  42 + Logger logger = LoggerFactory.getLogger(this.getClass());
  43 +
  44 + @Autowired
  45 + DayOfSchedule dayOfSchedule;
  46 +
  47 + @Autowired
  48 + DayOfDirectives dayOfDirectives;
  49 +
  50 + @Autowired
  51 + D60Repository d60Repository;
  52 +
  53 + @Autowired
  54 + GpsRealData gpsRealData;
  55 +
  56 + @Autowired
  57 + TccExternalService tccExternalService;
  58 +
  59 + @Autowired
  60 + private SendUtils sendUtils;
  61 +
  62 + /**
  63 + * 获取车辆 和 当前执行班次对照信息
  64 + *
  65 + * @return
  66 + */
  67 + @RequestMapping("/execSchList")
  68 + public List<Map<String, Object>> execSchList(@RequestParam String secretKey) {
  69 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  70 + return null;
  71 +
  72 + List<Map<String, Object>> rs = new ArrayList<>();
  73 + Collection<ScheduleRealInfo> list = dayOfSchedule.execPlanMap().values();
  74 +
  75 + Map<String, Object> map;
  76 + for (ScheduleRealInfo sch : list) {
  77 + if (null == sch)
  78 + continue;
  79 + map = new HashMap<>();
  80 + map.put("clZbh", sch.getClZbh());
  81 + map.put("jGh", sch.getjGh());
  82 + map.put("jName", sch.getjName());
  83 + map.put("sGh", sch.getsGh());
  84 + map.put("sName", sch.getsName());
  85 + map.put("lpName", sch.getLpName());
  86 + map.put("xlBm", sch.getXlBm());
  87 + map.put("xlName", sch.getXlName());
  88 + map.put("xlDir", sch.getXlDir());
  89 + map.put("qdzName", sch.getQdzName());
  90 + map.put("zdzName", sch.getZdzName());
  91 + map.put("fcsj", sch.getFcsj());
  92 + map.put("dfsj", sch.getDfsj());
  93 + map.put("zdsj", sch.getZdsj());
  94 + map.put("bcType", sch.getBcType());
  95 + map.put("remarks", sch.getRemark());
  96 + map.put("status", sch.getStatus());
  97 +
  98 + //放站班次,放到的站点
  99 + map.put("majorStationName", sch.getMajorStationName());
  100 + rs.add(map);
  101 + }
  102 + return rs;
  103 + }
  104 +
  105 + @RequestMapping("/getCurrentDayPlan")
  106 + public List<ScheduleRealInfo> getCurrentDayPlan(
  107 + @RequestParam String companyId,
  108 + @RequestParam String workId,
  109 + @RequestParam String secretKey) {
  110 +
  111 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  112 + return null;
  113 +
  114 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findByGsbm(companyId)), rs = new ArrayList<>();
  115 + for (ScheduleRealInfo sch : all) {
  116 + if (sch.getGsBm() != null
  117 + && sch.getGsBm().equals(companyId)
  118 + && sch.getjGh().equals(workId)) {
  119 + rs.add(sch);
  120 + }
  121 + }
  122 + return rs;
  123 + }
  124 +
  125 + @RequestMapping("/returnCCInfo")
  126 + public List<ScheduleRealInfo> returnCCInfo(@RequestParam String companyId, @RequestParam String secretKey) {
  127 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  128 + return null;
  129 +
  130 +
  131 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
  132 + for (ScheduleRealInfo sch : all) {
  133 +
  134 + if (sch.getBcType().equals("out")
  135 + && sch.getGsBm() != null
  136 + && sch.getGsBm().equals(companyId)) {
  137 + rs.add(sch);
  138 + }
  139 + }
  140 + return rs;
  141 + }
  142 +
  143 + @RequestMapping("/returnJCInfo")
  144 + public List<ScheduleRealInfo> returnJCInfo(@RequestParam String companyId, @RequestParam String secretKey) {
  145 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  146 + return null;
  147 +
  148 +
  149 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
  150 + for (ScheduleRealInfo sch : all) {
  151 + if (sch.getBcType().equals("in")
  152 + && sch.getGsBm() != null
  153 + && sch.getGsBm().equals(companyId)) {
  154 + rs.add(sch);
  155 + }
  156 + }
  157 + return rs;
  158 + }
  159 +
  160 + /**
  161 + * 获取全量的进出场数据, 仅供接口项目调用。 由接口项目负责对外所有场站输出
  162 + *
  163 + * @return
  164 + */
  165 + @RequestMapping("/findCurrInAndOut")
  166 + public List<ScheduleRealInfo> findCurrInAndOut(@RequestParam String secretKey) {
  167 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  168 + return null;
  169 +
  170 +
  171 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
  172 + for (ScheduleRealInfo sch : all) {
  173 + if (sch.getBcType().equals("in")
  174 + || sch.getBcType().equals("out")) {
  175 + rs.add(sch);
  176 + }
  177 + }
  178 + return rs;
  179 + }
  180 +
  181 + /**
  182 + * 向指定的车辆下发消息短语
  183 + *
  184 + * @return
  185 + */
  186 + @RequestMapping(value = "/send60Phrase", method = RequestMethod.POST)
  187 + public int send60Phrase(@RequestBody Map<String, String> map, @RequestParam String secretKey) {
  188 + try {
  189 + String nbbm = map.get("nbbm");
  190 + String txt = map.get("txt");
  191 + String sender = map.get("sender");
  192 + if (txt.length() > 50)
  193 + txt = txt.substring(0, 50);
  194 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  195 + return -500;
  196 +
  197 + //车辆和设备号对照
  198 + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  199 + if (StringUtils.isEmpty(deviceId))
  200 + return -404;
  201 +
  202 + //检查设备是否在线
  203 + long t = System.currentTimeMillis();
  204 + GpsEntity gps = gpsRealData.get(deviceId);
  205 + if (null == gps || (t - gps.getServerTimestamp()) > 1000 * 60 * 5)
  206 + return -405;
  207 +
  208 + Short dispatchInstruct = 0;//消息短语
  209 + D60 d60 = new DirectiveCreator().createD60(nbbm, txt, dispatchInstruct, gps.getUpDown(), gps.getState(), gps.getLineId());
  210 + d60.setSender(sender);
  211 + // 发送指令
  212 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));
  213 + d60.setHttpCode(code);
  214 +
  215 + if (code != 0)
  216 + d60.setErrorText("网关通讯失败, code: " + code);
  217 +
  218 + dayOfDirectives.put60(d60);
  219 + return d60.getMsgId();
  220 + } catch (Exception e) {
  221 + logger.error("", e);
  222 + return -500;
  223 + }
  224 + }
  225 +
  226 + /**
  227 + * 根据msg id 查询指令响应情况
  228 + *
  229 + * @param msgIds
  230 + * @return
  231 + */
  232 + @RequestMapping("/findD60Reply")
  233 + public List<Map<String, Object>> findD60Reply(@RequestParam String msgIds) {
  234 + List<Map<String, Object>> rs = new ArrayList<>();
  235 + try {
  236 + Map<String, Object> map = new HashMap();
  237 +
  238 + List<String> ids = Splitter.on(",").splitToList(msgIds);
  239 + D60 d60;
  240 + for (String id : ids) {
  241 + if (StringUtils.isEmpty(id))
  242 + continue;
  243 +
  244 + d60 = dayOfDirectives.get(Integer.parseInt(id));
  245 + if (null == d60)
  246 + continue;
  247 +
  248 + map.put("msgId", d60.getMsgId());
  249 + map.put("deviceReplyTime", d60.getReply46Time());
  250 + map.put("jsyReplyTime", d60.getReply47Time());
  251 + rs.add(map);
  252 + }
  253 + } catch (Exception e) {
  254 + logger.error("", e);
  255 + }
  256 + return rs;
  257 + }
  258 +
  259 + /**
  260 + * 获取路牌下所有班次
  261 + *
  262 + * @param lineCode
  263 + * @param lpName
  264 + * @return
  265 + */
  266 + @RequestMapping("/findByLpName")
  267 + public List<ScheduleRealInfo> findByLpName(@RequestParam String lineCode, @RequestParam String lpName, @RequestParam String secretKey) {
  268 + try {
  269 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  270 + return null;
  271 +
  272 + List<ScheduleRealInfo> list = dayOfSchedule.getLpScheduleMap().get(lineCode + "_" + lpName);
  273 + return list;
  274 + } catch (Exception e) {
  275 + logger.error("", e);
  276 + }
  277 + return null;
  278 + }
  279 +
  280 + /**
  281 + * 调整出场班次待发,并烂掉后续班次(调派用)
  282 + *
  283 + * @param dad
  284 + * @return
  285 + */
  286 + @RequestMapping(value = "/dftzAndDestroy", method = RequestMethod.POST)
  287 + public Map<String, Object> dftzAndDestroy(@RequestBody DftzAndDestroy dad, @RequestParam String secretKey) {
  288 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  289 + return null;
  290 + return tccExternalService.dftz(dad);
  291 + }
  292 +
  293 + /**
  294 + * 换人换车,(调派用)
  295 + * @return
  296 + */
  297 + @RequestMapping(value = "/tccHrhc", method = RequestMethod.POST)
  298 + public Map<String, Object> hrhc(@RequestBody String jsonStr, @RequestParam String secretKey){
  299 +
  300 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  301 + return null;
  302 +
  303 + jsonStr = StringEscapeUtils.unescapeHtml4(jsonStr);
  304 + JSONObject rootObj = JSON.parseObject(jsonStr);
  305 +
  306 + List<ChangePersonCar> cpcs = JSONArray.parseArray(rootObj.getString("cpcs"), ChangePersonCar.class);
  307 + return tccExternalService.hrhc(cpcs, rootObj.getString("tccCode"), rootObj.getString("userId"));
  308 + }
  309 +
  310 + /**
  311 + * 接收应急预案信息
  312 + * @return
  313 + */
  314 + @RequestMapping(value = "/contingencyPlan", method = RequestMethod.POST)
  315 + public Map<String, Object> contingencyPlan(@RequestBody String jsonStr, @RequestParam String secretKey){
  316 + Map<String, Object> result = new HashMap<>();
  317 + result.put("errCode", 0);
  318 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY)) {
  319 + result.put("errCode", 501);
  320 + result.put("msg", "无效的key");
  321 +
  322 + return result;
  323 + }
  324 +
  325 + ObjectMapper mapper = new ObjectMapper();
  326 + try {
  327 + List<Map> maps = mapper.readValue(jsonStr,mapper.getTypeFactory().constructParametricType(List.class, Map.class));
  328 + for (Map map : maps) {
  329 + sendUtils.sendContingencyPlan(map);
  330 + }
  331 + } catch (IOException e) {
  332 + result.put("errCode", 502);
  333 + result.put("msg", "json数据格式异常");
  334 + logger.info("", e);
  335 + }
  336 +
  337 + return result;
  338 + }
  339 +}
src/main/java/com/bsth/websocket/handler/RealControlSocketHandler.java
1 -package com.bsth.websocket.handler;  
2 -  
3 -import com.alibaba.fastjson.JSONObject;  
4 -import com.bsth.data.BasicData;  
5 -import com.bsth.data.msg_queue.WebSocketPushQueue;  
6 -import com.google.common.base.Splitter;  
7 -import org.slf4j.Logger;  
8 -import org.slf4j.LoggerFactory;  
9 -import org.springframework.stereotype.Component;  
10 -import org.springframework.web.socket.*;  
11 -  
12 -import java.util.ArrayList;  
13 -import java.util.Collection;  
14 -import java.util.Iterator;  
15 -import java.util.List;  
16 -import java.util.concurrent.ConcurrentHashMap;  
17 -import java.util.concurrent.CopyOnWriteArrayList;  
18 -  
19 -/**  
20 - * @author PanZhao  
21 - */  
22 -@Component  
23 -public class RealControlSocketHandler implements WebSocketHandler {  
24 -  
25 - Logger logger = LoggerFactory.getLogger(this.getClass());  
26 -  
27 - private static ArrayList<WebSocketSession> users;  
28 - private static ConcurrentHashMap<String, CopyOnWriteArrayList<WebSocketSession>> listenMap;  
29 -  
30 - static {  
31 - users = new ArrayList<WebSocketSession>();  
32 - listenMap = new ConcurrentHashMap();  
33 - }  
34 -  
35 - @Override  
36 - public void afterConnectionClosed(WebSocketSession session, CloseStatus arg1)  
37 - throws Exception {  
38 - users.remove(session);  
39 - //清理监听  
40 - int vsCount=0;  
41 - Collection<CopyOnWriteArrayList<WebSocketSession>> vs = listenMap.values();  
42 - for(CopyOnWriteArrayList<WebSocketSession> list : vs){  
43 - list.remove(session);  
44 -  
45 - vsCount += list.size();  
46 - }  
47 - logger.info("listen values size: " + vsCount + " -CloseStatus:" + arg1 + "conn: " + users.size());  
48 - }  
49 -  
50 - @Override  
51 - public void afterConnectionEstablished(WebSocketSession session)  
52 - throws Exception {  
53 - session.setBinaryMessageSizeLimit(52768);  
54 - session.setTextMessageSizeLimit(52768);  
55 - users.add(session);  
56 - }  
57 -  
58 - @Override  
59 - public void handleMessage(WebSocketSession session, WebSocketMessage<?> msg)  
60 - throws Exception {  
61 - JSONObject jsonObj = JSONObject.parseObject(msg.getPayload().toString());  
62 - switch (jsonObj.getString("operCode")) {  
63 - case "register_line":  
64 - //注册线路监听  
65 - List<String> idx = Splitter.on(",").splitToList(jsonObj.getString("idx"));  
66 - for(String lineCode : idx){  
67 - if(BasicData.lineCode2NameMap.containsKey(lineCode)){  
68 - if(!listenMap.containsKey(lineCode)){  
69 - listenMap.put(lineCode, new CopyOnWriteArrayList<WebSocketSession>());  
70 - }  
71 - listenMap.get(lineCode).add(session);  
72 - }  
73 - }  
74 - break;  
75 -  
76 - default:  
77 - break;  
78 - }  
79 - logger.info(msg.getPayload().toString());  
80 - }  
81 -  
82 - @Override  
83 - public void handleTransportError(WebSocketSession session, Throwable arg1)  
84 - throws Exception {  
85 - if(session.isOpen()){  
86 - session.close();  
87 - }  
88 - users.remove(session);  
89 - }  
90 -  
91 - @Override  
92 - public boolean supportsPartialMessages() {  
93 - return false;  
94 - }  
95 -  
96 -  
97 - /**  
98 - * 根据线路推送消息  
99 - */  
100 - public void sendMessageToLine(String lineCode, String msg) {  
101 -  
102 - TextMessage message = new TextMessage(msg.getBytes());  
103 - List<WebSocketSession> list = listenMap.get(lineCode);  
104 - if(list == null || list.size() == 0)  
105 - return;  
106 -  
107 - for(WebSocketSession user : list){  
108 - WebSocketPushQueue.put(user, message);  
109 - /*try {  
110 - if (user.isOpen()) {  
111 - user.sendMessage(message);  
112 - }  
113 - } catch (Exception e) {  
114 - try{  
115 - logger.error("error user...."+user.getAttributes().get(Constants.SESSION_USERNAME));  
116 - }  
117 - catch(Exception e2){}  
118 - logger.error("sendMessageToLine error ...."+msg);  
119 - logger.error("sendMessageToLine error ....", e);  
120 - }*/  
121 - }  
122 - }  
123 -  
124 -  
125 -  
126 - /**  
127 - * 全局推送  
128 - */  
129 - public void sendMessage(String msg) {  
130 -  
131 - TextMessage message = new TextMessage(msg.getBytes());  
132 -  
133 - Iterator<WebSocketSession> iterator = users.iterator();  
134 -  
135 - WebSocketSession user;  
136 - while(iterator.hasNext()){  
137 - user = iterator.next();  
138 - WebSocketPushQueue.put(user, message);  
139 - /*try {  
140 - if (user.isOpen()) {  
141 - user.sendMessage(message);  
142 - }  
143 - } catch (Exception e) {  
144 - logger.error("sendMessage error ...."+msg);  
145 - }*/  
146 - }  
147 - }  
148 -} 1 +package com.bsth.websocket.handler;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.data.msg_queue.WebSocketPushQueue;
  6 +import com.google.common.base.Splitter;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.stereotype.Component;
  10 +import org.springframework.web.socket.*;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.Collection;
  14 +import java.util.Iterator;
  15 +import java.util.List;
  16 +import java.util.concurrent.ConcurrentHashMap;
  17 +import java.util.concurrent.CopyOnWriteArrayList;
  18 +
  19 +/**
  20 + * @author PanZhao
  21 + */
  22 +@Component
  23 +public class RealControlSocketHandler implements WebSocketHandler {
  24 +
  25 + Logger logger = LoggerFactory.getLogger(this.getClass());
  26 +
  27 + private static ArrayList<WebSocketSession> users;
  28 + private static ConcurrentHashMap<String, CopyOnWriteArrayList<WebSocketSession>> listenMap;
  29 +
  30 + static {
  31 + users = new ArrayList<WebSocketSession>();
  32 + listenMap = new ConcurrentHashMap();
  33 + }
  34 +
  35 + @Override
  36 + public void afterConnectionClosed(WebSocketSession session, CloseStatus arg1)
  37 + throws Exception {
  38 + users.remove(session);
  39 + //清理监听
  40 + int vsCount=0;
  41 + Collection<CopyOnWriteArrayList<WebSocketSession>> vs = listenMap.values();
  42 + for(CopyOnWriteArrayList<WebSocketSession> list : vs){
  43 + list.remove(session);
  44 +
  45 + vsCount += list.size();
  46 + }
  47 + logger.info("listen values size: " + vsCount + " -CloseStatus:" + arg1 + "conn: " + users.size());
  48 + }
  49 +
  50 + @Override
  51 + public void afterConnectionEstablished(WebSocketSession session)
  52 + throws Exception {
  53 + session.setBinaryMessageSizeLimit(52768);
  54 + session.setTextMessageSizeLimit(52768);
  55 + users.add(session);
  56 + }
  57 +
  58 + @Override
  59 + public void handleMessage(WebSocketSession session, WebSocketMessage<?> msg)
  60 + throws Exception {
  61 + JSONObject jsonObj = JSONObject.parseObject(msg.getPayload().toString());
  62 + switch (jsonObj.getString("operCode")) {
  63 + case "register_line":
  64 + //注册线路监听
  65 + List<String> idx = Splitter.on(",").splitToList(jsonObj.getString("idx"));
  66 + for(String lineCode : idx){
  67 + if(BasicData.lineCode2NameMap.containsKey(lineCode)){
  68 + if(!listenMap.containsKey(lineCode)){
  69 + listenMap.put(lineCode, new CopyOnWriteArrayList<WebSocketSession>());
  70 + }
  71 + listenMap.get(lineCode).add(session);
  72 + }
  73 + }
  74 + break;
  75 +
  76 + default:
  77 + break;
  78 + }
  79 + logger.info(msg.getPayload().toString());
  80 + }
  81 +
  82 + @Override
  83 + public void handleTransportError(WebSocketSession session, Throwable arg1)
  84 + throws Exception {
  85 + if(session.isOpen()){
  86 + session.close();
  87 + }
  88 + users.remove(session);
  89 + }
  90 +
  91 + @Override
  92 + public boolean supportsPartialMessages() {
  93 + return false;
  94 + }
  95 +
  96 +
  97 + /**
  98 + * 根据线路推送消息
  99 + */
  100 + public void sendMessageToLine(String lineCode, String msg) {
  101 +
  102 + TextMessage message = new TextMessage(msg.getBytes());
  103 + List<WebSocketSession> list = listenMap.get(lineCode);
  104 + if(list == null || list.size() == 0)
  105 + return;
  106 +
  107 + for(WebSocketSession user : list){
  108 + WebSocketPushQueue.put(user, message);
  109 + /*try {
  110 + if (user.isOpen()) {
  111 + user.sendMessage(message);
  112 + }
  113 + } catch (Exception e) {
  114 + try{
  115 + logger.error("error user...."+user.getAttributes().get(Constants.SESSION_USERNAME));
  116 + }
  117 + catch(Exception e2){}
  118 + logger.error("sendMessageToLine error ...."+msg);
  119 + logger.error("sendMessageToLine error ....", e);
  120 + }*/
  121 + }
  122 + }
  123 +
  124 +
  125 +
  126 + /**
  127 + * 全局推送
  128 + */
  129 + public void sendMessage(String msg) {
  130 +
  131 + TextMessage message = new TextMessage(msg.getBytes());
  132 +
  133 + Iterator<WebSocketSession> iterator = users.iterator();
  134 +
  135 + WebSocketSession user;
  136 + while(iterator.hasNext()){
  137 + user = iterator.next();
  138 + WebSocketPushQueue.put(user, message);
  139 + /*try {
  140 + if (user.isOpen()) {
  141 + user.sendMessage(message);
  142 + }
  143 + } catch (Exception e) {
  144 + logger.error("sendMessage error ...."+msg);
  145 + }*/
  146 + }
  147 + }
  148 +
  149 + /**
  150 + * 根据线路推送消息
  151 + */
  152 + public void sendMessageToUser(String userName, String msg) {
  153 +
  154 + TextMessage message = new TextMessage(msg.getBytes());
  155 +
  156 + for(WebSocketSession user : users){
  157 + if (userName.equals(user.getPrincipal().getName())) {
  158 + WebSocketPushQueue.put(user, message);
  159 + }
  160 + }
  161 + }
  162 +}
src/main/java/com/bsth/websocket/handler/SendUtils.java
@@ -230,7 +230,23 @@ public class SendUtils{ @@ -230,7 +230,23 @@ public class SendUtils{
230 try { 230 try {
231 socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map)); 231 socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
232 } catch (JsonProcessingException e) { 232 } catch (JsonProcessingException e) {
233 - logger.error("", e); 233 + logger.error("sendRfid", e);
  234 + }
  235 + }
  236 +
  237 + /**
  238 + * 将应急预案发送至线调页面
  239 + */
  240 + public void sendContingencyPlan(Map<String, Object> cp) {
  241 + Map<String, Object> map = new HashMap<>();
  242 + map.put("fn", "contingencyPlan");
  243 + map.put("data", cp);
  244 + ObjectMapper mapper = new ObjectMapper();
  245 +
  246 + try {
  247 + socketHandler.sendMessageToUser((String)cp.get("instructionsPeopleCode"), mapper.writeValueAsString(map));
  248 + } catch (JsonProcessingException e) {
  249 + logger.error("sendContingencyPlan", e);
234 } 250 }
235 } 251 }
236 } 252 }