Commit ca3ef82c517d2516f74111d663ec8d432d66266c

Authored by 廖磊
2 parents 0b70499d 4a9bde17

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

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -35,6 +35,11 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, @@ -35,6 +35,11 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
35 return scheduleRealInfoService.findByLines(lines); 35 return scheduleRealInfoService.findByLines(lines);
36 } 36 }
37 37
  38 + @RequestMapping(value = "/car")
  39 + public List<ScheduleRealInfo> findByCar(String nbbm){
  40 + return dayOfSchedule.findByNbbm(nbbm);
  41 + }
  42 +
38 /** 43 /**
39 * 44 *
40 * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id 45 * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -46,7 +46,7 @@ public class DayOfSchedule implements CommandLineRunner { @@ -46,7 +46,7 @@ public class DayOfSchedule implements CommandLineRunner {
46 46
47 Logger logger = LoggerFactory.getLogger(this.getClass()); 47 Logger logger = LoggerFactory.getLogger(this.getClass());
48 48
49 - //按线路分组的 “计划” 排班数据 49 + //按线路分组的 “原始计划” 排班数据
50 public static Map<String, List<SchedulePlanInfo>> schedulePlanMap; 50 public static Map<String, List<SchedulePlanInfo>> schedulePlanMap;
51 51
52 // 按车辆分组的班次数据 52 // 按车辆分组的班次数据
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
@@ -463,6 +463,9 @@ public class ScheduleRealInfo { @@ -463,6 +463,9 @@ public class ScheduleRealInfo {
463 463
464 public void setJhlc(Double jhlc) { 464 public void setJhlc(Double jhlc) {
465 this.jhlc = jhlc; 465 this.jhlc = jhlc;
  466 + //临加班次 计划公里 和 实际计划公里一样
  467 + if(this.isSflj())
  468 + this.setJhlcOrig(this.getJhlc());
466 } 469 }
467 470
468 public String getSjlc() { 471 public String getSjlc() {
src/main/java/com/bsth/repository/schedule/SchedulePlanInfoRepository.java
@@ -33,15 +33,15 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI @@ -33,15 +33,15 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
33 "info.lp_name as lpName, " + 33 "info.lp_name as lpName, " +
34 "info.cl as clId, " + 34 "info.cl as clId, " +
35 "info.cl_zbh as clZbh, " + 35 "info.cl_zbh as clZbh, " +
36 - "group_concat(info.fcsj) ccsj, " +  
37 - "group_concat(info.bc_type) bctype, " + 36 + "group_concat(info.fcsj order by info.fcno) ccsj, " +
  37 + "group_concat(info.bc_type order by info.fcno) bctype, " +
38 "group_concat(distinct info.j) jsyId, " + 38 "group_concat(distinct info.j) jsyId, " +
39 "group_concat(distinct info.j_gh) jsyGh, " + 39 "group_concat(distinct info.j_gh) jsyGh, " +
40 "group_concat(distinct info.j_name) jsyName, " + 40 "group_concat(distinct info.j_name) jsyName, " +
41 "group_concat(distinct info.s) spyId, " + 41 "group_concat(distinct info.s) spyId, " +
42 "group_concat(distinct info.s_gh) spyGh, " + 42 "group_concat(distinct info.s_gh) spyGh, " +
43 "group_concat(distinct info.s_name) spyName, " + 43 "group_concat(distinct info.s_name) spyName, " +
44 - "group_concat(info.fcno) fcno, " + 44 + "group_concat(info.fcno order by info.fcno) fcno, " +
45 "max(info.update_date) as updateDate, " + 45 "max(info.update_date) as updateDate, " +
46 "max(user.user_name) as updateUserName, " + 46 "max(user.user_name) as updateUserName, " +
47 "max(info.tt_info_name) as ttInfoName " + 47 "max(info.tt_info_name) as ttInfoName " +
@@ -49,7 +49,7 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI @@ -49,7 +49,7 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
49 "where info.xl = ?1 and " + 49 "where info.xl = ?1 and " +
50 "info.schedule_date = ?2 " + 50 "info.schedule_date = ?2 " +
51 "group by info.xl_name, info.schedule_date, info.lp, info.lp_name, info.cl, info.cl_zbh " + 51 "group by info.xl_name, info.schedule_date, info.lp, info.lp_name, info.cl, info.cl_zbh " +
52 - "order by info.xl_name, info.schedule_date, info.lp, info.fcno ", nativeQuery = true) 52 + "order by info.xl_name, info.schedule_date, info.lp ", nativeQuery = true)
53 List<Object[]> findGroupInfo(Integer xlid, Date scheduleDate); 53 List<Object[]> findGroupInfo(Integer xlid, Date scheduleDate);
54 54
55 @Modifying 55 @Modifying
src/main/java/com/bsth/repository/sys/DutyEmployeeRepository.java
@@ -13,6 +13,7 @@ import java.util.List; @@ -13,6 +13,7 @@ import java.util.List;
13 @Repository 13 @Repository
14 public interface DutyEmployeeRepository extends BaseRepository<DutyEmployee, Long>{ 14 public interface DutyEmployeeRepository extends BaseRepository<DutyEmployee, Long>{
15 15
16 - @Query("select t from DutyEmployee t where t.codeIdx like %?1% and t.ts > ?2 and t.ts < ?3")  
17 - List<DutyEmployee> findByLineAndTime(String lineCode, long st, long et); 16 + //@Query("select t from DutyEmployee t where t.codeIdx like %?1% and t.ts > ?2 and t.ts < ?3")
  17 + @Query("select t from DutyEmployee t where t.codeIdx like %?1% and t.ts < ?2")
  18 + List<DutyEmployee> findByLineAndTime(String lineCode, long et);
18 } 19 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -341,7 +341,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -341,7 +341,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
341 t.setLate(false); 341 t.setLate(false);
342 t.setDfsj(t.getFcsj()); 342 t.setDfsj(t.getFcsj());
343 t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime()); 343 t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());
344 - 344 + t.setJhlcOrig(t.getJhlc());
345 345
346 //班次历时 346 //班次历时
347 t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60); 347 t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);
@@ -1066,8 +1066,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1066,8 +1066,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1066 if (StringUtils.isNotEmpty(jhlc)) { 1066 if (StringUtils.isNotEmpty(jhlc)) {
1067 if(Double.parseDouble(jhlc) == 0 && sch.getJhlcOrig() != 0) 1067 if(Double.parseDouble(jhlc) == 0 && sch.getJhlcOrig() != 0)
1068 destroy(sch.getId() + "", "", map.get("adjustExps").toString()); 1068 destroy(sch.getId() + "", "", map.get("adjustExps").toString());
1069 - else 1069 + else{
1070 sch.setJhlc(Double.parseDouble(jhlc)); 1070 sch.setJhlc(Double.parseDouble(jhlc));
  1071 + }
1071 } 1072 }
1072 } 1073 }
1073 1074
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
@@ -15,9 +15,7 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; @@ -15,9 +15,7 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; 16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
17 import com.bsth.service.schedule.rules.strategy.IStrategy; 17 import com.bsth.service.schedule.rules.strategy.IStrategy;
18 -import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input;  
19 -import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;  
20 -import com.bsth.service.schedule.rules.ttinfo.TTInfo_input; 18 +import com.bsth.service.schedule.rules.ttinfo.*;
21 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam; 19 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
22 import com.bsth.service.schedule.rules.ttinfo2.Result; 20 import com.bsth.service.schedule.rules.ttinfo2.Result;
23 import org.joda.time.DateTime; 21 import org.joda.time.DateTime;
@@ -96,7 +94,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -96,7 +94,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
96 * 循环规则输出。 94 * 循环规则输出。
97 * @param schedulePlan 95 * @param schedulePlan
98 */ 96 */
99 - private ScheduleResults_output loopRuleOutput(SchedulePlan schedulePlan) { 97 + private ScheduleResults_output loopRuleOutput(SchedulePlan schedulePlan, LpInfoResults_output lpInfoResults_output) {
100 // 获取主线路 98 // 获取主线路
101 Line xl = strategy.getLine(schedulePlan.getXl().getId()); 99 Line xl = strategy.getLine(schedulePlan.getXl().getId());
102 100
@@ -126,6 +124,9 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -126,6 +124,9 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
126 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) { 124 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) {
127 session.insert(scheduleRule_input); 125 session.insert(scheduleRule_input);
128 } 126 }
  127 + for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) {
  128 + session.insert(lpInfoResult_output);
  129 + }
