Commit 3528f512a7414f10a217341f3a80394514d1df3c

Authored by panzhaov5
1 parent 64119598

update...

src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
@@ -7,7 +7,6 @@ import com.bsth.entity.realcontrol.LineConfig; @@ -7,7 +7,6 @@ import com.bsth.entity.realcontrol.LineConfig;
7 import com.bsth.entity.realcontrol.ScheduleRealInfo; 7 import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 import com.bsth.util.Arith; 8 import com.bsth.util.Arith;
9 import com.bsth.websocket.handler.SendUtils; 9 import com.bsth.websocket.handler.SendUtils;
10 -import com.google.common.collect.ArrayListMultimap;  
11 import org.slf4j.Logger; 10 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
13 import org.springframework.beans.BeansException; 12 import org.springframework.beans.BeansException;
@@ -16,7 +15,8 @@ import org.springframework.context.ApplicationContextAware; @@ -16,7 +15,8 @@ import org.springframework.context.ApplicationContextAware;
16 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
17 16
18 import java.util.Collection; 17 import java.util.Collection;
19 -import java.util.List; 18 +import java.util.HashMap;
  19 +import java.util.Map;
20 20
21 /** 21 /**
22 * 误点自动调整待发 处理程序 22 * 误点自动调整待发 处理程序
@@ -33,17 +33,11 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -33,17 +33,11 @@ public class LateAdjustHandle implements ApplicationContextAware {
33 static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); 33 static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class);
34 34
35 /** 35 /**
36 - * 应发未到车辆 和 班次  
37 - * <p>  
38 - * 起点相同的,保留最后一个班次 36 + * 应发未到的班次 key : id
39 */ 37 */
40 - private static ArrayListMultimap lateSchMaps; 38 + private static Map<Long, ScheduleRealInfo> lateSchMap = new HashMap<>();
41 39
42 40
43 - static {  
44 - lateSchMaps = ArrayListMultimap.create();  
45 - }  
46 -  
47 /** 41 /**
48 * 新增一个误点班次 42 * 新增一个误点班次
49 * 43 *
@@ -63,15 +57,12 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -63,15 +57,12 @@ public class LateAdjustHandle implements ApplicationContextAware {
63 if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0 57 if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0
64 && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) { 58 && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) {
65 59
66 - ScheduleRealInfo old = popLateSch(sch);  
67 -  
68 - //班次被压入  
69 - if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) {  
70 -  
71 - logger.info("21【应发未到 -多个(" + lateSchMaps.get(sch.getClZbh()).size() + ")】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); 60 + //班次压入
  61 + if (!lateSchMap.containsKey(sch.getId())) {
  62 + logger.info("29【应发未到 班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!");
72 //通知客户端 63 //通知客户端
73 sch.setLate2(true); 64 sch.setLate2(true);
74 - sendUtils.sendAutoWdtz(sch, old); 65 + sendUtils.sendAutoWdtz(sch, null);
75 } 66 }
76 } 67 }
77 68
@@ -80,51 +71,6 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -80,51 +71,6 @@ public class LateAdjustHandle implements ApplicationContextAware {
80 } 71 }
81 } 72 }
82 73
83 - /**  
84 - * 压入新的误点班次  
85 - *  
86 - * @param sch  
87 - * @return 返回被移除的误点班次  
88 - */  
89 - private static ScheduleRealInfo popLateSch(ScheduleRealInfo sch) {  
90 - List<ScheduleRealInfo> list = lateSchMaps.get(sch.getClZbh());  
91 -  
92 - if (null == list || list.size() == 0)  
93 - lateSchMaps.put(sch.getClZbh(), sch);  
94 - else {  
95 - ScheduleRealInfo old = findExistQdz(list, sch.getQdzCode(), sch.getQdzName(), "");  
96 -  
97 - if (null == old)  
98 - lateSchMaps.put(sch.getClZbh(), sch);  
99 - else if (old.getDfsjT() < sch.getDfsjT()) {  
100 - //同一个起点,保留时间最大的班次  
101 - lateSchMaps.remove(old.getClZbh(), old);  
102 - lateSchMaps.put(sch.getClZbh(), sch);  
103 -  
104 - logger.info(sch.getClZbh() + "【应发未到】old 班次 " + old.getId() + " -被覆盖!");  
105 - return old;  
106 - }  
107 - }  
108 -  
109 - return null;  
110 - }  
111 -  
112 - /**  
113 - * 搜索同样起点的班次  
114 - *  
115 - * @param list  
116 - * @return  
117 - */  
118 - private static ScheduleRealInfo findExistQdz(List<ScheduleRealInfo> list, String qdzCode, String nam1, String name2) {  
119 - for (ScheduleRealInfo item : list) {  
120 - if (item.getQdzCode().equals(qdzCode)  
121 - || item.getQdzName().equals(nam1)  
122 - || item.getQdzName().equals(name2))  
123 - return item;  
124 - }  
125 - return null;  
126 - }  
127 -  
128 74
129 /** 75 /**
130 * 获取所有应发未到的班次 76 * 获取所有应发未到的班次
@@ -132,13 +78,13 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -132,13 +78,13 @@ public class LateAdjustHandle implements ApplicationContextAware {
132 * @return 78 * @return
133 */ 79 */
134 public static Collection<ScheduleRealInfo> allLateSch() { 80 public static Collection<ScheduleRealInfo> allLateSch() {
135 - return lateSchMaps.values(); 81 + return lateSchMap.values();
136 } 82 }
137 83
138 public static void remove(ScheduleRealInfo sch) { 84 public static void remove(ScheduleRealInfo sch) {
139 try { 85 try {
140 - if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) {  
141 - lateSchMaps.remove(sch.getClZbh(), sch); 86 + if (lateSchMap.containsKey(sch.getId())) {
  87 + lateSchMap.remove(sch.getId());
142 88
143 sch.setLate2(false); 89 sch.setLate2(false);
144 sch.setLateMinute(0); 90 sch.setLateMinute(0);
@@ -161,15 +107,14 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -161,15 +107,14 @@ public class LateAdjustHandle implements ApplicationContextAware {
161 if (gps.getInstation() <= 0 || null == sch) 107 if (gps.getInstation() <= 0 || null == sch)
162 return; 108 return;
163 109
164 - List<ScheduleRealInfo> list = lateSchMaps.get(gps.getNbbm());  
165 -  
166 - if (null == list || list.size() == 0 || !list.contains(sch)) 110 + if (!lateSchMap.containsKey(sch.getId()))
167 return; 111 return;
168 112
  113 +
169 //可能是延迟信号,gps时间没有误点 114 //可能是延迟信号,gps时间没有误点
170 if (gps.getTimestamp() <= sch.getDfsjT()) { 115 if (gps.getTimestamp() <= sch.getDfsjT()) {
171 sch.setLate2(false); 116 sch.setLate2(false);
172 - lateSchMaps.remove(sch.getClZbh(), sch); 117 + lateSchMap.remove(sch.getId());
173 return; 118 return;
174 } 119 }
175 120
@@ -182,8 +127,8 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -182,8 +127,8 @@ public class LateAdjustHandle implements ApplicationContextAware {
182 //取消应发未到标记 127 //取消应发未到标记
183 sch.setLate2(false); 128 sch.setLate2(false);
184 129
185 - lateSchMaps.remove(sch.getClZbh(), sch);  
186 - logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); 130 + lateSchMap.remove(sch.getId());
  131 + logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt + " -id:" + sch.getId());
187 } catch (Exception e) { 132 } catch (Exception e) {
188 e.printStackTrace(); 133 e.printStackTrace();
189 logger.error("late2 car arrive", e); 134 logger.error("late2 car arrive", e);