Commit d1c098ed77c313823076292767df1be2a8260d60

Authored by 廖磊
2 parents e843e7fc abd9f44a

Merge branch 'minhang' of

http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
Showing 31 changed files with 1420 additions and 394 deletions
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/gpsdata/recovery/GpsDataRecovery.java
... ... @@ -60,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware {
60 60 for (String nbbm : keys) {
61 61 Collections.sort(listMap.get(nbbm), comp);
62 62 threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
63   - /*if(nbbm.equals("W9G-013"))
  63 + /*if(nbbm.equals("W7C-001"))
64 64 new RecoveryThread(listMap.get(nbbm), count).run();*/
65 65 }
66 66  
... ... @@ -150,8 +150,6 @@ public class GpsDataRecovery implements ApplicationContextAware {
150 150 CircleQueue<GpsEntity> prevs;
151 151 boolean task;
152 152 for (GpsEntity gps : list) {
153   - /*if(gps.getTimestamp() > 1491951840000L)
154   - System.out.print("");*/
155 153  
156 154 //是否有任务
157 155  
... ...
src/main/java/com/bsth/data/safe_driv/SafeDrivDataLoadThread.java
... ... @@ -88,7 +88,7 @@ public class SafeDrivDataLoadThread extends Thread{
88 88 httpClient.close();
89 89 response.close();
90 90 } catch (Exception e) {
91   - logger.error("", e);
  91 + logger.error(e.getMessage());
92 92 }
93 93 }
94 94 }
... ...
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<>();
... ... @@ -233,10 +236,14 @@ public class DayOfSchedule implements CommandLineRunner {
233 236 //添加到缓存
234 237 putAll(list);
235 238  
  239 +
  240 + Set<String> lps = searchAllLP(list);
  241 + for(String lp : lps){
  242 + //计算“起点站应到”时间
  243 + schAttrCalculator.calcQdzTimePlan(lpScheduleMap.get(lineCode + "_" + lp));
  244 + }
236 245 Set<String> cars = searchAllCars(list);
237 246 for (String nbbm : cars) {
238   - //计算“起点站应到”时间
239   - schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm));
240 247 //车辆 ——> 要执行的班次对照
241 248 reCalcExecPlan(nbbm);
242 249 }
... ... @@ -258,7 +265,7 @@ public class DayOfSchedule implements CommandLineRunner {
258 265 /**
259 266 * @Title: searchAllCars
260 267 * @Description: TODO(搜索班次集合中的车辆)
261   - */
  268 + */
262 269 private Set<String> searchAllCars(List<ScheduleRealInfo> list) {
263 270 Set<String> cars = new HashSet<>();
264 271 for (ScheduleRealInfo sch : list)
... ... @@ -267,6 +274,18 @@ public class DayOfSchedule implements CommandLineRunner {
267 274 return cars;
268 275 }
269 276  
  277 + /**
  278 + * @Title: searchAllCars
  279 + * @Description: TODO(搜索班次集合中的路牌)
  280 + */
  281 + private Set<String> searchAllLP(List<ScheduleRealInfo> list) {
  282 + Set<String> lps = new HashSet<>();
  283 + for (ScheduleRealInfo sch : list)
  284 + lps.add(sch.getLpName());
  285 +
  286 + return lps;
  287 + }
  288 +
270 289 private void putAll(List<ScheduleRealInfo> list) {
271 290 for (ScheduleRealInfo sch : list)
272 291 put(sch);
... ... @@ -312,6 +331,17 @@ public class DayOfSchedule implements CommandLineRunner {
312 331 }
313 332 }
314 333  
  334 + //清理路牌对照
  335 + List<String> lprms = new ArrayList<>();
  336 + Set<String> lps = lpScheduleMap.keySet();
  337 + for(String lp : lps){
  338 + if(lp.indexOf(lineCode + "_") != -1)
  339 + lprms.add(lp);
  340 + }
  341 +
  342 + for(String lp : lprms)
  343 + lpScheduleMap.removeAll(lp);
  344 +
315 345 logger.info(lineCode + "排班清理 " + count);
316 346 }
317 347  
... ... @@ -496,18 +526,31 @@ public class DayOfSchedule implements CommandLineRunner {
496 526 return id2SchedulMap.get(id);
497 527 }
498 528  
499   - /* public Set<String> getSEStationList(String nbbm) {
500   - return nbbm2SEStationMap.get(nbbm);
501   - }*/
502 529  
503 530 /**
504 531 * @Title: next
505 532 * @Description: TODO(下一个班次)
506 533 */
507 534 public ScheduleRealInfo next(ScheduleRealInfo sch) {
  535 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  536 + return next(list, sch);
  537 + }
508 538  
  539 + /**
  540 + * 下一个相同走向的班次
  541 + * @param sch
  542 + * @return
  543 + */
  544 + public ScheduleRealInfo nextSame(final ScheduleRealInfo sch){
509 545 List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
510   - int outConfig = -1;
  546 + Collection<ScheduleRealInfo> subList = Collections2.filter(list, new Predicate<ScheduleRealInfo>(){
  547 +
  548 + @Override
  549 + public boolean apply(ScheduleRealInfo item) {
  550 + return item.getXlDir().equals(sch.getXlDir());
  551 + }
  552 + });
  553 + /*int outConfig = -1;
511 554 LineConfig config = lineConfigData.get(sch.getXlBm());
512 555 if (config != null)
513 556 outConfig = config.getOutConfig();
... ... @@ -531,21 +574,22 @@ public class DayOfSchedule implements CommandLineRunner {
531 574 && (!limitPark || park.equals(temp.getQdzCode())))
532 575 continue;
533 576  
534   - if (flag) {
  577 + if (flag && temp.getXlDir().equals(sch.getXlDir())) {
535 578 next = temp;
536 579 break;
537 580 }
538   - }
539   - return next;
  581 + }*/
  582 + return next(subList, sch);
540 583 }
541 584  
  585 +
542 586 /**
543   - * 下一个相同走向的班次
544   - * @param sch
  587 + * 下一个班次
  588 + * @param list 班次集合
  589 + * @param sch 当前班次
545 590 * @return
546 591 */
547   - public ScheduleRealInfo nextSame(ScheduleRealInfo sch){
548   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  592 + private ScheduleRealInfo next(Collection<ScheduleRealInfo> list , ScheduleRealInfo sch){
549 593 int outConfig = -1;
550 594 LineConfig config = lineConfigData.get(sch.getXlBm());
551 595 if (config != null)
... ... @@ -570,7 +614,7 @@ public class DayOfSchedule implements CommandLineRunner {
570 614 && (!limitPark || park.equals(temp.getQdzCode())))
571 615 continue;
572 616  
573   - if (flag && temp.getXlDir().equals(sch.getXlDir())) {
  617 + if (flag) {
574 618 next = temp;
575 619 break;
576 620 }
... ... @@ -626,16 +670,21 @@ public class DayOfSchedule implements CommandLineRunner {
626 670  
627 671 String nbbm = sch.getClZbh();
628 672 nbbmScheduleMap.put(nbbm, sch);
629   - //nbbm2SEStationMap.put(nbbm, sch.getQdzCode());
630   - //nbbm2SEStationMap.put(nbbm, sch.getZdzCode());
631 673  
632 674 //主键索引
633 675 id2SchedulMap.put(sch.getId(), sch);
  676 + //路牌对照表
  677 + addLPMapp(sch);
  678 +
634 679 //跨24点的,再save一次
635 680 if (!sch.getRealExecDate().equals(sch.getScheduleDateStr()))
636 681 save(sch);
637 682 }
638 683  
  684 + public void addLPMapp(ScheduleRealInfo sch){
  685 + lpScheduleMap.put(sch.getXlBm() + "_" + sch.getLpName(), sch);
  686 + }
  687 +
639 688 public void delete(ScheduleRealInfo sch) {
640 689 //ScheduleRealInfo sch = id2SchedulMap.get(id);
641 690 if (!sch.isSflj())
... ... @@ -643,13 +692,24 @@ public class DayOfSchedule implements CommandLineRunner {
643 692  
644 693 nbbmScheduleMap.remove(sch.getClZbh(), sch);
645 694 id2SchedulMap.remove(sch.getId());
  695 + lpScheduleMap.remove(sch.getXlBm() + "_" + sch.getLpName(), sch);
646 696 //return sch;
647 697 }
648 698  
649 699  
650   - public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm) {
  700 +/* public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm) {
651 701 Collections.sort(nbbmScheduleMap.get(nbbm), schFCSJComparator);
652 702 return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm));
  703 + }*/
  704 +
  705 + public List<ScheduleRealInfo> updateQdzTimePlan(String lpName) {
  706 + List<ScheduleRealInfo> list = lpScheduleMap.get(lpName);
  707 + Collections.sort(list, schFCSJComparator);
  708 + return schAttrCalculator.updateQdzTimePlan(list);
  709 + }
  710 +
  711 + public List<ScheduleRealInfo> updateQdzTimePlan(ScheduleRealInfo sch) {
  712 + return updateQdzTimePlan(sch.getXlBm() + "_" + sch.getLpName());
653 713 }
654 714  
655 715 /**
... ... @@ -810,9 +870,9 @@ public class DayOfSchedule implements CommandLineRunner {
810 870 */
811 871 public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) {
812 872 List<ScheduleRealInfo> ups = new ArrayList<>();
813   - String oldClzbh = sch.getClZbh();
  873 + /*String oldClzbh = sch.getClZbh();
814 874 if (oldClzbh.equals(newClZbh))
815   - return ups;
  875 + return ups;*/
816 876  
817 877  
818 878 //变更相关映射信息
... ... @@ -820,12 +880,10 @@ public class DayOfSchedule implements CommandLineRunner {
820 880  
821 881 sch.setClZbh(newClZbh);
822 882 nbbmScheduleMap.put(newClZbh, sch);
823   - //nbbm2SEStationMap.put(newClZbh, sch.getQdzCode());
824   - //nbbm2SEStationMap.put(newClZbh, sch.getZdzCode());
825 883  
826 884 //重新计算班次应到时间
827   - ups.addAll(updateQdzTimePlan(oldClzbh));
828   - ups.addAll(updateQdzTimePlan(newClZbh));
  885 + //ups.addAll(updateQdzTimePlan(oldClzbh));
  886 + //ups.addAll(updateQdzTimePlan(newClZbh));
829 887  
830 888 //重新计算车辆当前执行班次
831 889 reCalcExecPlan(newClZbh);
... ... @@ -842,7 +900,9 @@ public class DayOfSchedule implements CommandLineRunner {
842 900 }
843 901  
844 902 public void reCalcExecPlan(String nbbm){
845   - carExecutePlanMap.put(nbbm, schAttrCalculator.calcCurrentExecSch(nbbmScheduleMap.get(nbbm)));
  903 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
  904 + Collections.sort(list, schFCSJComparator);
  905 + carExecutePlanMap.put(nbbm, schAttrCalculator.calcCurrentExecSch(list));
846 906 }
847 907  
848 908 /**
... ... @@ -942,4 +1002,15 @@ public class DayOfSchedule implements CommandLineRunner {
942 1002 //重新计算班次应到时间
943 1003 updateQdzTimePlan(nbbm);
944 1004 }
  1005 +
  1006 + /**
  1007 + * 获取该班次所在路牌的下一个班次
  1008 + * @param sch
  1009 + * @return
  1010 + */
  1011 + public ScheduleRealInfo nextByLp(ScheduleRealInfo sch) {
  1012 + List<ScheduleRealInfo> list = lpScheduleMap.get(sch.getXlBm() + "_" + sch.getLpName());
  1013 + Collections.sort(list, schFCSJComparator);
  1014 + return next(list, sch);
  1015 + }
945 1016 }
946 1017 \ 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 //重新计算当前执行班次
... ... @@ -374,7 +364,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
374 364 t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
375 365 t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
376 366  
377   - //计算班次实际时间
  367 + //计算班次实际执行时间
378 368 schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
379 369 if (t.getZdsjT() < t.getFcsjT()) {
380 370 rs.put("status", ResponseCode.ERROR);
... ... @@ -389,7 +379,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
389 379 dayOfSchedule.put(t);
390 380  
391 381 //更新起点应到时间
392   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t.getClZbh());
  382 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t);
393 383  
394 384 //重新计算车辆当前执行班次
395 385 dayOfSchedule.reCalcExecPlan(t.getClZbh());
... ... @@ -429,7 +419,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
429 419 if(rs.get("status").equals(ResponseCode.SUCCESS)){
430 420 dayOfSchedule.delete(sch);
431 421 //更新起点应到时间
432   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch.getClZbh());
  422 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);
433 423 rs.put("ts", ts);
434 424 rs.put("delete", sch);
435 425 }
... ... @@ -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/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
... ... @@ -244,11 +244,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
244 244 Date end4 = new Date();
245 245  
246 246  
247   - logger.info("删除数据 {} ms,drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms,插入数据 {} ms",
  247 + logger.info("删除数据 {} ms,drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms,插入数据 {} 条 耗时 {} ms",
248 248 endpre.getTime() - startpre.getTime(),
249 249 end1.getTime() - start1.getTime(),
250 250 end2.getTime() - start2.getTime(),
251 251 end3.getTime() - start3.getTime(),
  252 + planResult.getSchedulePlanInfos().size(),
252 253 end4.getTime() - start4.getTime());
253 254  
254 255  
... ...
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
... ... @@ -76,12 +76,12 @@ public class MyDroolsConfiguration {
76 76 // 4、创建KieBuilder,使用KieFileSystem构建
77 77 KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll();
78 78 Results results = kieBuilder.getResults();
79   -// if (results.hasMessages(Message.Level.ERROR))
80   -// throw new IllegalStateException("构建drools6错误:" + results.getMessages());
81   - if (results.hasMessages(Message.Level.ERROR)) {
82   - logger.info("构建drools6错误:" + results.getMessages());
83   - return null;
84   - }
  79 + if (results.hasMessages(Message.Level.ERROR))
  80 + throw new IllegalStateException("构建drools6错误:" + results.getMessages());
  81 +// if (results.hasMessages(Message.Level.ERROR)) {
  82 +// logger.info("构建drools6错误:" + results.getMessages());
  83 +// return null;
  84 +// }
85 85  
86 86 // 5、获取KieContainer
87 87 // TODO:ReleaseId用处很大,以后再议
... ...
src/main/resources/logback.xml
... ... @@ -159,6 +159,32 @@
159 159 <!--<appender-ref ref="STDOUT" />-->
160 160 <!--</logger>-->
161 161  
  162 + <!--JdbcTemplate的日志输出器 -->
  163 + <logger name="org.springframework.jdbc.core.StatementCreatorUtils"
  164 + additivity="false" level="TRACE">
  165 + <appender-ref ref="STDOUT" />
  166 + </logger>
  167 + <logger name="org.springframework.jdbc.core" additivity="true">
  168 + <level value="DEBUG" />
  169 + <appender-ref ref="STDOUT" />
  170 + </logger>
  171 + <logger name="java.sql.Connection" additivity="true">
  172 + <level value="DEBUG" />
  173 + <appender-ref ref="STDOUT" />
  174 + </logger>
  175 + <logger name="java.sql.Statement" additivity="true">
  176 + <level value="DEBUG" />
  177 + <appender-ref ref="STDOUT" />
  178 + </logger>
  179 + <logger name="java.sql.PreparedStatement" additivity="true">
  180 + <level value="DEBUG" />
  181 + <appender-ref ref="STDOUT" />
  182 + </logger>
  183 + <logger name="java.sql.ResultSet" additivity="true">
  184 + <level value="DEBUG" />
  185 + <appender-ref ref="STDOUT" />
  186 + </logger>
  187 +
162 188 <!-- 日志输出级别 -->
163 189 <root level="info">
164 190 <appender-ref ref="STDOUT" />
... ...
src/main/resources/rules/legacy/plan.drl 0 → 100644
  1 +package com.bsth.service.schedule.plan;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +
  6 +import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input;
  7 +import com.bsth.service.schedule.rules.plan.PlanResult;
  8 +
  9 +import com.bsth.repository.schedule.TTInfoDetailRepository;
  10 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  11 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  12 +import com.bsth.repository.LineRepository;
  13 +import com.bsth.repository.BusinessRepository;
  14 +
  15 +import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
  16 +import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
  17 +import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output;
  18 +import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;
  19 +import com.bsth.entity.Line;
  20 +import com.bsth.entity.Business;
  21 +
  22 +import com.bsth.entity.schedule.CarConfigInfo;
  23 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  24 +import com.bsth.entity.schedule.TTInfo;
  25 +import com.bsth.entity.schedule.TTInfoDetail;
  26 +import com.bsth.entity.schedule.SchedulePlanInfo;
  27 +
  28 +import org.slf4j.Logger
  29 +import org.joda.time.format.DateTimeFormat
  30 +import org.apache.commons.lang3.StringUtils;
  31 +
  32 +
  33 +// 全局日志类(一般使用调用此规则的service类)
  34 +global Logger log;
  35 +
  36 +global TTInfoDetailRepository tTInfoDetailRepository;
  37 +global CarConfigInfoRepository carConfigInfoRepository;
  38 +global EmployeeConfigInfoRepository employeeConfigInfoRepository;
  39 +global LineRepository lineRepository;
  40 +global BusinessRepository businessRepository;
  41 +
  42 +// 输出
  43 +global PlanResult planResult;
  44 +
  45 +function Map xlidParams(String xlid) {
  46 + Map param = new HashMap();
  47 + param.put("xl.id_eq", Integer.valueOf(xlid));
  48 + return param;
  49 +}
  50 +
  51 +function List ecList(EmployeeConfigInfoRepository repo, String ecids) {
  52 + List<String> ids = Arrays.asList(ecids.split("-"));
  53 + List rst = new ArrayList();
  54 + for (int i = 0; i < ids.size(); i++) {
  55 + rst.add(repo.findOne(Long.parseLong(ids.get(i))));
  56 + }
  57 + return rst;
  58 +}
  59 +
  60 +function LocalTime fcsjTime(String fcsj) {
  61 + if ("NULL".equals(fcsj)) {
  62 + return null;
  63 + }
  64 + return LocalTime.parse(fcsj, DateTimeFormat.forPattern("HH:mm"));
  65 +}
  66 +
  67 +function String ttInfoId_sd(Map map, DateTime sd) {
  68 + TTInfoResult_output ttInfoResult_output = (TTInfoResult_output) map.get(sd);
  69 + return ttInfoResult_output.getTtInfoId();
  70 +}
  71 +
  72 +/*
  73 + 规则说明:
  74 + 根据循环规则输出,时刻表选择规则输出,组合计算排班明细
  75 +*/
  76 +
  77 +//-------------------- 第一阶段、计算迭代数据 -----------------//
  78 +declare Loop_result
  79 + xlId: String // 线路id
  80 +
  81 + ruleLoop: List // 每天分配的规则 List<ScheduleResult_output>
  82 +
  83 + ttInfoMapLoop_temp: Map // 每天分配的时刻表 Map<DataTime, Collection<TTInfoResult_output>>
  84 + ttInfoMapLoop: Map // 每天分配的时刻表 Map<DataTime, TTInfoResult_output>
  85 + ttInfoMap: Map // 总共用到的时刻表 Map<id, TTInfoResult_output>
  86 +end
  87 +
  88 +rule "calcu_step1_Loop_result"
  89 + salience 1000
  90 + when
  91 + $param: PlanCalcuParam_input($xlId: xlId)
  92 + then
  93 + Loop_result loop_result = new Loop_result();
  94 + loop_result.setXlId($xlId);
  95 + loop_result.setRuleLoop($param.getScheduleResults_output().getResults());
  96 +
  97 + loop_result.setTtInfoMapLoop(new HashMap());
  98 + loop_result.setTtInfoMap(new HashMap());
  99 +
  100 + com.google.common.collect.Multimap ttInfoMap_temp =
  101 + (com.google.common.collect.Multimap)
  102 + $param.getTtInfoResults_output().getResults().get(
  103 + String.valueOf($xlId));
  104 +
  105 + loop_result.setTtInfoMapLoop_temp(ttInfoMap_temp.asMap());
  106 +
  107 + insert(loop_result);
  108 +
  109 +// log.info("calcu_step1_Loop_result");
  110 +end
  111 +
  112 +rule "calcu_step2_loop_result"
  113 + salience 1000
  114 + no-loop
  115 + when
  116 + $param: PlanCalcuParam_input($xlId: xlId)
  117 + $lr: Loop_result(xlId == $xlId)
  118 + $sd: DateTime() from $lr.ttInfoMapLoop_temp.keySet()
  119 + then
  120 + // 当天时刻表只取第一张 TODO:
  121 + Collection col = (Collection) $lr.getTtInfoMapLoop_temp().get($sd);
  122 + Iterator iter = col.iterator();
  123 + TTInfoResult_output ttInfo_result = (TTInfoResult_output) iter.next();
  124 + $lr.getTtInfoMapLoop().put($sd, ttInfo_result);
  125 +
  126 + // 总共使用的时刻表
  127 + $lr.getTtInfoMap().put(ttInfo_result.getTtInfoId(), ttInfo_result);
  128 +
  129 + update($lr);
  130 +
  131 +// log.info("calcu_step2_Loop_result");
  132 +end
  133 +
  134 +//-------------------- 第二阶段、将时刻表班次,车辆配置,人员配置信息载入 -----------------//
  135 +
  136 +//--------------- 车辆配置信息载入 -------------//
  137 +declare CarConfig_Wrap
  138 + id: String // 车辆配置id(cast字符串-方便比较)
  139 +
  140 + self: CarConfigInfo // 原始数据
  141 +end
  142 +
  143 +rule "calcu_CarConfig_Wrap"
  144 + salience 800
  145 + when
  146 + $lr: Loop_result($xlId: xlId)
  147 + $ccf: CarConfigInfo() from carConfigInfoRepository.findByXlId(Integer.parseInt($xlId))
  148 + then
  149 + CarConfig_Wrap carConfig_wrap = new CarConfig_Wrap();
  150 + carConfig_wrap.setId(String.valueOf($ccf.getId()));
  151 + carConfig_wrap.setSelf($ccf);
  152 +
  153 + insert(carConfig_wrap);
  154 +
  155 +// log.info("calcu_CarConfig_Wrap");
  156 +end
  157 +
  158 +//--------------- 人员配置信息载入 --------------//
  159 +declare EmployeeConfig_Wrap
  160 + id: String // 人员配置id(cast字符串-方便比较)
  161 +
  162 + self: EmployeeConfigInfo // 原始数据
  163 +end
  164 +
  165 +rule "calcu_EmployeeConfig_Wrap"
  166 + salience 800
  167 + when
  168 + $lr: Loop_result($xlId: xlId)
  169 + $eci: EmployeeConfigInfo() from employeeConfigInfoRepository.findByXlId(Integer.parseInt($xlId))
  170 + then
  171 + EmployeeConfig_Wrap employeeConfig_wrap = new EmployeeConfig_Wrap();
  172 + employeeConfig_wrap.setId(String.valueOf($eci.getId()));
  173 + employeeConfig_wrap.setSelf($eci);
  174 +
  175 + insert(employeeConfig_wrap);
  176 +
  177 +// log.info("calcu_EmployeeConfig_Wrap");
  178 +end
  179 +
  180 +//----------------- 时刻表班次信息载入 -----------------//
  181 +declare TTInfo_gid_stat
  182 + xlId: String // 线路id(cast字符串-方便比较)
  183 + ttInfoId: String // 时刻表id(cast字符串-方便比较)
  184 + gid: String // 路牌id(cast字符串-方便比较)
  185 +
  186 + maxFcno: Integer // 最大发车顺序号
  187 +
  188 + fbTime: LocalTime // 分班时间
  189 +end
  190 +
  191 +rule "calcu_TTInfo_gid_stat"
  192 + salience 800
  193 + when
  194 + $lr: Loop_result($xlId: xlId)
  195 + $ttInfoId: String() from $lr.getTtInfoMap().keySet()
  196 + $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd))
  197 + $gid: String() from $gids
  198 + $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd))
  199 + $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno()))
  200 + then
  201 + TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat();
  202 + ttInfo_gid_stat.setXlId($xlId);
  203 + ttInfo_gid_stat.setTtInfoId($ttInfoId);
  204 + ttInfo_gid_stat.setGid($gid);
  205 +
  206 + ttInfo_gid_stat.setMaxFcno($maxfcno.intValue());
  207 + ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str));
  208 +
  209 + insert(ttInfo_gid_stat);
  210 +
  211 +// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}",
  212 +// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime());
  213 +
  214 +end
  215 +
  216 +declare TTInfoDetail_Wrap
  217 + xlId: String // 线路id(cast字符串-方便比较)
  218 + ttInfoId: String // 时刻表id(cast字符串-方便比较)
  219 + gid: String // 路牌id(cast字符串-方便比较)
  220 +
  221 + isFirstBc: Boolean = false // 是否是当前路牌的第一个班次
  222 + isLastBc: Boolean = false // 是否是当前路牌的最后一个班次
  223 + isFb: Boolean = false // 是否分班
  224 +
  225 + self: TTInfoDetail // 原始数据
  226 +end
  227 +
  228 +rule "calcu_TTInfoDetail_Wrap"
  229 + salience 800
  230 + when
  231 + $lr: Loop_result($xlId: xlId)
  232 + $ttInfoId: String() from $lr.getTtInfoMap().keySet()
  233 + $ttInfoStat: TTInfo_gid_stat(
  234 + ttInfoId == $ttInfoId,
  235 + $gid: gid, $maxFcno: maxFcno)
  236 + $ttInfoDetail: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId))
  237 + then
  238 + TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap();
  239 + ttInfoDetail_wrap.setXlId($xlId);
  240 + ttInfoDetail_wrap.setTtInfoId($ttInfoId);
  241 + ttInfoDetail_wrap.setGid($gid);
  242 + ttInfoDetail_wrap.setIsFirstBc(1 == $ttInfoDetail.getFcno());
  243 + ttInfoDetail_wrap.setIsLastBc($maxFcno == $ttInfoDetail.getFcno());
  244 +
  245 + LocalTime fcsj = fcsjTime($ttInfoDetail.getFcsj());
  246 + LocalTime fbsj = $ttInfoStat.getFbTime();
  247 + ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
  248 +
  249 + ttInfoDetail_wrap.setSelf($ttInfoDetail);
  250 +
  251 + insert(ttInfoDetail_wrap);
  252 +
  253 +// log.info("xlid={},ttid={},gid={},isFirstBc={},isLastBc={},isFb={},fcsj={}",
  254 +// $xlId, $ttInfoId, $gid,
  255 +// ttInfoDetail_wrap.getIsFirstBc(),
  256 +// ttInfoDetail_wrap.getIsLastBc(),
  257 +// ttInfoDetail_wrap.getIsFb(),
  258 +// $ttInfoDetail.getFcsj());
  259 +end
  260 +
  261 +//-------------------- 第三阶段、合并计算SchedulePlanInfo -----------------//
  262 +
  263 +rule "Calcu_SchedulePlanInfo"
  264 + salience 600
  265 + when
  266 + $param: PlanCalcuParam_input($xlId: xlId)
  267 + $lr: Loop_result(xlId == $xlId)
  268 + $sro: ScheduleResult_output($sd: sd, $gid: guideboardId) from $lr.getRuleLoop()
  269 + CarConfig_Wrap(id == $sro.carConfigId, $cc: self)
  270 + TTInfoDetail_Wrap(
  271 + ttInfoId == ttInfoId_sd($lr.getTtInfoMapLoop(), $sd),
  272 + gid == $gid,
  273 + $isFb: isFb, $isFirstBc: isFirstBc, $isLastBc: isLastBc,
  274 + $ttInfoDetail: self
  275 + )
  276 + then
  277 + // 线路
  278 + Line xl = lineRepository.findOne(Integer.parseInt($xlId));
  279 +
  280 + SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(
  281 + xl,
  282 + $sro,
  283 + $ttInfoDetail,
  284 + $isFb,
  285 + $cc,
  286 + ecList(employeeConfigInfoRepository, $sro.getEmployeeConfigId()),
  287 + $param.getSchedulePlan(),
  288 + $isFirstBc,
  289 + $isLastBc
  290 + );
  291 +
  292 + // 获取公司,分公司信息
  293 + String gsbm = xl.getCompany();
  294 + String fgsbm = xl.getBrancheCompany();
  295 + Business gs = null;
  296 + Business fgs = null;
  297 +
  298 + if (StringUtils.isNotEmpty(gsbm)) {
  299 + Iterator<Business> businessIterator1 = businessRepository.findByBusinessCode(gsbm).iterator();
  300 + if (businessIterator1.hasNext()) {
  301 + gs = (Business) businessIterator1.next();
  302 + }
  303 + }
  304 + if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {
  305 + Iterator<Business> businessIterator2 = businessRepository.findByUpCodeAndBusinessCode(gsbm, fgsbm).iterator();
  306 + if (businessIterator2.hasNext()) {
  307 + fgs = (Business) businessIterator2.next();
  308 + }
  309 + }
  310 +
  311 + if (gs != null) {
  312 + schedulePlanInfo.setGsBm(gs.getBusinessCode());
  313 + schedulePlanInfo.setGsName(gs.getBusinessName());
  314 + }
  315 + if (fgs != null) {
  316 + schedulePlanInfo.setFgsBm(fgs.getBusinessCode());
  317 + schedulePlanInfo.setFgsName(fgs.getBusinessName());
  318 + }
  319 +
  320 + // 操作人,操作时间
  321 + schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy());
  322 + schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate());
  323 + schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy());
  324 + schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate());
  325 +
  326 + // result 输出
  327 + planResult.getSchedulePlanInfos().add(schedulePlanInfo);
  328 +
  329 + log.info("gid={},ecid={},ttInfoId={}",
  330 + $gid, ecList(employeeConfigInfoRepository, $sro.getEmployeeConfigId()),
  331 + ttInfoId_sd($lr.getTtInfoMapLoop(), $sd));
  332 +
  333 +end
  334 +
  335 +
  336 +
  337 +
  338 +
  339 +
  340 +
  341 +
  342 +
  343 +
  344 +
  345 +
  346 +
  347 +
  348 +