129 // 执行rule 130 // 执行rule
130 session.fireAllRules(); 131 session.fireAllRules();
131 132
@@ -138,11 +139,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -138,11 +139,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
138 } 139 }
139 140
140 /** 141 /**
141 - * 时刻表选择(判定每天使用的时刻表)。 142 + * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。
142 * @param schedulePlan 143 * @param schedulePlan
143 - * @return 144 + * @return TTInfoResults_output, LpInfoResults_output
144 */ 145 */
145 - private TTInfoResults_output ttInfoOutput(SchedulePlan schedulePlan) { 146 + private Object[] ttInfoOutput(SchedulePlan schedulePlan) {
146 // 获取线路的所有未作废的时刻表 147 // 获取线路的所有未作废的时刻表
147 List<TTInfo> ttInfos = getTTInfos(schedulePlan.getXl().getId()); 148 List<TTInfo> ttInfos = getTTInfos(schedulePlan.getXl().getId());
148 149
@@ -156,6 +157,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -156,6 +157,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
156 ); 157 );
157 // 规则输出数据 158 // 规则输出数据
158 TTInfoResults_output ttInfoResults_output = new TTInfoResults_output(); 159 TTInfoResults_output ttInfoResults_output = new TTInfoResults_output();
  160 + LpInfoResults_output lpInfoResults_output = new LpInfoResults_output();
