Commit 07204d72e3a0567e969bf8e68081ea8f617c7864

Authored by 徐烜
2 parents 1ca919f8 96ea8d38

Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang

Showing 22 changed files with 572 additions and 455 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -186,16 +186,6 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, @@ -186,16 +186,6 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
186 186
187 /** 187 /**
188 * 188 *
189 - * @Title: trustStatus @Description: TODO(线路托管状态) @param @param lineCodes  
190 - * 线路编码 @throws  
191 - */  
192 - @RequestMapping(value = "/trustStatus")  
193 - public Map<Integer, Integer> trustStatus(@RequestParam String lineCodes) {  
194 - return scheduleRealInfoService.trustStatus(lineCodes);  
195 - }  
196 -  
197 - /**  
198 - *  
199 * @Title: outgoAdjustAll 189 * @Title: outgoAdjustAll
200 * @Description: TODO(批量待发调整) 190 * @Description: TODO(批量待发调整)
201 * @param @param list 191 * @param @param list
@@ -207,17 +197,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -207,17 +197,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
207 params = StringEscapeUtils.unescapeHtml4(params); 197 params = StringEscapeUtils.unescapeHtml4(params);
208 return scheduleRealInfoService.outgoAdjustAll(params); 198 return scheduleRealInfoService.outgoAdjustAll(params);
209 } 199 }
210 -  
211 - /**  
212 - *  
213 - * @Title: changeTrustStatus @Description: TODO(切换线路托管状态) @param @param  
214 - * lineCode 线路编码 @param @param status 托管状态 @throws  
215 - */  
216 - @RequestMapping(value = "/trustStatus/change", method = RequestMethod.POST)  
217 - public int changeTrustStatus(@RequestParam Integer lineCode, @RequestParam Integer status) {  
218 - //ScheduleBuffer.trustMap.put(lineCode, status);  
219 - return 200;  
220 - }  
221 200
222 /** 201 /**
223 * 202 *
@@ -243,12 +222,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -243,12 +222,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
243 return scheduleRealInfoService.findRouteByLine(lineCode); 222 return scheduleRealInfoService.findRouteByLine(lineCode);
244 } 223 }
245 224
246 - @RequestMapping(value = "/test/getSch")  
247 - public int getSch(){  
248 - //getSchedulePlanThread.start();  
249 - return 1;  
250 - }  
251 -  
252 /** 225 /**
253 * 226 *
254 * @Title: removeChildTask 227 * @Title: removeChildTask
@@ -269,7 +242,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -269,7 +242,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
269 */ 242 */
270 @RequestMapping(value = "/lineCode/{lineCode}") 243 @RequestMapping(value = "/lineCode/{lineCode}")
271 public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){ 244 public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){
272 - //return ScheduleBuffer.realSchedulListMap.get(lineCode);  
273 return dayOfSchedule.findByLineCode(lineCode); 245 return dayOfSchedule.findByLineCode(lineCode);
274 } 246 }
275 247
@@ -447,10 +419,10 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -447,10 +419,10 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
447 return scheduleRealInfoService.changeBcType(id, bcType, remarks); 419 return scheduleRealInfoService.changeBcType(id, bcType, remarks);
448 } 420 }
449 421
450 - @RequestMapping(value="/history", method=RequestMethod.POST) 422 +/* @RequestMapping(value="/history", method=RequestMethod.POST)
451 public Map<String,Object> historySave(ScheduleRealInfo sch){ 423 public Map<String,Object> historySave(ScheduleRealInfo sch){
452 return scheduleRealInfoService.historySave(sch); 424 return scheduleRealInfoService.historySave(sch);
453 - } 425 + }*/
454 426
455 427
456 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); 428 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
src/main/java/com/bsth/controller/report/ReportController.java
@@ -46,11 +46,18 @@ public class ReportController { @@ -46,11 +46,18 @@ public class ReportController {
46 for (ArrivalInfo a:list ) { 46 for (ArrivalInfo a:list ) {
47 Map<String, Object> m = new HashMap<String, Object>(); 47 Map<String, Object> m = new HashMap<String, Object>();
48 m.put("i", i); 48 m.put("i", i);
49 - m.put("mbbm", a.getNbbm()); 49 + m.put("nbbm", a.getNbbm());
50 m.put("stopName", a.getStopName()); 50 m.put("stopName", a.getStopName());
51 m.put("jzsj", a.getJzsj()); 51 m.put("jzsj", a.getJzsj());
52 m.put("czsj", a.getCzsj()); 52 m.put("czsj", a.getCzsj());
  53 + m.put("kgm", "");
53 m.put("upDown", a.getUpDown()==0?"上行":"下行"); 54 m.put("upDown", a.getUpDown()==0?"上行":"下行");
  55 + m.put("kmsd", "");
  56 + m.put("bufa", "");
  57 + m.put("skcs", "");
  58 + m.put("skje", "");
  59 + m.put("mfskcs", "");
  60 + m.put("mfskje", "");
54 resList.add(m); 61 resList.add(m);
55 i++; 62 i++;
56 } 63 }
@@ -77,6 +84,46 @@ public class ReportController { @@ -77,6 +84,46 @@ public class ReportController {
77 84
78 85
79 86
  87 + @RequestMapping(value="/exportQueryListClzd" ,method = RequestMethod.GET)
  88 + public List<Map<String, Object>> exportQueryListClzd(@RequestParam String zd,@RequestParam String line,
  89 + @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){
  90 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  91 + ReportUtils ee = new ReportUtils();
  92 + List<ArrivalInfo> list=service.queryListClzd(line,zd,zdlx,fcsj,ddsj);
  93 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  94 + int i=1;
  95 + for (ArrivalInfo a:list ) {
  96 + Map<String, Object> m = new HashMap<String, Object>();
  97 + m.put("i", i);
  98 + m.put("nbbm", a.getNbbm());
  99 + m.put("stopName", a.getStopName());
  100 + m.put("jzsj", a.getJzsj());
  101 + m.put("czsj", a.getCzsj());
  102 + m.put("kgm", "");
  103 + m.put("upDown", a.getUpDown()==0?"上行":"下行");
  104 + m.put("kmsd", "");
  105 + m.put("bufa", "");
  106 + m.put("skcs", "");
  107 + m.put("skje", "");
  108 + m.put("mfskcs", "");
  109 + m.put("mfskje", "");
  110 + resList.add(m);
  111 + i++;
  112 + }
  113 +
  114 + try {
  115 + Map<String, Object> map=new HashMap<String, Object>();
  116 + listI.add(resList.iterator());
  117 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  118 + ee.excelReplace(listI, new Object[] { map }, path + "mould/inoutstation.xls",
  119 + path + "export/班次到离站.xls");
  120 + } catch (Exception e) {
  121 + e.printStackTrace();
  122 + }
  123 + return resList;
  124 + }
  125 +
  126 +
80 @RequestMapping(value="/jobSummaryExport" ,method = RequestMethod.GET) 127 @RequestMapping(value="/jobSummaryExport" ,method = RequestMethod.GET)
81 public List<Map<String, Object>> jobSummaryExport(@RequestParam Map<String, Object> map){ 128 public List<Map<String, Object>> jobSummaryExport(@RequestParam Map<String, Object> map){
82 List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); 129 List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
@@ -85,7 +85,7 @@ public abstract class SignalHandle { @@ -85,7 +85,7 @@ public abstract class SignalHandle {
85 gps.setStopNo(station.getCode()); 85 gps.setStopNo(station.getCode());
86 } 86 }
87 87
88 - logger.info(fmtHHmm.print(gps.getTimestamp()) + " 车辆 :" + gps.getNbbm() + " 切换到走向 : " + updown); 88 + logger.info(gps.getTimestamp() + " -" + fmtHHmm.print(gps.getTimestamp()) + " 车辆 :" + gps.getNbbm() + " 切换到走向 : " + updown);
89 } 89 }
90 90
91 /** 91 /**
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
@@ -48,12 +48,6 @@ public class CorrectSignalHandle extends SignalHandle { @@ -48,12 +48,6 @@ public class CorrectSignalHandle extends SignalHandle {
48 gps.setState(0); 48 gps.setState(0);
49 } 49 }
50 50
51 - /*if(gps.getState() != 0){  
52 - logger.info(gps.getNbbm() + " 纠正状态到营运");  
53 - //切换到营运状态  
54 - directiveService.send60Operation(sch.getClZbh(), 0, Integer.parseInt(sch.getXlDir()), null, "纠正@系统");  
55 - }*/  
56 -  
57 return true; 51 return true;
58 } 52 }
59 } 53 }
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
@@ -257,13 +257,19 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -257,13 +257,19 @@ public class InOutStationSignalHandle extends SignalHandle{
257 dayOfSchedule.save(sch); 257 dayOfSchedule.save(sch);
258 258
259 if(next != null){ 259 if(next != null){
260 - next.setQdzArrDatesj(sch.getZdsjActual());  
261 dayOfSchedule.addExecPlan(next); 260 dayOfSchedule.addExecPlan(next);
262 //进站既进场 261 //进站既进场
263 inStationAndInPark(sch, next); 262 inStationAndInPark(sch, next);
264 } 263 }
  264 +
  265 + //该路牌的下一个班次,起点实际到达时间
  266 + ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch);
  267 + if(lpNext != null){
  268 + lpNext.setQdzArrDatesj(sch.getZdsjActual());
  269 + }
  270 +
