Commit cfd644b837c14063bfc590726900317bf103f960
1 parent
851fdf7c
Update
Showing
7 changed files
with
50 additions
and
14 deletions
src/main/java/com/bsth/entity/schedule/temp/SchedulePlanRuleResult.java
| ... | ... | @@ -27,20 +27,22 @@ public class SchedulePlanRuleResult { |
| 27 | 27 | |
| 28 | 28 | /** 排班规则id */ |
| 29 | 29 | private String ruleId; |
| 30 | - /** 启用日期 */ | |
| 30 | + /** 启用日期(用于md5计算) */ | |
| 31 | 31 | private Date qyrq; |
| 32 | 32 | /** 车辆配置id */ |
| 33 | 33 | private String ccId; |
| 34 | 34 | /** 车辆自编号 */ |
| 35 | 35 | private String ccZbh; |
| 36 | 36 | |
| 37 | - /** 路牌id列表字符串 */ | |
| 37 | + /** 路牌id列表字符串(用于md5计算) */ | |
| 38 | 38 | @Column(length = 1000) |
| 39 | 39 | private String gids; |
| 40 | 40 | /** 路牌名字列表字符串 */ |
| 41 | 41 | private String gnames; |
| 42 | 42 | /** 翻到哪个路牌索引 */ |
| 43 | 43 | private String gidindex; |
| 44 | + /** 原始的起始路牌索引(用于md5计算) */ | |
| 45 | + private String origingidindex; | |
| 44 | 46 | /** 人员配置id列表字符串 */ |
| 45 | 47 | @Column(length = 1000) |
| 46 | 48 | private String ecids; |
| ... | ... | @@ -81,8 +83,8 @@ public class SchedulePlanRuleResult { |
| 81 | 83 | "(xl_id,xl_name,rule_id,cc_id,cc_zbh," + |
| 82 | 84 | "gids,gnames,gidindex,ecids,ecdbbms,ecindex," + |
| 83 | 85 | "ttinfo_id,ttinfo_name,schedule_date," + |
| 84 | - "sysuser_id,sysuser_name,create_date, qyrq) " + | |
| 85 | - "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | |
| 86 | + "sysuser_id,sysuser_name,create_date, qyrq, origingidindex) " + | |
| 87 | + "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | |
| 86 | 88 | |
| 87 | 89 | return sql; |
| 88 | 90 | } |
| ... | ... | @@ -106,7 +108,7 @@ public class SchedulePlanRuleResult { |
| 106 | 108 | ps.setString(16, this.getSysuserName()); |
| 107 | 109 | ps.setTimestamp(17, new java.sql.Timestamp(this.getCreateDate().getTime())); |
| 108 | 110 | ps.setDate(18, new java.sql.Date(this.getQyrq().getTime())); |
| 109 | - | |
| 111 | + ps.setString(19, this.getOrigingidindex()); | |
| 110 | 112 | |
| 111 | 113 | } |
| 112 | 114 | |
| ... | ... | @@ -261,4 +263,12 @@ public class SchedulePlanRuleResult { |
| 261 | 263 | public void setQyrq(Date qyrq) { |
| 262 | 264 | this.qyrq = qyrq; |
| 263 | 265 | } |
| 266 | + | |
| 267 | + public String getOrigingidindex() { | |
| 268 | + return origingidindex; | |
| 269 | + } | |
| 270 | + | |
| 271 | + public void setOrigingidindex(String origingidindex) { | |
| 272 | + this.origingidindex = origingidindex; | |
| 273 | + } | |
| 264 | 274 | } | ... | ... |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| ... | ... | @@ -358,6 +358,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 358 | 358 | // 执行完毕销毁,有日志的也要关闭 |
| 359 | 359 | session.dispose(); |
| 360 | 360 | |
| 361 | +// logger.info("错误总数={}", result.getInfos().size()); | |
| 361 | 362 | // for (ValidateResults_output.ValidInfo validInfo: result.getInfos()) { |
| 362 | 363 | // logger.info(validInfo.getDesc()); |
| 363 | 364 | // } | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java
| ... | ... | @@ -119,6 +119,7 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { |
| 119 | 119 | obj.setScheduleDate(rs.getDate("schedule_date")); |
| 120 | 120 | obj.setGidindex(rs.getString("gidindex")); |
| 121 | 121 | obj.setEcindex(rs.getString("ecindex")); |
| 122 | + obj.setOrigingidindex(rs.getString("origingidindex")); | |
| 122 | 123 | |
| 123 | 124 | // 其他字段没用 |
| 124 | 125 | return obj; | ... | ... |
src/main/java/com/bsth/service/schedule/rules/validate/ValidRepeatBcFunction.java
| ... | ... | @@ -47,12 +47,14 @@ public class ValidRepeatBcFunction implements AccumulateFunction { |
| 47 | 47 | |
| 48 | 48 | @Override |
| 49 | 49 | public Serializable createContext() { |
| 50 | + System.out.println("create"); | |
| 50 | 51 | return new RepeatBcInfo(); |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | @Override |
| 54 | 55 | public void init(Serializable serializable) throws Exception { |
| 55 | 56 | // TODO: |
| 57 | + System.out.println("init"); | |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | @Override |
| ... | ... | @@ -82,12 +84,20 @@ public class ValidRepeatBcFunction implements AccumulateFunction { |
| 82 | 84 | |
| 83 | 85 | @Override |
| 84 | 86 | public boolean supportsReverse() { |
| 85 | - return false; | |
| 87 | + return true; | |
| 86 | 88 | } |
| 87 | 89 | |
| 88 | 90 | @Override |
| 89 | - public void reverse(Serializable serializable, Object o) throws Exception { | |
| 91 | + public void reverse(Serializable context, Object o) throws Exception { | |
| 92 | + RepeatBcInfo repeatBcInfo = (RepeatBcInfo) context; | |
| 93 | + SchedulePlanInfo schedulePlanInfo = (SchedulePlanInfo) o; | |
| 90 | 94 | |
| 95 | + String key = schedulePlanInfo.getLp() + "_" + schedulePlanInfo.getFcsj(); | |
| 96 | + repeatBcInfo.lpBcFcsjCount.remove(key); | |
| 97 | + | |
| 98 | + if (!repeatBcInfo.validInfoList.isEmpty()) { // 全部清空 | |
| 99 | + repeatBcInfo.validInfoList.clear(); | |
| 100 | + } | |
| 91 | 101 | } |
| 92 | 102 | |
| 93 | 103 | @Override | ... | ... |
src/main/resources/rules/shiftloop_fb_2.drl
| ... | ... | @@ -88,7 +88,9 @@ rule "calcu_days_1_" |
| 88 | 88 | String ruleMd5 = Md5Util.getMd5( |
| 89 | 89 | String.valueOf($qyrq.getMillis()) + |
| 90 | 90 | "_" + |
| 91 | - $sri.getSelf().getLpIds() | |
| 91 | + $sri.getSelf().getLpIds() + | |
| 92 | + "_" + | |
| 93 | + $sri.getSelf().getLpStart().toString() | |
| 92 | 94 | ); |
| 93 | 95 | cdrp.setRuleMd5(ruleMd5); |
| 94 | 96 | // 人员范围个数 |
| ... | ... | @@ -136,7 +138,9 @@ rule "calcu_days_2_" |
| 136 | 138 | String ruleMd5 = Md5Util.getMd5( |
| 137 | 139 | String.valueOf($qyrq.getMillis()) + |
| 138 | 140 | "_" + |
| 139 | - $sri.getSelf().getLpIds() | |
| 141 | + $sri.getSelf().getLpIds() + | |
| 142 | + "_" + | |
| 143 | + $sri.getSelf().getLpStart().toString() | |
| 140 | 144 | ); |
| 141 | 145 | cdrp.setRuleMd5(ruleMd5); |
| 142 | 146 | // 人员范围个数 |
| ... | ... | @@ -187,7 +191,9 @@ rule "Calcu_SchedulePlanRuleResult_wrap" |
| 187 | 191 | String md5 = Md5Util.getMd5( |
| 188 | 192 | String.valueOf($sprr.getQyrq().getTime()) + |
| 189 | 193 | "_" + |
| 190 | - $sprr.getGids() | |
| 194 | + $sprr.getGids() + | |
| 195 | + "_" + | |
| 196 | + $sprr.getOrigingidindex() | |
| 191 | 197 | ); |
| 192 | 198 | |
| 193 | 199 | // System.out.println("修改后的md5:" + md5 + "车辆:" + $sprr.getCcZbh()); |
| ... | ... | @@ -350,7 +356,7 @@ rule "Calcu_loop2_1_" // 路牌在时刻表中存在,就翻 |
| 350 | 356 | schedulePlanRuleResult.setRuleId($ruleId); |
| 351 | 357 | schedulePlanRuleResult.setCcId($cid); |
| 352 | 358 | schedulePlanRuleResult.setCcZbh($srf.getCarConfigInfo().getCl().getInsideCode()); |
| 353 | - schedulePlanRuleResult.setGids($srf.getLpIds()); | |
| 359 | + schedulePlanRuleResult.setGids($srf.getLpIds()); // 参与md5计算 | |
| 354 | 360 | schedulePlanRuleResult.setGnames($srf.getLpNames()); |
| 355 | 361 | schedulePlanRuleResult.setGidindex(String.valueOf($lpindex)); |
| 356 | 362 | schedulePlanRuleResult.setEcids($srf.getRyConfigIds()); |
| ... | ... | @@ -359,7 +365,8 @@ rule "Calcu_loop2_1_" // 路牌在时刻表中存在,就翻 |
| 359 | 365 | schedulePlanRuleResult.setScheduleDate($csd2.toDate()); |
| 360 | 366 | schedulePlanRuleResult.setTtinfoId($ttinfoId); |
| 361 | 367 | schedulePlanRuleResult.setTtinfoName($ttinfoName); |
| 362 | - schedulePlanRuleResult.setQyrq($sri.getQyrq().toDate()); | |
| 368 | + schedulePlanRuleResult.setQyrq($sri.getQyrq().toDate()); // 参与md5计算 | |
| 369 | + schedulePlanRuleResult.setOrigingidindex(String.valueOf($sri.getSelf().getLpStart())); // 参与md5计算 | |
| 363 | 370 | |
| 364 | 371 | scheduleResult.getSchedulePlanRuleResults().add(schedulePlanRuleResult); |
| 365 | 372 | ... | ... |
src/main/resources/rules/validplan.drl
| ... | ... | @@ -46,11 +46,11 @@ rule "Valid_repeat_bc" // 验证是否存在重复班次 |
| 46 | 46 | when |
| 47 | 47 | $lp: Loop_param($sd: start_date, $ed: end_date) |
| 48 | 48 | eval($sd.isBefore($ed) || $sd.isEqual($ed)) |
| 49 | - $spiList: ArrayList() from collect (SchedulePlanInfo(scheduleDate.getTime() == $sd.millis)) | |
| 49 | + $spiList: ArrayList() from collect (SchedulePlanInfo(scheduleDate.getTime() == $sd.getMillis())) | |
| 50 | 50 | $infos: ArrayList() from accumulate ($spi: SchedulePlanInfo() from $spiList, vrb($spi)) |
| 51 | 51 | then |
| 52 | 52 | // TODO: |
| 53 | -// log.info("日期={},班次重复错误数={}", $sd, $infos.size()); | |
| 53 | + log.info("日期={},班次重复错误数={}", $sd, $infos.size()); | |
| 54 | 54 | |
| 55 | 55 | validResult.getInfos().addAll($infos); |
| 56 | 56 | ... | ... |
src/test/resources/testdata/test6.txt
| ... | ... | @@ -7,6 +7,13 @@ update bsth_c_s_sp_rule_rst a |
| 7 | 7 | set a.qyrq = (select qyrq from bsth_c_s_sr1_flat where id = a.rule_id) |
| 8 | 8 | where a.qyrq is null; |
| 9 | 9 | |
| 10 | +select * from bsth_c_s_sp_rule_rst | |
| 11 | +where origingidindex is null; | |
| 12 | + | |
| 13 | +update bsth_c_s_sp_rule_rst a | |
| 14 | +set a.origingidindex = (select lp_start from bsth_c_s_sr1_flat where id = a.rule_id) | |
| 15 | +where a.origingidindex is null; | |
| 16 | + | |
| 10 | 17 | 970 |
| 11 | 18 | 789 |
| 12 | 19 | 604 | ... | ... |