159 161
160 // 1-2、构造drools session->载入数据->启动规则->计算->销毁session 162 // 1-2、构造drools session->载入数据->启动规则->计算->销毁session
161 // 创建session,内部配置的是stateful 163 // 创建session,内部配置的是stateful
@@ -163,8 +165,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -163,8 +165,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
163 165
164 // 设置gloable对象,在drl中通过别名使用 166 // 设置gloable对象,在drl中通过别名使用
165 session.setGlobal("results", ttInfoResults_output); 167 session.setGlobal("results", ttInfoResults_output);
  168 + session.setGlobal("lpInfoResults_output", lpInfoResults_output);
166 session.setGlobal("log", logger); // 设置日志 169 session.setGlobal("log", logger); // 设置日志
167 170
  171 + session.setGlobal("tTInfoDetailService", ttInfoDetailService);
  172 +
168 // 载入数据 173 // 载入数据
169 session.insert(ttInfoCalcuParam_input); 174 session.insert(ttInfoCalcuParam_input);
170 for (TTInfo ttInfo : ttInfos) { 175 for (TTInfo ttInfo : ttInfos) {
@@ -178,7 +183,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -178,7 +183,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
178 // 执行完毕销毁,有日志的也要关闭 183 // 执行完毕销毁,有日志的也要关闭
179 session.dispose(); 184 session.dispose();
180 185
181 - return ttInfoResults_output; 186 + return new Object[] {ttInfoResults_output, lpInfoResults_output};
182 187
183 } 188 }
184 189
@@ -225,19 +230,39 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -225,19 +230,39 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
225 230
226 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) 231 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
227 public SchedulePlan save2(SchedulePlan schedulePlan) { 232 public SchedulePlan save2(SchedulePlan schedulePlan) {
228 - // 1、循环规则计算输出  
229 - ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan);  
230 - // 2、时刻表选择  
231 - TTInfoResults_output ttInfoResults_output = ttInfoOutput(schedulePlan); 233 + // 1、时刻表数据及每日路牌数据计算
  234 + Object[] ttInfoRets = ttInfoOutput(schedulePlan);
  235 + TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0];
  236 + LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1];
  237 +
  238 + // 2、循环规则计算输出
  239 + ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output);
  240 +
232 // 3、计划输出 241 // 3、计划输出
233 PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); 242 PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);
234 243
235 - schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());  
236 schedulePlan.setTtInfoId("todo"); // TODO:待修正 244 schedulePlan.setTtInfoId("todo"); // TODO:待修正
237 schedulePlan.setTtInfoNames("todo"); // TODO:待修正 245 schedulePlan.setTtInfoNames("todo"); // TODO:待修正
238 246
  247 + schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());
  248 +
239 super.save(schedulePlan); 249 super.save(schedulePlan);
240 250
  251 +
  252 +
  253 +// // 1、循环规则计算输出
  254 +// ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan);
  255 +// // 2、时刻表选择
  256 +// TTInfoResults_output ttInfoResults_output = ttInfoOutput(schedulePlan);
  257 +// // 3、计划输出
  258 +// PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);
  259 +//
  260 +// schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());
  261 +// schedulePlan.setTtInfoId("todo"); // TODO:待修正
  262 +// schedulePlan.setTtInfoNames("todo"); // TODO:待修正
  263 +//
  264 +// super.save(schedulePlan);
  265 +
241 return new SchedulePlan(); 266 return new SchedulePlan();
242 } 267 }
243 268
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 +
  21 + public void add(LpInfoResult_output lpInfoResult_output) {
  22 +
  23 + }
  24 +}
