Commit 82e7e545276961d8545216d9f16d745383a22dd3
1 parent
7a7c9b2a
update...
Showing
11 changed files
with
79 additions
and
36 deletions
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
| ... | ... | @@ -67,6 +67,8 @@ public class DataHandleProcess { |
| 67 | 67 | //数据均分给线程 |
| 68 | 68 | ArrayListMultimap dataListMap = ArrayListMultimap.create(); |
| 69 | 69 | int size = deviceList.size(), threadIndex = 0, threadSize = size / POOL_SIZE; |
| 70 | + if(threadSize==0) | |
| 71 | + threadSize = size; | |
| 70 | 72 | for (int i = 0; i < size; i++) { |
| 71 | 73 | if (i % threadSize == 0) |
| 72 | 74 | threadIndex++; |
| ... | ... | @@ -78,7 +80,6 @@ public class DataHandleProcess { |
| 78 | 80 | |
| 79 | 81 | logger.info(JSON.toJSONString(ks)); |
| 80 | 82 | for (Integer index : ks) { |
| 81 | - //logger.info("execute index: " + index); | |
| 82 | 83 | threadPool.execute(new SignalHandleThread(dataListMap.get(index), count)); |
| 83 | 84 | } |
| 84 | 85 | |
| ... | ... | @@ -112,20 +113,17 @@ public class DataHandleProcess { |
| 112 | 113 | public void run() { |
| 113 | 114 | try { |
| 114 | 115 | Collections.sort(list, comp); |
| 115 | - //logger.info("sort end --" + Thread.currentThread().getName() + " -list size: " + list.size()); | |
| 116 | - | |
| 117 | 116 | GpsEntity gps; |
| 118 | 117 | for(int i = 0,len = list.size(); i< len ;i ++){ |
| 119 | 118 | gps = list.get(i); |
| 120 | 119 | |
| 121 | - //logger.info("run |--" + Thread.currentThread().getName() + " -i: " + i); | |
| 122 | 120 | try { |
| 123 | 121 | if (StringUtils.isEmpty(gps.getNbbm())) |
| 124 | 122 | continue; |
| 125 | 123 | if (Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20) |
| 126 | 124 | continue; |
| 127 | 125 | |
| 128 | - gpsStateProcess.process(gps);//状态处理 | |
| 126 | + //gpsStateProcess.process(gps);//状态处理 | |
| 129 | 127 | stationInsideProcess.process(gps);//场站内外判定 |
| 130 | 128 | reverseRouteProcess.process(gps);//反向路由处理 |
| 131 | 129 | abnormalStateProcess.process(gps);//超速越界 |
| ... | ... | @@ -134,20 +132,14 @@ public class DataHandleProcess { |
| 134 | 132 | outStationProcess.process(gps);//出站 |
| 135 | 133 | |
| 136 | 134 | |
| 137 | - //logger.info("put start --" + Thread.currentThread().getName() + " -i: " + i); | |
| 138 | 135 | GpsCacheData.putGps(gps);//历史gps缓存 |
| 139 | - //logger.info("put end --" + Thread.currentThread().getName() + " -i: " + i); | |
| 140 | 136 | } catch (Throwable e) { |
| 141 | 137 | logger.error("", e); |
| 142 | 138 | } |
| 143 | 139 | } |
| 144 | - | |
| 145 | - //logger.info("for end --" + Thread.currentThread().getName() + " -list size: " + list.size()); | |
| 146 | - | |
| 147 | 140 | } finally { |
| 148 | 141 | if (count != null) |
| 149 | 142 | count.countDown(); |
| 150 | - //logger.info(Thread.currentThread().getName() + " -countDown : " + count.getCount()); | |
| 151 | 143 | } |
| 152 | 144 | } |
| 153 | 145 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
| ... | ... | @@ -164,19 +164,23 @@ public class InStationProcess { |
| 164 | 164 | //将gps转换成下一个班次走向的站内信号(应对只有一个站内信号 即 发出时) |
| 165 | 165 | transformUpDown(gps, next); |
| 166 | 166 | |
| 167 | - //下发调度指令 | |
| 168 | - DirectivePushQueue.put6002(next, doneSum, "到站@系统"); | |
| 169 | - | |
| 170 | 167 | //套跑 -下发线路切换指令 |
| 171 | 168 | if (null != next && !next.getXlBm().equals(sch.getXlBm())) { |
| 172 | 169 | gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "套跑@系统"); |
| 173 | 170 | } |
| 174 | 171 | |
| 172 | + /** | |
| 173 | + * 注意: | |
| 174 | + * 要先发运营指令,再发调度指令 | |
| 175 | + */ | |
| 176 | + if(null == next && gps.isService()){ | |
| 177 | + nonService(sch, "结束@系统");//营运结束 | |
| 178 | + } | |
| 179 | + //下发运营指令 | |
| 180 | + DirectivePushQueue.put6003(next, "到站@系统"); | |
| 175 | 181 | |
| 176 | - if (null == next && gps.isService()) | |
| 177 | - nonService(sch, "结束@系统");//班次结束 | |
| 178 | - else if (null != next && dayOfSchedule.emptyService(next)) | |
| 179 | - nonService(sch, "空驶@系统");//下一班非营运 | |
| 182 | + //下发调度指令 | |
| 183 | + DirectivePushQueue.put6002(next, doneSum, "到站@系统", ""); | |
| 180 | 184 | } |
| 181 | 185 | |
| 182 | 186 | /** | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/rfid/handle/RfidSignalHandle.java
| ... | ... | @@ -123,7 +123,7 @@ public class RfidSignalHandle { |
| 123 | 123 | logger.info("RFID; 车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual()); |
| 124 | 124 | |
| 125 | 125 | //下发调度指令 |
| 126 | - DirectivePushQueue.put6002(next, doneSum, "rfid@系统"); | |
| 126 | + DirectivePushQueue.put6002(next, doneSum, "rfid@系统", ""); | |
| 127 | 127 | |
| 128 | 128 | //套跑 -下发线路切换指令 |
| 129 | 129 | if(null != next && !next.getXlBm().equals(sch.getXlBm())){ | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/status_manager/gps_service_state/ServiceStateHandle.java
| ... | ... | @@ -11,6 +11,7 @@ import org.springframework.stereotype.Component; |
| 11 | 11 | |
| 12 | 12 | import java.util.Collection; |
| 13 | 13 | import java.util.concurrent.ConcurrentHashMap; |
| 14 | +import java.util.concurrent.ConcurrentMap; | |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * 设备营运状态/上下行 处理 |
| ... | ... | @@ -19,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; |
| 19 | 20 | @Component |
| 20 | 21 | public class ServiceStateHandle { |
| 21 | 22 | |
| 22 | - private static ConcurrentHashMap<String, StateBean> map; | |
| 23 | + private static ConcurrentMap<String, StateBean> map; | |
| 23 | 24 | |
| 24 | 25 | @Autowired |
| 25 | 26 | DirectiveService directiveService; | ... | ... |
src/main/java/com/bsth/data/msg_queue/DirectivePushQueue.java
| 1 | 1 | package com.bsth.data.msg_queue; |
| 2 | 2 | |
| 3 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 3 | 4 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 4 | 5 | import com.bsth.service.directive.DirectiveService; |
| 5 | 6 | import org.slf4j.Logger; |
| ... | ... | @@ -9,7 +10,9 @@ import org.springframework.context.ApplicationContext; |
| 9 | 10 | import org.springframework.context.ApplicationContextAware; |
| 10 | 11 | import org.springframework.stereotype.Component; |
| 11 | 12 | |
| 13 | +import java.util.concurrent.ConcurrentHashMap; | |
| 12 | 14 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 15 | +import java.util.concurrent.ConcurrentMap; | |
| 13 | 16 | |
| 14 | 17 | /** |
| 15 | 18 | * 到网关的指令推送队列 (系统发送的队列, 用户手动发送的不走这里) |
| ... | ... | @@ -22,13 +25,23 @@ public class DirectivePushQueue implements ApplicationContextAware { |
| 22 | 25 | static DataPushThread thread; |
| 23 | 26 | static DirectiveService directiveService; |
| 24 | 27 | static long t; |
| 25 | - static final int IDLE_TIME = 1000 * 30; | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 下发运营指令6003的最小间隔时间 | |
| 31 | + */ | |
| 32 | + static final int MIN_SEND6003_SPACE = 1000 * 60; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 车辆 ——> 上次下发6003的时间 | |
| 36 | + */ | |
| 37 | + static ConcurrentMap<String, Long> lastSend6003Map; | |
| 26 | 38 | |
| 27 | 39 | static { |
| 28 | 40 | linkedList = new ConcurrentLinkedQueue<>(); |
| 41 | + lastSend6003Map = new ConcurrentHashMap<>(); | |
| 29 | 42 | } |
| 30 | 43 | |
| 31 | - public static void put6002(ScheduleRealInfo sch, int finish, String sender){ | |
| 44 | + public static void put6002(ScheduleRealInfo sch, int finish, String sender, String txtPrefix){ | |
| 32 | 45 | if(null == sch) |
| 33 | 46 | return; |
| 34 | 47 | QueueData_Directive qd6002 = new QueueData_Directive(); |
| ... | ... | @@ -36,21 +49,34 @@ public class DirectivePushQueue implements ApplicationContextAware { |
| 36 | 49 | qd6002.setFinish(finish); |
| 37 | 50 | qd6002.setSender(sender); |
| 38 | 51 | qd6002.setCode("60_02"); |
| 52 | + qd6002.setTxtPrefix(txtPrefix); | |
| 39 | 53 | |
| 40 | 54 | linkedList.add(qd6002); |
| 41 | 55 | } |
| 42 | 56 | |
| 43 | 57 | public static void put6003(String nbbm, int state, int upDown, String sender){ |
| 58 | + long t = System.currentTimeMillis(); | |
| 59 | + if(lastSend6003Map.containsKey(nbbm) | |
| 60 | + && t - lastSend6003Map.get(nbbm) < MIN_SEND6003_SPACE) | |
| 61 | + return; //最短下发间隔 | |
| 62 | + | |
| 44 | 63 | QueueData_Directive qd6003 = new QueueData_Directive(); |
| 45 | 64 | qd6003.setNbbm(nbbm); |
| 46 | 65 | qd6003.setState(state); |
| 47 | 66 | qd6003.setUpDown(upDown); |
| 48 | - //qd6003.setSch(sch); | |
| 49 | 67 | qd6003.setSender(sender); |
| 50 | - | |
| 51 | 68 | qd6003.setCode("60_03"); |
| 52 | 69 | |
| 53 | 70 | linkedList.add(qd6003); |
| 71 | + lastSend6003Map.put(nbbm, t); | |
| 72 | + } | |
| 73 | + | |
| 74 | + public static void put6003(ScheduleRealInfo sch, String sender){ | |
| 75 | + int state = 0;//营运状态 | |
| 76 | + if(DayOfSchedule.emptyService(sch)) | |
| 77 | + state = 1; | |
| 78 | + | |
| 79 | + put6003(sch.getClZbh(), state, Integer.parseInt(sch.getXlDir()), sender); | |
| 54 | 80 | } |
| 55 | 81 | |
| 56 | 82 | public static void put64(String nbbm, String lineCode, String sender){ |
| ... | ... | @@ -64,10 +90,6 @@ public class DirectivePushQueue implements ApplicationContextAware { |
| 64 | 90 | linkedList.add(qd64); |
| 65 | 91 | } |
| 66 | 92 | |
| 67 | - public static boolean isIdle(){ | |
| 68 | - return System.currentTimeMillis() - t > IDLE_TIME; | |
| 69 | - } | |
| 70 | - | |
| 71 | 93 | public static void start(){ |
| 72 | 94 | if(thread != null){ |
| 73 | 95 | thread.interrupt(); |
| ... | ... | @@ -108,7 +130,7 @@ public class DirectivePushQueue implements ApplicationContextAware { |
| 108 | 130 | code = qd.getCode(); |
| 109 | 131 | |
| 110 | 132 | if(code.equals("60_02")){ |
| 111 | - directiveService.send60Dispatch(qd.getSch(), qd.getFinish(), qd.getSender()); | |
| 133 | + directiveService.send60Dispatch(qd.getSch(), qd.getFinish(), qd.getSender(), qd.getTxtPrefix()); | |
| 112 | 134 | log.info("directive 60_02 sch id: " + qd.getSch().getId()); |
| 113 | 135 | } |
| 114 | 136 | else if(code.equals("60_03")){ | ... | ... |
src/main/java/com/bsth/data/msg_queue/QueueData_Directive.java
| ... | ... | @@ -29,6 +29,8 @@ public class QueueData_Directive { |
| 29 | 29 | |
| 30 | 30 | private String sender; |
| 31 | 31 | |
| 32 | + private String txtPrefix; | |
| 33 | + | |
| 32 | 34 | |
| 33 | 35 | public ScheduleRealInfo getSch() { |
| 34 | 36 | return sch; |
| ... | ... | @@ -93,4 +95,12 @@ public class QueueData_Directive { |
| 93 | 95 | public void setLineCode(String lineCode) { |
| 94 | 96 | this.lineCode = lineCode; |
| 95 | 97 | } |
| 98 | + | |
| 99 | + public String getTxtPrefix() { | |
| 100 | + return txtPrefix; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public void setTxtPrefix(String txtPrefix) { | |
| 104 | + this.txtPrefix = txtPrefix; | |
| 105 | + } | |
| 96 | 106 | } | ... | ... |
src/main/java/com/bsth/data/pilot80/PilotReport.java
| ... | ... | @@ -93,7 +93,7 @@ public class PilotReport { |
| 93 | 93 | if (outSch.getJhlc() == null) |
| 94 | 94 | outSch = dayOfSchedule.next(outSch); |
| 95 | 95 | //下发调度指令 |
| 96 | - DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); | |
| 96 | + DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统", "同意出场;"); | |
| 97 | 97 | } |
| 98 | 98 | break; |
| 99 | 99 | } | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -904,6 +904,7 @@ public class DayOfSchedule { |
| 904 | 904 | public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) { |
| 905 | 905 | List<ScheduleRealInfo> ups = new ArrayList<>(); |
| 906 | 906 | |
| 907 | + String oldClZbh = sch.getClZbh(); | |
| 907 | 908 | //变更相关映射信息 |
| 908 | 909 | nbbmScheduleMap.remove(sch.getClZbh(), sch); |
| 909 | 910 | |
| ... | ... | @@ -914,7 +915,7 @@ public class DayOfSchedule { |
| 914 | 915 | |
| 915 | 916 | //重新计算车辆当前执行班次 |
| 916 | 917 | reCalcExecPlan(newClZbh); |
| 917 | - reCalcExecPlan(sch.getClZbh()); | |
| 918 | + reCalcExecPlan(oldClZbh); | |
| 918 | 919 | //重新分组计划用车 |
| 919 | 920 | reCalcLineNbbms(); |
| 920 | 921 | return ups; |
| ... | ... | @@ -935,6 +936,8 @@ public class DayOfSchedule { |
| 935 | 936 | ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list); |
| 936 | 937 | if(null != sch) |
| 937 | 938 | carExecutePlanMap.put(nbbm, sch); |
| 939 | + else | |
| 940 | + carExecutePlanMap.remove(nbbm); | |
| 938 | 941 | } |
| 939 | 942 | |
| 940 | 943 | /** | ... | ... |
src/main/java/com/bsth/service/directive/DirectiveService.java
| ... | ... | @@ -32,7 +32,7 @@ public interface DirectiveService extends BaseService<D60, Integer>{ |
| 32 | 32 | * @param @param finish 已完成的班次数 |
| 33 | 33 | * @throws |
| 34 | 34 | */ |
| 35 | - int send60Dispatch(ScheduleRealInfo sch, int finish, String sender); | |
| 35 | + int send60Dispatch(ScheduleRealInfo sch, int finish, String sender,String txtPrefix); | |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * | ... | ... |
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| ... | ... | @@ -26,6 +26,7 @@ import com.bsth.websocket.handler.RealControlSocketHandler; |
| 26 | 26 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 27 | 27 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 28 | 28 | import com.google.common.base.Splitter; |
| 29 | +import org.apache.commons.lang3.StringEscapeUtils; | |
| 29 | 30 | import org.apache.commons.lang3.StringUtils; |
| 30 | 31 | import org.joda.time.format.DateTimeFormat; |
| 31 | 32 | import org.joda.time.format.DateTimeFormatter; |
| ... | ... | @@ -78,6 +79,8 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 78 | 79 | public int send60Phrase(String nbbm, String text, String sender) { |
| 79 | 80 | D60 d60 = null; |
| 80 | 81 | try { |
| 82 | + text = StringEscapeUtils.unescapeHtml4(text); | |
| 83 | + text = text.replaceAll("#", ""); | |
| 81 | 84 | d60 = create60Data(nbbm, text, (short) 0x00, null); |
| 82 | 85 | } catch (Exception e) { |
| 83 | 86 | logger.error("发送消息短语出现异常", e); |
| ... | ... | @@ -105,7 +108,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | 110 | @Override |
| 108 | - public int send60Dispatch(ScheduleRealInfo sch, int finish, String sender) { | |
| 111 | + public int send60Dispatch(ScheduleRealInfo sch, int finish, String sender, String txtPrefix) { | |
| 109 | 112 | D60 d60 = null; |
| 110 | 113 | try { |
| 111 | 114 | if (sch.isDestroy()) { |
| ... | ... | @@ -129,8 +132,15 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 129 | 132 | long t = System.currentTimeMillis() + 1000 * 30, |
| 130 | 133 | alarmTime = sch.getDfsjT() < t?t:sch.getDfsjT(); |
| 131 | 134 | |
| 135 | + if(StringUtils.isNotEmpty(txtPrefix)){ | |
| 136 | + text = txtPrefix + text; | |
| 137 | + } | |
| 138 | + text = StringEscapeUtils.unescapeHtml4(text); | |
| 139 | + int state = 0;//营运状态 | |
| 140 | + if(dayOfSchedule.emptyService(sch)) | |
| 141 | + state = 1; | |
| 132 | 142 | d60 = new DirectiveCreator().createD60_01(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir()) |
| 133 | - , 0, new Date(alarmTime)); | |
| 143 | + , state, new Date(alarmTime)); | |
| 134 | 144 | |
| 135 | 145 | d60.setLineCode(sch.getXlBm()); |
| 136 | 146 | } catch (Exception e) { |
| ... | ... | @@ -170,6 +180,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 170 | 180 | dayOfDirectives.put60(d60, false); |
| 171 | 181 | d60Repository.save(d60); |
| 172 | 182 | } |
| 183 | + | |
| 173 | 184 | return code; |
| 174 | 185 | } |
| 175 | 186 | |
| ... | ... | @@ -196,7 +207,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 196 | 207 | ScheduleRealInfo sch = dayOfSchedule.get(id); |
| 197 | 208 | // 车辆已完成班次 |
| 198 | 209 | int finish = dayOfSchedule.doneSum(sch.getClZbh()); |
| 199 | - return send60Dispatch(sch, finish, sender); | |
| 210 | + return send60Dispatch(sch, finish, sender, ""); | |
| 200 | 211 | } |
| 201 | 212 | |
| 202 | 213 | @Override | ... | ... |
src/main/resources/static/real_control_v2/fragments/north/nav/directive_history.html
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <select name="dType"> |
| 18 | 18 | <option value="-1">全部</option> |
| 19 | 19 | <option value="3">消息短语</option> |
| 20 | - <option value="0">调度指令</option> | |
| 20 | + <option value="0" selected>调度指令</option> | |
| 21 | 21 | <option value="1">运营指令</option> |
| 22 | 22 | <option value="2">线路切换指令</option> |
| 23 | 23 | </select> | ... | ... |