... ...
src/main/resources/rules/plan.drl
... ... @@ -69,6 +69,34 @@ function String ttInfoId_sd(Map map, DateTime sd) {
69 69 return ttInfoResult_output.getTtInfoId();
70 70 }
71 71  
  72 +function Map gsMap(List gses) {
  73 + Map gsMap = new HashMap();
  74 + for (int i = 0; i < gses.size(); i++) {
  75 + Business gs = (Business) gses.get(i);
  76 + if (StringUtils.isNotEmpty(gs.getBusinessCode())) {
  77 + if ("88".equals(gs.getUpCode())) { // 浦东公交
  78 + gsMap.put(gs.getBusinessCode(), gs);
  79 + }
  80 + if (gs.getBusinessCode().equals(gs.getUpCode())) { // 闵行,青浦
  81 + gsMap.put(gs.getBusinessCode(), gs);
  82 + }
  83 + }
  84 + }
  85 + return gsMap;
  86 +}
  87 +
  88 +function Map fgsMap(List gses) {
  89 + // 这里简单将 businessCode和upCode合并
  90 + Map fgsMap = new HashMap();
  91 + for (int i = 0; i < gses.size(); i++) {
  92 + Business gs = (Business) gses.get(i);
  93 + if (StringUtils.isNotEmpty(gs.getBusinessCode()) && StringUtils.isNotEmpty(gs.getUpCode())) {
  94 + fgsMap.put(gs.getUpCode() + "_" + gs.getBusinessCode(), gs);
  95 + }
  96 + }
  97 + return fgsMap;
  98 +}
  99 +
