Commit ce613b03e8ce7046bfe83a3885197fdd5b617f2c
Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
Showing
14 changed files
with
1053 additions
and
881 deletions
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -130,20 +130,25 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 130 | 130 | for (int i = 0; i < ylListBe.size(); i++) { |
| 131 | 131 | Ylb ylb=ylListBe.get(i); |
| 132 | 132 | if(map.get("clZbh").toString().equals(ylb.getNbbm())){ |
| 133 | - if(ylb.getJzyl()>0){ | |
| 134 | - t.setCzyl(ylb.getJzyl()); | |
| 135 | - fage=false; | |
| 136 | - break; | |
| 133 | + if(ylb.getJzyl()!=null){ | |
| 134 | + if(ylb.getJzyl()>0){ | |
| 135 | + t.setCzyl(ylb.getJzyl()); | |
| 136 | + fage=false; | |
| 137 | + break; | |
| 138 | + } | |
| 137 | 139 | } |
| 140 | + | |
| 138 | 141 | } |
| 139 | 142 | } |
| 140 | 143 | if(fage){ |
| 141 | 144 | for (int y = 0; y < clyList.size(); y++) { |
| 142 | 145 | Cyl cyl=clyList.get(y); |
| 143 | 146 | if(map.get("clZbh").toString().equals(cyl.getNbbm())){ |
| 144 | - t.setCzyl(cyl.getCyl()); | |
| 145 | - fage=false; | |
| 146 | - break; | |
| 147 | + if(cyl.getCyl()!=null){ | |
| 148 | + t.setCzyl(cyl.getCyl()); | |
| 149 | + fage=false; | |
| 150 | + break; | |
| 151 | + } | |
| 147 | 152 | } |
| 148 | 153 | } |
| 149 | 154 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -1378,13 +1378,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1378 | 1378 | map.put("addMileage", format.format(addMileage)); |
| 1379 | 1379 | map.put("yygl", format.format(yygl+addMileageYy)); |
| 1380 | 1380 | map.put("ksgl", format.format(ksgl)); |
| 1381 | - map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage)); | |
| 1381 | + map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileageYy)); | |
| 1382 | +// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage)); | |
| 1382 | 1383 | map.put("jhbc", jhbc); |
| 1383 | 1384 | map.put("cjbc", cjbc); |
| 1384 | 1385 | map.put("ljbc", ljbc); |
| 1385 | 1386 | map.put("sjbc", jhbc - cjbc + ljbc); |
| 1386 | 1387 | map.put("jcclc", jcclc); |
| 1387 | - map.put("zkslc", format.format(ksgl + jcclc+addMileageJc)); | |
| 1388 | + map.put("zkslc", format.format(ksgl + jcclc)); | |
| 1389 | +// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc)); | |
| 1388 | 1390 | return map; |
| 1389 | 1391 | } |
| 1390 | 1392 | ... | ... |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| ... | ... | @@ -15,6 +15,7 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; |
| 15 | 15 | import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; |
| 16 | 16 | import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; |
| 17 | 17 | import com.bsth.service.schedule.rules.strategy.IStrategy; |
| 18 | +import com.bsth.service.schedule.rules.ttinfo.LpInfoResults_output; | |
| 18 | 19 | import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input; |
| 19 | 20 | import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; |
| 20 | 21 | import com.bsth.service.schedule.rules.ttinfo.TTInfo_input; |
| ... | ... | @@ -156,6 +157,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 156 | 157 | ); |
| 157 | 158 | // 规则输出数据 |
| 158 | 159 | TTInfoResults_output ttInfoResults_output = new TTInfoResults_output(); |
| 160 | + LpInfoResults_output lpInfoResults_output = new LpInfoResults_output(); | |
| 159 | 161 | |
| 160 | 162 | // 1-2、构造drools session->载入数据->启动规则->计算->销毁session |
| 161 | 163 | // 创建session,内部配置的是stateful |
| ... | ... | @@ -163,8 +165,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 163 | 165 | |
| 164 | 166 | // 设置gloable对象,在drl中通过别名使用 |
| 165 | 167 | session.setGlobal("results", ttInfoResults_output); |
| 168 | + session.setGlobal("lpInfoResults_output", lpInfoResults_output); | |
| 166 | 169 | session.setGlobal("log", logger); // 设置日志 |
| 167 | 170 | |
| 171 | + session.setGlobal("tTInfoDetailService", ttInfoDetailService); | |
| 172 | + | |
| 168 | 173 | // 载入数据 |
| 169 | 174 | session.insert(ttInfoCalcuParam_input); |
| 170 | 175 | for (TTInfo ttInfo : ttInfos) { |
| ... | ... | @@ -225,18 +230,18 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 225 | 230 | |
| 226 | 231 | @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) |
| 227 | 232 | public SchedulePlan save2(SchedulePlan schedulePlan) { |
| 228 | - // 1、循环规则计算输出 | |
| 229 | - ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan); | |
| 233 | +// // 1、循环规则计算输出 | |
| 234 | +// ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan); | |
| 230 | 235 | // 2、时刻表选择 |
| 231 | 236 | TTInfoResults_output ttInfoResults_output = ttInfoOutput(schedulePlan); |
| 232 | - // 3、计划输出 | |
| 233 | - PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); | |
| 234 | - | |
| 235 | - schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos()); | |
| 236 | - schedulePlan.setTtInfoId("todo"); // TODO:待修正 | |
| 237 | - schedulePlan.setTtInfoNames("todo"); // TODO:待修正 | |
| 238 | - | |
| 239 | - super.save(schedulePlan); | |
| 237 | +// // 3、计划输出 | |
| 238 | +// PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); | |
| 239 | +// | |
| 240 | +// schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos()); | |
| 241 | +// schedulePlan.setTtInfoId("todo"); // TODO:待修正 | |
| 242 | +// schedulePlan.setTtInfoNames("todo"); // TODO:待修正 | |
| 243 | +// | |
| 244 | +// super.save(schedulePlan); | |
| 240 | 245 | |
| 241 | 246 | return new SchedulePlan(); |
| 242 | 247 | } | ... | ... |
src/main/java/com/bsth/service/schedule/rules/plan/PlanCalcuParam_input.java
| 1 | -package com.bsth.service.schedule.rules.plan; | |
| 2 | - | |
| 3 | -import com.bsth.entity.schedule.SchedulePlan; | |
| 4 | -import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; | |
| 5 | -import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * 排班规则-规则输入参数。 | |
| 9 | - */ | |
| 10 | -public class PlanCalcuParam_input { | |
| 11 | - /** 线路Id */ | |
| 12 | - private String xlId; | |
| 13 | - /** 计划主对象 */ | |
| 14 | - private SchedulePlan schedulePlan; | |
| 15 | - /** 循环规则输出 */ | |
| 16 | - private ScheduleResults_output scheduleResults_output; | |
| 17 | - /** 时刻表选择规则输出 */ | |
| 18 | - private TTInfoResults_output ttInfoResults_output; | |
| 19 | - | |
| 20 | - public PlanCalcuParam_input() { | |
| 21 | - } | |
| 22 | - public PlanCalcuParam_input( | |
| 23 | - SchedulePlan schedulePlan, | |
| 24 | - ScheduleResults_output scheduleResults_output, | |
| 25 | - TTInfoResults_output ttInfoResults_output) { | |
| 26 | - this.schedulePlan = schedulePlan; | |
| 27 | - this.xlId = String.valueOf(schedulePlan.getXl().getId()); | |
| 28 | - this.scheduleResults_output = scheduleResults_output; | |
| 29 | - this.ttInfoResults_output = ttInfoResults_output; | |
| 30 | - } | |
| 31 | - | |
| 32 | - public String getXlId() { | |
| 33 | - return xlId; | |
| 34 | - } | |
| 35 | - | |
| 36 | - public void setXlId(String xlId) { | |
| 37 | - this.xlId = xlId; | |
| 38 | - } | |
| 39 | - | |
| 40 | - public ScheduleResults_output getScheduleResults_output() { | |
| 41 | - return scheduleResults_output; | |
| 42 | - } | |
| 43 | - | |
| 44 | - public void setScheduleResults_output(ScheduleResults_output scheduleResults_output) { | |
| 45 | - this.scheduleResults_output = scheduleResults_output; | |
| 46 | - } | |
| 47 | - | |
| 48 | - public TTInfoResults_output getTtInfoResults_output() { | |
| 49 | - return ttInfoResults_output; | |
| 50 | - } | |
| 51 | - | |
| 52 | - public void setTtInfoResults_output(TTInfoResults_output ttInfoResults_output) { | |
| 53 | - this.ttInfoResults_output = ttInfoResults_output; | |
| 54 | - } | |
| 55 | - | |
| 56 | - public SchedulePlan getSchedulePlan() { | |
| 57 | - return schedulePlan; | |
| 58 | - } | |
| 59 | - | |
| 60 | - public void setSchedulePlan(SchedulePlan schedulePlan) { | |
| 61 | - this.schedulePlan = schedulePlan; | |
| 62 | - } | |
| 63 | -} | |
| 1 | +package com.bsth.service.schedule.rules.plan; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.SchedulePlan; | |
| 4 | +import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; | |
| 5 | +import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 排班规则-规则输入参数。 | |
| 9 | + */ | |
| 10 | +public class PlanCalcuParam_input { | |
| 11 | + /** 线路Id */ | |
| 12 | + private String xlId; | |
| 13 | + /** 计划主对象 */ | |
| 14 | + private SchedulePlan schedulePlan; | |
| 15 | + /** 循环规则输出 */ | |
| 16 | + private ScheduleResults_output scheduleResults_output; | |
| 17 | + /** 时刻表选择规则输出 */ | |
| 18 | + private TTInfoResults_output ttInfoResults_output; | |
| 19 | + | |
| 20 | + public PlanCalcuParam_input() { | |
| 21 | + } | |
| 22 | + public PlanCalcuParam_input( | |
| 23 | + SchedulePlan schedulePlan, | |
| 24 | + ScheduleResults_output scheduleResults_output, | |
| 25 | + TTInfoResults_output ttInfoResults_output) { | |
| 26 | + this.schedulePlan = schedulePlan; | |
| 27 | + this.xlId = String.valueOf(schedulePlan.getXl().getId()); | |
| 28 | + this.scheduleResults_output = scheduleResults_output; | |
| 29 | + this.ttInfoResults_output = ttInfoResults_output; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public String getXlId() { | |
| 33 | + return xlId; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setXlId(String xlId) { | |
| 37 | + this.xlId = xlId; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public ScheduleResults_output getScheduleResults_output() { | |
| 41 | + return scheduleResults_output; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setScheduleResults_output(ScheduleResults_output scheduleResults_output) { | |
| 45 | + this.scheduleResults_output = scheduleResults_output; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public TTInfoResults_output getTtInfoResults_output() { | |
| 49 | + return ttInfoResults_output; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setTtInfoResults_output(TTInfoResults_output ttInfoResults_output) { | |
| 53 | + this.ttInfoResults_output = ttInfoResults_output; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public SchedulePlan getSchedulePlan() { | |
| 57 | + return schedulePlan; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setSchedulePlan(SchedulePlan schedulePlan) { | |
| 61 | + this.schedulePlan = schedulePlan; | |
| 62 | + } | |
| 63 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/shiftloop/GidFbTimeFunction.java
| 1 | -package com.bsth.service.schedule.rules.shiftloop; | |
| 2 | - | |
| 3 | -import com.bsth.entity.schedule.TTInfoDetail; | |
| 4 | -import org.joda.time.LocalTime; | |
| 5 | -import org.joda.time.format.DateTimeFormat; | |
| 6 | -import org.kie.api.runtime.rule.AccumulateFunction; | |
| 7 | - | |
| 8 | -import java.io.*; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * 时刻表路牌下的分班时间(起始时间)。 | |
| 12 | - */ | |
| 13 | -public class GidFbTimeFunction implements AccumulateFunction { | |
| 14 | - @Override | |
| 15 | - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 16 | - } | |
| 17 | - | |
| 18 | - @Override | |
| 19 | - public void writeExternal(ObjectOutput out) throws IOException { | |
| 20 | - } | |
| 21 | - | |
| 22 | - protected static class GidFbTimeData implements Externalizable { | |
| 23 | - public LocalTime fbsj; | |
| 24 | - public String fbsj_str; | |
| 25 | - public TTInfoDetail ttInfoDetail; | |
| 26 | - | |
| 27 | - public GidFbTimeData() {} | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 31 | - fbsj_str = (String) in.readObject(); | |
| 32 | - ttInfoDetail = (TTInfoDetail) in.readObject(); | |
| 33 | - } | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void writeExternal(ObjectOutput out) throws IOException { | |
| 37 | - out.writeObject(fbsj_str); | |
| 38 | - out.writeObject(ttInfoDetail); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - | |
| 42 | - @Override | |
| 43 | - public Serializable createContext() { | |
| 44 | - return new GidFbTimeData(); | |
| 45 | - } | |
| 46 | - | |
| 47 | - @Override | |
| 48 | - public void init(Serializable context) throws Exception { | |
| 49 | - GidFbTimeData gidFbTimeData = (GidFbTimeData) context; | |
| 50 | - gidFbTimeData.fbsj_str = "NULL"; // 注意:因为空的时间也要规则执行,所以返回一个表示空的字符串 | |
| 51 | - } | |
| 52 | - | |
| 53 | - @Override | |
| 54 | - public void accumulate(Serializable context, Object value) { | |
| 55 | - GidFbTimeData gidFbTimeData = (GidFbTimeData) context; | |
| 56 | - TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 57 | - | |
| 58 | - // 1块路牌有多个分班班次,取最早的时间作为起始分班时间 | |
| 59 | - if (ttInfoDetail.getIsFB()) { | |
| 60 | - LocalTime localTime = LocalTime.parse(ttInfoDetail.getFcsj(), DateTimeFormat.forPattern("HH:mm")); | |
| 61 | - | |
| 62 | - if (gidFbTimeData.fbsj == null) { | |
| 63 | - gidFbTimeData.fbsj = localTime; | |
| 64 | - gidFbTimeData.fbsj_str = ttInfoDetail.getFcsj(); | |
| 65 | - } else if (localTime.isBefore(gidFbTimeData.fbsj)) { | |
| 66 | - gidFbTimeData.fbsj = localTime; | |
| 67 | - gidFbTimeData.fbsj_str = ttInfoDetail.getFcsj(); | |
| 68 | - } | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - @Override | |
| 73 | - public void reverse(Serializable serializable, Object o) throws Exception { | |
| 74 | - | |
| 75 | - } | |
| 76 | - | |
| 77 | - @Override | |
| 78 | - public boolean supportsReverse() { | |
| 79 | - return false; | |
| 80 | - } | |
| 81 | - | |
| 82 | - @Override | |
| 83 | - public Class<?> getResultType() { | |
| 84 | - return String.class; | |
| 85 | - } | |
| 86 | - | |
| 87 | - @Override | |
| 88 | - public Object getResult(Serializable context) throws Exception { | |
| 89 | - GidFbTimeData gidFbTimeData = (GidFbTimeData) context; | |
| 90 | - return gidFbTimeData.fbsj_str; | |
| 91 | - } | |
| 92 | -} | |
| 1 | +package com.bsth.service.schedule.rules.shiftloop; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 4 | +import org.joda.time.LocalTime; | |
| 5 | +import org.joda.time.format.DateTimeFormat; | |
| 6 | +import org.kie.api.runtime.rule.AccumulateFunction; | |
| 7 | + | |
| 8 | +import java.io.*; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 时刻表路牌下的分班时间(起始时间)。 | |
| 12 | + */ | |
| 13 | +public class GidFbTimeFunction implements AccumulateFunction { | |
| 14 | + @Override | |
| 15 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 16 | + } | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 20 | + } | |
| 21 | + | |
| 22 | + protected static class GidFbTimeData implements Externalizable { | |
| 23 | + public LocalTime fbsj; | |
| 24 | + public String fbsj_str; | |
| 25 | + public TTInfoDetail ttInfoDetail; | |
| 26 | + | |
| 27 | + public GidFbTimeData() {} | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 31 | + fbsj_str = (String) in.readObject(); | |
| 32 | + ttInfoDetail = (TTInfoDetail) in.readObject(); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 37 | + out.writeObject(fbsj_str); | |
| 38 | + out.writeObject(ttInfoDetail); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public Serializable createContext() { | |
| 44 | + return new GidFbTimeData(); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + public void init(Serializable context) throws Exception { | |
| 49 | + GidFbTimeData gidFbTimeData = (GidFbTimeData) context; | |
| 50 | + gidFbTimeData.fbsj_str = "NULL"; // 注意:因为空的时间也要规则执行,所以返回一个表示空的字符串 | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + public void accumulate(Serializable context, Object value) { | |
| 55 | + GidFbTimeData gidFbTimeData = (GidFbTimeData) context; | |
| 56 | + TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 57 | + | |
| 58 | + // 1块路牌有多个分班班次,取最早的时间作为起始分班时间 | |
| 59 | + if (ttInfoDetail.getIsFB()) { | |
| 60 | + LocalTime localTime = LocalTime.parse(ttInfoDetail.getFcsj(), DateTimeFormat.forPattern("HH:mm")); | |
| 61 | + | |
| 62 | + if (gidFbTimeData.fbsj == null) { | |
| 63 | + gidFbTimeData.fbsj = localTime; | |
| 64 | + gidFbTimeData.fbsj_str = ttInfoDetail.getFcsj(); | |
| 65 | + } else if (localTime.isBefore(gidFbTimeData.fbsj)) { | |
| 66 | + gidFbTimeData.fbsj = localTime; | |
| 67 | + gidFbTimeData.fbsj_str = ttInfoDetail.getFcsj(); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public void reverse(Serializable serializable, Object o) throws Exception { | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public boolean supportsReverse() { | |
| 79 | + return false; | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public Class<?> getResultType() { | |
| 84 | + return String.class; | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public Object getResult(Serializable context) throws Exception { | |
| 89 | + GidFbTimeData gidFbTimeData = (GidFbTimeData) context; | |
| 90 | + return gidFbTimeData.fbsj_str; | |
| 91 | + } | |
| 92 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/shiftloop/GidsCountFunction.java
| 1 | -package com.bsth.service.schedule.rules.shiftloop; | |
| 2 | - | |
| 3 | -import com.bsth.entity.schedule.TTInfoDetail; | |
| 4 | -import org.kie.api.runtime.rule.AccumulateFunction; | |
| 5 | - | |
| 6 | -import java.io.*; | |
| 7 | -import java.util.ArrayList; | |
| 8 | -import java.util.HashSet; | |
| 9 | -import java.util.List; | |
| 10 | -import java.util.Set; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 计算时刻表里的路爬列表。 | |
| 14 | - */ | |
| 15 | -public class GidsCountFunction implements AccumulateFunction { | |
| 16 | - @Override | |
| 17 | - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 18 | - } | |
| 19 | - | |
| 20 | - @Override | |
| 21 | - public void writeExternal(ObjectOutput out) throws IOException { | |
| 22 | - } | |
| 23 | - | |
| 24 | - protected static class GidsCountData implements Externalizable { | |
| 25 | - public List<String> gids = new ArrayList<>(); | |
| 26 | - public Set<String> gids_temp = new HashSet<>(); | |
| 27 | - public TTInfoDetail ttInfoDetail; | |
| 28 | - | |
| 29 | - public GidsCountData() {} | |
| 30 | - | |
| 31 | - @Override | |
| 32 | - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 33 | - gids = (List<String>) in.readObject(); | |
| 34 | - ttInfoDetail = (TTInfoDetail) in.readObject(); | |
| 35 | - } | |
| 36 | - | |
| 37 | - @Override | |
| 38 | - public void writeExternal(ObjectOutput out) throws IOException { | |
| 39 | - out.writeObject(gids); | |
| 40 | - out.writeObject(ttInfoDetail); | |
| 41 | - } | |
| 42 | - } | |
| 43 | - | |
| 44 | - @Override | |
| 45 | - public Serializable createContext() { | |
| 46 | - return new GidsCountData(); | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - public void init(Serializable context) throws Exception { | |
| 51 | - GidsCountData gidsCountData = (GidsCountData) context; | |
| 52 | - gidsCountData.gids = new ArrayList<>(); | |
| 53 | - gidsCountData.gids_temp = new HashSet<>(); | |
| 54 | - } | |
| 55 | - | |
| 56 | - @Override | |
| 57 | - public void accumulate(Serializable context, Object value) { | |
| 58 | - GidsCountData gidsCountData = (GidsCountData) context; | |
| 59 | - TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 60 | - | |
| 61 | - if (ttInfoDetail.getLp() != null) { | |
| 62 | - gidsCountData.gids_temp.add( | |
| 63 | - String.valueOf(ttInfoDetail.getLp().getId())); | |
| 64 | - gidsCountData.gids.clear(); | |
| 65 | - gidsCountData.gids.addAll(gidsCountData.gids_temp); | |
| 66 | - } | |
| 67 | - | |
| 68 | - // TODO:以后还需要按照路牌排序 | |
| 69 | - } | |
| 70 | - | |
| 71 | - @Override | |
| 72 | - public void reverse(Serializable serializable, Object o) throws Exception { | |
| 73 | - | |
| 74 | - } | |
| 75 | - | |
| 76 | - @Override | |
| 77 | - public boolean supportsReverse() { | |
| 78 | - return false; | |
| 79 | - } | |
| 80 | - | |
| 81 | - @Override | |
| 82 | - public Object getResult(Serializable context) throws Exception { | |
| 83 | - GidsCountData gidsCountData = (GidsCountData) context; | |
| 84 | - return gidsCountData.gids; | |
| 85 | - | |
| 86 | - } | |
| 87 | - | |
| 88 | - @Override | |
| 89 | - public Class<?> getResultType() { | |
| 90 | - return List.class; | |
| 91 | - } | |
| 92 | -} | |
| 1 | +package com.bsth.service.schedule.rules.shiftloop; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 4 | +import org.kie.api.runtime.rule.AccumulateFunction; | |
| 5 | + | |
| 6 | +import java.io.*; | |
| 7 | +import java.util.ArrayList; | |
| 8 | +import java.util.HashSet; | |
| 9 | +import java.util.List; | |
| 10 | +import java.util.Set; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 计算时刻表里的路爬列表。 | |
| 14 | + */ | |
| 15 | +public class GidsCountFunction implements AccumulateFunction { | |
| 16 | + @Override | |
| 17 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 18 | + } | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 22 | + } | |
| 23 | + | |
| 24 | + protected static class GidsCountData implements Externalizable { | |
| 25 | + public List<String> gids = new ArrayList<>(); | |
| 26 | + public Set<String> gids_temp = new HashSet<>(); | |
| 27 | + public TTInfoDetail ttInfoDetail; | |
| 28 | + | |
| 29 | + public GidsCountData() {} | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 33 | + gids = (List<String>) in.readObject(); | |
| 34 | + ttInfoDetail = (TTInfoDetail) in.readObject(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 39 | + out.writeObject(gids); | |
| 40 | + out.writeObject(ttInfoDetail); | |
| 41 | + } | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public Serializable createContext() { | |
| 46 | + return new GidsCountData(); | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + public void init(Serializable context) throws Exception { | |
| 51 | + GidsCountData gidsCountData = (GidsCountData) context; | |
| 52 | + gidsCountData.gids = new ArrayList<>(); | |
| 53 | + gidsCountData.gids_temp = new HashSet<>(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public void accumulate(Serializable context, Object value) { | |
| 58 | + GidsCountData gidsCountData = (GidsCountData) context; | |
| 59 | + TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 60 | + | |
| 61 | + if (ttInfoDetail.getLp() != null) { | |
| 62 | + gidsCountData.gids_temp.add( | |
| 63 | + String.valueOf(ttInfoDetail.getLp().getId())); | |
| 64 | + gidsCountData.gids.clear(); | |
| 65 | + gidsCountData.gids.addAll(gidsCountData.gids_temp); | |
| 66 | + } | |
| 67 | + | |
| 68 | + // TODO:以后还需要按照路牌排序 | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public void reverse(Serializable serializable, Object o) throws Exception { | |
| 73 | + | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public boolean supportsReverse() { | |
| 78 | + return false; | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public Object getResult(Serializable context) throws Exception { | |
| 83 | + GidsCountData gidsCountData = (GidsCountData) context; | |
| 84 | + return gidsCountData.gids; | |
| 85 | + | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public Class<?> getResultType() { | |
| 90 | + return List.class; | |
| 91 | + } | |
| 92 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResult_output.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules.ttinfo; | |
| 2 | + | |
| 3 | +import org.joda.time.DateTime; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 每日路爬信息。 | |
| 7 | + */ | |
| 8 | +public class LpInfoResult_output { | |
| 9 | + /** 具体日期 */ | |
| 10 | + private DateTime dateTime; | |
| 11 | + /** 路牌Id */ | |
| 12 | + private String lpId; | |
| 13 | + /** 线路Id */ | |
| 14 | + private String xlId; | |
| 15 | + /** 时刻表Id */ | |
| 16 | + private String ttInfoId; | |
| 17 | + | |
| 18 | + public DateTime getDateTime() { | |
| 19 | + return dateTime; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setDateTime(DateTime dateTime) { | |
| 23 | + this.dateTime = dateTime; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public String getLpId() { | |
| 27 | + return lpId; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setLpId(String lpId) { | |
| 31 | + this.lpId = lpId; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public String getXlId() { | |
| 35 | + return xlId; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setXlId(String xlId) { | |
| 39 | + this.xlId = xlId; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public String getTtInfoId() { | |
| 43 | + return ttInfoId; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setTtInfoId(String ttInfoId) { | |
| 47 | + this.ttInfoId = ttInfoId; | |
| 48 | + } | |
| 49 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResultsFunction.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules.ttinfo; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 4 | +import org.kie.api.runtime.rule.AccumulateFunction; | |
| 5 | + | |
| 6 | +import java.io.*; | |
| 7 | +import java.util.ArrayList; | |
| 8 | +import java.util.HashMap; | |
| 9 | +import java.util.List; | |
| 10 | +import java.util.Map; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 路牌信息统计函数。 | |
| 14 | + */ | |
| 15 | +public class LpInfoResultsFunction implements AccumulateFunction { | |
| 16 | + @Override | |
| 17 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 18 | + | |
| 19 | + } | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 23 | + | |
| 24 | + } | |
| 25 | + | |
| 26 | + protected static class LpInfoResultsData implements Externalizable { | |
| 27 | + public List<LpInfoResult_output> lpInfoResult_outputs = new ArrayList<>(); | |
| 28 | + public Map<Long, LpInfoResult_output> lpInfoResult_outputMap = new HashMap<>(); | |
| 29 | + public TTInfoDetail ttInfoDetail; | |
| 30 | + | |
| 31 | + public LpInfoResultsData() {} | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 35 | + out.writeObject(lpInfoResult_outputs); | |
| 36 | + out.writeObject(ttInfoDetail); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 41 | + lpInfoResult_outputs = (List<LpInfoResult_output>) in.readObject(); | |
| 42 | + ttInfoDetail = (TTInfoDetail) in.readObject(); | |
| 43 | + } | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public Serializable createContext() { | |
| 48 | + return new LpInfoResultsData(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void init(Serializable context) throws Exception { | |
| 53 | + LpInfoResultsData lpInfoResultsData = (LpInfoResultsData) context; | |
| 54 | + lpInfoResultsData.lpInfoResult_outputs = new ArrayList<>(); | |
| 55 | + lpInfoResultsData.lpInfoResult_outputMap = new HashMap<>(); | |
| 56 | + } | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public void accumulate(Serializable context, Object value) { | |
| 60 | + LpInfoResultsData lpInfoResultsData = (LpInfoResultsData) context; | |
| 61 | + TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 62 | + | |
| 63 | + if (ttInfoDetail.getLp() != null) { | |
| 64 | + if (lpInfoResultsData.lpInfoResult_outputMap.get(ttInfoDetail.getLp().getId()) == null) { | |
| 65 | + LpInfoResult_output lpInfoResult_output = new LpInfoResult_output(); | |
| 66 | + lpInfoResult_output.setLpId(String.valueOf(ttInfoDetail.getLp().getId())); | |
| 67 | + lpInfoResult_output.setXlId(String.valueOf(ttInfoDetail.getXl().getId())); | |
| 68 | + lpInfoResult_output.setTtInfoId(String.valueOf(ttInfoDetail.getTtinfo().getId())); | |
| 69 | + | |
| 70 | + lpInfoResultsData.lpInfoResult_outputMap.put( | |
| 71 | + ttInfoDetail.getLp().getId(), | |
| 72 | + lpInfoResult_output); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + lpInfoResultsData.lpInfoResult_outputs.clear(); | |
| 77 | + lpInfoResultsData.lpInfoResult_outputs.addAll( | |
| 78 | + lpInfoResultsData.lpInfoResult_outputMap.values()); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public boolean supportsReverse() { | |
| 83 | + return true; | |
| 84 | + } | |
| 85 | + | |
| 86 | + @Override | |
| 87 | + public void reverse(Serializable context, Object value) throws Exception { | |
| 88 | + LpInfoResultsData lpInfoResultsData = (LpInfoResultsData) context; | |
| 89 | + TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 90 | + | |
| 91 | + lpInfoResultsData.lpInfoResult_outputMap.remove(ttInfoDetail.getLp().getId()); | |
| 92 | + | |
| 93 | + lpInfoResultsData.lpInfoResult_outputs.clear(); | |
| 94 | + lpInfoResultsData.lpInfoResult_outputs.addAll( | |
| 95 | + lpInfoResultsData.lpInfoResult_outputMap.values()); | |
| 96 | + | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Override | |
| 100 | + public Object getResult(Serializable context) throws Exception { | |
| 101 | + LpInfoResultsData lpInfoResultsData = (LpInfoResultsData) context; | |
| 102 | + return lpInfoResultsData.lpInfoResult_outputs; | |
| 103 | + } | |
| 104 | + | |
| 105 | + @Override | |
| 106 | + public Class<?> getResultType() { | |
| 107 | + return List.class; | |
| 108 | + } | |
| 109 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResults_output.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules.ttinfo; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * Created by xu on 17/3/21. | |
| 8 | + */ | |
| 9 | +public class LpInfoResults_output { | |
| 10 | + | |
| 11 | + private List<LpInfoResult_output> lpInfoResult_outputs = new ArrayList<>(); | |
| 12 | + | |
| 13 | + public List<LpInfoResult_output> getLpInfoResult_outputs() { | |
| 14 | + return lpInfoResult_outputs; | |
| 15 | + } | |
| 16 | + | |
| 17 | + public void setLpInfoResult_outputs(List<LpInfoResult_output> lpInfoResult_outputs) { | |
| 18 | + this.lpInfoResult_outputs = lpInfoResult_outputs; | |
| 19 | + } | |
| 20 | +} | ... | ... |
src/main/resources/rules/functions.drl
| ... | ... | @@ -2,4 +2,5 @@ package com.bsth.service.schedule; |
| 2 | 2 | |
| 3 | 3 | import accumulate com.bsth.service.schedule.rules.ttinfo2.ErrorBcCountFunction ecount; |
| 4 | 4 | import accumulate com.bsth.service.schedule.rules.shiftloop.GidsCountFunction gidscount; |
| 5 | -import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime; | |
| 6 | 5 | \ No newline at end of file |
| 6 | +import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime; | |
| 7 | +import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult; | |
| 7 | 8 | \ No newline at end of file | ... | ... |
src/main/resources/rules/plan.drl
| 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.service.schedule.TTInfoService; | |
| 10 | -import com.bsth.service.schedule.TTInfoDetailService; | |
| 11 | -import com.bsth.service.schedule.CarConfigInfoService; | |
| 12 | -import com.bsth.service.schedule.EmployeeConfigInfoService; | |
| 13 | -import com.bsth.service.LineService; | |
| 14 | -import com.bsth.service.BusinessService; | |
| 15 | - | |
| 16 | -import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; | |
| 17 | -import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; | |
| 18 | -import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output; | |
| 19 | -import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; | |
| 20 | -import com.bsth.entity.Line; | |
| 21 | -import com.bsth.entity.Business; | |
| 22 | - | |
| 23 | -import com.bsth.entity.schedule.CarConfigInfo; | |
| 24 | -import com.bsth.entity.schedule.EmployeeConfigInfo; | |
| 25 | -import com.bsth.entity.schedule.TTInfo; | |
| 26 | -import com.bsth.entity.schedule.TTInfoDetail; | |
| 27 | -import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 28 | - | |
| 29 | -import org.slf4j.Logger | |
| 30 | -import org.joda.time.format.DateTimeFormat | |
| 31 | -import org.apache.commons.lang3.StringUtils; | |
| 32 | - | |
| 33 | - | |
| 34 | -// 全局日志类(一般使用调用此规则的service类) | |
| 35 | -global Logger log; | |
| 36 | -global TTInfoDetailService tTInfoDetailService; | |
| 37 | -global TTInfoService tTInfoService; | |
| 38 | -global CarConfigInfoService carConfigInfoService; | |
| 39 | -global EmployeeConfigInfoService employeeConfigInfoService; | |
| 40 | -global LineService lineService; | |
| 41 | -global BusinessService businessService; | |
| 42 | - | |
| 43 | -// 输出 | |
| 44 | -global PlanResult planResult; | |
| 45 | - | |
| 46 | -function Map ttidParams(String ttid) { | |
| 47 | - Map param = new HashMap(); | |
| 48 | - param.put("ttinfo.id_eq", Long.parseLong(ttid)); | |
| 49 | - return param; | |
| 50 | -} | |
| 51 | - | |
| 52 | -function Map xlidParams(String xlid) { | |
| 53 | - Map param = new HashMap(); | |
| 54 | - param.put("xl.id_eq", Integer.valueOf(xlid)); | |
| 55 | - return param; | |
| 56 | -} | |
| 57 | - | |
| 58 | -function List ecList(EmployeeConfigInfoService service, String ecids) { | |
| 59 | - List<String> ids = Arrays.asList(ecids.split("-")); | |
| 60 | - List rst = new ArrayList(); | |
| 61 | - for (int i = 0; i < ids.size(); i++) { | |
| 62 | - rst.add(service.findById(Long.parseLong(ids.get(i)))); | |
| 63 | - } | |
| 64 | - return rst; | |
| 65 | -} | |
| 66 | - | |
| 67 | -function LocalTime fcsjTime(String fcsj) { | |
| 68 | - if ("NULL".equals(fcsj)) { | |
| 69 | - return null; | |
| 70 | - } | |
| 71 | - return LocalTime.parse(fcsj, DateTimeFormat.forPattern("HH:mm")); | |
| 72 | -} | |
| 73 | - | |
| 74 | -function String ttInfoId_sd(Map map, DateTime sd) { | |
| 75 | - TTInfoResult_output ttInfoResult_output = (TTInfoResult_output) map.get(sd); | |
| 76 | - return ttInfoResult_output.getTtInfoId(); | |
| 77 | -} | |
| 78 | - | |
| 79 | -/* | |
| 80 | - 规则说明: | |
| 81 | - 根据循环规则输出,时刻表选择规则输出,组合计算排班明细 | |
| 82 | -*/ | |
| 83 | - | |
| 84 | -//-------------------- 第一阶段、计算迭代数据 -----------------// | |
| 85 | -declare Loop_result | |
| 86 | - xlId: String // 线路id | |
| 87 | - | |
| 88 | - ruleLoop: List // 每天分配的规则 List<ScheduleResult_output> | |
| 89 | - | |
| 90 | - ttInfoMapLoop_temp: Map // 每天分配的时刻表 Map<DataTime, Collection<TTInfoResult_output>> | |
| 91 | - ttInfoMapLoop: Map // 每天分配的时刻表 Map<DataTime, TTInfoResult_output> | |
| 92 | - ttInfoMap: Map // 总共用到的时刻表 Map<id, TTInfoResult_output> | |
| 93 | -end | |
| 94 | - | |
| 95 | -rule "calcu_step1_Loop_result" | |
| 96 | - salience 1000 | |
| 97 | - when | |
| 98 | - $param: PlanCalcuParam_input($xlId: xlId) | |
| 99 | - then | |
| 100 | - Loop_result loop_result = new Loop_result(); | |
| 101 | - loop_result.setXlId($xlId); | |
| 102 | - loop_result.setRuleLoop($param.getScheduleResults_output().getResults()); | |
| 103 | - | |
| 104 | - loop_result.setTtInfoMapLoop(new HashMap()); | |
| 105 | - loop_result.setTtInfoMap(new HashMap()); | |
| 106 | - | |
| 107 | - com.google.common.collect.Multimap ttInfoMap_temp = | |
| 108 | - (com.google.common.collect.Multimap) | |
| 109 | - $param.getTtInfoResults_output().getResults().get( | |
| 110 | - String.valueOf($xlId)); | |
| 111 | - | |
| 112 | - loop_result.setTtInfoMapLoop_temp(ttInfoMap_temp.asMap()); | |
| 113 | - | |
| 114 | - insert(loop_result); | |
| 115 | - | |
| 116 | - log.info("calcu_step1_Loop_result"); | |
| 117 | -end | |
| 118 | - | |
| 119 | -rule "calcu_step2_loop_result" | |
| 120 | - salience 1000 | |
| 121 | - no-loop | |
| 122 | - when | |
| 123 | - $param: PlanCalcuParam_input($xlId: xlId) | |
| 124 | - $lr: Loop_result(xlId == $xlId) | |
| 125 | - $sd: DateTime() from $lr.ttInfoMapLoop_temp.keySet() | |
| 126 | - then | |
| 127 | - // 当天时刻表只取第一张 TODO: | |
| 128 | - Collection col = (Collection) $lr.getTtInfoMapLoop_temp().get($sd); | |
| 129 | - Iterator iter = col.iterator(); | |
| 130 | - TTInfoResult_output ttInfo_result = (TTInfoResult_output) iter.next(); | |
| 131 | - $lr.getTtInfoMapLoop().put($sd, ttInfo_result); | |
| 132 | - | |
| 133 | - // 总共使用的时刻表 | |
| 134 | - $lr.getTtInfoMap().put(ttInfo_result.getTtInfoId(), ttInfo_result); | |
| 135 | - | |
| 136 | - update($lr); | |
| 137 | -end | |
| 138 | - | |
| 139 | -//-------------------- 第二阶段、将时刻表班次,车辆配置,人员配置信息载入 -----------------// | |
| 140 | - | |
| 141 | -//--------------- 车辆配置信息载入 -------------// | |
| 142 | -declare CarConfig_Wrap | |
| 143 | - id: String // 车辆配置id(cast字符串-方便比较) | |
| 144 | - | |
| 145 | - self: CarConfigInfo // 原始数据 | |
| 146 | -end | |
| 147 | - | |
| 148 | -rule "calcu_CarConfig_Wrap" | |
| 149 | - salience 800 | |
| 150 | - when | |
| 151 | - $lr: Loop_result($xlId: xlId) | |
| 152 | - $ccf: CarConfigInfo() from carConfigInfoService.list(xlidParams($xlId)) | |
| 153 | - then | |
| 154 | - CarConfig_Wrap carConfig_wrap = new CarConfig_Wrap(); | |
| 155 | - carConfig_wrap.setId(String.valueOf($ccf.getId())); | |
| 156 | - carConfig_wrap.setSelf($ccf); | |
| 157 | - | |
| 158 | - insert(carConfig_wrap); | |
| 159 | -end | |
| 160 | - | |
| 161 | -//--------------- 人员配置信息载入 --------------// | |
| 162 | -declare EmployeeConfig_Wrap | |
| 163 | - id: String // 人员配置id(cast字符串-方便比较) | |
| 164 | - | |
| 165 | - self: EmployeeConfigInfo // 原始数据 | |
| 166 | -end | |
| 167 | - | |
| 168 | -rule "calcu_EmployeeConfig_Wrap" | |
| 169 | - salience 800 | |
| 170 | - when | |
| 171 | - $lr: Loop_result($xlId: xlId) | |
| 172 | - $eci: EmployeeConfigInfo() from employeeConfigInfoService.list(xlidParams($xlId)) | |
| 173 | - then | |
| 174 | - EmployeeConfig_Wrap employeeConfig_wrap = new EmployeeConfig_Wrap(); | |
| 175 | - employeeConfig_wrap.setId(String.valueOf($eci.getId())); | |
| 176 | - employeeConfig_wrap.setSelf($eci); | |
| 177 | - | |
| 178 | - insert(employeeConfig_wrap); | |
| 179 | -end | |
| 180 | - | |
| 181 | -//----------------- 时刻表班次信息载入 -----------------// | |
| 182 | -declare TTInfo_gid_stat | |
| 183 | - xlId: String // 线路id(cast字符串-方便比较) | |
| 184 | - ttInfoId: String // 时刻表id(cast字符串-方便比较) | |
| 185 | - gid: String // 路牌id(cast字符串-方便比较) | |
| 186 | - | |
| 187 | - maxFcno: Integer // 最大发车顺序号 | |
| 188 | - | |
| 189 | - fbTime: LocalTime // 分班时间 | |
| 190 | -end | |
| 191 | - | |
| 192 | -rule "calcu_TTInfo_gid_stat" | |
| 193 | - salience 800 | |
| 194 | - when | |
| 195 | - $lr: Loop_result($xlId: xlId) | |
| 196 | - $ttInfoId: String() from $lr.getTtInfoMap().keySet() | |
| 197 | - $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttInfoId)), gidscount($ttd)) | |
| 198 | - $gid: String() from $gids | |
| 199 | - $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)), gidfbtime($ttd)) | |
| 200 | - $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)), max($ttd.getFcno())) | |
| 201 | - then | |
| 202 | - TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat(); | |
| 203 | - ttInfo_gid_stat.setXlId($xlId); | |
| 204 | - ttInfo_gid_stat.setTtInfoId($ttInfoId); | |
| 205 | - ttInfo_gid_stat.setGid($gid); | |
| 206 | - | |
| 207 | - ttInfo_gid_stat.setMaxFcno($maxfcno.intValue()); | |
| 208 | - ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str)); | |
| 209 | - | |
| 210 | - insert(ttInfo_gid_stat); | |
| 211 | - | |
| 212 | - log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}", | |
| 213 | - $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime()); | |
| 214 | - | |
| 215 | -end | |
| 216 | - | |
| 217 | -declare TTInfoDetail_Wrap | |
| 218 | - xlId: String // 线路id(cast字符串-方便比较) | |
| 219 | - ttInfoId: String // 时刻表id(cast字符串-方便比较) | |
| 220 | - gid: String // 路牌id(cast字符串-方便比较) | |
| 221 | - | |
| 222 | - isFirstBc: Boolean = false // 是否是当前路牌的第一个班次 | |
| 223 | - isLastBc: Boolean = false // 是否是当前路牌的最后一个班次 | |
| 224 | - isFb: Boolean = false // 是否分班 | |
| 225 | - | |
| 226 | - self: TTInfoDetail // 原始数据 | |
| 227 | -end | |
| 228 | - | |
| 229 | -rule "calcu_TTInfoDetail_Wrap" | |
| 230 | - salience 800 | |
| 231 | - when | |
| 232 | - $lr: Loop_result($xlId: xlId) | |
| 233 | - $ttInfoId: String() from $lr.getTtInfoMap().keySet() | |
| 234 | - $ttInfoStat: TTInfo_gid_stat( | |
| 235 | - ttInfoId == $ttInfoId, | |
| 236 | - $gid: gid, $maxFcno: maxFcno) | |
| 237 | - $ttInfoDetail: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)) | |
| 238 | - then | |
| 239 | - TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap(); | |
| 240 | - ttInfoDetail_wrap.setXlId($xlId); | |
| 241 | - ttInfoDetail_wrap.setTtInfoId($ttInfoId); | |
| 242 | - ttInfoDetail_wrap.setGid($gid); | |
| 243 | - ttInfoDetail_wrap.setIsFirstBc(1 == $ttInfoDetail.getFcno()); | |
| 244 | - ttInfoDetail_wrap.setIsLastBc($maxFcno == $ttInfoDetail.getFcno()); | |
| 245 | - | |
| 246 | - LocalTime fcsj = fcsjTime($ttInfoDetail.getFcsj()); | |
| 247 | - LocalTime fbsj = $ttInfoStat.getFbTime(); | |
| 248 | - ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj))); | |
| 249 | - | |
| 250 | - ttInfoDetail_wrap.setSelf($ttInfoDetail); | |
| 251 | - | |
| 252 | - insert(ttInfoDetail_wrap); | |
| 253 | - | |
| 254 | - log.info("xlid={},ttid={},gid={},isFirstBc={},isLastBc={},isFb={},fcsj={}", | |
| 255 | - $xlId, $ttInfoId, $gid, | |
| 256 | - ttInfoDetail_wrap.getIsFirstBc(), | |
| 257 | - ttInfoDetail_wrap.getIsLastBc(), | |
| 258 | - ttInfoDetail_wrap.getIsFb(), | |
| 259 | - $ttInfoDetail.getFcsj()); | |
| 260 | -end | |
| 261 | - | |
| 262 | -//-------------------- 第三阶段、合并计算SchedulePlanInfo -----------------// | |
| 263 | - | |
| 264 | -rule "Calcu_SchedulePlanInfo" | |
| 265 | - salience 600 | |
| 266 | - when | |
| 267 | - $param: PlanCalcuParam_input($xlId: xlId) | |
| 268 | - $lr: Loop_result(xlId == $xlId) | |
| 269 | - $sro: ScheduleResult_output($sd: sd, $gid: guideboardId) from $lr.getRuleLoop() | |
| 270 | - CarConfig_Wrap(id == $sro.carConfigId, $cc: self) | |
| 271 | - TTInfoDetail_Wrap( | |
| 272 | - ttInfoId == ttInfoId_sd($lr.getTtInfoMapLoop(), $sd), | |
| 273 | - gid == $gid, | |
| 274 | - $isFb: isFb, $isFirstBc: isFirstBc, $isLastBc: isLastBc, | |
| 275 | - $ttInfoDetail: self | |
| 276 | - ) | |
| 277 | - then | |
| 278 | - // 线路 | |
| 279 | - Line xl = lineService.findById(Integer.valueOf($xlId)); | |
| 280 | - | |
| 281 | - SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo( | |
| 282 | - xl, | |
| 283 | - $sro, | |
| 284 | - $ttInfoDetail, | |
| 285 | - $isFb, | |
| 286 | - $cc, | |
| 287 | - ecList(employeeConfigInfoService, $sro.getEmployeeConfigId()), | |
| 288 | - $param.getSchedulePlan(), | |
| 289 | - $isFirstBc, | |
| 290 | - $isLastBc | |
| 291 | - ); | |
| 292 | - | |
| 293 | - // 获取公司,分公司信息 | |
| 294 | - String gsbm = xl.getCompany(); | |
| 295 | - String fgsbm = xl.getBrancheCompany(); | |
| 296 | - Business gs = null; | |
| 297 | - Business fgs = null; | |
| 298 | - | |
| 299 | - Map<String, Object> param = new HashMap<>(); | |
| 300 | - | |
| 301 | - if (StringUtils.isNotEmpty(gsbm)) { | |
| 302 | - param.clear(); | |
| 303 | - param.put("businessCode_eq", gsbm); | |
| 304 | - Iterator<Business> businessIterator = businessService.list(param).iterator(); | |
| 305 | - if (businessIterator.hasNext()) { | |
| 306 | - gs = businessIterator.next(); | |
| 307 | - } | |
| 308 | - } | |
| 309 | - if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) { | |
| 310 | - param.clear();; | |
| 311 | - param.put("upCode_eq", gsbm); | |
| 312 | - param.put("businessCode_eq", fgsbm); | |
| 313 | - Iterator<Business> businessIterator = businessService.list(param).iterator(); | |
| 314 | - if (businessIterator.hasNext()) { | |
| 315 | - fgs = businessIterator.next(); | |
| 316 | - } | |
| 317 | - } | |
| 318 | - | |
| 319 | - if (gs != null) { | |
| 320 | - schedulePlanInfo.setGsBm(gs.getBusinessCode()); | |
| 321 | - schedulePlanInfo.setGsName(gs.getBusinessName()); | |
| 322 | - } | |
| 323 | - if (fgs != null) { | |
| 324 | - schedulePlanInfo.setFgsBm(fgs.getBusinessCode()); | |
| 325 | - schedulePlanInfo.setFgsName(fgs.getBusinessName()); | |
| 326 | - } | |
| 327 | - | |
| 328 | - // 操作人,操作时间 | |
| 329 | - schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy()); | |
| 330 | - schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate()); | |
| 331 | - schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy()); | |
| 332 | - schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate()); | |
| 333 | - | |
| 334 | - // TODO: | |
| 335 | - $param.getSchedulePlan().setTtInfo($ttInfoDetail.getTtinfo()); | |
| 336 | - | |
| 337 | - // result 输出 | |
| 338 | - planResult.getSchedulePlanInfos().add(schedulePlanInfo); | |
| 339 | - | |
| 340 | - log.info("gid={},ecid={},ttInfoId={}", | |
| 341 | - $gid, ecList(employeeConfigInfoService, $sro.getEmployeeConfigId()), | |
| 342 | - ttInfoId_sd($lr.getTtInfoMapLoop(), $sd)); | |
| 343 | - | |
| 344 | -end | |
| 345 | - | |
| 346 | - | |
| 347 | - | |
| 348 | - | |
| 349 | - | |
| 350 | - | |
| 351 | - | |
| 352 | - | |
| 353 | - | |
| 354 | - | |
| 355 | - | |
| 356 | - | |
| 357 | - | |
| 358 | - | |
| 359 | - | |
| 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.service.schedule.TTInfoService; | |
| 10 | +import com.bsth.service.schedule.TTInfoDetailService; | |
| 11 | +import com.bsth.service.schedule.CarConfigInfoService; | |
| 12 | +import com.bsth.service.schedule.EmployeeConfigInfoService; | |
| 13 | +import com.bsth.service.LineService; | |
| 14 | +import com.bsth.service.BusinessService; | |
| 15 | + | |
| 16 | +import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; | |
| 17 | +import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; | |
| 18 | +import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output; | |
| 19 | +import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; | |
| 20 | +import com.bsth.entity.Line; | |
| 21 | +import com.bsth.entity.Business; | |
| 22 | + | |
| 23 | +import com.bsth.entity.schedule.CarConfigInfo; | |
| 24 | +import com.bsth.entity.schedule.EmployeeConfigInfo; | |
| 25 | +import com.bsth.entity.schedule.TTInfo; | |
| 26 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 27 | +import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 28 | + | |
| 29 | +import org.slf4j.Logger | |
| 30 | +import org.joda.time.format.DateTimeFormat | |
| 31 | +import org.apache.commons.lang3.StringUtils; | |
| 32 | + | |
| 33 | + | |
| 34 | +// 全局日志类(一般使用调用此规则的service类) | |
| 35 | +global Logger log; | |
| 36 | +global TTInfoDetailService tTInfoDetailService; | |
| 37 | +global TTInfoService tTInfoService; | |
| 38 | +global CarConfigInfoService carConfigInfoService; | |
| 39 | +global EmployeeConfigInfoService employeeConfigInfoService; | |
| 40 | +global LineService lineService; | |
| 41 | +global BusinessService businessService; | |
| 42 | + | |
| 43 | +// 输出 | |
| 44 | +global PlanResult planResult; | |
| 45 | + | |
| 46 | +function Map ttidParams(String ttid) { | |
| 47 | + Map param = new HashMap(); | |
| 48 | + param.put("ttinfo.id_eq", Long.parseLong(ttid)); | |
| 49 | + return param; | |
| 50 | +} | |
| 51 | + | |
| 52 | +function Map xlidParams(String xlid) { | |
| 53 | + Map param = new HashMap(); | |
| 54 | + param.put("xl.id_eq", Integer.valueOf(xlid)); | |
| 55 | + return param; | |
| 56 | +} | |
| 57 | + | |
| 58 | +function List ecList(EmployeeConfigInfoService service, String ecids) { | |
| 59 | + List<String> ids = Arrays.asList(ecids.split("-")); | |
| 60 | + List rst = new ArrayList(); | |
| 61 | + for (int i = 0; i < ids.size(); i++) { | |
| 62 | + rst.add(service.findById(Long.parseLong(ids.get(i)))); | |
| 63 | + } | |
| 64 | + return rst; | |
| 65 | +} | |
| 66 | + | |
| 67 | +function LocalTime fcsjTime(String fcsj) { | |
| 68 | + if ("NULL".equals(fcsj)) { | |
| 69 | + return null; | |
| 70 | + } | |
| 71 | + return LocalTime.parse(fcsj, DateTimeFormat.forPattern("HH:mm")); | |
| 72 | +} | |
| 73 | + | |
| 74 | +function String ttInfoId_sd(Map map, DateTime sd) { | |
| 75 | + TTInfoResult_output ttInfoResult_output = (TTInfoResult_output) map.get(sd); | |
| 76 | + return ttInfoResult_output.getTtInfoId(); | |
| 77 | +} | |
| 78 | + | |
| 79 | +/* | |
| 80 | + 规则说明: | |
| 81 | + 根据循环规则输出,时刻表选择规则输出,组合计算排班明细 | |
| 82 | +*/ | |
| 83 | + | |
| 84 | +//-------------------- 第一阶段、计算迭代数据 -----------------// | |
| 85 | +declare Loop_result | |
| 86 | + xlId: String // 线路id | |
| 87 | + | |
| 88 | + ruleLoop: List // 每天分配的规则 List<ScheduleResult_output> | |
| 89 | + | |
| 90 | + ttInfoMapLoop_temp: Map // 每天分配的时刻表 Map<DataTime, Collection<TTInfoResult_output>> | |
| 91 | + ttInfoMapLoop: Map // 每天分配的时刻表 Map<DataTime, TTInfoResult_output> | |
| 92 | + ttInfoMap: Map // 总共用到的时刻表 Map<id, TTInfoResult_output> | |
| 93 | +end | |
| 94 | + | |
| 95 | +rule "calcu_step1_Loop_result" | |
| 96 | + salience 1000 | |
| 97 | + when | |
| 98 | + $param: PlanCalcuParam_input($xlId: xlId) | |
| 99 | + then | |
| 100 | + Loop_result loop_result = new Loop_result(); | |
| 101 | + loop_result.setXlId($xlId); | |
| 102 | + loop_result.setRuleLoop($param.getScheduleResults_output().getResults()); | |
| 103 | + | |
| 104 | + loop_result.setTtInfoMapLoop(new HashMap()); | |
| 105 | + loop_result.setTtInfoMap(new HashMap()); | |
| 106 | + | |
| 107 | + com.google.common.collect.Multimap ttInfoMap_temp = | |
| 108 | + (com.google.common.collect.Multimap) | |
| 109 | + $param.getTtInfoResults_output().getResults().get( | |
| 110 | + String.valueOf($xlId)); | |
| 111 | + | |
| 112 | + loop_result.setTtInfoMapLoop_temp(ttInfoMap_temp.asMap()); | |
| 113 | + | |
| 114 | + insert(loop_result); | |
| 115 | + | |
| 116 | + log.info("calcu_step1_Loop_result"); | |
| 117 | +end | |
| 118 | + | |
| 119 | +rule "calcu_step2_loop_result" | |
| 120 | + salience 1000 | |
| 121 | + no-loop | |
| 122 | + when | |
| 123 | + $param: PlanCalcuParam_input($xlId: xlId) | |
| 124 | + $lr: Loop_result(xlId == $xlId) | |
| 125 | + $sd: DateTime() from $lr.ttInfoMapLoop_temp.keySet() | |
| 126 | + then | |
| 127 | + // 当天时刻表只取第一张 TODO: | |
| 128 | + Collection col = (Collection) $lr.getTtInfoMapLoop_temp().get($sd); | |
| 129 | + Iterator iter = col.iterator(); | |
| 130 | + TTInfoResult_output ttInfo_result = (TTInfoResult_output) iter.next(); | |
| 131 | + $lr.getTtInfoMapLoop().put($sd, ttInfo_result); | |
| 132 | + | |
| 133 | + // 总共使用的时刻表 | |
| 134 | + $lr.getTtInfoMap().put(ttInfo_result.getTtInfoId(), ttInfo_result); | |
| 135 | + | |
| 136 | + update($lr); | |
| 137 | +end | |
| 138 | + | |
| 139 | +//-------------------- 第二阶段、将时刻表班次,车辆配置,人员配置信息载入 -----------------// | |
| 140 | + | |
| 141 | +//--------------- 车辆配置信息载入 -------------// | |
| 142 | +declare CarConfig_Wrap | |
| 143 | + id: String // 车辆配置id(cast字符串-方便比较) | |
| 144 | + | |
| 145 | + self: CarConfigInfo // 原始数据 | |
| 146 | +end | |
| 147 | + | |
| 148 | +rule "calcu_CarConfig_Wrap" | |
| 149 | + salience 800 | |
| 150 | + when | |
| 151 | + $lr: Loop_result($xlId: xlId) | |
| 152 | + $ccf: CarConfigInfo() from carConfigInfoService.list(xlidParams($xlId)) | |
| 153 | + then | |
| 154 | + CarConfig_Wrap carConfig_wrap = new CarConfig_Wrap(); | |
| 155 | + carConfig_wrap.setId(String.valueOf($ccf.getId())); | |
| 156 | + carConfig_wrap.setSelf($ccf); | |
| 157 | + | |
| 158 | + insert(carConfig_wrap); | |
| 159 | +end | |
| 160 | + | |
| 161 | +//--------------- 人员配置信息载入 --------------// | |
| 162 | +declare EmployeeConfig_Wrap | |
| 163 | + id: String // 人员配置id(cast字符串-方便比较) | |
| 164 | + | |
| 165 | + self: EmployeeConfigInfo // 原始数据 | |
| 166 | +end | |
| 167 | + | |
| 168 | +rule "calcu_EmployeeConfig_Wrap" | |
| 169 | + salience 800 | |
| 170 | + when | |
| 171 | + $lr: Loop_result($xlId: xlId) | |
| 172 | + $eci: EmployeeConfigInfo() from employeeConfigInfoService.list(xlidParams($xlId)) | |
| 173 | + then | |
| 174 | + EmployeeConfig_Wrap employeeConfig_wrap = new EmployeeConfig_Wrap(); | |
| 175 | + employeeConfig_wrap.setId(String.valueOf($eci.getId())); | |
| 176 | + employeeConfig_wrap.setSelf($eci); | |
| 177 | + | |
| 178 | + insert(employeeConfig_wrap); | |
| 179 | +end | |
| 180 | + | |
| 181 | +//----------------- 时刻表班次信息载入 -----------------// | |
| 182 | +declare TTInfo_gid_stat | |
| 183 | + xlId: String // 线路id(cast字符串-方便比较) | |
| 184 | + ttInfoId: String // 时刻表id(cast字符串-方便比较) | |
| 185 | + gid: String // 路牌id(cast字符串-方便比较) | |
| 186 | + | |
| 187 | + maxFcno: Integer // 最大发车顺序号 | |
| 188 | + | |
| 189 | + fbTime: LocalTime // 分班时间 | |
| 190 | +end | |
| 191 | + | |
| 192 | +rule "calcu_TTInfo_gid_stat" | |
| 193 | + salience 800 | |
| 194 | + when | |
| 195 | + $lr: Loop_result($xlId: xlId) | |
| 196 | + $ttInfoId: String() from $lr.getTtInfoMap().keySet() | |
| 197 | + $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttInfoId)), gidscount($ttd)) | |
| 198 | + $gid: String() from $gids | |
| 199 | + $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)), gidfbtime($ttd)) | |
| 200 | + $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)), max($ttd.getFcno())) | |
| 201 | + then | |
| 202 | + TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat(); | |
| 203 | + ttInfo_gid_stat.setXlId($xlId); | |
| 204 | + ttInfo_gid_stat.setTtInfoId($ttInfoId); | |
| 205 | + ttInfo_gid_stat.setGid($gid); | |
| 206 | + | |
| 207 | + ttInfo_gid_stat.setMaxFcno($maxfcno.intValue()); | |
| 208 | + ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str)); | |
| 209 | + | |
| 210 | + insert(ttInfo_gid_stat); | |
| 211 | + | |
| 212 | + log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}", | |
| 213 | + $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime()); | |
| 214 | + | |
| 215 | +end | |
| 216 | + | |
| 217 | +declare TTInfoDetail_Wrap | |
| 218 | + xlId: String // 线路id(cast字符串-方便比较) | |
| 219 | + ttInfoId: String // 时刻表id(cast字符串-方便比较) | |
| 220 | + gid: String // 路牌id(cast字符串-方便比较) | |
| 221 | + | |
| 222 | + isFirstBc: Boolean = false // 是否是当前路牌的第一个班次 | |
| 223 | + isLastBc: Boolean = false // 是否是当前路牌的最后一个班次 | |
| 224 | + isFb: Boolean = false // 是否分班 | |
| 225 | + | |
| 226 | + self: TTInfoDetail // 原始数据 | |
| 227 | +end | |
| 228 | + | |
| 229 | +rule "calcu_TTInfoDetail_Wrap" | |
| 230 | + salience 800 | |
| 231 | + when | |
| 232 | + $lr: Loop_result($xlId: xlId) | |
| 233 | + $ttInfoId: String() from $lr.getTtInfoMap().keySet() | |
| 234 | + $ttInfoStat: TTInfo_gid_stat( | |
| 235 | + ttInfoId == $ttInfoId, | |
| 236 | + $gid: gid, $maxFcno: maxFcno) | |
| 237 | + $ttInfoDetail: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)) | |
| 238 | + then | |
| 239 | + TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap(); | |
| 240 | + ttInfoDetail_wrap.setXlId($xlId); | |
| 241 | + ttInfoDetail_wrap.setTtInfoId($ttInfoId); | |
| 242 | + ttInfoDetail_wrap.setGid($gid); | |
| 243 | + ttInfoDetail_wrap.setIsFirstBc(1 == $ttInfoDetail.getFcno()); | |
| 244 | + ttInfoDetail_wrap.setIsLastBc($maxFcno == $ttInfoDetail.getFcno()); | |
| 245 | + | |
| 246 | + LocalTime fcsj = fcsjTime($ttInfoDetail.getFcsj()); | |
| 247 | + LocalTime fbsj = $ttInfoStat.getFbTime(); | |
| 248 | + ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj))); | |
| 249 | + | |
| 250 | + ttInfoDetail_wrap.setSelf($ttInfoDetail); | |
| 251 | + | |
| 252 | + insert(ttInfoDetail_wrap); | |
| 253 | + | |
| 254 | + log.info("xlid={},ttid={},gid={},isFirstBc={},isLastBc={},isFb={},fcsj={}", | |
| 255 | + $xlId, $ttInfoId, $gid, | |
| 256 | + ttInfoDetail_wrap.getIsFirstBc(), | |
| 257 | + ttInfoDetail_wrap.getIsLastBc(), | |
| 258 | + ttInfoDetail_wrap.getIsFb(), | |
| 259 | + $ttInfoDetail.getFcsj()); | |
| 260 | +end | |
| 261 | + | |
| 262 | +//-------------------- 第三阶段、合并计算SchedulePlanInfo -----------------// | |
| 263 | + | |
| 264 | +rule "Calcu_SchedulePlanInfo" | |
| 265 | + salience 600 | |
| 266 | + when | |
| 267 | + $param: PlanCalcuParam_input($xlId: xlId) | |
| 268 | + $lr: Loop_result(xlId == $xlId) | |
| 269 | + $sro: ScheduleResult_output($sd: sd, $gid: guideboardId) from $lr.getRuleLoop() | |
| 270 | + CarConfig_Wrap(id == $sro.carConfigId, $cc: self) | |
| 271 | + TTInfoDetail_Wrap( | |
| 272 | + ttInfoId == ttInfoId_sd($lr.getTtInfoMapLoop(), $sd), | |
| 273 | + gid == $gid, | |
| 274 | + $isFb: isFb, $isFirstBc: isFirstBc, $isLastBc: isLastBc, | |
| 275 | + $ttInfoDetail: self | |
| 276 | + ) | |
| 277 | + then | |
| 278 | + // 线路 | |
| 279 | + Line xl = lineService.findById(Integer.valueOf($xlId)); | |
| 280 | + | |
| 281 | + SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo( | |
| 282 | + xl, | |
| 283 | + $sro, | |
| 284 | + $ttInfoDetail, | |
| 285 | + $isFb, | |
| 286 | + $cc, | |
| 287 | + ecList(employeeConfigInfoService, $sro.getEmployeeConfigId()), | |
| 288 | + $param.getSchedulePlan(), | |
| 289 | + $isFirstBc, | |
| 290 | + $isLastBc | |
| 291 | + ); | |
| 292 | + | |
| 293 | + // 获取公司,分公司信息 | |
| 294 | + String gsbm = xl.getCompany(); | |
| 295 | + String fgsbm = xl.getBrancheCompany(); | |
| 296 | + Business gs = null; | |
| 297 | + Business fgs = null; | |
| 298 | + | |
| 299 | + Map<String, Object> param = new HashMap<>(); | |
| 300 | + | |
| 301 | + if (StringUtils.isNotEmpty(gsbm)) { | |
| 302 | + param.clear(); | |
| 303 | + param.put("businessCode_eq", gsbm); | |
| 304 | + Iterator<Business> businessIterator = businessService.list(param).iterator(); | |
| 305 | + if (businessIterator.hasNext()) { | |
| 306 | + gs = businessIterator.next(); | |
| 307 | + } | |
| 308 | + } | |
| 309 | + if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) { | |
| 310 | + param.clear();; | |
| 311 | + param.put("upCode_eq", gsbm); | |
| 312 | + param.put("businessCode_eq", fgsbm); | |
| 313 | + Iterator<Business> businessIterator = businessService.list(param).iterator(); | |
| 314 | + if (businessIterator.hasNext()) { | |
| 315 | + fgs = businessIterator.next(); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + | |
| 319 | + if (gs != null) { | |
| 320 | + schedulePlanInfo.setGsBm(gs.getBusinessCode()); | |
| 321 | + schedulePlanInfo.setGsName(gs.getBusinessName()); | |
| 322 | + } | |
| 323 | + if (fgs != null) { | |
| 324 | + schedulePlanInfo.setFgsBm(fgs.getBusinessCode()); | |
| 325 | + schedulePlanInfo.setFgsName(fgs.getBusinessName()); | |
| 326 | + } | |
| 327 | + | |
| 328 | + // 操作人,操作时间 | |
| 329 | + schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy()); | |
| 330 | + schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate()); | |
| 331 | + schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy()); | |
| 332 | + schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate()); | |
| 333 | + | |
| 334 | + // TODO: | |
| 335 | + $param.getSchedulePlan().setTtInfo($ttInfoDetail.getTtinfo()); | |
| 336 | + | |
| 337 | + // result 输出 | |
| 338 | + planResult.getSchedulePlanInfos().add(schedulePlanInfo); | |
| 339 | + | |
| 340 | + log.info("gid={},ecid={},ttInfoId={}", | |
| 341 | + $gid, ecList(employeeConfigInfoService, $sro.getEmployeeConfigId()), | |
| 342 | + ttInfoId_sd($lr.getTtInfoMapLoop(), $sd)); | |
| 343 | + | |
| 344 | +end | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | ... | ... |
src/main/resources/rules/ttinfo.drl
| ... | ... | @@ -7,13 +7,31 @@ import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input; |
| 7 | 7 | import com.bsth.service.schedule.rules.ttinfo.TTInfo_input; |
| 8 | 8 | import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output; |
| 9 | 9 | import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; |
| 10 | +import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output; | |
| 11 | +import com.bsth.service.schedule.rules.ttinfo.LpInfoResults_output; | |
| 10 | 12 | |
| 11 | -import org.slf4j.Logger; | |
| 13 | +import com.bsth.service.schedule.TTInfoDetailService; | |
| 14 | + | |
| 15 | +import com.bsth.entity.schedule.TTInfo; | |
| 16 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 17 | + | |
| 18 | +import org.slf4j.Logger | |
| 12 | 19 | |
| 13 | 20 | // 全局日志 |
| 14 | 21 | global Logger log; |
| 22 | +// service | |
| 23 | +global TTInfoDetailService tTInfoDetailService; | |
| 15 | 24 | // return输出 |
| 16 | 25 | global TTInfoResults_output results |
| 26 | +global LpInfoResults_output lpInfoResults_output | |
| 27 | + | |
| 28 | +function Map ttidParams(List ttinfolist) { | |
| 29 | + // 获取第一张时刻表id | |
| 30 | + TTInfo_input ttInfo_input = (TTInfo_input) ttinfolist.get(0); | |
| 31 | + Map param = new HashMap(); | |
| 32 | + param.put("ttinfo.id_eq", Long.parseLong(ttInfo_input.getTtInfoId())); | |
| 33 | + return param; | |
| 34 | +} | |
| 17 | 35 | |
| 18 | 36 | |
| 19 | 37 | /* |
| ... | ... | @@ -91,6 +109,7 @@ rule "calcu_ttinfo_special_day" // 特殊日期匹配 |
| 91 | 109 | $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list) |
| 92 | 110 | $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day) |
| 93 | 111 | $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays contains $calcu_date) from $ttInfo_input_list) |
| 112 | + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd)) | |
| 94 | 113 | then |
| 95 | 114 | // 更新Calcu_days_result对象 |
| 96 | 115 | int new_calcu_day = $calcu_day + 1; |
| ... | ... | @@ -105,6 +124,13 @@ rule "calcu_ttinfo_special_day" // 特殊日期匹配 |
| 105 | 124 | Collections.sort($ttinfolist); |
| 106 | 125 | results.addXlTTInfos($xlId, $calcu_date, $ttinfolist); |
| 107 | 126 | |
| 127 | + // lp输出 | |
| 128 | + for (int i = 0; i < $lpInfoResults.size(); i++) { | |
| 129 | + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i); | |
| 130 | + lpInfoResult_output.setDateTime($calcu_date); // 设定时间 | |
| 131 | + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output); | |
| 132 | + } | |
| 133 | + | |
| 108 | 134 | update($calcu_days_result); |
| 109 | 135 | end |
| 110 | 136 | |
| ... | ... | @@ -114,6 +140,7 @@ rule "calcu_ttinfo_normal_day" // 平日匹配 |
| 114 | 140 | $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list) |
| 115 | 141 | $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday) |
| 116 | 142 | $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == true) from $ttInfo_input_list) |
| 143 | + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd)) | |
| 117 | 144 | then |
| 118 | 145 | // 更新Calcu_days_result对象 |
| 119 | 146 | int new_calcu_day = $calcu_day + 1; |
| ... | ... | @@ -122,12 +149,19 @@ rule "calcu_ttinfo_normal_day" // 平日匹配 |
| 122 | 149 | $calcu_days_result.setCalcu_date(new_calcu_date); |
| 123 | 150 | $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek()); |
| 124 | 151 | |
| 125 | - log.info("启用常规日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday); | |
| 152 | + log.info("启用常规日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={} 路牌size={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday, $lpInfoResults.size()); | |
| 126 | 153 | |
| 127 | 154 | // $ttinfolist按时间倒排序,result输出 |
| 128 | 155 | Collections.sort($ttinfolist); |
| 129 | 156 | results.addXlTTInfos($xlId, $calcu_date, $ttinfolist); |
| 130 | 157 | |
| 158 | + // lp输出 | |
| 159 | + for (int i = 0; i < $lpInfoResults.size(); i++) { | |
| 160 | + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i); | |
| 161 | + lpInfoResult_output.setDateTime($calcu_date); // 设定时间 | |
| 162 | + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output); | |
| 163 | + } | |
| 164 | + | |
| 131 | 165 | update($calcu_days_result); |
| 132 | 166 | end |
| 133 | 167 | |
| ... | ... | @@ -137,6 +171,7 @@ rule "calcu_ttinfo_other_day" // 都没有的情况下,匹配 |
| 137 | 171 | $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list) |
| 138 | 172 | $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday) |
| 139 | 173 | $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == false) from $ttInfo_input_list) |
| 174 | + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd)) | |
| 140 | 175 | then |
| 141 | 176 | // 更新Calcu_days_result对象 |
| 142 | 177 | int new_calcu_day = $calcu_day + 1; |
| ... | ... | @@ -151,6 +186,13 @@ rule "calcu_ttinfo_other_day" // 都没有的情况下,匹配 |
| 151 | 186 | Collections.sort($ttinfolist); |
| 152 | 187 | results.addXlTTInfos($xlId, $calcu_date, $ttinfolist); |
| 153 | 188 | |
| 189 | + // lp输出 | |
| 190 | + for (int i = 0; i < $lpInfoResults.size(); i++) { | |
| 191 | + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i); | |
| 192 | + lpInfoResult_output.setDateTime($calcu_date); // 设定时间 | |
| 193 | + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output); | |
| 194 | + } | |
| 195 | + | |
| 154 | 196 | update($calcu_days_result); |
| 155 | 197 | |
| 156 | 198 | end |
| 157 | 199 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/forms/statement/waybill.html
src/main/resources/static/pages/forms/statement/waybillBf.html
| ... | ... | @@ -22,90 +22,48 @@ |
| 22 | 22 | </div> |
| 23 | 23 | </div> |
| 24 | 24 | |
| 25 | - | |
| 26 | 25 | <div class="row"> |
| 27 | - | |
| 28 | 26 | <div class="col-md-12"> |
| 29 | - | |
| 30 | 27 | <div class="portlet light porttlet-fit bordered"> |
| 31 | - | |
| 32 | 28 | <div class="portlet-title"> |
| 33 | - | |
| 34 | 29 | <form class="form-inline" action=""> |
| 35 | - | |
| 36 | 30 | <div style="display: inline-block;"> |
| 37 | - | |
| 38 | 31 | <span class="item-label" style="width: 80px;">线路: </span> |
| 39 | 32 | <select class="form-control" name="line" id="line" style="width: 180px;"></select> |
| 40 | - | |
| 41 | 33 | </div> |
| 42 | - | |
| 43 | 34 | <div style="display: inline-block;margin-left: 15px;"> |
| 44 | - | |
| 45 | 35 | <span class="item-label" style="width: 80px;">时间: </span> |
| 46 | - | |
| 47 | 36 | <input class="form-control" type="text" id="date" style="width: 180px;"/> |
| 48 | - | |
| 49 | 37 | </div> |
| 50 | - | |
| 51 | 38 | <div class="form-group" style="display: inline-block;margin-left: 15px;"> |
| 52 | - | |
| 53 | 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 54 | - | |
| 55 | 40 | <input class="btn btn-default" type="button" id="export" value="导出"/> |
| 56 | - | |
| 57 | 41 | <input class="btn btn-default" type="button" id="print" value="打印"/> |
| 58 | - | |
| 59 | 42 | <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> |
| 60 | - | |
| 61 | 43 | </div> |
| 62 | - | |
| 63 | 44 | </form> |
| 64 | - | |
| 65 | 45 | </div> |
| 66 | - | |
| 67 | 46 | <div class="portlet-body"> |
| 68 | - | |
| 69 | 47 | <div class="row"> |
| 70 | - | |
| 71 | 48 | <div class="col-md-3"> |
| 72 | - | |
| 73 | 49 | <div class="" style="margin-top: 10px;overflow:auto;height: 860px"> |
| 74 | - | |
| 75 | 50 | <table class="table table-bordered table-hover table-checkable pre-scrollable" id="info"> |
| 76 | - | |
| 77 | 51 | <thead> |
| 78 | - | |
| 79 | 52 | <tr class="hidden"> |
| 80 | - | |
| 81 | - <th>人员</th> | |
| 82 | - | |
| 83 | - <th>自编号</th> | |
| 84 | - | |
| 85 | - <th>路牌</th> | |
| 86 | - | |
| 53 | + <th class="rypx" style="cursor:pointer ">人员</th> | |
| 54 | + <th class="zbhpx" style="cursor:pointer ">自编号</th> | |
| 55 | + <th class="lppx" style="cursor:pointer ">路牌</th> | |
| 87 | 56 | </tr> |
| 88 | - | |
| 89 | 57 | </thead> |
| 90 | - | |
| 91 | 58 | <tbody> |
| 92 | - | |
| 93 | 59 | |
| 94 | - | |
| 95 | 60 | </tbody> |
| 96 | - | |
| 97 | 61 | </table> |
| 98 | - | |
| 99 | 62 | </div> |
| 100 | - | |
| 101 | 63 | </div> |
| 102 | - | |
| 103 | 64 | <div class="col-md-9" id="printArea"> |
| 104 | - | |
| 105 | 65 | <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> |
| 106 | - | |
| 107 | 66 | <table class="table table-bordered table-checkable" id="forms"> |
| 108 | - | |
| 109 | 67 | <tbody class="ludan_1"> |
| 110 | 68 | |
| 111 | 69 | </tbody> |
| ... | ... | @@ -118,45 +76,46 @@ |
| 118 | 76 | <tbody class="ludan_4"> |
| 119 | 77 | |
| 120 | 78 | </tbody> |
| 121 | - | |
| 122 | 79 | </table> |
| 123 | - | |
| 124 | 80 | </div> |
| 125 | - | |
| 126 | 81 | </div> |
| 127 | - | |
| 128 | 82 | </div> |
| 129 | - | |
| 130 | 83 | </div> |
| 131 | - | |
| 132 | 84 | </div> |
| 133 | - | |
| 134 | 85 | </div> |
| 135 | - | |
| 136 | 86 | </div> |
| 137 | 87 | |
| 138 | - | |
| 139 | - | |
| 140 | 88 | <script> |
| 141 | - | |
| 142 | 89 | $(function(){ |
| 143 | - | |
| 144 | 90 | // 关闭左侧栏 |
| 145 | - | |
| 146 | 91 | if (!$('body').hasClass('page-sidebar-closed')) |
| 147 | - | |
| 148 | 92 | $('.menu-toggler.sidebar-toggler').click(); |
| 149 | 93 | |
| 150 | - | |
| 151 | 94 | $("#date").datetimepicker({ |
| 152 | - | |
| 153 | 95 | format : 'YYYY-MM-DD', |
| 154 | - | |
| 155 | 96 | locale : 'zh-cn' |
| 156 | - | |
| 157 | 97 | }); |
| 98 | + | |
| 99 | + var d = new Date(); | |
| 100 | + var year = d.getFullYear(); | |
| 101 | + var month = d.getMonth() + 1; | |
| 102 | + var day = d.getDate(); | |
| 103 | + if(month < 10) | |
| 104 | + month = "0" + month; | |
| 105 | + if(day < 10) | |
| 106 | + day = "0" + day; | |
| 107 | + $("#date").val(year + "-" + month + "-" + day); | |
| 108 | + $.get('/basic/lineCode2Name',function(result){ | |
| 109 | + var data=[]; | |
| 110 | + | |
| 111 | + for(var code in result){ | |
| 112 | + data.push({id: code, text: result[code]}); | |
| 113 | + } | |
| 114 | + initPinYinSelect2('#line',data,''); | |
| 115 | + | |
| 116 | + }) | |
| 158 | 117 | |
| 159 | - $('#line').select2({ | |
| 118 | + /* $('#line').select2({ | |
| 160 | 119 | ajax: { |
| 161 | 120 | url: '/realSchedule/findLine', |
| 162 | 121 | type: 'post', |
| ... | ... | @@ -194,80 +153,163 @@ |
| 194 | 153 | } |
| 195 | 154 | } |
| 196 | 155 | }); |
| 156 | + */ | |
| 197 | 157 | |
| 198 | 158 | var date = ''; |
| 199 | - | |
| 159 | + var line =''; | |
| 200 | 160 | $("#query").on("click",function(){ |
| 201 | - | |
| 202 | - var line = $("#line").val(); | |
| 203 | - | |
| 161 | + line = $("#line").val(); | |
| 204 | 162 | date = $("#date").val(); |
| 205 | 163 | $(".hidden").removeClass("hidden"); |
| 206 | - | |
| 207 | - $get('/realSchedule/queryUserInfo',{line:line,date:date},function(result){ | |
| 208 | - | |
| 164 | + $get('/realSchedule/queryUserInfo',{line:line,date:date,state:2},function(result){ | |
| 209 | 165 | // 把数据填充到模版中 |
| 210 | - | |
| 211 | 166 | var tbodyHtml = template('list_info',{list:result}); |
| 212 | - | |
| 213 | 167 | // 把渲染好的模版html文本追加到表格中 |
| 214 | - | |
| 215 | 168 | $('#info tbody').html(tbodyHtml); |
| 216 | - | |
| 217 | 169 | }); |
| 218 | - | |
| 219 | 170 | }); |
| 171 | + var type="desc"; | |
| 172 | + $(".rypx").on("click",function(){ | |
| 173 | + line = $("#line").val(); | |
| 174 | + date = $("#date").val(); | |
| 175 | + $(".hidden").removeClass("hidden"); | |
| 176 | + $get('/realSchedule/queryUserInfoPx',{line:line,date:date,state:"j_Gh",type:type},function(result){ | |
| 177 | + if(type=="desc"){ | |
| 178 | + type ="asc"; | |
| 179 | + }else{ | |
| 180 | + type ="desc"; | |
| 181 | + } | |
| 182 | + // 把数据填充到模版中 | |
| 183 | + var tbodyHtml = template('list_info_px',{list:result}); | |
| 184 | + // 把渲染好的模版html文本追加到表格中 | |
| 185 | + $('#info tbody').html(tbodyHtml); | |
| 186 | + }); | |
| 187 | + }) | |
| 188 | + | |
| 189 | + $(".zbhpx").on("click",function(){ | |
| 190 | + line = $("#line").val(); | |
| 191 | + date = $("#date").val(); | |
| 192 | + $(".hidden").removeClass("hidden"); | |
| 193 | + $get('/realSchedule/queryUserInfoPx',{line:line,date:date,state:"clZbh",type:type},function(result){ | |
| 194 | + if(type=="desc"){ | |
| 195 | + type ="asc"; | |
| 196 | + }else{ | |
| 197 | + type ="desc"; | |
| 198 | + } | |
| 199 | + // 把数据填充到模版中 | |
| 200 | + var tbodyHtml = template('list_info_px',{list:result}); | |
| 201 | + // 把渲染好的模版html文本追加到表格中 | |
| 202 | + $('#info tbody').html(tbodyHtml); | |
| 203 | + }); | |
| 204 | + }) | |
| 205 | + | |
| 206 | + $(".lppx").on("click",function(){ | |
| 207 | + line = $("#line").val(); | |
| 208 | + date = $("#date").val(); | |
| 209 | + $(".hidden").removeClass("hidden"); | |
| 210 | + $get('/realSchedule/queryUserInfoPx',{line:line,date:date,state:"lpName",type:type},function(result){ | |
| 211 | + if(type=="desc"){ | |
| 212 | + type ="asc"; | |
| 213 | + }else{ | |
| 214 | + type ="desc"; | |
| 215 | + } | |
| 216 | + // 把数据填充到模版中 | |
| 217 | + var tbodyHtml = template('list_info_px',{list:result}); | |
| 218 | + // 把渲染好的模版html文本追加到表格中 | |
| 219 | + $('#info tbody').html(tbodyHtml); | |
| 220 | + }); | |
| 221 | + }) | |
| 220 | 222 | |
| 221 | 223 | var params = new Array(); |
| 222 | 224 | var jName = ''; |
| 223 | - | |
| 224 | 225 | $("#info tbody").on("click","tr",function(){ |
| 225 | 226 | if($(this).children().size() < 2){ |
| 226 | 227 | return; |
| 227 | 228 | } |
| 228 | - | |
| 229 | 229 | |
| 230 | - | |
| 231 | 230 | $(this).children().each(function(index){ |
| 232 | - | |
| 233 | 231 | params[index] = $(this).text(); |
| 234 | - | |
| 235 | 232 | }); |
| 236 | 233 | jName = params[0].split("\\")[0]; |
| 237 | 234 | var id = $("#"+params[1]).val(); |
| 238 | - $get('/realSchedule/'+id,null,function(result){ | |
| 235 | + $get('/realSchedule/MapById',{id:id},function(result){ | |
| 239 | 236 | result.scheduleDate = moment(result.scheduleDate).format("YYYY/MM/DD"); |
| 240 | 237 | var ludan_1 = template('ludan_1',result); |
| 241 | - //var ludan_4 = template('ludan_4',result); | |
| 242 | 238 | // 把渲染好的模版html文本追加到表格中 |
| 243 | 239 | $('#forms .ludan_1').html(ludan_1); |
| 244 | - //$('#forms .ludan_4').html(ludan_4); | |
| 245 | 240 | }); |
| 246 | - | |
| 247 | - $post('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2],date:date},function(result){ | |
| 241 | + $get('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2],date:date,line:line},function(result){ | |
| 248 | 242 | getTime(result); |
| 249 | - | |
| 250 | 243 | var ludan_2 = template('ludan_2',{list:result}); |
| 251 | - | |
| 252 | 244 | // 把渲染好的模版html文本追加到表格中 |
| 253 | - | |
| 254 | 245 | $('#forms .ludan_2').html(ludan_2); |
| 255 | - | |
| 256 | 246 | }); |
| 257 | - $post('/realSchedule/findKMBC',{jName:jName,clZbh:params[1],lpName:params[2],date:date},function(result){ | |
| 247 | + $get('/realSchedule/findKMBC',{jName:jName,clZbh:params[1],lpName:params[2],date:date,line:line},function(result){ | |
| 248 | + | |
| 249 | + var gl=accAdd(result.ksgl,result.jcclc); | |
| 250 | + result.ljgl=gl; | |
| 251 | + | |
| 252 | + var ljjcc1=accAdd(result.ksgl,result.jcclc); | |
| 253 | + //临加进出场公里 | |
| 254 | + var ljjcc=numSubtr(result.zkslc,ljjcc1); | |
| 255 | + result.zlcgl=numSubtr(result.realMileage,ljjcc); | |
| 256 | + | |
| 258 | 257 | var ludan_3 = template('ludan_3',result); |
| 259 | 258 | $('#forms .ludan_3').html(ludan_3); |
| 260 | 259 | }); |
| 261 | 260 | |
| 262 | - | |
| 263 | 261 | }); |
| 264 | 262 | |
| 263 | + var accAdd = function (a, b) { | |
| 264 | + var c, d, e; | |
| 265 | + try { | |
| 266 | + c = a.toString().split(".")[1].length; | |
| 267 | + } catch (f) { | |
| 268 | + c = 0; | |
| 269 | + } | |
| 270 | + try { | |
| 271 | + d = b.toString().split(".")[1].length; | |
| 272 | + } catch (f) { | |
| 273 | + d = 0; | |
| 274 | + } | |
| 275 | + return e = Math.pow(10, Math.max(c, d)), (mul(a, e) + mul(b, e)) / e; | |
| 276 | + }; | |
| 277 | + | |
| 278 | + var numSubtr = function (a, b) { | |
| 279 | + var c, d, e; | |
| 280 | + try { | |
| 281 | + c = a.toString().split(".")[1].length; | |
| 282 | + } catch (f) { | |
| 283 | + c = 0; | |
| 284 | + } | |
| 285 | + try { | |
| 286 | + d = b.toString().split(".")[1].length; | |
| 287 | + } catch (f) { | |
| 288 | + d = 0; | |
| 289 | + } | |
| 290 | + return e = Math.pow(10, Math.max(c, d)), (a * e - b * e) / e; | |
| 291 | + }; | |
| 292 | + | |
| 293 | + function mul(a, b) { | |
| 294 | + var c = 0, | |
| 295 | + d = a.toString(), | |
| 296 | + e = b.toString(); | |
| 297 | + try { | |
| 298 | + c += d.split(".")[1].length; | |
| 299 | + } catch (f) { | |
| 300 | + } | |
| 301 | + try { | |
| 302 | + c += e.split(".")[1].length; | |
| 303 | + } catch (f) { | |
| 304 | + } | |
| 305 | + return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c); | |
| 306 | + } | |
| 265 | 307 | $("#export").on("click",function(){ |
| 266 | 308 | if(params.length < 1){ |
| 267 | 309 | return; |
| 268 | 310 | } |
| 269 | - $post('/realSchedule/exportWaybill',{jName:jName,clZbh:params[1],lpName:params[2],date:date},function(result){ | |
| 270 | - window.open("/downloadFile/download?fileName="+jName); | |
| 311 | + $get('/realSchedule/exportWaybill',{jName:jName,clZbh:params[1],lpName:params[2],date:date,line:line},function(result){ | |
| 312 | + window.open("/downloadFile/download?fileName="+date+"-"+jName+"-"+params[1]+"-"+params[2]+"-行车路单"); | |
| 271 | 313 | }); |
| 272 | 314 | }); |
| 273 | 315 | |
| ... | ... | @@ -276,9 +318,17 @@ |
| 276 | 318 | }); |
| 277 | 319 | |
| 278 | 320 | $("#exportMore").on("click",function(){ |
| 279 | - return; | |
| 280 | - $post('/realSchedule/exportWaybillMore',{date:date},function(result){ | |
| 281 | - window.open("/downloadFile/download?fileName="+jName); | |
| 321 | + if($("#info tbody tr td").length <= 1) | |
| 322 | + return; | |
| 323 | + var param = new Array(); | |
| 324 | + $("#info tbody tr").each(function(index){ | |
| 325 | + param[index] = new Array(); | |
| 326 | + $(this).children().each(function(i){ | |
| 327 | + param[index][i] = $(this).text().split("\\")[0]; | |
| 328 | + }); | |
| 329 | + }); | |
| 330 | + $post('/realSchedule/exportWaybillMore',{date:date,line:line,strs:JSON.stringify(param)},function(result){ | |
| 331 | + window.open("/downloadFile/downloadList?fileName="+result.fileName); | |
| 282 | 332 | }); |
| 283 | 333 | }); |
| 284 | 334 | |
| ... | ... | @@ -296,37 +346,35 @@ |
| 296 | 346 | } |
| 297 | 347 | }); |
| 298 | 348 | } |
| 299 | - | |
| 300 | 349 | }); |
| 301 | - | |
| 302 | 350 | </script> |
| 303 | - | |
| 304 | 351 | <script type="text/html" id="list_info"> |
| 305 | - | |
| 306 | 352 | {{each list as obj i}} |
| 307 | - | |
| 308 | 353 | <tr> |
| 309 | - | |
| 310 | 354 | <td width="45%">{{obj[4]}}\{{obj[1]}}</td> |
| 311 | - | |
| 312 | 355 | <td width="32%">{{obj[2]}}</td> |
| 313 | - | |
| 314 | 356 | <td width="23%">{{obj[3]}}<input type="hidden" id="{{obj[2]}}" value="{{obj[0]}}"></td> |
| 315 | - | |
| 316 | 357 | </tr> |
| 317 | - | |
| 318 | 358 | {{/each}} |
| 319 | - | |
| 320 | 359 | {{if list.length == 0}} |
| 321 | - | |
| 322 | 360 | <tr> |
| 323 | - | |
| 324 | 361 | <td colspan="3"><h6 class="muted">没有找到相关数据</h6></td> |
| 325 | - | |
| 326 | 362 | </tr> |
| 327 | - | |
| 328 | 363 | {{/if}} |
| 329 | - | |
| 364 | +</script> | |
| 365 | +<script type="text/html" id="list_info_px"> | |
| 366 | + {{each list as obj i}} | |
| 367 | + <tr> | |
| 368 | + <td width="45%">{{obj.jName}}\{{obj.jGh}}</td> | |
| 369 | + <td width="32%">{{obj.clZbh}}</td> | |
| 370 | + <td width="23%">{{obj.lpName}}<input type="hidden" id="{{obj.clZbh}}" value="{{obj.id}}"></td> | |
| 371 | + </tr> | |
| 372 | + {{/each}} | |
| 373 | + {{if list.length == 0}} | |
| 374 | + <tr> | |
| 375 | + <td colspan="3"><h6 class="muted">没有找到相关数据</h6></td> | |
| 376 | + </tr> | |
| 377 | + {{/if}} | |
| 330 | 378 | </script> |
| 331 | 379 | <script type="text/html" id="ludan_1"> |
| 332 | 380 | <tr> |
| ... | ... | @@ -336,11 +384,11 @@ |
| 336 | 384 | <td colspan="14">路别:{{xlName}} 路牌:{{lpName}} 车号:{{clZbh}} 出场时间:{{fcsjActual}} 到达站名:{{zdzName}} 当班调派: 日期:{{scheduleDate}}</td> |
| 337 | 385 | </tr> |
| 338 | 386 | <tr> |
| 339 | - <td colspan="2">出场存油 升</td> | |
| 340 | - <td colspan="2">加注油量 升</td> | |
| 341 | - <td colspan="2">进场存油 升</td> | |
| 387 | + <td colspan="2">出场存油 {{ccyl}};升</td> | |
| 388 | + <td colspan="2">加注油量 {{jzl}}升</td> | |
| 389 | + <td colspan="2">进场存油 {{jcyl}}升</td> | |
| 342 | 390 | <td colspan="4">加注机油 升</td> |
| 343 | - <td colspan="4">本日耗油 升</td> | |
| 391 | + <td colspan="4">本日耗油 {{yh}}升</td> | |
| 344 | 392 | </tr> |
| 345 | 393 | <tr> |
| 346 | 394 | <td rowspan="2">调度章</td> |
| ... | ... | @@ -388,175 +436,65 @@ |
| 388 | 436 | <td colspan="1">慢</td> |
| 389 | 437 | </tr> |
| 390 | 438 | </script> |
| 391 | - | |
| 392 | 439 | <script type="text/html" id="ludan_2"> |
| 393 | - | |
| 394 | 440 | {{each list as obj i}} |
| 395 | - | |
| 396 | 441 | <tr> |
| 397 | - | |
| 398 | - <td>{{i+1}}</td> | |
| 399 | - | |
| 400 | - <td>{{obj.jName}}</td> | |
| 401 | - | |
| 402 | - <td>{{obj.sName}}</td> | |
| 403 | - | |
| 442 | + <td>{{obj.adjustExps}}</td> | |
| 443 | + <td>{{obj.jGh}}{{obj.jName}}</td> | |
| 444 | + <td>{{if obj.sGh !=null}} | |
| 445 | + {{obj.sGh}}{{obj.sName}} | |
| 446 | + {{/if}} | |
| 447 | + </td> | |
| 404 | 448 | <td> </td> |
| 405 | - | |
| 406 | 449 | <td>{{obj.qdzName}}</td> |
| 407 | - | |
| 408 | 450 | <td>{{obj.zdzName}}</td> |
| 409 | - | |
| 410 | 451 | <td>{{obj.fcsj}}</td> |
| 411 | - | |
| 412 | 452 | <td>{{obj.fcsjActual}}</td> |
| 413 | - | |
| 414 | 453 | <td>{{obj.zdsj}}</td> |
| 415 | - | |
| 416 | 454 | <td>{{obj.zdsjActual}}</td> |
| 417 | - | |
| 418 | 455 | <td>{{obj.fast}}</td> |
| 419 | - | |
| 420 | 456 | <td>{{obj.slow}}</td> |
| 421 | - | |
| 422 | 457 | <td>{{obj.jhlc}}</td> |
| 423 | - <td>{{obj.remarks}}</td> | |
| 424 | - | |
| 458 | + <td > | |
| 459 | + {{obj.remarks}} | |
| 460 | + </td> | |
| 425 | 461 | </tr> |
| 426 | - | |
| 427 | 462 | {{/each}} |
| 428 | 463 | {{if list.length == 0}} |
| 429 | 464 | <tr> |
| 430 | 465 | <td colspan="14"><h6 class="muted">没有找到相关数据</h6></td> |
| 431 | 466 | </tr> |
| 432 | 467 | {{/if}} |
| 433 | - | |
| 434 | 468 | </script> |
| 435 | 469 | <script type="text/html" id="ludan_3"> |
| 436 | 470 | <tr> |
| 437 | - <td colspan="2">计划公里</td> | |
| 438 | - <td>{{jhlc}}</td> | |
| 439 | - <td colspan="2">烂班公里</td> | |
| 440 | - <td>{{remMileage}}</td> | |
| 441 | - <td colspan="2">临加公里</td> | |
| 442 | - <td>{{addMileage}}</td> | |
| 443 | - <td colspan="2">营运公里</td> | |
| 444 | - <td colspan="3">{{yygl}}</td> | |
| 445 | - </tr> | |
| 446 | - <tr> | |
| 447 | - <td colspan="2">空驶公里</td> | |
| 448 | - <td>{{ksgl}}</td> | |
| 449 | - <td colspan="2">总公里</td> | |
| 450 | - <td>{{realMileage}}</td> | |
| 451 | 471 | <td colspan="2">计划班次</td> |
| 452 | 472 | <td>{{jhbc}}</td> |
| 473 | + <td colspan="2">计划公里</td> | |
| 474 | + <td>{{jhlc}}</td> | |
| 453 | 475 | <td colspan="2">烂班班次</td> |
| 454 | - <td colspan="3">{{cjbc}}</td> | |
| 476 | + <td>{{cjbc}}</td> | |
| 477 | + <td colspan="3"> 烂班公里</td> | |
| 478 | + <td colspan="2">{{remMileage}}</td> | |
| 455 | 479 | </tr> |
| 456 | 480 | <tr> |
| 457 | - <td colspan="2">增加班次</td> | |
| 481 | + <td colspan="2">临加班次</td> | |
| 458 | 482 | <td>{{ljbc}}</td> |
| 483 | + <td colspan="2">临加公里</td> | |
| 484 | + <td>{{addMileage}}</td> | |
| 459 | 485 | <td colspan="2">实际班次</td> |
| 460 | 486 | <td>{{sjbc}}</td> |
| 487 | + <td colspan="3">营运公里</td> | |
| 488 | + <td colspan="2">{{yygl}}</td> | |
| 489 | + </tr> | |
| 490 | + <tr> | |
| 491 | + <td colspan="2">空驶公里</td> | |
| 492 | + <td>{{ljgl}}</td> | |
| 493 | + <td colspan="2">总公里</td> | |
| 494 | + <td>{{zlcgl}}</td> | |
| 461 | 495 | <td colspan="2"></td> |
| 462 | 496 | <td></td> |
| 463 | - <td colspan="2"></td> | |
| 464 | 497 | <td colspan="3"></td> |
| 498 | + <td colspan="2"></td> | |
| 465 | 499 | </tr> |
| 466 | 500 | </script> |
| 467 | -<script type="text/html" id="ludan_4"> | |
| 468 | - <tr> | |
| 469 | - <td colspan="12">认真做好终点项目的例保保修工作,杜绝机械火警事故!</td> | |
| 470 | - <td>轮胎</td> | |
| 471 | - <td> </td> | |
| 472 | - </tr> | |
| 473 | - <tr> | |
| 474 | - <td colspan="3">重点例保项目</td> | |
| 475 | - <td>1</td> | |
| 476 | - <td>2</td> | |
| 477 | - <td>3</td> | |
| 478 | - <td colspan="3">重点例保项目</td> | |
| 479 | - <td>1</td> | |
| 480 | - <td>2</td> | |
| 481 | - <td>3</td> | |
| 482 | - <td>灭火机</td> | |
| 483 | - <td> </td> | |
| 484 | - </tr> | |
| 485 | - <tr> | |
| 486 | - <td colspan="3">各类制动</td> | |
| 487 | - <td> </td> | |
| 488 | - <td> </td> | |
| 489 | - <td> </td> | |
| 490 | - <td colspan="3">各类灯光</td> | |
| 491 | - <td> </td> | |
| 492 | - <td> </td> | |
| 493 | - <td> </td> | |
| 494 | - <td colspan="2">出场路码表里程</td> | |
| 495 | - </tr> | |
| 496 | - <tr> | |
| 497 | - <td colspan="3">方向机</td> | |
| 498 | - <td> </td> | |
| 499 | - <td> </td> | |
| 500 | - <td> </td> | |
| 501 | - <td colspan="3">各类仪表</td> | |
| 502 | - <td> </td> | |
| 503 | - <td> </td> | |
| 504 | - <td> </td> | |
| 505 | - <td colspan="2" rowspan="2"> </td> | |
| 506 | - </tr> | |
| 507 | - <tr> | |
| 508 | - <td colspan="3">欠压报警器</td> | |
| 509 | - <td> </td> | |
| 510 | - <td> </td> | |
| 511 | - <td> </td> | |
| 512 | - <td colspan="3">各类皮带</td> | |
| 513 | - <td> </td> | |
| 514 | - <td> </td> | |
| 515 | - <td> </td> | |
| 516 | - </tr> | |
| 517 | - <tr> | |
| 518 | - <td colspan="3">发动机清洁及响声</td> | |
| 519 | - <td> </td> | |
| 520 | - <td> </td> | |
| 521 | - <td> </td> | |
| 522 | - <td colspan="3">油箱及托架</td> | |
| 523 | - <td> </td> | |
| 524 | - <td> </td> | |
| 525 | - <td> </td> | |
| 526 | - <td colspan="2">出场路码表里程</td> | |
| 527 | - </tr> | |
| 528 | - <tr> | |
| 529 | - <td colspan="3">地盘响声</td> | |
| 530 | - <td> </td> | |
| 531 | - <td> </td> | |
| 532 | - <td> </td> | |
| 533 | - <td colspan="3">轮胎、半轴螺栓螺母</td> | |
| 534 | - <td> </td> | |
| 535 | - <td> </td> | |
| 536 | - <td> </td> | |
| 537 | - <td colspan="2" rowspan="3"> </td> | |
| 538 | - </tr> | |
| 539 | - <tr> | |
| 540 | - <td colspan="3">化油器及油路</td> | |
| 541 | - <td> </td> | |
| 542 | - <td> </td> | |
| 543 | - <td> </td> | |
| 544 | - <td colspan="3">油、电、水、气</td> | |
| 545 | - <td> </td> | |
| 546 | - <td> </td> | |
| 547 | - <td> </td> | |
| 548 | - </tr> | |
| 549 | - <tr> | |
| 550 | - <td colspan="3">进排歧管及排气管</td> | |
| 551 | - <td> </td> | |
| 552 | - <td> </td> | |
| 553 | - <td> </td> | |
| 554 | - <td colspan="3">内外车身及附件</td> | |
| 555 | - <td> </td> | |
| 556 | - <td> </td> | |
| 557 | - <td> </td> | |
| 558 | - </tr> | |
| 559 | - <tr> | |
| 560 | - <td colspan="14">1 首次出场,2 复使中途,3 某次进场。√正常,ⓧ报修,×尚未报修</td> | |
| 561 | - </tr> | |
| 562 | -</script> | |
| 563 | 501 | \ No newline at end of file | ... | ... |