Commit 2f5b50c57f47a640b192f5445638d2d7cda90092

Authored by 潘钊
2 parents 106e4427 effff2cb

Merge branch 'pudong' into jiading

# Conflicts:
#	src/main/resources/application-prod.properties
#	src/main/resources/datatools/config-prod.properties
#	src/main/resources/ms-jdbc.properties
#	src/main/resources/static/index.html
#	src/main/resources/static/login.html
#	src/main/resources/static/real_control_v2/main.html
Showing 59 changed files with 1254 additions and 2756 deletions

Too many changes to show.

To preserve performance only 59 of 512 files are displayed.

... ... @@ -250,15 +250,6 @@
250 250 <version>1.7.4</version>
251 251 </dependency>
252 252  
253   -
254   - <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
255   - <optional>true</optional> </dependency> -->
256   - <dependency>
257   - <groupId>com.vividsolutions</groupId>
258   - <artifactId>jts</artifactId>
259   - <version>1.13</version>
260   - </dependency>
261   -
262 253 <dependency>
263 254 <groupId>org.dbunit</groupId>
264 255 <artifactId>dbunit</artifactId>
... ...
src/main/java/com/bsth/Application.java
... ... @@ -17,7 +17,7 @@ import java.util.concurrent.ScheduledExecutorService;
17 17 @SpringBootApplication
18 18 public class Application extends SpringBootServletInitializer {
19 19  
20   - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(16);
  20 + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18);
21 21  
22 22 @Override
23 23 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
... ...
src/main/java/com/bsth/XDApplication.java
1 1 package com.bsth;
2 2  
3 3 import com.bsth.data.BasicData;
  4 +import com.bsth.data.LineVersionsData;
4 5 import com.bsth.data.ThreadMonotor;
5 6 import com.bsth.data.car_out_info.UpdateDBThread;
6 7 import com.bsth.data.directive.DirectivesPstThread;
7 8 import com.bsth.data.forecast.SampleTimeDataLoader;
8   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
9   -import com.bsth.data.gpsdata.thread.OfflineMonitorThread;
  9 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
  10 +import com.bsth.data.gpsdata_v2.thread.OfflineMonitorThread;
10 11 import com.bsth.data.msg_queue.DirectivePushQueue;
11 12 import com.bsth.data.msg_queue.WebSocketPushQueue;
  13 +import com.bsth.data.schedule.DayOfSchedule;
  14 +import com.bsth.data.schedule.auto_exec.AutoExecScanThread;
12 15 import com.bsth.data.schedule.edit_logs.SeiPstThread;
13 16 import com.bsth.data.schedule.late_adjust.ScheduleLateThread;
14 17 import com.bsth.data.schedule.signal.SchSiginUpdateDBThread;
... ... @@ -41,10 +44,6 @@ public class XDApplication implements CommandLineRunner {
41 44 @Autowired
42 45 UpdateDBThread fcxxUpdateThread;
43 46 @Autowired
44   - GpsDataLoaderThread gpsDataLoader;
45   - @Autowired
46   - OfflineMonitorThread offlineMonitorThread;
47   - @Autowired
48 47 ScheduleRefreshThread scheduleRefreshThread;
49 48 @Autowired
50 49 SchedulePstThread schedulePstThread;
... ... @@ -64,6 +63,17 @@ public class XDApplication implements CommandLineRunner {
64 63 SampleTimeDataLoader sampleTimeDataLoader;
65 64 @Autowired
66 65 SchSiginUpdateDBThread schSiginUpdateDBThread;
  66 + @Autowired
  67 + AutoExecScanThread autoExecScanThread;
  68 +
  69 + @Autowired
  70 + GpsDataLoaderThread gpsDataLoader;
  71 +
  72 + @Autowired
  73 + OfflineMonitorThread offlineMonitorThread;
  74 +
  75 + @Autowired
  76 + LineVersionsData lineVersionsData;
67 77  
68 78 private static long timeDiff;
69 79 private static long timeDiffTraffic;
... ... @@ -100,17 +110,19 @@ public class XDApplication implements CommandLineRunner {
100 110 }
101 111 }
102 112  
103   - //@Autowired
104   - //DayOfSchedule dayOfSchedule;
  113 + @Autowired
  114 + DayOfSchedule dayOfSchedule;
105 115 public void devInit(){
106 116 log.info("devInit...");
107 117 ScheduledExecutorService sexec = Application.mainServices;
108 118 //抓取GPS数据
109 119 gpsDataLoader.setFlag(-1);
110 120 //dayOfSchedule.dataRecovery();
111   - //sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS);
  121 + //sexec.scheduleWithFixedDelay(gpsDataLoader, 60, 4, TimeUnit.SECONDS);
112 122 //实际排班更新线程
113 123 //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  124 + //sexec.scheduleWithFixedDelay(autoExecScanThread, 100, 50, TimeUnit.SECONDS);//班次自动执行
  125 + //WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的
114 126 //实际排班延迟入库线程
115 127 //sexec.scheduleWithFixedDelay(schedulePstThread, 60, 15, TimeUnit.SECONDS);
116 128 //班次修正日志延迟入库
... ... @@ -126,29 +138,34 @@ public class XDApplication implements CommandLineRunner {
126 138 ScheduledExecutorService sexec = Application.mainServices;
127 139  
128 140 /** 线调业务 */
129   - sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS);//抓取GPS数据
  141 + sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程
  142 + sexec.scheduleWithFixedDelay(scheduleLateThread, 70, 30, TimeUnit.SECONDS);//检查班次误点
  143 + sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据
  144 +
130 145 sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线
131   - sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);//班次更新线程
132   - sexec.scheduleWithFixedDelay(schedulePstThread, 60, 10, TimeUnit.SECONDS);//班次延迟入库线程
133   - sexec.scheduleWithFixedDelay(seiPstThread, 60, 60, TimeUnit.SECONDS);//班次修正日志入库
134   - sexec.scheduleWithFixedDelay(scheduleLateThread, 60, 30, TimeUnit.SECONDS);//检查班次误点
135   - sexec.scheduleWithFixedDelay(directivesPstThread, 180, 100, TimeUnit.SECONDS);//调度指令延迟入库
136   - sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
137   - sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 12, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据
  146 + sexec.scheduleWithFixedDelay(schedulePstThread, 120, 10, TimeUnit.SECONDS);//班次延迟入库线程
  147 + sexec.scheduleWithFixedDelay(seiPstThread, 160, 60, TimeUnit.SECONDS);//班次修正日志入库
  148 + sexec.scheduleWithFixedDelay(directivesPstThread, 180, 120, TimeUnit.SECONDS);//调度指令延迟入库
  149 + //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
  150 + sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据
138 151 sexec.scheduleWithFixedDelay(basicDataLoader, 2, 2, TimeUnit.HOURS);//基础数据更新
  152 + sexec.scheduleWithFixedDelay(autoExecScanThread, 160, 50, TimeUnit.SECONDS);//班次自动执行
139 153 DirectivePushQueue.start();//消息队列 -指令,系统下发的
140 154 WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的
141 155  
142 156 /** 线调为其他程序提供的数据 --写入数据库 */
143   - sexec.scheduleWithFixedDelay(fcxxUpdateThread, 60, 40, TimeUnit.SECONDS);//发车信息(发车屏、信息发布)
  157 + sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布)
144 158 //线路首末班数据(网关用,班次更新时写入)
145 159 //com.bsth.data.schedule.f_a_l.FirstAndLastHandler
146   - sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 60, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号)
  160 + sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号)
147 161  
148 162 //运管处静态数据提交
149 163 log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处");
150 164 sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
151 165 //计算油、公里加注
152 166 sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
  167 +
  168 + //线路版本更新
  169 + sexec.scheduleWithFixedDelay(lineVersionsData, 60 * 5, 60 * 15, TimeUnit.SECONDS);
153 170 }
154 171 }
... ...
src/main/java/com/bsth/common/Constants.java
... ... @@ -33,6 +33,8 @@ public class Constants {
33 33  
34 34 //车载网关上行接口
35 35 public static final String UPSTREAM_URL = "/control/upstream";
  36 + //rfid 上传入口
  37 + public static final String UP_RFID_URL = "/rfid/**";
36 38  
37 39 public static final String SESSION_USERNAME = "sessionUserName";
38 40 public static final String COMPANY_AUTHORITYS = "cmyAuths";
... ...
src/main/java/com/bsth/controller/DeviceGpsController.java
1 1 package com.bsth.controller;
2 2  
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.GpsRealData;
  3 +import com.bsth.data.gpsdata_v2.GpsRealData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
5 5 import com.fasterxml.jackson.core.JsonParseException;
6 6 import com.fasterxml.jackson.databind.JsonMappingException;
7 7 import com.fasterxml.jackson.databind.ObjectMapper;
... ...
src/main/java/com/bsth/controller/LineController.java
1 1 package com.bsth.controller;
2 2  
  3 +import java.text.ParseException;
  4 +import java.text.SimpleDateFormat;
  5 +import java.util.Date;
3 6 import java.util.HashMap;
4 7 import java.util.Map;
5 8  
... ... @@ -11,7 +14,9 @@ import org.springframework.web.bind.annotation.RestController;
11 14  
12 15 import com.bsth.common.ResponseCode;
13 16 import com.bsth.entity.Line;
  17 +import com.bsth.entity.LineVersions;
14 18 import com.bsth.service.LineService;
  19 +import com.bsth.service.LineVersionsService;
15 20 import com.bsth.util.GetUIDAndCode;
16 21  
17 22 /**
... ... @@ -36,6 +41,9 @@ public class LineController extends BaseController&lt;Line, Integer&gt; {
36 41 @Autowired
37 42 private LineService service;
38 43  
  44 + @Autowired
  45 + private LineVersionsService lineVersionsService;
  46 +
39 47 /**
40 48 * 获取线路编码与ID
41 49 *
... ... @@ -47,6 +55,16 @@ public class LineController extends BaseController&lt;Line, Integer&gt; {
47 55 }
48 56  
49 57 /**
  58 + * 验证线路编码是否存在
  59 + *
  60 + * @return Map < {valid: true }:是否通过验证>
  61 + */
  62 + @RequestMapping(value = "lineCodeVerification", method = RequestMethod.GET)
  63 + public String lineCodeVerification(@RequestParam(defaultValue = "lineCode") String lineCode) {
  64 + return service.lineCodeVerification(lineCode);
  65 + }
  66 +
  67 + /**
50 68 *
51 69 * 保存
52 70 *
... ... @@ -59,12 +77,46 @@ public class LineController extends BaseController&lt;Line, Integer&gt; {
59 77 t.setId(Integer.valueOf(t.getLineCode()));
60 78  
61 79 }
62   - if( (t.getId().toString().length()) > 6) {
  80 + if( (t.getId().toString().length()) > 6 || service.lineCodeVerification(t.getLineCode()).equals("false") ) {
  81 +
  82 + map.put("status", ResponseCode.ERROR);
  83 + return map;
  84 + }
  85 + // 添加线路版本
  86 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  87 + try {
  88 + Date endDate = simpleDateFormat.parse("2088-08-08 00:00:00");
  89 + LineVersions lineVersions = new LineVersions();
  90 + lineVersions.setName("原始版本");
  91 + lineVersions.setLine(t);
  92 + lineVersions.setLineCode(t.getLineCode());
  93 + lineVersions.setStartDate(t.getCreateDate());
  94 + lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00
  95 + lineVersions.setVersions(1);
  96 + lineVersions.setStatus(1);
  97 + // 先添加线路再添加版本
  98 + service.save(t);
  99 + return lineVersionsService.save(lineVersions);
  100 + } catch (ParseException e) {
  101 + // TODO Auto-generated catch block
  102 + e.printStackTrace();
  103 + map.put("status", ResponseCode.ERROR);
  104 + return map;
  105 + }
  106 + }
  107 +
  108 + /**
  109 + * 更改
  110 + */
  111 + @RequestMapping(value="/update", method = RequestMethod.POST)
  112 + public Map<String, Object> update(Line l){
  113 + Map<String, Object> map = new HashMap<>();
  114 + if((l.getId().toString().length()) > 6 || service.lineCodeVerification(l.getLineCode()).equals("true") ) {
63 115  
64 116 map.put("status", ResponseCode.ERROR);
65 117 return map;
66 118 }
67   - return service.save(t);
  119 + return service.update(l);
68 120 }
69 121  
70 122 @RequestMapping(value ="/findById" , method = RequestMethod.GET)
... ...
src/main/java/com/bsth/controller/LineVersionsController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import java.text.ParseException;
  4 +import java.text.SimpleDateFormat;
  5 +import java.util.Date;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestMethod;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import com.bsth.entity.Line;
  16 +import com.bsth.entity.LineVersions;
  17 +import com.bsth.repository.LineRepository;
  18 +import com.bsth.service.LineVersionsService;
  19 +
  20 +/**
  21 + *
  22 + * @ClassName: LineController(线路版本控制器)
  23 + *
  24 + * @Extends : BaseController
  25 + *
  26 + * @Description: TODO(线路版本版控制层)
  27 + *
  28 + * @Author bsth@lq
  29 + *
  30 + * @Version 公交调度系统BS版 0.1
  31 + *
  32 + */
  33 +@RestController
  34 +@RequestMapping("lineVersions")
  35 +public class LineVersionsController extends BaseController<LineVersions, Integer> {
  36 +
  37 + @Autowired
  38 + private LineVersionsService service;
  39 +
  40 + @Autowired
  41 + LineRepository lineRepository;
  42 +
  43 + /**
  44 + * 获取线路所有版本
  45 + */
  46 + @RequestMapping(value = "findLineVersionsMax", method = RequestMethod.GET)
  47 + public LineVersions findLineVersionsMax(@RequestParam(defaultValue = "lineId") int lineId) {
  48 + return service.findLineVersionsMax(lineId);
  49 + }
  50 +
  51 + /**
  52 + * 获取线路所有版本
  53 + *
  54 + */
  55 + @RequestMapping(value = "findByLineId", method = RequestMethod.GET)
  56 + public List<LineVersions> getLineCode(@RequestParam(defaultValue = "lineId") int lineId) {
  57 + return service.findByLineCode(lineId);
  58 + }
  59 +
  60 + /**
  61 + * 根据id查询线路版本信息
  62 + *
  63 + */
  64 + @RequestMapping(value = "findById", method = RequestMethod.GET)
  65 + public LineVersions findOne(@RequestParam(defaultValue = "id") int id) {
  66 + return service.findById(id);
  67 + }
  68 +
  69 + /**
  70 + * 根据id修改线路版本信息
  71 + *
  72 + */
  73 + @RequestMapping(value = "update", method = RequestMethod.POST)
  74 + public Map<String, Object> update(@RequestParam Map<String, Object> map) {
  75 + return service.update(map);
  76 + }
  77 +
  78 + @RequestMapping(value = "add", method = RequestMethod.POST)
  79 + public Map<String, Object> add(@RequestParam Map<String, Object> map) {
  80 + return service.add(map);
  81 + }
  82 +
  83 +}
... ...
src/main/java/com/bsth/controller/RoadSpeedController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.entity.RoadSpeed;
  13 +import com.bsth.service.RoadSpeedService;
  14 +
  15 +/**
  16 + *
  17 + * @ClassName: RoadSpeedController(路段限速控制器)
  18 + *
  19 + * @Extends : BaseController
  20 + *
  21 + * @Description: TODO(路段限速控制层)
  22 + *
  23 + * @Author bsth@lq
  24 + *
  25 + * @Version 公交调度系统BS版 0.1
  26 + *
  27 + */
  28 +@RestController
  29 +@RequestMapping("roadSpeed")
  30 +public class RoadSpeedController extends BaseController<RoadSpeed, Integer> {
  31 +
  32 + @Autowired
  33 + private RoadSpeedService service;
  34 +
  35 + /*@RequestMapping(value="all", method = RequestMethod.GET)
  36 + public List<RoadSpeed> allRoadSpeed(){
  37 + return service.allRoadSpeed();
  38 + }*/
  39 +
  40 + @RequestMapping(value="save", method = RequestMethod.POST)
  41 + public Map<String, Object> save(@RequestParam Map<String, Object> map){
  42 + return service.roadSpeedSave(map);
  43 + }
  44 +
  45 + @RequestMapping(value="update", method = RequestMethod.POST)
  46 + public Map<String, Object> update(@RequestParam Map<String, Object> map){
  47 + return service.update(map);
  48 + }
  49 +
  50 + @RequestMapping(value="findById", method = RequestMethod.GET)
  51 + public RoadSpeed findById(@RequestParam(defaultValue = "id") Integer id){
  52 + return service.findId(id);
  53 + }
  54 +}
... ...
src/main/java/com/bsth/controller/SectionController.java
... ... @@ -74,6 +74,24 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; {
74 74 }
75 75  
76 76 /**
  77 + * @Description :TODO(编辑线路走向保存到线路历史表)
  78 + *
  79 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  80 + *
  81 + * @return Map<String, Object> <SUCCESS ; ERROR>
  82 + */
  83 + @RequestMapping(value="sectionCutSaveLineLS" , method = RequestMethod.POST)
  84 + public Map<String, Object> sectionCutSaveLineLS(@RequestParam Map<String, Object> map) {
  85 +
  86 + map.put("updateBy", "");
  87 +
  88 + map.put("createBy", "");
  89 +
  90 + return service.sectionCutSaveLineLS(map);
  91 +
  92 + }
  93 +
  94 + /**
77 95 * @Description :TODO(编辑线路走向)
78 96 *
79 97 * @param map <sectionId:路段ID; sectionJSON:路段信息>
... ...
src/main/java/com/bsth/controller/StationController.java
... ... @@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
8 8 import org.springframework.web.bind.annotation.RequestParam;
9 9 import org.springframework.web.bind.annotation.RestController;
10 10  
11   -import antlr.collections.List;
12   -
13 11 import com.bsth.entity.Station;
14 12 import com.bsth.service.StationService;
15 13 import com.bsth.util.GetUIDAndCode;
... ... @@ -128,6 +126,27 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
128 126 map.put("updateBy", "");
129 127 return service.stationUpdate(map);
130 128 }
  129 +
  130 + /**
  131 + * @Description :TODO(更新缓存站点保存)
  132 + *
  133 + * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;
  134 + *
  135 + * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
  136 + *
  137 + * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
  138 + *
  139 + * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
  140 + *
  141 + * versions:版本号;x:城建坐标x;y:城建坐标y>
  142 + *
  143 + * @return Map<String, Object> <SUCCESS ; ERROR>
  144 + */
  145 + @RequestMapping(value="stationCacheUpdate" , method = RequestMethod.POST)
  146 + public Map<String, Object> stationCacheUpdate(@RequestParam Map<String, Object> map) {
  147 + map.put("updateBy", "");
  148 + return service.stationCacheUpdate(map);
  149 + }
131 150 /**
132 151 * @Description :TODO(查询站点编码)
133 152 *
... ...
src/main/java/com/bsth/controller/StationRouteController.java
1 1 package com.bsth.controller;
2 2  
3 3 import com.bsth.entity.StationRoute;
  4 +import com.bsth.entity.StationRouteCache;
  5 +import com.bsth.repository.StationRouteCacheRepository;
4 6 import com.bsth.repository.StationRouteRepository;
5 7 import com.bsth.service.StationRouteService;
6 8 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -37,6 +39,8 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
37 39 StationRouteService service;
38 40 @Autowired
39 41 StationRouteRepository stationRouteRepository;
  42 + @Autowired
  43 + StationRouteCacheRepository stationRouteCacheRepository;
40 44  
41 45 /**
42 46 * @param @param map
... ... @@ -49,6 +53,11 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
49 53 return service.list(map);
50 54 }
51 55  
  56 + @RequestMapping(value = "/cacheList", method = RequestMethod.GET)
  57 + public List<StationRouteCache> cacheList(@RequestParam Map<String, Object> map) {
  58 + return service.cacheList(map);
  59 + }
  60 +
52 61 /**
53 62 * @Description :TODO(查询路段信息)
54 63 *
... ... @@ -101,6 +110,14 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
101 110 }
102 111  
103 112 /**
  113 + * @Description :TODO(查询缓存站点的上一个缓存站点)
  114 + */
  115 + @RequestMapping(value = "/findCacheUpStationRouteCode" , method = RequestMethod.GET)
  116 + public List<Map<String, Object>> findCacheUpStationRouteCode(@RequestParam Map<String, Object> map) {
  117 + return service.findCacheUpStationRouteCode(map);
  118 + }
  119 +
  120 + /**
104 121 * @Description :TODO(查询线路某方向下所有站点的中心百度坐标)
105 122 *
106 123 * @param map <lineId:线路ID; direction:方向>
... ... @@ -195,4 +212,31 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
195 212 public Map<String, Object> upddis(@RequestParam Map<String, Object> map) {
196 213 return service.upddis(map);
197 214 }
  215 +
  216 + /**
  217 + *
  218 + * @Title: findCacheStationRoute
  219 + * @Description: TODO(查询缓存路由)
  220 + */
  221 + @RequestMapping(value = "/findCacheStationRoute",method = RequestMethod.GET)
  222 + public List<StationRouteCache> findCacheStationRoute(@RequestParam Map<String, Object> map) {
  223 + int lineId = Integer.parseInt(map.get("lineId").toString());
  224 + int dir = Integer.parseInt(map.get("dir").toString());
  225 + return stationRouteCacheRepository.findstationRoute(lineId, dir);
  226 + }
  227 +
  228 + /**
  229 + *
  230 + * @Title: findCachePoint
  231 + *
  232 + * @param map <lineId:线路ID; dir:方向>
  233 + *
  234 + * @Description: TODO(查询缓存路由)
  235 + */
  236 + @RequestMapping(value = "/findCachePoint",method = RequestMethod.GET)
  237 + public List<Map<String, Object>> findCachePoint(@RequestParam Map<String, Object> map) {
  238 + int lineId = Integer.parseInt(map.get("lineId").toString());
  239 + int dir = Integer.parseInt(map.get("dir").toString());
  240 + return service.findCachePoint(lineId, dir);
  241 + }
198 242 }
... ...
src/main/java/com/bsth/controller/calc/CalcWaybillController.java 0 → 100644
  1 +package com.bsth.controller.calc;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import com.bsth.common.ResponseCode;
  8 +import com.bsth.controller.BaseController;
  9 +import com.bsth.entity.calc.CalcWaybill;
  10 +import com.bsth.service.calc.CalcWaybillService;
  11 +
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.RequestParam;
  15 +import org.springframework.web.bind.annotation.RestController;
  16 +
  17 +/**
  18 + * Created by 17/10/23.
  19 + */
  20 +@RestController
  21 +@RequestMapping("calcWaybill")
  22 +public class CalcWaybillController extends BaseController<CalcWaybill, Integer> {
  23 +
  24 + @Autowired
  25 + private CalcWaybillService calcWaybillService;
  26 +
  27 + @RequestMapping(value="/generateNew")
  28 + public Map<String, Object> generateNews(@RequestParam Map<String, Object> map) throws Exception{
  29 + String date = "", line = "";
  30 + if(map.get("date")!=null){
  31 + date=map.get("date").toString().trim();
  32 + }
  33 + if(map.get("line")!=null){
  34 + line=map.get("line").toString().trim();
  35 + }
  36 +
  37 + Map<String, Object> m = new HashMap<String, Object>();
  38 + try {
  39 +
  40 + m = calcWaybillService.generateNew(date, line);
  41 +
  42 + } catch (Exception e) {
  43 + // TODO: handle exception
  44 + e.printStackTrace();
  45 + m.put("status", ResponseCode.ERROR);
  46 + return m;
  47 + }
  48 +
  49 + return m;
  50 + }
  51 +
  52 + @RequestMapping(value="/statisticsDailyTj")
  53 + public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
  54 + String gsdm="";
  55 + if(map.get("gsdm")!=null){
  56 + gsdm=map.get("gsdm").toString().trim();
  57 + }
  58 + String fgsdm="";
  59 + if(map.get("fgsdm")!=null){
  60 + fgsdm=map.get("fgsdm").toString().trim();
  61 + }
  62 + String line="";
  63 + if(map.get("line")!=null){
  64 + line=map.get("line").toString().trim();
  65 + }
  66 + String date="";
  67 + if(map.get("date")!=null){
  68 + date=map.get("date").toString().trim();
  69 + }
  70 + String date2="";
  71 + if(map.get("date2")!=null){
  72 + date2=map.get("date2").toString().trim();
  73 + }
  74 + String xlName="";
  75 + if(map.get("xlName")!=null){
  76 + xlName=map.get("xlName").toString().trim();
  77 + }
  78 + String type="";
  79 + if(map.get("type")!=null){
  80 + type=map.get("type").toString().trim();
  81 + }
  82 + return calcWaybillService.statisticsDailyTj(gsdm,fgsdm,line,date,date2,xlName,type);
  83 + }
  84 +
  85 +}
