Commit 829cc48882537441f217dfd668ee771a9f7fdde4
Merge branch 'minhang' of
http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
Showing
10 changed files
with
123 additions
and
20 deletions
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
| ... | ... | @@ -56,15 +56,15 @@ public class CorrectSignalHandle extends SignalHandle { |
| 56 | 56 | //gps=非营运 或走向不对 && 班次=非空驶 ;切换到营运状态 |
| 57 | 57 | if((!gps.isService() || gps.getUpDown() != updown) && |
| 58 | 58 | !dayOfSchedule.emptyService(task)){ |
| 59 | - gpsStatusManager.changeServiceState(gps.getNbbm(), updown, 0, "系统@同步"); | |
| 59 | + gpsStatusManager.changeServiceState(gps.getNbbm(), updown, 0, "同步@系统"); | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | //需要切换线路 |
| 63 | 63 | if(!task.getXlBm().equals(gps.getLineId())){ |
| 64 | - gpsStatusManager.changeLine(gps.getNbbm(), task.getXlBm(), "系统@同步"); | |
| 64 | + gpsStatusManager.changeLine(gps.getNbbm(), task.getXlBm(), "同步@系统"); | |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return true; |
| 69 | 69 | } |
| 70 | -} | |
| 70 | +} | |
| 71 | 71 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata/status_manager/gps_line_state/LineStateHandle.java
| ... | ... | @@ -31,7 +31,7 @@ public class LineStateHandle { |
| 31 | 31 | /** 重发次数 */ |
| 32 | 32 | private final static int MAX_SEND_COUNT=3; |
| 33 | 33 | /** 重发间隔 */ |
| 34 | - private final static int SEND_SPACE=1000 * 60 * 5; | |
| 34 | + private final static int SEND_SPACE=1000 * 60 * 4; | |
| 35 | 35 | /** 最大有效时间 */ |
| 36 | 36 | private final static int MAX_AVAIL_TIME=1000 * 60 * 60 * 2; |
| 37 | 37 | ... | ... |
src/main/java/com/bsth/data/gpsdata/status_manager/gps_service_state/ServiceStateHandle.java
| ... | ... | @@ -13,7 +13,7 @@ import java.util.Collection; |
| 13 | 13 | import java.util.concurrent.ConcurrentHashMap; |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * 设备营运状态处理 | |
| 16 | + * 设备营运状态/上下行 处理 | |
| 17 | 17 | * Created by panzhao on 2017/7/13. |
| 18 | 18 | */ |
| 19 | 19 | @Component |
| ... | ... | @@ -31,9 +31,9 @@ public class ServiceStateHandle { |
| 31 | 31 | /** 重发次数 */ |
| 32 | 32 | private final static int MAX_SEND_COUNT=3; |
| 33 | 33 | /** 重发间隔 */ |
| 34 | - private final static int SEND_SPACE=1000 * 60 * 4; | |
| 34 | + private final static int SEND_SPACE=1000 * 60 * 3; | |
| 35 | 35 | /** 最大有效时间 */ |
| 36 | - private final static int MAX_AVAIL_TIME=1000 * 60 * 60; | |
| 36 | + private final static int MAX_AVAIL_TIME=1000 * 60 * 50; | |
| 37 | 37 | |
| 38 | 38 | static{ |
| 39 | 39 | map = new ConcurrentHashMap(); |
| ... | ... | @@ -67,9 +67,9 @@ public class ServiceStateHandle { |
| 67 | 67 | if(gps == null) |
| 68 | 68 | return; |
| 69 | 69 | |
| 70 | - if(gps.getState().equals(sb.getState())){ | |
| 70 | + if(gps.getState().equals(sb.getState()) && gps.getUpDown() == sb.getUpDown()){ | |
| 71 | 71 | map.remove(sb.getNbbm()); |
| 72 | - logger.info("营运状态切换成功," + sb.getNbbm() + "、" + sb.getState()); | |
| 72 | + logger.info("状态切换成功," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getUpDown()); | |
| 73 | 73 | } |
| 74 | 74 | else |
| 75 | 75 | reSend(sb); |
| ... | ... | @@ -88,14 +88,14 @@ public class ServiceStateHandle { |
| 88 | 88 | long diff = System.currentTimeMillis() - sb.getSt(); |
| 89 | 89 | if(diff >= MAX_AVAIL_TIME){ |
| 90 | 90 | map.remove(sb.getNbbm()); |
| 91 | - logger.info("营运状态切换超过有效时间," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getSt()); | |
| 91 | + logger.info("状态切换超过有效时间," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getSt()); | |
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | if(diff >= SEND_SPACE){ |
| 96 | 96 | sb.setSender("补发@系统"); |
| 97 | 97 | changeState(sb); |
| 98 | - logger.info("重发营运状态切换指令," + sb.getNbbm() + "、" + sb.getState()); | |
| 98 | + logger.info("重发状态切换指令," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getUpDown()); | |
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java
| ... | ... | @@ -154,6 +154,7 @@ public class GpsDataLoaderThread extends Thread { |
| 154 | 154 | CloseableHttpResponse response = null; |
| 155 | 155 | |
| 156 | 156 | try { |
| 157 | + logger.error("load start..."); | |
| 157 | 158 | httpClient = HttpClients.createDefault(); |
| 158 | 159 | HttpGet get = new HttpGet(clientUrl); |
| 159 | 160 | //超时时间 |
| ... | ... | @@ -174,6 +175,7 @@ public class GpsDataLoaderThread extends Thread { |
| 174 | 175 | |
| 175 | 176 | list = JSON.parseArray(stringBuffer.toString(), GpsEntity.class); |
| 176 | 177 | String nbbm; |
| 178 | + logger.error("load end!"); | |
| 177 | 179 | for (GpsEntity gps : list) { |
| 178 | 180 | |
| 179 | 181 | //没有设备号 | ... | ... |
src/main/java/com/bsth/entity/search/PredicatesBuilder.java
| ... | ... | @@ -34,7 +34,16 @@ public class PredicatesBuilder { |
| 34 | 34 | Class<?> leftType = expression.getJavaType(); |
| 35 | 35 | Class<?> rightType = object.getClass(); |
| 36 | 36 | |
| 37 | - if (Number.class.isAssignableFrom(leftType) && | |
| 37 | + if(Date.class.isAssignableFrom(leftType) && | |
| 38 | + String.class.isAssignableFrom(rightType)){ | |
| 39 | + DateTime dateTime = new DateTime(object); | |
| 40 | + return cb.equal(expression, dateTime.toDate()); | |
| 41 | + } | |
| 42 | + else { | |
| 43 | + return cb.equal(expression, object); | |
| 44 | + } | |
| 45 | + | |
| 46 | + /*if (Number.class.isAssignableFrom(leftType) && | |
| 38 | 47 | (Number.class.isAssignableFrom(rightType) || String.class.isAssignableFrom(rightType))) { // Number == Number/String |
| 39 | 48 | return cb.equal(expression, object); |
| 40 | 49 | } else if (String.class.isAssignableFrom(leftType) && |
| ... | ... | @@ -52,8 +61,7 @@ public class PredicatesBuilder { |
| 52 | 61 | return cb.equal(expression, dateTime.toDate()); |
| 53 | 62 | } else { |
| 54 | 63 | throw new RuntimeException("eq 不支持类型组合:" + expression.getJavaType() + "==" + object.getClass()); |
| 55 | - } | |
| 56 | - | |
| 64 | + }*/ | |
| 57 | 65 | } |
| 58 | 66 | |
| 59 | 67 | public static Predicate ne(CriteriaBuilder cb,Path<?> expression, Object object){ | ... | ... |
src/main/java/com/bsth/service/forecast/SampleServiceImpl.java
| ... | ... | @@ -37,10 +37,12 @@ public class SampleServiceImpl extends BaseServiceImpl<Sample, Long> implements |
| 37 | 37 | //转换站点名称 |
| 38 | 38 | Iterator<Sample> iterator = rs.iterator(); |
| 39 | 39 | Sample s; |
| 40 | + String prefix; | |
| 40 | 41 | while(iterator.hasNext()){ |
| 41 | 42 | s = iterator.next(); |
| 42 | - s.setsName(BasicData.stationCode2NameMap.get(s.getsStation())); | |
| 43 | - s.seteName(BasicData.stationCode2NameMap.get(s.geteStation())); | |
| 43 | + prefix = s.getLineCode() + "_" + s.getUpdown() + "_"; | |
| 44 | + s.setsName(BasicData.getStationNameByCode(s.getsStation(), prefix)); | |
| 45 | + s.seteName(BasicData.getStationNameByCode(s.geteStation(), prefix)); | |
| 44 | 46 | |
| 45 | 47 | rsList.add(s); |
| 46 | 48 | } | ... | ... |
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
src/main/resources/rules/functions.drl
| ... | ... | @@ -3,6 +3,7 @@ package com.bsth.service.schedule; |
| 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 | 5 | import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime; |
| 6 | +import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbFcnoFunction gidfbfcno; | |
| 6 | 7 | import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult; |
| 7 | 8 | import accumulate com.bsth.service.schedule.rules.ttinfo.MinRuleQyrqFunction minruleqyrq; |
| 8 | 9 | import accumulate com.bsth.service.schedule.rules.validate.ValidRepeatBcFunction vrb; |
| 9 | 10 | \ No newline at end of file | ... | ... |
src/main/resources/rules/plan.drl
| ... | ... | @@ -224,6 +224,7 @@ declare TTInfo_gid_stat |
| 224 | 224 | maxFcno: Integer // 最大发车顺序号 |
| 225 | 225 | |
| 226 | 226 | fbTime: LocalTime // 分班时间 |
| 227 | + fbfcno: Integer // 分班发车顺序号 | |
| 227 | 228 | end |
| 228 | 229 | |
| 229 | 230 | rule "calcu_TTInfo_gid_stat" |
| ... | ... | @@ -234,6 +235,7 @@ rule "calcu_TTInfo_gid_stat" |
| 234 | 235 | $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd)) |
| 235 | 236 | $gid: String() from $gids |
| 236 | 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 | 239 | $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno())) |
| 238 | 240 | then |
| 239 | 241 | TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat(); |
| ... | ... | @@ -243,11 +245,12 @@ rule "calcu_TTInfo_gid_stat" |
| 243 | 245 | |
| 244 | 246 | ttInfo_gid_stat.setMaxFcno($maxfcno.intValue()); |
| 245 | 247 | ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str)); |
| 248 | + ttInfo_gid_stat.setFbfcno($fbfcno); | |
| 246 | 249 | |
| 247 | 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 | 255 | end |
| 253 | 256 | |
| ... | ... | @@ -304,7 +307,10 @@ rule "calcu_TTInfoDetail_Wraps" |
| 304 | 307 | |
| 305 | 308 | LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj()); |
| 306 | 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 | 315 | ttInfoDetail_wrap.setSelf(ttInfoDetail); |
| 310 | 316 | ... | ... |