src/main/java/com/bsth/service/sys/impl/DutyEmployeeServiceImpl.java
@@ -39,6 +39,6 @@ public class DutyEmployeeServiceImpl extends BaseServiceImpl&lt;DutyEmployee, Long&gt; @@ -39,6 +39,6 @@ public class DutyEmployeeServiceImpl extends BaseServiceImpl&lt;DutyEmployee, Long&gt;
39 */ 39 */
40 public List<DutyEmployee> getDutyEmployee(String lineCode, String startTime, String endTime) { 40 public List<DutyEmployee> getDutyEmployee(String lineCode, String startTime, String endTime) {
41 DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); 41 DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
42 - return dutyEmployeeRepository.findByLineAndTime(lineCode + ",", fmtyyyyMMddHHmm.parseMillis(startTime), fmtyyyyMMddHHmm.parseMillis(endTime)); 42 + return dutyEmployeeRepository.findByLineAndTime(lineCode + ",", fmtyyyyMMddHHmm.parseMillis(endTime));
43 } 43 }
44 } 44 }
src/main/resources/rules/functions.drl
@@ -2,4 +2,5 @@ package com.bsth.service.schedule; @@ -2,4 +2,5 @@ package com.bsth.service.schedule;
2 2
3 import accumulate com.bsth.service.schedule.rules.ttinfo2.ErrorBcCountFunction ecount; 3 import accumulate com.bsth.service.schedule.rules.ttinfo2.ErrorBcCountFunction ecount;
4 import accumulate com.bsth.service.schedule.rules.shiftloop.GidsCountFunction gidscount; 4 import accumulate com.bsth.service.schedule.rules.shiftloop.GidsCountFunction gidscount;
5 -import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime;  
6 \ No newline at end of file 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 \ No newline at end of file 8 \ No newline at end of file
src/main/resources/rules/shiftloop_fb_2.drl 0 → 100644
  1 +package com.bsth.service.schedule.shiftloop;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +
  6 +import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output;
  7 +
  8 +import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
  9 +import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
  10 +import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
  11 +import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
  12 +
  13 +import org.slf4j.Logger;
  14 +
  15 +global Logger log;
  16 +global ScheduleResults_output scheduleResult;
  17 +
  18 +/*
  19 + 存在(翻班格式)
  20 +*/
  21 +
  22 +//------------------------- 第一阶段、计算规则准备数据(天数) ----------------------------//
  23 +
  24 +declare Calcu_days_result_pre
  25 + ruleId: String // 规则Id
  26 +
  27 + calcu_index_lp : Integer // 计算之后路牌的起始索引
  28 + calcu_index_ry : Integer // 计算之后人员的起始索引
  29 +
  30 + // 1、第一部分循环需要用到的数据(当开始日期大于启用日期的时候才有)
  31 + calcu_start_date_1: DateTime // 第一部分开始计算日期
  32 + calcu_end_date_1: DateTime // 第一部分结束计算日期
  33 +
  34 + // 2、第二部分循环需要用到的数据
  35 + sdays : Integer // 总共需要排班的天数
  36 + calcu_start_date_2 : DateTime // 开始计算日期
  37 + calcu_end_date_2 : DateTime // 结束计算日期
  38 +
  39 +end
  40 +
  41 +/*
  42 + 计算启用日期,开始计算日期,结束计算日期,相差天数
  43 + 1、规则启用日期小于开始计算日期
  44 + 2、规则启用日期大于等于开始日期,小于等于结束日期
  45 +*/
  46 +// 1、启用日期 < 开始日期
  47 +rule "calcu_days_1_"
  48 + salience 1000
  49 + when
  50 + ScheduleCalcuParam_input(
  51 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  52 + $fromDate : fromDate,
  53 + $toDate : toDate
  54 + )
  55 + ScheduleRule_input(
  56 + $ruleId : ruleId, $qyrq : qyrq,
  57 + $lpindex : startGbdIndex, $ryindex: startEIndex)
  58 + eval($qyrq.isBefore($fromDate))
  59 + then
  60 + // 构造Calcu_days_result_pre,用于路牌
  61 + Calcu_days_result_pre cdrp = new Calcu_days_result_pre();
  62 + cdrp.setRuleId($ruleId);
  63 + cdrp.setCalcu_index_lp($lpindex);
  64 + cdrp.setCalcu_index_ry($ryindex);
  65 + cdrp.setCalcu_start_date_1($qyrq);
  66 + cdrp.setCalcu_end_date_1($fromDate);
  67 + Period p2 = new Period($fromDate, $toDate, PeriodType.days());
  68 + cdrp.setSdays(p2.getDays() + 1);
  69 + cdrp.setCalcu_start_date_2($fromDate);
  70 + cdrp.setCalcu_end_date_2($toDate);
  71 +
  72 + insert(cdrp);
  73 +
  74 + log.info("总共需要排班的天数 sdays={} ruleId={}", (p2.getDays() + 1), $ruleId);
  75 +
  76 +end
  77 +
  78 +// 启用日期 属于 [开始日期,结束日期]
  79 +rule "calcu_days_2_"
  80 + salience 1000
  81 + when
  82 + ScheduleCalcuParam_input(
  83 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  84 + $fromDate : fromDate,
  85 + $toDate : toDate
  86 + )
  87 + ScheduleRule_input(
  88 + $ruleId : ruleId, $qyrq : qyrq,
  89 + $lpindex : startGbdIndex, $ryindex: startEIndex)
  90 + eval((!$qyrq.isBefore($fromDate)) && (!$qyrq.isAfter($toDate)))
  91 + then
  92 + // 构造Calcu_days_result_pre,用于路牌
  93 + Calcu_days_result_pre cdrp = new Calcu_days_result_pre();
  94 + cdrp.setRuleId($ruleId);
  95 + cdrp.setCalcu_index_lp($lpindex);
  96 + cdrp.setCalcu_index_ry($ryindex);
  97 + cdrp.setCalcu_start_date_1($qyrq);
  98 + cdrp.setCalcu_end_date_1($qyrq);
  99 + Period p2 = new Period($qyrq, $toDate, PeriodType.days());
  100 + cdrp.setSdays(p2.getDays() + 1);
  101 + cdrp.setCalcu_start_date_2($qyrq);
  102 + cdrp.setCalcu_end_date_2($toDate);
  103 +
  104 + insert(cdrp);
  105 +
  106 + log.info("总共需要排班的天数 sdays={} ruleId={}", (p2.getDays() + 1), $ruleId);
  107 +
  108 +end
  109 +
  110 +//------------------------- 第二阶段、计算规则准备数据2(第一组循环) ----------------------------//
  111 +rule "Calcu_loop1_1_" // 时刻表的关联的路牌不存在,调整翻版规则
  112 + salience 900
  113 + when
  114 + $cdrp: Calcu_days_result_pre(
  115 + calcu_start_date_1.isBefore(calcu_end_date_1),
  116 + $csd1: calcu_start_date_1,
  117 + $ced1: calcu_end_date_1,
  118 + $ruleId: ruleId,
  119 + $lpindex: calcu_index_lp,
  120 + $ryindex: calcu_index_ry
  121 + )
  122 + $sri: ScheduleRule_input(
  123 + ruleId == $ruleId,
  124 + $gids: guideboardIds,
  125 + $lprangesize : guideboardIds.size(),
  126 + $ryrangesize: employeeConfigIds.size()
  127 + )
  128 + $liro: LpInfoResult_output(
  129 + dateTime.isEqual($csd1),
  130 + $gids.get($lpindex) == lpId,
  131 + $lpId: lpId
  132 + )
  133 + then
  134 + $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);
  135 + $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);
  136 + $cdrp.setCalcu_start_date_1($csd1.plusDays(1));
  137 +
  138 + log.info("Calcu_loop1_1_ ruleId={}, calcu_index_lp/ry={}/{}",
  139 + $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry());
  140 +
  141 + update($cdrp);
  142 +end
  143 +
  144 +rule "Calcu_loop1_2_" // 时刻表的关联路牌存在,就翻
  145 + salience 800
  146 + when
  147 + $cdrp: Calcu_days_result_pre(
  148 + calcu_start_date_1.isBefore(calcu_end_date_1),
  149 + $csd1: calcu_start_date_1,
  150 + $ced1: calcu_end_date_1,
  151 + $ruleId: ruleId
  152 + )
  153 + $sri: ScheduleRule_input(
  154 + ruleId == $ruleId,
  155 + $rangesize : guideboardIds.size()
  156 + )
  157 + then
  158 + $cdrp.setCalcu_start_date_1($csd1.plusDays(1));
  159 +
  160 + log.info("Calcu_loop1_2_ ruleId={}, calcu_index_lp/ry={}/{}",
  161 + $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry());
  162 +
  163 + update($cdrp);
  164 +end
  165 +
  166 +
  167 +//----------------------- 路牌范围循环计算 ------------------------//
  168 +
  169 +//declare Calcu_guideboard_index_result
  170 +// ruleId : String // 规则Id
  171 +// calcu_index : Integer // 计算之后的起始索引
  172 +//end
  173 +//
  174 +//// 启用日期等于开始日期
  175 +//rule "calcu_guideboard_index_qyrq_eq_startrq"
  176 +// when
  177 +// $calcu_days_result : Calcu_days_result(
  178 +// qyrq_days == 0,
  179 +// $ruleId: ruleId
  180 +// )
  181 +// $scheduleRule_input : ScheduleRule_input(
  182 +// ruleId == $ruleId,
  183 +// $oindex : startGbdIndex
  184 +// )
  185 +// then
  186 +// Calcu_guideboard_index_result cgir = new Calcu_guideboard_index_result();
  187 +// cgir.setRuleId($ruleId);
  188 +// cgir.setCalcu_index($oindex);
  189 +//
  190 +// log.info("calcu_guideboard_index_qyrq_eq_startrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  191 +//
  192 +// insert(cgir);
  193 +//end
  194 +//
  195 +//// 开始日期大于启用日期
  196 +//rule "calcu_guideboard_index_startrq_gt_qyrq"
  197 +// when
  198 +// $calcu_days_result : Calcu_days_result(
  199 +// qyrq_days > 0,
  200 +// $ruleId: ruleId, $qyrq_days: qyrq_days,
  201 +// $calcu_start_date: calcu_start_date
  202 +// )
  203 +// $scheduleRule_input : ScheduleRule_input(
  204 +// ruleId == $ruleId,
  205 +// $qyrq: qyrq,
  206 +// $rangesize : guideboardIds.size(),
  207 +// $oindex : startGbdIndex,
  208 +// $weekdays: weekdays
  209 +// )
  210 +// then
  211 +// // 开始时间
  212 +// DateTime initDate = $qyrq;
  213 +// int index = $oindex;
  214 +// int resultIndex = index;
  215 +//
  216 +// while (!initDate.isAfter($calcu_start_date)) {
  217 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  218 +// resultIndex = index;
  219 +// index = (index + 1) % $rangesize;
  220 +// }
  221 +// initDate = initDate.plusDays(1);
  222 +// }
  223 +//
  224 +// Calcu_guideboard_index_result cgir = new Calcu_guideboard_index_result();
  225 +// cgir.setRuleId($ruleId);
  226 +// cgir.setCalcu_index(resultIndex);
  227 +//
  228 +// log.info("calcu_guideboard_index_startrq_gt_qyrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  229 +//
  230 +// insert(cgir);
  231 +//end
  232 +//
  233 +////----------------------- 人员范围循环计算 ------------------------//
  234 +//
  235 +//declare Calcu_employee_index_result
  236 +// ruleId : String // 规则Id
  237 +// calcu_index : Integer // 计算之后的起始索引
  238 +//end
  239 +//
  240 +//// 启用日期等于开始日期
  241 +//rule "calcu_employee_index_qyrq_eq_startrq"
  242 +// when
  243 +// $calcu_days_result : Calcu_days_result(
  244 +// qyrq_days == 0,
  245 +// $ruleId: ruleId)
  246 +// $scheduleRule_input : ScheduleRule_input(
  247 +// ruleId == $ruleId,
  248 +// $oindex : startEIndex)
  249 +// then
  250 +// Calcu_employee_index_result cgir = new Calcu_employee_index_result();
  251 +// cgir.setRuleId($ruleId);
  252 +// cgir.setCalcu_index($oindex);
  253 +//
  254 +// log.info("calcu_employee_index_qyrq_eq_startrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  255 +//
  256 +// insert(cgir);
  257 +//end
  258 +//
  259 +//// 开始日期大于启用日期
  260 +//rule "calcu_employee_index_startrq_gt_qyrq"
  261 +// when
  262 +// $calcu_days_result : Calcu_days_result(
  263 +// qyrq_days > 0,
  264 +// $ruleId: ruleId, $qyrq_days: qyrq_days,
  265 +// $calcu_start_date: calcu_start_date
  266 +// )
  267 +// $scheduleRule_input : ScheduleRule_input(
  268 +// ruleId == $ruleId,
  269 +// $qyrq: qyrq,
  270 +// $rangesize : employeeConfigIds.size(),
  271 +// $oindex : startEIndex,
  272 +// $weekdays: weekdays
  273 +// )
  274 +// then
  275 +// // 开始时间
  276 +// DateTime initDate = $qyrq;
  277 +// int index = $oindex;
  278 +// int resultIndex = index;
  279 +//
  280 +// while (!initDate.isAfter($calcu_start_date)) {
  281 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  282 +// resultIndex = index;
  283 +// index = (index + 1) % $rangesize;
  284 +// }
  285 +// initDate = initDate.plusDays(1);
  286 +// }
  287 +//
  288 +// Calcu_employee_index_result cgir = new Calcu_employee_index_result();
  289 +// cgir.setRuleId($ruleId);
  290 +// cgir.setCalcu_index(resultIndex);
  291 +//
  292 +// log.info("calcu_employee_index_startrq_gt_qyrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  293 +//
  294 +// insert(cgir);
  295 +//
  296 +//end
  297 +//
  298 +////------------------------- 第三阶段、循环计算 ------------------------//
  299 +//
  300 +////----------------------- 路牌范围循环计算 ------------------------//
  301 +//declare loop_guideboard_result
  302 +// ruleId : String // 规则id
  303 +// go_list : List // 路牌循环的列表
  304 +//end
  305 +//
  306 +//// 循环路牌计算
  307 +//rule "Calcu_loop_guideboard_result"
  308 +// when
  309 +// Calcu_days_result(
  310 +// $ruleId: ruleId,
  311 +// $startDate : calcu_start_date,
  312 +// $calcu_end_date: calcu_end_date
  313 +// )
  314 +// $ruleData : ScheduleRule_input(
  315 +// ruleId == $ruleId,
  316 +// $rangesize : guideboardIds.size(),
  317 +// $weekdays: weekdays
  318 +// )
  319 +// $indexData : Calcu_guideboard_index_result(
  320 +// ruleId == $ruleId
  321 +// )
  322 +// then
  323 +// DateTime initDate = $startDate; // 开始时间
  324 +// DateTime endDate = $calcu_end_date; // 结束实际
  325 +// List<ScheduleResult_output> scheduleResult_outputs =
  326 +// new ArrayList<ScheduleResult_output>();
  327 +//
  328 +// int i = $indexData.getCalcu_index();
  329 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue() == false) {
  330 +// i = (i + 1) % $rangesize;
  331 +// }
  332 +//
  333 +// while (!initDate.isAfter(endDate)) {
  334 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  335 +// ScheduleResult_output ro = new ScheduleResult_output();
  336 +// ro.setRuleId($ruleId);
  337 +// ro.setSd(initDate);
  338 +// ro.setGuideboardId($ruleData.getGuideboardIds().get(i));
  339 +// ro.setCarConfigId($ruleData.getCarConfigId());
  340 +// scheduleResult_outputs.add(ro);
  341 +//
  342 +// i = (i + 1) % $rangesize;
  343 +// }
  344 +//
  345 +// initDate = initDate.plusDays(1);
  346 +// }
  347 +//
  348 +// loop_guideboard_result clgr = new loop_guideboard_result();
  349 +// clgr.setRuleId($ruleId);
  350 +// clgr.setGo_list(scheduleResult_outputs);
  351 +//
  352 +// log.info(String.valueOf(scheduleResult_outputs.size()));
  353 +//
  354 +// insert(clgr);
  355 +//
  356 +//end
  357 +//
  358 +////----------------------- 人员范围循环计算 ------------------------//
  359 +//declare loop_employee_result
  360 +// ruleId : String // 规则id
  361 +// eo_list : List // 人员循环的列表
  362 +//end
  363 +//
  364 +//// 循环人员计算
  365 +//rule "Calcu_loop_employee_result"
  366 +// when
  367 +// Calcu_days_result(
  368 +// $ruleId: ruleId,
  369 +// $startDate : calcu_start_date,
  370 +// $calcu_end_date: calcu_end_date
  371 +// )
  372 +// $ruleData : ScheduleRule_input(
  373 +// ruleId == $ruleId,
  374 +// $rangesize : employeeConfigIds.size(),
  375 +// $weekdays: weekdays
  376 +// )
  377 +// $indexData : Calcu_employee_index_result(
  378 +// ruleId == $ruleId
  379 +// )
  380 +// then
  381 +// DateTime initDate = $startDate; // 开始时间
  382 +// DateTime endDate = $calcu_end_date; // 结束实际
  383 +// List<ScheduleResult_output> scheduleResult_outputs =
  384 +// new ArrayList<ScheduleResult_output>();
  385 +//
  386 +// int i = $indexData.getCalcu_index();
  387 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue() == false) {
  388 +// i = (i + 1) % $rangesize;
  389 +// }
  390 +//
  391 +// while (!initDate.isAfter(endDate)) {
  392 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  393 +// ScheduleResult_output ro = new ScheduleResult_output();
  394 +// ro.setRuleId($ruleId);
  395 +// ro.setSd(initDate);
  396 +// ro.setEmployeeConfigId($ruleData.getEmployeeConfigIds().get(i));
  397 +// ro.setCarConfigId($ruleData.getCarConfigId());
  398 +// scheduleResult_outputs.add(ro);
  399 +//
  400 +// i = (i + 1) % $rangesize;
  401 +// }
  402 +//
  403 +// initDate = initDate.plusDays(1);
  404 +// }
  405 +//
  406 +// loop_employee_result clgr = new loop_employee_result();
  407 +// clgr.setRuleId($ruleId);
  408 +// clgr.setEo_list(scheduleResult_outputs);
  409 +//
  410 +// log.info(String.valueOf(scheduleResult_outputs.size()));
  411 +//
  412 +// insert(clgr);
  413 +//end
  414 +//
  415 +////------------------------- 第四阶段、范围组循环计算 ----------------------------//
  416 +//
  417 +//global ScheduleResults_output scheduleResult;
  418 +//
  419 +//rule "output"
  420 +// when
  421 +// loop_guideboard_result(
  422 +// go_list.size() > 0,
  423 +// $ruleId : ruleId, $go_list : go_list
  424 +// )
  425 +// loop_employee_result(
  426 +// ruleId == $ruleId,
  427 +// eo_list.size() == $go_list.size(),
  428 +// $eo_list : eo_list
  429 +// )
  430 +// then
  431 +// for (int i = 0; i < $go_list.size(); i++) {
  432 +// ScheduleResult_output go = (ScheduleResult_output) $go_list.get(i);
  433 +// ScheduleResult_output eo = (ScheduleResult_output) $eo_list.get(i);
  434 +// go.setEmployeeConfigId(eo.getEmployeeConfigId());
  435 +// scheduleResult.getResults().add(go);
  436 +// }
  437 +//
  438 +//end
  439 +//
  440 +//
  441 +//
  442 +//
  443 +//
  444 +//
  445 +//
  446 +//
  447 +//
  448 +//
  449 +//
  450 +//
  451 +//
  452 +//
  453 +
  454 +
src/main/resources/rules/ttinfo.drl
@@ -7,19 +7,39 @@ import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input; @@ -7,19 +7,39 @@ import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input;
7 import com.bsth.service.schedule.rules.ttinfo.TTInfo_input; 7 import com.bsth.service.schedule.rules.ttinfo.TTInfo_input;
8 import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output; 8 import com.bsth.service.schedule.rules.ttinfo.TTInfoResult_output;
9 import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output; 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 global Logger log; 21 global Logger log;
  22 +// service
  23 +global TTInfoDetailService tTInfoDetailService;
15 // return输出 24 // return输出
16 global TTInfoResults_output results 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 /*
20 TODO:规则说明,以后待说明 38 TODO:规则说明,以后待说明
21 */ 39 */
22 40
  41 +// TODO:
  42 +
23 //----------------- 第一阶段、计算规则准备数据(天数)----------------// 43 //----------------- 第一阶段、计算规则准备数据(天数)----------------//
24 44
25 declare Calcu_days_result 45 declare Calcu_days_result
@@ -91,6 +111,7 @@ rule &quot;calcu_ttinfo_special_day&quot; // 特殊日期匹配 @@ -91,6 +111,7 @@ rule &quot;calcu_ttinfo_special_day&quot; // 特殊日期匹配
91 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list) 111 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
92 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day) 112 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day)
93 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays contains $calcu_date) from $ttInfo_input_list) 113 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays contains $calcu_date) from $ttInfo_input_list)
  114 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd))
