Commit 829cc48882537441f217dfd668ee771a9f7fdde4

Authored by 廖磊
2 parents ad185331 de846074

Merge branch 'minhang' of

http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
@@ -56,15 +56,15 @@ public class CorrectSignalHandle extends SignalHandle { @@ -56,15 +56,15 @@ public class CorrectSignalHandle extends SignalHandle {
56 //gps=非营运 或走向不对 && 班次=非空驶 ;切换到营运状态 56 //gps=非营运 或走向不对 && 班次=非空驶 ;切换到营运状态
57 if((!gps.isService() || gps.getUpDown() != updown) && 57 if((!gps.isService() || gps.getUpDown() != updown) &&
58 !dayOfSchedule.emptyService(task)){ 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 if(!task.getXlBm().equals(gps.getLineId())){ 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 return true; 68 return true;
69 } 69 }
70 -} 70 +}
71 \ No newline at end of file 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,7 +31,7 @@ public class LineStateHandle {
31 /** 重发次数 */ 31 /** 重发次数 */
32 private final static int MAX_SEND_COUNT=3; 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 private final static int MAX_AVAIL_TIME=1000 * 60 * 60 * 2; 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,7 +13,7 @@ import java.util.Collection;
13 import java.util.concurrent.ConcurrentHashMap; 13 import java.util.concurrent.ConcurrentHashMap;
14 14
15 /** 15 /**
16 - * 设备营运状态处理 16 + * 设备营运状态/上下行 处理
17 * Created by panzhao on 2017/7/13. 17 * Created by panzhao on 2017/7/13.
18 */ 18 */
19 @Component 19 @Component
@@ -31,9 +31,9 @@ public class ServiceStateHandle { @@ -31,9 +31,9 @@ public class ServiceStateHandle {
31 /** 重发次数 */ 31 /** 重发次数 */
32 private final static int MAX_SEND_COUNT=3; 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 static{ 38 static{
39 map = new ConcurrentHashMap(); 39 map = new ConcurrentHashMap();
@@ -67,9 +67,9 @@ public class ServiceStateHandle { @@ -67,9 +67,9 @@ public class ServiceStateHandle {
67 if(gps == null) 67 if(gps == null)
68 return; 68 return;
69 69
70 - if(gps.getState().equals(sb.getState())){ 70 + if(gps.getState().equals(sb.getState()) && gps.getUpDown() == sb.getUpDown()){
71 map.remove(sb.getNbbm()); 71 map.remove(sb.getNbbm());
72 - logger.info("营运状态切换成功," + sb.getNbbm() + "、" + sb.getState()); 72 + logger.info("状态切换成功," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getUpDown());
73 } 73 }
74 else 74 else
75 reSend(sb); 75 reSend(sb);
@@ -88,14 +88,14 @@ public class ServiceStateHandle { @@ -88,14 +88,14 @@ public class ServiceStateHandle {
88 long diff = System.currentTimeMillis() - sb.getSt(); 88 long diff = System.currentTimeMillis() - sb.getSt();
89 if(diff >= MAX_AVAIL_TIME){ 89 if(diff >= MAX_AVAIL_TIME){
90 map.remove(sb.getNbbm()); 90 map.remove(sb.getNbbm());
91 - logger.info("营运状态切换超过有效时间," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getSt()); 91 + logger.info("状态切换超过有效时间," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getSt());
92 return; 92 return;
93 } 93 }
94 94
95 if(diff >= SEND_SPACE){ 95 if(diff >= SEND_SPACE){
96 sb.setSender("补发@系统"); 96 sb.setSender("补发@系统");
97 changeState(sb); 97 changeState(sb);
98 - logger.info("重发营运状态切换指令," + sb.getNbbm() + "、" + sb.getState()); 98 + logger.info("重发状态切换指令," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getUpDown());
99 return; 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,6 +154,7 @@ public class GpsDataLoaderThread extends Thread {
154 CloseableHttpResponse response = null; 154 CloseableHttpResponse response = null;
155 155
156 try { 156 try {
  157 + logger.error("load start...");
157 httpClient = HttpClients.createDefault(); 158 httpClient = HttpClients.createDefault();
158 HttpGet get = new HttpGet(clientUrl); 159 HttpGet get = new HttpGet(clientUrl);
159 //超时时间 160 //超时时间
@@ -174,6 +175,7 @@ public class GpsDataLoaderThread extends Thread { @@ -174,6 +175,7 @@ public class GpsDataLoaderThread extends Thread {
174 175
175 list = JSON.parseArray(stringBuffer.toString(), GpsEntity.class); 176 list = JSON.parseArray(stringBuffer.toString(), GpsEntity.class);
176 String nbbm; 177 String nbbm;
  178 + logger.error("load end!");
177 for (GpsEntity gps : list) { 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,7 +34,16 @@ public class PredicatesBuilder {
34 Class<?> leftType = expression.getJavaType(); 34 Class<?> leftType = expression.getJavaType();
35 Class<?> rightType = object.getClass(); 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 (Number.class.isAssignableFrom(rightType) || String.class.isAssignableFrom(rightType))) { // Number == Number/String 47 (Number.class.isAssignableFrom(rightType) || String.class.isAssignableFrom(rightType))) { // Number == Number/String
39 return cb.equal(expression, object); 48 return cb.equal(expression, object);
40 } else if (String.class.isAssignableFrom(leftType) && 49 } else if (String.class.isAssignableFrom(leftType) &&
@@ -52,8 +61,7 @@ public class PredicatesBuilder { @@ -52,8 +61,7 @@ public class PredicatesBuilder {
52 return cb.equal(expression, dateTime.toDate()); 61 return cb.equal(expression, dateTime.toDate());
53 } else { 62 } else {
54 throw new RuntimeException("eq 不支持类型组合:" + expression.getJavaType() + "==" + object.getClass()); 63 throw new RuntimeException("eq 不支持类型组合:" + expression.getJavaType() + "==" + object.getClass());
55 - }  
56 - 64 + }*/
57 } 65 }
58 66
59 public static Predicate ne(CriteriaBuilder cb,Path<?> expression, Object object){ 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&lt;Sample, Long&gt; implements @@ -37,10 +37,12 @@ public class SampleServiceImpl extends BaseServiceImpl&lt;Sample, Long&gt; implements
37 //转换站点名称 37 //转换站点名称
38 Iterator<Sample> iterator = rs.iterator(); 38 Iterator<Sample> iterator = rs.iterator();
39 Sample s; 39 Sample s;
  40 + String prefix;
40 while(iterator.hasNext()){ 41 while(iterator.hasNext()){
41 s = iterator.next(); 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 rsList.add(s); 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
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