Commit b56089fd06f6524f45e04bca0d87864ddcb74b13

Authored by 徐烜
2 parents d5ae91b6 343bdebb

Merge branch 'lggj' of http://192.168.168.245:8888/panzhaov5/bsth_control into lggj

src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
... ... @@ -345,8 +345,7 @@ public class AdminUtilsController {
345 345 gatewayHttpLoader.afterPropertiesSet();
346 346 gatewayHttpUtils.afterPropertiesSet();
347 347 rfidHttpLoader.afterPropertiesSet();
348   - ssoConfig.setSystemCode(SystemParamCache.getSsoSystemCode());
349   - ssoConfig.setSsoAuthUrl(SystemParamCache.getUrlHttpSsoAuth());
  348 + ssoConfig.afterPropertiesSet();
350 349  
351 350 return "success";
352 351 } catch (Exception e) {
... ... @@ -365,8 +364,7 @@ public class AdminUtilsController {
365 364 gatewayHttpLoader.afterPropertiesSet();
366 365 gatewayHttpUtils.afterPropertiesSet();
367 366 rfidHttpLoader.afterPropertiesSet();
368   - ssoConfig.setSystemCode(SystemParamCache.getSsoSystemCode());
369   - ssoConfig.setSsoAuthUrl(SystemParamCache.getUrlHttpSsoAuth());
  367 + ssoConfig.afterPropertiesSet();
370 368  
371 369 return "success";
372 370 } catch (Exception e) {
... ...
src/main/java/com/bsth/data/zndd/AutomaticSch.java
... ... @@ -5,31 +5,22 @@ import com.alibaba.fastjson.JSONObject;
5 5 import com.bsth.data.BasicData;
6 6 import com.bsth.data.adjg.domain.LargeGap;
7 7 import com.bsth.data.directive.DayOfDirectives;
8   -import com.bsth.data.directive.GatewayHttpUtils;
9   -import com.bsth.data.directive.MsgIdGenerator;
10 8 import com.bsth.data.gpsdata_v2.GpsRealData;
11 9 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
12 10 import com.bsth.data.schedule.DayOfSchedule;
13 11 import com.bsth.data.schedule.ScheduleComparator;
14   -import com.bsth.entity.StationRoute;
  12 +import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
15 13 import com.bsth.entity.directive.D60;
16   -import com.bsth.entity.realcontrol.LineConfig;
17 14 import com.bsth.entity.realcontrol.ScheduleRealInfo;
18   -import com.bsth.entity.sys.SysUser;
19 15 import com.bsth.repository.StationRouteRepository;
20   -import com.bsth.security.util.SecurityUtils;
21 16 import com.bsth.service.directive.DirectiveService;
22 17 import com.bsth.service.realcontrol.ScheduleRealInfoService;
23 18 import com.bsth.util.HttpClientUtils;
24 19 import org.apache.commons.lang3.StringUtils;
25   -import org.joda.time.format.DateTimeFormat;
26   -import org.joda.time.format.DateTimeFormatter;
27 20 import org.slf4j.Logger;
28 21 import org.slf4j.LoggerFactory;
29 22 import org.springframework.beans.factory.annotation.Autowired;
30 23 import org.springframework.stereotype.Component;
31   -
32   -import javax.xml.crypto.Data;
33 24 import java.text.ParseException;
34 25 import java.text.SimpleDateFormat;
35 26 import java.util.*;
... ... @@ -57,13 +48,15 @@ public class AutomaticSch {
57 48 StationRouteRepository stationRouteRepository;
58 49 @Autowired
59 50 OutEntrance outEntrance;
  51 + @Autowired
  52 + carMonitor carMonitor;
  53 + @Autowired
  54 + BasicData basicData;
60 55  
61   - private static DateTimeFormatter fmtHHmmss = DateTimeFormat.forPattern("HHmmss");
62   - private static SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd");
63   - private static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-ddHHmmss");
64 56 private static SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm");
65 57 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
66   -
  58 +
  59 + private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.DFSJ2();
67 60 private Map<String,Long> drivreMap =new HashMap<>(); //自动重发map
68 61 // 当日60指令缓存
69 62 private ConcurrentMap<Integer, D60> d60Map = new ConcurrentHashMap<>();//d60map
... ... @@ -132,13 +125,12 @@ public class AutomaticSch {
132 125 //获取所有线路
133 126 Map<String, String> lineMap = BasicData.lineCode2NameMap;
134 127 for (Map.Entry<String, String> t : lineMap.entrySet()){
135   - List<GpsEntity> gpslist = gpsRealData.getByLine(t.getKey());
136 128 List<ScheduleRealInfo> srList = dayOfSchedule.findByLineCode(t.getKey());
137 129 for (ScheduleRealInfo sr : srList){
138 130 //1.离线 2.实发时间为空 3.已过待发时间还没发车的
139 131 long time = System.currentTimeMillis();//实际时间+2分钟
140 132 //超过待发时间 实发时间还是null的
141   - if (sr.getFcsjT() + (1000*3) < time) {
  133 + if (sr.getFcsjT() + (1000*3) > time) {
142 134  
143 135 //起点站实际到达时间为null的情况下
144 136 if (StringUtils.isEmpty(sr.getQdzArrDatesj())) {
... ... @@ -150,7 +142,7 @@ public class AutomaticSch {
150 142 }
151 143 //第一种 设备离线的情况下改出站
152 144 Integer staus = 0; //状态
153   - if (StringUtils.isEmpty(sr.getFcsjActual()) && sr.getBcType().equals("normal") && sr.getRemarks() == null) {
  145 + if (StringUtils.isEmpty(sr.getFcsjActual()) && sr.getBcType().equals("normal") && StringUtils.isEmpty(sr.getRemarks())) {
154 146  
155 147 GpsEntity gps = gpsRealData.getByNbbm(sr.getClZbh());
156 148 //当前设备离线的情况
... ... @@ -189,7 +181,7 @@ public class AutomaticSch {
189 181 Collections.sort(oldSchDateList, new ScheduleComparator.FCSJ());
190 182 for (ScheduleRealInfo t : oldSchDateList){
191 183 // 发车误点
192   - if (t.getFcsj() != null && t.getFcsjActual() != null && t.getBcType().equals("normal") && t.getRemarks() == null){
  184 + if (t.getFcsj() != null && t.getFcsjActual() != null && t.getBcType().equals("normal") && StringUtils.isEmpty(t.getRemarks())){
193 185 Long sst = ((t.getFcsjActualTime() - t.getFcsjT()) / 1000 / 60);
194 186 Long fcsj = t.getFcsjT() / 1000 ;
195 187 Long sfsj = t.getFcsjActualTime() / 1000;
... ... @@ -284,23 +276,50 @@ public class AutomaticSch {
284 276 }
285 277 }
286 278 }
287   -
288   -
289   -
290   -
291 279 }catch (Exception e){
292 280 logger.error("自动调度,指令重发---",e);
293 281 }
294 282 logger.warn("指令重发扫描结束");
295 283 }
296   -
297 284 //误点检测 调度有的-LateAdjustHandle
298   - public Map wd(ScheduleRealInfo sch){
  285 + public Map wd(){
299 286 //推送
300 287 try{
301   - return addStationPeople(sch, "WD", 0L);
  288 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
  289 + Collections.sort(all, cpm);
  290 + long t = System.currentTimeMillis();
  291 + int size = all.size();
  292 + ScheduleRealInfo sch;
  293 + for(int i = 0; i < size; i ++){
  294 + sch = all.get(i);
  295 + if(sch.getDfsjT() > t)
  296 + break;
  297 +
  298 + /*if(sch.isLate())
  299 + continue;*/
  300 +
  301 + if(sch.getStatus() == 0
  302 + && StringUtils.isEmpty(sch.getFcsjActual())){
  303 +
  304 + //检查应发未到 当前班次无起点到达时间
  305 + if(StringUtils.isEmpty(sch.getQdzArrDatesj())){
  306 + ScheduleRealInfo prev = dayOfSchedule.prev(sch);
  307 + //上一个班次也没有实际终点到达时间
  308 + if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){
  309 + //进入误点调整程序
  310 + LateAdjustHandle.putLate(sch);
  311 + List<Map> dzList = carMonitor.carMonitor(prev.getXlBm(), prev.getXlDir(), prev.getZdzCode()); //信息发布接口
  312 + for (Map m : dzList){
  313 + if (m.get("terminal").equals(basicData.nbbmCompanyPlateMap.get(prev.getClZbh()).replaceAll("-",""))){
  314 + return addStationPeople(sch, "WD", 0L);
  315 + }
  316 + }
  317 + }
  318 + };
  319 + }
  320 + }
302 321 }catch (Exception e){
303   - logger.error("自动调度,推送失败---",e);
  322 + logger.error("误点检测推送接口出错---",e);
304 323 }
305 324 return null;
306 325 }
... ... @@ -324,12 +343,6 @@ public class AutomaticSch {
324 343 }
325 344 }
326 345 outEntrance.Znddjk(m);//测试推送
327   - if (i == list.size()){
328   - list.add(sj);
329   - ZnddThread.ZNDDTYPEMAP.put(st,list);//存记录
330   - outEntrance.Znddjk(m);//推送
331   - }
332   - return;
333 346 }else {
334 347 list.add(sj);
335 348 ZnddThread.ZNDDTYPEMAP.put(st,list);//存记录
... ...
src/main/java/com/bsth/data/zndd/OutEntrance.java
1 1 package com.bsth.data.zndd;
2 2 import com.bsth.common.ResponseCode;
3 3 import com.bsth.data.schedule.DayOfSchedule;
4   -import com.bsth.data.schedule.ScheduleComparator;
5   -import com.bsth.data.adjg.domain.LargeGap;
6 4 import com.bsth.websocket.handler.SendUtils;
7 5 import com.fasterxml.jackson.databind.ObjectMapper;
8 6 import org.slf4j.Logger;
9 7 import org.slf4j.LoggerFactory;
10 8 import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.beans.factory.annotation.Value;
12 9 import org.springframework.web.bind.annotation.*;
13   -import sun.misc.BASE64Decoder;
14   -
15 10 import java.io.*;
16 11 import java.text.SimpleDateFormat;
17   -import java.time.LocalTime;
18   -import java.time.format.DateTimeFormatter;
19 12 import java.util.*;
20 13  
21 14 /**
... ... @@ -170,10 +163,10 @@ public class OutEntrance {
170 163  
171 164  
172 165 base=base.replaceAll("data:image/png;base64,","");
173   - BASE64Decoder decoder = new BASE64Decoder();
  166 + Base64.Decoder decoder = Base64.getDecoder();
174 167 byte[] imageByte = null;
175 168 try{
176   - imageByte = decoder.decodeBuffer(base);
  169 + imageByte = decoder.decode(base);
177 170 for (int i = 0; i < imageByte.length; ++i) {
178 171 if (imageByte[i] < 0) {// 调整异常数据
179 172 imageByte[i] += 256;
... ...
src/main/java/com/bsth/data/zndd/ZnddThread.java
... ... @@ -80,6 +80,10 @@ public class ZnddThread extends Thread{
80 80 automaticSch.drivresponse();
81 81 logger.info("设备重发执行完毕");
82 82 }
  83 + if (zs.getType().equals("wd")){
  84 + automaticSch.wd();
  85 + logger.info("误点执行完毕");
  86 + }
83 87 }
84 88 }
85 89 }catch (Exception e){
... ...
src/main/java/com/bsth/data/zndd/carMonitor.java 0 → 100644
  1 +package com.bsth.data.zndd;
  2 +
  3 +import org.apache.commons.io.IOUtils;
  4 +import org.dom4j.Document;
  5 +import org.dom4j.DocumentHelper;
  6 +import org.dom4j.Element;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.io.ByteArrayOutputStream;
  12 +import java.io.InputStream;
  13 +import java.io.OutputStream;
  14 +import java.net.HttpURLConnection;
  15 +import java.net.URL;
  16 +import java.nio.charset.Charset;
  17 +import java.util.*;
  18 +
  19 +@Component
  20 +public class carMonitor {
  21 + Logger logger = LoggerFactory.getLogger(this.getClass());
  22 +
  23 + static String url;
  24 +
  25 +
  26 + public List<Map> carMonitor(String lineCode,String directions,String station) {
  27 +
  28 + List<Map> list = new ArrayList<>(); //返回的接口数据
  29 + url = "http://58.34.52.130:9777/xxfb/carMonitor?lineid="+lineCode+"&stopid="+station+"&direction="+directions+"&t=";
  30 + InputStream in = null;
  31 + OutputStream out = null;
  32 + try {
  33 + HttpURLConnection con = (HttpURLConnection)new URL(url).openConnection();
  34 + con.setDoInput(true);
  35 + con.setDoOutput(true);
  36 + con.setRequestMethod("GET");
  37 + con.setConnectTimeout(15000);
  38 + con.setReadTimeout(15000);
  39 + con.setRequestProperty("keep-alive", "true");
  40 + con.setRequestProperty("accept", "application/json");
  41 + con.setRequestProperty("content-type", "application/json;charset=UTF-8");
  42 +
  43 + //System.out.println(con.getResponseCode());
  44 + //if (con.getResponseCode() == 200) {
  45 + in = con.getInputStream();
  46 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  47 + IOUtils.copy(in, bout);
  48 + //System.out.println(new String(bout.toByteArray()));
  49 + if (bout.toByteArray().length == 0){
  50 + return list;
  51 + }
  52 + Document doc = null;
  53 + doc = DocumentHelper.parseText(new String(bout.toByteArray(), Charset.forName("UTF-8")));
  54 +
  55 + // 获取根节点
  56 + Element rootElt = doc.getRootElement();
  57 + //获取到根节点的名称
  58 + //System.out.println("根节点:" + rootElt.getName());
  59 +
  60 + Iterator iter = rootElt.elementIterator("cars");
  61 + while (iter.hasNext()) {
  62 + //获取到第二级节点元所有元素
  63 + Element sessionEle = (Element) iter.next();
  64 + //System.out.println("-第一级节点名称: " + sessionEle.getName());
  65 + //获取到第二级节点指定的子节点
  66 + Iterator iterResponse = sessionEle.elementIterator("car");
  67 + while (iterResponse.hasNext()){
  68 + Map map = new HashMap();
  69 + //获取到所有第三级子节点所有元素
  70 + Element responseEle = (Element) iterResponse.next();
  71 + //System.out.println("--第二级节点名称: "+ responseEle.getName());
  72 + //获取到第三级节点指定的子节点
  73 + map.put("terminal",responseEle.elementTextTrim("terminal"));
  74 + map.put("stopdis",responseEle.elementTextTrim("stopdis"));
  75 + map.put("distance",responseEle.elementTextTrim("distance"));
  76 + map.put("time",responseEle.elementTextTrim("time"));
  77 + map.put("sj",Gpstime(responseEle.elementTextTrim("time")));
  78 + map.put("loc",responseEle.elementTextTrim("loc"));
  79 + map.put("gpstime",responseEle.elementTextTrim("gpstime"));
  80 + map.put("direction",responseEle.elementTextTrim("direction"));
  81 + list.add(map);
  82 + }
  83 + }
  84 + //System.out.println(maps.size());
  85 + } catch (Exception e) {
  86 + logger.error("信息发布接口报错了----", e);
  87 + }
  88 +
  89 + return list;
  90 + }
  91 +
  92 + public String Gpstime(String duration){
  93 + Integer seconds = Integer.parseInt(duration);
  94 + Integer hours = seconds / 3600;
  95 + Integer minutes = (seconds % 3600) / 60;
  96 + Integer remainingSeconds = seconds % 60;
  97 +
  98 + if (hours!= 0){
  99 + return hours+"时"+ minutes+"分"+remainingSeconds+"秒";
  100 + }else if (minutes != 0){
  101 + return minutes+"分"+remainingSeconds+"秒";
  102 + }else {
  103 + return remainingSeconds+"秒";
  104 + }
  105 + }
  106 +
  107 +}
... ...
src/main/java/com/bsth/security/SsoConfig.java
1 1 package com.bsth.security;
2 2  
3 3 import com.bsth.common.Constants;
  4 +import com.bsth.data.SystemParamCache;
  5 +import org.springframework.beans.factory.InitializingBean;
4 6 import org.springframework.beans.factory.annotation.Value;
5 7 import org.springframework.stereotype.Component;
6 8  
... ... @@ -9,7 +11,7 @@ import org.springframework.stereotype.Component;
9 11 * @author Hill
10 12 */
11 13 @Component
12   -public class SsoConfig {
  14 +public class SsoConfig implements InitializingBean {
13 15  
14 16 /**
15 17 * 是否开启sso登录
... ... @@ -87,4 +89,10 @@ public class SsoConfig {
87 89 public void setSsoAuthUrl(String ssoAuthUrl) {
88 90 this.ssoAuthUrl = ssoAuthUrl;
89 91 }
  92 +
  93 + @Override
  94 + public void afterPropertiesSet() throws Exception {
  95 + setSystemCode(SystemParamCache.getSsoSystemCode());
  96 + setSsoAuthUrl(SystemParamCache.getUrlHttpSsoAuth());
  97 + }
90 98 }
... ...