Commit c1c24590766859f71a0fc157f0f536b23907e9bb

Authored by 徐烜
1 parent 0b686385

Update

src/main/java/com/bsth/service/schedule/rules/shiftloop/GidFbFcnoFunction.java 0 → 100644
  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 +
  8 +/**
  9 + * 时刻表路牌下的分班班次发车顺序号。
  10 + */
  11 +public class GidFbFcnoFunction implements AccumulateFunction {
  12 + @Override
  13 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  14 + }
  15 +
  16 + @Override
  17 + public void writeExternal(ObjectOutput out) throws IOException {
  18 + }
  19 +
  20 + protected static class GidFbInfoData implements Externalizable {
  21 + public Integer fbfcno;
  22 + public TTInfoDetail ttInfoDetail;
  23 +
  24 + public GidFbInfoData() {}
  25 +
  26 + @Override
  27 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  28 + fbfcno = (Integer) in.readObject();
  29 + ttInfoDetail = (TTInfoDetail) in.readObject();
  30 + }
  31 +
  32 + @Override
  33 + public void writeExternal(ObjectOutput out) throws IOException {
  34 + out.writeObject(fbfcno);
  35 + out.writeObject(ttInfoDetail);
  36 + }
  37 + }
  38 +
  39 + @Override
  40 + public Serializable createContext() {
  41 + return new GidFbInfoData();
  42 + }
  43 +
  44 + @Override
  45 + public void init(Serializable context) throws Exception {
  46 + GidFbInfoData gidFbInfoData = (GidFbInfoData) context;
  47 + gidFbInfoData.fbfcno = 999;
  48 + }
  49 +
  50 + @Override
  51 + public void accumulate(Serializable context, Object value) {
  52 + GidFbInfoData gidFbInfoData = (GidFbInfoData) context;
  53 + TTInfoDetail ttInfoDetail = (TTInfoDetail) value;
  54 +
  55 + // 1块路牌有多个分班班次,取最早的时间作为起始分班班次发车顺序号
  56 + if (ttInfoDetail.getIsFB()) {
  57 + if (ttInfoDetail.getFcno() <= gidFbInfoData.fbfcno) {
  58 + gidFbInfoData.fbfcno = ttInfoDetail.getFcno();
  59 + }
  60 + }
  61 + }
  62 +
  63 + @Override
  64 + public void reverse(Serializable serializable, Object o) throws Exception {
  65 +
  66 + }
  67 +
  68 + @Override
  69 + public boolean supportsReverse() {
  70 + return false;
  71 + }
  72 +
  73 + @Override
  74 + public Class<?> getResultType() {
  75 + return Integer.class;
  76 + }
  77 +
  78 + @Override
  79 + public Object getResult(Serializable context) throws Exception {
  80 + GidFbInfoData gidFbInfoData = (GidFbInfoData) context;
  81 +
  82 + return gidFbInfoData.fbfcno;
  83 + }
  84 +
  85 +}
src/main/java/com/bsth/service/schedule/rules/shiftloop/readme.txt deleted 100644 → 0
1 -翻班循环规则  
2 \ No newline at end of file 0 \ No newline at end of file
src/main/resources/rules/functions.drl
@@ -3,6 +3,7 @@ package com.bsth.service.schedule; @@ -3,6 +3,7 @@ package com.bsth.service.schedule;
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; 5 import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime;
  6 +import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbFcnoFunction gidfbfcno;
6 import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult; 7 import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult;
7 import accumulate com.bsth.service.schedule.rules.ttinfo.MinRuleQyrqFunction minruleqyrq; 8 import accumulate com.bsth.service.schedule.rules.ttinfo.MinRuleQyrqFunction minruleqyrq;
8 import accumulate com.bsth.service.schedule.rules.validate.ValidRepeatBcFunction vrb; 9 import accumulate com.bsth.service.schedule.rules.validate.ValidRepeatBcFunction vrb;
9 \ No newline at end of file 10 \ No newline at end of file
src/main/resources/rules/plan.drl
@@ -224,6 +224,7 @@ declare TTInfo_gid_stat @@ -224,6 +224,7 @@ declare TTInfo_gid_stat
224 maxFcno: Integer // 最大发车顺序号 224 maxFcno: Integer // 最大发车顺序号
225 225
226 fbTime: LocalTime // 分班时间 226 fbTime: LocalTime // 分班时间
  227 + fbfcno: Integer // 分班发车顺序号
227 end 228 end
228 229
229 rule "calcu_TTInfo_gid_stat" 230 rule "calcu_TTInfo_gid_stat"
@@ -234,6 +235,7 @@ rule &quot;calcu_TTInfo_gid_stat&quot; @@ -234,6 +235,7 @@ rule &quot;calcu_TTInfo_gid_stat&quot;
234 $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd)) 235 $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd))
235 $gid: String() from $gids 236 $gid: String() from $gids
236 $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd)) 237 $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd))
  238 + $fbfcno: Integer() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbfcno($ttd))
237 $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno())) 239 $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno()))
238 then 240 then
239 TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat(); 241 TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat();
@@ -243,11 +245,12 @@ rule &quot;calcu_TTInfo_gid_stat&quot; @@ -243,11 +245,12 @@ rule &quot;calcu_TTInfo_gid_stat&quot;
243 245
244 ttInfo_gid_stat.setMaxFcno($maxfcno.intValue()); 246 ttInfo_gid_stat.setMaxFcno($maxfcno.intValue());
245 ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str)); 247 ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str));
  248 + ttInfo_gid_stat.setFbfcno($fbfcno);
246 249
247 insert(ttInfo_gid_stat); 250 insert(ttInfo_gid_stat);
248 251
249 -// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}",  
250 -// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime()); 252 +// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={},fbfcno={}",
  253 +// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime(), ttInfo_gid_stat.getFbfcno());
251 254
252 end 255 end
253 256
@@ -304,7 +307,10 @@ rule &quot;calcu_TTInfoDetail_Wraps&quot; @@ -304,7 +307,10 @@ rule &quot;calcu_TTInfoDetail_Wraps&quot;
304 307
305 LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj()); 308 LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj());
306 LocalTime fbsj = ttInfo_gid_stat.getFbTime(); 309 LocalTime fbsj = ttInfo_gid_stat.getFbTime();
307 - ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj))); 310 + Integer fbfcno = ttInfo_gid_stat.getFbfcno();
  311 + // 不用时间判定,因为有的路牌,后面的班次都是凌晨的,时间反而比分班时间早,不合理,所以使用发车顺序号做第二次比较
  312 +// ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
  313 + ttInfoDetail_wrap.setIsFb(fbsj == null ? false : ttInfoDetail.getFcno() >= fbfcno);
308 314
309 ttInfoDetail_wrap.setSelf(ttInfoDetail); 315 ttInfoDetail_wrap.setSelf(ttInfoDetail);
310 316