... ...
src/main/java/com/bsth/controller/directive/DirectiveController.java
... ... @@ -165,11 +165,11 @@ public class DirectiveController {
165 165 * @throws
166 166 */
167 167 @RequestMapping(value = "/list", method = RequestMethod.GET)
168   - public Map<String, Object> findDirective(String nbbm,@RequestParam int dType
  168 + public Map<String, Object> findDirective(String nbbms,@RequestParam int dType
169 169 , @RequestParam(defaultValue = "0") int page,
170 170 @RequestParam(defaultValue = "10") int size){
171 171  
172   - return directiveService.findDirective(nbbm, dType, page, size);
  172 + return directiveService.findDirective(nbbms, dType, page, size);
173 173 }
174 174  
175 175 @RequestMapping(value = "/c0a4", method = RequestMethod.POST)
... ...
src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -186,13 +186,10 @@ public class ExportController {
186 186 m.put("i", i);
187 187 m.put("rQ", l.getrQ());
188 188 m.put("gS", l.getgS());
189   - m.put("xL", l.getxL());
  189 + m.put("xL", l.getXlmc());
190 190 m.put("clzbh", l.getClzbh());
191 191 m.put("jsy", l.getJsy());
192 192 m.put("jName", l.getjName());
193   -
194   -
195   -
196 193 m.put("sgh", l.getSgh());
197 194 m.put("sName", l.getsName());
198 195 m.put("jhlc", l.getJhlc());
... ...
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
... ... @@ -78,6 +78,13 @@ public class MCY_FormsController {
78 78  
79 79 return formsService.singledata(map);
80 80 }
  81 +
  82 + // 路单数据
  83 + @RequestMapping(value = "/singledatanew", method = RequestMethod.GET)
  84 + public List<Singledata> singledatanew(@RequestParam Map<String, Object> map) {
  85 +
  86 + return formsService.singledata(map);
  87 + }
81 88  
82 89 // 车辆加注
83 90 @RequestMapping(value = "/vehicleloading", method = RequestMethod.GET)
... ...
src/main/java/com/bsth/controller/gps/GpsController.java
1 1 package com.bsth.controller.gps;
2 2  
3 3 import com.bsth.data.BasicData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.GpsRealData;
6   -import com.bsth.entity.excep.Speeding;
  4 +import com.bsth.data.gpsdata_v2.GpsRealData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 6 import com.bsth.service.gps.GpsService;
8 7 import com.bsth.service.gps.entity.GpsSpeed;
9   -import com.bsth.util.PageObject;
10 8 import com.google.common.base.Splitter;
11 9 import org.springframework.beans.factory.annotation.Autowired;
12 10 import org.springframework.web.bind.annotation.*;
13 11  
14 12 import javax.servlet.http.HttpServletResponse;
15   -
16 13 import java.text.ParseException;
17 14 import java.util.ArrayList;
18 15 import java.util.List;
... ...
src/main/java/com/bsth/controller/oil/CwjyController.java
... ... @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
12 12 import org.springframework.web.bind.annotation.RequestParam;
13 13 import org.springframework.web.bind.annotation.RestController;
14 14  
  15 +import com.bsth.common.ResponseCode;
15 16 import com.bsth.controller.BaseController;
16 17 import com.bsth.data.BasicData;
17 18 import com.bsth.entity.Line;
... ... @@ -35,7 +36,16 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{
35 36 t.setNbbm(t.getNbbm().trim().toUpperCase());
36 37 Line line=BasicData.nbbm2LineMap.get(t.getNbbm());
37 38 t.setLine(line == null?"" : line.getLineCode());
38   - return service.save(t);
  39 + Map<String, Object> map = new HashMap<>();
  40 + try {
  41 + map=service.save(t);
  42 + }catch (Exception e) {
  43 + // TODO: handle exception
  44 + if(e.getMessage().indexOf("PK_CWJYUK")>0){
  45 + map.put("fage", "存在相同数据,数据已经过滤");
  46 + }
  47 + }
  48 + return map;
39 49 }
40 50  
41 51 @RequestMapping(value = "/checkNbbm",method = RequestMethod.GET)
... ...
src/main/java/com/bsth/controller/oil/DlbController.java
... ... @@ -2,6 +2,7 @@ package com.bsth.controller.oil;
2 2  
3 3 import java.text.SimpleDateFormat;
4 4 import java.util.ArrayList;
  5 +import java.util.Date;
5 6 import java.util.HashMap;
6 7 import java.util.Iterator;
7 8 import java.util.List;
... ... @@ -20,6 +21,7 @@ import com.bsth.controller.BaseController;
20 21 import com.bsth.entity.oil.Dlb;
21 22 import com.bsth.entity.oil.Ylb;
22 23 import com.bsth.service.oil.DlbService;
  24 +import com.bsth.util.Arith;
23 25 import com.bsth.util.ReportUtils;
24 26 import com.google.common.base.Splitter;
25 27  
... ... @@ -162,10 +164,11 @@ public class DlbController extends BaseController&lt;Dlb, Integer&gt;{
162 164 m.put("hd", y.getHd()<=0?"0":y.getHd());
163 165 String shyy ="无";
164 166 if(y.getShyy()!=null){
165   - if(shyy.equals("1")){shyy="票务用油";}
166   - else if(shyy.equals("2")){shyy="保养用油";}
167   - else if(shyy.equals("3")){shyy="报废车用油";}
168   - else if(shyy.equals("4")){shyy="其它用油";}
  167 + shyy=y.getShyy();
  168 + if(shyy.equals("1")){shyy="票务用电";}
  169 + else if(shyy.equals("2")){shyy="保养用电";}
  170 + else if(shyy.equals("3")){shyy="报废车用电";}
  171 + else if(shyy.equals("4")){shyy="其它用电";}
169 172 else if(shyy.equals("5")){shyy="人保部";}
170 173 else if(shyy.equals("6")){shyy="车队";}
171 174 else if(shyy.equals("7")){shyy="车间(高保)";}
... ... @@ -178,6 +181,7 @@ public class DlbController extends BaseController&lt;Dlb, Integer&gt;{
178 181 m.put("zlc", y.getZlc()<=0?"0":y.getZlc());
179 182 m.put("rdlx", "");
180 183 m.put("bglyh", y.getBglyh());
  184 + m.put("zdh", Arith.add(y.getSh(), y.getHd()));
181 185 resList.add(m);
182 186 }
183 187 try {
... ... @@ -194,4 +198,30 @@ public class DlbController extends BaseController&lt;Dlb, Integer&gt;{
194 198  
195 199 }
196 200  
  201 +
  202 + @RequestMapping(value = "/checkJsy",method = RequestMethod.GET)
  203 + public String checkJsy(@RequestParam Map<String, Object> map){
  204 + String list=service.checkJsy(map);
  205 + return list;
  206 + }
  207 +
  208 + @RequestMapping(value = "/deleteIds", method = RequestMethod.POST)
  209 + public Map<String, Object> deleteIds(@RequestParam Map<String, Object> map) {
  210 + Map<String, Object> maps=new HashMap<String, Object>();
  211 + try {
  212 + maps= service.deleteIds(map);
  213 + } catch (Exception e) {
  214 + // TODO Auto-generated catch block
  215 + e.printStackTrace();
  216 + }
  217 + return maps;
  218 + }
  219 +
  220 + @RequestMapping(value = "/saveDlb",method = RequestMethod.POST)
  221 + public Map<String, Object> saveDlb(Dlb t){
  222 +// SysUser user = SecurityUtils.getCurrentUser();
  223 + t.setCreatetime(new Date());
  224 +// Ylb t=new Ylb();
  225 + return service.saveDlb(t);
  226 + }
197 227 }
... ...
src/main/java/com/bsth/controller/oil/YlbController.java
... ... @@ -27,6 +27,7 @@ import com.bsth.entity.oil.Ylb;
27 27 import com.bsth.entity.sys.SysUser;
28 28 import com.bsth.security.util.SecurityUtils;
29 29 import com.bsth.service.oil.YlbService;
  30 +import com.bsth.util.Arith;
30 31 import com.bsth.util.ReportUtils;
31 32 import com.google.common.base.Splitter;
32 33  
... ... @@ -209,8 +210,8 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
209 210 return maps;
210 211 }
211 212 @RequestMapping(value="/oilListMonth")
212   - public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date,@RequestParam String type){
213   - return yblService.oilListMonth(line, date, type);
  213 + public List<Ylb> oilListMonth(@RequestParam Map<String, Object> map){
  214 + return yblService.oilListMonth(map);
214 215 }
215 216  
216 217 @RequestMapping(value = "/checkJsy",method = RequestMethod.GET)
... ... @@ -273,6 +274,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
273 274 m.put("sh", y.getSh()<=0?"0":y.getSh());
274 275 m.put("zlc", y.getZlc()<=0?"0":y.getZlc());
275 276 m.put("bglyh", y.getBglyh());
  277 + m.put("zyh", Arith.add(y.getSh(), y.getYh()));
276 278 resList.add(m);
277 279 }
278 280 try {
... ... @@ -288,4 +290,22 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
288 290 return resList;
289 291  
290 292 }
  293 +
  294 + /*
  295 + * 历史修改行车路单后重新统计油量信息 (传参:line --线路编码 date --日期)
  296 + */
  297 +
  298 + @RequestMapping(value = "/updateHistory",method = RequestMethod.POST)
  299 + public Map<String, Object> updateHistory(@RequestParam Map<String, Object> map) throws Exception{
  300 + Map<String, Object> list =new HashMap<String, Object>();
  301 + try {
  302 + list = yblService.updateHistory(map);
  303 + } catch (Exception e) {
  304 + // TODO Auto-generated catch block
  305 + throw e;
  306 + }
  307 + return list;
  308 + }
  309 +
  310 +
291 311 }
... ...
src/main/java/com/bsth/controller/oil/YlxxbController.java
1 1 package com.bsth.controller.oil;
2 2  
3 3 import java.util.HashMap;
  4 +import java.util.List;
4 5 import java.util.Map;
5 6  
6 7 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -28,6 +29,12 @@ public class YlxxbController extends BaseController&lt;Ylxxb, Integer&gt;{
28 29 return pagequery;
29 30 }
30 31  
  32 + @RequestMapping(value = "/listNbbm",method = RequestMethod.GET)
  33 + public List<Ylxxb> listNbbm(@RequestParam Map<String, Object> map){
  34 + List<Ylxxb> list=service.Pagequery_nbbm(map);
  35 + return list;
  36 + }
  37 +
31 38  
32 39 /**
33 40 * 核对油量(有加油没里程)
... ... @@ -45,4 +52,17 @@ public class YlxxbController extends BaseController&lt;Ylxxb, Integer&gt;{
45 52 }
46 53 return list;
47 54 }
  55 +
  56 + @RequestMapping(value = "/checkNbbm",method = RequestMethod.POST)
  57 + public Map<String, Object> checkNbbm(@RequestParam Map<String, Object> map){
  58 + Map<String, Object> list=new HashMap<>();
  59 + try {
  60 + list = service.checkNbbm(map);
  61 + } catch (Exception e) {
  62 + // TODO Auto-generated catch block
  63 + e.printStackTrace();
  64 + }
  65 + return list;
  66 + }
  67 +
48 68 }
... ...
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
... ... @@ -131,7 +131,7 @@ public class BasicDataController {
131 131 */
132 132 @RequestMapping("/nbbm2PlateNo")
133 133 public Map<String, String> nbbm2PlateNo(){
134   - return basicData.getNbbm2PlateNo();
  134 + return basicData.nbbmCompanyPlateMap;
135 135 }
136 136  
137 137  
... ...
src/main/java/com/bsth/controller/realcontrol/FrequentPhrasesController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.realcontrol.FrequentPhrases;
  5 +import org.springframework.web.bind.annotation.RequestMapping;
  6 +import org.springframework.web.bind.annotation.RestController;
  7 +
  8 +/**
  9 + * Created by panzhao on 2017/9/17.
  10 + */
  11 +@RestController
  12 +@RequestMapping("frequent_phrases")
  13 +public class FrequentPhrasesController extends BaseController<FrequentPhrases, Integer>{
  14 +
  15 +}
... ...
src/main/java/com/bsth/controller/realcontrol/LineConfigController.java
... ... @@ -79,6 +79,11 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{
79 79 return lineConfigService.getByLineCode(lineCode);
80 80 }
81 81  
  82 + @RequestMapping(value = "/findByIdx")
  83 + public Map<String, Object> findByIdx(@RequestParam String idx){
  84 + return lineConfigService.findByIdx(idx);
  85 + }
  86 +
82 87 /**
83 88 * 到站缓冲区设置
84 89 * @param lineCode
... ... @@ -111,4 +116,14 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{
111 116 public Map<String, Object> parkAndStationSet(@RequestParam Map<String, String> map){
112 117 return lineConfigService.parkAndStationSet(map);
113 118 }
  119 +
  120 + @RequestMapping(value = "/setAutoExec", method = RequestMethod.POST)
  121 + public Map<String, Object> setAutoExec(@RequestParam Map<String, String> map){
  122 + return lineConfigService.setAutoExec(map);
  123 + }
  124 +
  125 + @RequestMapping(value = "/setReadReverse")
  126 + public Map<String, Object> setReadReverse(@RequestParam int status,@RequestParam String lineCode){
  127 + return lineConfigService.setReadReverse(status, lineCode);
  128 + }
114 129 }
... ...
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
4   -import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute;
5 3 import com.bsth.service.realcontrol.RealMapService;
6 4 import org.springframework.beans.factory.annotation.Autowired;
7 5 import org.springframework.web.bind.annotation.RequestMapping;
8   -import org.springframework.web.bind.annotation.RequestMethod;
9 6 import org.springframework.web.bind.annotation.RequestParam;
10 7 import org.springframework.web.bind.annotation.RestController;
11 8  
... ... @@ -77,9 +74,4 @@ public class RealMapController {
77 74 public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx){
78 75 return realMapService.multiSectionRoute(codeIdx);
79 76 }
80   -
81   - @RequestMapping(value = "/lockAndFlxedTimeEnabled", method = RequestMethod.POST)
82   - public void lockAndFlxedTimeEnabled(TimedEnableStationRoute tes){
83   - GeoCacheData.tesMap.put(tes.getLineCode(), tes);
84   - }
85 77 }
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -529,8 +529,8 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
529 529 }
530 530  
531 531 @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)
532   - public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks){
533   - return scheduleRealInfoService.changeBcType(id, bcType, remarks);
  532 + public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){
  533 + return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);
534 534 }
535 535  
536 536 @RequestMapping(value="/history", method=RequestMethod.POST)
... ... @@ -549,9 +549,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
549 549 public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
550 550 List<String> rs = new ArrayList<>();
551 551  
552   - long t = new Date().getTime();
  552 + long t = System.currentTimeMillis();
553 553 if(c != 1)
554   - t -= ONE_DAY - (1000 * 60 * 60 * 2);
  554 + t -= (ONE_DAY + (1000 * 60 * 60 * 2));
555 555 for(int i = 0; i < 3; i ++){
556 556 rs.add(fmtyyyyMMdd.print(t));
557 557 t -= ONE_DAY;
... ...
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
1 1 package com.bsth.controller.realcontrol;
2 2  
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.data.directive.DayOfDirectives;
  6 +import com.bsth.data.directive.DirectiveCreator;
  7 +import com.bsth.data.directive.GatewayHttpUtils;
  8 +import com.bsth.data.gpsdata_v2.GpsRealData;
  9 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
3 10 import com.bsth.data.schedule.DayOfSchedule;
  11 +import com.bsth.entity.directive.D60;
4 12 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  13 +import com.bsth.repository.directive.D60Repository;
  14 +import com.google.common.base.Splitter;
5 15 import org.apache.commons.lang3.StringUtils;
  16 +import org.slf4j.Logger;
  17 +import org.slf4j.LoggerFactory;
6 18 import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.web.bind.annotation.RequestMapping;
8   -import org.springframework.web.bind.annotation.RequestParam;
9   -import org.springframework.web.bind.annotation.RestController;
  19 +import org.springframework.web.bind.annotation.*;
10 20  
11   -import java.util.ArrayList;
12   -import java.util.List;
  21 +import java.util.*;
13 22  
14 23 /**
15   - * 对外的营运数据接口,主要输出当日的数据
  24 + * 对外的营运数据接口
16 25 * Created by panzhao on 2017/3/15.
17 26 */
18 27 @RestController
... ... @@ -21,9 +30,58 @@ public class ServiceDataInterface {
21 30  
22 31 private final static String SECRE_KEY = "dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki";
23 32  
  33 + Logger logger = LoggerFactory.getLogger(this.getClass());
  34 +
24 35 @Autowired
25 36 DayOfSchedule dayOfSchedule;
26 37  
  38 + @Autowired
  39 + DayOfDirectives dayOfDirectives;
  40 +
  41 + @Autowired
  42 + D60Repository d60Repository;
  43 +
  44 + @Autowired
  45 + GpsRealData gpsRealData;
  46 +
  47 + /**
  48 + * 获取车辆 和 当前执行班次对照信息
  49 + * @return
  50 + */
  51 + @RequestMapping("/execSchList")
  52 + public List<Map<String, Object>> execSchList(@RequestParam String secretKey){
  53 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  54 + return null;
  55 +
  56 + List<Map<String, Object>> rs = new ArrayList<>();
  57 + Collection<ScheduleRealInfo> list = dayOfSchedule.execPlanMap().values();
  58 +
  59 + Map<String, Object> map;
  60 + for(ScheduleRealInfo sch : list){
  61 + if(null == sch)
  62 + continue;
  63 + map = new HashMap<>();
  64 + map.put("clZbh", sch.getClZbh());
  65 + map.put("jGh", sch.getjGh());
  66 + map.put("sGh", sch.getsGh());
  67 + map.put("lpName", sch.getLpName());
  68 + map.put("xlBm", sch.getXlBm());
  69 + map.put("xlName", sch.getXlName());
  70 + map.put("xlDir", sch.getXlDir());
  71 + map.put("qdzName", sch.getQdzName());
  72 + map.put("zdzName", sch.getZdzName());
  73 + map.put("fcsj", sch.getFcsj());
  74 + map.put("dfsj", sch.getDfsj());
  75 + map.put("zdsj", sch.getZdsj());
  76 + map.put("bcType", sch.getBcType());
  77 + map.put("remarks", sch.getRemark());
  78 + map.put("status", sch.getStatus());
  79 +
  80 + rs.add(map);
  81 + }
  82 + return rs;
  83 + }
  84 +
27 85 @RequestMapping("/getCurrentDayPlan")
28 86 public List<ScheduleRealInfo> getCurrentDayPlan(
29 87 @RequestParam String companyId,
... ... @@ -78,4 +136,107 @@ public class ServiceDataInterface {
78 136 }
79 137 return rs;
80 138 }
  139 +
  140 + /**
  141 + * 获取全量的进出场数据, 仅供接口项目调用。 由接口项目负责对外所有场站输出
  142 + * @return
  143 + */
  144 + @RequestMapping("/findCurrInAndOut")
  145 + public List<ScheduleRealInfo> findCurrInAndOut(@RequestParam String secretKey){
  146 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  147 + return null;
  148 +
  149 +
  150 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
  151 + for (ScheduleRealInfo sch : all) {
  152 + if (sch.getBcType().equals("in")
  153 + || sch.getBcType().equals("out")) {
  154 + rs.add(sch);
  155 + }
  156 + }
  157 + return rs;
  158 + }
  159 +
  160 + /**
  161 + * 向指定的车辆下发消息短语
  162 + * @param nbbm
  163 + * @param txt
  164 + * @return
  165 + */
  166 + @RequestMapping(value = "/send60Phrase", method = RequestMethod.POST)
  167 + public int send60Phrase(@RequestBody Map<String, String> map,@RequestParam String secretKey){
  168 + try{
  169 + String nbbm = map.get("nbbm");
  170 + String txt = map.get("txt");
  171 + String sender = map.get("sender");
  172 + if(txt.length() > 50)
  173 + txt = txt.substring(0, 50);
  174 + if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
  175 + return -500;
  176 +
  177 + //车辆和设备号对照
  178 + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  179 + if(StringUtils.isEmpty(deviceId))
  180 + return -404;
  181 +
  182 + //检查设备是否在线
  183 + long t = System.currentTimeMillis();
  184 + GpsEntity gps = gpsRealData.get(deviceId);
  185 + if(null == gps || (t - gps.getServerTimestamp()) > 1000 * 60 * 5)
  186 + return -405;
  187 +
  188 + Short dispatchInstruct = 0;//消息短语
  189 + D60 d60 = new DirectiveCreator().createD60(nbbm, txt, dispatchInstruct, gps.getUpDown(), gps.getState(), gps.getLineId());
  190 + d60.setSender(sender);
  191 + // 发送指令
  192 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));
  193 + d60.setHttpCode(code);
  194 +
  195 + if (code == 0) {
  196 + // 添加到缓存
  197 + dayOfDirectives.put60(d60, true);
  198 + } else {
  199 + d60.setErrorText("网关通讯失败, code: " + code);
  200 + d60Repository.save(d60);
  201 + dayOfDirectives.put60(d60, false);
  202 + }
  203 +
  204 + return d60.getMsgId();
  205 + }catch (Exception e){
  206 + logger.error("", e);
  207 + return -500;
  208 + }
  209 + }
  210 +
  211 + /**
  212 + * 根据msg id 查询指令响应情况
  213 + * @param msgIDs
  214 + * @return
  215 + */
  216 + @RequestMapping("/findD60Reply")
  217 + public List<Map<String, Object>> findD60Reply(@RequestParam String msgIds){
  218 + List<Map<String, Object>> rs = new ArrayList<>();
  219 + try{
  220 + Map<String, Object> map = new HashMap();
  221 +
  222 + List<String> ids = Splitter.on(",").splitToList(msgIds);
  223 + D60 d60;
  224 + for(String id : ids){
  225 + if(StringUtils.isEmpty(id))
  226 + continue;
  227 +
  228 + d60 = dayOfDirectives.get(Integer.parseInt(id));
  229 + if(null == d60)
  230 + continue;
  231 +
  232 + map.put("msgId", d60.getMsgId());
  233 + map.put("deviceReplyTime", d60.getReply46Time());
  234 + map.put("jsyReplyTime", d60.getReply47Time());
  235 + rs.add(map);
  236 + }
  237 + }catch (Exception e){
  238 + logger.error("", e);
  239 + }
  240 + return rs;
  241 + }
81 242 }
... ...
src/main/java/com/bsth/controller/realcontrol/SignalStateController.java
1   -package com.bsth.controller.realcontrol;
2   -
3   -import com.bsth.data.gpsdata.SignalStateData;
4   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestParam;
8   -import org.springframework.web.bind.annotation.RestController;
9   -
10   -import java.util.List;
11   -
12   -/**
13   - * Created by panzhao on 2016/12/30.
14   - */
15   -@RestController
16   -@RequestMapping("signalState")
17   -public class SignalStateController {
18   -
19   - @Autowired
20   - SignalStateData signalStateData;
21   -
22   - @RequestMapping("/multi")
23   - public List<SignalState> findByMultiLine(@RequestParam String idx){
24   - return signalStateData.get(idx);
25   - }
26   -}
  1 +//package com.bsth.controller.realcontrol;
  2 +//
  3 +//import com.bsth.data.gpsdata.SignalStateData;
  4 +//import com.bsth.data.gpsdata.arrival.entity.SignalState;
  5 +//import org.springframework.beans.factory.annotation.Autowired;
  6 +//import org.springframework.web.bind.annotation.RequestMapping;
  7 +//import org.springframework.web.bind.annotation.RequestParam;
  8 +//import org.springframework.web.bind.annotation.RestController;
  9 +//
  10 +//import java.util.List;
  11 +//
  12 +///**
  13 +// * Created by panzhao on 2016/12/30.
  14 +// */
  15 +//@RestController
  16 +//@RequestMapping("signalState")
  17 +//public class SignalStateController {
  18 +//
  19 +// @Autowired
  20 +// SignalStateData signalStateData;
  21 +//
  22 +// @RequestMapping("/multi")
  23 +// public List<SignalState> findByMultiLine(@RequestParam String idx){
  24 +// return signalStateData.get(idx);
  25 +// }
  26 +//}