72 100 /*
73 101 规则说明:
74 102 根据循环规则输出,时刻表选择规则输出,组合计算排班明细
... ... @@ -106,7 +134,7 @@ rule &quot;calcu_step1_Loop_result&quot;
106 134  
107 135 insert(loop_result);
108 136  
109   - log.info("calcu_step1_Loop_result");
  137 +// log.info("calcu_step1_Loop_result");
110 138 end
111 139  
112 140 rule "calcu_step2_loop_result"
... ... @@ -128,51 +156,61 @@ rule &quot;calcu_step2_loop_result&quot;
128 156  
129 157 update($lr);
130 158  
131   - log.info("calcu_step2_Loop_result");
  159 +// log.info("calcu_step2_Loop_result");
132 160 end
133 161  
134 162 //-------------------- 第二阶段、将时刻表班次,车辆配置,人员配置信息载入 -----------------//
135 163  
136 164 //--------------- 车辆配置信息载入 -------------//
137   -declare CarConfig_Wrap
138   - id: String // 车辆配置id(cast字符串-方便比较)
139   -
140   - self: CarConfigInfo // 原始数据
  165 +declare CarConfig_Wraps
  166 + xlId: String // 线路Id
  167 + ccMap: Map // 车辆配置Map Map<id, CarConfigInfo>
141 168 end
142 169  
143   -rule "calcu_CarConfig_Wrap"
  170 +rule "calcu_CarConfig_Wraps"
144 171 salience 800
145 172 when
146 173 $lr: Loop_result($xlId: xlId)
147   - $ccf: CarConfigInfo() from carConfigInfoRepository.findByXlId(Integer.parseInt($xlId))
148 174 then
149   - CarConfig_Wrap carConfig_wrap = new CarConfig_Wrap();
150   - carConfig_wrap.setId(String.valueOf($ccf.getId()));
151   - carConfig_wrap.setSelf($ccf);
  175 + List carConfigInfos = carConfigInfoRepository.findByXlId(Integer.parseInt($xlId));
  176 +
  177 + CarConfig_Wraps carConfig_wraps = new CarConfig_Wraps();
  178 + carConfig_wraps.setXlId($xlId);
  179 + carConfig_wraps.setCcMap(new HashMap());
  180 +
  181 + for (int i = 0; i < carConfigInfos.size(); i++) {
  182 + CarConfigInfo carConfigInfo = (CarConfigInfo) carConfigInfos.get(i);
  183 + carConfig_wraps.getCcMap().put(carConfigInfo.getId().toString(), carConfigInfo);
  184 + }
152 185  
153   - insert(carConfig_wrap);
  186 + insert(carConfig_wraps);
154 187  
155 188 log.info("calcu_CarConfig_Wrap");
156 189 end
157 190  
158 191 //--------------- 人员配置信息载入 --------------//
159   -declare EmployeeConfig_Wrap
160   - id: String // 人员配置id(cast字符串-方便比较)
161   -
162   - self: EmployeeConfigInfo // 原始数据
  192 +declare EmployeeConfig_Wraps
  193 + xlId: String // 线路Id
  194 + ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>
163 195 end
164 196  
165   -rule "calcu_EmployeeConfig_Wrap"
  197 +rule "calcu_EmployeeConfig_Wraps"
166 198 salience 800
167 199 when
168 200 $lr: Loop_result($xlId: xlId)
169   - $eci: EmployeeConfigInfo() from employeeConfigInfoRepository.findByXlId(Integer.parseInt($xlId))
170 201 then
171   - EmployeeConfig_Wrap employeeConfig_wrap = new EmployeeConfig_Wrap();
172   - employeeConfig_wrap.setId(String.valueOf($eci.getId()));
173   - employeeConfig_wrap.setSelf($eci);
  202 + List employeeConfigInfos = employeeConfigInfoRepository.findByXlId(Integer.parseInt($xlId));
  203 +
  204 + EmployeeConfig_Wraps employeeConfig_wraps = new EmployeeConfig_Wraps();
  205 + employeeConfig_wraps.setXlId($xlId);
  206 + employeeConfig_wraps.setEcMap(new HashMap());
  207 +
  208 + for (int i = 0; i < employeeConfigInfos.size(); i++) {
  209 + EmployeeConfigInfo employeeConfigInfo = (EmployeeConfigInfo) employeeConfigInfos.get(i);
  210 + employeeConfig_wraps.getEcMap().put(employeeConfigInfo.getId().toString(), employeeConfigInfo);
  211 + }
174 212  
175   - insert(employeeConfig_wrap);
  213 + insert(employeeConfig_wraps);
176 214  
177 215 log.info("calcu_EmployeeConfig_Wrap");
178 216 end
... ... @@ -208,16 +246,12 @@ rule &quot;calcu_TTInfo_gid_stat&quot;
208 246  
209 247 insert(ttInfo_gid_stat);
210 248  
211   - log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}",
212   - $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime());
  249 +// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}",
  250 +// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime());
213 251  
214 252 end
215 253  
216 254 declare TTInfoDetail_Wrap
217   - xlId: String // 线路id(cast字符串-方便比较)
218   - ttInfoId: String // 时刻表id(cast字符串-方便比较)
219   - gid: String // 路牌id(cast字符串-方便比较)
220   -
221 255 isFirstBc: Boolean = false // 是否是当前路牌的第一个班次
222 256 isLastBc: Boolean = false // 是否是当前路牌的最后一个班次
223 257 isFb: Boolean = false // 是否分班
... ... @@ -225,110 +259,193 @@ declare TTInfoDetail_Wrap
225 259 self: TTInfoDetail // 原始数据
226 260 end
227 261  
228   -rule "calcu_TTInfoDetail_Wrap"
229   - salience 800
  262 +declare TTInfoDetail_Wraps
  263 + xlId: String // 线路id(cast字符串-方便比较)
  264 + ttInfoId: String // 时刻表id(cast字符串-方便比较)
  265 +
  266 + detailsMap: Map // 明细Map,Map<路牌id, List<TTInfoDetail_Wrap>>
  267 +end
  268 +
  269 +rule "calcu_TTInfoDetail_Wraps"
  270 + salience 700
230 271 when
231 272 $lr: Loop_result($xlId: xlId)
232 273 $ttInfoId: String() from $lr.getTtInfoMap().keySet()
233   - $ttInfoStat: TTInfo_gid_stat(
234   - ttInfoId == $ttInfoId,
235   - $gid: gid, $maxFcno: maxFcno)
236   - $ttInfoDetail: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId))
  274 + $ttInfoStatList: List(size > 0) from collect (TTInfo_gid_stat(ttInfoId == $ttInfoId))
237 275 then
238   - TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap();
239   - ttInfoDetail_wrap.setXlId($xlId);
240   - ttInfoDetail_wrap.setTtInfoId($ttInfoId);
241   - ttInfoDetail_wrap.setGid($gid);
242   - ttInfoDetail_wrap.setIsFirstBc(1 == $ttInfoDetail.getFcno());
243   - ttInfoDetail_wrap.setIsLastBc($maxFcno == $ttInfoDetail.getFcno());
244   -
245   - LocalTime fcsj = fcsjTime($ttInfoDetail.getFcsj());
246   - LocalTime fbsj = $ttInfoStat.getFbTime();
247   - ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
248   -
249   - ttInfoDetail_wrap.setSelf($ttInfoDetail);
250   -
251   - insert(ttInfoDetail_wrap);
252   -
253   - log.info("xlid={},ttid={},gid={},isFirstBc={},isLastBc={},isFb={},fcsj={}",
254   - $xlId, $ttInfoId, $gid,
255   - ttInfoDetail_wrap.getIsFirstBc(),
256   - ttInfoDetail_wrap.getIsLastBc(),
257   - ttInfoDetail_wrap.getIsFb(),
258   - $ttInfoDetail.getFcsj());
  276 + TTInfoDetail_Wraps ttInfoDetail_wraps = new TTInfoDetail_Wraps();
  277 + ttInfoDetail_wraps.setXlId($xlId);
  278 + ttInfoDetail_wraps.setTtInfoId($ttInfoId);
  279 + ttInfoDetail_wraps.setDetailsMap(new HashMap());
  280 +
  281 + // 将list的形式变成 Map<路牌id, TTInfo_gid_stat>
  282 + Map statMap = new HashMap();
  283 + for (int i = 0; i < $ttInfoStatList.size(); i++) {
  284 + TTInfo_gid_stat ttInfo_gid_stat = (TTInfo_gid_stat) $ttInfoStatList.get(i);
  285 + statMap.put(ttInfo_gid_stat.getGid(), ttInfo_gid_stat);
  286 + }
  287 +
  288 + // 迭代ttinfodetail,拼装 TTInfoDetail_Wraps
  289 + List detaillist = tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId));
  290 + for (int j = 0; j < detaillist.size(); j++) {
  291 + TTInfoDetail ttInfoDetail = (TTInfoDetail) detaillist.get(j);
  292 + String gid = String.valueOf(ttInfoDetail.getLp().getId());
  293 +
  294 + if (ttInfoDetail_wraps.getDetailsMap().get(gid) == null) {
  295 + ttInfoDetail_wraps.getDetailsMap().put(gid, new ArrayList());
  296 + }
  297 +
  298 + // 获取stat
  299 + TTInfo_gid_stat ttInfo_gid_stat = (TTInfo_gid_stat) statMap.get(gid);
  300 +
  301 + TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap();
  302 + ttInfoDetail_wrap.setIsFirstBc(1 == ttInfoDetail.getFcno());
  303 + ttInfoDetail_wrap.setIsLastBc(ttInfo_gid_stat.getMaxFcno() == ttInfoDetail.getFcno());
  304 +
  305 + LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj());
  306 + LocalTime fbsj = ttInfo_gid_stat.getFbTime();
  307 + ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
  308 +
  309 + ttInfoDetail_wrap.setSelf(ttInfoDetail);
  310 +
  311 + ((List) ttInfoDetail_wraps.getDetailsMap().get(gid)).add(ttInfoDetail_wrap);
  312 +
  313 + }
  314 +
  315 +
  316 + insert(ttInfoDetail_wraps);
  317 +
  318 + log.info("xlid={}, ttinfoid={}, lpstatCount={}, detailLpCount={}",
  319 + $xlId, $ttInfoId, $ttInfoStatList.size(), ttInfoDetail_wraps.getDetailsMap().keySet().size());
  320 +
  321 +
  322 +end
  323 +
  324 +declare TTInfoDetail_Wraps_map
  325 + xlId: String // 线路id(cast字符串-方便比较)
  326 +
  327 + wrapsMap: Map // 明细Map,Map<时刻表Id, TTInfoDetail_Wraps>
  328 +end
  329 +
  330 +rule "calcu_TTInfoDetail_Wraps_toMap"
  331 + salience 600
  332 + when
  333 + $lr: Loop_result($xlId: xlId)
  334 + $wrapsList: List(size > 0) from collect (TTInfoDetail_Wraps(xlId == $xlId))
  335 + then
  336 + // 转换成Map
  337 + TTInfoDetail_Wraps_map all = new TTInfoDetail_Wraps_map();
  338 + all.setXlId($xlId);
  339 + all.setWrapsMap(new HashMap());
  340 +
  341 + for (int i = 0; i < $wrapsList.size(); i++) {
  342 + TTInfoDetail_Wraps ttInfoDetail_wraps = (TTInfoDetail_Wraps) $wrapsList.get(i);
  343 + all.getWrapsMap().put(ttInfoDetail_wraps.getTtInfoId(), ttInfoDetail_wraps);
  344 + }
  345 +
  346 + insert(all);
259 347 end
260 348  
  349 +
  350 +
  351 +
261 352 //-------------------- 第三阶段、合并计算SchedulePlanInfo -----------------//
262 353  
  354 +
263 355 rule "Calcu_SchedulePlanInfo"
264   - salience 600
  356 + salience 500
265 357 when
266 358 $param: PlanCalcuParam_input($xlId: xlId)
267 359 $lr: Loop_result(xlId == $xlId)
268   - $sro: ScheduleResult_output($sd: sd, $gid: guideboardId) from $lr.getRuleLoop()
269   - CarConfig_Wrap(id == $sro.carConfigId, $cc: self)
270   - TTInfoDetail_Wrap(
271   - ttInfoId == ttInfoId_sd($lr.getTtInfoMapLoop(), $sd),
272   - gid == $gid,
273   - $isFb: isFb, $isFirstBc: isFirstBc, $isLastBc: isLastBc,
274   - $ttInfoDetail: self
275   - )
  360 + $ccs: CarConfig_Wraps(xlId == $xlId)
  361 + $ecs: EmployeeConfig_Wraps(xlId == $xlId)
  362 + $tts: TTInfoDetail_Wraps_map(xlId == $xlId)
276 363 then
277 364 // 线路
278 365 Line xl = lineRepository.findOne(Integer.parseInt($xlId));
279 366  
280   - SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(
281   - xl,
282   - $sro,
283   - $ttInfoDetail,
284   - $isFb,
285   - $cc,
286   - ecList(employeeConfigInfoRepository, $sro.getEmployeeConfigId()),
287   - $param.getSchedulePlan(),
288   - $isFirstBc,
289   - $isLastBc
290   - );
291   -
292   - // 获取公司,分公司信息
293   - String gsbm = xl.getCompany();
294   - String fgsbm = xl.getBrancheCompany();
295   - Business gs = null;
296   - Business fgs = null;
297   -
298   - if (StringUtils.isNotEmpty(gsbm)) {
299   - Iterator<Business> businessIterator1 = businessRepository.findByBusinessCode(gsbm).iterator();
300   - if (businessIterator1.hasNext()) {
301   - gs = (Business) businessIterator1.next();
  367 + // 查找公司
  368 + List gses = (List) businessRepository.findAll();
  369 + // 构造公司代码对应map
  370 + Map gsMap = gsMap(gses);
  371 + // 构造分公司对应的map
  372 + Map fgsMap = fgsMap(gses);
  373 +
  374 + for (int i = 0; i < $lr.getRuleLoop().size(); i++) {
  375 + ScheduleResult_output sro = (ScheduleResult_output) $lr.getRuleLoop().get(i);
  376 +
  377 + // 日期
  378 + DateTime sd = sro.getSd();
  379 + // 路牌
  380 + String gid = sro.getGuideboardId();
  381 + // 车辆配置
  382 + CarConfigInfo carConfigInfo = (CarConfigInfo) $ccs.getCcMap().get(sro.getCarConfigId());
  383 + // 人员配置
  384 + List eclist = ecList(employeeConfigInfoRepository, sro.getEmployeeConfigId());
  385 +
  386 + // 时刻表id
  387 + String ttInfoId = ttInfoId_sd($lr.getTtInfoMapLoop(), sd);
  388 + TTInfoDetail_Wraps ttInfoDetail_wraps = (TTInfoDetail_Wraps) $tts.getWrapsMap().get(ttInfoId);
  389 + List detaillist = (List) ttInfoDetail_wraps.getDetailsMap().get(gid);
  390 +
  391 + if (detaillist == null) {
  392 + // 这里翻到的路牌时刻表里可能没有,
  393 + // 因为没有考虑翻班格式(就是做几休几)
  394 + // 所有翻班格式全由时刻表决定,即时刻表有的路牌就做,没有不做
  395 + continue;
302 396 }
303   - }
304   - if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {
305   - Iterator<Business> businessIterator2 = businessRepository.findByUpCodeAndBusinessCode(gsbm, fgsbm).iterator();
306   - if (businessIterator2.hasNext()) {
307   - fgs = (Business) businessIterator2.next();
308   - }
309   - }
310 397  
311   - if (gs != null) {
312   - schedulePlanInfo.setGsBm(gs.getBusinessCode());
313   - schedulePlanInfo.setGsName(gs.getBusinessName());
314   - }
315   - if (fgs != null) {
316   - schedulePlanInfo.setFgsBm(fgs.getBusinessCode());
317   - schedulePlanInfo.setFgsName(fgs.getBusinessName());
318   - }
  398 + for (int j = 0; j < detaillist.size(); j++) {
  399 + TTInfoDetail_Wrap wrap = (TTInfoDetail_Wrap) detaillist.get(j);
  400 +
  401 + SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(
  402 + xl,
  403 + sro,
  404 + wrap.getSelf(),
  405 + wrap.getIsFb(),
  406 + carConfigInfo,
  407 + eclist,
  408 + $param.getSchedulePlan(),
  409 + wrap.getIsFirstBc(),
  410 + wrap.getIsLastBc()
  411 + );
  412 +
  413 + // 获取公司,分公司信息
  414 + String gsbm = xl.getCompany();
  415 + String fgsbm = xl.getBrancheCompany();
  416 + Business gs = null;
  417 + Business fgs = null;
  418 +
  419 + if (StringUtils.isNotEmpty(gsbm)) {
  420 + gs = (Business) gsMap.get(gsbm);
  421 + }
  422 + if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {
  423 + fgs = (Business) fgsMap.get(gsbm + "_" + fgsbm);
  424 + }
  425 +
  426 + if (gs != null) {
  427 + schedulePlanInfo.setGsBm(gs.getBusinessCode());
  428 + schedulePlanInfo.setGsName(gs.getBusinessName());
  429 + }
  430 + if (fgs != null) {
  431 + schedulePlanInfo.setFgsBm(fgs.getBusinessCode());
  432 + schedulePlanInfo.setFgsName(fgs.getBusinessName());
  433 + }
  434 +
  435 + // 操作人,操作时间
  436 + schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy());
  437 + schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate());
  438 + schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy());
  439 + schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate());
  440 +
  441 + // result 输出
  442 + planResult.getSchedulePlanInfos().add(schedulePlanInfo);
319 443  
320   - // 操作人,操作时间
321   - schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy());
322   - schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate());
323   - schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy());
324   - schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate());
  444 + }
325 445  
326   - // result 输出
327   - planResult.getSchedulePlanInfos().add(schedulePlanInfo);
  446 + }
328 447  
329   - log.info("gid={},ecid={},ttInfoId={}",
330   - $gid, ecList(employeeConfigInfoRepository, $sro.getEmployeeConfigId()),
331   - ttInfoId_sd($lr.getTtInfoMapLoop(), $sd));
  448 + log.info("xlid={} plan ok!", $xlId);
332 449  
333 450 end
334 451  
... ... @@ -345,4 +462,3 @@ end
345 462  
346 463  
347 464  
348   -
... ...
src/main/resources/static/real_control_v2/css/line_schedule_table.css 0 → 100644
  1 +
  2 +.electron-waybill-table{
  3 + height: 100%;
  4 +}
  5 +
  6 +.electron-waybill-table dl{
  7 + font-size: 0;
  8 + white-space: nowrap;
  9 + overflow: hidden;
  10 + text-overflow: ellipsis;
  11 +}
  12 +
  13 +.electron-waybill-table dt,
  14 +.electron-waybill-table dd{
  15 + display: inline-block;
  16 + font-size: 14px;
  17 + white-space: nowrap;
  18 + overflow: hidden;
  19 + text-overflow: ellipsis;
  20 + border-right: 1px solid;
  21 + text-indent: 5px;
  22 + height: 37px;
  23 +}
  24 +.electron-waybill-table dt:nth-of-type(1),
  25 +.electron-waybill-table dd:nth-of-type(1){
  26 + width: 50px;
  27 + text-align: center;
  28 +}
  29 +.electron-waybill-table dt:nth-of-type(2),
  30 +.electron-waybill-table dd:nth-of-type(2){
  31 + width: 55px;
  32 + text-align: center;
  33 +}
  34 +.electron-waybill-table dt:nth-of-type(3),
  35 +.electron-waybill-table dd:nth-of-type(3){
  36 + width: calc(2% + 66px);
  37 +}
  38 +.electron-waybill-table dt:nth-of-type(4),
  39 +.electron-waybill-table dd:nth-of-type(4){
  40 + width: 10%;
  41 +}
  42 +.electron-waybill-table dt:nth-of-type(5),
  43 +.electron-waybill-table dd:nth-of-type(5){
  44 + width: 10%;
  45 +}
  46 +.electron-waybill-table dt:nth-of-type(6),
  47 +.electron-waybill-table dd:nth-of-type(6){
  48 + width: calc(13% + 18px);
  49 +}
  50 +.electron-waybill-table dt:nth-of-type(7),
  51 +.electron-waybill-table dd:nth-of-type(7){
  52 + width: calc(10% + 10px);
  53 +}
  54 +.electron-waybill-table dt:nth-of-type(8),
  55 +.electron-waybill-table dd:nth-of-type(8){
  56 + width: calc(51% - 233px);
  57 +}
  58 +.electron-waybill-table dt:nth-of-type(9),
  59 +.electron-waybill-table dd:nth-of-type(9){
  60 + width: 65px;
  61 +}
  62 +
  63 +
  64 +
  65 +.electron-waybill-table .electron-waybill-header{
  66 + color: #cfd2da;
  67 +}
  68 +
  69 +.electron-waybill-table .electron-waybill-header dl{
  70 + border-bottom: 1px solid #979494;
  71 + height: 38px;
  72 + line-height: 38px;
  73 + margin-bottom: 0;
  74 + margin-top: 0;
  75 +}
  76 +.electron-waybill-table .electron-waybill-header dl dt{
  77 +
  78 +}
  79 +
  80 +
  81 +.electron-waybill-table .electron-waybill-body{
  82 + color: #cfd2da;
  83 + height: calc(100% - 39px);
  84 + overflow: hidden;
  85 + position: relative;
  86 +}
  87 +
  88 +.electron-waybill-table .electron-waybill-body dl{
  89 + height: 38px;
  90 + line-height: 38px;
  91 + margin-bottom: 0;
  92 + margin-top: 0;
  93 +}
  94 +
  95 +.electron-waybill-table .electron-waybill-body dl:nth-child(1n+2){
  96 + border-top: 1px solid;
  97 +}
  98 +
  99 +.electron-waybill-table .electron-waybill-body dl:last-child{
  100 + border-bottom: 1px solid;
  101 +}
  102 +
  103 +.electron-waybill-table dt,
  104 +.electron-waybill-table dd,
  105 +.electron-waybill-table .electron-waybill-body dl:nth-child(1n+2),
  106 +.electron-waybill-table .electron-waybill-body dl:last-child{
  107 + border-color: #363a44;
  108 +}
  109 +
  110 +.electron-waybill-table .electron-waybill-body dl:nth-child(odd){
  111 +
  112 +}
  113 +
  114 +.electron-waybill-table .electron-waybill-body dl:nth-child(even){
  115 + /*background: #434753;*/
  116 +}
  117 +
  118 +.electron-waybill-table .uk-badge{
  119 + padding: 0 1px 0 1px;
  120 + text-indent: 0;
  121 + font-family: 华文细黑;
  122 +}
  123 +
  124 +
  125 +
  126 +.electron-waybill-table .ps-container:hover > .ps-scrollbar-y-rail:hover,
  127 +.electron-waybill-table .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail{
  128 + background-color: #484848;
  129 +}
  130 +
  131 +.electron-waybill-table .ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y {
  132 + background-color: #fff;
  133 + }
