Commit 7c68baa1c692af1a5cd7cd9033ac10a0415fa723

Authored by ljq
1 parent 077bf7cd

一件报警与智能调度推送优化

src/main/java/com/bsth/data/pilot80/PilotReport.java
... ... @@ -135,8 +135,6 @@ public class PilotReport {
135 135 }
136 136 if (d80.getSchId() != null){
137 137 sch = dayOfSchedule.get(d80.getSchId());
138   - Long nextschid = dayOfSchedule.nextByLp(sch).getId();
139   - d80.setNextschId(nextschid);
140 138 }
141 139 String url = systemParamService.getValue("url.yjbj")+"dataDockingApi/accident/saveAccident?";
142 140 url = url + "accidentTime=" + new Date().getTime() + "&nbbm=" + nbbm +"&requestCode=" +d80.getData().getRequestCode()
... ... @@ -154,6 +152,10 @@ public class PilotReport {
154 152 }else {
155 153 logger.info("报警请求失败="+ jsonObject.get("msg"));
156 154 }
  155 + if (d80.getSchId() != null && dayOfSchedule.nextByLp(sch) != null){
  156 + Long nextschid = dayOfSchedule.nextByLp(sch).getId();
  157 + d80.setNextschId(nextschid);
  158 + }
157 159 }catch (Exception e){
158 160 logger.info("报警请求异常",e);
159 161 }
... ...
src/main/java/com/bsth/data/zndd/AutomaticSch.java
... ... @@ -27,6 +27,7 @@ import com.bsth.service.zndd.ZnddLoggerService;
27 27 import com.bsth.service.zndd.ZnddYuAnService;
28 28 import com.bsth.util.DateUtils;
29 29 import com.bsth.util.HttpClientUtils;
  30 +import com.bsth.websocket.handler.SendUtils;