... ...
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
4   -import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
5   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
6 5 import com.bsth.data.msg_queue.DirectivePushQueue;
7 6 import com.bsth.data.msg_queue.WebSocketPushQueue;
8 7 import com.bsth.data.schedule.DayOfSchedule;
... ... @@ -59,11 +58,6 @@ public class anomalyCheckController {
59 58 }
60 59 }
61 60  
62   - @RequestMapping(value = "/shutdownThreadPool")
63   - public void shutdownThreadPool(){
64   - GpsRealAnalyse.shutdown();
65   - }
66   -
67 61 @RequestMapping(value = "/directivePushQueue")
68 62 public void directivePushQueue(){
69 63 DirectivePushQueue.start();
... ... @@ -105,4 +99,15 @@ public class anomalyCheckController {
105 99 public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName){
106 100 return dayOfSchedule.getLpScheduleMap().get(lpName);
107 101 }
  102 +
  103 + @RequestMapping(value = "/findSchByNbbm")
  104 + public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm){
  105 + return dayOfSchedule.findByNbbm(nbbm);
  106 + }
  107 +
  108 + @RequestMapping(value = "/removeExecPlan")
  109 + public int removeExecPlan(@RequestParam String nbbm){
  110 + dayOfSchedule.removeExecPlan(nbbm);
  111 + return 1;
  112 + }
108 113 }
... ...
src/main/java/com/bsth/controller/realcontrol/summary/DestroySituationController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol.summary;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.data.summary.entity.DestroySituation;
  5 +import com.bsth.data.summary.service.DestroySituationService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import javax.servlet.http.HttpServletRequest;
  12 +import javax.servlet.http.HttpServletResponse;
  13 +import java.util.Map;
  14 +
  15 +/**
  16 + * Created by panzhao on 2017/11/1.
  17 + */
  18 +@RestController
  19 +@RequestMapping("/summary/destroy_detail")
  20 +public class DestroySituationController extends BaseController<DestroySituation, Long> {
  21 +
  22 + @Autowired
  23 + DestroySituationService destroySituationService;
  24 +
  25 + @RequestMapping("excel")
  26 + public void excel(@RequestParam Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) {
  27 + destroySituationService.excel(map, request, response);
  28 + }
  29 +}
... ...
src/main/java/com/bsth/controller/realcontrol/summary/FastAndSlowController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol.summary;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.data.summary.entity.FastAndSlow;
  5 +import com.bsth.data.summary.service.FastAndSlowService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.PathVariable;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import javax.servlet.http.HttpServletRequest;
  13 +import javax.servlet.http.HttpServletResponse;
  14 +
  15 +/**
  16 + * 快慢误点统计
  17 + * Created by panzhao on 2017/10/24.
  18 + */
  19 +@RestController
  20 +@RequestMapping("/summary/fastAndSlow")
  21 +public class FastAndSlowController extends BaseController<FastAndSlow, Long> {
  22 +
  23 + @Autowired
  24 + FastAndSlowService fastAndSlowService;
  25 +
  26 + @RequestMapping("/excel/{lineCode}")
  27 + public void excel(@PathVariable("lineCode") String lineCode, @RequestParam String st
  28 + , @RequestParam String et, @RequestParam int type, HttpServletRequest request, HttpServletResponse response) {
  29 + fastAndSlowService.excel(lineCode, st, et, type, request, response);
  30 + }
  31 +}
0 32 \ No newline at end of file
... ...
src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -82,7 +82,8 @@ public class ReportController {
82 82 @RequestMapping(value="/queryStrinon" ,method = RequestMethod.GET)
83 83 public List<StationRoute> queryStrinon(@RequestParam String line,
84 84 @RequestParam int zd){
85   - return service.queryStrinon(line,zd);
  85 + List<StationRoute> list=service.queryStrinon(line,zd);
  86 + return list;
86 87 }
87 88 //根据排班查到离站
88 89 @RequestMapping(value="/queryInOutStrtion" ,method = RequestMethod.GET)
... ...
src/main/java/com/bsth/controller/schedule/core/TTInfoController.java
... ... @@ -2,14 +2,16 @@ package com.bsth.controller.schedule.core;
2 2  
3 3 import com.bsth.common.ResponseCode;
4 4 import com.bsth.controller.schedule.BController;
  5 +import com.bsth.entity.LineVersions;
5 6 import com.bsth.entity.schedule.TTInfo;
  7 +import com.bsth.service.LineVersionsService;
6 8 import com.bsth.service.schedule.TTInfoService;
7 9 import com.bsth.service.schedule.exception.ScheduleException;
  10 +import org.joda.time.DateTime;
8 11 import org.springframework.beans.factory.annotation.Autowired;
9 12 import org.springframework.web.bind.annotation.*;
10 13  
11   -import java.util.HashMap;
12   -import java.util.Map;
  14 +import java.util.*;
13 15  
14 16 /**
15 17 * Created by xu on 16/12/20.
... ... @@ -19,6 +21,56 @@ import java.util.Map;
19 21 public class TTInfoController extends BController<TTInfo, Long> {
20 22 @Autowired
21 23 private TTInfoService ttInfoService;
  24 + @Autowired
  25 + private LineVersionsService lineVersionsService;
  26 +
  27 + @RequestMapping(value = "/stationroute/{lineid}", method = RequestMethod.GET)
  28 + public Map<String, Object> getLineStationRouteVersions(@PathVariable(value = "lineid") Integer lineid) {
  29 + Map<String, Object> rtn = new HashMap<>();
  30 + try {
  31 + List<LineVersions> lineVersionses = lineVersionsService.findByLineCode(lineid);
  32 + Collections.sort(lineVersionses, new Comparator<LineVersions>() {
  33 + @Override
  34 + public int compare(LineVersions o1, LineVersions o2) {
  35 + if (o1.getVersions() > o2.getVersions()) {
  36 + return -1;
  37 + } else if (o1.getVersions() < o2.getVersions()) {
  38 + return 1;
  39 + } else {
  40 + return 0;
  41 + }
  42 + }
  43 + });
  44 +
  45 + // 取最近2条记录
  46 + List<Map<String, Object>> mapList = new ArrayList<>();
  47 + for (LineVersions lv: lineVersionses) {
  48 + String vname = lv.getName();
  49 + String rq = lv.getStartDate() == null ? "未知启用日期" : new DateTime(lv.getStartDate()).toString("YYYY年MM月dd日");
  50 + String sdesc = lv.getStatus() == 0 ? "历史" : (lv.getStatus() == 1 ? "当前" : "待更新");
  51 +
  52 + Map<String, Object> value = new HashMap<>();
  53 + value.put("desc", vname + "-" + rq + "-" + sdesc);
  54 + value.put("version", lv.getVersions());
  55 +
  56 + mapList.add(value);
  57 +
  58 + if (mapList.size() == 2) {
  59 + break;
  60 + }
  61 + }
  62 +
  63 + rtn.put("status", ResponseCode.SUCCESS);
  64 + rtn.put("data", mapList);
  65 +
  66 + } catch (Exception exp) {
  67 + rtn.put("status", ResponseCode.ERROR);
  68 + rtn.put("msg", exp.getMessage());
  69 + }
  70 +
  71 + return rtn;
  72 +
  73 + }
22 74  
23 75 @RequestMapping(value = "/validate_name", method = RequestMethod.GET)
24 76 public Map<String, Object> validate_name(@RequestParam Map<String, Object> param) {
... ...
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
... ... @@ -35,10 +35,27 @@ public class TTInfoDetailController extends BController&lt;TTInfoDetail, Long&gt; {
35 35 * @return
36 36 */
37 37 @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST)
38   - public Map<String, Object> validate_sheet(String filename, String sheetname, Integer lineid, String linename) {
  38 + public Map<String, Object> validate_sheet(
  39 + String filename, String sheetname, Integer lineid, String linename,
  40 + Integer zdlytype, Integer zdlyversion) {
39 41 Map<String, Object> rtn = new HashMap<>();
40 42 try {
41   - ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename);
  43 + if (zdlytype == null) {
  44 + throw new Exception("请选择路由版本类型");
  45 + } else {
  46 + if (zdlytype == 1) {
  47 + ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, null);
  48 + } else if (zdlytype == 2) {
  49 + if (zdlyversion == null || zdlyversion == -1) {
  50 + throw new Exception("请选择具体版本");
  51 + } else {
  52 + ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, zdlyversion);
  53 + }
  54 + } else {
  55 + throw new Exception("未知路由版本类型");
  56 + }
  57 + }
  58 +
