Commit 642c9016885d0950043762c9ff7536869bcf3eb3

Authored by 潘钊
1 parent 2159f48a

update...

src/main/java/com/bsth/controller/berth/BerthController.java
@@ -2,9 +2,9 @@ package com.bsth.controller.berth; @@ -2,9 +2,9 @@ package com.bsth.controller.berth;
2 2
3 import com.bsth.controller.BaseController; 3 import com.bsth.controller.BaseController;
4 import com.bsth.controller.berth.dto.Car2Berth; 4 import com.bsth.controller.berth.dto.Car2Berth;
5 -import com.bsth.data.in_out.RealInoutHandler;  
6 import com.bsth.data.in_out.buffer.BerthDataBuffer; 5 import com.bsth.data.in_out.buffer.BerthDataBuffer;
7 import com.bsth.data.in_out.buffer.ElectricDataBuffer; 6 import com.bsth.data.in_out.buffer.ElectricDataBuffer;
  7 +import com.bsth.data.in_out.carpark.RealBerthManager;
8 import com.bsth.entity.berth.RegionBerth; 8 import com.bsth.entity.berth.RegionBerth;
9 import com.bsth.service.berth.BerthService; 9 import com.bsth.service.berth.BerthService;
10 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,7 +35,7 @@ public class BerthController extends BaseController<RegionBerth, Integer> { @@ -35,7 +35,7 @@ public class BerthController extends BaseController<RegionBerth, Integer> {
35 BerthService berthService; 35 BerthService berthService;
36 36
37 @Autowired 37 @Autowired
38 - RealInoutHandler realInoutHandler; 38 + RealBerthManager realBerthManager;
39 39
40 @Autowired 40 @Autowired
41 BerthDataBuffer berthDataBuffer; 41 BerthDataBuffer berthDataBuffer;
@@ -52,17 +52,17 @@ public class BerthController extends BaseController<RegionBerth, Integer> { @@ -52,17 +52,17 @@ public class BerthController extends BaseController<RegionBerth, Integer> {
52 52
53 @RequestMapping("addCar") 53 @RequestMapping("addCar")
54 public Map<String, Object> addCar(@RequestParam String berthName,@RequestParam String nbbm){ 54 public Map<String, Object> addCar(@RequestParam String berthName,@RequestParam String nbbm){
55 - return realInoutHandler.addCar2Berth(nbbm, berthName); 55 + return realBerthManager.addCar2Berth(nbbm, berthName);
56 } 56 }
57 57
58 @RequestMapping("removeCar") 58 @RequestMapping("removeCar")
59 public Map<String, Object> removeCar(@RequestParam String b){ 59 public Map<String, Object> removeCar(@RequestParam String b){
60 - return realInoutHandler.removeCar2Berth(b); 60 + return realBerthManager.removeCar2Berth(b);
61 } 61 }
62 62
63 @RequestMapping("changeCar2Berth") 63 @RequestMapping("changeCar2Berth")
64 public Map<String, Object> changeCar2Berth(@RequestParam String s,@RequestParam String d){ 64 public Map<String, Object> changeCar2Berth(@RequestParam String s,@RequestParam String d){
65 - return RealInoutHandler.changeCar2Berth(s, d); 65 + return RealBerthManager.changeCar2Berth(s, d);
66 } 66 }
67 67
68 @RequestMapping("lockBerth") 68 @RequestMapping("lockBerth")
src/main/java/com/bsth/data/abnormal/MainAbnormalClient.java
@@ -3,6 +3,7 @@ package com.bsth.data.abnormal; @@ -3,6 +3,7 @@ package com.bsth.data.abnormal;
3 import com.bsth.data.abnormal.entity.AbnormalEntity; 3 import com.bsth.data.abnormal.entity.AbnormalEntity;
4 import com.bsth.data.abnormal.handler.AttendanceHandler; 4 import com.bsth.data.abnormal.handler.AttendanceHandler;
5 import com.bsth.data.abnormal.handler.InOutHandler; 5 import com.bsth.data.abnormal.handler.InOutHandler;
  6 +import com.bsth.data.schedule.dto.ScheduleInOut;
6 import com.bsth.websocket.handler.SendUtils; 7 import com.bsth.websocket.handler.SendUtils;
7 import com.google.common.collect.ArrayListMultimap; 8 import com.google.common.collect.ArrayListMultimap;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -87,4 +88,12 @@ public class MainAbnormalClient { @@ -87,4 +88,12 @@ public class MainAbnormalClient {
87 public AbnormalEntity cycc(Long id, String timeStr, String reason, String remarks) { 88 public AbnormalEntity cycc(Long id, String timeStr, String reason, String remarks) {
88 return inOutHandler.cycc(id, timeStr, reason, remarks); 89 return inOutHandler.cycc(id, timeStr, reason, remarks);
89 } 90 }
  91 +
  92 + /**
  93 + * rfid 出场
  94 + * @param sio
  95 + */
  96 + public AbnormalEntity rfidOut(ScheduleInOut sio) {
  97 + return inOutHandler.rfidOut(sio);
  98 + }
90 } 99 }
src/main/java/com/bsth/data/abnormal/handler/InOutHandler.java
@@ -4,6 +4,8 @@ import com.bsth.data.abnormal.entity.AbnormalEntity; @@ -4,6 +4,8 @@ import com.bsth.data.abnormal.entity.AbnormalEntity;
4 import com.bsth.data.schedule.dto.ScheduleInOut; 4 import com.bsth.data.schedule.dto.ScheduleInOut;
5 import com.bsth.data.schedule.real.ScheduleDataBuffer; 5 import com.bsth.data.schedule.real.ScheduleDataBuffer;
6 import com.bsth.security.util.SecurityUtils; 6 import com.bsth.security.util.SecurityUtils;
  7 +import org.joda.time.format.DateTimeFormat;
  8 +import org.joda.time.format.DateTimeFormatter;
7 import org.springframework.stereotype.Component; 9 import org.springframework.stereotype.Component;
8 10
9 import java.util.concurrent.ConcurrentHashMap; 11 import java.util.concurrent.ConcurrentHashMap;
@@ -18,6 +20,8 @@ public class InOutHandler { @@ -18,6 +20,8 @@ public class InOutHandler {
18 20
19 private static ConcurrentMap<Long, AbnormalEntity> schIdMap; 21 private static ConcurrentMap<Long, AbnormalEntity> schIdMap;
20 22
  23 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  24 +
21 static { 25 static {
22 schIdMap = new ConcurrentHashMap<>(); 26 schIdMap = new ConcurrentHashMap<>();
23 } 27 }
@@ -77,4 +81,19 @@ public class InOutHandler { @@ -77,4 +81,19 @@ public class InOutHandler {
77 schIdMap.remove(ae.getSchId()); 81 schIdMap.remove(ae.getSchId());
78 return ae; 82 return ae;
79 } 83 }
  84 +
  85 +
  86 + public AbnormalEntity rfidOut(ScheduleInOut sio) {
  87 + AbnormalEntity ae = schIdMap.get(sio.getId());
  88 + if(null == ae)
  89 + return null;
  90 +
  91 + ae.setHandlerTime(sio.getOutTimeRfid());
  92 + ae.setHandlerUser("system");
  93 + ae.setHandlerDes("RFID信号出场," + fmtHHmm.print(sio.getOutTimeRfid()));
  94 +
  95 + sio.reCalcAnStatus();
  96 + schIdMap.remove(ae.getSchId());
  97 + return ae;
  98 + }
80 } 99 }
src/main/java/com/bsth/data/in_out/DataRecoveryUtil.java
1 package com.bsth.data.in_out; 1 package com.bsth.data.in_out;
2 2
3 import com.bsth.data.in_out.buffer.BerthDataBuffer; 3 import com.bsth.data.in_out.buffer.BerthDataBuffer;
  4 +import com.bsth.data.in_out.carpark.RealBerthManager;
4 import com.bsth.entity.berth.RegionBerth; 5 import com.bsth.entity.berth.RegionBerth;
5 import com.bsth.repository.berth.BerthRepository; 6 import com.bsth.repository.berth.BerthRepository;
6 import com.google.common.collect.BiMap; 7 import com.google.common.collect.BiMap;
@@ -23,10 +24,10 @@ public class DataRecoveryUtil { @@ -23,10 +24,10 @@ public class DataRecoveryUtil {
23 BerthRepository berthRepository; 24 BerthRepository berthRepository;
24 25
25 @Autowired 26 @Autowired
26 - RealInoutHandler realInoutHandler; 27 + BerthDataBuffer berthDataBuffer;
27 28
28 @Autowired 29 @Autowired
29 - BerthDataBuffer berthDataBuffer; 30 + RealBerthManager realBerthManager;
30 31
31 public void recovery(){ 32 public void recovery(){
32 List<RegionBerth> list = (List<RegionBerth>) berthRepository.findAll(); 33 List<RegionBerth> list = (List<RegionBerth>) berthRepository.findAll();
@@ -44,7 +45,7 @@ public class DataRecoveryUtil { @@ -44,7 +45,7 @@ public class DataRecoveryUtil {
44 car2berth.put(b.getCar(), b.getName()); 45 car2berth.put(b.getCar(), b.getName());
45 } 46 }
46 47
47 - realInoutHandler.init(car2berth); 48 + realBerthManager.init(car2berth);
48 berthDataBuffer.putLocks(locks); 49 berthDataBuffer.putLocks(locks);
49 } 50 }
50 } 51 }
src/main/java/com/bsth/data/in_out/RealInoutHandler.java
1 package com.bsth.data.in_out; 1 package com.bsth.data.in_out;
2 2
3 -import com.bsth.common.ResponseCode;  
4 -import com.bsth.data.basic.bus.BusDataBuffer;  
5 -import com.bsth.data.in_out.buffer.BerthDataBuffer;  
6 -import com.bsth.data.led_http.LedHttpPushHandler; 3 +import com.bsth.data.abnormal.MainAbnormalClient;
  4 +import com.bsth.data.abnormal.entity.AbnormalEntity;
  5 +import com.bsth.data.in_out.carpark.RealBerthManager;
7 import com.bsth.data.schedule.dto.ScheduleInOut; 6 import com.bsth.data.schedule.dto.ScheduleInOut;
8 import com.bsth.data.schedule.real.ScheduleDataBuffer; 7 import com.bsth.data.schedule.real.ScheduleDataBuffer;
9 -import com.bsth.entity.Bus;  
10 import com.bsth.entity.ac.CarInOutEntity; 8 import com.bsth.entity.ac.CarInOutEntity;
11 -import com.bsth.entity.berth.RegionBerth;  
12 import com.bsth.websocket.handler.SendUtils; 9 import com.bsth.websocket.handler.SendUtils;
13 -import com.google.common.collect.BiMap;  
14 -import com.google.common.collect.HashBiMap; 10 +import com.google.common.collect.ArrayListMultimap;
15 import org.apache.commons.lang3.StringUtils; 11 import org.apache.commons.lang3.StringUtils;
16 import org.slf4j.Logger; 12 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
20 16
21 -import java.util.HashMap;  
22 import java.util.LinkedList; 17 import java.util.LinkedList;
23 -import java.util.List;  
24 -import java.util.Map;  
25 18
26 /** 19 /**
27 * 实时进出场数据处理程序 20 * 实时进出场数据处理程序
@@ -32,24 +25,26 @@ public class RealInoutHandler { @@ -32,24 +25,26 @@ public class RealInoutHandler {
32 25
33 static Logger logger = LoggerFactory.getLogger(RealInoutHandler.class); 26 static Logger logger = LoggerFactory.getLogger(RealInoutHandler.class);
34 27
  28 + @Autowired
  29 + SendUtils sendUtils;
  30 +
  31 + @Autowired
  32 + RealBerthManager realBerthManager;
  33 +
  34 + @Autowired
  35 + MainAbnormalClient mainAbnormalClient;
  36 +
35 /** 37 /**
36 - * 车辆自编号和停放泊位号对照 38 + * K:车辆自编号 V:实际RFID进出场数据
37 */ 39 */
38 - private static BiMap<String, String> car2berthMap; 40 + private static ArrayListMultimap<String, CarInOutEntity> rfidSignalMaps;
39 41
40 //待入库数据 42 //待入库数据
41 public static LinkedList<CarInOutEntity> psts; 43 public static LinkedList<CarInOutEntity> psts;
42 44
43 - @Autowired  
44 - SendUtils sendUtils;  
45 -  
46 static { 45 static {
47 - car2berthMap = HashBiMap.create();  
48 psts = new LinkedList(); 46 psts = new LinkedList();
49 - }  
50 -  
51 - public void init(BiMap<String, String> map){  
52 - car2berthMap = map; 47 + rfidSignalMaps = ArrayListMultimap.create();
53 } 48 }
54 49
55 /** 50 /**
@@ -57,8 +52,9 @@ public class RealInoutHandler { @@ -57,8 +52,9 @@ public class RealInoutHandler {
57 * @param cio 52 * @param cio
58 */ 53 */
59 public void inOut(CarInOutEntity cio) { 54 public void inOut(CarInOutEntity cio) {
60 - //公交车  
61 - if(0 == cio.getCarType()){ 55 + rfidSignalMaps.put(cio.getNbbm(), cio);
  56 +
  57 + if(0 == cio.getCarType()){//公交车
62 //获取对应的计划排班 58 //获取对应的计划排班
63 ScheduleInOut sch = ScheduleDataBuffer.get(cio); 59 ScheduleInOut sch = ScheduleDataBuffer.get(cio);
64 60
@@ -71,79 +67,54 @@ public class RealInoutHandler { @@ -71,79 +67,54 @@ public class RealInoutHandler {
71 psts.add(cio); 67 psts.add(cio);
72 68
73 if (cio.getType() == 2 || cio.getType() == 1)//待进 和 实进 69 if (cio.getType() == 2 || cio.getType() == 1)//待进 和 实进
74 - busIn(cio); //公交车进场 70 + realBerthManager.busIn(cio); //公交车进场
75 else if (cio.getType() == 4) 71 else if (cio.getType() == 4)
76 - busOut(cio); //公交车出场 72 + realBerthManager.busOut(cio); //公交车出场
  73 +
  74 + //处理异常监管的班次信息
  75 + attachRfidTime(sch, cio);
77 } 76 }
78 } 77 }
79 78
80 - private void busOut(CarInOutEntity cio) {  
81 - car2berthMap.remove(cio.getNbbm());  
82 -  
83 - //led  
84 - LedHttpPushHandler.busOut(cio);  
85 - //通知客户端  
86 - sendUtils.sendCarOut(cio.getNbbm(), cio.getT()); 79 + /**
  80 + * 处理异常监管的班次信息
  81 + * @param sio
  82 + * @param cio
  83 + */
  84 + public void attachRfidTime(ScheduleInOut sio, CarInOutEntity cio){
  85 + if(sio.getBcType().equals("out")){//出场班次
  86 + if(sio.getOutTimeRfid() == null ||
  87 + (null != sio.getOutTimeRfid() && outSignalMatch(sio, cio))){
  88 +
  89 + //是否是一个更合适的信号
  90 + sio.setOutTimeRfid(cio.getT());
  91 + //处理相关异常
  92 + AbnormalEntity ae = mainAbnormalClient.rfidOut(sio);
  93 +
  94 + //通知页面
  95 + sendUtils.scheduleOut(sio, ae);
  96 + }
  97 + }
87 } 98 }
88 99
89 - private void busIn(CarInOutEntity cio) {  
90 - String nbbm = cio.getNbbm();  
91 - if (StringUtils.isEmpty(nbbm))  
92 - return;  
93 -  
94 -  
95 - //车辆已经在泊位上,先移除(可能没有出场信号)  
96 - if(car2berthMap.containsKey(nbbm)){  
97 - if(cio.getType()==1)//待进  
98 - return;  
99 - car2berthMap.remove(nbbm);  
100 - }  
101 - Bus bus = BusDataBuffer.findOne(nbbm);  
102 - //非电车,停柴油泊位区  
103 - if(!bus.isSfdc()){  
104 - LedHttpPushHandler.busIn(bus.getCarPlate(), "柴油泊位区");  
105 - return;  
106 - } 100 + /**
  101 + * 信号匹配,
  102 + * @param sio
  103 + * @param cio
  104 + * @return true : 是更合适的信号
  105 + */
  106 + public boolean outSignalMatch(ScheduleInOut sio, CarInOutEntity cio){
  107 + long diff1 = sio.getOutTimeRfid() - sio.getDfsjT();
  108 + long diff2 = cio.getT() - sio.getDfsjT();
107 109
108 - //是否有固定泊位  
109 - String lockBName = BerthDataBuffer.getLockBerthName(nbbm);  
110 - if(StringUtils.isNotEmpty(lockBName)){  
111 - if(cio.getType()==2)  
112 - car2berthMap.put(nbbm, lockBName);  
113 - else {  
114 - //泊位引导  
115 - LedHttpPushHandler.busIn(bus.getCarPlate(), lockBName);  
116 - }  
117 - }  
118 - else{  
119 - //停空闲泊位  
120 - List<RegionBerth> berthList = BerthDataBuffer.allNoLock();  
121 - RegionBerth free = null;  
122 - for(RegionBerth b : berthList){  
123 - //被占用的泊位  
124 - if(car2berthMap.inverse().containsKey(b.getName()))  
125 - continue;  
126 - //被禁用的泊位  
127 - if(BerthDataBuffer.isLock(b.getName()))  
128 - continue;  
129 - free = b;  
130 - break;  
131 - }  
132 - if(null != free){  
133 - if(cio.getType()==2)  
134 - car2berthMap.put(nbbm, free.getName());  
135 - else{  
136 - //泊位引导  
137 - LedHttpPushHandler.busIn(nbbm, free.getName());  
138 - }  
139 - }  
140 - else  
141 - logger.info("没有空余泊位了"); 110 + if(diff1 <= 0 && diff2 <= 0){//都在计划时间之前,用最靠近的信号
  111 + return diff1<diff2;
142 } 112 }
143 113
144 - //通知客户端  
145 - if(cio.getType() == 2)  
146 - sendUtils.sendCarIn(nbbm, car2berthMap.get(nbbm), cio.getT()); 114 + if(Math.abs(diff1) > 1000 * 60 * 30
  115 + && Math.abs(diff2) < 1000 * 60 * 5)
  116 + return true;
  117 + return false;
147 } 118 }
148 119
149 private void addPlanFiled(CarInOutEntity cio, ScheduleInOut sch) { 120 private void addPlanFiled(CarInOutEntity cio, ScheduleInOut sch) {
@@ -170,95 +141,12 @@ public class RealInoutHandler { @@ -170,95 +141,12 @@ public class RealInoutHandler {
170 } 141 }
171 } 142 }
172 143
173 - public static Map<String, String> getCar2berthMap(){  
174 - return car2berthMap;  
175 - }  
176 -  
177 /** 144 /**
178 - * 添加车辆和泊位对照 145 + * 重新匹配2辆车的计划和实际信号
  146 + * @param oldName
179 * @param nbbm 147 * @param nbbm
180 - * @param berthName  
181 - * @return  
182 - */  
183 - public Map<String, Object> addCar2Berth(String nbbm, String berthName) {  
184 - Map<String, Object> rs = new HashMap<>();  
185 -  
186 - try{  
187 - if(car2berthMap.containsKey(nbbm))  
188 - car2berthMap.remove(nbbm);  
189 -  
190 - if(car2berthMap.inverse().containsKey(berthName))  
191 - car2berthMap.inverse().remove(berthName);  
192 -  
193 - car2berthMap.put(nbbm, berthName);  
194 - rs.put("status", ResponseCode.SUCCESS);  
195 - }catch (Exception e){  
196 - logger.error("", e);  
197 - rs.put("status", ResponseCode.ERROR);  
198 - }  
199 - return rs;  
200 - }  
201 -  
202 - /**  
203 - * 删除指定泊位上的车辆  
204 - * @param berthName  
205 - * @return  
206 - */  
207 - public Map<String, Object> removeCar2Berth(String berthName) {  
208 - Map<String, Object> rs = new HashMap<>();  
209 -  
210 - try{  
211 -  
212 - if(car2berthMap.inverse().containsKey(berthName))  
213 - car2berthMap.inverse().remove(berthName);  
214 -  
215 - rs.put("status", ResponseCode.SUCCESS);  
216 - }catch (Exception e){  
217 - logger.error("", e);  
218 - rs.put("status", ResponseCode.ERROR);  
219 - }  
220 - return rs;  
221 - }  
222 -  
223 - /**  
224 - * 对换指定2个泊位上的车辆  
225 - * @param s  
226 - * @param d  
227 - * @return  
228 */ 148 */
229 - public static Map<String, Object> changeCar2Berth(String s, String d) {  
230 - Map<String, Object> rs = new HashMap<>();  
231 -  
232 - try{  
233 -  
234 - Map<String, String> inverseMap = car2berthMap.inverse();  
235 -  
236 - String sv = inverseMap.get(s);  
237 - String dv = inverseMap.get(d);  
238 -  
239 - if(sv != null){  
240 - inverseMap.remove(s);  
241 - inverseMap.put(d, sv);  
242 - }  
243 - else  
244 - inverseMap.remove(d);  
245 -  
246 - if(dv != null)  
247 - inverseMap.put(s, dv);  
248 -  
249 - rs.put("status", ResponseCode.SUCCESS);  
250 - }catch (Exception e){  
251 - logger.error("", e);  
252 - rs.put("status", ResponseCode.ERROR);  
253 - }  
254 - return rs;  
255 - }  
256 -  
257 - public boolean containsBerth(String berthName) {  
258 - return car2berthMap.inverse().containsKey(berthName);  
259 - } 149 + public static void reCalcOutSignal(String oldName, String nbbm) {
260 150
261 - public int size() {  
262 - return car2berthMap.size();  
263 } 151 }
264 } 152 }
src/main/java/com/bsth/data/in_out/buffer/BerthDataBuffer.java
1 package com.bsth.data.in_out.buffer; 1 package com.bsth.data.in_out.buffer;
2 2
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
4 -import com.bsth.data.in_out.RealInoutHandler; 4 +import com.bsth.data.in_out.carpark.RealBerthManager;
5 import com.bsth.entity.berth.RegionBerth; 5 import com.bsth.entity.berth.RegionBerth;
6 import com.bsth.repository.berth.BerthRepository; 6 import com.bsth.repository.berth.BerthRepository;
7 import com.google.common.collect.BiMap; 7 import com.google.common.collect.BiMap;
@@ -42,7 +42,7 @@ public class BerthDataBuffer { @@ -42,7 +42,7 @@ public class BerthDataBuffer {
42 private static BiMap<String, String> lockBerthMap; 42 private static BiMap<String, String> lockBerthMap;
43 43
44 @Autowired 44 @Autowired
45 - RealInoutHandler realInoutHandler; 45 + RealBerthManager realBerthManager;
46 46
47 @Autowired 47 @Autowired
48 private BerthComp comp; 48 private BerthComp comp;
@@ -124,14 +124,14 @@ public class BerthDataBuffer { @@ -124,14 +124,14 @@ public class BerthDataBuffer {
124 car2berth.put(berth.getCar(), berth.getName()); 124 car2berth.put(berth.getCar(), berth.getName());
125 } 125 }
126 nameMap = nameMapCopy; 126 nameMap = nameMapCopy;
127 - realInoutHandler.init(car2berth); 127 + realBerthManager.init(car2berth);
128 putLocks(locks); 128 putLocks(locks);
129 } 129 }
130 130
131 public Map<String, Object> lockBerth(String berthName) { 131 public Map<String, Object> lockBerth(String berthName) {
132 Map<String, Object> rs = new HashMap<>(); 132 Map<String, Object> rs = new HashMap<>();
133 try{ 133 try{
134 - if(realInoutHandler.containsBerth(berthName)){ 134 + if(realBerthManager.containsBerth(berthName)){
135 rs.put("status", ResponseCode.ERROR); 135 rs.put("status", ResponseCode.ERROR);
136 rs.put("msg", "请先清除泊位上的车辆,再尝试禁用泊位"); 136 rs.put("msg", "请先清除泊位上的车辆,再尝试禁用泊位");
137 } 137 }
src/main/java/com/bsth/data/in_out/carpark/RealBerthManager.java 0 → 100644
  1 +package com.bsth.data.in_out.carpark;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.data.basic.bus.BusDataBuffer;
  5 +import com.bsth.data.in_out.buffer.BerthDataBuffer;
  6 +import com.bsth.data.led_http.LedHttpPushHandler;
  7 +import com.bsth.entity.Bus;
  8 +import com.bsth.entity.ac.CarInOutEntity;
  9 +import com.bsth.entity.berth.RegionBerth;
  10 +import com.bsth.websocket.handler.SendUtils;
  11 +import com.google.common.collect.BiMap;
  12 +import com.google.common.collect.HashBiMap;
  13 +import org.apache.commons.lang3.StringUtils;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.stereotype.Component;
  18 +
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +/**
  24 + * 实时泊位停放管理
  25 + * Created by panzhao on 2018/3/26.
  26 + */
  27 +@Component
  28 +public class RealBerthManager {
  29 +
  30 + static Logger logger = LoggerFactory.getLogger(RealBerthManager.class);
  31 +
  32 + @Autowired
  33 + SendUtils sendUtils;
  34 +
  35 + /**
  36 + * 车辆自编号和停放泊位号对照
  37 + */
  38 + private static BiMap<String, String> car2berthMap;
  39 +
  40 + static {
  41 + car2berthMap = HashBiMap.create();
  42 + }
  43 +
  44 + public void init(BiMap<String, String> map){
  45 + car2berthMap = map;
  46 + }
  47 +
  48 + public void busIn(CarInOutEntity cio){
  49 +
  50 + String nbbm = cio.getNbbm();
  51 + if (StringUtils.isEmpty(nbbm))
  52 + return;
  53 +
  54 +
  55 + //车辆已经在泊位上,先移除(可能没有出场信号)
  56 + if(car2berthMap.containsKey(nbbm)){
  57 + if(cio.getType()==1)//待进
  58 + return;
  59 + car2berthMap.remove(nbbm);
  60 + }
  61 + Bus bus = BusDataBuffer.findOne(nbbm);
  62 + //非电车,停柴油泊位区
  63 + if(!bus.isSfdc()){
  64 + LedHttpPushHandler.busIn(bus.getCarPlate(), "柴油泊位区");
  65 + return;
  66 + }
  67 +
  68 + //是否有固定泊位
  69 + String lockBName = BerthDataBuffer.getLockBerthName(nbbm);
  70 + if(StringUtils.isNotEmpty(lockBName)){
  71 + if(cio.getType()==2)
  72 + car2berthMap.put(nbbm, lockBName);
  73 + else {
  74 + //泊位引导
  75 + LedHttpPushHandler.busIn(bus.getCarPlate(), lockBName);
  76 + }
  77 + }
  78 + else{
  79 + //停空闲泊位
  80 + List<RegionBerth> berthList = BerthDataBuffer.allNoLock();
  81 + RegionBerth free = null;
  82 + for(RegionBerth b : berthList){
  83 + //被占用的泊位
  84 + if(car2berthMap.inverse().containsKey(b.getName()))
  85 + continue;
  86 + //被禁用的泊位
  87 + if(BerthDataBuffer.isLock(b.getName()))
  88 + continue;
  89 + free = b;
  90 + break;
  91 + }
  92 + if(null != free){
  93 + if(cio.getType()==2)
  94 + car2berthMap.put(nbbm, free.getName());
  95 + else{
  96 + //泊位引导
  97 + LedHttpPushHandler.busIn(nbbm, free.getName());
  98 + }
  99 + }
  100 + else
  101 + logger.info("没有空余泊位了");
  102 + }
  103 +
  104 + //通知客户端
  105 + if(cio.getType() == 2)
  106 + sendUtils.sendCarIn(nbbm, car2berthMap.get(nbbm), cio.getT());
  107 + }
  108 +
  109 + public void busOut(CarInOutEntity cio) {
  110 + car2berthMap.remove(cio.getNbbm());
  111 +
  112 + //led
  113 + LedHttpPushHandler.busOut(cio);
  114 + //通知客户端
  115 + sendUtils.sendCarOut(cio.getNbbm(), cio.getT());
  116 + }
  117 +
  118 + public static Map<String, String> getCar2berthMap(){
  119 + return car2berthMap;
  120 + }
  121 +
  122 + /**
  123 + * 添加车辆和泊位对照
  124 + * @param nbbm
  125 + * @param berthName
  126 + * @return
  127 + */
  128 + public Map<String, Object> addCar2Berth(String nbbm, String berthName) {
  129 + Map<String, Object> rs = new HashMap<>();
  130 +
  131 + try{
  132 + if(car2berthMap.containsKey(nbbm))
  133 + car2berthMap.remove(nbbm);
  134 +
  135 + if(car2berthMap.inverse().containsKey(berthName))
  136 + car2berthMap.inverse().remove(berthName);
  137 +
  138 + car2berthMap.put(nbbm, berthName);
  139 + rs.put("status", ResponseCode.SUCCESS);
  140 + }catch (Exception e){
  141 + logger.error("", e);
  142 + rs.put("status", ResponseCode.ERROR);
  143 + }
  144 + return rs;
  145 + }
  146 +
  147 + /**
  148 + * 删除指定泊位上的车辆
  149 + * @param berthName
  150 + * @return
  151 + */
  152 + public Map<String, Object> removeCar2Berth(String berthName) {
  153 + Map<String, Object> rs = new HashMap<>();
  154 +
  155 + try{
  156 +
  157 + if(car2berthMap.inverse().containsKey(berthName))
  158 + car2berthMap.inverse().remove(berthName);
  159 +
  160 + rs.put("status", ResponseCode.SUCCESS);
  161 + }catch (Exception e){
  162 + logger.error("", e);
  163 + rs.put("status", ResponseCode.ERROR);
  164 + }
  165 + return rs;
  166 + }
  167 +
  168 + /**
  169 + * 对换指定2个泊位上的车辆
  170 + * @param s
  171 + * @param d
  172 + * @return
  173 + */
  174 + public static Map<String, Object> changeCar2Berth(String s, String d) {
  175 + Map<String, Object> rs = new HashMap<>();
  176 +
  177 + try{
  178 +
  179 + Map<String, String> inverseMap = car2berthMap.inverse();
  180 +
  181 + String sv = inverseMap.get(s);
  182 + String dv = inverseMap.get(d);
  183 +
  184 + if(sv != null){
  185 + inverseMap.remove(s);
  186 + inverseMap.put(d, sv);
  187 + }
  188 + else
  189 + inverseMap.remove(d);
  190 +
  191 + if(dv != null)
  192 + inverseMap.put(s, dv);
  193 +
  194 + rs.put("status", ResponseCode.SUCCESS);
  195 + }catch (Exception e){
  196 + logger.error("", e);
  197 + rs.put("status", ResponseCode.ERROR);
  198 + }
  199 + return rs;
  200 + }
  201 +
  202 + public boolean containsBerth(String berthName) {
  203 + return car2berthMap.inverse().containsKey(berthName);
  204 + }
  205 +
  206 + public int size() {
  207 + return car2berthMap.size();
  208 + }
  209 +}
src/main/java/com/bsth/data/in_out/thread/Car2BerthDataPstThread.java
1 package com.bsth.data.in_out.thread; 1 package com.bsth.data.in_out.thread;
2 2
3 -import com.bsth.data.in_out.RealInoutHandler; 3 +import com.bsth.data.in_out.carpark.RealBerthManager;
4 import org.slf4j.Logger; 4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory; 5 import org.slf4j.LoggerFactory;
6 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +33,7 @@ public class Car2BerthDataPstThread extends Thread { @@ -33,7 +33,7 @@ public class Car2BerthDataPstThread extends Thread {
33 @Override 33 @Override
34 public void run() { 34 public void run() {
35 try { 35 try {
36 - final Map<String, String> map = RealInoutHandler.getCar2berthMap(); 36 + final Map<String, String> map = RealBerthManager.getCar2berthMap();
37 final List<String> ks = new ArrayList<>(map.keySet()); 37 final List<String> ks = new ArrayList<>(map.keySet());
38 38
39 //编程式事务 39 //编程式事务
src/main/java/com/bsth/data/led_http/LedHttpPushHandler.java
1 package com.bsth.data.led_http; 1 package com.bsth.data.led_http;
2 2
3 -import com.bsth.data.in_out.RealInoutHandler;  
4 import com.bsth.data.in_out.buffer.BerthDataBuffer; 3 import com.bsth.data.in_out.buffer.BerthDataBuffer;
5 import com.bsth.data.in_out.buffer.ElectricDataBuffer; 4 import com.bsth.data.in_out.buffer.ElectricDataBuffer;
  5 +import com.bsth.data.in_out.carpark.RealBerthManager;
6 import com.bsth.data.utils.HttpClientUtils_tms; 6 import com.bsth.data.utils.HttpClientUtils_tms;
7 import com.bsth.entity.ac.CarInOutEntity; 7 import com.bsth.entity.ac.CarInOutEntity;
8 import com.bsth.entity.berth.RegionBerth; 8 import com.bsth.entity.berth.RegionBerth;
@@ -30,8 +30,9 @@ public class LedHttpPushHandler { @@ -30,8 +30,9 @@ public class LedHttpPushHandler {
30 private static String baseUrl; 30 private static String baseUrl;
31 //private static String outUrl; 31 //private static String outUrl;
32 32
  33 +
33 @Autowired 34 @Autowired
34 - RealInoutHandler realInoutHandler; 35 + RealBerthManager realBerthManager;
35 36
36 //上次发送停放信息时间戳 37 //上次发送停放信息时间戳
37 private static long send_tfxx_time=System.currentTimeMillis(); 38 private static long send_tfxx_time=System.currentTimeMillis();
@@ -87,9 +88,9 @@ public class LedHttpPushHandler { @@ -87,9 +88,9 @@ public class LedHttpPushHandler {
87 List<RegionBerth> list = BerthDataBuffer.all(); 88 List<RegionBerth> list = BerthDataBuffer.all();
88 can = list.size(); 89 can = list.size();
89 90
90 - yet = realInoutHandler.size(); 91 + yet = realBerthManager.size();
91 92
92 - Map<String, String> map = realInoutHandler.getCar2berthMap(); 93 + Map<String, String> map = realBerthManager.getCar2berthMap();
93 Set<String> ks = map.keySet(); 94 Set<String> ks = map.keySet();
94 95
95 Double soc; 96 Double soc;
src/main/java/com/bsth/data/schedule/real/ScheduleDataBuffer.java
@@ -3,6 +3,7 @@ package com.bsth.data.schedule.real; @@ -3,6 +3,7 @@ package com.bsth.data.schedule.real;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.bsth.Application; 4 import com.bsth.Application;
5 import com.bsth.data.basic.line.LineDataBuffer; 5 import com.bsth.data.basic.line.LineDataBuffer;
  6 +import com.bsth.data.in_out.RealInoutHandler;
6 import com.bsth.data.schedule.dto.ScheduleInOut; 7 import com.bsth.data.schedule.dto.ScheduleInOut;
7 import com.bsth.data.utils.HttpClientUtils; 8 import com.bsth.data.utils.HttpClientUtils;
8 import com.bsth.data.utils.RsRequestUtils; 9 import com.bsth.data.utils.RsRequestUtils;
@@ -223,7 +224,10 @@ public class ScheduleDataBuffer implements CommandLineRunner { @@ -223,7 +224,10 @@ public class ScheduleDataBuffer implements CommandLineRunner {
223 } 224 }
224 225
225 if (isCCar) { 226 if (isCCar) {
  227 + String oldName = old.getNbbm();
  228 + old.setNbbm(now.getNbbm());
226 //重新匹配车辆计划和实际出场 229 //重新匹配车辆计划和实际出场
  230 + RealInoutHandler.reCalcOutSignal(oldName, now.getNbbm());
227 } 231 }
228 } 232 }
229 233
src/main/java/com/bsth/service/berth/impl/BerthServiceImpl.java
@@ -2,7 +2,7 @@ package com.bsth.service.berth.impl; @@ -2,7 +2,7 @@ package com.bsth.service.berth.impl;
2 2
3 import com.bsth.controller.berth.dto.Car2Berth; 3 import com.bsth.controller.berth.dto.Car2Berth;
4 import com.bsth.data.basic.bus.BusDataBuffer; 4 import com.bsth.data.basic.bus.BusDataBuffer;
5 -import com.bsth.data.in_out.RealInoutHandler; 5 +import com.bsth.data.in_out.carpark.RealBerthManager;
6 import com.bsth.entity.berth.RegionBerth; 6 import com.bsth.entity.berth.RegionBerth;
7 import com.bsth.service.berth.BerthService; 7 import com.bsth.service.berth.BerthService;
8 import com.bsth.service.impl.BaseServiceImpl; 8 import com.bsth.service.impl.BaseServiceImpl;
@@ -23,7 +23,7 @@ public class BerthServiceImpl extends BaseServiceImpl&lt;RegionBerth, Integer&gt; impl @@ -23,7 +23,7 @@ public class BerthServiceImpl extends BaseServiceImpl&lt;RegionBerth, Integer&gt; impl
23 public List<Car2Berth> car2Berths() { 23 public List<Car2Berth> car2Berths() {
24 List<Car2Berth> list = new ArrayList<>(); 24 List<Car2Berth> list = new ArrayList<>();
25 //车辆自编号和停放泊位名称对照 25 //车辆自编号和停放泊位名称对照
26 - Map<String, String> map = RealInoutHandler.getCar2berthMap(); 26 + Map<String, String> map = RealBerthManager.getCar2berthMap();
27 Car2Berth c2b; 27 Car2Berth c2b;
28 Set<String> ks = map.keySet(); 28 Set<String> ks = map.keySet();
29 for(String nbbm : ks){ 29 for(String nbbm : ks){
src/main/java/com/bsth/websocket/handler/SendUtils.java
1 package com.bsth.websocket.handler; 1 package com.bsth.websocket.handler;
2 2
3 import com.bsth.data.abnormal.entity.AbnormalEntity; 3 import com.bsth.data.abnormal.entity.AbnormalEntity;
  4 +import com.bsth.data.schedule.dto.ScheduleInOut;
4 import com.fasterxml.jackson.databind.ObjectMapper; 5 import com.fasterxml.jackson.databind.ObjectMapper;
5 import org.slf4j.Logger; 6 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory; 7 import org.slf4j.LoggerFactory;
@@ -69,4 +70,24 @@ public class SendUtils{ @@ -69,4 +70,24 @@ public class SendUtils{
69 logger.error("", e); 70 logger.error("", e);
70 } 71 }
71 } 72 }
  73 +
  74 + /**
  75 + * 班次出场
  76 + * @param sio
  77 + */
  78 + public void scheduleOut(ScheduleInOut sio, AbnormalEntity ae) {
  79 + Map<String, Object> map = new HashMap<>();
  80 + map.put("fn", "abnormal_out");
  81 + map.put("sio", sio);
  82 + if(null != ae)
  83 + map.put("ae", ae);
  84 +
  85 + ObjectMapper mapper = new ObjectMapper();
  86 +
  87 + try {
  88 + socketHandler.sendMessage(mapper.writeValueAsString(map));
  89 + } catch (Exception e) {
  90 + logger.error("", e);
  91 + }
  92 + }
72 } 93 }
src/main/resources/static/assets/js/ct_pagination.js deleted 100644 → 0
1 -/**  
2 - * 自己写的一个分页js函数,uikit3 之后不提供js了,只提供样式  
3 - * auth panzhao  
4 - * date 2017-08-06  
5 - *  
6 - * 直接占用全局全量,,怎么高兴怎么来^v^  
7 - */  
src/main/resources/static/index.html
@@ -52,7 +52,6 @@ @@ -52,7 +52,6 @@
52 <script src="/assets/uikit-3.0.0/js/uikit.min.js"></script> 52 <script src="/assets/uikit-3.0.0/js/uikit.min.js"></script>
53 <script src="/assets/uikit-3.0.0/js/uikit-icons.min.js"></script> 53 <script src="/assets/uikit-3.0.0/js/uikit-icons.min.js"></script>
54 <script src="/assets/plugins/jquery.serializejson.js"></script> 54 <script src="/assets/plugins/jquery.serializejson.js"></script>
55 -<script src="/assets/js/common.js"></script>  
56 <script src="/assets/plugins/template.js"></script> 55 <script src="/assets/plugins/template.js"></script>
57 <script src="/assets/selectize/js/standalone/selectize.min.js"></script> 56 <script src="/assets/selectize/js/standalone/selectize.min.js"></script>
58 <script src="/assets/plugins/simplePagination/jquery.simplePagination.js"></script> 57 <script src="/assets/plugins/simplePagination/jquery.simplePagination.js"></script>
@@ -72,223 +71,20 @@ @@ -72,223 +71,20 @@
72 <script src="/assets/plugins/contextmenu/jquery.contextMenu.min.js" ></script> 71 <script src="/assets/plugins/contextmenu/jquery.contextMenu.min.js" ></script>
73 <script src="/assets/plugins/contextmenu/jquery.ui.position.min.js" ></script> 72 <script src="/assets/plugins/contextmenu/jquery.ui.position.min.js" ></script>
74 <script src="/assets/plugins/toastr/toastr.min.js"></script> 73 <script src="/assets/plugins/toastr/toastr.min.js"></script>
75 -<script src="/assets/js/tts.js"></script> 74 +<script src="/js/tts.js"></script>
76 75
77 -<script src="/assets/js/ct_autocompleter.js"></script> 76 +
  77 +<script src="/js/common.js"></script>
  78 +<!-- 主JS 文件 -->
  79 +<script src="/js/main.js"></script>
  80 +<script src="/js/ct_autocompleter.js"></script>
78 <!-- websocket --> 81 <!-- websocket -->
79 <script src="/assets/plugins/sockjs-client/sockjs.min.js"></script> 82 <script src="/assets/plugins/sockjs-client/sockjs.min.js"></script>
80 -<script>  
81 -  
82 - var gb_inout_websocket = (function () {  
83 -  
84 - var schSock = null;  
85 - var recInterval = null;  
86 - var reConnSpace = 1500;//重连间隔  
87 - var reConnCount; //重连次数  
88 - var maxReConn = 6; //最多重连次数  
89 -  
90 - var new_conn = function () {  
91 - schSock = new SockJS('/sockjs/inout');  
92 - schSock.onopen = function (e) {  
93 - if(reConnCount && reConnCount > 1)  
94 - console.log('重新连接websocket');  
95 - reConnCount = 1;  
96 - clearInterval(recInterval);  
97 - console.log('webSocket[realcontrol] onopen');  
98 - $('.top_tools').removeClass('scok-colse');  
99 - };  
100 -  
101 - //接收消息  
102 - schSock.onmessage = function (e) {  
103 - try {  
104 - var jsonMsg = $.parseJSON(e.data);  
105 - console.log('websocket...', jsonMsg);  
106 - msgHandle[jsonMsg.fn](jsonMsg);  
107 - } catch (e) {  
108 - console.log(e, e.data);  
109 - }  
110 - };  
111 -  
112 - //断开  
113 - schSock.onclose = function (e) {  
114 - console.log('和服务器连接断开....', e);  
115 - $('.top_tools').addClass('scok-colse');  
116 - //1.5秒后重新连接  
117 - recInterval = setTimeout(function () {  
118 - reConnCount++;  
119 - if(reConnCount > maxReConn){  
120 - clearInterval(recInterval);  
121 - return;  
122 - }  
123 - new_conn();  
124 - }, reConnSpace * reConnCount);  
125 - };  
126 - };  
127 -  
128 - //初始化websocket连接  
129 - new_conn();  
130 -  
131 - var msgHandle = {  
132 - carIn: carInFun,  
133 - carOut: carOutFun  
134 - };  
135 -  
136 - //子片段的进出场回调  
137 - var inoutEventCallbacks = [];  
138 -  
139 - function carInFun(msg) {  
140 - var text = msg['dataStr'] + " " +msg.nbbm + "进场" + (msg.berthName?(" 停泊位" + msg.berthName):"");  
141 - toastr.info(text);  
142 - gb_tts.speak(text);  
143 -  
144 - //CCCallFuncN  
145 - $.each(inoutEventCallbacks, function (i, cb) {  
146 - cb(msg);  
147 - });  
148 - }  
149 -  
150 - function carOutFun(msg) {  
151 - var text = msg['dataStr'] + " " + msg.nbbm + " 出场";  
152 - toastr.info(text);  
153 - gb_tts.speak(text);  
154 -  
155 - //CCCallFuncN  
156 - $.each(inoutEventCallbacks, function (i, cb) {  
157 - cb(msg);  
158 - });  
159 - }  
160 -  
161 -  
162 - var registerCallback = function (cb) {  
163 - if (cb)  
164 - inoutEventCallbacks.push(cb);  
165 - };  
166 -  
167 - var cancelCallback = function (cb) {  
168 - if(cb){  
169 - removeByValue(inoutEventCallbacks, cb);  
170 - }  
171 - };  
172 -  
173 - return {  
174 - registerCallback: registerCallback,  
175 - cancelCallback: cancelCallback  
176 - }  
177 - })();  
178 -</script>  
179 -  
180 -<script>  
181 - var company_json, company_code_name={};  
182 - var cont = $('.ct-container');  
183 - var top_btn_list = $('.ct-btn-list', cont);  
184 - var current_tcc_name, current_tcc_code;  
185 -  
186 - //按公司_分公司分组的线路数据  
187 - var groupLineArrays;  
188 -  
189 - $('.ct-btn-link', top_btn_list).on('click', function () {  
190 - var page = $(this).data('page');  
191 - if(!page)  
192 - return;  
193 - var that = this;  
194 - $('.ct-cont-body', cont).trigger('exit').empty().load(page, function () {  
195 - $('.ct-btn-link.active', top_btn_list).removeClass('active');  
196 - $(that).addClass('active');  
197 - });  
198 - });  
199 -  
200 - //停车场信息  
201 - $.get('/company_json/curr_tcc_info', function (rs) {  
202 - current_tcc_name = rs.name;  
203 - current_tcc_code = rs.code;  
204 - });  
205 -  
206 - //loading end...  
207 - var ep = EventProxy.create('load_company', 'load_lines', function (companyData, linesData) {  
208 - groupLineArrays = {};  
209 - var key;  
210 - $.each(linesData, function () {  
211 - key = this['company']+'_'+this['brancheCompany'];  
212 - if(!groupLineArrays[key])  
213 - groupLineArrays[key] = [];  
214 -  
215 - groupLineArrays[key].push(this);  
216 - });  
217 - //默认显示  
218 - $('.ct-btn-link[data-name=b_p_manager]').trigger('click');  
219 - });  
220 -  
221 - //加载公司编码对照数据  
222 - $.get('/company_json', function (rs) {  
223 - company_json = JSON.parse(rs);  
224 - for(var c in company_json){  
225 - company_code_name[c] = company_json[c].name;  
226 - for(var f in company_json[c]['fgs'])  
227 - company_code_name[c+'_'+f]=company_json[c]['fgs'][f];  
228 - }  
229 - ep.emit('load_company', company_json);  
230 - });  
231 -  
232 - //加载线路数据  
233 - $.get('/line/all', function (rs) {  
234 - ep.emit('load_lines', rs.list);  
235 - });  
236 -  
237 - $(document).on('submit', 'form', function () {  
238 - return false;  
239 - });  
240 -  
241 -  
242 - //modal hidden  
243 - $(document).on('hidden', '.uk-modal', function () {  
244 - $(this).remove();  
245 - });  
246 -  
247 - //switcher hidden stopPropagation  
248 - $(document).on('hidden', '.uk-switcher', function (e) {  
249 - e.stopPropagation();  
250 - });  
251 -  
252 - var gb_form_validation_opts = {  
253 - framework: 'uikit',  
254 - locale: 'zh_CN',  
255 - icon: {  
256 - valid: 'uk-icon-check',  
257 - invalid: 'uk-icon-times',  
258 - validating: 'uk-icon-refresh'  
259 - }  
260 - };  
261 -  
262 - var flatpickrDateTimeConfig = {  
263 - enableTime: true,  
264 - time_24hr: true,  
265 - "locale": "zh",  
266 - onOpen: function () {  
267 - $(this.calendarContainer).addClass('showTimeInput');  
268 - }  
269 - };  
270 -  
271 - toastr.options = {  
272 - "timeOut": "10000"  
273 - };  
274 -  
275 - function removeByValue(arr, val) {  
276 - for(var i=0; i<arr.length; i++) {  
277 - if(arr[i] == val) {  
278 - arr.splice(i, 1);  
279 - break;  
280 - }  
281 - }  
282 - }  
283 -  
284 - var isArray = function (obj) {  
285 - return Object.prototype.toString.call(obj) === '[object Array]';  
286 - };  
287 -</script>  
288 - 83 +<script src="/js/_websocket.js"></script>
289 <!-- 异常监管 JS --> 84 <!-- 异常监管 JS -->
290 <script src="/pages/abnormal/js/o_s_card.js"></script> 85 <script src="/pages/abnormal/js/o_s_card.js"></script>
291 <script src="/pages/abnormal/js/o_s_abnormal.js"></script> 86 <script src="/pages/abnormal/js/o_s_abnormal.js"></script>
292 <script src="/pages/abnormal/js/o_s_basic_data.js"></script> 87 <script src="/pages/abnormal/js/o_s_basic_data.js"></script>
  88 +<script src="/pages/abnormal/js/o_s_websocket.js"></script>
293 </body> 89 </body>
294 </html> 90 </html>
295 \ No newline at end of file 91 \ No newline at end of file
src/main/resources/static/js/_websocket.js 0 → 100644
  1 +
  2 +var gb_websocket = (function () {
  3 +
  4 + var schSock = null;
  5 + var recInterval = null;
  6 + var reConnSpace = 1500;//重连间隔
  7 + var reConnCount; //重连次数
  8 + var maxReConn = 6; //最多重连次数
  9 +
  10 + var new_conn = function () {
  11 + schSock = new SockJS('/sockjs/inout');
  12 + schSock.onopen = function (e) {
  13 + if(reConnCount && reConnCount > 1)
  14 + console.log('重新连接websocket');
  15 + reConnCount = 1;
  16 + clearInterval(recInterval);
  17 + console.log('webSocket[realcontrol] onopen');
  18 + $('.top_tools').removeClass('scok-colse');
  19 + };
  20 +
  21 + //接收消息
  22 + schSock.onmessage = function (e) {
  23 + try {
  24 + var jsonMsg = $.parseJSON(e.data);
  25 + console.log('websocket...', jsonMsg);
  26 + msgHandle[jsonMsg.fn](jsonMsg);
  27 + } catch (e) {
  28 + console.log(e, e.data);
  29 + }
  30 + };
  31 +
  32 + //断开
  33 + schSock.onclose = function (e) {
  34 + console.log('和服务器连接断开....', e);
  35 + $('.top_tools').addClass('scok-colse');
  36 + //1.5秒后重新连接
  37 + recInterval = setTimeout(function () {
  38 + reConnCount++;
  39 + if(reConnCount > maxReConn){
  40 + clearInterval(recInterval);
  41 + return;
  42 + }
  43 + new_conn();
  44 + }, reConnSpace * reConnCount);
  45 + };
  46 + };
  47 +
  48 + //初始化websocket连接
  49 + new_conn();
  50 +
  51 + var msgHandle = {
  52 + carIn: carInFun,
  53 + carOut: carOutFun,
  54 + abnormal_out: gb_o_s_ws_handler.out
  55 + };
  56 +
  57 + //websocket回调
  58 + var eventCallbacks = [];
  59 +
  60 + function carInFun(msg) {
  61 + var text = msg['dataStr'] + " " +msg.nbbm + "进场" + (msg.berthName?(" 停泊位" + msg.berthName):"");
  62 + toastr.info(text);
  63 + gb_tts.speak(text);
  64 +
  65 + //CCCallFuncN
  66 + $.each(eventCallbacks, function (i, cb) {
  67 + cb(msg);
  68 + });
  69 + }
  70 +
  71 + function carOutFun(msg) {
  72 + var text = msg['dataStr'] + " " + msg.nbbm + " 出场";
  73 + toastr.info(text);
  74 + gb_tts.speak(text);
  75 +
  76 + //CCCallFuncN
  77 + $.each(eventCallbacks, function (i, cb) {
  78 + cb(msg);
  79 + });
  80 + }
  81 +
  82 + var registerCallback = function (cb) {
  83 + if (cb)
  84 + eventCallbacks.push(cb);
  85 + };
  86 +
  87 + var cancelCallback = function (cb) {
  88 + if(cb){
  89 + removeByValue(eventCallbacks, cb);
  90 + }
  91 + };
  92 +
  93 + return {
  94 + registerCallback: registerCallback,
  95 + cancelCallback: cancelCallback
  96 + }
  97 +})();
0 \ No newline at end of file 98 \ No newline at end of file
src/main/resources/static/assets/js/common.js renamed to src/main/resources/static/js/common.js
src/main/resources/static/assets/js/ct_autocompleter.js renamed to src/main/resources/static/js/ct_autocompleter.js
src/main/resources/static/js/main.js 0 → 100644
  1 +var company_json, company_code_name = {};
  2 +var cont = $('.ct-container');
  3 +var top_btn_list = $('.ct-btn-list', cont);
  4 +var current_tcc_name, current_tcc_code;
  5 +
  6 +//按公司_分公司分组的线路数据
  7 +var groupLineArrays;
  8 +
  9 +//loading end...
  10 +var ep = EventProxy.create('load_company', 'load_lines', function (companyData, linesData) {
  11 + groupLineArrays = {};
  12 + var key;
  13 + $.each(linesData, function () {
  14 + key = this['company'] + '_' + this['brancheCompany'];
  15 + if (!groupLineArrays[key])
  16 + groupLineArrays[key] = [];
  17 +
  18 + groupLineArrays[key].push(this);
  19 + });
  20 + //默认显示
  21 + $('.ct-btn-link[data-name=b_p_manager]').trigger('click');
  22 +});
  23 +
  24 +$('.ct-btn-link', top_btn_list).on('click', function () {
  25 + var page = $(this).data('page');
  26 + if (!page)
  27 + return;
  28 + var that = this;
  29 + $('.ct-cont-body', cont).trigger('exit').empty().load(page, function () {
  30 + $('.ct-btn-link.active', top_btn_list).removeClass('active');
  31 + $(that).addClass('active');
  32 + });
  33 +});
  34 +
  35 +//停车场信息
  36 +$.get('/company_json/curr_tcc_info', function (rs) {
  37 + current_tcc_name = rs.name;
  38 + current_tcc_code = rs.code;
  39 +});
  40 +
  41 +//加载公司编码对照数据
  42 +$.get('/company_json', function (rs) {
  43 + company_json = JSON.parse(rs);
  44 + for (var c in company_json) {
  45 + company_code_name[c] = company_json[c].name;
  46 + for (var f in company_json[c]['fgs'])
  47 + company_code_name[c + '_' + f] = company_json[c]['fgs'][f];
  48 + }
  49 + ep.emit('load_company', company_json);
  50 +});
  51 +
  52 +//加载线路数据
  53 +$.get('/line/all', function (rs) {
  54 + ep.emit('load_lines', rs.list);
  55 +});
  56 +
  57 +$(document).on('submit', 'form', function () {
  58 + return false;
  59 +});
  60 +
  61 +
  62 +//modal hidden
  63 +$(document).on('hidden', '.uk-modal', function () {
  64 + $(this).remove();
  65 +});
  66 +
  67 +//switcher hidden stopPropagation
  68 +$(document).on('hidden', '.uk-switcher', function (e) {
  69 + e.stopPropagation();
  70 +});
  71 +
  72 +var gb_form_validation_opts = {
  73 + framework: 'uikit',
  74 + locale: 'zh_CN',
  75 + icon: {
  76 + valid: 'uk-icon-check',
  77 + invalid: 'uk-icon-times',
  78 + validating: 'uk-icon-refresh'
  79 + }
  80 +};
  81 +
  82 +var flatpickrDateTimeConfig = {
  83 + enableTime: true,
  84 + time_24hr: true,
  85 + "locale": "zh",
  86 + onOpen: function () {
  87 + $(this.calendarContainer).addClass('showTimeInput');
  88 + }
  89 +};
  90 +
  91 +toastr.options = {
  92 + "timeOut": "10000"
  93 +};
  94 +
  95 +function removeByValue(arr, val) {
  96 + for (var i = 0; i < arr.length; i++) {
  97 + if (arr[i] == val) {
  98 + arr.splice(i, 1);
  99 + break;
  100 + }
  101 + }
  102 +}
  103 +
  104 +var isArray = function (obj) {
  105 + return Object.prototype.toString.call(obj) === '[object Array]';
  106 +};
0 \ No newline at end of file 107 \ No newline at end of file
src/main/resources/static/assets/js/tts.js renamed to src/main/resources/static/js/tts.js
src/main/resources/static/pages/abnormal/js/o_s_websocket.js 0 → 100644
  1 +
  2 +/**
  3 + * 异常监管 websocket 相关处理
  4 + */
  5 +var gb_o_s_ws_handler = (function () {
  6 +
  7 + //班次出场
  8 + var out = function (msg) {
  9 + console.log('gb_o_s_ws_handler', msg);
  10 + };
  11 +
  12 + return {
  13 + out: out
  14 + };
  15 +})();
0 \ No newline at end of file 16 \ No newline at end of file
src/main/resources/static/pages/b_p_manager/b_p_main.html
@@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
77 //init drag events 77 //init drag events
78 initDragEvents(); 78 initDragEvents();
79 //注册websocket回调 79 //注册websocket回调
80 - gb_inout_websocket.registerCallback(socketInoutHandler); 80 + gb_websocket.registerCallback(socketInoutHandler);
81 //加载泊位信息 81 //加载泊位信息
82 queryRealInfos(); 82 queryRealInfos();
83 $('.berth_card_list', wrap).perfectScrollbar('update'); 83 $('.berth_card_list', wrap).perfectScrollbar('update');