0 134 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/css/main.css
... ... @@ -1058,4 +1058,79 @@ span.late-badge {
1058 1058  
1059 1059 dl.intimity span.late-badge{
1060 1060 color: #fbfbfb;
1061   -}
1062 1061 \ No newline at end of file
  1062 +}
  1063 +
  1064 +/** badge tooltip */
  1065 +.uk-badge.c_task:hover,
  1066 +.uk-badge.sch_region:hover{
  1067 + background-image: none;
  1068 + background: #38b3e1;
  1069 + border: 1px solid #7ebad1;
  1070 +}
  1071 +
  1072 +.uk-badge.out:hover{
  1073 + background-image: none;
  1074 + background: #8fc650;
  1075 + border: 1px solid #949f86;
  1076 +}
  1077 +
  1078 +.uk-badge.in:hover{
  1079 + background-image: none;
  1080 + background: #fabc64;
  1081 + border: 1px solid #a68c67;
  1082 +}
  1083 +
  1084 +.qtip.sch-badge-tip{
  1085 + max-width: 500px;
  1086 +}
  1087 +
  1088 +.tip_task_list {
  1089 + width: 460px;
  1090 + margin-bottom: -10px;
  1091 +}
  1092 +.tip_task_list dl{
  1093 + font-size: 0;
  1094 + border-bottom: 1px solid #e6e6e6;
  1095 + margin: 0;
  1096 +}
  1097 +.tip_task_list dl:last-child{
  1098 + border-bottom: none;
  1099 +}
  1100 +.tip_task_list dl dt,
  1101 +.tip_task_list dl dd{
  1102 + display: inline-block;
  1103 + font-size: 13px;
  1104 + white-space: nowrap;
  1105 + overflow: hidden;
  1106 + text-overflow: ellipsis;
  1107 + height: 24px;
  1108 + line-height: 24px;
  1109 +}
  1110 +
  1111 +.tip_task_list dl dt:nth-of-type(1), .tip_task_list dl dd:nth-of-type(1){
  1112 + width: 19%;
  1113 +}
  1114 +.tip_task_list dl dt:nth-of-type(2), .tip_task_list dl dd:nth-of-type(2){
  1115 + width: 12%;
  1116 +}
  1117 +.tip_task_list dl dt:nth-of-type(3), .tip_task_list dl dd:nth-of-type(3){
  1118 + width: 28%;
  1119 +}
  1120 +.tip_task_list dl dt:nth-of-type(4), .tip_task_list dl dd:nth-of-type(4){
  1121 + width: 28%;
  1122 +}
  1123 +.tip_task_list dl dt:nth-of-type(5), .tip_task_list dl dd:nth-of-type(5){
  1124 + width: 13%;
  1125 +}
  1126 +
  1127 +.tip_task_list dl.service{
  1128 + color: blue;
  1129 +}
  1130 +.tip_task_list dl.service.destroy{
  1131 + color: red;
  1132 +}
  1133 +
  1134 +.tip_task_list dl span{
  1135 + margin: 0;
  1136 + width: auto;
  1137 +}
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/badge_tooltip.html 0 → 100644
  1 +<div>
  2 + <script id="sch-table-task-tootip-temp" type="text/html">
  3 + <div class="tl-tip-panel">
  4 + <div class="tip_task_list">
  5 + <dl>
  6 + <dt>类型</dt>
  7 + <dt>里程</dt>
  8 + <dt>起点</dt>
  9 + <dt>终点</dt>
  10 + <dt>备注</dt>
  11 + </dl>
  12 + {{each tasks as t i}}
  13 + <dl class="{{t.mileageType}} {{if t.destroy}}destroy{{/if}}">
  14 + <dd>
  15 + {{if t.mileageType=="service"}}
  16 + 营运
  17 + {{else if t.mileageType=="empty"}}
  18 + 空驶
  19 + {{/if}}
  20 + {{if t.destroy}}
  21 + <span>(烂班)</span>
  22 + {{else if t.type2==2}}
  23 + <span>(进场)</span>
  24 + {{else if t.type2==3}}
  25 + <span>(出场)</span>
  26 + {{/if}}
  27 + </dd>
  28 + <dd>
  29 + {{t.mileage}}
  30 + </dd>
  31 + <dd title="{{t.startStationName}}">{{t.startStationName}}</dd>
  32 + <dd title="{{t.endStationName}}">{{t.endStationName}}</dd>
  33 + <dd title="{{t.remarks}}">{{t.remarks}}</dd>
  34 + </dl>
  35 + {{/each}}
  36 + </div>
  37 + </div>
  38 + </script>
  39 +
  40 +
  41 + <script id="sch-table-region-tootip-temp" type="text/html">
  42 + <div class="tl-tip-panel">
  43 + <div style="font-size: 13px;">
  44 + 由 {{qdzName}} 发往 {{zdzName}}
  45 + </div>
  46 + </div>
  47 + </script>
  48 +
  49 + <script id="sch-table-out-tootip-temp" type="text/html">
  50 + <div class="tl-tip-panel">
  51 + <div style="font-size: 13px;">
  52 + {{qdzName}} 出场至 {{zdzName}}
  53 + </div>
  54 + </div>
  55 + </script>
  56 +
  57 + <script id="sch-table-in-tootip-temp" type="text/html">
  58 + <div class="tl-tip-panel">
  59 + <div style="font-size: 13px;">
  60 + 进 {{zdzName}}
  61 + </div>
  62 + </div>
  63 + </script>
  64 +</div>
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_inpark.html
... ... @@ -6,7 +6,7 @@
6 6  
7 7 <div style="width: 100%;padding-left: 1%;">
8 8 <div class="sub-task-card">
9   - <div class="uk-panel uk-panel-box uk-panel-box-primary">
  9 + <div class="uk-panel uk-panel-box uk-panel-box-primary twins_task_panel">
