Commit 2cf067bd749a8e2cbeff6924adc2a77bc5c2d727

Authored by 廖磊
2 parents 1499e81d d71b5a59

Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control

into pudong
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
@@ -2,9 +2,11 @@ package com.bsth.controller.realcontrol; @@ -2,9 +2,11 @@ package com.bsth.controller.realcontrol;
2 2
3 import com.bsth.data.directive.DayOfDirectives; 3 import com.bsth.data.directive.DayOfDirectives;
4 import com.bsth.data.gpsdata_v2.cache.GeoCacheData; 4 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  5 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
5 import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; 6 import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
6 import com.bsth.data.msg_queue.DirectivePushQueue; 7 import com.bsth.data.msg_queue.DirectivePushQueue;
7 import com.bsth.data.msg_queue.WebSocketPushQueue; 8 import com.bsth.data.msg_queue.WebSocketPushQueue;
  9 +import com.bsth.data.pilot80.PilotReport;
8 import com.bsth.data.schedule.DayOfSchedule; 10 import com.bsth.data.schedule.DayOfSchedule;
9 import com.bsth.entity.realcontrol.ScheduleRealInfo; 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
10 import com.bsth.websocket.handler.SendUtils; 12 import com.bsth.websocket.handler.SendUtils;
@@ -41,29 +43,32 @@ public class AdminUtilsController { @@ -41,29 +43,32 @@ public class AdminUtilsController {
41 @Autowired 43 @Autowired
42 SendUtils sendUtils; 44 SendUtils sendUtils;
43 45
  46 + @Autowired
  47 + PilotReport pilotReport;
  48 +
44 /** 49 /**
45 * 出现重复班次的车辆 50 * 出现重复班次的车辆
46 * @param 51 * @param
47 52
48 - @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)  
49 - public void schRepeat(@RequestParam String nbbm){  
50 - logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");  
51 - List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);  
52 - logger.info("检测前,车辆班次数量:" + list.size());  
53 -  
54 - Map<Long, ScheduleRealInfo> map = new HashMap<>();  
55 - for(ScheduleRealInfo sch : list){  
56 - if(map.containsKey(sch.getId())){  
57 - logger.info("检测到重复ID: " + sch.getId());  
58 - }  
59 - map.put(sch.getId(), sch);  
60 - }  
61 -  
62 - logger.info("检测后,车辆班次数量:" + list.size());  
63 - if(map.values().size() > 0){  
64 - dayOfSchedule.replaceByNbbm(nbbm, map.values());  
65 - }  
66 - }*/ 53 + @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
  54 + public void schRepeat(@RequestParam String nbbm){
  55 + logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
  56 + List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
  57 + logger.info("检测前,车辆班次数量:" + list.size());
  58 +
  59 + Map<Long, ScheduleRealInfo> map = new HashMap<>();
  60 + for(ScheduleRealInfo sch : list){
  61 + if(map.containsKey(sch.getId())){
  62 + logger.info("检测到重复ID: " + sch.getId());
  63 + }
  64 + map.put(sch.getId(), sch);
  65 + }
  66 +
  67 + logger.info("检测后,车辆班次数量:" + list.size());
  68 + if(map.values().size() > 0){
  69 + dayOfSchedule.replaceByNbbm(nbbm, map.values());
  70 + }
  71 + }*/
67 72
68 /* @RequestMapping(value = "/directivePushQueue") 73 /* @RequestMapping(value = "/directivePushQueue")
69 public void directivePushQueue(){ 74 public void directivePushQueue(){
@@ -132,10 +137,12 @@ public class AdminUtilsController { @@ -132,10 +137,12 @@ public class AdminUtilsController {
132 public Map<String, Integer> containerSize(){ 137 public Map<String, Integer> containerSize(){
133 Map<String, Integer> rs = new HashMap<>(); 138 Map<String, Integer> rs = new HashMap<>();
134 rs.put("60_size", dayOfDirectives.all60().size()); 139 rs.put("60_size", dayOfDirectives.all60().size());
  140 + rs.put("80_size", pilotReport.findAll().size());
135 rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); 141 rs.put("nbbm_sch_size", dayOfSchedule.findAll().size());
136 rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); 142 rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size());
137 rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); 143 rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size());
138 rs.put("pst_sch_size", dayOfSchedule.getPstSize()); 144 rs.put("pst_sch_size", dayOfSchedule.getPstSize());
  145 + rs.put("speeds_size", OverspeedProcess.size());
139 return rs; 146 return rs;
140 } 147 }
141 148
src/main/java/com/bsth/data/directive/DayOfDirectives.java
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
16 16
17 import java.util.*; 17 import java.util.*;
18 import java.util.concurrent.ConcurrentHashMap; 18 import java.util.concurrent.ConcurrentHashMap;
  19 +import java.util.concurrent.ConcurrentMap;
19 20
20 /** 21 /**
21 * 22 *
@@ -29,13 +30,10 @@ import java.util.concurrent.ConcurrentHashMap; @@ -29,13 +30,10 @@ import java.util.concurrent.ConcurrentHashMap;
29 public class DayOfDirectives { 30 public class DayOfDirectives {
30 31
31 // 当日60指令缓存 32 // 当日60指令缓存
32 - private static Map<Integer, D60> d60Map; 33 + private static ConcurrentMap<Integer, D60> d60Map;
33 34
34 // 线路切换指令 64 35 // 线路切换指令 64
35 - public static Map<String, D64> d64Map;  
36 -  
37 - //等待C0_A4回复的用户  
38 - //public static Map<K, V> 36 + public static ConcurrentMap<String, D64> d64Map;
39 37
40 //等待入库的指令 38 //等待入库的指令
41 public static LinkedList<Directive> pstDirectives; 39 public static LinkedList<Directive> pstDirectives;
@@ -149,9 +147,53 @@ public class DayOfDirectives { @@ -149,9 +147,53 @@ public class DayOfDirectives {
149 return; 147 return;
150 148
151 directiveService.save(d60); 149 directiveService.save(d60);
  150 + }
  151 +
  152 + public void clear(String lineCode){
  153 + int c60 = 0, c64 = 0;
  154 +
  155 + Collection<D60> d60s = d60Map.values();
  156 + List<D60> rem60List = new ArrayList<>();
  157 + for(D60 d60 : d60s){
  158 + if(d60.getLineCode().equals(lineCode))
  159 + rem60List.add(d60);
  160 + }
  161 +
  162 + //清除60数据
  163 + for(D60 d60 : rem60List){
  164 + if(d60.getReply47() == null)
  165 + directiveService.save(d60);
  166 + if(null != d60Map.remove(d60.getMsgId()))
  167 + c60 ++;
  168 + }
  169 +
  170 + rem60List.clear();
  171 + if(c60 > 0)
  172 + logger.info("清除60数据 ," + c60);
  173 +
  174 + //找到该设备的64数据
  175 + Collection<D64> d64s = d64Map.values();
  176 + List<D64> rem64List = new ArrayList<>();
  177 + for(D64 d64 : d64s){
  178 + if(d64.get)
  179 + rem64List.add(d64);
  180 + }
  181 +
  182 + //清除64数据
  183 + for(D64 d64 : rem64List){
  184 + if(d64.getRespAck() == null)
  185 + directiveService.save64(d64);
  186 +
  187 + if(null != d64Map.remove(d64.getKey()))
  188 + c64 ++;
  189 + }
  190 +
  191 + rem64List.clear();
  192 + if(c64 > 0)
  193 + logger.info("清除64数据 ," + c64);
152 }*/ 194 }*/
153 -  
154 - public void clear(String device){ 195 +
  196 +/* public void clear(String device){
155 int c60 = 0, c64 = 0; 197 int c60 = 0, c64 = 0;
156 198
157 Collection<D60> d60s = d60Map.values(); 199 Collection<D60> d60s = d60Map.values();
@@ -193,6 +235,12 @@ public class DayOfDirectives { @@ -193,6 +235,12 @@ public class DayOfDirectives {
193 rem64List.clear(); 235 rem64List.clear();
194 if(c64 > 0) 236 if(c64 > 0)
195 logger.info("清除64数据 ," + c64); 237 logger.info("清除64数据 ," + c64);
  238 + }*/
  239 +
  240 + public void clearAll(){
  241 + d60Map = new ConcurrentHashMap<>();
  242 + d64Map = new ConcurrentHashMap<>();
  243 + logger.info("清除指令数据 ,,,");
196 } 244 }
197 245
198 public Collection<D60> all60(){ 246 public Collection<D60> all60(){
src/main/java/com/bsth/data/directive/DirectiveCreator.java
@@ -81,7 +81,7 @@ public class DirectiveCreator { @@ -81,7 +81,7 @@ public class DirectiveCreator {
81 } 81 }
82 82
83 83
84 - public D60 createD60_01(String nbbm, String text, int upDown, int state, Date alarmTime){ 84 + public D60 createD60_02(String nbbm, String text, int upDown, int state, Date alarmTime){
85 SimpleDateFormat sdfMMddHHmm = new SimpleDateFormat("MMddHHmm"); 85 SimpleDateFormat sdfMMddHHmm = new SimpleDateFormat("MMddHHmm");
86 86
87 Long timestamp = System.currentTimeMillis(); 87 Long timestamp = System.currentTimeMillis();
@@ -102,7 +102,7 @@ public class DirectiveCreator { @@ -102,7 +102,7 @@ public class DirectiveCreator {
102 directive.setMsgId(msgId); 102 directive.setMsgId(msgId);
103 // 构造数据 103 // 构造数据
104 data.setDeviceId(deviceId); 104 data.setDeviceId(deviceId);
105 - data.setDispatchInstruct((short) 0x01); 105 + data.setDispatchInstruct((short) 0x02);
106 data.setTimestamp(timestamp); 106 data.setTimestamp(timestamp);
107 data.setCompanyCode(company); 107 data.setCompanyCode(company);
108 data.setMsgId(msgId); 108 data.setMsgId(msgId);
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
@@ -48,9 +48,7 @@ public class GatewayHttpUtils { @@ -48,9 +48,7 @@ public class GatewayHttpUtils {
48 48
49 int statusCode = response.getStatusLine().getStatusCode(); 49 int statusCode = response.getStatusLine().getStatusCode();
50 if(statusCode != 200){ 50 if(statusCode != 200){
51 - //post.abort();  
52 logger.error("http client status code: " + statusCode); 51 logger.error("http client status code: " + statusCode);
53 - //return code;  
54 } 52 }
55 53
56 JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); 54 JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity()));
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
@@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; @@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
13 public class GpsEntity implements Cloneable{ 13 public class GpsEntity implements Cloneable{
14 14
15 /** 公司代码 */ 15 /** 公司代码 */
  16 + @JsonIgnore
16 private Short companyCode; 17 private Short companyCode;
17 18
18 /** 线路编码 */ 19 /** 线路编码 */
@@ -31,6 +32,7 @@ public class GpsEntity implements Cloneable{ @@ -31,6 +32,7 @@ public class GpsEntity implements Cloneable{
31 private String stationName; 32 private String stationName;
32 33
33 /** 到站时间 */ 34 /** 到站时间 */
  35 + @JsonIgnore
34 private long arrTime; 36 private long arrTime;
35 37
36 /** 经度 */ 38 /** 经度 */
@@ -56,6 +58,12 @@ public class GpsEntity implements Cloneable{ @@ -56,6 +58,12 @@ public class GpsEntity implements Cloneable{
56 58
57 /** 上下行(0 上行 , 1 下行 , -1 无效) */ 59 /** 上下行(0 上行 , 1 下行 , -1 无效) */
58 private Byte upDown; 60 private Byte upDown;
  61 +
  62 + /**
  63 + * 设备原始走向_营运状态
  64 + * 当设备状态和系统不一致时,该字段有值
  65 + */
  66 + private String origStateStr;
59 67
60 /** 车辆内部编码 */ 68 /** 车辆内部编码 */
61 private String nbbm; 69 private String nbbm;
@@ -379,4 +387,12 @@ public class GpsEntity implements Cloneable{ @@ -379,4 +387,12 @@ public class GpsEntity implements Cloneable{
379 public void setPlanCode(String planCode) { 387 public void setPlanCode(String planCode) {
380 this.planCode = planCode; 388 this.planCode = planCode;
381 } 389 }
  390 +
  391 + public String getOrigStateStr() {
  392 + return origStateStr;
  393 + }
  394 +
  395 + public void setOrigStateStr(String origStateStr) {
  396 + this.origStateStr = origStateStr;
  397 + }
382 } 398 }
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java
@@ -7,6 +7,9 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; @@ -7,6 +7,9 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo;
7 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Component; 8 import org.springframework.stereotype.Component;
9 9
  10 +import java.util.concurrent.ConcurrentHashMap;
  11 +import java.util.concurrent.ConcurrentMap;
  12 +
10 /** 13 /**
11 * GPS 状态处理 14 * GPS 状态处理
12 * Created by panzhao on 2017/11/15. 15 * Created by panzhao on 2017/11/15.
@@ -20,6 +23,13 @@ public class GpsStateProcess { @@ -20,6 +23,13 @@ public class GpsStateProcess {
20 @Autowired 23 @Autowired
21 GpsStatusManager gpsStatusManager; 24 GpsStatusManager gpsStatusManager;
22 25
  26 + /**
  27 + * 设置状态差异连续次数
  28 + */
  29 + private static ConcurrentMap<String, Integer> stateDiffMap = new ConcurrentHashMap<>();
  30 +
  31 + private final static int CHANGE_THRESHOLD = 2;
  32 +
23 public void process(GpsEntity gps) { 33 public void process(GpsEntity gps) {
24 //在执行的任务 34 //在执行的任务
25 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); 35 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
@@ -27,16 +37,40 @@ public class GpsStateProcess { @@ -27,16 +37,40 @@ public class GpsStateProcess {
27 if (null == sch) 37 if (null == sch)
28 return; 38 return;
29 39
30 - byte upDown = Byte.parseByte(sch.getXlDir()); 40 + int upDown = Integer.parseInt(sch.getXlDir());
31 int schState = dayOfSchedule.emptyService(sch)?1:0; 41 int schState = dayOfSchedule.emptyService(sch)?1:0;
32 - 42 + String device = gps.getDeviceId();
  43 + /**
  44 + * 网关在进终点的时候,会直接将当前点位状态改变
  45 + * 为避免出现单个点的状态跳动,设置一下切换阈值
  46 + */
33 if(gps.getState() != schState || gps.getUpDown() != upDown){ 47 if(gps.getState() != schState || gps.getUpDown() != upDown){
34 - //下发指令纠正车载的 营运状态 和 走向  
35 - gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, schState, "同步@系统"); 48 + Integer count = 0;
  49 + if(stateDiffMap.containsKey(device))
  50 + count = stateDiffMap.get(device);
  51 +
  52 + count ++;
  53 +
  54 + if(count >= CHANGE_THRESHOLD){
  55 + //下发指令纠正车载的 营运状态 和 走向
  56 + gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, schState, "同步@系统");
  57 + count = 0;
  58 + }
  59 +
  60 + stateDiffMap.put(device, count);
  61 +
  62 + //记录原始设备状态
  63 + gps.setOrigStateStr(gps.getUpDown() + "_" + gps.getState());
36 } 64 }
  65 + else
  66 + stateDiffMap.put(device, 0);
37 67
38 if (gps.getUpDown() != upDown) { 68 if (gps.getUpDown() != upDown) {
39 - gps.setUpDown(upDown);//修正走向 69 + gps.setUpDown((byte) upDown);//修正走向
  70 + }
  71 +
  72 + if(gps.getState() != schState){
  73 + gps.setState(schState);//修正营运状态
40 } 74 }
41 75
42 if (!sch.getXlBm().equals(gps.getLineId())) { 76 if (!sch.getXlBm().equals(gps.getLineId())) {
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
@@ -144,6 +144,8 @@ public class InStationProcess { @@ -144,6 +144,8 @@ public class InStationProcess {
144 dayOfSchedule.addExecPlan(next); 144 dayOfSchedule.addExecPlan(next);
145 inStationAndInPark(sch, next);//进站既进场 145 inStationAndInPark(sch, next);//进站既进场
146 } 146 }
  147 + else
  148 + dayOfSchedule.removeExecPlan(nbbm);
147 149
148 //路牌的下一个班次,页面显示起点实际到达时间 150 //路牌的下一个班次,页面显示起点实际到达时间
149 ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch); 151 ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch);
@@ -176,9 +178,14 @@ public class InStationProcess { @@ -176,9 +178,14 @@ public class InStationProcess {
176 if(null == next && gps.isService()){ 178 if(null == next && gps.isService()){
177 nonService(sch, "结束@系统");//营运结束 179 nonService(sch, "结束@系统");//营运结束
178 } 180 }
179 - //下发运营指令  
180 - DirectivePushQueue.put6003(next, "到站@系统");  
181 181
  182 + /**
  183 + * 下一班不是全程班次的时候,下发运营指令
  184 + * 全程班次时,由网关根据进出起终点,自动切换走向
  185 +
  186 + if(null != next && !next.getBcType().equals("normal"))
  187 + DirectivePushQueue.put6003(next, "到站@系统");
  188 + */
182 //下发调度指令 189 //下发调度指令
183 DirectivePushQueue.put6002(next, doneSum, "到站@系统", ""); 190 DirectivePushQueue.put6002(next, doneSum, "到站@系统", "");
184 } 191 }
src/main/java/com/bsth/data/gpsdata_v2/handlers/overspeed/OverspeedProcess.java
@@ -43,7 +43,7 @@ public class OverspeedProcess { @@ -43,7 +43,7 @@ public class OverspeedProcess {
43 */ 43 */
44 private static Map<String, Integer> contSpeedMap; 44 private static Map<String, Integer> contSpeedMap;
45 45
46 - Logger logger = LoggerFactory.getLogger(this.getClass()); 46 + static Logger logger = LoggerFactory.getLogger(OverspeedProcess.class);
47 47
48 static{ 48 static{
49 multimap = ArrayListMultimap.create(); 49 multimap = ArrayListMultimap.create();
@@ -51,6 +51,10 @@ public class OverspeedProcess { @@ -51,6 +51,10 @@ public class OverspeedProcess {
51 realOverspeedMap = new HashMap(); 51 realOverspeedMap = new HashMap();
52 } 52 }
53 53
  54 + public static int size(){
  55 + return multimap.size();
  56 + }
  57 +
54 public static void clear(){ 58 public static void clear(){
55 multimap = null; 59 multimap = null;
56 multimap = ArrayListMultimap.create(); 60 multimap = ArrayListMultimap.create();
@@ -60,6 +64,8 @@ public class OverspeedProcess { @@ -60,6 +64,8 @@ public class OverspeedProcess {
60 64
61 realOverspeedMap = null; 65 realOverspeedMap = null;
62 realOverspeedMap = new HashMap(); 66 realOverspeedMap = new HashMap();
  67 +
  68 + logger.info("清理超速缓存数据,,,");
63 } 69 }
64 70
65 public boolean process(GpsEntity gps){ 71 public boolean process(GpsEntity gps){
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataUtils.java
@@ -15,6 +15,8 @@ public class GpsDataUtils { @@ -15,6 +15,8 @@ public class GpsDataUtils {
15 15
16 static Logger logger = LoggerFactory.getLogger(GpsDataUtils.class); 16 static Logger logger = LoggerFactory.getLogger(GpsDataUtils.class);
17 17
  18 + private final static long MAX_DIFF = 1000 * 60 * 60 * 24;
  19 +
18 /** 20 /**
19 * 过滤无效的gps点位 21 * 过滤无效的gps点位
20 * 22 *
@@ -24,9 +26,16 @@ public class GpsDataUtils { @@ -24,9 +26,16 @@ public class GpsDataUtils {
24 public static List<GpsEntity> clearInvalid(List<GpsEntity> list) { 26 public static List<GpsEntity> clearInvalid(List<GpsEntity> list) {
25 List<GpsEntity> rs = new ArrayList<>(); 27 List<GpsEntity> rs = new ArrayList<>();
26 28
  29 + long t = System.currentTimeMillis();
27 try { 30 try {
28 GpsEntity prev; 31 GpsEntity prev;
29 for (GpsEntity gps : list) { 32 for (GpsEntity gps : list) {
  33 + if(Math.abs(gps.getTimestamp() - t) > MAX_DIFF){
  34 + //尝试校准GPS时间
  35 + gps.setTimestamp(t + 1);
  36 + gps.setAbnormalStatus("timeError");
  37 + }
  38 +
30 prev = GpsRealData.get(gps.getDeviceId()); 39 prev = GpsRealData.get(gps.getDeviceId());
31 40
32 //不接收过期数据 41 //不接收过期数据
@@ -48,7 +57,7 @@ public class GpsDataUtils { @@ -48,7 +57,7 @@ public class GpsDataUtils {
48 if (rs.size() < list.size()) 57 if (rs.size() < list.size())
49 logger.info("过滤无效的点位 : " + (list.size() - rs.size())); 58 logger.info("过滤无效的点位 : " + (list.size() - rs.size()));
50 } catch (Exception e) { 59 } catch (Exception e) {
51 - logger.error("", e); 60 + logger.error("过滤GPS出现异常", e);
52 rs = list; 61 rs = list;
53 } 62 }
54 return rs; 63 return rs;
src/main/java/com/bsth/data/msg_queue/DirectivePushQueue.java
@@ -24,7 +24,7 @@ public class DirectivePushQueue implements ApplicationContextAware { @@ -24,7 +24,7 @@ public class DirectivePushQueue implements ApplicationContextAware {
24 static ConcurrentLinkedQueue<QueueData_Directive> linkedList; 24 static ConcurrentLinkedQueue<QueueData_Directive> linkedList;
25 static DataPushThread thread; 25 static DataPushThread thread;
26 static DirectiveService directiveService; 26 static DirectiveService directiveService;
27 - static long t; 27 + static long threadT;
28 28
29 /** 29 /**
30 * 下发运营指令6003的最小间隔时间 30 * 下发运营指令6003的最小间隔时间
@@ -34,11 +34,11 @@ public class DirectivePushQueue implements ApplicationContextAware { @@ -34,11 +34,11 @@ public class DirectivePushQueue implements ApplicationContextAware {
34 /** 34 /**
35 * 车辆 ——> 上次下发6003的时间 35 * 车辆 ——> 上次下发6003的时间
36 */ 36 */
37 - static ConcurrentMap<String, Long> lastSend6003Map; 37 + static ConcurrentMap<String, Long> lastSend60TimeMap;
38 38
39 static { 39 static {
40 linkedList = new ConcurrentLinkedQueue<>(); 40 linkedList = new ConcurrentLinkedQueue<>();
41 - lastSend6003Map = new ConcurrentHashMap<>(); 41 + lastSend60TimeMap = new ConcurrentHashMap<>();
42 } 42 }
43 43
44 public static void put6002(ScheduleRealInfo sch, int finish, String sender, String txtPrefix){ 44 public static void put6002(ScheduleRealInfo sch, int finish, String sender, String txtPrefix){
@@ -52,12 +52,13 @@ public class DirectivePushQueue implements ApplicationContextAware { @@ -52,12 +52,13 @@ public class DirectivePushQueue implements ApplicationContextAware {
52 qd6002.setTxtPrefix(txtPrefix); 52 qd6002.setTxtPrefix(txtPrefix);
53 53
54 linkedList.add(qd6002); 54 linkedList.add(qd6002);
  55 + lastSend60TimeMap.put(sch.getClZbh(), System.currentTimeMillis());
55 } 56 }
56 57
57 public static void put6003(String nbbm, int state, int upDown, String sender){ 58 public static void put6003(String nbbm, int state, int upDown, String sender){
58 long t = System.currentTimeMillis(); 59 long t = System.currentTimeMillis();
59 - if(lastSend6003Map.containsKey(nbbm)  
60 - && t - lastSend6003Map.get(nbbm) < MIN_SEND6003_SPACE) 60 + if(lastSend60TimeMap.containsKey(nbbm)
  61 + && t - lastSend60TimeMap.get(nbbm) < MIN_SEND6003_SPACE)
61 return; //最短下发间隔 62 return; //最短下发间隔
62 63
63 QueueData_Directive qd6003 = new QueueData_Directive(); 64 QueueData_Directive qd6003 = new QueueData_Directive();
@@ -68,7 +69,7 @@ public class DirectivePushQueue implements ApplicationContextAware { @@ -68,7 +69,7 @@ public class DirectivePushQueue implements ApplicationContextAware {
68 qd6003.setCode("60_03"); 69 qd6003.setCode("60_03");
69 70
70 linkedList.add(qd6003); 71 linkedList.add(qd6003);
71 - lastSend6003Map.put(nbbm, t); 72 + lastSend60TimeMap.put(nbbm, t);
72 } 73 }
73 74
74 public static void put6003(ScheduleRealInfo sch, String sender){ 75 public static void put6003(ScheduleRealInfo sch, String sender){
@@ -146,7 +147,7 @@ public class DirectivePushQueue implements ApplicationContextAware { @@ -146,7 +147,7 @@ public class DirectivePushQueue implements ApplicationContextAware {
146 sleepFlag = true; 147 sleepFlag = true;
147 } 148 }
148 } 149 }
149 - t = System.currentTimeMillis(); 150 + threadT = System.currentTimeMillis();
150 } 151 }
151 catch(InterruptedException e){ 152 catch(InterruptedException e){
152 log.error("", e); 153 log.error("", e);
src/main/java/com/bsth/data/safe_driv/SafeDrivCenter.java
@@ -3,6 +3,8 @@ package com.bsth.data.safe_driv; @@ -3,6 +3,8 @@ package com.bsth.data.safe_driv;
3 import com.bsth.websocket.handler.SendUtils; 3 import com.bsth.websocket.handler.SendUtils;
4 import org.joda.time.format.DateTimeFormat; 4 import org.joda.time.format.DateTimeFormat;
5 import org.joda.time.format.DateTimeFormatter; 5 import org.joda.time.format.DateTimeFormatter;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
6 import org.springframework.beans.BeansException; 8 import org.springframework.beans.BeansException;
7 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.context.ApplicationContext; 10 import org.springframework.context.ApplicationContext;
@@ -33,6 +35,8 @@ public class SafeDrivCenter implements ApplicationContextAware { @@ -33,6 +35,8 @@ public class SafeDrivCenter implements ApplicationContextAware {
33 */ 35 */
34 private static Map<String, SafeDriv> safeMap; 36 private static Map<String, SafeDriv> safeMap;
35 37
  38 + static Logger logger = LoggerFactory.getLogger(SafeDrivCenter.class);
  39 +
36 static { 40 static {
37 data = new HashSet<>(); 41 data = new HashSet<>();
38 safeMap = new HashMap<>(); 42 safeMap = new HashMap<>();
@@ -61,6 +65,7 @@ public class SafeDrivCenter implements ApplicationContextAware { @@ -61,6 +65,7 @@ public class SafeDrivCenter implements ApplicationContextAware {
61 public static void clear(){ 65 public static void clear(){
62 data = new HashSet<>(); 66 data = new HashSet<>();
63 safeMap = new HashMap<>(); 67 safeMap = new HashMap<>();
  68 + logger.info("清除安全驾驶数据,,,");
64 } 69 }
65 70
66 @Override 71 @Override
src/main/java/com/bsth/data/schedule/thread/CalcOilThread.java
1 package com.bsth.data.schedule.thread; 1 package com.bsth.data.schedule.thread;
2 2
  3 +import com.bsth.data.directive.DayOfDirectives;
3 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; 4 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
4 import com.bsth.service.oil.DlbService; 5 import com.bsth.service.oil.DlbService;
5 import com.bsth.data.safe_driv.SafeDrivCenter; 6 import com.bsth.data.safe_driv.SafeDrivCenter;
@@ -27,6 +28,9 @@ public class CalcOilThread extends Thread{ @@ -27,6 +28,9 @@ public class CalcOilThread extends Thread{
27 SheetService sheetService; 28 SheetService sheetService;
28 Logger logger = LoggerFactory.getLogger(this.getClass()); 29 Logger logger = LoggerFactory.getLogger(this.getClass());
29 30
  31 + @Autowired
  32 + DayOfDirectives dayOfDirectives;
  33 +
30 @Override 34 @Override
31 public void run() { 35 public void run() {
32 try{ 36 try{
@@ -37,12 +41,15 @@ public class CalcOilThread extends Thread{ @@ -37,12 +41,15 @@ public class CalcOilThread extends Thread{
37 logger.info("开始计算班次准点率...."); 41 logger.info("开始计算班次准点率....");
38 sheetService.saveSheetList(""); 42 sheetService.saveSheetList("");
39 logger.info("计算班次准点率结束!"); 43 logger.info("计算班次准点率结束!");
40 - //清除安全驾驶数据 先临时蹭这个线程  
41 - SafeDrivCenter.clear();  
42 - //清除超速缓存数据  
43 - OverspeedProcess.clear();  
44 } catch(Exception e){ 44 } catch(Exception e){
45 logger.error("计算路单里程加注量失败",e); 45 logger.error("计算路单里程加注量失败",e);
46 } 46 }
  47 +
  48 + //清除指令数据
  49 + dayOfDirectives.clearAll();
  50 + //清除安全驾驶数据
  51 + SafeDrivCenter.clear();
  52 + //清除超速缓存数据
  53 + OverspeedProcess.clear();
47 } 54 }
48 } 55 }
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
1 package com.bsth.data.schedule.thread; 1 package com.bsth.data.schedule.thread;
2 2
3 -import com.bsth.data.BasicData;  
4 import com.bsth.data.LineConfigData; 3 import com.bsth.data.LineConfigData;
5 import com.bsth.data.directive.DayOfDirectives; 4 import com.bsth.data.directive.DayOfDirectives;
6 import com.bsth.data.gpsdata_v2.cache.GpsCacheData; 5 import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
@@ -56,17 +55,15 @@ public class ScheduleRefreshThread extends Thread{ @@ -56,17 +55,15 @@ public class ScheduleRefreshThread extends Thread{
56 55
57 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ 56 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){
58 57
59 - //logger.info(lineCode + "开始翻班, " + currSchDate);  
60 -  
61 try{ 58 try{
62 - //清除指令数据  
63 Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode); 59 Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode);
64 for(String car : cars){ 60 for(String car : cars){
65 - dayOfDirectives.clear(BasicData.deviceId2NbbmMap.inverse().get(car));  
66 GpsCacheData.remove(car); 61 GpsCacheData.remove(car);
67 } 62 }
68 //清除驾驶员上报数据 63 //清除驾驶员上报数据
69 pilotReport.clear(lineCode); 64 pilotReport.clear(lineCode);
  65 + //清除指令数据 指令数据,直接定时全部清空
  66 + //dayOfDirectives.clear(lineCode);
70 }catch (Exception e){ 67 }catch (Exception e){
71 logger.error("清理 60 和 80出现问题", e); 68 logger.error("清理 60 和 80出现问题", e);
72 } 69 }
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
@@ -128,7 +128,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen @@ -128,7 +128,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
128 text += " (放站到"+sch.getMajorStationName()+"带客)"; 128 text += " (放站到"+sch.getMajorStationName()+"带客)";
129 } 129 }
130 130
131 - //下发0x01指令 调度指令(闹钟有效) 131 + //下发0x02指令 调度指令(闹钟有效)
132 long t = System.currentTimeMillis() + 1000 * 30, 132 long t = System.currentTimeMillis() + 1000 * 30,
133 alarmTime = sch.getDfsjT() < t?t:sch.getDfsjT(); 133 alarmTime = sch.getDfsjT() < t?t:sch.getDfsjT();
134 134
@@ -139,7 +139,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen @@ -139,7 +139,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
139 int state = 0;//营运状态 139 int state = 0;//营运状态
140 if(dayOfSchedule.emptyService(sch)) 140 if(dayOfSchedule.emptyService(sch))
141 state = 1; 141 state = 1;
142 - d60 = new DirectiveCreator().createD60_01(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir()) 142 + d60 = new DirectiveCreator().createD60_02(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir())
143 , state, new Date(alarmTime)); 143 , state, new Date(alarmTime));
144 144
145 d60.setLineCode(sch.getXlBm()); 145 d60.setLineCode(sch.getXlBm());
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
@@ -5,6 +5,7 @@ import com.bsth.data.BasicData; @@ -5,6 +5,7 @@ import com.bsth.data.BasicData;
5 import com.bsth.data.forecast.entity.ArrivalEntity; 5 import com.bsth.data.forecast.entity.ArrivalEntity;
6 import com.bsth.data.gpsdata_v2.GpsRealData; 6 import com.bsth.data.gpsdata_v2.GpsRealData;
7 import com.bsth.data.gpsdata_v2.cache.GeoCacheData; 7 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  8 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
8 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 9 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
9 import com.bsth.data.gpsdata_v2.utils.GeoUtils; 10 import com.bsth.data.gpsdata_v2.utils.GeoUtils;
10 import com.bsth.data.pilot80.PilotReport; 11 import com.bsth.data.pilot80.PilotReport;
@@ -492,6 +493,7 @@ public class GpsServiceImpl implements GpsService { @@ -492,6 +493,7 @@ public class GpsServiceImpl implements GpsService {
492 try { 493 try {
493 494
494 gpsRealData.remove(device); 495 gpsRealData.remove(device);
  496 + GpsCacheData.remove(BasicData.deviceId2NbbmMap.get(device));
495 rs.put("status", ResponseCode.SUCCESS); 497 rs.put("status", ResponseCode.SUCCESS);
496 } catch (Exception e) { 498 } catch (Exception e) {
497 rs.put("status", ResponseCode.ERROR); 499 rs.put("status", ResponseCode.ERROR);
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -698,13 +698,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -698,13 +698,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
698 //数据库删除 698 //数据库删除
699 rs = super.delete(id); 699 rs = super.delete(id);
700 if(rs.get("status").equals(ResponseCode.SUCCESS)){ 700 if(rs.get("status").equals(ResponseCode.SUCCESS)){
701 - /*ScheduleRealInfo temp = super.findById(id);  
702 - if(temp != null){  
703 - rs.put("status", ResponseCode.ERROR);  
704 - rs.put("msg", "删除失败,请重试!");  
705 - return rs;  
706 - }*/  
707 -  
708 dayOfSchedule.delete(sch); 701 dayOfSchedule.delete(sch);
709 //更新起点应到时间 702 //更新起点应到时间
710 List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); 703 List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);
src/main/resources/static/real_control_v2/alone_page/map/alone_wrap.html
@@ -110,6 +110,7 @@ @@ -110,6 +110,7 @@
110 <!-- jquery.serializejson JSON序列化插件 --> 110 <!-- jquery.serializejson JSON序列化插件 -->
111 <script src="/assets/plugins/jquery.serializejson.js" merge="uikit_js"></script> 111 <script src="/assets/plugins/jquery.serializejson.js" merge="uikit_js"></script>
112 112
  113 +<script src="/assets/plugins/pinyin.js" merge="plugins"></script>
113 </body> 114 </body>
114 <script> 115 <script>
115 gb_data_gps.fixedTimeRefresh(); 116 gb_data_gps.fixedTimeRefresh();
src/main/resources/static/real_control_v2/fragments/north/nav/all_devices.html
@@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
36 <div class="uk-autocomplete uk-form " > 36 <div class="uk-autocomplete uk-form " >
37 <select name="abnormalStatus"> 37 <select name="abnormalStatus">
38 <option value="">全部</option> 38 <option value="">全部</option>
  39 + <option value="timeError">时间戳异常</option>
39 <option value="outBounds">越界</option> 40 <option value="outBounds">越界</option>
40 <option value="overspeed">超速</option> 41 <option value="overspeed">超速</option>
41 <option value="offline">离线</option> 42 <option value="offline">离线</option>
@@ -58,11 +59,11 @@ @@ -58,11 +59,11 @@
58 <th style="width: 14%;">站点</th> 59 <th style="width: 14%;">站点</th>
59 <th style="width: 11%;">车辆</th> 60 <th style="width: 11%;">车辆</th>
60 <th style="width: 11%;">设备号</th> 61 <th style="width: 11%;">设备号</th>
61 - <th style="width: 9%;">走向/营运</th> 62 + <th style="width: 12%;">走向/营运</th>
62 <th style="width: 9%;">程序版本</th> 63 <th style="width: 9%;">程序版本</th>
63 <th>最后GPS时间</th> 64 <th>最后GPS时间</th>
64 - <th style="width: 9%;">状态</th>  
65 - <th style="width: 8%;">来源</th> 65 + <th style="width: 8%;">状态</th>
  66 + <th style="width: 6%;">源</th>
66 </tr> 67 </tr>
67 </thead> 68 </thead>
68 <tbody> 69 <tbody>
@@ -81,7 +82,11 @@ @@ -81,7 +82,11 @@
81 <td>{{gps.stationName}}</td> 82 <td>{{gps.stationName}}</td>
82 <td>{{gps.nbbm}}</td> 83 <td>{{gps.nbbm}}</td>
83 <td>{{gps.deviceId}}</td> 84 <td>{{gps.deviceId}}</td>
84 - <td>{{gps.upDown}}/{{gps.state}}</td> 85 + <td>{{gps.upDown}}/{{gps.state}}
  86 + {{if gps.origStateStr!=null}}
  87 + (<span style="color: #fe6262;">{{gps.origStateStr}}</span>)
  88 + {{/if}}
  89 + </td>
85 <td>{{gps.version}}</td> 90 <td>{{gps.version}}</td>
86 <td>{{gps.timeStr}}</td> 91 <td>{{gps.timeStr}}</td>
87 <td> 92 <td>
@@ -95,18 +100,14 @@ @@ -95,18 +100,14 @@
95 <span class="sm-red">GPS (0,0)</span> 100 <span class="sm-red">GPS (0,0)</span>
96 {{else if gps.abnormalStatus=='offline'}} 101 {{else if gps.abnormalStatus=='offline'}}
97 <span>离线</span> 102 <span>离线</span>
  103 + {{else if gps.abnormalStatus=='timeError'}}
  104 + <span class="sm-red" title="设备时间戳异常,尝试以服务器时间修正">time_ex</span>
98 {{else}} 105 {{else}}
99 ... 106 ...
100 {{/if}} 107 {{/if}}
101 </td> 108 </td>
102 <td> 109 <td>
103 - {{if gps.source==1}}  
104 - <span style="color: #1e1ef5;" title="已切换至新网关">网关</span>  
105 - {{else if gps.source==0}}  
106 - <span style="color: #8e8e8e;" title="转接的数据,无法下发指令">转发</span>  
107 - {{else}}  
108 - <span class="sm-grey">未知</span>  
109 - {{/if}} 110 + <span class="sm-grey">{{gps.source}}</span>
110 </td> 111 </td>
111 </tr> 112 </tr>
112 {{/each}} 113 {{/each}}