94 then 115 then
95 // 更新Calcu_days_result对象 116 // 更新Calcu_days_result对象
96 int new_calcu_day = $calcu_day + 1; 117 int new_calcu_day = $calcu_day + 1;
@@ -105,6 +126,13 @@ rule &quot;calcu_ttinfo_special_day&quot; // 特殊日期匹配 @@ -105,6 +126,13 @@ rule &quot;calcu_ttinfo_special_day&quot; // 特殊日期匹配
105 Collections.sort($ttinfolist); 126 Collections.sort($ttinfolist);
106 results.addXlTTInfos($xlId, $calcu_date, $ttinfolist); 127 results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);
107 128
  129 + // lp输出
  130 + for (int i = 0; i < $lpInfoResults.size(); i++) {
  131 + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);
  132 + lpInfoResult_output.setDateTime($calcu_date); // 设定时间
  133 + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);
  134 + }
  135 +
108 update($calcu_days_result); 136 update($calcu_days_result);
109 end 137 end
110 138
@@ -114,6 +142,7 @@ rule &quot;calcu_ttinfo_normal_day&quot; // 平日匹配 @@ -114,6 +142,7 @@ rule &quot;calcu_ttinfo_normal_day&quot; // 平日匹配
114 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list) 142 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
115 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday) 143 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)
116 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == true) from $ttInfo_input_list) 144 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == true) from $ttInfo_input_list)
  145 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd))