42 59 rtn.put("status", ResponseCode.SUCCESS);
43 60 } catch (Exception exp) {
44 61 rtn.put("status", ResponseCode.ERROR);
... ...
src/main/java/com/bsth/controller/sys/UserController.java
... ... @@ -31,220 +31,252 @@ import java.util.*;
31 31 @RequestMapping("user")
32 32 public class UserController extends BaseController<SysUser, Integer> {
33 33  
34   - Logger logger = LoggerFactory.getLogger(this.getClass());
35   -
36   - @Autowired
37   - SysUserService sysUserService;
38   -
39   - @Autowired
40   - CompanyAuthorityService companyAuthorityService;
41   -
42   - @RequestMapping(value = "/login/jCryptionKey")
43   - public Map<String, Object> jCryptionKey(HttpServletRequest request){
44   - //公匙返回页面
45   - Map<String, Object> rs = new HashMap<>();
46   - rs.put("publickey", RSAUtils.generateBase64PublicKey());
47   - return rs;
48   - }
49   -
50   - //需要验证码的账号
51   - public static Map<String, Integer> captchaMap = new HashMap<>();
52   -
53   - @RequestMapping(value = "/login", method = RequestMethod.POST)
54   - public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
55   - @RequestParam String password, String captcha) {
56   -
57   - Map<String, Object> rs = new HashMap<>();
58   - rs.put("status", ResponseCode.ERROR);
59   - try {
60   - HttpSession session = request.getSession();
61   - rs.put("captcha", session.getAttribute("captcha"));
62   -
63   - if(captchaMap.get(userName) != null && captchaMap.get(userName) >= 3){
64   - //校验验证码
65   - String verCode = (String) session
66   - .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
67   -
68   - if(StringUtils.isBlank(captcha))
69   - return put(rs, "msg", "请输入验证码");
70   -
71   - if(!verCode.equals(captcha))
72   - return put(rs, "msg", "验证码有误,请刷新后重新输入");
73   - }
74   -
75   - //解密RSA
76   - try {
77   - userName = RSAUtils.decryptBase64(userName);
78   - password = RSAUtils.decryptBase64(password);
79   - } catch (RuntimeException e) {
80   - return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。");
81   - }
82   -
83   - SysUser user = sysUserService.findByUserName(userName);
84   - if (null == user)
85   - return put(rs, "msg", "不存在的用户");
86   -
87   - if (!user.isEnabled())
88   - return put(rs, "msg", "该用户已被锁定,请联系管理员");
89   -
90   - // 校验密码
91   - boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
92   - if (!matchStatus) {
93   - rs.put("msg", "密码有误");
94   -
95   - Integer captchSize = captchaMap.get(userName);
96   - if(null == captchSize)
97   - captchSize = 0;
98   -
99   - captchSize ++;
100   - captchaMap.put(userName, captchSize);
101   - return rs;
102   - }
103   -
104   - // 登录
105   - SecurityUtils.login(user, request);
106   - //session里写入用户名,webSocket连接时标识身份用
107   - session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
108   -
109   - //获取公司权限数据
110   - List<CompanyAuthority> cmyAuths=companyAuthorityService.findByUser(user);
111   - session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
112   -
113   - captchaMap.remove(userName);
114   - rs.put("status", ResponseCode.SUCCESS);
115   - } catch (Exception e) {
116   - logger.error("", e);
117   - rs.put("msg", "服务器出现异常,请联系管理员");
118   - }
119   - return rs;
120   - }
121   -
122   - /**
123   - * 返回当前用户的公司权限数据,用于构建页面级联下拉框
124   - * @return
125   - */
126   - @RequestMapping("companyData")
127   - public List<CompanyData> companyData(HttpServletRequest request){
128   - List<CompanyData> rs = new ArrayList<>();
129   - CompanyData companyData;
130   -
131   - ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create();
132   - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
133   -
134   - for(CompanyAuthority cAuth : cmyAuths){
135   - map.put(cAuth.getCompanyCode()+"_"+cAuth.getCompanyName(), cAuth);
136   - }
137   -
138   - Set<String> keys = map.keySet();
139   - String[] temps;
140   - for(String k : keys){
141   - temps = k.split("_");
142   -
143   - companyData = new CompanyData();
144   - companyData.setCompanyCode(temps[0]);
145   - companyData.setCompanyName(temps[1]);
146   - companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>());
147   -
148   - cmyAuths = map.get(k);
149   - for(CompanyAuthority c : cmyAuths){
150   - companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName()));
151   - }
152   -
153   - rs.add(companyData);
154   - }
155   -
156   - return rs;
157   - }
158   -
159   - @RequestMapping(value = "/login/captchaStatus")
160   - public int captchaStatus(String userName){
161   - Integer size = captchaMap.get(userName);
162   - return size == null?0:size;
163   - }
164   -
165   - public Map<String, Object> put(Map<String, Object> rs, String key, Object val){
166   - rs.put(key, val);
167   - return rs;
168   - }
169   -
170   - /**
171   - *
172   - * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param
173   - * request @return String 返回类型 @throws
174   - */
175   - @RequestMapping("/loginFailure")
176   - public String loginFailure(HttpServletRequest request) {
177   - String msg = "";
178   - HttpSession session = request.getSession();
179   -
180   - Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
181   -
182   - if (obj instanceof BadCredentialsException)
183   - msg = "登录失败,用户名或密码错误.";
184   - else if (obj instanceof SessionAuthenticationException)
185   - msg = "登录失败,当前策略不允许重复登录.";
186   - session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
187   - return msg;
188   - }
189   -
190   - @RequestMapping("/currentUser")
191   - public SysUser currentUser() {
192   - return SecurityUtils.getCurrentUser();
193   - }
194   -
195   - /**
196   - * @Title changeEnabled
197   - * @Description: TODO(改变用户状态)
198   - * @param id
199   - * 用户ID
200   - * @param enabled
201   - * 状态
202   - * @return
203   - */
204   - @RequestMapping("/changeEnabled")
205   - public int changeEnabled(@RequestParam int id, @RequestParam int enabled) {
206   - return sysUserService.changeEnabled(id, enabled);
207   - }
208   -
209   - /**
210   - * @Title changePWD
211   - * @Description: TODO(修改密码)
212   - * @param oldPWD
213   - * 原始密码
214   - * @param newPWD
215   - * 新密码
216   - * @param cnewPWD
217   - * 确认新密码
218   - * @return
219   - */
220   - @RequestMapping(value = "/changePWD", method = RequestMethod.POST)
221   - public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) {
222   - SysUser sysUser = SecurityUtils.getCurrentUser();
223   - String msg = "";
224   - if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) {
225   - if (oldPWD.equals(newPWD)) {
226   - msg = "新密码不能跟原始密码一样!";
227   - } else {
228   - if (newPWD.equals(cnewPWD)) {
229   - sysUserService.changePWD(sysUser.getId(), newPWD);
230   - msg = "修改成功!";
231   - } else {
232   - msg = "新密码两次输入不一致!";
233   - }
234   - }
235   - } else {
236   - msg = "原始密码错误!";
237   - }
238   - return msg;
239   - }
240   -
241   - @RequestMapping(value = "/register" ,method = RequestMethod.POST)
242   - public Map<String, Object> register(SysUser u){
243   - return sysUserService.register(u);
244   - }
245   -
246   - @RequestMapping(value = "/all_distinct")
247   - public List<SysUser> findAll_distinct(){
248   - return sysUserService.findAll_distinct();
249   - }
  34 + Logger logger = LoggerFactory.getLogger(this.getClass());
  35 +
  36 + @Autowired
  37 + SysUserService sysUserService;
  38 +
  39 + @Autowired
  40 + CompanyAuthorityService companyAuthorityService;
  41 +
  42 + @RequestMapping(value = "/login/jCryptionKey")
  43 + public Map<String, Object> jCryptionKey(HttpServletRequest request) {
  44 + //公匙返回页面
  45 + Map<String, Object> rs = new HashMap<>();
  46 + rs.put("publickey", RSAUtils.generateBase64PublicKey());
  47 + return rs;
  48 + }
  49 +
  50 + //需要验证码的账号
  51 + public static Map<String, Integer> captchaMap = new HashMap<>();
  52 +
  53 + @RequestMapping(value = "/login", method = RequestMethod.POST)
  54 + public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
  55 + @RequestParam String password, String captcha) {
  56 +
  57 + Map<String, Object> rs = new HashMap<>();
  58 + rs.put("status", ResponseCode.ERROR);
  59 + try {
  60 + HttpSession session = request.getSession();
  61 + rs.put("captcha", session.getAttribute("captcha"));
  62 +
  63 + if (captchaMap.get(userName) != null && captchaMap.get(userName) >= 3) {
  64 + //校验验证码
  65 + String verCode = (String) session
  66 + .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
  67 +
  68 + if (StringUtils.isBlank(captcha))
  69 + return put(rs, "msg", "请输入验证码");
  70 +
  71 + if (!verCode.equals(captcha))
  72 + return put(rs, "msg", "验证码有误,请刷新后重新输入");
  73 + }
  74 +
  75 + //解密RSA
  76 + try {
  77 + userName = RSAUtils.decryptBase64(userName);
  78 + password = RSAUtils.decryptBase64(password);
  79 + } catch (RuntimeException e) {
  80 + return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。");
  81 + }
  82 +
  83 + SysUser user = sysUserService.findByUserName(userName);
  84 + if (null == user)
  85 + return put(rs, "msg", "不存在的用户");
  86 +
  87 + if (!user.isEnabled())
  88 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
  89 +
  90 + // 校验密码
  91 + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
  92 + if (!matchStatus) {
  93 + rs.put("msg", "密码有误");
  94 +
  95 + Integer captchSize = captchaMap.get(userName);
  96 + if (null == captchSize)
  97 + captchSize = 0;
  98 +
  99 + captchSize++;
  100 + captchaMap.put(userName, captchSize);
  101 + return rs;
  102 + }
  103 +
  104 + // 登录
  105 + SecurityUtils.login(user, request);
  106 + //session里写入用户名,webSocket连接时标识身份用
  107 + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
  108 +
  109 + //获取公司权限数据
  110 + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
  111 + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
  112 +
  113 + captchaMap.remove(userName);
  114 + rs.put("status", ResponseCode.SUCCESS);
  115 + } catch (Exception e) {
  116 + logger.error("", e);
  117 + rs.put("msg", "服务器出现异常,请联系管理员");
  118 + }
  119 + return rs;
  120 + }
  121 +
  122 + @RequestMapping(value = "/change_user", method = RequestMethod.POST)
  123 + public Map<String, Object> changeUser(HttpServletRequest request, @RequestParam String userName,
  124 + @RequestParam String password) {
  125 +
  126 + Map<String, Object> rs = new HashMap<>();
  127 + rs.put("status", ResponseCode.ERROR);
  128 + try {
  129 + HttpSession session = request.getSession();
  130 +
  131 + SysUser user = sysUserService.findByUserName(userName);
  132 + if (null == user)
  133 + return put(rs, "msg", "不存在的用户");
  134 +
  135 + if (!user.isEnabled())
  136 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
  137 +
  138 + // 校验密码
  139 + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
  140 + if (!matchStatus)
  141 + return put(rs, "msg", "密码有误");
  142 +
  143 + // 登录
  144 + SecurityUtils.login(user, request);
  145 + //session里写入用户名,webSocket连接时标识身份用
  146 + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
  147 +
  148 + //获取公司权限数据
  149 + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
  150 + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
  151 + rs.put("status", ResponseCode.SUCCESS);
  152 + } catch (Exception e) {
  153 + logger.error("", e);
  154 + rs.put("msg", "服务器出现异常,请联系管理员");
  155 + }
  156 + return rs;
  157 + }
  158 +
  159 + /**
  160 + * 返回当前用户的公司权限数据,用于构建页面级联下拉框
  161 + *
  162 + * @return
  163 + */
  164 + @RequestMapping("companyData")
  165 + public List<CompanyData> companyData(HttpServletRequest request) {
  166 + List<CompanyData> rs = new ArrayList<>();
  167 + CompanyData companyData;
  168 +
  169 + ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create();
  170 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
  171 +
  172 + for (CompanyAuthority cAuth : cmyAuths) {
  173 + map.put(cAuth.getCompanyCode() + "_" + cAuth.getCompanyName(), cAuth);
  174 + }
  175 +
  176 + Set<String> keys = map.keySet();
  177 + String[] temps;
  178 + for (String k : keys) {
  179 + temps = k.split("_");
  180 +
  181 + companyData = new CompanyData();
  182 + companyData.setCompanyCode(temps[0]);
  183 + companyData.setCompanyName(temps[1]);
  184 + companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>());
  185 +
  186 + cmyAuths = map.get(k);
  187 + for (CompanyAuthority c : cmyAuths) {
  188 + companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName()));
  189 + }
  190 +
  191 + rs.add(companyData);
  192 + }
  193 +
  194 + return rs;
  195 + }
  196 +
  197 + @RequestMapping(value = "/login/captchaStatus")
  198 + public int captchaStatus(String userName) {
  199 + Integer size = captchaMap.get(userName);
  200 + return size == null ? 0 : size;
  201 + }
  202 +
  203 + public Map<String, Object> put(Map<String, Object> rs, String key, Object val) {
  204 + rs.put(key, val);
  205 + return rs;
  206 + }
  207 +
  208 + /**
  209 + * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param
  210 + * request @return String 返回类型 @throws
  211 + */
  212 + @RequestMapping("/loginFailure")
  213 + public String loginFailure(HttpServletRequest request) {
  214 + String msg = "";
  215 + HttpSession session = request.getSession();
  216 +
  217 + Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
  218 +
  219 + if (obj instanceof BadCredentialsException)
  220 + msg = "登录失败,用户名或密码错误.";
  221 + else if (obj instanceof SessionAuthenticationException)
  222 + msg = "登录失败,当前策略不允许重复登录.";
  223 + session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
  224 + return msg;
  225 + }
  226 +
  227 + @RequestMapping("/currentUser")
  228 + public SysUser currentUser() {
  229 + return SecurityUtils.getCurrentUser();
  230 + }
  231 +
  232 + /**
  233 + * @param id 用户ID
  234 + * @param enabled 状态
  235 + * @return
  236 + * @Title changeEnabled
  237 + * @Description: TODO(改变用户状态)
  238 + */
  239 + @RequestMapping("/changeEnabled")
  240 + public int changeEnabled(@RequestParam int id, @RequestParam int enabled) {
  241 + return sysUserService.changeEnabled(id, enabled);
  242 + }
  243 +
  244 + /**
  245 + * @param oldPWD 原始密码
  246 + * @param newPWD 新密码
  247 + * @param cnewPWD 确认新密码
  248 + * @return
  249 + * @Title changePWD
  250 + * @Description: TODO(修改密码)
  251 + */
  252 + @RequestMapping(value = "/changePWD", method = RequestMethod.POST)
  253 + public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) {
  254 + SysUser sysUser = SecurityUtils.getCurrentUser();
  255 + String msg = "";
  256 + if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) {
  257 + if (oldPWD.equals(newPWD)) {
  258 + msg = "新密码不能跟原始密码一样!";
  259 + } else {
  260 + if (newPWD.equals(cnewPWD)) {
  261 + sysUserService.changePWD(sysUser.getId(), newPWD);
  262 + msg = "修改成功!";
  263 + } else {
  264 + msg = "新密码两次输入不一致!";
  265 + }
  266 + }
  267 + } else {
  268 + msg = "原始密码错误!";
  269 + }
  270 + return msg;
  271 + }
  272 +
  273 + @RequestMapping(value = "/register", method = RequestMethod.POST)
  274 + public Map<String, Object> register(SysUser u) {
  275 + return sysUserService.register(u);
  276 + }
  277 +
  278 + @RequestMapping(value = "/all_distinct")
  279 + public List<SysUser> findAll_distinct() {
  280 + return sysUserService.findAll_distinct();
  281 + }
250 282 }
... ...
src/main/java/com/bsth/controller/traffic/VehicleInoutStopController.java 0 → 100644
  1 +package com.bsth.controller.traffic;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.traffic.VehicleInoutStop;
  5 +import com.bsth.service.traffic.VehicleInoutStopService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.data.domain.Page;
  8 +import org.springframework.data.domain.PageImpl;
  9 +import org.springframework.data.domain.PageRequest;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestParam;
  12 +import org.springframework.web.bind.annotation.RestController;
  13 +
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + *
  18 + * @author BSTH
  19 + *
  20 + */
  21 +@RestController
  22 +@RequestMapping("vehicle_stop")
  23 +public class VehicleInoutStopController extends BaseController<VehicleInoutStop,Integer> {
  24 +
  25 + @Autowired
  26 + VehicleInoutStopService vehicleInoutStopService;
  27 +
  28 + /**
  29 + * 给定条件查车载上报停靠站
  30 + * @param map
  31 + * @param page
  32 + * @param size
  33 + * @return
  34 + */
  35 + @RequestMapping(value = "getVehicleInoutStopByParam")
  36 + public Page<Map<String, Object>> getVehicleInoutStopByParam(@RequestParam Map<String, Object> map,
  37 + @RequestParam(defaultValue = "0") int page,
  38 + @RequestParam(defaultValue = "10") int size) {
  39 + map.put("page",page);
  40 + map.put("size",size);
  41 + long total = vehicleInoutStopService.getVehicleInoutStopCountByParam(map);
  42 + Page<Map<String, Object>> result = new PageImpl<>(vehicleInoutStopService.getVehicleInoutStopByParam(map),
  43 + new PageRequest(page, size, null),total);
  44 + return result;
  45 + }
  46 +}
... ...
src/main/java/com/bsth/data/BasicData.java
1 1 package com.bsth.data;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
4 4 import com.bsth.data.pinyin.PersionPinYinBuffer;
5 5 import com.bsth.entity.*;
6 6 import com.bsth.entity.schedule.CarConfigInfo;
... ... @@ -12,7 +12,6 @@ import org.apache.commons.lang3.StringUtils;
12 12 import org.slf4j.Logger;
13 13 import org.slf4j.LoggerFactory;
14 14 import org.springframework.beans.factory.annotation.Autowired;
15   -import org.springframework.jdbc.core.JdbcTemplate;
16 15 import org.springframework.stereotype.Component;
17 16  
18 17 import java.util.*;
... ... @@ -82,7 +81,7 @@ public class BasicData {
82 81 return name != null? name: stationCode2NameMap.get(prefix + code);
83 82 }
84 83  
85   - @Autowired
  84 +/* @Autowired
86 85 JdbcTemplate jdbcTemplate;
87 86 public Map<String, String> getNbbm2PlateNo(){
88 87 List<Map<String, Object>> list = jdbcTemplate.queryForList("select CAR_CODE,CAR_PLATE from bsth_c_cars where CAR_CODE is not null and CAR_PLATE is not null");
... ... @@ -92,7 +91,7 @@ public class BasicData {
92 91 rs.put(map.get("CAR_CODE").toString(), map.get("CAR_PLATE").toString());
93 92 }
94 93 return rs;
95   - }
  94 + }*/