10 10 <div class="uk-panel-badge uk-badge">营运</div>
11 11 <h3 class="uk-panel-title">线路上站点间</h3>
12 12 <form class="uk-form uk-form-horizontal inpark_form" service_form>
... ... @@ -105,7 +105,7 @@
105 105 </div>
106 106 </div>
107 107 <div class="uk-width-7-10 pl5">
108   - <select name="startStation" disabled></select>
  108 + <select name="startStation" ></select>
109 109 </div>
110 110 </div>
111 111 <div class="uk-grid">
... ... @@ -352,6 +352,9 @@
352 352 var e =$('#globalRemarks', modal);
353 353 e.val(e.val() + $(this).val() + ',');
354 354 });
  355 +
  356 + //根据主任务状态,复子任务
  357 + updateTwinsTaskBySch(sch);
355 358 });
356 359  
357 360 function allValidSuccess() {
... ... @@ -579,6 +582,22 @@
579 582 btmDrawer.data('name', id).data('url', url).trigger('drawer_show');
580 583 }
581 584 }
  585 +
  586 +
  587 + function updateTwinsTaskBySch(sch) {
  588 + //主任务是烂班
  589 + if(sch.destroy){
  590 + serviceForm.prepend('<input type="hidden" name="destroy" value="true">');
  591 + $('[name=mileage]', serviceForm).val(sch.jhlcOrig).attr('disabled', 'disabled');
  592 + $('.twins_task_panel .uk-badge', modal).addClass('uk-badge-danger').text('烂班');
  593 + //终点禁选
  594 + $('select[name=endStation]', serviceForm).attr('disabled', 'disabled');
  595 + //开始结束时间禁选
  596 +
  597 + //空驶起点
  598 + $('select[name=startStation]', emptyForm).val(sch.qdzCode);
  599 + }
  600 + }
