Commit 912bfc75c91deb43fdf7b168ae1d1f928ae65aa1

Authored by 潘钊
1 parent d2dcc317

应到时间跟随路牌

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -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 189 * @Title: outgoAdjustAll
200 190 * @Description: TODO(批量待发调整)
201 191 * @param @param list
... ... @@ -207,17 +197,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
207 197 params = StringEscapeUtils.unescapeHtml4(params);
208 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 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 227 * @Title: removeChildTask
... ... @@ -269,7 +242,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
269 242 */
270 243 @RequestMapping(value = "/lineCode/{lineCode}")
271 244 public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){
272   - //return ScheduleBuffer.realSchedulListMap.get(lineCode);
273 245 return dayOfSchedule.findByLineCode(lineCode);
274 246 }
275 247  
... ... @@ -447,10 +419,10 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
447 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 423 public Map<String,Object> historySave(ScheduleRealInfo sch){
452 424 return scheduleRealInfoService.historySave(sch);
453   - }
  425 + }*/
454 426  
455 427  
456 428 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
... ...
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
... ... @@ -85,7 +85,7 @@ public abstract class SignalHandle {
85 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 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 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 257 dayOfSchedule.save(sch);
258 258  
259 259 if(next != null){
260   - next.setQdzArrDatesj(sch.getZdsjActual());
261 260 dayOfSchedule.addExecPlan(next);
262 261 //进站既进场
263 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 275 if (next != null) {
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -23,7 +23,9 @@ import com.bsth.service.schedule.SchedulePlanInfoService;
23 23 import com.bsth.util.BatchSaveUtils;
24 24 import com.bsth.util.DateUtils;
25 25 import com.bsth.websocket.handler.SendUtils;
  26 +import com.google.common.base.Predicate;
26 27 import com.google.common.collect.ArrayListMultimap;
  28 +import com.google.common.collect.Collections2;
27 29 import org.apache.commons.lang3.StringUtils;
28 30 import org.joda.time.format.DateTimeFormat;
29 31 import org.joda.time.format.DateTimeFormatter;
... ... @@ -59,16 +61,16 @@ public class DayOfSchedule implements CommandLineRunner {
59 61 // 按车辆分组的班次数据
60 62 private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap;
61 63  
  64 + //按路牌分组的班次数据 线路编码_路牌名称 ——> 班次list
  65 + private static ArrayListMultimap<String, ScheduleRealInfo> lpScheduleMap;
  66 +
62 67 // 班次主键映射
63 68 private static Map<Long, ScheduleRealInfo> id2SchedulMap;
64 69  
65   - // 车辆和排班起终点站对照(包括进出的停车场,区间起终点)
66   - //private static TreeMultimap<String, String> nbbm2SEStationMap;
67   -
68 70 //车辆 ——> 当前执行班次
69 71 private static Map<String, ScheduleRealInfo> carExecutePlanMap;
70 72  
71   - // 持久化缓冲区
  73 + // 持久化
72 74 public static LinkedList<ScheduleRealInfo> pstBuffer;
73 75  
74 76 // 排序器
... ... @@ -102,11 +104,12 @@ public class DayOfSchedule implements CommandLineRunner {
102 104  
103 105 static {
104 106 nbbmScheduleMap = ArrayListMultimap.create();
  107 + lpScheduleMap = ArrayListMultimap.create();
  108 +
105 109 id2SchedulMap = new HashMap<>();
106 110 pstBuffer = new LinkedList<>();
107 111 schFCSJComparator = new ScheduleComparator.FCSJ();
108 112 currSchDateMap = new HashMap<>();
109   - //nbbm2SEStationMap = TreeMultimap.create();
110 113 carExecutePlanMap = new HashMap<>();
111 114  
112 115 schedulePlanMap = new HashMap<>();
... ... @@ -145,7 +148,7 @@ public class DayOfSchedule implements CommandLineRunner {
145 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 153 // Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 30, TimeUnit.SECONDS);
151 154 //班次误点扫描
... ... @@ -233,13 +236,19 @@ public class DayOfSchedule implements CommandLineRunner {
233 236 //添加到缓存
234 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 246 for (String nbbm : cars) {
238 247 //计算“起点站应到”时间
239 248 schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm));
240 249 //车辆 ——> 要执行的班次对照
241 250 reCalcExecPlan(nbbm);
242   - }
  251 + }*/
243 252  
244 253 // 页面 翻班通知
245 254 //sendUtils.shiftSchedule(lineCode);
... ... @@ -258,13 +267,25 @@ public class DayOfSchedule implements CommandLineRunner {
258 267 /**
259 268 * @Title: searchAllCars
260 269 * @Description: TODO(搜索班次集合中的车辆)
261   - */
  270 +
262 271 private Set<String> searchAllCars(List<ScheduleRealInfo> list) {
263 272 Set<String> cars = new HashSet<>();
264 273 for (ScheduleRealInfo sch : list)
265 274 cars.add(sch.getClZbh());
266 275  
267 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 291 private void putAll(List<ScheduleRealInfo> list) {
... ... @@ -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 343 logger.info(lineCode + "排班清理 " + count);
316 344 }
317 345  
... ... @@ -496,18 +524,31 @@ public class DayOfSchedule implements CommandLineRunner {
496 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 529 * @Title: next
505 530 * @Description: TODO(下一个班次)
506 531 */
507 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 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 552 LineConfig config = lineConfigData.get(sch.getXlBm());
512 553 if (config != null)
513 554 outConfig = config.getOutConfig();
... ... @@ -531,21 +572,22 @@ public class DayOfSchedule implements CommandLineRunner {
531 572 && (!limitPark || park.equals(temp.getQdzCode())))
532 573 continue;
533 574  
534   - if (flag) {
  575 + if (flag && temp.getXlDir().equals(sch.getXlDir())) {
535 576 next = temp;
536 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 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 591 int outConfig = -1;
550 592 LineConfig config = lineConfigData.get(sch.getXlBm());
551 593 if (config != null)
... ... @@ -570,7 +612,7 @@ public class DayOfSchedule implements CommandLineRunner {
570 612 && (!limitPark || park.equals(temp.getQdzCode())))
571 613 continue;
572 614  
573   - if (flag && temp.getXlDir().equals(sch.getXlDir())) {
  615 + if (flag) {
574 616 next = temp;
575 617 break;
576 618 }
... ... @@ -626,16 +668,21 @@ public class DayOfSchedule implements CommandLineRunner {
626 668  
627 669 String nbbm = sch.getClZbh();
628 670 nbbmScheduleMap.put(nbbm, sch);
629   - //nbbm2SEStationMap.put(nbbm, sch.getQdzCode());
630   - //nbbm2SEStationMap.put(nbbm, sch.getZdzCode());
631 671  
632 672 //主键索引
633 673 id2SchedulMap.put(sch.getId(), sch);
  674 + //路牌对照表
  675 + addLPMapp(sch);
  676 +
634 677 //跨24点的,再save一次
635 678 if (!sch.getRealExecDate().equals(sch.getScheduleDateStr()))
636 679 save(sch);
637 680 }
638 681  
  682 + public void addLPMapp(ScheduleRealInfo sch){
  683 + lpScheduleMap.put(sch.getXlBm() + "_" + sch.getLpName(), sch);
  684 + }
  685 +
639 686 public void delete(ScheduleRealInfo sch) {
640 687 //ScheduleRealInfo sch = id2SchedulMap.get(id);
641 688 if (!sch.isSflj())
... ... @@ -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 698 Collections.sort(nbbmScheduleMap.get(nbbm), schFCSJComparator);
652 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 863 */
811 864 public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) {
812 865 List<ScheduleRealInfo> ups = new ArrayList<>();
813   - String oldClzbh = sch.getClZbh();
  866 + /*String oldClzbh = sch.getClZbh();
814 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 873  
821 874 sch.setClZbh(newClZbh);
822 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 882 reCalcExecPlan(newClZbh);
... ... @@ -942,4 +993,15 @@ public class DayOfSchedule implements CommandLineRunner {
942 993 //重新计算班次应到时间
943 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 1008 \ No newline at end of file
... ...
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
... ... @@ -104,7 +104,7 @@ public class SchAttrCalculator {
104 104 /**
105 105 *
106 106 * @Title: calcQdzTimePlan
107   - * @Description: TODO(计算班次的起点应到时间,list 必须是同一辆车的班次)
  107 + * @Description: TODO(计算班次的起点应到时间)
108 108 */
109 109 public void calcQdzTimePlan(List<ScheduleRealInfo> list){
110 110 Collections.sort(list, new ScheduleComparator.FCSJ());
... ... @@ -116,12 +116,13 @@ public class SchAttrCalculator {
116 116 ScheduleRealInfo prve = list.get(0), curr;
117 117 for(int i = 1; i < len; i ++){
118 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 122 curr.setQdzArrDateJH(prve.getZdsj());
121   - if(StringUtils.isNotEmpty(prve.getZdsjActual()) && StringUtils.isEmpty(curr.getQdzArrDatesj()))
  123 + if(StringUtils.isNotEmpty(prve.getZdsjActual()))
122 124 curr.setQdzArrDatesj(prve.getZdsjActual());
123 125 }
124   -
125 126 prve = curr;
126 127 }
127 128 }
... ... @@ -129,7 +130,7 @@ public class SchAttrCalculator {
129 130 /**
130 131 *
131 132 * @Title: updateQdzTimePlan
132   - * @Description: TODO(更新班次的起点应到时间,list 必须是同一辆车的班次) 并返回被更新的班次
  133 + * @Description: TODO(更新班次的起点应到时间) 并返回被更新的班次
133 134 */
134 135 public List<ScheduleRealInfo> updateQdzTimePlan(List<ScheduleRealInfo> list){
135 136 Collections.sort(list, new ScheduleComparator.FCSJ());
... ... @@ -143,7 +144,8 @@ public class SchAttrCalculator {
143 144 for(int i = 1; i < len; i ++){
144 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 150 if(curr.getQdzArrDateJH() != null && prve.getZdsj().equals(curr.getQdzArrDateJH())){
149 151 prve = curr;
... ...
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
... ... @@ -57,8 +57,6 @@ public class ScheduleRefreshThread extends Thread{
57 57 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){
58 58  
59 59 logger.info(lineCode + "开始翻班, " + currSchDate);
60   - //清除进出站数据
61   - //arrivalData.clearRAMData(lineCode);
62 60 //清除指令数据
63 61 Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode);
64 62 for(String car : cars)
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
... ... @@ -779,6 +779,8 @@ public class ScheduleRealInfo {
779 779  
780 780 public void destroy(){
781 781 this.jhlc = 0.0;
  782 + if(this.isSflj())
  783 + this.jhlcOrig = 0.0;
782 784 this.status = -1;
783 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 138  
139 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 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 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONArray;
5 5 import com.alibaba.fastjson.JSONObject;
6   -import com.alibaba.fastjson.support.odps.udf.CodecCheck.A;
7 6 import com.bsth.common.Constants;
8 7 import com.bsth.common.ResponseCode;
9 8 import com.bsth.controller.realcontrol.dto.ChangePersonCar;
... ... @@ -158,6 +157,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
158 157 private static int BUF_SIZE = 1024;
159 158  
160 159 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  160 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
161 161  
162 162 @Override
163 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 166  
167 167 ScheduleRealInfo schedule = dayOfSchedule.get(id);
168 168  
169   -
170 169 LineConfig config = lineConfigData.get(schedule.getXlBm());
171 170 //小于线路开始运营时间,则默认跨过24点
172 171 if (dfsj.compareTo(config.getStartOpt()) < 0) {
... ... @@ -178,17 +177,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
178 177 schedule.setDfsjAll(dfsj);
179 178 schedule.addRemarks(remarks);
180 179  
181   - //取消应发未到标记
182   - if(schedule.isLate2()){
183   - schedule.setLate2(false);
184   - LateAdjustHandle.remove(schedule);
185   - }
186   -
187 180 List<ScheduleRealInfo> ts = new ArrayList<>();
188 181 ts.add(schedule);
189 182 //调整终点时间和下一个班次的应到时间
190 183 schedule.calcEndTime();
191   - ScheduleRealInfo nextSch = dayOfSchedule.next(schedule);
  184 + ScheduleRealInfo nextSch = dayOfSchedule.nextByLp(schedule);
192 185 if (null != nextSch) {
193 186 nextSch.setQdzArrDateJH(schedule.getZdsj());
194 187 ts.add(nextSch);
... ... @@ -201,7 +194,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
201 194  
202 195 //重新计算是否误点
203 196 schedule.reCalcLate();
204   -
  197 + //取消应发未到标记,不再自动调整待发
  198 + if(schedule.isLate2()){
  199 + schedule.setLate2(false);
  200 + LateAdjustHandle.remove(schedule);
  201 + }
205 202 // 持久化到数据库
206 203 dayOfSchedule.save(schedule);
207 204  
... ... @@ -223,7 +220,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
223 220 try {
224 221 List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
225 222  
226   - ScheduleRealInfo schedule = null, next;
  223 + ScheduleRealInfo schedule = null;
227 224 for (String id : idList) {
228 225 schedule = dayOfSchedule.get(Long.parseLong(id));
229 226 if (schedule.isDestroy()) {
... ... @@ -238,13 +235,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
238 235  
239 236 dayOfSchedule.save(schedule);
240 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 936 for (int i = 1; i < size; i++) {
947 937 st += plus;
948 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 944 rs.put("status", ResponseCode.SUCCESS);
965   - rs.put("ts", updateList);
  945 + //返回最后一个班次,页面会全量刷新
  946 + rs.put("t", sch);
966 947 }
967 948  
968 949 } catch (Exception e) {
... ... @@ -980,121 +961,146 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
980 961 List<ScheduleRealInfo> ts = new ArrayList<>();
981 962 try {
982 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 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 1098 String bcType = map.get("bcType");
1094 1099 if (StringUtils.isNotEmpty(bcType)) {
1095 1100 sch.setBcType(bcType);
1096 1101 }
1097   - //班次状态
  1102 +
  1103 + //重新计算班次状态
1098 1104 sch.calcStatus();
1099 1105 dayOfSchedule.save(sch);
1100 1106 //页面需要更新的班次信息
... ... @@ -1118,25 +1124,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1118 1124 ScheduleRealInfo schedule = null;
1119 1125 JSONObject jsonObj;
1120 1126 String dfsj;
  1127 + long id;
1121 1128 for (int i = 0; i < jsonArray.size(); i++) {
1122 1129 jsonObj = jsonArray.getJSONObject(i);
1123 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 1138 rs.put("status", ResponseCode.SUCCESS);
1139   - //将更新的最后一个班次返回
  1139 + //将更新的最后一个班次返回,页面会做全量刷新
1140 1140 rs.put("t", schedule);
1141 1141 } catch (Exception e) {
1142 1142 logger.error("", e);
... ... @@ -2909,29 +2909,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2909 2909 Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();
2910 2910 List<ScheduleRealInfo> list = new ArrayList<>();
2911 2911  
2912   - ScheduleRealInfo sch, next;
2913 2912 for (DfsjChange dc : dfsjcs) {
2914 2913 if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
2915 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 2916 tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null);
2926 2917  
2927 2918 if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {
2928 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 2923 rs.put("status", ResponseCode.SUCCESS);
... ... @@ -3021,7 +3007,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3021 3007 if (sch != null) {
3022 3008 sch.setBcType(bcType);
3023 3009 sch.addRemarks(remarks);
3024   - //有时间记录一下相关变更数据
3025 3010 rs.put("status", ResponseCode.SUCCESS);
3026 3011 rs.put("t", sch);
3027 3012 }
... ... @@ -3033,7 +3018,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3033 3018 return rs;
3034 3019 }
3035 3020  
3036   - @Override
  3021 + /* @Override
3037 3022 public Map<String, Object> historySave(ScheduleRealInfo sch) {
3038 3023 Map<String, Object> rs = new HashMap<>();
3039 3024 rs.put("status", ResponseCode.ERROR);
... ... @@ -3073,7 +3058,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3073 3058 scheduleRealInfoRepository.save(oldSch);
3074 3059 rs.put("status", ResponseCode.SUCCESS);
3075 3060 return rs;
3076   - }
  3061 + }*/
3077 3062  
3078 3063 @Autowired
3079 3064 SvgAttributeRepository svgAttributeRepository;
... ... @@ -4151,8 +4136,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4151 4136  
4152 4137 sch.clearFcsjActual();
4153 4138 sch.clearZdsjActual();
4154   - //清除下一个班次的起点到达时间
4155   - ScheduleRealInfo next = dayOfSchedule.next(sch);
  4139 + //清除路牌下一个班的起点到达时间
  4140 + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);
4156 4141 if (null != next) {
4157 4142 next.setQdzArrDateSJ(null);
4158 4143 ts.add(next);
... ... @@ -4164,6 +4149,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4164 4149 rs.put("ts", ts);
4165 4150  
4166 4151 dayOfSchedule.save(sch);
  4152 + //重新计算当前执行班次
  4153 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
4167 4154  
4168 4155 }
4169 4156 } catch (Exception e) {
... ...
src/main/resources/static/real_control_v2/js/line_schedule/context_menu.js
... ... @@ -118,7 +118,10 @@ var gb_schedule_context_menu = (function () {
118 118 if (!isNaN(newValue) && newValue > 0) {
119 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 125 notify_succ('调整间隔成功!');
123 126 });
124 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 86 .html(htmlStr);
87 87 }
88 88  
89   - //标记车辆最后一个班次
  89 + //标记路牌最后一个班次
90 90 markerLastByLine(lineCode);
91 91 //初始化图例相关,dbclick 不能代理事件
92 92 gb_sch_legend.init(this);
... ... @@ -495,7 +495,7 @@ var gb_schedule_table = (function () {
495 495  
496 496 //标记终点时间 -线路
497 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 500 var array, lastSch, dl;
501 501 for (var nbbm in data) {
... ...