117 then 146 then
118 // 更新Calcu_days_result对象 147 // 更新Calcu_days_result对象
119 int new_calcu_day = $calcu_day + 1; 148 int new_calcu_day = $calcu_day + 1;
@@ -122,12 +151,19 @@ rule &quot;calcu_ttinfo_normal_day&quot; // 平日匹配 @@ -122,12 +151,19 @@ rule &quot;calcu_ttinfo_normal_day&quot; // 平日匹配
122 $calcu_days_result.setCalcu_date(new_calcu_date); 151 $calcu_days_result.setCalcu_date(new_calcu_date);
123 $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek()); 152 $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());
124 153
125 - log.info("启用常规日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday); 154 + log.info("启用常规日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={} 路牌size={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday, $lpInfoResults.size());
126 155
127 // $ttinfolist按时间倒排序,result输出 156 // $ttinfolist按时间倒排序,result输出
128 Collections.sort($ttinfolist); 157 Collections.sort($ttinfolist);
129 results.addXlTTInfos($xlId, $calcu_date, $ttinfolist); 158 results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);
130 159
  160 + // lp输出
  161 + for (int i = 0; i < $lpInfoResults.size(); i++) {
  162 + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);
  163 + lpInfoResult_output.setDateTime($calcu_date); // 设定时间
  164 + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);
  165 + }
  166 +