96 95  
97 96 @Component
98 97 public static class BasicDataLoader extends Thread {
... ... @@ -258,7 +257,7 @@ public class BasicData {
258 257 * @Description: TODO(加载线路相关信息)
259 258 */
260 259 public void loadLineInfo() {
261   - Iterator<Line> iterator = lineRepository.findAll().iterator();
  260 + Iterator<Line> iterator = lineRepository.findAllService().iterator();
262 261  
263 262 Line line;
264 263 BiMap<Integer, String> biMap = HashBiMap.create();
... ...
src/main/java/com/bsth/data/LineConfigData.java
... ... @@ -2,7 +2,6 @@ package com.bsth.data;
2 2  
3 3 import com.bsth.Application;
4 4 import com.bsth.entity.Line;
5   -import com.bsth.entity.realcontrol.D80ReplyTemp;
6 5 import com.bsth.entity.realcontrol.LineConfig;
7 6 import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 7 import com.bsth.service.LineService;
... ... @@ -132,34 +131,19 @@ public class LineConfigData implements CommandLineRunner {
132 131 if (null == line)
133 132 throw new NullPointerException("异常的lineCode");
134 133  
  134 + conf.setReadReverse(true);
135 135 conf.setLine(line);
136 136 //开始运营时间
137 137 conf.setStartOpt("02:00");
138   - //托管状态
139   - conf.setTrust(true);
140 138 //出场时间类型
141 139 conf.setOutConfig(0);
142   - //进场时间类型
143   - //conf.setInConfig(1);
144   - //短语模板
145   - conf.setPhraseTemps("");
146 140 //调度指令模板
147 141 conf.setSchDirectiveTemp("");
148 142  
149   - //80指令回复 闵行用
150   - D80ReplyTemp t50 = new D80ReplyTemp(conf, (short) 0x50, "同意,回电详谈", "不同意,请回电"), t60 = new D80ReplyTemp(conf, (short) 0x60, "同意,回电详谈", "不同意,请回电"), tA2 = new D80ReplyTemp(conf, (short) 0xA2, "同意,回电详谈", "不同意,请回电"), t70 = new D80ReplyTemp(conf, (short) 0x70, "同意,回电详谈", "不同意,请回电"), t11 = new D80ReplyTemp(conf, (short) 0x11, "同意,回电详谈", "不同意,请回电");
151   -
152 143 //应急停靠默认值
153 144 conf.setYjtkStart("00:00");
154 145 conf.setYjtkEnd("23:59");
155 146  
156   - Set<D80ReplyTemp> temps = conf.getD80Temps();
157   - temps.add(t50);
158   - temps.add(t60);
159   - temps.add(tA2);
160   - temps.add(t70);
161   - temps.add(t11);
162   -
163 147 set(conf);
164 148 }
165 149 }
... ...
src/main/java/com/bsth/data/LineVersionsData.java 0 → 100644
  1 +package com.bsth.data;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.boot.CommandLineRunner;
  11 +import org.springframework.core.annotation.Order;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import com.bsth.entity.LineVersions;
  15 +import com.bsth.service.LineVersionsService;
  16 +import com.bsth.service.StationRouteService;
  17 +
  18 +/**
  19 + * @ClassName: LineVersionsData
  20 + * @Description: TODO(线路版本数据管理)
  21 + */
  22 +@Component
  23 +@Order(20)
  24 +public class LineVersionsData extends Thread {
  25 +
  26 + static Logger logger = LoggerFactory.getLogger(LineVersionsData.class);
  27 +
  28 +
  29 + @Autowired
  30 + LineVersionsService lineVersionsService;
  31 +
  32 + @Autowired
  33 + StationRouteService stationRouteService;
  34 +
  35 + @Override
  36 + public void run() {
  37 + try {
  38 + List<LineVersions> list = lineVersionsService.lineUpdate();
  39 + for (LineVersions lineVersions : list) {
  40 + Integer lineId = lineVersions.getLine().getId();
  41 + // 更新线路文件
  42 + Map<String, Object> map = new HashMap<>();
  43 + map.put("lineId", lineId);
  44 + stationRouteService.usingSingle(map);
  45 + logger.info("线路版本更新成功!");
  46 + }
  47 + } catch (Exception e) {
  48 + e.printStackTrace();
  49 + logger.error("线路版本更新出现异常!", e);
  50 + }
  51 + }
  52 +}
... ...
src/main/java/com/bsth/data/ThreadMonotor.java
1 1 package com.bsth.data;
2 2  
3   -import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
4   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
5   -import com.bsth.data.msg_queue.DirectivePushQueue;
6   -import com.bsth.data.msg_queue.WebSocketPushQueue;
7 3 import org.slf4j.Logger;
8 4 import org.slf4j.LoggerFactory;
9 5 import org.springframework.stereotype.Component;
... ... @@ -20,26 +16,26 @@ public class ThreadMonotor extends Thread{
20 16 public void run() {
21 17  
22 18 //线调GPS分析主线程
23   - if(GpsRealAnalyse.isBlock()){
  19 + /*if(GpsRealAnalyse.isBlock()){
24 20 log.warn("GpsRealAnalyse isBlock true !!!!");
25 21 GpsRealAnalyse.shutdown();
26   - }
  22 + }*/
27 23  
28   - if(GpsRealAnalyse.isIdle()){
  24 + /*if(GpsRealAnalyse.isIdle()){
29 25 //切换到备用的网关实时GPS对照数据
30 26 GpsDataLoaderThread.setFlag(-1);
31   - }
  27 + }*/
32 28  
33 29 //webSocket 消息推送队列
34   - if(WebSocketPushQueue.isIdle()){
  30 + /*if(WebSocketPushQueue.isIdle()){
35 31 log.warn("WebSocketPushQueue isIdle true !!!!");
36 32 WebSocketPushQueue.start();
37   - }
  33 + }*/
38 34  
39 35 //网关指令推送队列(系统自动发送的)
40   - if(DirectivePushQueue.isIdle()){
  36 + /*if(DirectivePushQueue.isIdle()){
41 37 log.warn("DirectivePushQueue isIdle true !!!!");
42 38 DirectivePushQueue.start();
43   - }
  39 + }*/
44 40 }
45 41 }
46 42 \ No newline at end of file
... ...
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
... ... @@ -159,7 +159,7 @@ public class CarOutInfoHandler {
159 159 ScheduleRealInfo[] array = new ScheduleRealInfo[3];
160 160 Collections.sort(list, schDFSJComparator);
161 161  
162   - int count = 0, threshold = 1000 * 60 * 60;
  162 + int count = 0, threshold = 1000 * 60 * 60 * 4;
163 163 long t = System.currentTimeMillis();
164 164 for (ScheduleRealInfo sch : list) {
165 165 if (count == 3)
... ...
src/main/java/com/bsth/data/directive/DayOfDirectives.java
... ... @@ -152,13 +152,14 @@ public class DayOfDirectives {
152 152  
153 153 public void clear(String device){
154 154 int c60 = 0, c64 = 0;
155   - //找到该设备的60数据
  155 +
156 156 Collection<D60> d60s = d60Map.values();
157 157 List<D60> rem60List = new ArrayList<>();
158 158 for(D60 d60 : d60s){
159   - if(d60.getDeviceId().equals(device))
  159 + if(device.equals(d60.getDeviceId()))
160 160 rem60List.add(d60);
161 161 }
  162 +
162 163 //清除60数据
163 164 for(D60 d60 : rem60List){
164 165 if(d60.getReply47() == null)
... ... @@ -166,6 +167,8 @@ public class DayOfDirectives {
166 167 if(null != d60Map.remove(d60.getMsgId()))
167 168 c60 ++;
168 169 }
  170 +
  171 + rem60List.clear();
169 172 if(c60 > 0)
170 173 logger.info("清除60数据 ," + c60);
171 174  
... ... @@ -173,7 +176,7 @@ public class DayOfDirectives {
173 176 Collection<D64> d64s = d64Map.values();
174 177 List<D64> rem64List = new ArrayList<>();
175 178 for(D64 d64 : d64s){
176   - if(d64.getDeviceId().equals(device))
  179 + if(device.equals(d64.getDeviceId()))
177 180 rem64List.add(d64);
178 181 }
179 182  
... ... @@ -186,6 +189,7 @@ public class DayOfDirectives {
186 189 c64 ++;
187 190 }
188 191  
  192 + rem64List.clear();
189 193 if(c64 > 0)
190 194 logger.info("清除64数据 ," + c64);
191 195 }
... ... @@ -197,7 +201,11 @@ public class DayOfDirectives {
197 201 public Collection<D64> all64(){
198 202 return d64Map.values();
199 203 }
200   -
  204 +
  205 + public D60 get(Integer msgId){
  206 + return d60Map.get(msgId);
  207 + }
  208 +
201 209 public Collection<Directive> all(){
202 210 List<Directive> all = new ArrayList<>();
203 211 all.addAll(d60Map.values());
... ...
src/main/java/com/bsth/data/directive/MsgIdGenerator.java
... ... @@ -12,7 +12,7 @@ public class MsgIdGenerator {
12 12  
13 13 private static int msgId = 1;
14 14  
15   - private final static int MAX_VALUE = Integer.MAX_VALUE - 10;
  15 + private final static int MAX_VALUE = Integer.MAX_VALUE - 1000;
16 16  
17 17 public synchronized static int getMsgId(){
18 18 msgId ++;
... ...
src/main/java/com/bsth/data/forecast/ArrivalDataLoader.java
... ... @@ -3,7 +3,6 @@ package com.bsth.data.forecast;
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.LineConfigData;
5 5 import com.bsth.data.forecast.entity.ArrivalEntity;
6   -import com.bsth.entity.realcontrol.LineConfig;
7 6 import com.bsth.util.db.DBUtils_MS;
8 7 import org.slf4j.Logger;
9 8 import org.slf4j.LoggerFactory;
... ... @@ -16,7 +15,6 @@ import java.sql.ResultSet;
16 15 import java.sql.SQLException;
17 16 import java.util.ArrayList;
18 17 import java.util.Calendar;
19   -import java.util.Collection;
20 18 import java.util.List;
21 19  
22 20 /**
... ... @@ -43,7 +41,7 @@ public class ArrivalDataLoader {
43 41 *
44 42 * @Title: load
45 43 * @Description: TODO(根据上次加载时间,查询之后的增量数据)
46   - */
  44 +
47 45 public List<ArrivalEntity> load(){
48 46 List<ArrivalEntity> list = null;
49 47  
... ... @@ -79,13 +77,13 @@ public class ArrivalDataLoader {
79 77 }
80 78 }
81 79 return list;
82   - }
  80 + }*/
83 81  
84 82 /**
85 83 *
86 84 * @Title: recovery
87 85 * @Description: TODO(从数据库恢复数据,按照线路的开始运营时间恢复)
88   - */
  86 +
89 87 public List<ArrivalEntity> recovery(){
90 88 Collection<LineConfig> confs = lineConfigData.getAll();
91 89 long t = System.currentTimeMillis()
... ... @@ -105,7 +103,7 @@ public class ArrivalDataLoader {
105 103  
106 104 prveLoadTime = t;
107 105 return all;
108   - }
  106 + }*/
109 107  
110 108 /**
111 109 *
... ...
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
... ... @@ -4,8 +4,8 @@ import com.bsth.data.forecast.entity.ForecastResult;
4 4 import com.bsth.data.forecast.entity.ForecastResult.ForecastResultItem;
5 5 import com.bsth.data.forecast.entity.SimpleRoute;
6 6 import com.bsth.data.forecast.entity.SimpleRoute.TimeRange;
7   -import com.bsth.data.gpsdata.GpsEntity;
8   -import com.bsth.data.gpsdata.GpsRealData;
  7 +import com.bsth.data.gpsdata_v2.GpsRealData;
  8 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
9 9 import com.bsth.data.schedule.DayOfSchedule;
10 10 import com.bsth.entity.realcontrol.ScheduleRealInfo;
11 11 import com.google.common.collect.ArrayListMultimap;
... ...
src/main/java/com/bsth/data/gpsdata/SignalStateData.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata;
2   -
3   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
4   -import com.bsth.websocket.handler.SendUtils;
5   -import com.google.common.base.Splitter;
6   -import com.google.common.collect.ArrayListMultimap;
7   -import org.springframework.beans.factory.annotation.Autowired;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.util.ArrayList;
11   -import java.util.List;
12   -
13   -/**
14   - * 信号状态数据
15   - * Created by panzhao on 2016/12/30.
16   - */
17   -@Component
18   -public class SignalStateData {
19   -
20   - @Autowired
21   - SendUtils sendUtils;
22   -
23   - private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create();
24   -
25   - public void put(SignalState state){
26   - //listMultimap.put(state.getLineCode(), state);
27   - //推送到客户端
28   - //sendUtils.sendSignalState(state);
29   - }
30   -
31   - public List<SignalState> get(String idx){
32   - List<SignalState> rs = new ArrayList<>();
33   - List<String> ids = Splitter.on(",").splitToList(idx);
34   -
35   - for(String lineCode : ids){
36   - rs.addAll(listMultimap.get(lineCode));
37   - }
38   - return rs;
39   - }
40   -}
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
5   -import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute;
6   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
7   -import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
8   -import com.google.common.collect.ArrayListMultimap;
9   -import com.vividsolutions.jts.geom.Coordinate;
10   -import com.vividsolutions.jts.geom.GeometryFactory;
11   -import com.vividsolutions.jts.geom.LineString;
12   -import com.vividsolutions.jts.geom.Polygon;
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.jdbc.core.JdbcTemplate;
18   -import org.springframework.jdbc.core.RowMapper;
19   -import org.springframework.stereotype.Component;
20   -
21   -import java.sql.ResultSet;
22   -import java.sql.SQLException;
23   -import java.util.*;
24   -
25   -/**
26   - * Created by panzhao on 2016/12/23.
27   - */
28   -@Component
29   -public class GeoCacheData {
30   -
31   - static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
32   -
33   - //每辆车缓存最后1000条gps
34   - private static final int CACHE_SIZE = 1000;
35   - private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
36   -
37   - //线路路段走向
38   - private static ArrayListMultimap<String, LineString> sectionCacheMap;
39   -
40   - //路段编码和名称对照
41   - private static Map<String, String> sectionCode2Name;
42   -
43   - //线路站点路由
44   - private static ArrayListMultimap<String, StationRoute> stationCacheMap;
45   -
46   - //线路_上下行_站点编码 ——> 站点
47   - private static Map<String, StationRoute> routeCodeMap;
48   -
49   - //停车场
50   - public static Map<String, Polygon> tccMap;
51   - //停车场
52   - public static Map<String, com.bsth.util.Geo.Polygon> tccMap2;
53   -
54   - //线路限速信息
55   - private static Map<String, Double> speedLimitMap;
56   -
57   - //需要定时刷新的站点路由
58   - public static Map<String, TimedEnableStationRoute> tesMap = new HashMap<>();
59   - //TimedEnableStationRoute
60   -
61   - @Autowired
62   - JdbcTemplate jdbcTemplate;
63   -
64   - public static CircleQueue<GpsEntity> getGps(String nbbm) {
65   - return gpsCacheMap.get(nbbm);
66   - }
67   -
68   - public static void putGps(GpsEntity gps) {
69   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
70   - if (queue == null) {
71   - /*//第一个点从站内开始
72   - if (gps.getInstation() == 0)
73   - return;*/
74   -
75   - queue = new CircleQueue<>(CACHE_SIZE);
76   - gpsCacheMap.put(gps.getNbbm(), queue);
77   - }
78   - queue.add(gps);
79   - }
80   -
81   - public static void clear(String nbbm) {
82   - try {
83   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
84   - if (queue != null)
85   - queue.clear();
86   - } catch (Exception e) {
87   - logger.error("", e);
88   - }
89   - }
90   -
91   - public static Map<String, String> sectionCode2NameMap(){
92   - return sectionCode2Name;
93   - }
94   -
95   - public static StationRoute getRouteCode(GpsEntity gps) {
96   - return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
97   - }
98   -
99   - public static List<StationRoute> getStationRoute(String lineCode, int directions) {
100   - return stationCacheMap.get(lineCode + "_" + directions);
101   - }
102   -
103   - public static StationRoute getStation(String lineCode, int directions, String code) {
104   - List<StationRoute> list = getStationRoute(lineCode, directions);
105   -
106   - for (StationRoute sr : list) {
107   - if (sr.getCode().equals(code)) {
108   - return sr;
109   - }
110   - }
111   - return null;
112   - }
113   -
114   - public static Double speedLimit(String lineCode){
115   - return speedLimitMap.get(lineCode);
116   - }
117   -
118   - public static List<LineString> getLineStringList(GpsEntity gps){
119   - return sectionCacheMap.get(gps.getLineId() + "_" + gps.getUpDown());
120   - }
121   -
122   - public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) {
123   - List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>();
124   -
125   - boolean flag = false;
126   - for (StationRoute sr : list) {
127   - if (flag)
128   - rs.add(sr);
129   - if (sr.getCode().equals(sCode))
130   - flag = true;
131   - else if (sr.getCode().equals(eCode))
132   - break;
133   - }
134   - return rs;
135   - }
136   -
137   - public static Polygon getTccPolygon(String code) {
138   - return tccMap.get(code);
139   - }
140   -
141   - GeometryFactory geometryFactory = new GeometryFactory();
142   - public void loadData() {
143   - loadStationRoutesData();
144   - loadTccMapData();
145   - loadSpeedLimit();
146   -
147   - //加载路段信息
148   - loadRoadsData();
149   - }
150   -
151   - private void loadRoadsData() {
152   - //加载线路下路段空间数据
153   - String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS, s.CROSES_ROAD from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code";
154   - List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql);
155   -
156   - String polygonStr, key;
157   - String[] coords;
158   - int i, len;
159   - ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create();
160   - Coordinate[] cds;
161   - String[] temps1, temps2;
162   - for (Map<String, Object> tMap : secList) {
163   - //空间数据映射
164   - polygonStr = tMap.get("GSECTION_VECTOR").toString();
165   - key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS");
166   -
167   - coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
168   - len = coords.length - 1;
169   - //每2个点连一条线
170   - for(i = 0; i < len; i ++){
171   - temps1 = coords[i].split(" ");
172   - temps2 = coords[i + 1].split(" ");
173   -
174   - cds = new Coordinate[2];
175   - cds[0] = new Coordinate(Float.parseFloat(temps1[1]), Float.parseFloat(temps1[0]));
176   - cds[1] = new Coordinate(Float.parseFloat(temps2[1]), Float.parseFloat(temps2[0]));
177   -
178   - sectionCacheTempMap.put(key, geometryFactory.createLineString(cds));
179   - }
180   - }
181   -
182   - if(sectionCacheTempMap.size() > 0)
183   - sectionCacheMap = sectionCacheTempMap;
184   -
185   - Map<String, String> sectionCode2NameTemp = new HashMap<>();
186   -
187   - //加载全量路段编码和名称对照
188   - sql = "select SECTION_CODE,SECTION_NAME,CROSES_ROAD from bsth_c_section";
189   - secList = jdbcTemplate.queryForList(sql);
190   - String name = null, code;
191   - for (Map<String, Object> tMap : secList) {
192   - if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))
193   - name = tMap.get("CROSES_ROAD").toString();
194   - else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))
195   - name = tMap.get("SECTION_NAME").toString();
196   -
197   - code = tMap.get("SECTION_CODE").toString();
198   - sectionCode2NameTemp.put(code, name);
199   - }
200   - if(sectionCode2NameTemp.size() > 0)
201   - sectionCode2Name = sectionCode2NameTemp;
202   - }
203   -
204   - private void loadTccMapData(){
205   - //加载停车场数据
206   - String sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
207   - List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
208   - Map<String, Polygon> tccTempMap = new HashMap<>();
209   -
210   - Polygon polygon;
211   - for (Map<String, Object> tMap : tccList) {
212   -
213   - try {
214   - polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString()));
215   - tccTempMap.put(tMap.get("PARK_CODE").toString()
216   - , polygon);
217   - } catch (Exception e) {
218   - logger.error("停车场:" + tMap.get("PARK_CODE"), e);
219   - }
220   - }
221   - if (tccTempMap.size() > 0){
222   - tccMap = tccTempMap;
223   - tccMap2 = convertPolygonMap(tccMap);
224   - }
225   - }
226   -
227   - private Map<String, com.bsth.util.Geo.Polygon> convertPolygonMap(Map<String, Polygon> tccMap) {
228   - Map<String, com.bsth.util.Geo.Polygon> rsMap = new HashMap<>();
229   - Set<String> ks = tccMap.keySet();
230   - for(String k : ks){
231   - rsMap.put(k, convertPolygon(tccMap.get(k)));
232   - }
233   - return rsMap;
234   - }
235   -
236   - public static com.bsth.util.Geo.Polygon convertPolygon(Polygon polygon) {
237   - List<com.bsth.util.Geo.Point> ps = new ArrayList<>();
238   - com.bsth.util.Geo.Point p;
239   -
240   - Coordinate[] cs = polygon.getCoordinates();
241   - for(int i = 0; i < cs.length;i ++){
242   - p = new com.bsth.util.Geo.Point(cs[i].y, cs[i].x);
243   - ps.add(p);
244   - }
245   - return new com.bsth.util.Geo.Polygon(ps);
246   - }
247   -
248   - private void loadStationRoutesData(){
249   - //加载站点路由
250   - String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
251   - List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
252   - @Override
253   - public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
254   - StationRoute sRoute = new StationRoute();
255   - sRoute.setCode(rs.getString("STATION_CODE"));
256   - sRoute.setLineCode(rs.getString("LINE_CODE"));
257   - sRoute.setDirections(rs.getInt("DIRECTIONS"));
258   - sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX"))));
259   - sRoute.setRadius(rs.getFloat("RADIUS"));
260   - sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
261   - sRoute.setMark(rs.getString("STATION_MARK"));
262   - sRoute.setName(rs.getString("STATION_NAME"));
263   -
264   - String shapesType = rs.getString("SHAPES_TYPE");
265   - //多边形电子围栏
266   - if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
267   - sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
268   - }
269   - return sRoute;
270   - }
271   - });
272   - //按线路和走向分组
273   - if (routeList.size() > 0) {
274   - ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
275   - Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
276   - for (StationRoute sr : routeList) {
277   - tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
278   - //站点编码 ——> 和路由顺序对照
279   - codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
280   - }
281   -
282   - StationRouteComp srCom = new StationRouteComp();
283   - //连接路由
284   - Set<String> set = tempMap.keySet();
285   - for (String key : set) {
286   - Collections.sort(tempMap.get(key), srCom);
287   - connectStationRoute(tempMap.get(key));
288   - }
289   -
290   - //定时启用的站点走向
291   - if(tesMap.size() > 0){
292   - List<String> rems = new ArrayList<>();
293   - long t = System.currentTimeMillis();
294   - for(TimedEnableStationRoute tes : tesMap.values()){
295   - if(tes.getEnableTime() > t){
296   - logger.info("锁住站点路由," + tes.getLineCode());
297   - tempMap.replaceValues(tes.getLineCode() + "_0", stationCacheMap.get(tes.getLineCode() + "_0"));
298   - tempMap.replaceValues(tes.getLineCode() + "_1", stationCacheMap.get(tes.getLineCode() + "_1"));
299   - }
300   - else
301   - rems.add(tes.getLineCode());
302   - }
303   -
304   - //remove
305   - if(rems.size() > 0){
306   - for(String lineCode : rems){
307   - logger.info("启用路由," + lineCode);
308   - tesMap.remove(lineCode);
309   - }
310   - }
311   - }
312   - stationCacheMap = tempMap;
313   - routeCodeMap = codeMap;
314   - }
315   - }
316   -
317   - private void loadSpeedLimit(){
318   - //加载线路限速信息
319   - String sql = "select l.LINE_CODE,i.SPEEDING from bsth_c_line_information i left join bsth_c_line l on i.line=l.id where i.speed_limit is not null";
320   - List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql);
321   - Map<String, Double> speedTempMap = new HashMap<>();
322   - for (Map<String, Object> tMap : speedMap) {
323   - try {
324   - speedTempMap.put(tMap.get("LINE_CODE").toString(), Double.parseDouble(tMap.get("SPEEDING").toString()));
325   - } catch (NumberFormatException e) {
326   - logger.error("speeding is null...");
327   - }
328   - }
329   - speedLimitMap = speedTempMap;
330   - }
331   -
332   - private void connectStationRoute(List<StationRoute> list) {
333   - int size = list.size();
334   - StationRoute sr = null;
335   - for (int i = 0; i < size; i++) {
336   - sr = list.get(i);
337   - //上一个
338   - if (i > 0)
339   - sr.setPrve(list.get(i - 1));
340   - //下一个
341   - if (i < size - 1)
342   - sr.setNext(list.get(i + 1));
343   - }
344   - }
345   -
346   - public Coordinate[] parsePolygon(String polygonStr) {
347   - String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
348   -
349   - Coordinate[] cds = new Coordinate[coords.length];
350   - int len = coords.length;
351   - for (int i = 0; i < len; i++) {
352   - temps = coords[i].split(" ");
353   - cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0]));
354   - }
355   - return cds;
356   - }
357   -
358   - /**
359   - * 是不是终点站
360   - *
361   - * @param lineId
362   - * @param upDown
363   - * @param stationCode
364   - * @return
365   - */
366   - public static boolean isEndStation(String lineId, Byte upDown, String stationCode) {
367   - StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode);
368   - return station != null && station.getMark().equals("E");
369   - }
370   -}
371 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
5   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6   -import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
7   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
8   -import org.joda.time.format.DateTimeFormat;
9   -import org.joda.time.format.DateTimeFormatter;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -
13   -import java.util.List;
14   -
15   -/**
16   - * Created by panzhao on 2016/12/27.
17   - */
18   -public abstract class SignalHandle {
19   -
20   - public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs);
21   -
22   - protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) {
23   - return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
24   - }
25   -
26   -/* protected boolean isDriftSignal(GpsEntity gps) {
27   - return gps.getLat() == 0 || gps.getLon() == 0;
28   - }*/
29   -
30   - /**
31   - * gps掉线
32   - * @param gps
33   - * @return
34   - */
35   - protected boolean isGpsOffline(GpsEntity gps){
36   - return gps.getLat() == 0 || gps.getLon() == 0;
37   - }
38   -
39   - protected boolean isOffline(GpsEntity gps){
40   - return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline");
41   - }
42   - /**
43   - * 是不是异常信号
44   - *
45   - * @param gps
46   - * @return protected boolean isAbnormal(GpsEntity gps) {
47   - return gps.getLat() == 0 || gps.getLon() == 0;
48   - }*/
49   -
50   - /**
51   - * 连续异常信号个数统计
52   - *
53   - * @param
54   - * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
55   - * int count = 0;
56   - * <p>
57   - * if (!isNotEmpty(prevs))
58   - * return count;
59   - * <p>
60   - * GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
61   - * GpsEntity gps;
62   - * for (int i = array.length - 1; i > 0; i--) {
63   - * gps = array[i];
64   - * <p>
65   - * if (isAbnormal(gps))
66   - * count++;
67   - * else
68   - * break;
69   - * }
70   - * <p>
71   - * return count;
72   - * }
73   - */
74   -
75   - Logger logger = LoggerFactory.getLogger(this.getClass());
76   - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
77   - protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
78   - byte updown = Byte.parseByte(sch.getXlDir());
79   - //gps 切换走向
80   - gps.setUpDown(updown);
81   -
82   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), updown);
83   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
84   - if (station != null) {
85   - gps.setStopNo(station.getCode());
86   - }
87   -
88   - logger.info(gps.getTimestamp() + " -" + fmtHHmm.print(gps.getTimestamp()) + " 车辆 :" + gps.getNbbm() + " 切换到走向 : " + updown);
89   - }
90   -
91   - /**
92   - * 是否是从异常状态恢复的第一个信号
93   - *
94   - * @param gps
95   - * @param prevs
96   - * @return
97   - */
98   - protected boolean abnormalRecovery(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
99   - if (prevs == null || prevs.size() == 0)
100   - return false;
101   -
102   - GpsEntity prev = prevs.getTail();
103   - //从异常状态恢复
104   - if (isGpsOffline(prev)
105   - && !isGpsOffline(gps)) {
106   - return true;
107   - }
108   -
109   - return false;
110   - }
111   -}
112 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/entity/ArrivalInfo.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/**
4   - * 到离站信息
5   - * Created by panzhao on 2017/2/20.
6   - */
7   -public class ArrivalInfo {
8   -
9   - private String lineCode;
10   -
11   - private String deviceId;
12   -
13   - /** 时间戳 */
14   - private Long ts;
15   -
16   - private String stop;
17   -
18   - private Integer upDown;
19   -
20   - private int inOut;
21   -
22   -
23   -}
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/** 路由反转
4   - * Created by panzhao on 2016/12/28.
5   - */
6   -public class RouteReverse {
7   -
8   - private String nbbm;
9   - //反转个数
10   - private int count;
11   -
12   - //详细 1,2,3,2,1
13   - private String detail;
14   -
15   - //掉头站点
16   - private String turned;
17   -
18   - //掉头时间
19   - private long zt;
20   -
21   - //检测时间
22   - private long ct;
23   -
24   - //是否闭合
25   - private boolean close;
26   -
27   - //信号不明确
28   - private boolean vague;
29   -
30   - public int getCount() {
31   - return count;
32   - }
33   -
34   - public void setCount(int count) {
35   - this.count = count;
36   - }
37   -
38   - public String getDetail() {
39   - return detail;
40   - }
41   -
42   - public void setDetail(String detail) {
43   - this.detail = detail;
44   - }
45   -
46   - public String getTurned() {
47   - return turned;
48   - }
49   -
50   - public void setTurned(String turned) {
51   - this.turned = turned;
52   - }
53   -
54   - public boolean isClose() {
55   - return close;
56   - }
57   -
58   - public void setClose(boolean close) {
59   - this.close = close;
60   - }
61   -
62   - public long getZt() {
63   - return zt;
64   - }
65   -
66   - public void setZt(long zt) {
67   - this.zt = zt;
68   - }
69   -
70   - public long getCt() {
71   - return ct;
72   - }
73   -
74   - public void setCt(long ct) {
75   - this.ct = ct;
76   - }
77   -
78   - public String getNbbm() {
79   - return nbbm;
80   - }
81   -
82   - public void setNbbm(String nbbm) {
83   - this.nbbm = nbbm;
84   - }
85   -
86   - public boolean isVague() {
87   - return vague;
88   - }
89   -
90   - public void setVague(boolean vague) {
91   - this.vague = vague;
92   - }
93   -}
94 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalAbnormal.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/**
4   - * 班次信号异常(漂移 或 断线)
5   - * Created by panzhao on 2016/12/31.
6   - */
7   -public class SignalAbnormal {
8   -
9   - private Long et;
10   -
11   - /** drift or reconnection */
12   - private String abnormalType;
13   -
14   - private Long st;
15   -
16   - private String nearPoint;
17   -
18   - private String destCode;
19   -
20   - private Long ct;
21   -
22   - //0: 发车 1:到站
23   - private int outOrIn;
24   -
25   - public Long getEt() {
26   - return et;
27   - }
28   -
29   - public void setEt(Long et) {
30   - this.et = et;
31   - }
32   -
33   - public String getAbnormalType() {
34   - return abnormalType;
35   - }
36   -
37   - public void setAbnormalType(String abnormalType) {
38   - this.abnormalType = abnormalType;
39   - }
40   -
41   - public Long getSt() {
42   - return st;
43   - }
44   -
45   - public void setSt(Long st) {
46   - this.st = st;
47   - }
48   -
49   - public String getNearPoint() {
50   - return nearPoint;
51   - }
52   -
53   - public void setNearPoint(String nearPoint) {
54   - this.nearPoint = nearPoint;
55   - }
56   -
57   - public Long getCt() {
58   - return ct;
59   - }
60   -
61   - public void setCt(Long ct) {
62   - this.ct = ct;
63   - }
64   -
65   - public int getOutOrIn() {
66   - return outOrIn;
67   - }
68   -
69   - public void setOutOrIn(int outOrIn) {
70   - this.outOrIn = outOrIn;
71   - }
72   -
73   - public String getDestCode() {
74   - return destCode;
75   - }
76   -
77   - public void setDestCode(String destCode) {
78   - this.destCode = destCode;
79   - }
80   -}
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalState.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
5   -import org.joda.time.format.DateTimeFormat;
6   -import org.joda.time.format.DateTimeFormatter;
7   -
8   -/**
9   - * 信号状态
10   - * Created by panzhao on 2016/12/30.
11   - */
12   -public class SignalState {
13   -
14   - private String type;
15   -
16   - private Long st;
17   -
18   - //private Long checkTime;
19   -
20   - private Long schId;
21   -
22   - private String lineCode;
23   -
24   - private String text;
25   -
26   - private RouteReverse reverse;
27   -
28   - private SignalAbnormal signalAbnormal;
29   -
30   - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
31   -
32   - /**
33   - * 记录区间调头
34   - *
35   - * @param sch
36   - * @param reverse
37   - * @return
38   - */
39   - public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) {
40   - /*if(reverse.isVague())
41   - return null;*/
42   -
43   - SignalState state = new SignalState();
44   - state.setSchId(sch.getId());
45   - state.setType("route_reverse");
46   - //state.setCheckTime(System.currentTimeMillis());
47   -
48   - String stationName = BasicData.stationCode2NameMap.get(sch.getXlBm() + "_" + sch.getXlDir() + "_" + reverse.getTurned());
49   - state.setText(fmtHHmm.print(reverse.getZt()) + " 从 " + stationName + " 站掉头");
50   - state.setSt(sch.getFcsjActualTime());
51   - state.setLineCode(sch.getXlBm());
52   - state.setReverse(reverse);
53   - return state;
54   - }
55   -
56   - public static SignalState abnormalSignalSTate(ScheduleRealInfo sch, SignalAbnormal signalAbnormal) {
57   - SignalState state = new SignalState();
58   - state.setSchId(sch.getId());
59   - state.setType("abnormal_signal");
60   - //state.setCheckTime(signalAbnormal.getCt());
61   - state.setLineCode(sch.getXlBm());
62   -
63   - String text = (fmtHHmm.print(signalAbnormal.getSt()) + " ~ " + fmtHHmm.print(signalAbnormal.getEt()));
64   - String abnormType = signalAbnormal.getAbnormalType();
65   - if (abnormType.equals("drift"))
66   - text += "(GPS无效)";
67   - else if (abnormType.equals("reconnection"))
68   - text += "(信号丢失)";
69   -
70   - state.setText(text);
71   - state.setSignalAbnormal(signalAbnormal);
72   - return state;
73   - }
74   -
75   - public String getType() {
76   - return type;
77   - }
78   -
79   - public void setType(String type) {
80   - this.type = type;
81   - }
82   -
83   - public long getSchId() {
84   - return schId;
85   - }
86   -
87   - public void setSchId(long schId) {
88   - this.schId = schId;
89   - }
90   -
91   - public String getLineCode() {
92   - return lineCode;
93   - }
94   -
95   - public void setLineCode(String lineCode) {
96   - this.lineCode = lineCode;
97   - }
98   -
99   - public Long getSt() {
100   - return st;
101   - }
102   -
103   - public void setSt(Long st) {
104   - this.st = st;
105   - }
106   -
107   - public String getText() {
108   - return text;
109   - }
110   -
111   - public void setText(String text) {
112   - this.text = text;
113   - }
114   -
115   - public RouteReverse getReverse() {
116   - return reverse;
117   - }
118   -
119   - public void setReverse(RouteReverse reverse) {
120   - this.reverse = reverse;
121   - }
122   -
123   - public SignalAbnormal getSignalAbnormal() {
124   - return signalAbnormal;
125   - }
126   -
127   - public void setSignalAbnormal(SignalAbnormal signalAbnormal) {
128   - this.signalAbnormal = signalAbnormal;
129   - }
130   -}
src/main/java/com/bsth/data/gpsdata/arrival/entity/TimedEnableStationRoute.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -/**
4   - * 定时启用站点路由
5   - * Created by panzhao on 2017/8/28.
6   - */
7   -public class TimedEnableStationRoute {
8   -
9   - private String lineCode;
10   -
11   - private Long enableTime;
12   -
13   - public String getLineCode() {
14   - return lineCode;
15   - }
16   -
17   - public void setLineCode(String lineCode) {
18   - this.lineCode = lineCode;
19   - }
20   -
21   - public Long getEnableTime() {
22   - return enableTime;
23   - }
24   -
25   - public void setEnableTime(Long enableTime) {
26   - this.enableTime = enableTime;
27   - }
28   -}
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.SignalHandle;
5   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6   -import com.bsth.data.gpsdata.status_manager.GpsStatusManager;
7   -import com.bsth.data.schedule.DayOfSchedule;
8   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
9   -import com.bsth.service.directive.DirectiveService;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -import org.springframework.stereotype.Component;
14   -
15   -/**
16   - * 信号状态纠正
17   - * Created by panzhao on 2016/12/27.
18   - */
19   -@Component
20   -public class CorrectSignalHandle extends SignalHandle {
21   -
22   - @Autowired
23   - DayOfSchedule dayOfSchedule;
24   - @Autowired
25   - DirectiveService directiveService;
26   -
27   - @Autowired
28   - GpsStatusManager gpsStatusManager;
29   -
30   - Logger logger = LoggerFactory.getLogger(this.getClass());
31   -
32   - @Override
33   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
34   - ScheduleRealInfo task = dayOfSchedule.executeCurr(gps.getNbbm());
35   - if(task == null)
36   - return false;
37   - //ScheduleRealInfo sch;
38   -
39   - //子任务
40   - /*if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){
41   - ChildTaskPlan childTask = (ChildTaskPlan) task;
42   - sch = childTask.getSchedule();
43   - }
44   - else
45   - sch = (ScheduleRealInfo) task;*/
46   -
47   - byte updown = Byte.parseByte(task.getXlDir());
48   - //走向
49   - if(gps.getUpDown() != updown){
50   - gps.setUpDown(updown);
51   - //gps.setState(0);
52   - }
53   -
54   - //(转发的数据不管)
55   - if(gps.getSource() != 0){
56   - //gps=非营运 或走向不对 && 班次=非空驶 ;切换到营运状态
57   - if((!gps.isService() || gps.getUpDown() != updown) &&
58   - !dayOfSchedule.emptyService(task)){
59   - gpsStatusManager.changeServiceState(gps.getNbbm(), updown, 0, "同步@系统");
60   - }
61   -
62   - //需要切换线路
63   - if(!task.getXlBm().equals(gps.getLineId())){
64   - gpsStatusManager.changeLine(gps.getNbbm(), task.getXlBm(), "同步@系统");
65   - }
66   - }
67   -
68   - return true;
69   - }
70   -}
71 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.SignalHandle;
7   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
8   -import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
9   -import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher;
10   -import com.bsth.data.gpsdata.status_manager.GpsStatusManager;
11   -import com.bsth.data.msg_queue.DirectivePushQueue;
12   -import com.bsth.data.schedule.DayOfSchedule;
13   -import com.bsth.data.schedule.ScheduleComparator;
14   -import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
15   -import com.bsth.entity.realcontrol.LineConfig;
16   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
17   -import com.bsth.websocket.handler.SendUtils;
18   -import org.apache.commons.lang3.StringUtils;
19   -import org.slf4j.Logger;
20   -import org.slf4j.LoggerFactory;
21   -import org.springframework.beans.factory.annotation.Autowired;
22   -import org.springframework.stereotype.Component;
23   -
24   -import java.util.Collections;
25   -import java.util.List;
26   -
27   -/**
28   - * 进出站动作处理
29   - * Created by panzhao on 2016/12/27.
30   - */
31   -@Component
32   -public class InOutStationSignalHandle extends SignalHandle{
33   -
34   - Logger logger = LoggerFactory.getLogger(this.getClass());
35   -
36   - @Autowired
37   - DayOfSchedule dayOfSchedule;
38   -
39   - @Autowired
40   - LineConfigData lineConfigData;
41   -
42   - @Autowired
43   - SendUtils sendUtils;
44   -
45   - @Autowired
46   - ScheduleSignalState scheduleSignalState;
47   -
48   - @Autowired
49   - SignalSchPlanMatcher signalSchPlanMatcher;
50   -
51   - @Autowired
52   - GpsStatusManager gpsStatusManager;
53   -
54   - private final static int MAX_BEFORE_TIME = 1000 * 60 * 120;
55   -
56   - //最大的班次时间差,防止异常的GPS时间打乱数据
57   - private final static int MAX_NORMAL_DIFF = 1000 * 60 * 60 * 12;
58   -
59   - @Override
60   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
61   - //忽略掉线信号
62   - if(isGpsOffline(gps))
63   - return false;
64   -
65   - /*//从异常状态恢复的第一个信号*/
66   - if(abnormalRecovery(gps, prevs)){
67   - //回溯一下之前的轨迹
68   - //scheduleSignalState.signalRetrospect(gps);
69   - return false;
70   - }
71   -
72   - if(isNotEmpty(prevs)){
73   - GpsEntity prev = prevs.getTail();
74   - if(isOutStation(gps, prev))
75   - outStation(gps, prev);
76   -
77   -
78   - if(isInStation(gps, prev))
79   - inStation(gps, prev);
80   - }
81   -
82   - return true;
83   - }
84   -
85   - private boolean isOutStation(GpsEntity gps, GpsEntity prev){
86   - //从站内到站外
87   - if(prev.getInstation() > 0 && gps.getInstation() == 0)
88   - return true;
89   -
90   - //从站内到另一个站内
91   - if(prev.getInstation() > 0 && gps.getInstation() > 0
92   - && !prev.getStopNo().equals(gps.getStopNo()))
93   - return true;
94   -
95   - //在被起点站覆盖的情况下出场
96   - if(isOutPark(gps, prev)){
97   - return true;
98   - }
99   - return false;
100   - }
101   -
102   - private boolean isInStation(GpsEntity gps, GpsEntity prev){
103   - //从站外到站内
104   - if(prev.getInstation() == 0 && gps.getInstation() > 0
105   - /*&& !prev.getStopNo().equals(gps.getStopNo())*/){
106   - return true;
107   - }
108   -
109   - //从站内到另一个站内
110   - if(prev.getInstation() == 1 && gps.getInstation() == 1
111   - && !prev.getStopNo().equals(gps.getStopNo())
112   - && !prev.getStation().getName().equals(gps.getStation().getName()))
113   - return true;
114   -
115   - //从场内到站内
116   - if(prev.getInstation() == 2 && gps.getInstation() == 1){
117   - return true;
118   - }
119   -
120   - //被起点站覆盖的情况下进场
121   - if(isInPark(gps, prev))
122   - return true;
123   - return false;
124   - }
125   -
126   - /**
127   - * 出站/出场
128   - * @param gps 当前点
129   - * @param prev 上一个点
130   - */
131   - private void outStation(GpsEntity gps, GpsEntity prev) {
132   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
133   - String qdzCode = sch.getQdzCode();
134   -
135   - int diff = (int) (sch.getDfsjT() - gps.getTimestamp());
136   -
137   - //首班出场最多提前2小时
138   - if((dayOfSchedule.isFirstOut(sch) && diff > MAX_BEFORE_TIME) || diff > MAX_BEFORE_TIME / 2)
139   - return;
140   -
141   - //正常班次最大时间差
142   - if(Math.abs(diff) > MAX_NORMAL_DIFF)
143   - return;
144   -
145   - //起点发车
146   - if(qdzCode != null
147   - && prev.getStopNo().equals(qdzCode)
148   - && (gps.getInstation()==0 || !gps.getStopNo().equals(prev.getStopNo()))
149   - && !willDepart(gps, prev, sch)){
150   -
151   - //发车班次匹配
152   - signalSchPlanMatcher.outMatch(gps, sch);
153   - sch = dayOfSchedule.executeCurr(gps.getNbbm());
154   -
155   - //班次已经实发
156   - if(StringUtils.isNotEmpty(sch.getFcsjActual())
157   - && !outManyFit(gps, sch)){
158   - return;
159   - }
160   -
161   - //应用到离站缓冲区设置参数
162   - long rsT = lineConfigData.applyOut(sch, gps.getTimestamp());
163   -
164   - //实发时间
165   - sch.setFcsjActualAll(rsT);
166   - sch.setSiginCompate(1);
167   - //通知客户端
168   - sendUtils.sendFcsj(sch);
169   - //持久化
170   - dayOfSchedule.save(sch);
171   -
172   - //清理应发未发标记
173   - LateAdjustHandle.remove(sch);
174   -
175   - if(!gps.isService()){
176   - //切换成营运状态
177   - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 0, "发车@系统");
178   - }
179   - //出站既出场
180   - outStationAndOutPark(sch);
181   - logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
182   - }
183   - else if(isOutSch(sch)){
184   - //有出场动作(起点站覆盖停车场时,并且不设置出站既出场,逻辑可能会走到这里)
185   - try{
186   - if(isOutPark(gps, prev)){
187   - if(prev.getCarparkNo().equals(sch.getQdzCode())){
188   - //再试一下出场
189   - GpsEntity prevClone = (GpsEntity) prev.clone(),
190   - gpsClone = (GpsEntity) gps.clone();
191   - prevClone.setStopNo(prevClone.getCarparkNo());
192   - gpsClone.setInstation(0);
193   - outStation(gpsClone, prevClone);
194   - return;
195   - }
196   - }
197   - }catch (Exception e){logger.error("",e);}
198   -
199   - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
200   - //如果下一个班次是区间,并且是环线
201   - if(next != null && next.getBcType().equals("region")){
202   - next = dayOfSchedule.nextSame(next);
203   - if(next == null || !next.getQdzName().equals(next.getZdzName())){
204   - return;
205   - }
206   - }
207   - if(next != null && prev.getStopNo().equals(next.getQdzCode())){
208   - //发下一个班次
209   - dayOfSchedule.addExecPlan(next);
210   - outStation(gps, prev);
211   - }
212   - }
213   - //当前班次是区间
214   - else if(sch.getBcType().equals("region")){
215   - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);
216   - if(next==null || !next.getQdzName().equals(next.getZdzName())){
217   - return;
218   - }
219   - //是环线
220   - if(prev.getStopNo().equals(next.getQdzCode())){
221   - //发下一个班次
222   - dayOfSchedule.addExecPlan(next);
223   - outStation(gps, prev);
224   - }
225   - }
226   - }
227   -
228   - /**
229   - * 是否是一个更合适的发车信号
230   - * @param gps
231   - * @param sch
232   - * @return
233   - */
234   - private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) {
235   - if(StringUtils.isNotEmpty(sch.getZdsjActual()))
236   - return false;
237   -
238   - long t1 = sch.getFcsjActualTime();
239   - long t2 = gps.getTimestamp();
240   - long c = sch.getDfsjT();
241   -
242   - /*if(c - t1 > 1000 * 60 * 15 && Math.abs(t2 - c) < 1000 * 60 * 5){
243   - return true;
244   - }*/
245   - int threshold = 1000 * 60 * 5;
246   - if(Math.abs(t2 - c) < threshold && c - t1 > threshold){
247   - return true;
248   - }
249   - //if(Math.abs(t2 - c) < 1000 * 60 * 5 && c - t1 > 1000 * 60 * 5)
250   - return false;
251   - }
252   -
253   -
254   - private void outStationAndOutPark(ScheduleRealInfo sch){
255   - LineConfig config = lineConfigData.get(sch.getXlBm());
256   - //限定出站既出场的停车场
257   - String park = config.getTwinsPark();
258   - boolean limitPark = StringUtils.isNotEmpty(park);
259   -
260   - if (config != null && config.getOutConfig() == 2) {
261   - //出站既出场
262   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
263   - if (schPrev != null && schPrev.getBcType().equals("out") && (schPrev.getBcsj()==0 || schPrev.getJhlcOrig().equals(0))
264   - && (!limitPark || park.equals(schPrev.getQdzCode()))) {
265   -
266   - schPrev.setFcsjActualAll(sch.getFcsjActualTime());
267   - schPrev.setZdsjActualAll(sch.getFcsjActualTime());
268   -
269   - sendUtils.refreshSch(schPrev);
270   - dayOfSchedule.save(schPrev);
271   -
272   - /*if(schPrev.getBcType().equals("out")){
273   - //出场时,切换成营运状态
274   - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(sch.getClZbh());
275   - gpsStatusManager.changeServiceState(deviceId, schPrev.getXlDir(), 0, "出场@系统");
276   - //DirectivePushQueue.put6003(schPrev.getClZbh(), 0, Integer.parseInt(schPrev.getXlDir()), "出场@系统");
277   - //directiveService.send60Operation(schPrev.getClZbh(), 0, Integer.parseInt(schPrev.getXlDir()), null, "出场@系统");
278   - }*/
279   - }
280   - }
281   - }
282   -
283   - /**
284   - * 进站
285   - * @param gps 当前点
286   - * @param prev 上一个点
287   - */
288   - private void inStation(GpsEntity gps, GpsEntity prev){
289   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
290   -
291   - if(gps.getStopNo().equals(sch.getZdzCode())
292   - && !gps.getStopNo().equals(prev.getStopNo())){
293   -
294   - int diff = 0;
295   - try{
296   - diff = (int) (sch.getZdsjT() - gps.getTimestamp());
297   - }catch(NullPointerException e){
298   - logger.info("NullPointerException " + sch.getXlName() + " 有班次无班次历时,,,检查一下是否需要出站既出场。");
299   - }
300   - //进场最多提前1.2小时
301   - if((sch.getBcType().equals("in") && diff > MAX_BEFORE_TIME) || diff > MAX_BEFORE_TIME/2)
302   - return;
303   -
304   - //正常班次最大时间差
305   - if(Math.abs(diff) > MAX_NORMAL_DIFF)
306   - return;
307   -
308   - //环线或内外圈 ,飘出去再回来
309   - if(sch.getQdzCode().equals(sch.getZdzCode())
310   - && StringUtils.isNotEmpty(sch.getFcsjActual())
311   - && gps.getTimestamp() - sch.getFcsjActualTime() < 1000 * 60 * 3){
312   - sch.clearFcsjActual();
313   - sendUtils.refreshSch(sch);
314   - return;
315   - }
316   -
317   - //实达时间不覆盖
318   - if(StringUtils.isNotEmpty(sch.getZdsjActual()))
319   - return;
320   -
321   - //应用到离站缓冲区设置参数
322   - long rsT = lineConfigData.applyIn(sch, gps.getTimestamp());
323   -
324   - sch.setZdsjActualAll(rsT);
325   - sch.setSiginCompate(2);
326   - //通知误点停靠程序,有车辆到站
327   - LateAdjustHandle.carArrive(gps);
328   -
329   - //已完成班次数
330   - int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
331   - ScheduleRealInfo next = dayOfSchedule.next(sch);
332   - //持久化
333   - dayOfSchedule.save(sch);
334   -
335   - if(next != null){
336   - dayOfSchedule.addExecPlan(next);
337   - //进站既进场
338   - inStationAndInPark(sch, next);
339   - }
340   -
341   - //该路牌的下一个班次,起点实际到达时间
342   - ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch);
343   - if(lpNext != null){
344   - lpNext.setQdzArrDatesj(sch.getZdsjActual());
345   - }
346   - else{
347   - logger.info(sch.getClZbh() + " 到终点,无下一班");
348   - }
349   -
350   - //通知客户端
351   - sendUtils.sendZdsj(sch, lpNext, doneSum);
352   - logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual());
353   - //准备执行下一个班次
354   - if (next != null) {
355   - //将gps转换为下一个班次走向的站内信号
356   - transformUpdown(gps, next);
357   - //下发调度指令
358   - DirectivePushQueue.put6002(next, doneSum, "到站@系统");
359   -
360   - //套跑 -下发线路切换指令
361   - if(!next.getXlBm().equals(sch.getXlBm())){
362   - gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "套跑@系统");
363   - }
364   - }
365   - else if(sch.getBcType().equals("in")){
366   - //进场,切换成非营运状态
367   - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, "进场@系统");
368   - }
369   - }
370   - else {
371   - /*if(sch.getFcsjActual() == null){
372   - //有进站,但班次没有实发,向前追溯一下信号
373   - scheduleSignalState.signalRetrospect(gps, sch);
374   - }
375   -*/
376   - //被起点站覆盖的情况下进场,没有设置出站既是出场,逻辑会走到这里(模拟进站信号)
377   - if(isInSch(sch)){
378   - try{
379   - if(isInPark(gps, prev)){
380   - if(gps.getCarparkNo().equals(sch.getZdzCode())){
381   - //再试一下进场
382   - GpsEntity gpsClone = (GpsEntity) gps.clone(),
383   - prevClone = (GpsEntity) prev.clone();
384   - gpsClone.setStopNo(gpsClone.getCarparkNo());
385   - prevClone.setStopNo(null);
386   - inStation(gpsClone, prevClone);
387   - return;
388   - }
389   - }
390   - }catch (Exception e){
391   - logger.error("", e);
392   - }
393   - }
394   -
395   - //如果当前班次是出场,并且进的是下一个班次的终点
396   - if(sch.getBcType().equals("out")){
397   - ScheduleRealInfo next = dayOfSchedule.next(sch);
398   - if(next != null && next.getZdzCode().equals(gps.getStopNo())){
399   - List<ScheduleRealInfo> halfList = dayOfSchedule.findByNbbm(sch.getClZbh());
400   - //和当前进站信号最匹配的一个班次
401   - ScheduleRealInfo nearSch = nearScheduleByGpsIn(gps, halfList);
402   -
403   - if(nearSch != null){
404   - //直接跳到这个班次
405   - dayOfSchedule.addExecPlan(nearSch);
406   - //重新进站
407   - inStation(gps, prev);
408   - }
409   - }
410   - }
411   - }
412   - }
413   -
414   - /**
415   - * 和当前进站信号最匹配的一个班次
416   - * @param gps
417   - * @param halfList
418   - * @return
419   - */
420   - private ScheduleRealInfo nearScheduleByGpsIn(GpsEntity gps, List<ScheduleRealInfo> halfList){
421   - if(halfList == null || halfList.size() == 0)
422   - return null;
423   -
424   - //排序
425   - Collections.sort(halfList, new ScheduleComparator.FCSJ());
426   - ScheduleRealInfo near = null;// = halfList.get(0);
427   - ScheduleRealInfo sch;
428   -
429   - String stopId = gps.getStopNo();
430   - for(int i = 0; i < halfList.size(); i ++){
431   - sch = halfList.get(i);
432   - if(!sch.getZdzCode().equals(stopId))
433   - continue;
434   -
435   - if(sch.getZdsjT() < gps.getTimestamp())
436   - near = sch;
437   - else
438   - break;
439   -
440   - }
441   - return near;
442   - }
443   -
444   - /**
445   - * 进站既进场
446   - * @param sch
447   - */
448   - private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
449   - LineConfig config = lineConfigData.get(sch.getXlBm());
450   - //限定出站既出场的停车场
451   - String park = config.getTwinsPark();
452   - boolean limitPark = StringUtils.isNotEmpty(park);
453   -
454   -
455   - if (next.getBcType().equals("in") && config.getOutConfig() == 2 && (next.getBcsj()==0 || next.getJhlcOrig().equals(0))
456   - && (!limitPark || park.equals(next.getZdzCode()))) {
457   -
458   - next.setFcsjActualAll(sch.getZdsjActualTime());
459   - next.setZdsjActualAll(sch.getZdsjActualTime());
460   -
461   - sendUtils.refreshSch(next);
462   - dayOfSchedule.save(next);
463   -
464   - //分班的时候,需要再跳过1个班次
465   - next = dayOfSchedule.next(next);
466   - if(next != null)
467   - dayOfSchedule.addExecPlan(next);
468   -
469   - //进场,切换成非营运状态
470   - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, "进场@系统");
471   - }
472   - }
473   -
474   - /**
475   - * 发车漂移判定(这里出现的误判,由车辆到达中途站的时候补偿)
476   - * @param gps
477   - * @param prev
478   - * @param task
479   - * @return
480   - */
481   - private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){
482   -
483   - /*ScheduleRealInfo sch = (ScheduleRealInfo) task;
484   - ScheduleRealInfo prevTask = dayOfSchedule.prev(sch);
485   - if(prevTask == null || prevTask.getBcType().equals("out"))
486   - return false;
487   -
488   - //计划停站时间
489   - int stopTimePlan = (int) (sch.getDfsjT() - prevTask.getZdsjT());
490   -
491   - if(stopTimePlan < 1000 * 60 * 10)
492   - return false;
493   -
494   - //实际停站时间
495   - if(prevTask.getZdsjActual() != null){
496   - int actualTime = (int) (gps.getTimestamp() - prevTask.getZdsjActualTime());
497   -
498   - if(actualTime < stopTimePlan * 0.8){
499   - logger.info("漂移判定");
500   -
501   - return true;
502   - }
503   - }*/
504   - return false;
505   - }
506   -
507   - private boolean isOutPark(GpsEntity gps, GpsEntity prve){
508   - if(StringUtils.isNotEmpty(prve.getCarparkNo()) && StringUtils.isEmpty(gps.getCarparkNo()))
509   - return true;
510   - return false;
511   - }
512   -
513   - private boolean isInPark(GpsEntity gps, GpsEntity prve){
514   - if(StringUtils.isNotEmpty(gps.getCarparkNo()) && StringUtils.isEmpty(prve.getCarparkNo()))
515   - return true;
516   - return false;
517   - }
518   -
519   - private boolean isOutSch(ScheduleRealInfo sch){
520   - return sch.getBcType().equals("out") || GeoCacheData.tccMap.keySet().contains(sch.getQdzCode());
521   - }
522   -
523   - private boolean isInSch(ScheduleRealInfo sch){
524   - return sch.getBcType().equals("in") || GeoCacheData.tccMap.keySet().contains(sch.getZdzCode());
525   - }
526   -}
527 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.SignalHandle;
6   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
7   -import org.springframework.stereotype.Component;
8   -
9   -/**
10   - * 信号断线重连处理
11   - * Created by panzhao on 2016/12/27.
12   - */
13   -@Component
14   -public class OfflineSignalHandle extends SignalHandle{
15   -
16   - //断开4分钟,标记为重连信号
17   - private final static int OFFLINE_TIME = 1000 * 60 * 4;
18   -
19   - //断开70分钟,之前的信号不再有参考价值
20   - private final static int CLEAR_TIME = 1000 * 60 * 70;
21   -
22   - @Override
23   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
24   - //掉线信号不管
25   - if(isGpsOffline(gps)){
26   - gps.setSignalState("gps-offline");
27   - gps.setAbnormalStatus("gps-offline");
28   - return true;
29   - }
30   -
31   - if(isNotEmpty(prevs)){
32   - GpsEntity prev = prevs.getTail();
33   - //间隔太大就丢弃,不管之前还是之后
34   - int space = Math.abs((int) (gps.getTimestamp() - prev.getTimestamp()));
35   - if(space > OFFLINE_TIME)
36   - gps.setSignalState("reconnection");
37   -
38   - if(space > CLEAR_TIME){
39   - //清理缓存的信号
40   - GeoCacheData.clear(gps.getNbbm());
41   - }
42   - }
43   - return true;
44   - }
45   -}
46 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.SignalHandle;
6   -import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
7   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
8   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
9   -import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
10   -import com.bsth.data.schedule.DayOfSchedule;
11   -import org.slf4j.Logger;
12   -import org.slf4j.LoggerFactory;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.stereotype.Component;
15   -
16   -/**
17   - * 路由反向信号处理
18   - * Created by panzhao on 2016/12/28.
19   - */
20   -@Component
21   -public class ReverseSignalHandle extends SignalHandle {
22   -
23   - Logger logger = LoggerFactory.getLogger(this.getClass());
24   -
25   - @Autowired
26   - DayOfSchedule dayOfSchedule;
27   -
28   - @Autowired
29   - ScheduleSignalState scheduleSignalState;
30   -
31   - @Override
32   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
33   - if (!isNotEmpty(prevs))
34   - return false;
35   -
36   - GpsEntity prev = prevs.getTail();
37   -
38   - if (isReverse(gps, prev)) {
39   - RouteReverse reverse = reverseSearch(prevs, gps);
40   -
41   - if (reverse != null && reverse.getCount() >= 3
42   - && reverse.isClose()
43   - && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) {
44   - scheduleSignalState.reverseAnalyse(reverse);
45   - }
46   - }
47   - return false;
48   - }
49   -
50   - /**
51   - * 搜索路由反向详细
52   - *
53   - * @param prevs
54   - * @param gps
55   - * @return
56   - */
57   - public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) {
58   - RouteReverse routeReverse = new RouteReverse();
59   - int count = 0;
60   - String path = "";
61   - long zt = 0L;
62   - boolean half = false;
63   -
64   - //当前站点
65   - StationRoute curr = GeoCacheData.getRouteCode(gps), sr;
66   - GpsEntity prev;
67   - Object[] array = prevs.getQueue();
68   - for (int i = array.length - 1; i > 0; i--) {
69   - prev = (GpsEntity) array[i];
70   -
71   - if (!prev.getUpDown().equals(gps.getUpDown())
72   - || prev.getSignalState().equals("reconnection"))
73   - break;
74   -
75   - if (prev.getInstation() == 1) {
76   - sr = GeoCacheData.getRouteCode(prev);
77   - if(sr == null)
78   - return null;
79   -
80   - if (sr.getRouteSort() > curr.getRouteSort()) {
81   - if(half){
82   - routeReverse.setVague(true);
83   - }
84   -
85   - path += (curr.getCode() + ",");
86   - count++;
87   - zt = prev.getTimestamp();
88   - } else if (sr.getRouteSort() < curr.getRouteSort()) {
89   - if (routeReverse.getTurned() == null) {
90   - routeReverse.setTurned(curr.getCode());
91   - half = true;
92   - }
93   -
94   - path += (curr.getCode() + ",");
95   - //掉头前当前站
96   - if (sr.getCode().equals(gps.getStopNo())) {
97   - routeReverse.setClose(true);
98   - path += sr.getCode();
99   - break;
100   - }
101   - }
102   -
103   - curr = sr;
104   - }
105   - }
106   -
107   - routeReverse.setZt(zt);
108   - routeReverse.setCount(count);
109   - routeReverse.setDetail(path);
110   - routeReverse.setCt(gps.getTimestamp());
111   - routeReverse.setNbbm(gps.getNbbm());
112   - return routeReverse;
113   - }
114   -
115   - /**
116   - * 是否反向
117   - *
118   - * @param gps
119   - * @param prev
120   - * @return
121   - */
122   - public boolean isReverse(GpsEntity gps, GpsEntity prev) {
123   - if (gps.getInstation() == 1
124   - &&
125   - gps.getUpDown().equals(prev.getUpDown())
126   - && !gps.getStopNo().equals(prev.getStopNo())) {
127   -
128   - StationRoute currStation = GeoCacheData.getRouteCode(gps);
129   - StationRoute prevStation = GeoCacheData.getRouteCode(prev);
130   -
131   - if (currStation == null || prevStation == null)
132   - return false;
133   -
134   - if (currStation.getRouteSort() < prevStation.getRouteSort())
135   - return true;
136   - }
137   - return false;
138   - }
139   -}
140 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.utils;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
6   -import com.vividsolutions.jts.geom.Coordinate;
7   -import com.vividsolutions.jts.geom.GeometryFactory;
8   -import com.vividsolutions.jts.geom.LineString;
9   -import com.vividsolutions.jts.geom.Point;
10   -
11   -import java.util.List;
12   -import java.util.Map;
13   -import java.util.Set;
14   -
15   -/**
16   - * Created by panzhao on 2016/12/23.
17   - */
18   -public class GeoUtils {
19   -
20   - private final static double EARTHRADIUS = 6378137;
21   -
22   - private static GeometryFactory geometryFactory = new GeometryFactory();
23   - /**
24   - * gps是否在路由上的某个站内
25   - *
26   - * @param gps
27   - * @param srs
28   - * @return
29   - */
30   - public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) {
31   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
32   - double min = -1, distance;
33   - StationRoute stationRoute = null;
34   -
35   - for (StationRoute sr : srs) {
36   - if (sr.getPolygon() == null) {
37   - //圆形
38   - distance = getDistance(sr.getPoint(), point);//sr.getPoint().distance(point);
39   -
40   - if (distance > sr.getRadius())
41   - continue;
42   -
43   - if (min > distance || min == -1) {
44   - min = distance;
45   - stationRoute = sr;
46   - }
47   - } else {
48   - //多边形
49   - /*if (sr.getPolygon().contains(point)) {
50   - stationRoute = sr;
51   - break;
52   - }*/
53   - com.bsth.util.Geo.Polygon polygon2 = GeoCacheData.convertPolygon(sr.getPolygon());
54   - com.bsth.util.Geo.Point point2 = new com.bsth.util.Geo.Point(gps.getLon(), gps.getLat());
55   - if(com.bsth.util.Geo.GeoUtils.isPointInPolygon(point2, polygon2)){
56   - stationRoute = sr;
57   - break;
58   - }
59   - }
60   - }
61   - return stationRoute;
62   - }
63   -
64   - public static double getDistance(Point p1, Point p2) {
65   - double lng1 = getLoop(p1.getY(), -180, 180), lat1 = getRange(
66   - p1.getX(), -74, 74);
67   - double lng2 = getLoop(p2.getY(), -180, 180), lat2 = getRange(
68   - p2.getX(), -74, 74);
69   -
70   - double x1, x2, y1, y2;
71   - x1 = degreeToRad(lng1);
72   - y1 = degreeToRad(lat1);
73   - x2 = degreeToRad(lng2);
74   - y2 = degreeToRad(lat2);
75   - return EARTHRADIUS
76   - * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1)
77   - * Math.cos(y2) * Math.cos(x2 - x1)));
78   - }
79   -
80   - private static double getLoop(double v, double a, double b) {
81   - while (v > b) {
82   - v -= b - a;
83   - }
84   - while (v < a) {
85   - v += b - a;
86   - }
87   - return v;
88   - }
89   -
90   - private static double getRange(double v, double a, double b) {
91   - v = Math.min(Math.max(v, a), b);
92   - return v;
93   - }
94   -
95   - private static double degreeToRad(double degree) {
96   - return Math.PI * degree / 180;
97   - }
98   -
99   - /**
100   - * 计算点 到 线的距离
101   - * @param line
102   - * @param p
103   - * @return
104   - */
105   - public static double getDistanceFromLine(LineString line, Point p){
106   - Point s = line.getStartPoint();
107   - Point e = line.getEndPoint();
108   - return getDistanceFromLine(s, e, p);
109   - }
110   -
111   - public static double getDistanceFromLine(Point s, Point e, Point p){
112   - double d1 = getDistance(s, p);
113   - double d2 = getDistance(p, e);
114   - double d3 = getDistance(s, e);
115   - double distance = 0;
116   -
117   - double alpha = Math.acos((d1*d1 + d3*d3 - d2*d2)/(2*d1*d3));
118   - double beta = Math.acos((d2*d2 + d3*d3 - d1*d1)/(2*d2*d3));
119   -
120   - if(alpha>Math.PI/2) {
121   - distance = d1;
122   - }
123   - else if(beta > Math.PI/2) {
124   - distance = d2;
125   - }
126   - else {
127   - distance = Math.sin(alpha) * d1;
128   - }
129   - return distance;
130   - }
131   -
132   -
133   - /**
134   - * gps 是否在某个停车场内
135   - * @param gps
136   - * @return
137   - public static String gpsInCarpark(GpsEntity gps){
138   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
139   -
140   - Map<String, Polygon> carparkMap = GeoCacheData.tccMap;
141   - Set<String> codes = carparkMap.keySet();
142   - Polygon polygon;
143   - for(String code : codes){
144   - polygon = carparkMap.get(code);
145   - if(point.within(polygon)){
146   - return code;
147   - }
148   - }
149   - return null;
150   - }*/
151   -
152   - /**
153   - * gps 是否在某个停车场内
154   - * @param gps
155   - * @return
156   - */
157   - public static String gpsInCarpark(GpsEntity gps){
158   - com.bsth.util.Geo.Point point = new com.bsth.util.Geo.Point(gps.getLon(), gps.getLat());
159   - Map<String, com.bsth.util.Geo.Polygon> carparkMap = GeoCacheData.tccMap2;
160   - com.bsth.util.Geo.Polygon polygon;
161   - Set<String> codes = carparkMap.keySet();
162   - for(String code : codes){
163   - polygon = carparkMap.get(code);
164   - if(com.bsth.util.Geo.GeoUtils.isPointInPolygon(point, polygon)){
165   - return code;
166   - }
167   - }
168   - return null;
169   - }
170   -
171   - /**
172   - * 是否是有效的连续点
173   - * @param prevGps
174   - * @param gps
175   - * @return
176   - */
177   - public static boolean overdue(GpsEntity prevGps, GpsEntity gps) {
178   - return gps.getTimestamp() - prevGps.getTimestamp() < 120000;
179   - }
180   -
181   - /**
182   - * 计算2条直线的最短距离
183   - * @param p1
184   - * @param p2
185   - * @param p3
186   - * @param p4
187   - * @return
188   - */
189   - public static double getDistanceLineToLine(Point p1, Point p2, Point p3, Point p4){
190   - double distance;
191   - double x1 = p1.getX(); //A点坐标(x1,y1,z1)
192   - double y1 = p1.getY();
193   - double z1 = 0;
194   - double x2 = p2.getX(); //B点坐标(x2,y2,z2)
195   - double y2 = p2.getY();
196   - double z2 = 0;
197   - double x3 = p3.getX(); //C点坐标(x3,y3,z3)
198   - double y3 = p3.getY();
199   - double z3 = 0;
200   - double x4 = p4.getX(); //D点坐标(x4,y4,z4)
201   - double y4 = p4.getY();
202   - double z4 = 0;
203   -
204   - double a = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1);
205   - double b = -((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3)+(z2-z1)*(z4-z3));
206   - double c = -((x1-x2)*(x1-x3)+(y1-y2)*(y1-y3)+(z1-z2)*(z1-z3));
207   -
208   - double d = -((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3)+(z2-z1)*(z4-z3));
209   - double e = (x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)+(z4-z3)*(z4-z3);
210   - double f = -((x1-x3)*(x4-x3)+(y1-y3)*(y4-y3)+(z1-z3)*(z4-z3));
211   -
212   - //平行
213   - if ((a*e-b*d)==0&&(b*d-a*e)==0)
214   - {
215   - double d1 = getDistance(p1, p3);
216   - double d2 = getDistance(p1, p4);
217   - distance = (d1<d2)?d1:d2;
218   - return distance;
219   - }
220   -
221   - double s = (b*f-e*c)/(a*e-b*d);
222   - double t = (a*f-d*c)/(b*d-a*e);
223   -
224   - //说明P点落在线段AB上,Q点落在线段CD上
225   - if(0<=s&&s<=1&&0<=t&&t<=1)
226   - {
227   - //2条线段的公垂线段PQ;
228   - //P点坐标
229   - double X = x1+s*(x2-x1);
230   - double Y = y1+s*(y2-y1);
231   - double Z = z1+s*(z2-z1);
232   - //Q点坐标
233   - double U = x3+t*(x4-x3);
234   - double V = y3+t*(y4-y3);
235   - double W = z3+t*(z4-z3);
236   - Point p = geometryFactory.createPoint(new Coordinate(X, Y, Z));
237   - Point q = geometryFactory.createPoint(new Coordinate(U, V, W));
238   - distance = getDistance(p, q);
239   - }
240   - else
241   - {
242   - double d1 = getDistanceFromLine(p3,p4,p1);
243   - double d2 = getDistanceFromLine(p3,p4,p2);
244   - double d3 = getDistanceFromLine(p1,p2,p3);
245   - double d4 = getDistanceFromLine(p1,p2,p4);
246   - distance = (d1<d2)?d1:d2;
247   - distance = (distance<d3)?distance:d3;
248   - distance = (distance<d4)?distance:d4;
249   - }
250   -
251   - return distance;
252   - }
253   -
254   - /**
255   - * 计算点 到 线的垂直交点
256   - * @param lp1
257   - * @param lp2
258   - * @param p
259   - * @return
260   - */
261   - public static Point perpendularPoint(Point lp1, Point lp2, Point p){
262   - double a = lp1.getX() - lp2.getX(), b = lp2.getY() - lp1.getY(), c = lp1.getY() * lp2.getX() - lp2.getY() * lp1.getX();
263   - double lon = (Math.pow(b, 2) * p.getY() - a * b * p.getX() - a * c) / (Math.pow(a, 2) + Math.pow(b, 2));
264   - double lat = (Math.pow(a, 2) * p.getX() - a * b * p.getY() - b * c) / (Math.pow(a, 2) + Math.pow(b, 2));
265   -
266   - return geometryFactory.createPoint(new Coordinate(lat, lon));
267   - }
268   -}
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.arrival.utils;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.SignalStateData;
6   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
7   -import com.bsth.data.gpsdata.arrival.entity.RouteReverse;
8   -import com.bsth.data.gpsdata.arrival.entity.SignalAbnormal;
9   -import com.bsth.data.gpsdata.arrival.entity.SignalState;
10   -import com.bsth.data.schedule.DayOfSchedule;
11   -import com.bsth.entity.realcontrol.LineConfig;
12   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
13   -import org.slf4j.Logger;
14   -import org.slf4j.LoggerFactory;
15   -import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.stereotype.Component;
17   -
18   -/**
19   - * 班次信号状态分析
20   - * Created by panzhao on 2016/12/29.
21   - */
22   -@Component
23   -public class ScheduleSignalState {
24   -
25   - @Autowired
26   - DayOfSchedule dayOfSchedule;
27   -
28   - Logger logger = LoggerFactory.getLogger(this.getClass());
29   -
30   - @Autowired
31   - LineConfigData lineConfigData;
32   -
33   - @Autowired
34   - SignalStateData signalStateData;
35   -
36   - /**
37   - * 路由反向分析
38   - */
39   - public void reverseAnalyse(RouteReverse reverse) {
40   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(reverse.getNbbm());
41   -
42   - String bcType = sch.getBcType();
43   -
44   - switch (bcType) {
45   - case "out":
46   - outReverseAnalyse(sch, reverse);
47   - break;
48   - case "normal":
49   - normalReverseAnalyse(sch, reverse);
50   - break;
51   - }
52   - }
53   -
54   - /**
55   - * 出场班次路由反向分析
56   - *
57   - * @param sch
58   - */
59   - private void outReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
60   - long t = reverse.getCt();
61   - //出场班次终点时间前,允许反向轨迹
62   - if (sch.getZdsjT() != null && sch.getZdsjT() > t) {
63   - return;
64   - }
65   -
66   - int rt;
67   - //从实发 到 当前时间 < 计划运送时间 * 0.9
68   - if (sch.getFcsjActual() != null && sch.getBcsj() != null) {
69   - rt = (int) (t - sch.getFcsjActualTime());
70   - if (rt < sch.getBcsj() * 0.9)
71   - return;
72   - }
73   -
74   - ScheduleRealInfo next = dayOfSchedule.next(sch);
75   - if (next != null && next.getXlDir().equals(sch.getXlDir()))
76   - return;
77   -
78   - if(next == null)
79   - return;
80   - //时间足够下一个班次待发时间运行到当前站
81   - int runTime = reverse.getCount() * 1500 * 60;
82   - if (next.getDfsjT() + runTime < t) {
83   - //跳到下一个班次
84   - dayOfSchedule.addExecPlan(next);
85   - }
86   - }
87   -
88   - /**
89   - * 正常班次路由反向分析
90   - *
91   - * @param sch
92   - * @param reverse
93   - */
94   - private void normalReverseAnalyse(ScheduleRealInfo sch, RouteReverse reverse) {
95   - LineConfig conf = lineConfigData.get(sch.getXlBm());
96   -
97   - if (conf.isReadReverse()) {
98   - //跳下一个班次
99   - ScheduleRealInfo next = dayOfSchedule.next(sch);
100   - if (next != null)
101   - dayOfSchedule.addExecPlan(next);
102   -
103   - //记录信号状态
104   - SignalState signalState = SignalState.reverseSignalSTate(sch, reverse);
105   - if(signalState != null)
106   - signalStateData.put(signalState);
107   - }
108   - }
109   -
110   - public void signalRetrospect(GpsEntity gps) {
111   - signalRetrospect(gps, dayOfSchedule.executeCurr(gps.getNbbm()));
112   - }
113   -
114   - /**
115   - * 信号追溯
116   - *
117   - * @param gps
118   - * @param sch
119   - */
120   - public void signalRetrospect(GpsEntity gps, ScheduleRealInfo sch) {
121   - //回放数据,是否有掉线或者漂移
122   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
123   - if (queue == null || queue.size() == 0 /*|| gps.getInstation() == 0*/)
124   - return;
125   -
126   - //起始时间点
127   - long st = 0;
128   - ScheduleRealInfo prev = dayOfSchedule.prev(sch);
129   -
130   - if (prev != null) {
131   - if (prev.getZdsjActual() != null)
132   - st = prev.getZdsjActualTime();
133   - else
134   - st = (GeoCacheData.midwayStation(gps.getLineId(), gps.getUpDown(), sch.getQdzCode(), gps.getStopNo()).size() + 1) * (1000 * 60 * 5);
135   - }
136   -
137   - Object[] tempArray = queue.getQueue();
138   - int len = tempArray.length;
139   -
140   - Object[] array = new Object[len + 1];
141   - System.arraycopy(tempArray, 0, array, 0, len);
142   - array[len] = gps;
143   -
144   - String gpsState = "";
145   - GpsEntity tempGps, nearGps = null;
146   - int i = len - 1;
147   - for (; i >= 0; i--) {
148   - tempGps = (GpsEntity) array[i];
149   -
150   - gpsState = tempGps.getSignalState();
151   - if (gpsState.equals("truncation"))
152   - break;
153   - else if (gpsState.equals("drift")) {
154   - nearGps = (GpsEntity) array[i + 1];
155   - break;
156   - } else if (gpsState.equals("reconnection")) {
157   - nearGps = tempGps;
158   - break;
159   - }
160   -
161   - if (tempGps.getTimestamp() < st)
162   - break;
163   - }
164   -
165   - if (nearGps != null && i > 0) {
166   - createSignalAbnormal(gpsState, nearGps, i, array, sch);
167   - }
168   - }
169   -
170   - private void createSignalAbnormal(String gpsState, GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
171   - switch (gpsState) {
172   - case "drift":
173   - driftSignalAbnormal(nearGps, i, array, sch);
174   - break;
175   - case "reconnection":
176   - offlineSignalAbnormal(nearGps, ((GpsEntity) array[i - 1]), sch);
177   - break;
178   - }
179   - }
180   -
181   - /**
182   - * 掉线异常状态记录
183   - *
184   - * @param e
185   - * @param s
186   - */
187   - private void offlineSignalAbnormal(GpsEntity e, GpsEntity s, ScheduleRealInfo sch) {
188   - long st = s.getTimestamp(), et = e.getTimestamp();
189   -
190   - //掉线超过10分钟才记录
191   - if (et - st < (1000 * 60 * 10))
192   - return;
193   -
194   - SignalAbnormal signalAbnormal = new SignalAbnormal();
195   - signalAbnormal.setSt(st);
196   - signalAbnormal.setEt(et);
197   - signalAbnormal.setAbnormalType("reconnection");
198   - signalAbnormal.setDestCode(sch.getQdzCode());
199   - signalAbnormal.setOutOrIn(0);
200   -
201   - //截断GPS
202   - e.setSignalState("truncation");
203   -
204   - //记录信号状态
205   - SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
206   - signalStateData.put(signalState);
207   - }
208   -
209   - /**
210   - * 漂移异常状态记录
211   - *
212   - * @param nearGps
213   - * @param i
214   - * @param array
215   - */
216   - private void driftSignalAbnormal(GpsEntity nearGps, int i, Object[] array, ScheduleRealInfo sch) {
217   - GpsEntity gps, s = null;
218   - //找到漂移开始时间
219   - for (; i >= 0; i--) {
220   - gps = (GpsEntity) array[i];
221   -
222   - if (!gps.getSignalState().equals("drift") || i == 0
223   - || gps.getSignalState().equals("truncation")) {
224   - s = gps;
225   - break;
226   - }
227   - }
228   -
229   - long st = s.getTimestamp(), et = nearGps.getTimestamp();
230   - if (et - st < (1000 * 60 * 3))
231   - return;
232   - /*if (s != null){
233   - st = s.getTimestamp();
234   - //漂移小于3分钟
235   - if(et - st < (1000 * 60 * 3))
236   - return;
237   - }*/
238   -
239   -
240   - SignalAbnormal signalAbnormal = new SignalAbnormal();
241   - signalAbnormal.setSt(st);
242   - signalAbnormal.setEt(et);
243   - signalAbnormal.setAbnormalType("drift");
244   - signalAbnormal.setDestCode(sch.getQdzCode());
245   - signalAbnormal.setOutOrIn(0);
246   -
247   - //截断GPS
248   - nearGps.setSignalState("truncation");
249   -
250   - //记录信号状态
251   - SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal);
252   - signalStateData.put(signalState);
253   - }
254   -}
255 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.thread;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5   -import com.bsth.data.BasicData;
6   -import com.bsth.data.gpsdata.GpsEntity;
7   -import com.bsth.data.gpsdata.GpsRealData;
8   -import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
9   -import com.bsth.util.ConfigUtil;
10   -import org.apache.commons.lang3.StringUtils;
11   -import org.apache.http.HttpEntity;
12   -import org.apache.http.client.config.RequestConfig;
13   -import org.apache.http.client.methods.CloseableHttpResponse;
14   -import org.apache.http.client.methods.HttpGet;
15   -import org.apache.http.impl.client.CloseableHttpClient;
16   -import org.apache.http.impl.client.HttpClients;
17   -import org.slf4j.Logger;
18   -import org.slf4j.LoggerFactory;
19   -import org.springframework.beans.factory.annotation.Autowired;
20   -import org.springframework.stereotype.Component;
21   -
22   -import java.io.BufferedReader;
23   -import java.io.InputStreamReader;
24   -import java.util.ArrayList;
25   -import java.util.List;
26   -
27   -/**
28   - * Created by panzhao on 2017/1/11.
29   - */
30   -@Component
31   -public class GpsDataLoaderThread extends Thread {
32   -
33   - Logger logger = LoggerFactory.getLogger(GpsDataLoaderThread.class);
34   -
35   - /**
36   - * 构造函数
37   - */
38   - public GpsDataLoaderThread() {
39   - url = ConfigUtil.get("http.gps.real.url");
40   - clientUrl = ConfigUtil.get("http.gps.real.cache.url");
41   - }
42   -
43   - // 网关数据接口地址
44   - private static String url;
45   - // GPS客户端内存数据接口
46   - private static String clientUrl;
47   -
48   - //0:从GPS客户端内存获取 -1:从网关获取
49   - private static int flag = 0;
50   -
51   - public static void setFlag(int v){
52   - flag = v;
53   - }
54   -
55   - public static int getFlag(int v){
56   - return flag;
57   - }
58   -
59   - @Autowired
60   - GpsRealData gpsRealData;
61   -
62   - @Autowired
63   - GpsRealAnalyse gpsRealAnalyse;
64   -
65   - @Override
66   - public void run() {
67   - try {
68   - if(flag == 0)
69   - load();
70   - else
71   - loadByGateway();
72   - } catch (Exception e) {
73   - logger.error("", e);
74   - }
75   - }
76   -
77   - /**
78   - * 从网关获取实时GPS数据
79   - * @throws Exception
80   - */
81   - public void loadByGateway() throws Exception {
82   - List<GpsEntity> list = null;
83   - List<GpsEntity> updateList = new ArrayList<>();
84   - CloseableHttpClient httpClient = null;
85   - CloseableHttpResponse response = null;
86   - try {
87   - httpClient = HttpClients.createDefault();
88   - HttpGet get = new HttpGet(url);
89   - //超时时间
90   - RequestConfig requestConfig = RequestConfig.custom()
91   - .setConnectTimeout(1500).setConnectionRequestTimeout(1000)
92   - .setSocketTimeout(1500).build();
93   - get.setConfig(requestConfig);
94   -
95   - response = httpClient.execute(get);
96   -
97   - HttpEntity entity = response.getEntity();
98   - if (null != entity) {
99   - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
100   - StringBuilder stringBuffer = new StringBuilder();
101   - String str = "";
102   - while ((str = br.readLine()) != null)
103   - stringBuffer.append(str);
104   -
105   - JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
106   -
107   - if (jsonObj != null)
108   - list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
109   -
110   - String nbbm;
111   - GpsEntity old;
112   - for (GpsEntity gps : list) {
113   -
114   - //没有设备号
115   - if (StringUtils.isBlank(gps.getDeviceId()))
116   - continue;
117   -
118   - old = gpsRealData.get(gps.getDeviceId());
119   - if (old != null &&
120   - old.getTimestamp().equals(gps.getTimestamp()) &&
121   - old.getLat().equals(gps.getLat()) &&
122   - old.getLon().equals(gps.getLon()))
123   - continue;
124   -
125   - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
126   - if (StringUtils.isBlank(nbbm))
127   - gps.setIncomplete(true);//标记为异常数据
128   - else
129   - gps.setNbbm(nbbm);
130   - //有更新的点位
131   - updateList.add(gps);
132   - }
133   - logger.info("全量点:"+ list.size() +",更新点" + updateList.size());
134   - //分析数据
135   - gpsRealAnalyse.analyse(updateList);
136   - } else
137   - logger.error("real gps result is null");
138   - } catch (Exception e) {
139   - logger.error("", e);
140   - } finally {
141   - if (null != httpClient)
142   - httpClient.close();
143   - if (null != response)
144   - response.close();
145   - }
146   - }
147   -
148   - /**
149   - * 从客户端内存获取GPS数据
150   - */
151   - public void load() throws Exception{
152   - List<GpsEntity> list = null;
153   - CloseableHttpClient httpClient = null;
154   - CloseableHttpResponse response = null;
155   -
156   - try {
157   - logger.info("load start...");
158   - httpClient = HttpClients.createDefault();
159   - HttpGet get = new HttpGet(clientUrl);
160   - //超时时间
161   - RequestConfig requestConfig = RequestConfig.custom()
162   - .setConnectTimeout(2000).setConnectionRequestTimeout(1000)
163   - .setSocketTimeout(3000).build();
164   - get.setConfig(requestConfig);
165   -
166   - response = httpClient.execute(get);
167   -
168   - HttpEntity entity = response.getEntity();
169   - if (null != entity) {
170   - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
171   - StringBuilder stringBuffer = new StringBuilder();
172   - String str = "";
173   - while ((str = br.readLine()) != null)
174   - stringBuffer.append(str);
175   -
176   - list = JSON.parseArray(stringBuffer.toString(), GpsEntity.class);
177   - String nbbm;
178   - logger.info("load end!");
179   - for (GpsEntity gps : list) {
180   -
181   - //没有设备号
182   - if (StringUtils.isBlank(gps.getDeviceId()))
183   - continue;
184   -
185   - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
186   - if (StringUtils.isBlank(nbbm))
187   - gps.setIncomplete(true);//标记为异常数据
188   - else
189   - gps.setNbbm(nbbm);
190   - }
191   - //分析数据
192   - gpsRealAnalyse.analyse(list);
193   - } else
194   - logger.error("client gps result is null");
195   - } catch (Exception e) {
196   - logger.error("", e);
197   - } finally {
198   - if (null != httpClient)
199   - httpClient.close();
200   - if (null != response)
201   - response.close();
202   - }
203   - }
204   -}
205 0 \ No newline at end of file