265 //通知客户端 271 //通知客户端
266 - sendUtils.sendZdsj(sch, next, doneSum); 272 + sendUtils.sendZdsj(sch, lpNext, doneSum);
267 273
268 //准备执行下一个班次 274 //准备执行下一个班次
269 if (next != null) { 275 if (next != null) {
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
@@ -30,7 +30,8 @@ public class OfflineSignalHandle extends SignalHandle{ @@ -30,7 +30,8 @@ public class OfflineSignalHandle extends SignalHandle{
30 30
31 if(isNotEmpty(prevs)){ 31 if(isNotEmpty(prevs)){
32 GpsEntity prev = prevs.getTail(); 32 GpsEntity prev = prevs.getTail();
33 - int space = (int) (gps.getTimestamp() - prev.getTimestamp()); 33 + //间隔太大就丢弃,不管之前还是之后
  34 + int space = Math.abs((int) (gps.getTimestamp() - prev.getTimestamp()));
34 if(space > OFFLINE_TIME) 35 if(space > OFFLINE_TIME)
35 gps.setSignalState("reconnection"); 36 gps.setSignalState("reconnection");
36 37
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -23,7 +23,9 @@ import com.bsth.service.schedule.SchedulePlanInfoService; @@ -23,7 +23,9 @@ import com.bsth.service.schedule.SchedulePlanInfoService;
23 import com.bsth.util.BatchSaveUtils; 23 import com.bsth.util.BatchSaveUtils;
24 import com.bsth.util.DateUtils; 24 import com.bsth.util.DateUtils;
25 import com.bsth.websocket.handler.SendUtils; 25 import com.bsth.websocket.handler.SendUtils;
  26 +import com.google.common.base.Predicate;
26 import com.google.common.collect.ArrayListMultimap; 27 import com.google.common.collect.ArrayListMultimap;
  28 +import com.google.common.collect.Collections2;
27 import org.apache.commons.lang3.StringUtils; 29 import org.apache.commons.lang3.StringUtils;
28 import org.joda.time.format.DateTimeFormat; 30 import org.joda.time.format.DateTimeFormat;
29 import org.joda.time.format.DateTimeFormatter; 31 import org.joda.time.format.DateTimeFormatter;
@@ -59,16 +61,16 @@ public class DayOfSchedule implements CommandLineRunner { @@ -59,16 +61,16 @@ public class DayOfSchedule implements CommandLineRunner {
59 // 按车辆分组的班次数据 61 // 按车辆分组的班次数据
60 private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap; 62 private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap;
61 63
  64 + //按路牌分组的班次数据 线路编码_路牌名称 ——> 班次list
  65 + private static ArrayListMultimap<String, ScheduleRealInfo> lpScheduleMap;
  66 +
62 // 班次主键映射 67 // 班次主键映射
63 private static Map<Long, ScheduleRealInfo> id2SchedulMap; 68 private static Map<Long, ScheduleRealInfo> id2SchedulMap;
64 69
65 - // 车辆和排班起终点站对照(包括进出的停车场,区间起终点)  
66 - //private static TreeMultimap<String, String> nbbm2SEStationMap;  
67 -  
68 //车辆 ——> 当前执行班次 70 //车辆 ——> 当前执行班次
69 private static Map<String, ScheduleRealInfo> carExecutePlanMap; 71 private static Map<String, ScheduleRealInfo> carExecutePlanMap;
70 72
71 - // 持久化缓冲区 73 + // 持久化
72 public static LinkedList<ScheduleRealInfo> pstBuffer; 74 public static LinkedList<ScheduleRealInfo> pstBuffer;
73 75
74 // 排序器 76 // 排序器
@@ -102,11 +104,12 @@ public class DayOfSchedule implements CommandLineRunner { @@ -102,11 +104,12 @@ public class DayOfSchedule implements CommandLineRunner {
102 104
103 static { 105 static {
104 nbbmScheduleMap = ArrayListMultimap.create(); 106 nbbmScheduleMap = ArrayListMultimap.create();
  107 + lpScheduleMap = ArrayListMultimap.create();
  108 +
105 id2SchedulMap = new HashMap<>(); 109 id2SchedulMap = new HashMap<>();
106 pstBuffer = new LinkedList<>(); 110 pstBuffer = new LinkedList<>();
107 schFCSJComparator = new ScheduleComparator.FCSJ(); 111 schFCSJComparator = new ScheduleComparator.FCSJ();
108 currSchDateMap = new HashMap<>(); 112 currSchDateMap = new HashMap<>();
109 - //nbbm2SEStationMap = TreeMultimap.create();  
110 carExecutePlanMap = new HashMap<>(); 113 carExecutePlanMap = new HashMap<>();
111 114
112 schedulePlanMap = new HashMap<>(); 115 schedulePlanMap = new HashMap<>();
@@ -145,7 +148,7 @@ public class DayOfSchedule implements CommandLineRunner { @@ -145,7 +148,7 @@ public class DayOfSchedule implements CommandLineRunner {
145 //dataRecovery(); 148 //dataRecovery();
146 149
147 //翻班线程 150 //翻班线程
148 -// Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); 151 + Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
149 //入库 152 //入库
150 // Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 30, TimeUnit.SECONDS); 153 // Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 30, TimeUnit.SECONDS);
151 //班次误点扫描 154 //班次误点扫描
@@ -233,13 +236,19 @@ public class DayOfSchedule implements CommandLineRunner { @@ -233,13 +236,19 @@ public class DayOfSchedule implements CommandLineRunner {
233 //添加到缓存 236 //添加到缓存
234 putAll(list); 237 putAll(list);
235 238
236 - Set<String> cars = searchAllCars(list); 239 +
  240 + Set<String> lps = searchAllLP(list);
  241 + for(String lp : lps){
  242 + //计算“起点站应到”时间
  243 + schAttrCalculator.calcQdzTimePlan(lpScheduleMap.get(lineCode + "_" + lp));
  244 + }
  245 + /*Set<String> cars = searchAllCars(list);
237 for (String nbbm : cars) { 246 for (String nbbm : cars) {
238 //计算“起点站应到”时间 247 //计算“起点站应到”时间
239 schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm)); 248 schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm));
240 //车辆 ——> 要执行的班次对照 249 //车辆 ——> 要执行的班次对照
241 reCalcExecPlan(nbbm); 250 reCalcExecPlan(nbbm);
242 - } 251 + }*/
243 252
244 // 页面 翻班通知 253 // 页面 翻班通知
245 //sendUtils.shiftSchedule(lineCode); 254 //sendUtils.shiftSchedule(lineCode);
@@ -258,13 +267,25 @@ public class DayOfSchedule implements CommandLineRunner { @@ -258,13 +267,25 @@ public class DayOfSchedule implements CommandLineRunner {
258 /** 267 /**
259 * @Title: searchAllCars 268 * @Title: searchAllCars
260 * @Description: TODO(搜索班次集合中的车辆) 269 * @Description: TODO(搜索班次集合中的车辆)
261 - */ 270 +
262 private Set<String> searchAllCars(List<ScheduleRealInfo> list) { 271 private Set<String> searchAllCars(List<ScheduleRealInfo> list) {
263 Set<String> cars = new HashSet<>(); 272 Set<String> cars = new HashSet<>();
264 for (ScheduleRealInfo sch : list) 273 for (ScheduleRealInfo sch : list)
265 cars.add(sch.getClZbh()); 274 cars.add(sch.getClZbh());
266 275
267 return cars; 276 return cars;
  277 + }*/
  278 +
  279 + /**
  280 + * @Title: searchAllCars
  281 + * @Description: TODO(搜索班次集合中的路牌)
  282 + */
  283 + private Set<String> searchAllLP(List<ScheduleRealInfo> list) {
  284 + Set<String> lps = new HashSet<>();
  285 + for (ScheduleRealInfo sch : list)
  286 + lps.add(sch.getLpName());
  287 +
  288 + return lps;
268 } 289 }
269 290
270 private void putAll(List<ScheduleRealInfo> list) { 291 private void putAll(List<ScheduleRealInfo> list) {
@@ -312,6 +333,13 @@ public class DayOfSchedule implements CommandLineRunner { @@ -312,6 +333,13 @@ public class DayOfSchedule implements CommandLineRunner {
312 } 333 }
313 } 334 }
314 335
  336 + //清理路牌对照
  337 + Set<String> lps = lpScheduleMap.keySet();
  338 + for(String lp : lps){
  339 + if(lp.indexOf(lineCode + "_") != -1)
  340 + lpScheduleMap.removeAll(lp);
  341 + }
  342 +
315 logger.info(lineCode + "排班清理 " + count); 343 logger.info(lineCode + "排班清理 " + count);
316 } 344 }
317 345
@@ -496,18 +524,31 @@ public class DayOfSchedule implements CommandLineRunner { @@ -496,18 +524,31 @@ public class DayOfSchedule implements CommandLineRunner {
496 return id2SchedulMap.get(id); 524 return id2SchedulMap.get(id);
497 } 525 }
498 526
499 - /* public Set<String> getSEStationList(String nbbm) {  
500 - return nbbm2SEStationMap.get(nbbm);  
501 - }*/  
502 527
503 /** 528 /**
504 * @Title: next 529 * @Title: next
505 * @Description: TODO(下一个班次) 530 * @Description: TODO(下一个班次)
506 */ 531 */
507 public ScheduleRealInfo next(ScheduleRealInfo sch) { 532 public ScheduleRealInfo next(ScheduleRealInfo sch) {
  533 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  534 + return next(list, sch);
  535 + }
508 536
  537 + /**
  538 + * 下一个相同走向的班次
  539 + * @param sch
  540 + * @return
  541 + */
  542 + public ScheduleRealInfo nextSame(final ScheduleRealInfo sch){
509 List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); 543 List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
510 - int outConfig = -1; 544 + Collection<ScheduleRealInfo> subList = Collections2.filter(list, new Predicate<ScheduleRealInfo>(){
  545 +
  546 + @Override
  547 + public boolean apply(ScheduleRealInfo item) {
  548 + return item.getXlDir().equals(sch.getXlDir());
  549 + }
  550 + });
  551 + /*int outConfig = -1;
511 LineConfig config = lineConfigData.get(sch.getXlBm()); 552 LineConfig config = lineConfigData.get(sch.getXlBm());
512 if (config != null) 553 if (config != null)
513 outConfig = config.getOutConfig(); 554 outConfig = config.getOutConfig();
@@ -531,21 +572,22 @@ public class DayOfSchedule implements CommandLineRunner { @@ -531,21 +572,22 @@ public class DayOfSchedule implements CommandLineRunner {
531 && (!limitPark || park.equals(temp.getQdzCode()))) 572 && (!limitPark || park.equals(temp.getQdzCode())))
532 continue; 573 continue;
533 574
534 - if (flag) { 575 + if (flag && temp.getXlDir().equals(sch.getXlDir())) {
535 next = temp; 576 next = temp;
536 break; 577 break;
537 } 578 }
538 - }  
539 - return next; 579 + }*/
  580 + return next(subList, sch);
540 } 581 }
541 582
  583 +
542 /** 584 /**
543 - * 下一个相同走向的班次  
544 - * @param sch 585 + * 下一个班次
  586 + * @param list 班次集合
  587 + * @param sch 当前班次
545 * @return 588 * @return
546 */ 589 */
547 - public ScheduleRealInfo nextSame(ScheduleRealInfo sch){  
548 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); 590 + private ScheduleRealInfo next(Collection<ScheduleRealInfo> list , ScheduleRealInfo sch){
549 int outConfig = -1; 591 int outConfig = -1;
550 LineConfig config = lineConfigData.get(sch.getXlBm()); 592 LineConfig config = lineConfigData.get(sch.getXlBm());
551 if (config != null) 593 if (config != null)
@@ -570,7 +612,7 @@ public class DayOfSchedule implements CommandLineRunner { @@ -570,7 +612,7 @@ public class DayOfSchedule implements CommandLineRunner {
570 && (!limitPark || park.equals(temp.getQdzCode()))) 612 && (!limitPark || park.equals(temp.getQdzCode())))
571 continue; 613 continue;
572 614
573 - if (flag && temp.getXlDir().equals(sch.getXlDir())) { 615 + if (flag) {
574 next = temp; 616 next = temp;
575 break; 617 break;
576 } 618 }
@@ -626,16 +668,21 @@ public class DayOfSchedule implements CommandLineRunner { @@ -626,16 +668,21 @@ public class DayOfSchedule implements CommandLineRunner {
626 668
627 String nbbm = sch.getClZbh(); 669 String nbbm = sch.getClZbh();
628 nbbmScheduleMap.put(nbbm, sch); 670 nbbmScheduleMap.put(nbbm, sch);
629 - //nbbm2SEStationMap.put(nbbm, sch.getQdzCode());  
630 - //nbbm2SEStationMap.put(nbbm, sch.getZdzCode());  
631 671
632 //主键索引 672 //主键索引
633 id2SchedulMap.put(sch.getId(), sch); 673 id2SchedulMap.put(sch.getId(), sch);
  674 + //路牌对照表
  675 + addLPMapp(sch);
  676 +
634 //跨24点的,再save一次 677 //跨24点的,再save一次
635 if (!sch.getRealExecDate().equals(sch.getScheduleDateStr())) 678 if (!sch.getRealExecDate().equals(sch.getScheduleDateStr()))
636 save(sch); 679 save(sch);
637 } 680 }
638 681
  682 + public void addLPMapp(ScheduleRealInfo sch){
  683 + lpScheduleMap.put(sch.getXlBm() + "_" + sch.getLpName(), sch);
  684 + }
  685 +
639 public void delete(ScheduleRealInfo sch) { 686 public void delete(ScheduleRealInfo sch) {
640 //ScheduleRealInfo sch = id2SchedulMap.get(id); 687 //ScheduleRealInfo sch = id2SchedulMap.get(id);
641 if (!sch.isSflj()) 688 if (!sch.isSflj())
@@ -647,9 +694,15 @@ public class DayOfSchedule implements CommandLineRunner { @@ -647,9 +694,15 @@ public class DayOfSchedule implements CommandLineRunner {
647 } 694 }
648 695
649 696
650 - public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm) { 697 +/* public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm) {
651 Collections.sort(nbbmScheduleMap.get(nbbm), schFCSJComparator); 698 Collections.sort(nbbmScheduleMap.get(nbbm), schFCSJComparator);
652 return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm)); 699 return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm));
  700 + }*/
  701 +
  702 + public List<ScheduleRealInfo> updateQdzTimePlan(String lpName) {
  703 + List<ScheduleRealInfo> list = lpScheduleMap.get(lpName);
  704 + Collections.sort(list, schFCSJComparator);
  705 + return schAttrCalculator.updateQdzTimePlan(list);
653 } 706 }
654 707
655 /** 708 /**
@@ -810,9 +863,9 @@ public class DayOfSchedule implements CommandLineRunner { @@ -810,9 +863,9 @@ public class DayOfSchedule implements CommandLineRunner {
810 */ 863 */
811 public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) { 864 public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) {
812 List<ScheduleRealInfo> ups = new ArrayList<>(); 865 List<ScheduleRealInfo> ups = new ArrayList<>();
813 - String oldClzbh = sch.getClZbh(); 866 + /*String oldClzbh = sch.getClZbh();
814 if (oldClzbh.equals(newClZbh)) 867 if (oldClzbh.equals(newClZbh))
815 - return ups; 868 + return ups;*/
816 869
817 870
818 //变更相关映射信息 871 //变更相关映射信息
@@ -820,12 +873,10 @@ public class DayOfSchedule implements CommandLineRunner { @@ -820,12 +873,10 @@ public class DayOfSchedule implements CommandLineRunner {
820 873
821 sch.setClZbh(newClZbh); 874 sch.setClZbh(newClZbh);
822 nbbmScheduleMap.put(newClZbh, sch); 875 nbbmScheduleMap.put(newClZbh, sch);
823 - //nbbm2SEStationMap.put(newClZbh, sch.getQdzCode());  
824 - //nbbm2SEStationMap.put(newClZbh, sch.getZdzCode());  
825 876
826 //重新计算班次应到时间 877 //重新计算班次应到时间
827 - ups.addAll(updateQdzTimePlan(oldClzbh));  
828 - ups.addAll(updateQdzTimePlan(newClZbh)); 878 + //ups.addAll(updateQdzTimePlan(oldClzbh));
  879 + //ups.addAll(updateQdzTimePlan(newClZbh));
829 880
830 //重新计算车辆当前执行班次 881 //重新计算车辆当前执行班次
831 reCalcExecPlan(newClZbh); 882 reCalcExecPlan(newClZbh);
@@ -942,4 +993,15 @@ public class DayOfSchedule implements CommandLineRunner { @@ -942,4 +993,15 @@ public class DayOfSchedule implements CommandLineRunner {
942 //重新计算班次应到时间 993 //重新计算班次应到时间
943 updateQdzTimePlan(nbbm); 994 updateQdzTimePlan(nbbm);
944 } 995 }
  996 +
  997 + /**
  998 + * 获取该班次所在路牌的下一个班次
  999 + * @param sch
  1000 + * @return
  1001 + */
  1002 + public ScheduleRealInfo nextByLp(ScheduleRealInfo sch) {
  1003 + List<ScheduleRealInfo> list = lpScheduleMap.get(sch.getXlBm() + "_" + sch.getLpName());
  1004 + Collections.sort(list, schFCSJComparator);
  1005 + return next(list, sch);
  1006 + }
945 } 1007 }
946 \ No newline at end of file 1008 \ No newline at end of file
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
@@ -104,7 +104,7 @@ public class SchAttrCalculator { @@ -104,7 +104,7 @@ public class SchAttrCalculator {
104 /** 104 /**
105 * 105 *
106 * @Title: calcQdzTimePlan 106 * @Title: calcQdzTimePlan
107 - * @Description: TODO(计算班次的起点应到时间,list 必须是同一辆车的班次) 107 + * @Description: TODO(计算班次的起点应到时间)
108 */ 108 */
109 public void calcQdzTimePlan(List<ScheduleRealInfo> list){ 109 public void calcQdzTimePlan(List<ScheduleRealInfo> list){
110 Collections.sort(list, new ScheduleComparator.FCSJ()); 110 Collections.sort(list, new ScheduleComparator.FCSJ());
@@ -116,12 +116,13 @@ public class SchAttrCalculator { @@ -116,12 +116,13 @@ public class SchAttrCalculator {
116 ScheduleRealInfo prve = list.get(0), curr; 116 ScheduleRealInfo prve = list.get(0), curr;
117 for(int i = 1; i < len; i ++){ 117 for(int i = 1; i < len; i ++){
118 curr = list.get(i); 118 curr = list.get(i);
119 - if(prve.getZdzName().equals(curr.getQdzName())){ 119 +
  120 + if(prve.getZdzName().equals(curr.getQdzName())
  121 + || prve.getZdzCode().equals(curr.getQdzCode())){
120 curr.setQdzArrDateJH(prve.getZdsj()); 122 curr.setQdzArrDateJH(prve.getZdsj());
121 - if(StringUtils.isNotEmpty(prve.getZdsjActual()) && StringUtils.isEmpty(curr.getQdzArrDatesj())) 123 + if(StringUtils.isNotEmpty(prve.getZdsjActual()))
122 curr.setQdzArrDatesj(prve.getZdsjActual()); 124 curr.setQdzArrDatesj(prve.getZdsjActual());
123 } 125 }
124 -  
125 prve = curr; 126 prve = curr;
126 } 127 }
127 } 128 }
@@ -129,7 +130,7 @@ public class SchAttrCalculator { @@ -129,7 +130,7 @@ public class SchAttrCalculator {
129 /** 130 /**
130 * 131 *
131 * @Title: updateQdzTimePlan 132 * @Title: updateQdzTimePlan
132 - * @Description: TODO(更新班次的起点应到时间,list 必须是同一辆车的班次) 并返回被更新的班次 133 + * @Description: TODO(更新班次的起点应到时间) 并返回被更新的班次
133 */ 134 */
134 public List<ScheduleRealInfo> updateQdzTimePlan(List<ScheduleRealInfo> list){ 135 public List<ScheduleRealInfo> updateQdzTimePlan(List<ScheduleRealInfo> list){
135 Collections.sort(list, new ScheduleComparator.FCSJ()); 136 Collections.sort(list, new ScheduleComparator.FCSJ());
@@ -143,7 +144,8 @@ public class SchAttrCalculator { @@ -143,7 +144,8 @@ public class SchAttrCalculator {
143 for(int i = 1; i < len; i ++){ 144 for(int i = 1; i < len; i ++){
144 curr = list.get(i); 145 curr = list.get(i);
145 146
146 - if(prve.getZdzName().equals(curr.getQdzName())){ 147 + if(prve.getZdzName().equals(curr.getQdzName())
  148 + || prve.getZdzCode().equals(curr.getQdzCode())){
147 149
148 if(curr.getQdzArrDateJH() != null && prve.getZdsj().equals(curr.getQdzArrDateJH())){ 150 if(curr.getQdzArrDateJH() != null && prve.getZdsj().equals(curr.getQdzArrDateJH())){
149 prve = curr; 151 prve = curr;
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
@@ -57,8 +57,6 @@ public class ScheduleRefreshThread extends Thread{ @@ -57,8 +57,6 @@ public class ScheduleRefreshThread extends Thread{
57 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ 57 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){
58 58
59 logger.info(lineCode + "开始翻班, " + currSchDate); 59 logger.info(lineCode + "开始翻班, " + currSchDate);
60 - //清除进出站数据  
61 - //arrivalData.clearRAMData(lineCode);  
62 //清除指令数据 60 //清除指令数据
63 Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode); 61 Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode);
64 for(String car : cars) 62 for(String car : cars)
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
@@ -779,6 +779,8 @@ public class ScheduleRealInfo { @@ -779,6 +779,8 @@ public class ScheduleRealInfo {
779 779
780 public void destroy(){ 780 public void destroy(){
781 this.jhlc = 0.0; 781 this.jhlc = 0.0;
  782 + if(this.isSflj())
  783 + this.jhlcOrig = 0.0;
782 this.status = -1; 784 this.status = -1;
783 this.clearFcsjActual(); 785 this.clearFcsjActual();
784 } 786 }
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -138,7 +138,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -138,7 +138,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
138 138
139 Map<String,Object> changeBcType(Long id, String bcType, String remarks); 139 Map<String,Object> changeBcType(Long id, String bcType, String remarks);
140 140
141 - Map<String,Object> historySave(ScheduleRealInfo sch); 141 + //Map<String,Object> historySave(ScheduleRealInfo sch);
142 142
143 Map<String, Object> MapById(Long id) ; 143 Map<String, Object> MapById(Long id) ;
144 144
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -3,7 +3,6 @@ package com.bsth.service.realcontrol.impl; @@ -3,7 +3,6 @@ package com.bsth.service.realcontrol.impl;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
6 -import com.alibaba.fastjson.support.odps.udf.CodecCheck.A;  
7 import com.bsth.common.Constants; 6 import com.bsth.common.Constants;
8 import com.bsth.common.ResponseCode; 7 import com.bsth.common.ResponseCode;
9 import com.bsth.controller.realcontrol.dto.ChangePersonCar; 8 import com.bsth.controller.realcontrol.dto.ChangePersonCar;
@@ -158,6 +157,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -158,6 +157,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
158 private static int BUF_SIZE = 1024; 157 private static int BUF_SIZE = 1024;
159 158
160 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); 159 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  160 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
161 161
162 @Override 162 @Override
163 public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType) { 163 public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType) {
@@ -166,7 +166,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -166,7 +166,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
166 166
167 ScheduleRealInfo schedule = dayOfSchedule.get(id); 167 ScheduleRealInfo schedule = dayOfSchedule.get(id);
168 168
169 -  
170 LineConfig config = lineConfigData.get(schedule.getXlBm()); 169 LineConfig config = lineConfigData.get(schedule.getXlBm());
171 //小于线路开始运营时间,则默认跨过24点 170 //小于线路开始运营时间,则默认跨过24点
172 if (dfsj.compareTo(config.getStartOpt()) < 0) { 171 if (dfsj.compareTo(config.getStartOpt()) < 0) {
@@ -178,17 +177,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -178,17 +177,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
178 schedule.setDfsjAll(dfsj); 177 schedule.setDfsjAll(dfsj);
179 schedule.addRemarks(remarks); 178 schedule.addRemarks(remarks);
180 179
181 - //取消应发未到标记  
182 - if(schedule.isLate2()){  
183 - schedule.setLate2(false);  
184 - LateAdjustHandle.remove(schedule);  
185 - }  
186 -  
187 List<ScheduleRealInfo> ts = new ArrayList<>(); 180 List<ScheduleRealInfo> ts = new ArrayList<>();
188 ts.add(schedule); 181 ts.add(schedule);
189 //调整终点时间和下一个班次的应到时间 182 //调整终点时间和下一个班次的应到时间
190 schedule.calcEndTime(); 183 schedule.calcEndTime();
191 - ScheduleRealInfo nextSch = dayOfSchedule.next(schedule); 184 + ScheduleRealInfo nextSch = dayOfSchedule.nextByLp(schedule);
192 if (null != nextSch) { 185 if (null != nextSch) {
193 nextSch.setQdzArrDateJH(schedule.getZdsj()); 186 nextSch.setQdzArrDateJH(schedule.getZdsj());
194 ts.add(nextSch); 187 ts.add(nextSch);
@@ -201,7 +194,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -201,7 +194,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
201 194
202 //重新计算是否误点 195 //重新计算是否误点
203 schedule.reCalcLate(); 196 schedule.reCalcLate();
204 - 197 + //取消应发未到标记,不再自动调整待发
  198 + if(schedule.isLate2()){
  199 + schedule.setLate2(false);
  200 + LateAdjustHandle.remove(schedule);
  201 + }
205 // 持久化到数据库 202 // 持久化到数据库
206 dayOfSchedule.save(schedule); 203 dayOfSchedule.save(schedule);
207 204
@@ -223,7 +220,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -223,7 +220,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
223 try { 220 try {
224 List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr)); 221 List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
225 222
226 - ScheduleRealInfo schedule = null, next; 223 + ScheduleRealInfo schedule = null;
227 for (String id : idList) { 224 for (String id : idList) {
228 schedule = dayOfSchedule.get(Long.parseLong(id)); 225 schedule = dayOfSchedule.get(Long.parseLong(id));
229 if (schedule.isDestroy()) { 226 if (schedule.isDestroy()) {
@@ -238,13 +235,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -238,13 +235,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
238 235
239 dayOfSchedule.save(schedule); 236 dayOfSchedule.save(schedule);
240 rsList.add(schedule); 237 rsList.add(schedule);
241 -  
242 - /*//如果正在执行当前班次,跳下一个班次  
243 - execSch = dayOfSchedule.executeCurr(schedule.getClZbh());  
244 - if(execSch != null && execSch.getId().equals(schedule.getId())){  
245 - next = dayOfSchedule.next(schedule);  
246 - dayOfSchedule.addExecPlan(next);  
247 - }*/  
248 } 238 }
249 239
250 //重新计算当前执行班次 240 //重新计算当前执行班次
@@ -946,23 +936,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -946,23 +936,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
946 for (int i = 1; i < size; i++) { 936 for (int i = 1; i < size; i++) {
947 st += plus; 937 st += plus;
948 sch = list.get(i); 938 sch = list.get(i);
949 - sch.setDfsjAll(st);  
950 - //重新计算终点时间  
951 - sch.calcEndTime();  
952 939
953 - dayOfSchedule.save(sch);  
954 -  
955 - updateList.add(sch);  
956 - next = dayOfSchedule.next(sch);  
957 - if (next.getQdzName().equals(sch.getZdzName())) {  
958 - next.setQdzArrDateJH(sch.getZdsj());  
959 - updateList.add(next);  
960 - } 940 + //调整待发
  941 + outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null);
961 } 942 }
962 943
963 -  
964 rs.put("status", ResponseCode.SUCCESS); 944 rs.put("status", ResponseCode.SUCCESS);
965 - rs.put("ts", updateList); 945 + //返回最后一个班次,页面会全量刷新
  946 + rs.put("t", sch);
966 } 947 }
967 948
968 } catch (Exception e) { 949 } catch (Exception e) {
@@ -980,121 +961,146 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -980,121 +961,146 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
980 List<ScheduleRealInfo> ts = new ArrayList<>(); 961 List<ScheduleRealInfo> ts = new ArrayList<>();
981 try { 962 try {
982 Long id = Long.parseLong(map.get("id")); 963 Long id = Long.parseLong(map.get("id"));
983 - //实际发车时间  
984 - String fcsjActual = map.get("fcsjActual");  
985 - //实际终点时间  
986 - String zdsjActual = map.get("zdsjActual");  
987 - //备注  
988 - String remarks = map.get("remarks");  
989 ScheduleRealInfo sch = dayOfSchedule.get(id); 964 ScheduleRealInfo sch = dayOfSchedule.get(id);
990 - if (null != sch) {  
991 -  
992 - String clZbh = map.get("clZbh");  
993 - if (StringUtils.isNotEmpty(clZbh)) {  
994 - //换车  
995 - BiMap<String, String> clMap = BasicData.deviceId2NbbmMap.inverse();  
996 - if (clMap.get(clZbh) == null) {  
997 - rs.put("status", ResponseCode.ERROR);  
998 - rs.put("msg", "车辆 " + clZbh + " 不存在!");  
999 - return rs;  
1000 - } else {  
1001 - dayOfSchedule.changeCar(sch, clZbh);  
1002 - }  
1003 - }  
1004 - //换驾驶员  
1005 - String jsy = map.get("jsy");  
1006 - if (StringUtils.isNotEmpty(jsy) && jsy.indexOf("/") != -1) {  
1007 - persoChange(sch, jsy.split("/")[0]);  
1008 - }  
1009 - //换售票员  
1010 - String spy = map.get("spy");  
1011 - if (StringUtils.isNotEmpty(spy) && spy.indexOf("/") != -1 && !spy.equals("/")) {  
1012 - persoChangeSPY(sch, spy.split("/")[0]);  
1013 - }  
1014 - else{  
1015 - sch.setsGh("");  
1016 - sch.setsName("");  
1017 - }  
1018 965
  966 + if(null == sch){
  967 + rs.put("status", ResponseCode.ERROR);
  968 + rs.put("msg", "不存在的班次!");
  969 + return rs;
  970 + }
1019 971
1020 - if (StringUtils.isNotBlank(fcsjActual)) {  
1021 - LineConfig config = lineConfigData.get(sch.getXlBm());  
1022 - long t = 0L;  
1023 - //小于线路开始运营时间,则默认跨过24点  
1024 - if (fcsjActual.compareTo(config.getStartOpt()) < 0)  
1025 - t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);  
1026 - else  
1027 - t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual); 972 + /**
  973 + * 换车
  974 + */
  975 + String clZbh = map.get("clZbh");
  976 + if (StringUtils.isNotEmpty(clZbh)) {
  977 + //换车
  978 + if (!BasicData.deviceId2NbbmMap.inverse().containsKey(clZbh)) {
  979 + rs.put("status", ResponseCode.ERROR);
  980 + rs.put("msg", "车辆 " + clZbh + " 不存在!");
  981 + return rs;
  982 + } else {
  983 + dayOfSchedule.changeCar(sch, clZbh);
  984 + }
  985 + }
1028 986
1029 - //调整实发  
1030 - if (!fcsjActual.equals(sch.getFcsjActual())){  
1031 - sch.setFcsjActualAll(t); 987 + /**
  988 + * 换驾驶员
  989 + */
  990 + String jsy = map.get("jsy");
  991 + if (StringUtils.isNotEmpty(jsy) && jsy.indexOf("/") != -1) {
  992 + persoChange(sch, jsy.split("/")[0]);
  993 + }
1032 994
1033 - //取消应发未到标记  
1034 - if(sch.isLate2()){  
1035 - sch.setLate2(false);  
1036 - LateAdjustHandle.remove(sch);  
1037 - }  
1038 - }  
1039 - } else {  
1040 - //撤销实发  
1041 - if (sch.getFcsjActual() != null)  
1042 - revokeRealOutgo(sch.getId()); 995 + /**
  996 + * 换售票员
  997 + */
  998 + String spy = map.get("spy");
  999 + if (StringUtils.isNotEmpty(spy) && spy.indexOf("/") != -1 && !spy.equals("/")) {
  1000 + persoChangeSPY(sch, spy.split("/")[0]);
  1001 + }
  1002 + else{
  1003 + sch.setsGh("");
  1004 + sch.setsName("");
  1005 + }
  1006 +
  1007 + /**
  1008 + * 调整实发
  1009 + */
  1010 + String fcsjActual = map.get("fcsjActual");
  1011 + if (StringUtils.isNotBlank(fcsjActual)
  1012 + && !fcsjActual.equals(sch.getFcsjActual())) {
  1013 +
  1014 + LineConfig config = lineConfigData.get(sch.getXlBm());
  1015 + long t = 0L;
  1016 + //小于线路开始运营时间,则默认跨过24点
  1017 + if (fcsjActual.compareTo(config.getStartOpt()) < 0)
  1018 + t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);
  1019 + else
  1020 + t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);
  1021 +
  1022 + sch.setFcsjActualAll(t);
  1023 + //取消应发未到标记
  1024 + if(sch.isLate2()){
  1025 + sch.setLate2(false);
  1026 + LateAdjustHandle.remove(sch);
1043 } 1027 }
1044 - //实达时间  
1045 - if (StringUtils.isNotBlank(zdsjActual)) {  
1046 - if (!zdsjActual.equals(sch.getZdsjActual())) {  
1047 - //调整实达  
1048 - sch.setZdsjActualAll(zdsjActual);  
1049 - //下一班次起点到达时间  
1050 - ScheduleRealInfo next = dayOfSchedule.next(sch);  
1051 - if (null != next) {  
1052 - next.setQdzArrDateSJ(zdsjActual);  
1053 - next.setLate2(false);  
1054 - ts.add(next);  
1055 - } 1028 + } else if (sch.getFcsjActual() != null){
  1029 + //撤销实发
  1030 + revokeRealOutgo(sch.getId());
  1031 + }
1056 1032
1057 - //重新计算车辆执行班次  
1058 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1059 - }  
1060 - } else {  
1061 - //清除实达时间  
1062 - sch.clearZdsjActual();  
1063 - //清除下一班次起点到达时间  
1064 - ScheduleRealInfo next = dayOfSchedule.next(sch);  
1065 - if (null != next) {  
1066 - next.setQdzArrDateSJ(null);  
1067 - ts.add(next);  
1068 - } 1033 + /**
  1034 + * 调整实达
  1035 + */
  1036 + String zdsjActual = map.get("zdsjActual");
  1037 + if (StringUtils.isNotBlank(zdsjActual)
  1038 + && !zdsjActual.equals(sch.getZdsjActual())) {
  1039 +
  1040 + //调整实达
  1041 + sch.setZdsjActualAll(zdsjActual);
  1042 + //路牌下一班起点到达时间
  1043 + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);
  1044 + if (null != next) {
  1045 + next.setQdzArrDateSJ(zdsjActual);
  1046 + next.setLate2(false);
  1047 + ts.add(next);
1069 } 1048 }
1070 - sch.setRemarks(remarks);  
1071 1049
1072 - try {  
1073 - //烂班  
1074 - if (map.get("status") != null  
1075 - && Integer.parseInt(map.get("status").toString()) == -1) {  
1076 - destroy(sch.getId() + "", "", map.get("adjustExps").toString());  
1077 - }  
1078 - } catch (NumberFormatException e) {  
1079 - logger.error("", e); 1050 + //重新计算车辆执行班次
  1051 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  1052 + } else if(StringUtils.isNotEmpty(sch.getZdsjActual())){
  1053 + //清除实达时间
  1054 + sch.clearZdsjActual();
  1055 + //清除路牌下一班起点到达时间
  1056 + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);
  1057 + if (null != next) {
  1058 + next.setQdzArrDateSJ(null);
  1059 + ts.add(next);
1080 } 1060 }
  1061 + //重新计算车辆执行班次
  1062 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  1063 + }
1081 1064
1082 - //修改班次里程  
1083 - String jhlc = map.get("jhlc");  
1084 - if (StringUtils.isNotEmpty(jhlc)) {  
1085 - if(Double.parseDouble(jhlc) == 0 && sch.getJhlcOrig() != 0)  
1086 - destroy(sch.getId() + "", "", map.get("adjustExps").toString());  
1087 - else{  
1088 - sch.setJhlc(Double.parseDouble(jhlc));  
1089 - } 1065 + /**
  1066 + * 备注
  1067 + */
  1068 + sch.setRemarks(map.get("remarks"));
  1069 +
  1070 + /**
  1071 + * 烂班
  1072 + */
  1073 + if (map.get("status") != null
  1074 + && Integer.parseInt(map.get("status").toString()) == -1) {
  1075 + destroy(sch.getId() + "", "", map.get("adjustExps").toString());
  1076 + }
  1077 +
  1078 + /**
  1079 + * 修改班次里程
  1080 + */
  1081 + String jhlc = map.get("jhlc");
  1082 + if (StringUtils.isNotEmpty(jhlc)) {
  1083 + double jhlcNum = Double.parseDouble(jhlc);
  1084 + //烂班
  1085 + if(jhlcNum == 0 && sch.getJhlcOrig() != 0)
  1086 + destroy(sch.getId() + "", "", map.get("adjustExps").toString());
  1087 + else if(jhlcNum != sch.getJhlc()){
  1088 + sch.setJhlc(jhlcNum);
  1089 + //临加班次,实际计划一起改
  1090 + if(sch.isSflj())
  1091 + sch.setJhlcOrig(jhlcNum);
1090 } 1092 }
1091 } 1093 }
1092 1094
  1095 + /**
  1096 + * 修改班次类型
  1097 + */
1093 String bcType = map.get("bcType"); 1098 String bcType = map.get("bcType");
1094 if (StringUtils.isNotEmpty(bcType)) { 1099 if (StringUtils.isNotEmpty(bcType)) {
1095 sch.setBcType(bcType); 1100 sch.setBcType(bcType);
1096 } 1101 }
1097 - //班次状态 1102 +
  1103 + //重新计算班次状态
1098 sch.calcStatus(); 1104 sch.calcStatus();
1099 dayOfSchedule.save(sch); 1105 dayOfSchedule.save(sch);
1100 //页面需要更新的班次信息 1106 //页面需要更新的班次信息
@@ -1118,25 +1124,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1118,25 +1124,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1118 ScheduleRealInfo schedule = null; 1124 ScheduleRealInfo schedule = null;
1119 JSONObject jsonObj; 1125 JSONObject jsonObj;
1120 String dfsj; 1126 String dfsj;
  1127 + long id;
1121 for (int i = 0; i < jsonArray.size(); i++) { 1128 for (int i = 0; i < jsonArray.size(); i++) {
1122 jsonObj = jsonArray.getJSONObject(i); 1129 jsonObj = jsonArray.getJSONObject(i);
1123 dfsj = jsonObj.getString("t"); 1130 dfsj = jsonObj.getString("t");
1124 - schedule = dayOfSchedule.get(jsonObj.getLong("id"));  
1125 - //设置待发时间  
1126 - schedule.setDfsjAll(dfsj);  
1127 - //重新计算是否误点  
1128 - schedule.reCalcLate(); 1131 + id = jsonObj.getLong("id");
  1132 + schedule = dayOfSchedule.get(id);
1129 1133
1130 - //取消应发未到标记  
1131 - if(schedule.isLate2()){  
1132 - schedule.setLate2(false);  
1133 - LateAdjustHandle.remove(schedule);  
1134 - }  
1135 - dayOfSchedule.save(schedule); 1134 + if(schedule != null)
  1135 + outgoAdjust(id, null, dfsj, null);
1136 } 1136 }
1137 1137
1138 rs.put("status", ResponseCode.SUCCESS); 1138 rs.put("status", ResponseCode.SUCCESS);
1139 - //将更新的最后一个班次返回 1139 + //将更新的最后一个班次返回,页面会做全量刷新
1140 rs.put("t", schedule); 1140 rs.put("t", schedule);
1141 } catch (Exception e) { 1141 } catch (Exception e) {
1142 logger.error("", e); 1142 logger.error("", e);
@@ -2909,29 +2909,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2909,29 +2909,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2909 Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>(); 2909 Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();
2910 List<ScheduleRealInfo> list = new ArrayList<>(); 2910 List<ScheduleRealInfo> list = new ArrayList<>();
2911 2911
2912 - ScheduleRealInfo sch, next;  
2913 for (DfsjChange dc : dfsjcs) { 2912 for (DfsjChange dc : dfsjcs) {
2914 if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj())) 2913 if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
2915 continue; 2914 continue;
2916 -  
2917 - /*sch = dayOfSchedule.get(dc.getSchId());  
2918 - if(sch==null)  
2919 - continue;  
2920 -  
2921 - sch.setDfsjAll(dc.getNew_dfsj());  
2922 - //重新计算终点时间  
2923 - sch.calcEndTime();  
2924 - list.add(sch);*/ 2915 +
2925 tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null); 2916 tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null);
2926 2917
2927 if (tempMap.get("status").equals(ResponseCode.SUCCESS)) { 2918 if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {
2928 list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts")); 2919 list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));
2929 } 2920 }
2930 - //next=dayOfSchedule.next(sch);  
2931 - /*if(next.getQdzName().equals(sch.getZdzName())){  
2932 - next.setQdzArrDateJH(sch.getZdsj());  
2933 - list.add(next);  
2934 - }*/  
2935 } 2921 }
2936 2922
2937 rs.put("status", ResponseCode.SUCCESS); 2923 rs.put("status", ResponseCode.SUCCESS);
@@ -3021,7 +3007,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3021,7 +3007,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3021 if (sch != null) { 3007 if (sch != null) {
3022 sch.setBcType(bcType); 3008 sch.setBcType(bcType);
3023 sch.addRemarks(remarks); 3009 sch.addRemarks(remarks);
3024 - //有时间记录一下相关变更数据  
3025 rs.put("status", ResponseCode.SUCCESS); 3010 rs.put("status", ResponseCode.SUCCESS);
3026 rs.put("t", sch); 3011 rs.put("t", sch);
3027 } 3012 }
@@ -3033,7 +3018,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3033,7 +3018,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3033 return rs; 3018 return rs;
3034 } 3019 }
3035 3020
3036 - @Override 3021 + /* @Override
3037 public Map<String, Object> historySave(ScheduleRealInfo sch) { 3022 public Map<String, Object> historySave(ScheduleRealInfo sch) {
3038 Map<String, Object> rs = new HashMap<>(); 3023 Map<String, Object> rs = new HashMap<>();
3039 rs.put("status", ResponseCode.ERROR); 3024 rs.put("status", ResponseCode.ERROR);
@@ -3073,7 +3058,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3073,7 +3058,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3073 scheduleRealInfoRepository.save(oldSch); 3058 scheduleRealInfoRepository.save(oldSch);
3074 rs.put("status", ResponseCode.SUCCESS); 3059 rs.put("status", ResponseCode.SUCCESS);
3075 return rs; 3060 return rs;
3076 - } 3061 + }*/
3077 3062
3078 @Autowired 3063 @Autowired
3079 SvgAttributeRepository svgAttributeRepository; 3064 SvgAttributeRepository svgAttributeRepository;
@@ -4151,8 +4136,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4151,8 +4136,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4151 4136
4152 sch.clearFcsjActual(); 4137 sch.clearFcsjActual();
4153 sch.clearZdsjActual(); 4138 sch.clearZdsjActual();
4154 - //清除下一个班次的起点到达时间  
4155 - ScheduleRealInfo next = dayOfSchedule.next(sch); 4139 + //清除路牌下一个班的起点到达时间
  4140 + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);
4156 if (null != next) { 4141 if (null != next) {
4157 next.setQdzArrDateSJ(null); 4142 next.setQdzArrDateSJ(null);
4158 ts.add(next); 4143 ts.add(next);
@@ -4164,6 +4149,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4164,6 +4149,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4164 rs.put("ts", ts); 4149 rs.put("ts", ts);
4165 4150
4166 dayOfSchedule.save(sch); 4151 dayOfSchedule.save(sch);
  4152 + //重新计算当前执行班次
  4153 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
4167 4154
4168 } 4155 }
4169 } catch (Exception e) { 4156 } catch (Exception e) {
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
@@ -141,8 +141,15 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { @@ -141,8 +141,15 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
141 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); 141 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
142 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); 142 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
143 143
144 - String company = map.get("company").toString();  
145 - String subCompany = map.get("subCompany").toString(); 144 + /*String company = "";
  145 + String subCompany ="";
  146 + if(map.get("company")!=null){
  147 + company = map.get("company").toString();
  148 + }
  149 +
  150 + if(map.get("subCompany")!=null){
  151 + subCompany=map.get("subCompany").toString();
  152 + }*/
146 String line = map.get("line").toString(); 153 String line = map.get("line").toString();
147 String date = map.get("date").toString(); 154 String date = map.get("date").toString();
148 String type = map.get("type").toString(); 155 String type = map.get("type").toString();
@@ -157,9 +164,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { @@ -157,9 +164,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
157 if(line.length() != 0){ 164 if(line.length() != 0){
158 sql += " and xl_bm = '"+line+"'"; 165 sql += " and xl_bm = '"+line+"'";
159 } 166 }
160 - if(company.length() != 0){ 167 + /*if(company.length() != 0){
161 sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; 168 sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
162 - } 169 + }*/
163 170
164 list = jdbcTemplate.query(sql, 171 list = jdbcTemplate.query(sql,
165 new RowMapper<SchedulePlanInfo>(){ 172 new RowMapper<SchedulePlanInfo>(){
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleService.java
1 -package com.bsth.service.schedule.rules;  
2 -  
3 -import com.bsth.entity.schedule.SchedulePlan;  
4 -import com.bsth.entity.schedule.SchedulePlanInfo;  
5 -import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;  
6 -  
7 -import java.util.Date;  
8 -import java.util.List;  
9 -  
10 -/**  
11 - * 排班计划使用的service。  
12 - */  
13 -public interface ScheduleRuleService {  
14 -  
15 - // TODO:之后所有排班使用的方法汇总到这里  
16 -  
17 - /**  
18 - * 查找最近的历史排班记录  
19 - * @param xlid 线路id  
20 - * @param from 开始时间  
21 - * @return  
22 - */  
23 - List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from);  
24 -  
25 - /**  
26 - * 生成排班计划。  
27 - * @param schedulePlan 计划主表  
28 - * @param schedulePlanInfos 计划明细表  
29 - */  
30 - void generateSchedulePlan(SchedulePlan schedulePlan, List<SchedulePlanInfo> schedulePlanInfos);  
31 -  
32 - /**  
33 - * 删除排班计划。  
34 - * @param id 排班计划id  
35 - */  
36 - void deleteSchedulePlanAll(Long id);  
37 -  
38 - /**  
39 - * 删除指定时间范围的排班明细。  
40 - * @param xlid 线路id  
41 - * @param datefrom 开始日期  
42 - * @param dateto 结束日期  
43 - */  
44 - void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto);  
45 -}  
46 - 1 +package com.bsth.service.schedule.rules;
  2 +
  3 +import com.bsth.entity.schedule.SchedulePlan;
  4 +import com.bsth.entity.schedule.SchedulePlanInfo;
  5 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
  6 +
  7 +import java.util.Date;
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * 排班计划使用的service。
  12 + */
  13 +public interface ScheduleRuleService {
  14 +
  15 + // TODO:之后所有排班使用的方法汇总到这里
  16 +
  17 + /**
  18 + * 查找最近的历史排班记录
  19 + * @param xlid 线路id
  20 + * @param from 开始时间
  21 + * @return
  22 + */
  23 + List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from);
  24 +
  25 + /**
  26 + * 生成排班计划。
  27 + * @param schedulePlan 计划主表
  28 + * @param schedulePlanInfos 计划明细表
  29 + */
  30 + void generateSchedulePlan(SchedulePlan schedulePlan, List<SchedulePlanInfo> schedulePlanInfos);
  31 +
  32 + /**
  33 + * 删除排班计划。
  34 + * @param id 排班计划id
  35 + */
  36 + void deleteSchedulePlanAll(Long id);
  37 +
  38 + /**
  39 + * 删除指定时间范围的排班明细。
  40 + * @param xlid 线路id
  41 + * @param datefrom 开始日期
  42 + * @param dateto 结束日期
  43 + */
  44 + void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto);
  45 +}
  46 +
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java
1 -package com.bsth.service.schedule.rules;  
2 -  
3 -import com.bsth.entity.schedule.SchedulePlan;  
4 -import com.bsth.entity.schedule.SchedulePlanInfo;  
5 -import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;  
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory;  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
10 -import org.springframework.jdbc.core.JdbcTemplate;  
11 -import org.springframework.jdbc.core.PreparedStatementCreator;  
12 -import org.springframework.jdbc.core.RowMapper;  
13 -import org.springframework.jdbc.support.GeneratedKeyHolder;  
14 -import org.springframework.jdbc.support.KeyHolder;  
15 -import org.springframework.stereotype.Service;  
16 -import org.springframework.transaction.annotation.Isolation;  
17 -import org.springframework.transaction.annotation.Propagation;  
18 -import org.springframework.transaction.annotation.Transactional;  
19 -  
20 -import java.sql.Connection;  
21 -import java.sql.PreparedStatement;  
22 -import java.sql.ResultSet;  
23 -import java.sql.SQLException;  
24 -import java.util.ArrayList;  
25 -import java.util.Date;  
26 -import java.util.List;  
27 -  
28 -/**  
29 - * Created by xu on 17/4/19.  
30 - */  
31 -@Service  
32 -public class ScheduleRuleServiceImpl implements ScheduleRuleService {  
33 - /** 日志记录器 */  
34 - private static final Logger logger = LoggerFactory.getLogger(ScheduleRuleServiceImpl.class);  
35 -  
36 - @Autowired  
37 - private JdbcTemplate jdbcTemplate;  
38 -  
39 - @Override  
40 - public List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from) {  
41 - String sql = "select * from bsth_c_s_sp_rule_rst a " +  
42 - "where exists (select 1 from " +  
43 - "(select t.rule_id as rid, max(t.schedule_date) as sd from bsth_c_s_sp_rule_rst t " +  
44 - "where t.xl_id = ? and t.schedule_date < ? " +  
45 - "group by t.rule_id) a2 " +  
46 - "where a.rule_id = rid and a.schedule_date = sd) ";  
47 -  
48 - return jdbcTemplate.query(sql, new Object[]{xlid, from}, new RowMapper<SchedulePlanRuleResult>() {  
49 - @Override  
50 - public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException {  
51 - SchedulePlanRuleResult obj = new SchedulePlanRuleResult();  
52 - obj.setRuleId(rs.getString("rule_id"));  
53 - obj.setScheduleDate(rs.getDate("schedule_date"));  
54 - obj.setGidindex(rs.getString("gidindex"));  
55 - obj.setEcindex(rs.getString("ecindex"));  
56 -  
57 - // 其他字段没用  
58 - return obj;  
59 - }  
60 - });  
61 - }  
62 -  
63 - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)  
64 - public void deleteSchedulePlanAll(Long id) {  
65 - String sql1 = "delete from bsth_c_s_sp where id = ?";  
66 - String sql2 = "delete from bsth_c_s_sp_info where schedule_plan = ?";  
67 -  
68 - jdbcTemplate.update(sql2, id);  
69 - jdbcTemplate.update(sql1, id);  
70 - }  
71 -  
72 - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)  
73 - public void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto) {  
74 - String sql = "delete from bsth_c_s_sp_info where xl = ? and schedule_date >= ? and schedule_date <= ?";  
75 - jdbcTemplate.update(sql, xlid, datefrom, dateto);  
76 - }  
77 -  
78 - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)  
79 - @Override  
80 - public void generateSchedulePlan(final SchedulePlan schedulePlan, final List<SchedulePlanInfo> schedulePlanInfos) {  
81 - // 1、插入排班计划主表,并获取主键id  
82 - KeyHolder keyHolder = new GeneratedKeyHolder();  
83 - jdbcTemplate.update(new PreparedStatementCreator() {  
84 - @Override  
85 - public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {  
86 - PreparedStatement ps = connection.prepareStatement(  
87 - SchedulePlan.generateInsertSql(), new String[] {"id"});  
88 - schedulePlan.preparedStatementSet(ps);  
89 -  
90 - return ps;  
91 - }  
92 - }, keyHolder);  
93 -  
94 - SchedulePlan master = new SchedulePlan();  
95 - master.setId(keyHolder.getKey().longValue());  
96 - for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) {  
97 - schedulePlanInfo.setSchedulePlan(master);  
98 - }  
99 -  
100 - // 2、批量插入排班计划从表  
101 - List<List<SchedulePlanInfo>> lists = new ArrayList<>();  
102 - int batchSize = 2000;  
103 - int loopCount = schedulePlanInfos.size() / batchSize;  
104 - int otherCount = schedulePlanInfos.size() % batchSize;  
105 - for (int i = 0; i < loopCount; i++) {  
106 - lists.add(schedulePlanInfos.subList(i * batchSize, i * batchSize + batchSize));  
107 - }  
108 - if (otherCount > 0) {  
109 - lists.add(schedulePlanInfos.subList(loopCount * batchSize, loopCount * batchSize + otherCount));  
110 - }  
111 -  
112 - for (final List<SchedulePlanInfo> list : lists) {  
113 - jdbcTemplate.batchUpdate(SchedulePlanInfo.generateInsertSql(), new BatchPreparedStatementSetter() {  
114 - @Override  
115 - public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {  
116 - SchedulePlanInfo schedulePlanInfo = list.get(i);  
117 - schedulePlanInfo.preparedStatementSet(preparedStatement);  
118 - }  
119 - @Override  
120 - public int getBatchSize() {  
121 - return list.size();  
122 - }  
123 - });  
124 - }  
125 -  
126 - }  
127 -}  
128 - 1 +package com.bsth.service.schedule.rules;
  2 +
  3 +import com.bsth.entity.schedule.SchedulePlan;
  4 +import com.bsth.entity.schedule.SchedulePlanInfo;
  5 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  10 +import org.springframework.jdbc.core.JdbcTemplate;
  11 +import org.springframework.jdbc.core.PreparedStatementCreator;
  12 +import org.springframework.jdbc.core.RowMapper;
  13 +import org.springframework.jdbc.support.GeneratedKeyHolder;
  14 +import org.springframework.jdbc.support.KeyHolder;
  15 +import org.springframework.stereotype.Service;
  16 +import org.springframework.transaction.annotation.Isolation;
  17 +import org.springframework.transaction.annotation.Propagation;
  18 +import org.springframework.transaction.annotation.Transactional;
  19 +
  20 +import java.sql.Connection;
  21 +import java.sql.PreparedStatement;
  22 +import java.sql.ResultSet;
  23 +import java.sql.SQLException;
  24 +import java.util.ArrayList;
  25 +import java.util.Date;
  26 +import java.util.List;
  27 +
  28 +/**
  29 + * Created by xu on 17/4/19.
  30 + */
  31 +@Service
  32 +public class ScheduleRuleServiceImpl implements ScheduleRuleService {
  33 + /** 日志记录器 */
  34 + private static final Logger logger = LoggerFactory.getLogger(ScheduleRuleServiceImpl.class);
  35 +
  36 + @Autowired
  37 + private JdbcTemplate jdbcTemplate;
  38 +
  39 + @Override
  40 + public List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from) {
  41 + String sql = "select * from bsth_c_s_sp_rule_rst a " +
  42 + "where exists (select 1 from " +
  43 + "(select t.rule_id as rid, max(t.schedule_date) as sd from bsth_c_s_sp_rule_rst t " +
  44 + "where t.xl_id = ? and t.schedule_date < ? " +
  45 + "group by t.rule_id) a2 " +
  46 + "where a.rule_id = rid and a.schedule_date = sd) ";
  47 +
  48 + return jdbcTemplate.query(sql, new Object[]{xlid, from}, new RowMapper<SchedulePlanRuleResult>() {
  49 + @Override
  50 + public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException {
  51 + SchedulePlanRuleResult obj = new SchedulePlanRuleResult();
  52 + obj.setRuleId(rs.getString("rule_id"));
  53 + obj.setScheduleDate(rs.getDate("schedule_date"));
  54 + obj.setGidindex(rs.getString("gidindex"));
  55 + obj.setEcindex(rs.getString("ecindex"));
  56 +
  57 + // 其他字段没用
  58 + return obj;
  59 + }
  60 + });
  61 + }
  62 +
  63 + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
  64 + public void deleteSchedulePlanAll(Long id) {
  65 + String sql1 = "delete from bsth_c_s_sp where id = ?";
  66 + String sql2 = "delete from bsth_c_s_sp_info where schedule_plan = ?";
  67 +
  68 + jdbcTemplate.update(sql2, id);
  69 + jdbcTemplate.update(sql1, id);
  70 + }
  71 +
  72 + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
  73 + public void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto) {
  74 + String sql = "delete from bsth_c_s_sp_info where xl = ? and schedule_date >= ? and schedule_date <= ?";
  75 + jdbcTemplate.update(sql, xlid, datefrom, dateto);
  76 + }
  77 +
  78 + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
  79 + @Override
  80 + public void generateSchedulePlan(final SchedulePlan schedulePlan, final List<SchedulePlanInfo> schedulePlanInfos) {
  81 + // 1、插入排班计划主表,并获取主键id
  82 + KeyHolder keyHolder = new GeneratedKeyHolder();
  83 + jdbcTemplate.update(new PreparedStatementCreator() {
  84 + @Override
  85 + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
  86 + PreparedStatement ps = connection.prepareStatement(
  87 + SchedulePlan.generateInsertSql(), new String[] {"id"});
  88 + schedulePlan.preparedStatementSet(ps);
  89 +
  90 + return ps;
  91 + }
  92 + }, keyHolder);
  93 +
  94 + SchedulePlan master = new SchedulePlan();
  95 + master.setId(keyHolder.getKey().longValue());
  96 + for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) {
  97 + schedulePlanInfo.setSchedulePlan(master);
  98 + }
  99 +
  100 + // 2、批量插入排班计划从表
  101 + List<List<SchedulePlanInfo>> lists = new ArrayList<>();
  102 + int batchSize = 2000;
  103 + int loopCount = schedulePlanInfos.size() / batchSize;
  104 + int otherCount = schedulePlanInfos.size() % batchSize;
  105 + for (int i = 0; i < loopCount; i++) {
  106 + lists.add(schedulePlanInfos.subList(i * batchSize, i * batchSize + batchSize));
  107 + }
  108 + if (otherCount > 0) {
  109 + lists.add(schedulePlanInfos.subList(loopCount * batchSize, loopCount * batchSize + otherCount));
  110 + }
  111 +
  112 + for (final List<SchedulePlanInfo> list : lists) {
  113 + jdbcTemplate.batchUpdate(SchedulePlanInfo.generateInsertSql(), new BatchPreparedStatementSetter() {
  114 + @Override
  115 + public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {
  116 + SchedulePlanInfo schedulePlanInfo = list.get(i);
  117 + schedulePlanInfo.preparedStatementSet(preparedStatement);
  118 + }
  119 + @Override
  120 + public int getBatchSize() {
  121 + return list.size();
  122 + }
  123 + });
  124 + }
  125 +
  126 + }
  127 +}
  128 +
src/main/java/com/bsth/util/db/DBUtils_oldSystem.java
@@ -50,8 +50,8 @@ public class DBUtils_oldSystem { @@ -50,8 +50,8 @@ public class DBUtils_oldSystem {
50 pool_conf.put("testConnectionOnCheckout", false); 50 pool_conf.put("testConnectionOnCheckout", false);
51 //异步检测连接的有效性 51 //异步检测连接的有效性
52 pool_conf.put("testConnectionOnCheckin", true); 52 pool_conf.put("testConnectionOnCheckin", true);
53 - //10分钟检测一次  
54 - pool_conf.put("idleConnectionTestPeriod", 60 * 10); 53 + //30秒检测一次
  54 + pool_conf.put("idleConnectionTestPeriod", 30);
55 ds_pooled = DataSources.pooledDataSource(ds_unpooled, pool_conf); 55 ds_pooled = DataSources.pooledDataSource(ds_unpooled, pool_conf);
56 } catch (ClassNotFoundException e) { 56 } catch (ClassNotFoundException e) {
57 logger.error(e.toString()); 57 logger.error(e.toString());
src/main/resources/static/pages/forms/mould/inoutstation.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/peopleCarPlan.html
@@ -101,32 +101,31 @@ @@ -101,32 +101,31 @@
101 day = "0" + day; 101 day = "0" + day;
102 $("#date").val(year + "-" + month + "-" + day); 102 $("#date").val(year + "-" + month + "-" + day);
103 103
104 - $.get('/basic/lineCode2Name',function(result){  
105 - var data=[];  
106 -  
107 - data.push({id: " ", text: "全部线路"});  
108 - for(var code in result){  
109 - data.push({id: code, text: result[code]});  
110 - }  
111 - console.log(data);  
112 - initPinYinSelect2('#line',data,'');  
113 - });  
114 - 104 + var fage=false;
  105 + var xlList;
115 var obj = []; 106 var obj = [];
116 - $.get('/user/companyData', function(result){  
117 - obj = result;  
118 - var options = '';  
119 - for(var i = 0; i < obj.length; i++){  
120 - options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';  
121 - }  
122 - if(obj.length == 1){  
123 - $('#company1').hide();  
124 - if(obj[0].children.length == 1)  
125 - $('#subCompany1').hide();  
126 - }  
127 - $('#company').html(options);  
128 - updateCompany();  
129 - }); 107 +
  108 +
  109 + $.get('/report/lineList',function(result){
  110 + xlList=result;
  111 + $.get('/user/companyData', function(result){
  112 + obj = result;
  113 + var options = '';
  114 + for(var i = 0; i < obj.length; i++){
  115 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  116 + }
  117 +
  118 + if(obj.length ==0){
  119 + $("#company1").css('display','none');
  120 + }else if(obj.length ==1){
  121 + $("#company1").css('display','none');
  122 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  123 + $('#subCompany1').css('display','none');
  124 + }
  125 + $('#company').html(options);
  126 + updateCompany();
  127 + });
  128 + })
130 $("#company").on("change",updateCompany); 129 $("#company").on("change",updateCompany);
131 function updateCompany(){ 130 function updateCompany(){
132 var company = $('#company').val(); 131 var company = $('#company').val();
@@ -140,6 +139,42 @@ @@ -140,6 +139,42 @@
140 } 139 }
141 } 140 }
142 $('#subCompany').html(options); 141 $('#subCompany').html(options);
  142 + initXl();
  143 + }
  144 +
  145 + /* $.get('/basic/lineCode2Name',function(result){
  146 + var data=[];
  147 +
  148 + for(var code in result){
  149 + data.push({id: code, text: result[code]});
  150 + }
  151 + initPinYinSelect2('#line',data,'');
  152 +
  153 + }) */
  154 +
  155 + $("#subCompany").on("change",initXl);
  156 + function initXl(){
  157 + var data=[];
  158 + if(fage){
  159 + $("#line").select2("destroy").html('');
  160 + }
  161 + var fgs=$('#subCompany').val();
  162 + var gs=$('#company').val();
  163 + for(var i=0;i<xlList.length;i++){
  164 + if(gs!=""){
  165 + if(fgs!=""){
  166 + if(xlList[i]["fgsbm"]==fgs && xlList[i]["gsbm"]==gs){
  167 + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]});
  168 + }
  169 + }else{
  170 + if(xlList[i]["gsbm"]==gs){
  171 + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]});
  172 + }
  173 + }
  174 + }
  175 + }
  176 + initPinYinSelect2('#line',data,'');
  177 + fage=true;
143 } 178 }
144 179
145 180
src/main/resources/static/real_control_v2/js/line_schedule/context_menu.js
@@ -118,7 +118,10 @@ var gb_schedule_context_menu = (function () { @@ -118,7 +118,10 @@ var gb_schedule_context_menu = (function () {
118 if (!isNaN(newValue) && newValue > 0) { 118 if (!isNaN(newValue) && newValue > 0) {
119 gb_common.$post_arr('/realSchedule/spaceAdjust', {ids: idArr, space: newValue}, function (rs) { 119 gb_common.$post_arr('/realSchedule/spaceAdjust', {ids: idArr, space: newValue}, function (rs) {
120 //刷新数据 120 //刷新数据
121 - gb_schedule_table.updateSchedule(rs.ts); 121 + if(rs.t){
  122 + gb_schedule_table.reLoadAndRefresh(rs.t.xlBm);
  123 + }
  124 + //gb_schedule_table.updateSchedule(rs.ts);
122 notify_succ('调整间隔成功!'); 125 notify_succ('调整间隔成功!');
123 }); 126 });
124 } else 127 } else
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
@@ -86,7 +86,7 @@ var gb_schedule_table = (function () { @@ -86,7 +86,7 @@ var gb_schedule_table = (function () {
86 .html(htmlStr); 86 .html(htmlStr);
87 } 87 }
88 88
89 - //标记车辆最后一个班次 89 + //标记路牌最后一个班次
90 markerLastByLine(lineCode); 90 markerLastByLine(lineCode);
91 //初始化图例相关,dbclick 不能代理事件 91 //初始化图例相关,dbclick 不能代理事件
92 gb_sch_legend.init(this); 92 gb_sch_legend.init(this);
@@ -495,7 +495,7 @@ var gb_schedule_table = (function () { @@ -495,7 +495,7 @@ var gb_schedule_table = (function () {
495 495
496 //标记终点时间 -线路 496 //标记终点时间 -线路
497 var markerLastByLine = function (lineCode) { 497 var markerLastByLine = function (lineCode) {
498 - var data = gb_common.groupBy(gb_common.get_vals(line2Schedule[lineCode]).filter(schDestroyFilter), 'clZbh'); 498 + var data = gb_common.groupBy(gb_common.get_vals(line2Schedule[lineCode]).filter(schDestroyFilter), 'lpName');
499 499
500 var array, lastSch, dl; 500 var array, lastSch, dl;
501 for (var nbbm in data) { 501 for (var nbbm in data) {
src/main/resources/static/real_control_v2/mapmonitor/fragments/playback_v2/main.html
@@ -858,6 +858,7 @@ @@ -858,6 +858,7 @@
858 upDown = roadUpdown; 858 upDown = roadUpdown;
859 859
860 map.clearOverlays(); 860 map.clearOverlays();
  861 + parkPolygons = {};//清除停车场对照
861 //路段 862 //路段
862 drawRoadPolyline(upDown); 863 drawRoadPolyline(upDown);
863 //站点 864 //站点
src/test/resources/testdata/test5.txt
1 -update bsth_c_s_sp_info a  
2 -set a.schedule_plan = (  
3 -select sp_id from bsth_c_s_sp_r_info b where a.id = b.sp_info_id  
4 -)  
5 -where a.schedule_plan is null  
6 -  
7 -select count(*) from bsth_c_s_sp_info 1 +update bsth_c_s_sp_info a
  2 +set a.schedule_plan = (
  3 +select sp_id from bsth_c_s_sp_r_info b where a.id = b.sp_info_id
  4 +)
  5 +where a.schedule_plan is null
  6 +
  7 +select count(*) from bsth_c_s_sp_info
8 where schedule_plan is null 8 where schedule_plan is null
9 \ No newline at end of file 9 \ No newline at end of file