131 update($calcu_days_result); 167 update($calcu_days_result);
132 end 168 end
133 169
@@ -137,6 +173,7 @@ rule &quot;calcu_ttinfo_other_day&quot; // 都没有的情况下,匹配 @@ -137,6 +173,7 @@ rule &quot;calcu_ttinfo_other_day&quot; // 都没有的情况下,匹配
137 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list) 173 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
138 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday) 174 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)
139 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == false) from $ttInfo_input_list) 175 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == false) from $ttInfo_input_list)
  176 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd))
140 then 177 then
141 // 更新Calcu_days_result对象 178 // 更新Calcu_days_result对象
142 int new_calcu_day = $calcu_day + 1; 179 int new_calcu_day = $calcu_day + 1;
@@ -151,6 +188,13 @@ rule &quot;calcu_ttinfo_other_day&quot; // 都没有的情况下,匹配 @@ -151,6 +188,13 @@ rule &quot;calcu_ttinfo_other_day&quot; // 都没有的情况下,匹配
151 Collections.sort($ttinfolist); 188 Collections.sort($ttinfolist);
152 results.addXlTTInfos($xlId, $calcu_date, $ttinfolist); 189 results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);
153 190
  191 + // lp输出
  192 + for (int i = 0; i < $lpInfoResults.size(); i++) {
  193 + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);
  194 + lpInfoResult_output.setDateTime($calcu_date); // 设定时间
  195 + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);
  196 + }
  197 +
154 update($calcu_days_result); 198 update($calcu_days_result);
155 199
156 end 200 end
157 \ No newline at end of file 201 \ No newline at end of file