582 601 })();
583 602 </script>
584 603 </div>
585 604 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_oil.html
... ... @@ -6,7 +6,7 @@
6 6  
7 7 <div class="uk-grid">
8 8 <div class="uk-width-1-3">
9   - <form class="uk-form uk-form-horizontal c_task_form">
  9 + <form class="uk-form uk-form-horizontal c_task_form twins_task_form">
10 10 <input type="hidden" name="type1" value="正常">
11 11 <input type="hidden" name="type2" value="1">
12 12 <input type="hidden" name="mileageType" value="service">
... ... @@ -189,6 +189,7 @@
189 189 $(modal).on('init', function (e, data) {
190 190 e.stopPropagation();
191 191 sch = data.sch;
  192 +
192 193 oilId = sch.xlBm + '_oil_station';
193 194 lineInfo = gb_data_basic.codeToLine[sch.xlBm];
194 195  
... ... @@ -242,6 +243,9 @@
242 243 }, {center: false, bgclose: false, modal: false});
243 244 });
244 245 });
  246 +
  247 + //根据主任务状态,复子任务
  248 + updateTwinsTaskBySch(sch);
245 249 });
246 250  
247 251 var dataArray = [];
... ... @@ -274,7 +278,7 @@
274 278 }
275 279 else{
276 280 //营运子任务不写备注
277   - if(data.mileageType == 'service' && !data.destroy)
  281 + if(data.mileageType == 'service')
278 282 data.remarks = '';
279 283 gb_common.$post('/childTask', data, function (rs) {
280 284 notify_succ('子任务添加成功');
... ... @@ -450,6 +454,23 @@
450 454 $('.inout_reason_tags>span.active', modal).removeClass('active');
451 455 $(this).addClass('active');
452 456 });
  457 +
  458 +
  459 + function updateTwinsTaskBySch(sch) {
  460 + //主任务是烂班
  461 + if(sch.destroy){
  462 + var f = $('.twins_task_form', modal);
  463 + $('.uk-badge', f).addClass('uk-badge-danger').text('烂班');
  464 + $('.uk-panel-box', f).removeClass('uk-panel-box-primary');
  465 + f.prepend('<input type="hidden" name="destroy" value="true">');
  466 + $('[name=mileage]', f).val(sch.jhlcOrig);
  467 +
  468 + //进场起点
  469 + $('[name=startStation]', jcForm).val(sch.qdzCode);
  470 + //出场终点
  471 + $('[name=endStation]', ccForm).val(sch.qdzCode);
  472 + }
  473 + }
453 474 })();
454 475 </script>
455 476 </div>
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_outpark.html
... ... @@ -42,7 +42,7 @@
42 42 </div>
43 43 </div>
44 44 <div class="uk-width-7-10 pl5">
45   - <select name="endStation" class="ct_focus" disabled></select>
  45 + <select name="endStation" class="ct_focus"></select>