30 31 import org.apache.commons.lang3.StringUtils;
31 32 import org.slf4j.Logger;
32 33 import org.slf4j.LoggerFactory;
... ... @@ -72,7 +73,8 @@ public class AutomaticSch {
72 73 @Autowired
73 74 SchEditInfoService schEditInfoService;
74 75  
75   -
  76 + @Autowired
  77 + SendUtils sendUtils;
76 78 private static SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm");
77 79 private static SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd");
78 80 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
... ... @@ -498,7 +500,7 @@ public class AutomaticSch {
498 500 splogger.setClZbh(m.get("clzbh").toString());
499 501 znddLoggerService.save(splogger);
500 502  
501   - outEntrance.Znddjk(m);//推送
  503 + sendUtils.sendzndd(m);//推送
502 504 }
503 505  
504 506  
... ...
src/main/java/com/bsth/data/zndd/OutEntrance.java
... ... @@ -16,14 +16,12 @@ import com.bsth.service.DKLInfoService;
16 16 import com.bsth.util.HttpClientUtils;
17 17 import com.bsth.util.SignUtils;
18 18 import com.bsth.websocket.handler.SendUtils;
19   -import com.fasterxml.jackson.databind.ObjectMapper;
20 19 import org.slf4j.Logger;
21 20 import org.slf4j.LoggerFactory;
22 21 import org.springframework.beans.factory.annotation.Autowired;
23 22 import org.springframework.beans.factory.annotation.Value;
24 23 import org.springframework.dao.DataAccessException;
25 24 import org.springframework.jdbc.core.JdbcTemplate;
26   -import org.springframework.scheduling.annotation.Scheduled;
27 25 import org.springframework.web.bind.annotation.*;
28 26  
29 27 import java.io.*;
... ... @@ -33,7 +31,6 @@ import java.nio.file.Paths;
33 31 import java.nio.file.StandardCopyOption;
34 32 import java.text.SimpleDateFormat;
35 33 import java.time.Duration;
36   -import java.time.LocalDateTime;
37 34 import java.time.LocalTime;
38 35 import java.time.format.DateTimeFormatter;
39 36 import java.util.*;
... ... @@ -312,19 +309,34 @@ public class OutEntrance {
312 309 Map rtn = new HashMap<>();
313 310  
314 311 try {
315   - ObjectMapper mapper = new ObjectMapper();
316   - //线调页面推送
317   - sendUtils.sendzndd(m);
318   -
  312 + List<ScheduleRealInfo> sr = dayOfSchedule.findByBcType(m.get("nbbm").toString(),"normal");
  313 + automaticSch.ts(automaticSch.addStationPeople(sr.get(Integer.parseInt(m.get("num").toString())), m.get("type").toString(), 0L));//测试接口
319 314 rtn.put("status",ResponseCode.SUCCESS);
320 315 } catch (Exception e) {
321   - rtn.put("status",ResponseCode.ERROR);
  316 + rtn.put("err",ResponseCode.ERROR);
322 317 logger.info("智能调度推送----",e);
323 318 }
324 319  
325 320 return rtn;
326 321 }
327 322  
  323 +/*
  324 + //大客流消息测试接口
  325 + @RequestMapping(value="/znMeeage",method = RequestMethod.GET)
  326 + public Map znddMessagejk(@RequestParam Map m){
  327 + Map rtn = new HashMap<>();
  328 + try {
  329 + List<ScheduleRealInfo> sr = dayOfSchedule.findByBcType(m.get("nbbm").toString(),"normal");
  330 + ZnddMessage.saveSch(sr.get(Integer.parseInt(m.get("num").toString())));
  331 + rtn.put("status",ResponseCode.SUCCESS);
  332 + } catch (Exception e) {
  333 + rtn.put("err",ResponseCode.ERROR);
  334 + logger.info("大客流消息推送----",e);
  335 + }
  336 + return rtn;
  337 + }
  338 +*/
  339 +
328 340  
329 341  
330 342 /**
... ... @@ -440,6 +452,7 @@ public class OutEntrance {
440 452 return traffic.get("trafficStatus").toString();
441 453 }
442 454  
  455 +/*
443 456 @Scheduled(cron = "0 0 0 * * ?")
444 457 public void clearImg(){
445 458 try {
... ... @@ -451,6 +464,7 @@ public class OutEntrance {
451 464 e.printStackTrace();
452 465 }
453 466 }
  467 +*/
454 468  
455 469 public static void delete(File folder) throws Exception{
456 470 if(folder.isDirectory()) {
... ...
src/main/java/com/bsth/data/zndd/ZnddThread.java
... ... @@ -2,9 +2,7 @@ package com.bsth.data.zndd;
2 2  
3 3 import com.bsth.data.LineConfigData;
4 4 import com.bsth.data.gpsdata_v2.GpsRealData;
5   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 5 import com.bsth.data.schedule.DayOfSchedule;
7   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 6 import com.bsth.entity.zndd.znddStatus;
9 7 import com.bsth.repository.StationRouteRepository;
10 8 import com.bsth.repository.zndd.ZnddStatusRepository;
... ... @@ -13,9 +11,10 @@ import org.slf4j.LoggerFactory;
13 11 import org.springframework.beans.factory.annotation.Autowired;
14 12 import org.springframework.stereotype.Component;
15 13  
16   -import java.text.ParseException;
17 14 import java.text.SimpleDateFormat;
18   -import java.util.*;
  15 +import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.Map;
19 18  
20 19 /**
21 20 * 调度预案 发车间隔、误点、大间隔、满载、大客流
... ... @@ -35,8 +34,6 @@ public class ZnddThread extends Thread{
35 34 @Autowired
36 35 StationRouteRepository stationRouteRepository;
37 36 @Autowired
38   - OutEntrance outEntrance;
39   - @Autowired
40 37 AutomaticSch automaticSch;
41 38  
42 39 @Autowired
... ... @@ -83,120 +80,9 @@ public class ZnddThread extends Thread{
83 80  
84 81  
85 82 }
86   - //满载
87   - /* public void MZ(){
88   - try {
89   - StringBuilder sb = HttpClientUtils.get(url);
90   - List<Object> list = JSONArray.parseArray(String.valueOf(sb));
91   - for (Object b :list){
92   - Map m = (Map) b;
93   - Integer num = Integer.parseInt(m.get("inside_num").toString());
94   - if (num >= 15){ //大间隔阈值 检测到超过15个人的时候推送
95   - ScheduleRealInfo sr = dayOfSchedule.executeCurr(m.get("nbbm").toString()); //查询当前车辆执行班次
96   - GpsEntity gps = gpsRealData.get(m.get("sbbh").toString());
97   - Map msp = new HashMap();
98   - msp.put("lineCode",m.get("xlbm"));
99   - msp.put("lineName",m.get("xlmc"));
100   - msp.put("stationName",gps.getStationName());
101   - msp.put("rqStr",sdfMonth.format(new Date()));
102   - msp.put("rq",sdfHHmm.format(new Date()));
103   - msp.put("type","MZ");
104   - msp.put("numType",num);
105   - if (sr != null )
106   - msp.put("xlDir",sr.getXlDir());
107   -
108   - if (gps != null )
109   - msp.put("station",gps.getStation().getCode());
110   -
111   - ts(msp);
112   - }
113   - }
114   -
115   - }catch (Exception e){
116   - logger.error("满载检测接口出错-----------",e);
117   - }
118   - }*/
119   - public void ts(Map m) throws ParseException {
120   - outEntrance.Znddjk(m);//测试推送
121   - }
122   - /* public void ts(Map m) throws ParseException {
123   - //记录存一下 --超过当前时间的是否推送?
124   - String st = m.get("lineCode")+"_"+m.get("type")+"_"+m.get("rqStr");
125   - Long sj = sdf.parse(m.get("rqStr").toString() +" "+ m.get("rq")).getTime();
126   - List<Long> list = new ArrayList();
127   - //111_DJG_2024-06-24
128   - if (ZNDDTYPEMAP.get(st) != null ) {
129   - list = ZNDDTYPEMAP.get(st);
130   - int i = 0;
131   - for (Long s : list){
132   - if (Math.abs(s - sj) > (60 * 60 * 1000)){
133   - i ++ ;
134   - }
135   - }
136   - if (i == list.size()){
137   - list.add(sj);
138   - ZNDDTYPEMAP.put(st,list);//存记录
139   - outEntrance.Znddjk(m);//推送
140   - }
141   - return;
142   - }else {
143   - list.add(sj);
144   - ZNDDTYPEMAP.put(st,list);//存记录
145   - outEntrance.Znddjk(m);//推送
146   - }
147   -
148   - }
149   -
150   -*/
151   -
152   - /* //发车间隔
153   - public void FCJG(){
154   - try {
155   - //无数据情况下 查看发车间隔配置数据是否正常bsth_c_calc_interval
156   - List<CalcIntervalDetail> fcjgList = userCarCountHandler.calcLast();
157   - if (fcjgList!= null && !fcjgList.isEmpty()){
158   - for (CalcIntervalDetail cd : fcjgList){
159   - Map sp = new HashMap();
160   - sp.put("lineCode",cd.getLineCode());
161   - sp.put("lineName",cd.getLineName());
162   - sp.put("rqStr",cd.getDate());
163   - sp.put("rq",cd.getSjfc2());
164   - sp.put("type","FCJG");
165   - sp.put("xlDir",cd.getXlDir());
166   - sp.put("numType",cd.getSubTime());
167   - sp.put("fcsj",cd.getSjfc2());
168   - sp.put("stationName",cd.getStation());
169   - ts(sp);
170   - }
171   - }
172   - }catch (Exception e){
173   - logger.error("发车间隔检测出现出错-----------",e);
174   - }
175   - }
176   -*/
177   -
178   - //转换
179   - public Map addStationPeople(ScheduleRealInfo info,String type,Long sst,String sj) throws ParseException{
180   - Map sp = new HashMap();
181   - sp.put("lineCode",info.getXlBm());
182   - sp.put("lineName",info.getXlName() );
183   - sp.put("rqStr",info.getScheduleDateStr());
184   - sp.put("rq",new java.sql.Date(sdf.parse((info.getScheduleDateStr()+" " + sj)).getTime())); //检测到时间
185   - sp.put("type",type);
186   - sp.put("xlDir",info.getXlDir());
187   - sp.put("numType",sst);
188   - return sp;
189   - }
190 83  
191 84  
192 85  
193   - //排序
194   - public static class GpsComp implements Comparator<GpsEntity> {
195   - @Override
196   - public int compare(GpsEntity o1, GpsEntity o2) {
197   - return Integer.parseInt(o1.getRemark()) - Integer.parseInt(o2.getRemark());
198   - }
199   - }
200 86  
201 87 }
202 88  
... ...
src/main/java/com/bsth/data/zndd/ZnddTwoThread.java
... ... @@ -2,9 +2,7 @@ package com.bsth.data.zndd;
2 2  
3 3 import com.bsth.data.LineConfigData;
4 4 import com.bsth.data.gpsdata_v2.GpsRealData;
5   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 5 import com.bsth.data.schedule.DayOfSchedule;
7   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 6 import com.bsth.entity.zndd.znddStatus;
9 7 import com.bsth.repository.StationRouteRepository;
10 8 import com.bsth.repository.zndd.ZnddStatusRepository;
... ... @@ -13,9 +11,7 @@ import org.slf4j.LoggerFactory;
13 11 import org.springframework.beans.factory.annotation.Autowired;
14 12 import org.springframework.stereotype.Component;
15 13  
16   -import java.text.ParseException;
17 14 import java.text.SimpleDateFormat;
18   -import java.util.Comparator;
19 15 import java.util.HashMap;
20 16 import java.util.List;
21 17 import java.util.Map;
... ... @@ -38,8 +34,6 @@ public class ZnddTwoThread extends Thread{
38 34 @Autowired
39 35 StationRouteRepository stationRouteRepository;
40 36 @Autowired
41   - OutEntrance outEntrance;
42   - @Autowired
43 37 AutomaticSch automaticSch;
44 38  
45 39 @Autowired
... ... @@ -120,120 +114,5 @@ public class ZnddTwoThread extends Thread{
120 114 }
121 115  
122 116  
123   - //满载
124   - /* public void MZ(){
125   - try {
126   - StringBuilder sb = HttpClientUtils.get(url);
127   - List<Object> list = JSONArray.parseArray(String.valueOf(sb));
128   - for (Object b :list){
129   - Map m = (Map) b;
130   - Integer num = Integer.parseInt(m.get("inside_num").toString());
131   - if (num >= 15){ //大间隔阈值 检测到超过15个人的时候推送
132   - ScheduleRealInfo sr = dayOfSchedule.executeCurr(m.get("nbbm").toString()); //查询当前车辆执行班次
133   - GpsEntity gps = gpsRealData.get(m.get("sbbh").toString());
134   - Map msp = new HashMap();
135   - msp.put("lineCode",m.get("xlbm"));
136   - msp.put("lineName",m.get("xlmc"));
137   - msp.put("stationName",gps.getStationName());
138   - msp.put("rqStr",sdfMonth.format(new Date()));
139   - msp.put("rq",sdfHHmm.format(new Date()));
140   - msp.put("type","MZ");
141   - msp.put("numType",num);
142   - if (sr != null )
143   - msp.put("xlDir",sr.getXlDir());
144   -
145   - if (gps != null )
146   - msp.put("station",gps.getStation().getCode());
147   -
148   - ts(msp);
149   - }
150   - }
151   -
152   - }catch (Exception e){
153   - logger.error("满载检测接口出错-----------",e);
154   - }
155   - }*/
156   - public void ts(Map m) throws ParseException {
157   - outEntrance.Znddjk(m);//测试推送
158   - }
159   - /* public void ts(Map m) throws ParseException {
160   - //记录存一下 --超过当前时间的是否推送?
161   - String st = m.get("lineCode")+"_"+m.get("type")+"_"+m.get("rqStr");
162   - Long sj = sdf.parse(m.get("rqStr").toString() +" "+ m.get("rq")).getTime();
163   - List<Long> list = new ArrayList();
164   - //111_DJG_2024-06-24
165   - if (ZNDDTYPEMAP.get(st) != null ) {
166   - list = ZNDDTYPEMAP.get(st);
167   - int i = 0;
168   - for (Long s : list){
169   - if (Math.abs(s - sj) > (60 * 60 * 1000)){
170   - i ++ ;
171   - }
172   - }
173   - if (i == list.size()){
174   - list.add(sj);
175   - ZNDDTYPEMAP.put(st,list);//存记录
176   - outEntrance.Znddjk(m);//推送
177   - }
178   - return;
179   - }else {
180   - list.add(sj);
181   - ZNDDTYPEMAP.put(st,list);//存记录
182   - outEntrance.Znddjk(m);//推送
183   - }
184   -
185   - }
186   -
187   -*/
188   -
189   - /* //发车间隔
190   - public void FCJG(){
191   - try {
192   - //无数据情况下 查看发车间隔配置数据是否正常bsth_c_calc_interval
193   - List<CalcIntervalDetail> fcjgList = userCarCountHandler.calcLast();
194   - if (fcjgList!= null && !fcjgList.isEmpty()){
195   - for (CalcIntervalDetail cd : fcjgList){
196   - Map sp = new HashMap();
197   - sp.put("lineCode",cd.getLineCode());
198   - sp.put("lineName",cd.getLineName());
199   - sp.put("rqStr",cd.getDate());
200   - sp.put("rq",cd.getSjfc2());
201   - sp.put("type","FCJG");
202   - sp.put("xlDir",cd.getXlDir());
203   - sp.put("numType",cd.getSubTime());
204   - sp.put("fcsj",cd.getSjfc2());
205   - sp.put("stationName",cd.getStation());
206   - ts(sp);
207   - }
208   - }
209   - }catch (Exception e){
210   - logger.error("发车间隔检测出现出错-----------",e);
211   - }
212   - }
213   -*/
214   -
215   - //转换
216   - public Map addStationPeople(ScheduleRealInfo info,String type,Long sst,String sj) throws ParseException{
217   - Map sp = new HashMap();
218   - sp.put("lineCode",info.getXlBm());
219   - sp.put("lineName",info.getXlName() );
220   - sp.put("rqStr",info.getScheduleDateStr());
221   - sp.put("rq",new java.sql.Date(sdf.parse((info.getScheduleDateStr()+" " + sj)).getTime())); //检测到时间
222   - sp.put("type",type);
223   - sp.put("xlDir",info.getXlDir());
224   - sp.put("numType",sst);
225   - return sp;
226   - }
227   -
228   -
229   -
230   - //排序
231   - public static class GpsComp implements Comparator<GpsEntity> {
232   - @Override
233   - public int compare(GpsEntity o1, GpsEntity o2) {
234   - return Integer.parseInt(o1.getRemark()) - Integer.parseInt(o2.getRemark());
235   - }
236   - }
237   -
238 117 }
239 118  
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
... ... @@ -273,6 +273,21 @@ public class ScheduleRealInfo implements Cloneable{
273 273 @Transient
274 274 private int regionSwitchState;
275 275  
  276 + /**
  277 + *大客流进度 0下发驾驶员,1下发车辆,2,班次就位
  278 + */
  279 + @Transient
  280 + private int messageDKL;
  281 +
  282 + public int getMessageDKL() {
  283 + return messageDKL;
  284 + }
  285 +
  286 + public void setMessageDKL(int messageDKL) {
  287 + this.messageDKL = messageDKL;
  288 + }
  289 +
  290 +
276 291 public Integer getLpChange() {
277 292 return lpChange;
278 293 }
... ...