46 46 </div>
47 47 </div>
48 48 <div class="uk-grid">
... ... @@ -82,7 +82,7 @@
82 82 </div>
83 83  
84 84 <div class="sub-task-card">
85   - <div class="uk-panel uk-panel-box uk-panel-box-primary">
  85 + <div class="uk-panel uk-panel-box uk-panel-box-primary twins_task_panel">
86 86 <div class="uk-panel-badge uk-badge">营运</div>
87 87 <h3 class="uk-panel-title">线路上站点间</h3>
88 88 <form class="uk-form uk-form-horizontal inpark_form" service_form>
... ... @@ -199,6 +199,9 @@
199 199  
200 200 //设置默认值
201 201 setDefaultVal();
  202 +
  203 + //根据主任务状态,复子任务
  204 + updateTwinsTaskBySch(sch);
202 205 });
203 206 //线路标准
204 207 information = gb_data_basic.getLineInformation(sch.xlBm);
... ... @@ -271,13 +274,6 @@
271 274 });
272 275 });
273 276  
274   - /* function outUpOrDown() {
275   - if (information.carPark != $('select[name=startStation]', emptyForm).val())
276   - return -1;
277   -
278   - return sch.xlDir;
279   - }*/
280   -
281 277 function getOutTime() {
282 278 if (information.carPark != $('select[name=startStation]', emptyForm).val())
283 279 return null;
... ... @@ -337,6 +333,16 @@
337 333 //空驶里程
338 334 $('input[name=mileage]', emptyForm).val(sch.xlDir == 0 ? information.upOutMileage : information.downOutMileage);
339 335 }
  336 +
  337 +
  338 + function updateTwinsTaskBySch(sch) {
  339 + //主任务是烂班
  340 + if(sch.destroy){
  341 + serviceForm.prepend('<input type="hidden" name="destroy" value="true">');
  342 + $('.twins_task_panel .uk-badge', modal).addClass('uk-badge-danger').text('烂班');
  343 + $('[name=mileage]', serviceForm).val(sch.jhlcOrig).attr('disabled', 'disabled');
  344 + }
  345 + }
340 346 })();
341 347 </script>
342 348 </div>
343 349 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
... ... @@ -3,9 +3,9 @@
3 3 <div class="schedule-wrap {{if dir==0}}up{{else}}down{{/if}}">
4 4 <h3 class="header-title">
5 5 {{if dir==0}}
6   - 上行/{{line.startStationName}}
  6 + {{line.startStationName}}
7 7 {{else}}
8   - 下行/{{line.endStationName}}
  8 + {{line.endStationName}}
9 9 {{/if}}
10 10 <i class="uk-icon-question-circle uk-icon-hover"></i>
11 11 <div class="fixed_legend">
... ... @@ -65,21 +65,21 @@
65 65 <dd data-sort-val={{sch.fcsjT}}>
66 66 {{sch.fcsj}}
67 67 {{if sch.bcType == "out"}}
68   - <span class="uk-badge uk-badge-success">出场</span>
  68 + <span class="uk-badge uk-badge-success out">出场</span>
69 69 {{else if sch.bcType == "in"}}
70   - <span class="uk-badge uk-badge-warning">进场</span>
  70 + <span class="uk-badge uk-badge-warning in">进场</span>
71 71 {{else if sch.bcType == "venting"}}
72 72 <span class="uk-badge uk-badge-danger">直放</span>
73 73 {{else if sch.bcType == "major"}}
74 74 <span class="uk-badge uk-badge-danger">放站</span>
75 75 {{else if sch.bcType == "region"}}
76   - <span class="uk-badge">区间</span>
  76 + <span class="uk-badge sch_region">区间</span>
77 77 {{/if}}
78 78 {{if sch.sflj}}
79 79 <span class="uk-badge uk-badge-danger">临加</span>
80 80 {{/if}}
81 81 {{if sch.cTasks.length > 0}}
82   - <span class="uk-badge uk-badge-notification">{{sch.cTasks.length}}</span>
  82 + <span class="uk-badge uk-badge-notification c_task">{{sch.cTasks.length}}</span>
83 83 {{/if}}
84 84 </dd>
85 85 <dd data-sort-val={{sch.dfsjT}} dbclick dbclick-type="dfsj" dbclick-val="{{sch.dfsj}}">
... ... @@ -117,21 +117,21 @@
117 117 <dd data-sort-val={{fcsjT}}>
118 118 {{fcsj}}
119 119 {{if bcType == "out"}}
120   - <span class="uk-badge uk-badge-success">出场</span>
  120 + <span class="uk-badge uk-badge-success out">出场</span>
121 121 {{else if bcType == "in"}}
122   - <span class="uk-badge uk-badge-warning">进场</span>
  122 + <span class="uk-badge uk-badge-warning in">进场</span>
123 123 {{else if bcType == "venting"}}
124 124 <span class="uk-badge uk-badge-danger">直放</span>
125 125 {{else if bcType == "major"}}
126 126 <span class="uk-badge uk-badge-danger">放站</span>
127 127 {{else if bcType == "region"}}
128   - <span class="uk-badge">区间</span>
  128 + <span class="uk-badge sch_region">区间</span>
129 129 {{/if}}
130 130 {{if sflj}}
131 131 <span class="uk-badge uk-badge-danger">临加</span>
132 132 {{/if}}
133 133 {{if cTasks.length > 0}}
134   - <span class="uk-badge uk-badge-notification">{{cTasks.length}}</span>
  134 + <span class="uk-badge uk-badge-notification c_task">{{cTasks.length}}</span>
135 135 {{/if}}
136 136 </dd>
137 137 </script>
... ...
src/main/resources/static/real_control_v2/js/line_schedule/badge_tooltip.js 0 → 100644
  1 +
  2 +/** badge 悬停 tip 相关 */
  3 +var gb_schedule_badge_tootip = (function () {
  4 +
  5 + var temps;
  6 + //html 模板
  7 + $.get('/real_control_v2/fragments/line_schedule/badge_tooltip.html', function(dom) {
  8 + temps = gb_common.compileTempByDom(dom);
  9 + });
  10 +
  11 + //子任务 tootip
  12 + $(document).on('mouseenter', '.schedule-wrap .ct_table_body .uk-badge.c_task', function() {
  13 + $(this).qtip({
  14 + show: {
  15 + ready: true,
  16 + delay: 300
  17 + },
  18 + content: {
  19 + text: function() {
  20 + var id = $(this).parents('dl').data('id'),
  21 + lineCode = $(this).parents('li.line_schedule').data('id'),
  22 + sch = gb_schedule_table.findScheduleByLine(lineCode)[id];
  23 + //排序
  24 + var array = sch.cTasks.sort(function (a, b) {
  25 + var an = (a.mileageType=='service'?1:0)+''+(a.destroy?0:1);
  26 + var bn = (b.mileageType=='service'?1:0)+''+(b.destroy?0:1);
  27 + return parseInt(bn) - parseInt(an);
  28 + });
  29 + return temps['sch-table-task-tootip-temp']({tasks: array});
  30 + }
  31 + },
  32 + position: {
  33 + viewport: $(window),
  34 + my: 'center left',
  35 + at: 'center right'
  36 + },
  37 + style: {
  38 + classes: 'qtip-light qtip-rounded qtip-shadow sch-badge-tip'
  39 + },
  40 + hide: {
  41 + fixed: true,
  42 + delay: 300
  43 + },
  44 + events: {
  45 + hidden: function(event, api) {
  46 + //destroy dom
  47 + $(this).qtip('destroy', true);
  48 + }
  49 + }
  50 + });
  51 + });
  52 +
  53 + //区间 tootip
  54 + $(document).on('mouseenter', '.schedule-wrap .ct_table_body .uk-badge.sch_region', function() {
  55 + $(this).qtip({
  56 + show: {
  57 + ready: true,
  58 + delay: 300
  59 + },
  60 + content: {
  61 + text: function() {
  62 + var id = $(this).parents('dl').data('id'),
  63 + lineCode = $(this).parents('li.line_schedule').data('id'),
  64 + sch = gb_schedule_table.findScheduleByLine(lineCode)[id];
  65 + return temps['sch-table-region-tootip-temp'](sch);
  66 + }
  67 + },
  68 + position: {
  69 + viewport: $(window),
  70 + my: 'center left',
  71 + at: 'center right'
  72 + },
  73 + style: {
  74 + classes: 'qtip-youtube sch-badge-tip'
  75 + },
  76 + hide: {
  77 + fixed: true,
  78 + delay: 300
  79 + },
  80 + events: {
  81 + hidden: function(event, api) {
  82 + //destroy dom
  83 + $(this).qtip('destroy', true);
  84 + }
  85 + }
  86 + });
  87 + });
  88 +
  89 +
  90 + //出场 tootip
  91 + $(document).on('mouseenter', '.schedule-wrap .ct_table_body .uk-badge.out', function() {
  92 + $(this).qtip({
  93 + show: {
  94 + ready: true,
  95 + delay: 300
  96 + },
  97 + content: {
  98 + text: function() {
  99 + var id = $(this).parents('dl').data('id'),
  100 + lineCode = $(this).parents('li.line_schedule').data('id'),
  101 + sch = gb_schedule_table.findScheduleByLine(lineCode)[id];
  102 + return temps['sch-table-out-tootip-temp'](sch);
  103 + }
  104 + },
  105 + position: {
  106 + viewport: $(window),
  107 + my: 'center left',
  108 + at: 'center right'
  109 + },
  110 + style: {
  111 + classes: 'qtip-youtube sch-badge-tip'
  112 + },
  113 + hide: {
  114 + fixed: true,
  115 + delay: 300
  116 + },
  117 + events: {
  118 + hidden: function(event, api) {
  119 + //destroy dom
  120 + $(this).qtip('destroy', true);
  121 + }
  122 + }
  123 + });
  124 + });
  125 +
  126 +
  127 + //进场 tootip
  128 + $(document).on('mouseenter', '.schedule-wrap .ct_table_body .uk-badge.in', function() {
  129 + $(this).qtip({
  130 + show: {
  131 + ready: true,
  132 + delay: 300
  133 + },
  134 + content: {
  135 + text: function() {
  136 + var id = $(this).parents('dl').data('id'),
  137 + lineCode = $(this).parents('li.line_schedule').data('id'),
  138 + sch = gb_schedule_table.findScheduleByLine(lineCode)[id];
  139 + return temps['sch-table-in-tootip-temp'](sch);
  140 + }
  141 + },
  142 + position: {
  143 + viewport: $(window),
  144 + my: 'center left',
  145 + at: 'center right'
  146 + },
  147 + style: {
  148 + classes: 'qtip-youtube sch-badge-tip'
  149 + },
  150 + hide: {
  151 + fixed: true,
  152 + delay: 300
  153 + },
  154 + events: {
  155 + hidden: function(event, api) {
  156 + //destroy dom
  157 + $(this).qtip('destroy', true);
  158 + }
  159 + }
  160 + });
  161 + });
  162 +})();
0 163 \ No newline at end of file
... ...
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
... ... @@ -171,13 +174,15 @@ var gb_schedule_context_menu = (function () {
171 174 add_sub_task_range_turn: function (sch) {
172 175 if(sch.bcType == 'out' || sch.bcType == 'in')
173 176 return notify_err('进出场班次不能做区间掉头!');
  177 + if(sch.destroy)
  178 + return notify_err('没有理由在烂班上做区间调头!!');
174 179 open_modal(folder + '/sub_task/add_sub_task_range_turn.html', {
175 180 sch: sch
176 181 }, modal_opts);
177 182 },
178 183 add_oil: function (sch) {
179 184 if(sch.bcType == 'out' || sch.bcType == 'in'){
180   - notify_err('暂不能在进出场班次上做加油子任务!');
  185 + notify_err('暂不能在进出场班次上做这个操作!');
181 186 return;
182 187 }
183 188 open_modal(folder + '/sub_task/add_sub_task_oil.html', {
... ...
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);
... ... @@ -194,6 +194,9 @@ var gb_schedule_table = (function () {
194 194 gb_schedule_table_dbclick.sfsjCellClick($('dd.fcsjActualCell', tabCont));
195 195 //滚动条
196 196 $('.schedule-wrap .ct_table_wrap', tabCont).perfectScrollbar({suppressScrollX: true});
  197 +
  198 + //搜索模板初始化
  199 + gb_sch_search.init();
197 200 }
198 201 };
199 202  
... ... @@ -495,7 +498,7 @@ var gb_schedule_table = (function () {
495 498  
496 499 //标记终点时间 -线路
497 500 var markerLastByLine = function (lineCode) {
498   - var data = gb_common.groupBy(gb_common.get_vals(line2Schedule[lineCode]).filter(schDestroyFilter), 'clZbh');
  501 + var data = gb_common.groupBy(gb_common.get_vals(line2Schedule[lineCode]).filter(schDestroyFilter), 'lpName');
499 502  
500 503 var array, lastSch, dl;
501 504 for (var nbbm in data) {
... ...
src/main/resources/static/real_control_v2/js/line_schedule/search.js
... ... @@ -40,6 +40,9 @@ var gb_sch_search = (function() {
40 40 var elements = '.search_sch_panel .sch-search-autocom';
41 41 var init = function() {
42 42 $(elements).each(function() {
  43 + if($('script[type="text/autocomplete"]', this).length > 0)
  44 + return true;
  45 +
43 46 $(this).append(result_template);
44 47 constructor(this);
45 48 });
... ...
src/main/resources/static/real_control_v2/js/main.js
... ... @@ -171,8 +171,8 @@ var disabled_submit_btn = function (form) {
171 171 function showUpdateDescription() {
172 172 //更新说明
173 173 var updateDescription = {
174   - date: '2017-04-20',
175   - text: '<h5>现在可以在轨迹回放里看到停车场位置和多边形电子围栏</h5><h5>区间调头子任务,可以勾选“调头后空驶回起点”</h5>'
  174 + date: '2017-04-24',
  175 + text: '<h5>应到实到时间按路牌连接显示</h5><h5>批量子任务时,如果主任务烂班,则自动复一个全程烂班子任务</h5><h5>鼠标悬停在子任务数字徽章上可查看详细</h5>'
176 176 };
177 177  
178 178 var storage = window.localStorage
... ...
src/main/resources/static/real_control_v2/main.html
... ... @@ -22,6 +22,8 @@
22 22 <link rel="stylesheet" href="/real_control_v2/css/home.css" merge="custom_style"/>
23 23 <!-- line style -->
24 24 <link rel="stylesheet" href="/real_control_v2/css/line_schedule.css" merge="custom_style"/>
  25 + <link rel="stylesheet" href="/real_control_v2/css/line_schedule_table.css" merge="custom_style"/>
  26 +
25 27 <link rel="stylesheet" href="/real_control_v2/css/sch_autocomp_result.css" merge="custom_style"/>
26 28 <!-- custom table -->
27 29 <link rel="stylesheet" href="/real_control_v2/css/ct_table.css" merge="custom_style"/>
... ... @@ -172,6 +174,7 @@
172 174 <script src="/real_control_v2/js/line_schedule/context_menu.js" merge="custom_js"></script>
173 175 <script src="/real_control_v2/js/line_schedule/dbclick.js" merge="custom_js"></script>
174 176 <script src="/real_control_v2/js/line_schedule/search.js" merge="custom_js"></script>
  177 +<script src="/real_control_v2/js/line_schedule/badge_tooltip.js" merge="custom_js"></script>
175 178  
176 179 <!-- 字典相关 -->
177 180 <script src="/assets/js/dictionary.js" merge="custom_js"></script>
... ...
src/test/resources/testdata/problem.txt 0 → 100644
  1 +1、时刻表明细导入,线路标准里所有的高峰低谷时间需要带入时刻表班次时间里,标准可以点击切换到线路标准界面
  2 +2、时刻表明细编辑功能,数据工具移到时刻表里,类似工具栏的样子
  3 +3、时刻表导入,可以选一个已经存在的时刻表导入,而不是excel文件
  4 +4、所有的删除,作废,都要有提示框操作
  5 +5、排班计划错误提示,如果选的排班日期之前没有排班,提示错误,排班结果有重复与时刻表不符合,显示错误
  6 +6、调度执行日报,显示最近排班日期,修改操作强化
  7 +7、警告功能,如时刻表选择相同的常规有效日,特殊有效日,车辆,人员配置重复等等
  8 +8、时刻表明细编辑,颜色覆盖冲突
  9 +9、下拉框貌似中文不能搜索
  10 +10、时刻表明细编辑,环线,选上下行,上下的站点在下行站点列表里
  11 +11、人员基础信息导入问题,工号前要加公司代码
0 12 \ No newline at end of file
... ...