Commit 26ba4515c54c50a86ce2e2b2a81b3d27cc1b8d38

Authored by 徐烜
2 parents 7ae37be1 5ea684d3

Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang

Showing 41 changed files with 1903 additions and 662 deletions

Too many changes to show.

To preserve performance only 41 of 136 files are displayed.

src/main/java/com/bsth/controller/directive/DirectiveController.java
@@ -173,15 +173,10 @@ public class DirectiveController { @@ -173,15 +173,10 @@ public class DirectiveController {
173 } 173 }
174 174
175 @RequestMapping(value = "/c0a4", method = RequestMethod.POST) 175 @RequestMapping(value = "/c0a4", method = RequestMethod.POST)
176 - public int c0a4(@RequestParam String nbbm){ 176 + public Map<String, Object> c0a4(@RequestParam String nbbm){
177 return directiveService.sendC0A4(nbbm); 177 return directiveService.sendC0A4(nbbm);
178 } 178 }
179 179
180 -// @RequestMapping(value = "/c0a3", method = RequestMethod.POST)  
181 -// public int c0a3(@RequestParam DC0_A4 c0a4){  
182 -// return directiveService.sendC0A3(c0a4);  
183 -// }  
184 -  
185 @RequestMapping(value = "/c0a3", method = RequestMethod.POST) 180 @RequestMapping(value = "/c0a3", method = RequestMethod.POST)
186 public int c0a3(String json){ 181 public int c0a3(String json){
187 json = StringEscapeUtils.unescapeHtml4(json); 182 json = StringEscapeUtils.unescapeHtml4(json);
@@ -192,7 +187,18 @@ public class DirectiveController { @@ -192,7 +187,18 @@ public class DirectiveController {
192 @RequestMapping(value = "/c0a5", method = RequestMethod.POST) 187 @RequestMapping(value = "/c0a5", method = RequestMethod.POST)
193 public int c0a5(String json){ 188 public int c0a5(String json){
194 json = StringEscapeUtils.unescapeHtml4(json); 189 json = StringEscapeUtils.unescapeHtml4(json);
195 - //DC0_A3 c0a3 = JSON.toJavaObject(JSONObject.parseObject(json), DC0_A3.class);  
196 return directiveService.sendC0A5(json); 190 return directiveService.sendC0A5(json);
197 } 191 }
  192 +
  193 + /**
  194 + * 设备参数查询
  195 + * @return
  196 + */
  197 + @RequestMapping(value = "/deviceCofigList", method = RequestMethod.GET)
  198 + public Map<String, Object> deviceCofigList(
  199 + @RequestParam Map<String, String> map,
  200 + @RequestParam(defaultValue = "0") int page,
  201 + @RequestParam(defaultValue = "10") int size){
  202 + return directiveService.deviceCofigList(map, page, size);
  203 + }
198 } 204 }
src/main/java/com/bsth/controller/directive/UpstreamEntrance.java
1 package com.bsth.controller.directive; 1 package com.bsth.controller.directive;
2 2
  3 +import org.apache.commons.lang3.StringUtils;
3 import org.slf4j.Logger; 4 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory; 5 import org.slf4j.LoggerFactory;
5 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,7 +60,8 @@ public class UpstreamEntrance { @@ -59,7 +60,8 @@ public class UpstreamEntrance {
59 case 0x26: 60 case 0x26:
60 // 驾驶员上报 61 // 驾驶员上报
61 D80 d80 = JSON.toJavaObject(jsonParam, D80.class); 62 D80 d80 = JSON.toJavaObject(jsonParam, D80.class);
62 - pilotReport.report(d80); 63 + if(d80!=null && StringUtils.isNotEmpty(d80.getDeviceId()))
  64 + pilotReport.report(d80);
63 break; 65 break;
64 66
65 case 0xA4: 67 case 0xA4:
@@ -67,9 +69,9 @@ public class UpstreamEntrance { @@ -67,9 +69,9 @@ public class UpstreamEntrance {
67 data.put("posPort", data.getString("posPort").trim()); 69 data.put("posPort", data.getString("posPort").trim());
68 data.put("posIpAddress", data.getString("posIpAddress").trim()); 70 data.put("posIpAddress", data.getString("posIpAddress").trim());
69 data.put("ipAddress", data.getString("ipAddress").trim()); 71 data.put("ipAddress", data.getString("ipAddress").trim());
70 - 72 +
71 DC0_A4 c0a4 = JSON.toJavaObject(jsonParam, DC0_A4.class); 73 DC0_A4 c0a4 = JSON.toJavaObject(jsonParam, DC0_A4.class);
72 - System.out.println(c0a4); 74 + pilotReport.report(c0a4);
73 break; 75 break;
74 } 76 }
75 77
src/main/java/com/bsth/controller/excep/SpeedingController.java
@@ -31,10 +31,8 @@ public class SpeedingController extends BaseController&lt;SysUser, Integer&gt;{ @@ -31,10 +31,8 @@ public class SpeedingController extends BaseController&lt;SysUser, Integer&gt;{
31 map.put("pageData","10"); 31 map.put("pageData","10");
32 pageObject=speedingService.Pagequery(map); 32 pageObject=speedingService.Pagequery(map);
33 return pageObject; 33 return pageObject;
34 -  
35 } 34 }
36 35
37 -  
38 @RequestMapping(value = "/getReport", method = RequestMethod.POST) 36 @RequestMapping(value = "/getReport", method = RequestMethod.POST)
39 public Map<String, Object> getReport(@RequestParam Map<String, Object> map) { 37 public Map<String, Object> getReport(@RequestParam Map<String, Object> map) {
40 Map<String, Object> modelMap = new HashMap<String, Object>(); 38 Map<String, Object> modelMap = new HashMap<String, Object>();
src/main/java/com/bsth/controller/gps/GpsController.java
@@ -8,6 +8,7 @@ import com.google.common.base.Splitter; @@ -8,6 +8,7 @@ import com.google.common.base.Splitter;
8 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.web.bind.annotation.*; 9 import org.springframework.web.bind.annotation.*;
10 10
  11 +import javax.servlet.http.HttpServletResponse;
11 import java.util.List; 12 import java.util.List;
12 import java.util.Map; 13 import java.util.Map;
13 14
@@ -110,6 +111,57 @@ public class GpsController { @@ -110,6 +111,57 @@ public class GpsController {
110 } 111 }
111 112
112 /** 113 /**
  114 + * 历史GPS查询 ,第三版轨迹回放用
  115 + * @param nbbm
  116 + * @param st
  117 + * @param et
  118 + * @return
  119 + */
  120 + @RequestMapping(value = "/history_v3/{nbbm}")
  121 + public Map<String, Object> history_v3(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){
  122 + return gpsService.history_v3(nbbm, st, et);
  123 + }
  124 +
  125 + /**
  126 + * 轨迹导出
  127 + * @param nbbm
  128 + * @param st
  129 + * @param et
  130 + * @return
  131 + */
  132 + @RequestMapping(value = "/history_v3/excel/{nbbm}")
  133 + public void trailExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  134 + gpsService.trailExcel(nbbm, st, et, resp);
  135 + }
  136 +
  137 + /**
  138 + * 轨迹异常数据导出
  139 + * @param nbbm
  140 + * @param st
  141 + * @param et
  142 + * @return
  143 + */
  144 + @RequestMapping(value = "/history_v3/excel_abnormal/{nbbm}")
  145 + public void abnormalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  146 + gpsService.abnormalExcel(nbbm, st, et, resp);
  147 + }
  148 +
  149 + /**
  150 + * 到离站数据导出
  151 + * @param nbbm
  152 + * @param st
  153 + * @param et
  154 + * @return
  155 + */
  156 + @RequestMapping(value = "/history_v3/excel_arrival/{nbbm}")
  157 + public void arrivalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  158 + gpsService.arrivalExcel(nbbm, st, et, resp);
  159 + }
  160 +
  161 +
  162 +
  163 +
  164 + /**
113 * 安全驾驶数据 分页查询 165 * 安全驾驶数据 分页查询
114 * @param map 166 * @param map
115 * @param page 167 * @param page
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
@@ -5,12 +5,15 @@ import com.alibaba.fastjson.serializer.PropertyFilter; @@ -5,12 +5,15 @@ import com.alibaba.fastjson.serializer.PropertyFilter;
5 import com.bsth.common.ResponseCode; 5 import com.bsth.common.ResponseCode;
6 import com.bsth.data.BasicData; 6 import com.bsth.data.BasicData;
7 import com.bsth.entity.Line; 7 import com.bsth.entity.Line;
  8 +import com.google.common.base.Splitter;
8 import com.google.common.collect.ArrayListMultimap; 9 import com.google.common.collect.ArrayListMultimap;
  10 +import com.google.common.collect.BiMap;
9 import org.slf4j.Logger; 11 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 12 import org.slf4j.LoggerFactory;
11 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.web.bind.annotation.RequestMapping; 14 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RequestMethod; 15 import org.springframework.web.bind.annotation.RequestMethod;
  16 +import org.springframework.web.bind.annotation.RequestParam;
14 import org.springframework.web.bind.annotation.RestController; 17 import org.springframework.web.bind.annotation.RestController;
15 18
16 import java.util.*; 19 import java.util.*;
@@ -145,4 +148,36 @@ public class BasicDataController { @@ -145,4 +148,36 @@ public class BasicDataController {
145 } 148 }
146 return listMultimap.asMap(); 149 return listMultimap.asMap();
147 } 150 }
  151 +
  152 + /**
  153 + * 获取车辆信息
  154 + * @return
  155 + */
  156 + @RequestMapping("/ccInfo/lineArray")
  157 + public List<Map<String, String>> ccInfoByLine(@RequestParam String idx){
  158 + List<String> lines = Splitter.on(",").splitToList(idx);
  159 + List<Map<String, String>> rs = new ArrayList<>();
  160 + Map<String, String> map;
  161 +
  162 + //ArrayListMultimap<String, String> listMultimap = ArrayListMultimap.create();
  163 + Set<String> ks = BasicData.nbbm2LineMap.keySet();
  164 + BiMap<String,String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse();
  165 +
  166 + Line line;
  167 + for(String nbbm : ks){
  168 + line = BasicData.nbbm2LineMap.get(nbbm);
  169 + if(lines.contains(line.getLineCode())){
  170 + map = new HashMap<>();
  171 + map.put("nbbm", nbbm);
  172 + map.put("deviceId", nbbm2deviceMap.get(nbbm));
  173 + map.put("lineName", line.getName());
  174 + map.put("lineCode", line.getLineCode());
  175 + rs.add(map);
  176 + }
  177 + //listMultimap.put(line.getName(), nbbm);
  178 + }
  179 + //return listMultimap.asMap();
  180 +
  181 + return rs;
  182 + }
148 } 183 }
src/main/java/com/bsth/controller/realcontrol/LineConfigController.java
@@ -101,4 +101,14 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{ @@ -101,4 +101,14 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{
101 //System.out.println(map); 101 //System.out.println(map);
102 return lineConfigService.yjtkSet(map); 102 return lineConfigService.yjtkSet(map);
103 } 103 }
  104 +
  105 + /**
  106 + * 修改场既是站的 停车场 和 站点
  107 + * @param map
  108 + * @return
  109 + */
  110 + @RequestMapping(value = "/parkAndStationSet", method = RequestMethod.POST)
  111 + public Map<String, Object> parkAndStationSet(@RequestParam Map<String, String> map){
  112 + return lineConfigService.parkAndStationSet(map);
  113 + }
104 } 114 }
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -294,6 +294,21 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -294,6 +294,21 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
294 return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line); 294 return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
295 } 295 }
296 296
  297 + /**
  298 + * 路单公里统计 (闵行审计专用)
  299 + * @param jGh
  300 + * @param clZbh
  301 + * @param lpName
  302 + * @param date
  303 + * @param line
  304 + * @return
  305 + */
  306 + @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)
  307 + public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  308 + ,@RequestParam String date,@RequestParam String line){
  309 + return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);
  310 + }
  311 +
297 @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET) 312 @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
298 public Map<String,Object> findKMBCQp(@RequestParam String clZbh 313 public Map<String,Object> findKMBCQp(@RequestParam String clZbh
299 ,@RequestParam String date,@RequestParam String line){ 314 ,@RequestParam String date,@RequestParam String line){
@@ -337,6 +352,20 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -337,6 +352,20 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
337 return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,line); 352 return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,line);
338 } 353 }
339 354
  355 + /**
  356 + * @Title queryListWaybill
  357 + * @Description 查询行车路单列表(闵行审计专用路单)
  358 + * @param jName 驾驶员名字
  359 + * @param clZbh 车辆自编号(内部编号)
  360 + * @param lpName 路牌
  361 + * @return
  362 + */
  363 + @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)
  364 + public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
  365 + ,@RequestParam String date,@RequestParam String line){
  366 + return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);
  367 + }
  368 +
340 @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET) 369 @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)
341 public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh, 370 public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
342 @RequestParam String date,@RequestParam String line){ 371 @RequestParam String date,@RequestParam String line){
@@ -349,6 +378,12 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -349,6 +378,12 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
349 return scheduleRealInfoService.statisticsDaily(line, date, xlName, type); 378 return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);
350 } 379 }
351 380
  381 + @RequestMapping(value="/statisticsDaily_mh_2")
  382 + public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,
  383 + @RequestParam String xlName, @RequestParam String type){
  384 + return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);
  385 + }
  386 +
352 @RequestMapping(value="/statisticsDailyTj") 387 @RequestMapping(value="/statisticsDailyTj")
353 public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){ 388 public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
354 String gsdm=""; 389 String gsdm="";
@@ -404,6 +439,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -404,6 +439,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
404 return scheduleRealInfoService.realScheduleList(line,date); 439 return scheduleRealInfoService.realScheduleList(line,date);
405 } 440 }
406 441
  442 + @RequestMapping(value="/realScheduleList_mh_2")
  443 + public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
  444 + return scheduleRealInfoService.realScheduleList_mh_2(line,date);
  445 + }
  446 +
407 @RequestMapping(value="/realScheduleListQp") 447 @RequestMapping(value="/realScheduleListQp")
408 public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){ 448 public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){
409 return scheduleRealInfoService.realScheduleListQp(line,date); 449 return scheduleRealInfoService.realScheduleListQp(line,date);
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
@@ -69,11 +69,21 @@ public class anomalyCheckController { @@ -69,11 +69,21 @@ public class anomalyCheckController {
69 DirectivePushQueue.start(); 69 DirectivePushQueue.start();
70 } 70 }
71 71
  72 + @RequestMapping(value = "/directiveQueueSize")
  73 + public void directiveQueueSize(){
  74 + DirectivePushQueue.size();
  75 + }
  76 +
72 @RequestMapping(value = "/webSocketPushQueue") 77 @RequestMapping(value = "/webSocketPushQueue")
73 public void webSocketPushQueue(){ 78 public void webSocketPushQueue(){
74 WebSocketPushQueue.start(); 79 WebSocketPushQueue.start();
75 } 80 }
76 81
  82 + @RequestMapping(value = "/webSocketQueueSize")
  83 + public void webSocketQueueSize(){
  84 + WebSocketPushQueue.size();
  85 + }
  86 +
77 @RequestMapping(value = "/setHttpFlag") 87 @RequestMapping(value = "/setHttpFlag")
78 public void setHttpFlag(@RequestParam int flag){ 88 public void setHttpFlag(@RequestParam int flag){
79 if(flag != 0 && flag != -1) 89 if(flag != 0 && flag != -1)
src/main/java/com/bsth/controller/report/ReportController.java
@@ -261,4 +261,17 @@ public class ReportController { @@ -261,4 +261,17 @@ public class ReportController {
261 return service.userList(map); 261 return service.userList(map);
262 } 262 }
263 263
  264 + @RequestMapping(value="/countLineMileage")
  265 + public List<Map<String,Object>> countLineMileage(@RequestParam Map<String, Object> map){
  266 +
  267 + return service.countByList(map);
  268 + }
  269 +
  270 + @RequestMapping(value="/countBusMileage")
  271 + public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){
  272 +
  273 + return service.countByBusList(map);
  274 + }
  275 +
  276 +
264 } 277 }
src/main/java/com/bsth/data/directive/DirectiveCreator.java
1 package com.bsth.data.directive; 1 package com.bsth.data.directive;
2 2
3 -import java.text.SimpleDateFormat;  
4 -import java.util.Date;  
5 -import java.util.HashMap;  
6 -import java.util.Map;  
7 -  
8 -import org.slf4j.Logger;  
9 -import org.slf4j.LoggerFactory;  
10 -  
11 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
12 import com.bsth.data.BasicData; 4 import com.bsth.data.BasicData;
13 import com.bsth.entity.directive.D60; 5 import com.bsth.entity.directive.D60;
14 import com.bsth.entity.directive.D60.D60Data; 6 import com.bsth.entity.directive.D60.D60Data;
15 import com.bsth.entity.directive.D64; 7 import com.bsth.entity.directive.D64;
16 import com.bsth.entity.directive.D64.D64Data; 8 import com.bsth.entity.directive.D64.D64Data;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +
  12 +import java.text.SimpleDateFormat;
  13 +import java.util.Date;
  14 +import java.util.HashMap;
  15 +import java.util.Map;
17 16
18 /** 17 /**
19 * 18 *
@@ -81,7 +80,7 @@ public class DirectiveCreator { @@ -81,7 +80,7 @@ public class DirectiveCreator {
81 } 80 }
82 81
83 82
84 - public D60 createD60_02(String nbbm, String text, int upDown, int state, Date alarmTime){ 83 + public D60 createD60_01(String nbbm, String text, int upDown, int state, Date alarmTime){
85 SimpleDateFormat sdfMMddHHmm = new SimpleDateFormat("MMddHHmm"); 84 SimpleDateFormat sdfMMddHHmm = new SimpleDateFormat("MMddHHmm");
86 85
87 Long timestamp = System.currentTimeMillis(); 86 Long timestamp = System.currentTimeMillis();
@@ -102,7 +101,7 @@ public class DirectiveCreator { @@ -102,7 +101,7 @@ public class DirectiveCreator {
102 directive.setMsgId(msgId); 101 directive.setMsgId(msgId);
103 // 构造数据 102 // 构造数据
104 data.setDeviceId(deviceId); 103 data.setDeviceId(deviceId);
105 - data.setDispatchInstruct((short) 0x02); 104 + data.setDispatchInstruct((short) 0x01);
106 data.setTimestamp(timestamp); 105 data.setTimestamp(timestamp);
107 data.setCompanyCode(company); 106 data.setCompanyCode(company);
108 data.setMsgId(msgId); 107 data.setMsgId(msgId);
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
@@ -307,4 +307,28 @@ public class GpsEntity { @@ -307,4 +307,28 @@ public class GpsEntity {
307 public void setSource(int source) { 307 public void setSource(int source) {
308 this.source = source; 308 this.source = source;
309 } 309 }
  310 +
  311 + public void offline(){
  312 + this.setAbnormalStatus("offline");
  313 + }
  314 +
  315 + public boolean isOnline(){
  316 + if(isOffline())
  317 + return false;
  318 +
  319 + long t = System.currentTimeMillis();
  320 +
  321 + if((t - this.getTimestamp()) > 1000 * 60){
  322 + return false;
  323 + }
  324 +
  325 + if((this.getTimestamp() - t) > 1000 * 60 * 3){
  326 + return false;
  327 + }
  328 + return true;
  329 + }
  330 +
  331 + public boolean isOffline(){
  332 + return this.getAbnormalStatus() != null && this.getAbnormalStatus().equals("offline");
  333 + }
310 } 334 }
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
@@ -36,6 +36,9 @@ public class GeoCacheData { @@ -36,6 +36,9 @@ public class GeoCacheData {
36 //线路路段走向 36 //线路路段走向
37 private static ArrayListMultimap<String, LineString> sectionCacheMap; 37 private static ArrayListMultimap<String, LineString> sectionCacheMap;
38 38
  39 + //路段编码和名称对照
  40 + private static Map<String, String> sectionCode2Name;
  41 +
39 //线路站点路由 42 //线路站点路由
40 private static ArrayListMultimap<String, StationRoute> stationCacheMap; 43 private static ArrayListMultimap<String, StationRoute> stationCacheMap;
41 44
@@ -44,6 +47,8 @@ public class GeoCacheData { @@ -44,6 +47,8 @@ public class GeoCacheData {
44 47
45 //停车场 48 //停车场
46 public static Map<String, Polygon> tccMap; 49 public static Map<String, Polygon> tccMap;
  50 + //停车场
  51 + public static Map<String, com.bsth.util.Geo.Polygon> tccMap2;
47 52
48 //线路限速信息 53 //线路限速信息
49 private static Map<String, Double> speedLimitMap; 54 private static Map<String, Double> speedLimitMap;
@@ -78,6 +83,10 @@ public class GeoCacheData { @@ -78,6 +83,10 @@ public class GeoCacheData {
78 } 83 }
79 } 84 }
80 85
  86 + public static Map<String, String> sectionCode2NameMap(){
  87 + return sectionCode2Name;
  88 + }
  89 +
81 public static StationRoute getRouteCode(GpsEntity gps) { 90 public static StationRoute getRouteCode(GpsEntity gps) {
82 return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo()); 91 return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
83 } 92 }
@@ -135,7 +144,7 @@ public class GeoCacheData { @@ -135,7 +144,7 @@ public class GeoCacheData {
135 } 144 }
136 145
137 private void loadRoadsData() { 146 private void loadRoadsData() {
138 - 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 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"; 147 + 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";
139 List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql); 148 List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql);
140 149
141 String polygonStr, key; 150 String polygonStr, key;
@@ -143,9 +152,22 @@ public class GeoCacheData { @@ -143,9 +152,22 @@ public class GeoCacheData {
143 int i, len; 152 int i, len;
144 153
145 ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create(); 154 ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create();
  155 + Map<String, String> sectionCode2NameTemp = new HashMap<>();
  156 +
146 Coordinate[] cds; 157 Coordinate[] cds;
147 String[] temps1, temps2; 158 String[] temps1, temps2;
  159 + String name = null, code;
148 for (Map<String, Object> tMap : secList) { 160 for (Map<String, Object> tMap : secList) {
  161 + //编码和名称对照
  162 + if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))
  163 + name = tMap.get("CROSES_ROAD").toString();
  164 + else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))
  165 + name = tMap.get("SECTION_NAME").toString();
  166 +
  167 + code = tMap.get("SECTION_CODE").toString();
  168 + sectionCode2NameTemp.put(code, name);
  169 +
  170 + //空间数据映射
149 polygonStr = tMap.get("GSECTION_VECTOR").toString(); 171 polygonStr = tMap.get("GSECTION_VECTOR").toString();
150 key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS"); 172 key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS");
151 173
@@ -166,6 +188,8 @@ public class GeoCacheData { @@ -166,6 +188,8 @@ public class GeoCacheData {
166 188
167 if(sectionCacheTempMap.size() > 0) 189 if(sectionCacheTempMap.size() > 0)
168 sectionCacheMap = sectionCacheTempMap; 190 sectionCacheMap = sectionCacheTempMap;
  191 + if(sectionCode2NameTemp.size() > 0)
  192 + sectionCode2Name = sectionCode2NameTemp;
169 } 193 }
170 194
171 private void loadTccMapData(){ 195 private void loadTccMapData(){
@@ -185,8 +209,31 @@ public class GeoCacheData { @@ -185,8 +209,31 @@ public class GeoCacheData {
185 logger.error("停车场:" + tMap.get("PARK_CODE"), e); 209 logger.error("停车场:" + tMap.get("PARK_CODE"), e);
186 } 210 }
187 } 211 }
188 - if (tccTempMap.size() > 0) 212 + if (tccTempMap.size() > 0){
189 tccMap = tccTempMap; 213 tccMap = tccTempMap;
  214 + tccMap2 = convertPolygonMap(tccMap);
  215 + }
  216 + }
  217 +
  218 + private Map<String, com.bsth.util.Geo.Polygon> convertPolygonMap(Map<String, Polygon> tccMap) {
  219 + Map<String, com.bsth.util.Geo.Polygon> rsMap = new HashMap<>();
  220 + Set<String> ks = tccMap.keySet();
  221 + for(String k : ks){
  222 + rsMap.put(k, convertPolygon(tccMap.get(k)));
  223 + }
  224 + return rsMap;
  225 + }
  226 +
  227 + public static com.bsth.util.Geo.Polygon convertPolygon(Polygon polygon) {
  228 + List<com.bsth.util.Geo.Point> ps = new ArrayList<>();
  229 + com.bsth.util.Geo.Point p;
  230 +
  231 + Coordinate[] cs = polygon.getCoordinates();
  232 + for(int i = 0; i < cs.length;i ++){
  233 + p = new com.bsth.util.Geo.Point(cs[i].y, cs[i].x);
  234 + ps.add(p);
  235 + }
  236 + return new com.bsth.util.Geo.Polygon(ps);
190 } 237 }
191 238
192 private void loadStationRoutesData(){ 239 private void loadStationRoutesData(){
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
@@ -96,9 +96,15 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -96,9 +96,15 @@ public class InOutStationSignalHandle extends SignalHandle{
96 } 96 }
97 97
98 //从站内到另一个站内 98 //从站内到另一个站内
99 - if(prev.getInstation() > 0 && gps.getInstation() > 0  
100 - && !prev.getStopNo().equals(gps.getStopNo())) 99 + if(prev.getInstation() == 1 && gps.getInstation() == 1
  100 + && !prev.getStopNo().equals(gps.getStopNo())
  101 + && !prev.getStation().getName().equals(gps.getStation().getName()))
101 return true; 102 return true;
  103 +
  104 + //从场内到站内
  105 + if(prev.getInstation() == 2 && gps.getInstation() == 1){
  106 + return true;
  107 + }
102 return false; 108 return false;
103 } 109 }
104 110
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
@@ -3,7 +3,10 @@ package com.bsth.data.gpsdata.arrival.utils; @@ -3,7 +3,10 @@ package com.bsth.data.gpsdata.arrival.utils;
3 import com.bsth.data.gpsdata.GpsEntity; 3 import com.bsth.data.gpsdata.GpsEntity;
4 import com.bsth.data.gpsdata.arrival.GeoCacheData; 4 import com.bsth.data.gpsdata.arrival.GeoCacheData;
5 import com.bsth.data.gpsdata.arrival.entity.StationRoute; 5 import com.bsth.data.gpsdata.arrival.entity.StationRoute;
6 -import com.vividsolutions.jts.geom.*; 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;
7 10
8 import java.util.List; 11 import java.util.List;
9 import java.util.Map; 12 import java.util.Map;
@@ -26,7 +29,7 @@ public class GeoUtils { @@ -26,7 +29,7 @@ public class GeoUtils {
26 */ 29 */
27 public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) { 30 public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) {
28 Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); 31 Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
29 - double min = -1, distance, distance2; 32 + double min = -1, distance;
30 StationRoute stationRoute = null; 33 StationRoute stationRoute = null;
31 34
32 for (StationRoute sr : srs) { 35 for (StationRoute sr : srs) {
@@ -43,7 +46,13 @@ public class GeoUtils { @@ -43,7 +46,13 @@ public class GeoUtils {
43 } 46 }
44 } else { 47 } else {
45 //多边形 48 //多边形
46 - if (sr.getPolygon().contains(point)) { 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)){
47 stationRoute = sr; 56 stationRoute = sr;
48 break; 57 break;
49 } 58 }
@@ -125,7 +134,6 @@ public class GeoUtils { @@ -125,7 +134,6 @@ public class GeoUtils {
125 * gps 是否在某个停车场内 134 * gps 是否在某个停车场内
126 * @param gps 135 * @param gps
127 * @return 136 * @return
128 - */  
129 public static String gpsInCarpark(GpsEntity gps){ 137 public static String gpsInCarpark(GpsEntity gps){
130 Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); 138 Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
131 139
@@ -139,6 +147,25 @@ public class GeoUtils { @@ -139,6 +147,25 @@ public class GeoUtils {
139 } 147 }
140 } 148 }
141 return null; 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;
142 } 169 }
143 170
144 /** 171 /**
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
@@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware { @@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware {
84 Calendar calendar = Calendar.getInstance(); 84 Calendar calendar = Calendar.getInstance();
85 int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); 85 int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
86 86
87 - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=143";// + dayOfYear; 87 + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=173";// + dayOfYear;
88 JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); 88 JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
89 89
90 List<GpsEntity> list = 90 List<GpsEntity> list =
src/main/java/com/bsth/data/gpsdata/thread/OfflineMonitorThread.java
@@ -45,7 +45,7 @@ public class OfflineMonitorThread extends Thread{ @@ -45,7 +45,7 @@ public class OfflineMonitorThread extends Thread{
45 continue; 45 continue;
46 46
47 if (t - gps.getTimestamp() > LOSE_TIME){ 47 if (t - gps.getTimestamp() > LOSE_TIME){
48 - gps.setAbnormalStatus("offline"); 48 + gps.offline();
49 49
50 //通知页面有设备掉线 50 //通知页面有设备掉线
51 sendUtils.deviceOffline(gps); 51 sendUtils.deviceOffline(gps);
src/main/java/com/bsth/data/msg_queue/DirectivePushQueue.java
@@ -10,7 +10,7 @@ import org.springframework.context.ApplicationContext; @@ -10,7 +10,7 @@ import org.springframework.context.ApplicationContext;
10 import org.springframework.context.ApplicationContextAware; 10 import org.springframework.context.ApplicationContextAware;
11 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
12 12
13 -import java.util.LinkedList; 13 +import java.util.concurrent.ConcurrentLinkedQueue;
14 14
15 /** 15 /**
16 * 到网关的指令推送队列 (系统发送的队列, 用户手动发送的不走这里) 16 * 到网关的指令推送队列 (系统发送的队列, 用户手动发送的不走这里)
@@ -19,14 +19,14 @@ import java.util.LinkedList; @@ -19,14 +19,14 @@ import java.util.LinkedList;
19 @Component 19 @Component
20 public class DirectivePushQueue implements CommandLineRunner, ApplicationContextAware { 20 public class DirectivePushQueue implements CommandLineRunner, ApplicationContextAware {
21 21
22 - static LinkedList<QueueData_Directive> linkedList; 22 + static ConcurrentLinkedQueue<QueueData_Directive> linkedList;
23 static DataPushThread thread; 23 static DataPushThread thread;
24 static DirectiveService directiveService; 24 static DirectiveService directiveService;
25 static long t; 25 static long t;
26 static final int IDLE_TIME = 1000 * 30; 26 static final int IDLE_TIME = 1000 * 30;
27 27
28 static { 28 static {
29 - linkedList = new LinkedList<>(); 29 + linkedList = new ConcurrentLinkedQueue<>();
30 } 30 }
31 31
32 public static void put6002(ScheduleRealInfo sch, int finish, String sender){ 32 public static void put6002(ScheduleRealInfo sch, int finish, String sender){
@@ -71,10 +71,15 @@ public class DirectivePushQueue implements CommandLineRunner, ApplicationContext @@ -71,10 +71,15 @@ public class DirectivePushQueue implements CommandLineRunner, ApplicationContext
71 if(thread != null){ 71 if(thread != null){
72 thread.interrupt(); 72 thread.interrupt();
73 } 73 }
  74 + linkedList.clear();
74 thread = new DataPushThread(); 75 thread = new DataPushThread();
75 thread.start(); 76 thread.start();
76 } 77 }
77 78
  79 + public static int size(){
  80 + return linkedList.size();
  81 + }
  82 +
78 @Override 83 @Override
79 public void run(String... strings) throws Exception { 84 public void run(String... strings) throws Exception {
80 start(); 85 start();
@@ -96,7 +101,7 @@ public class DirectivePushQueue implements CommandLineRunner, ApplicationContext @@ -96,7 +101,7 @@ public class DirectivePushQueue implements CommandLineRunner, ApplicationContext
96 String code; 101 String code;
97 while (true) { 102 while (true) {
98 try { 103 try {
99 - qd = linkedList.pollFirst(); 104 + qd = linkedList.poll();
100 if (qd != null) { 105 if (qd != null) {
101 sleepFlag = false; 106 sleepFlag = false;
102 code = qd.getCode(); 107 code = qd.getCode();
@@ -124,13 +129,15 @@ public class DirectivePushQueue implements CommandLineRunner, ApplicationContext @@ -124,13 +129,15 @@ public class DirectivePushQueue implements CommandLineRunner, ApplicationContext
124 t = System.currentTimeMillis(); 129 t = System.currentTimeMillis();
125 } 130 }
126 catch(InterruptedException e){ 131 catch(InterruptedException e){
  132 + log.error("", e);
127 break; 133 break;
128 } 134 }
129 catch (Exception e) { 135 catch (Exception e) {
130 log.error("", e); 136 log.error("", e);
131 } 137 }
132 -  
133 } 138 }
  139 +
  140 + log.warn("DirectivePushQueue is break...");
134 } 141 }
135 } 142 }
136 } 143 }
src/main/java/com/bsth/data/msg_queue/WebSocketPushQueue.java
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component; @@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
8 import org.springframework.web.socket.TextMessage; 8 import org.springframework.web.socket.TextMessage;
9 import org.springframework.web.socket.WebSocketSession; 9 import org.springframework.web.socket.WebSocketSession;
10 10
11 -import java.util.LinkedList; 11 +import java.util.concurrent.ConcurrentLinkedQueue;
12 12
13 /** 13 /**
14 * 线调web socket 推送队列 14 * 线调web socket 推送队列
@@ -17,14 +17,14 @@ import java.util.LinkedList; @@ -17,14 +17,14 @@ import java.util.LinkedList;
17 @Component 17 @Component
18 public class WebSocketPushQueue implements CommandLineRunner { 18 public class WebSocketPushQueue implements CommandLineRunner {
19 19
20 - static LinkedList<QueueData> linkedList; 20 + static ConcurrentLinkedQueue<QueueData> linkedList;
21 static DataPushThread thread; 21 static DataPushThread thread;
22 static Logger log = LoggerFactory.getLogger(WebSocketPushQueue.class); 22 static Logger log = LoggerFactory.getLogger(WebSocketPushQueue.class);
23 static long t; 23 static long t;
24 static final int IDLE_TIME = 1000 * 30; 24 static final int IDLE_TIME = 1000 * 30;
25 25
26 static { 26 static {
27 - linkedList = new LinkedList(); 27 + linkedList = new ConcurrentLinkedQueue();
28 } 28 }
29 29
30 public static boolean isIdle() { 30 public static boolean isIdle() {
@@ -45,10 +45,15 @@ public class WebSocketPushQueue implements CommandLineRunner { @@ -45,10 +45,15 @@ public class WebSocketPushQueue implements CommandLineRunner {
45 if (thread != null) { 45 if (thread != null) {
46 thread.interrupt(); 46 thread.interrupt();
47 } 47 }
  48 + linkedList.clear();
48 thread = new DataPushThread(); 49 thread = new DataPushThread();
49 thread.start(); 50 thread.start();
50 } 51 }
51 52
  53 + public static int size(){
  54 + return linkedList.size();
  55 + }
  56 +
52 @Override 57 @Override
53 public void run(String... strings) throws Exception { 58 public void run(String... strings) throws Exception {
54 start(); 59 start();
@@ -66,7 +71,7 @@ public class WebSocketPushQueue implements CommandLineRunner { @@ -66,7 +71,7 @@ public class WebSocketPushQueue implements CommandLineRunner {
66 boolean sleepFlag = false; 71 boolean sleepFlag = false;
67 while (true) { 72 while (true) {
68 try { 73 try {
69 - qd = linkedList.pollFirst(); 74 + qd = linkedList.poll();
70 if (qd != null) { 75 if (qd != null) {
71 sleepFlag = false; 76 sleepFlag = false;
72 session = qd.getSession(); 77 session = qd.getSession();
@@ -84,11 +89,14 @@ public class WebSocketPushQueue implements CommandLineRunner { @@ -84,11 +89,14 @@ public class WebSocketPushQueue implements CommandLineRunner {
84 } 89 }
85 t = System.currentTimeMillis(); 90 t = System.currentTimeMillis();
86 } catch (InterruptedException e) { 91 } catch (InterruptedException e) {
  92 + log.error("", e);
87 break; 93 break;
88 } catch (Exception e) { 94 } catch (Exception e) {
89 log.error("", e); 95 log.error("", e);
90 } 96 }
91 } 97 }
  98 +
  99 + log.warn("WebSocketPushQueue is break...");
92 } 100 }
93 } 101 }
94 } 102 }
src/main/java/com/bsth/data/pilot80/PilotReport.java
@@ -8,13 +8,16 @@ import com.bsth.data.msg_queue.DirectivePushQueue; @@ -8,13 +8,16 @@ import com.bsth.data.msg_queue.DirectivePushQueue;
8 import com.bsth.data.schedule.DayOfSchedule; 8 import com.bsth.data.schedule.DayOfSchedule;
9 import com.bsth.entity.Line; 9 import com.bsth.entity.Line;
10 import com.bsth.entity.directive.D80; 10 import com.bsth.entity.directive.D80;
  11 +import com.bsth.entity.directive.DC0_A4;
11 import com.bsth.entity.realcontrol.D80ReplyTemp; 12 import com.bsth.entity.realcontrol.D80ReplyTemp;
12 import com.bsth.entity.realcontrol.LineConfig; 13 import com.bsth.entity.realcontrol.LineConfig;
13 import com.bsth.entity.realcontrol.ScheduleRealInfo; 14 import com.bsth.entity.realcontrol.ScheduleRealInfo;
14 import com.bsth.repository.directive.D80Repository; 15 import com.bsth.repository.directive.D80Repository;
  16 +import com.bsth.repository.directive.DC0A4Repository;
15 import com.bsth.service.directive.DirectiveService; 17 import com.bsth.service.directive.DirectiveService;
16 import com.bsth.websocket.handler.SendUtils; 18 import com.bsth.websocket.handler.SendUtils;
17 import com.google.common.collect.ArrayListMultimap; 19 import com.google.common.collect.ArrayListMultimap;
  20 +import org.apache.commons.lang3.StringUtils;
18 import org.slf4j.Logger; 21 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory; 22 import org.slf4j.LoggerFactory;
20 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +30,7 @@ import java.util.List; @@ -27,7 +30,7 @@ import java.util.List;
27 /** 30 /**
28 * 31 *
29 * @ClassName: PilotReport 32 * @ClassName: PilotReport
30 - * @Description: TODO(驾驶员上报) 33 + * @Description: TODO(设备80协议上报处理)
31 * @author PanZhao 34 * @author PanZhao
32 * @date 2016年8月14日 下午11:37:51 35 * @date 2016年8月14日 下午11:37:51
33 * 36 *
@@ -37,31 +40,26 @@ public class PilotReport { @@ -37,31 +40,26 @@ public class PilotReport {
37 40
38 @Autowired 41 @Autowired
39 D80Repository d80Repository; 42 D80Repository d80Repository;
40 -  
41 @Autowired 43 @Autowired
42 DayOfSchedule dayOfSchedule; 44 DayOfSchedule dayOfSchedule;
43 -  
44 @Autowired 45 @Autowired
45 LineConfigData lineConfigData; 46 LineConfigData lineConfigData;
46 -  
47 @Autowired 47 @Autowired
48 DirectiveService directiveService; 48 DirectiveService directiveService;
49 -  
50 @Autowired 49 @Autowired
51 GpsRealData gpsRealData; 50 GpsRealData gpsRealData;
52 -  
53 @Autowired 51 @Autowired
54 SendUtils sendUtils; 52 SendUtils sendUtils;
55 -  
56 - //private static ScheduleComparator.FCNO schComp;  
57 - 53 +
  54 + @Autowired
  55 + DC0A4Repository dc0A4Repository;
  56 +
58 private static ArrayListMultimap<String, D80> d80MultiMap; 57 private static ArrayListMultimap<String, D80> d80MultiMap;
59 58
60 Logger logger = LoggerFactory.getLogger(PilotReport.class); 59 Logger logger = LoggerFactory.getLogger(PilotReport.class);
61 60
62 static{ 61 static{
63 d80MultiMap = ArrayListMultimap.create(); 62 d80MultiMap = ArrayListMultimap.create();
64 - //schComp = new ScheduleComparator.FCNO();  
65 } 63 }
66 64
67 public void report(D80 d80){ 65 public void report(D80 d80){
@@ -95,22 +93,31 @@ public class PilotReport { @@ -95,22 +93,31 @@ public class PilotReport {
95 93
96 case 0xA5: 94 case 0xA5:
97 //进场请求 95 //进场请求
98 - ScheduleRealInfo inSch = dayOfSchedule.nextByBcType(nbbm, "in"); 96 + //ScheduleRealInfo inSch = dayOfSchedule.nextByBcType(nbbm, "in");
99 //如果有对应出场班次 97 //如果有对应出场班次
100 - if(inSch != null){  
101 - d80.setRemarks("计划进场时间:" + inSch.getDfsj()); 98 + //if(inSch != null){
  99 + /*d80.setRemarks("计划进场时间:" + inSch.getDfsj());
102 //当前GPS位置 100 //当前GPS位置
103 GpsEntity gps = gpsRealData.get(d80.getDeviceId()); 101 GpsEntity gps = gpsRealData.get(d80.getDeviceId());
104 if(null != gps) 102 if(null != gps)
105 - d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));  
106 - }else  
107 - d80.setRemarks("没有进场计划"); 103 + d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));*/
  104 + //}/*else
  105 + // d80.setRemarks("没有进场计划");*/
108 break; 106 break;
109 } 107 }
110 108
111 //推送到页面 109 //推送到页面
112 sendUtils.send80ToPage(d80); 110 sendUtils.send80ToPage(d80);
113 } 111 }
  112 +
  113 + public void report(DC0_A4 c0a4){
  114 + String deviceId = c0a4.getData().getDeviceId();
  115 + if(StringUtils.isNotEmpty(deviceId))
  116 + c0a4.setId(deviceId);
  117 +
  118 + //入库
  119 + dc0A4Repository.save(c0a4);
  120 + }
114 121
115 /** 122 /**
116 * 123 *
@@ -121,7 +128,7 @@ public class PilotReport { @@ -121,7 +128,7 @@ public class PilotReport {
121 String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); 128 String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
122 Short reqCode = d80.getData().getRequestCode(); 129 Short reqCode = d80.getData().getRequestCode();
123 //默认短语回复 130 //默认短语回复
124 - defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false); 131 + //defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false);
125 132
126 switch (reqCode) { 133 switch (reqCode) {
127 case 0xA3: 134 case 0xA3:
@@ -181,7 +188,7 @@ public class PilotReport { @@ -181,7 +188,7 @@ public class PilotReport {
181 sch.setZdsjActualAll(d80.getTimestamp()); 188 sch.setZdsjActualAll(d80.getTimestamp());
182 189
183 //没有里程的进场班次 190 //没有里程的进场班次
184 - if(sch.getBcsj() == null && sch.getJhlc() == null) 191 + if(isEmpty(sch.getBcsj()) && isEmpty(sch.getJhlc()))
185 sch.setFcsjActualAll(d80.getTimestamp()); 192 sch.setFcsjActualAll(d80.getTimestamp());
186 193
187 dayOfSchedule.save(sch); 194 dayOfSchedule.save(sch);
@@ -190,6 +197,14 @@ public class PilotReport { @@ -190,6 +197,14 @@ public class PilotReport {
190 } 197 }
191 } 198 }
192 } 199 }
  200 +
  201 + public boolean isEmpty(Integer v){
  202 + return v == null || v.equals(0);
  203 + }
  204 +
  205 + public boolean isEmpty(Double v){
  206 + return v == null || v.equals(0);
  207 + }
193 208
194 public void defaultReply(String nbbm, short requestCode, boolean agree){ 209 public void defaultReply(String nbbm, short requestCode, boolean agree){
195 Line line = BasicData.nbbm2LineMap.get(nbbm); 210 Line line = BasicData.nbbm2LineMap.get(nbbm);
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSON; @@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.bsth.common.Constants; 5 import com.bsth.common.Constants;
6 import com.bsth.common.ResponseCode; 6 import com.bsth.common.ResponseCode;
  7 +import com.bsth.data.BasicData;
7 import com.bsth.data.LineConfigData; 8 import com.bsth.data.LineConfigData;
  9 +import com.bsth.data.gpsdata.GpsEntity;
8 import com.bsth.data.gpsdata.GpsRealData; 10 import com.bsth.data.gpsdata.GpsRealData;
9 import com.bsth.data.gpsdata.recovery.GpsDataRecovery; 11 import com.bsth.data.gpsdata.recovery.GpsDataRecovery;
  12 +import com.bsth.data.msg_queue.DirectivePushQueue;
10 import com.bsth.entity.realcontrol.LineConfig; 13 import com.bsth.entity.realcontrol.LineConfig;
11 import com.bsth.entity.realcontrol.ScheduleRealInfo; 14 import com.bsth.entity.realcontrol.ScheduleRealInfo;
12 import com.bsth.entity.schedule.SchedulePlanInfo; 15 import com.bsth.entity.schedule.SchedulePlanInfo;
@@ -579,6 +582,37 @@ public class DayOfSchedule { @@ -579,6 +582,37 @@ public class DayOfSchedule {
579 } 582 }
580 583
581 /** 584 /**
  585 + * 下一个班次
  586 + * @param list 班次集合
  587 + * @param sch 当前班次
  588 + * @return
  589 + */
  590 + private ScheduleRealInfo next2(Collection<ScheduleRealInfo> list , ScheduleRealInfo sch){
  591 + int outConfig = -1;
  592 + LineConfig config = lineConfigData.get(sch.getXlBm());
  593 + if (config != null)
  594 + outConfig = config.getOutConfig();
  595 +
  596 + boolean flag = false;
  597 + ScheduleRealInfo next = null;
  598 + for (ScheduleRealInfo temp : list) {
  599 + if (temp.getId() == sch.getId()) {
  600 + flag = true;
  601 + continue;
  602 + }
  603 + //忽略烂班
  604 + if (temp.isDestroy())
  605 + continue;
  606 +
  607 + if (flag) {
  608 + next = temp;
  609 + break;
  610 + }
  611 + }
  612 + return next;
  613 + }
  614 +
  615 + /**
582 * 上一个班次 616 * 上一个班次
583 * 617 *
584 * @param sch 618 * @param sch
@@ -906,7 +940,22 @@ public class DayOfSchedule { @@ -906,7 +940,22 @@ public class DayOfSchedule {
906 public void reCalcExecPlan(String nbbm){ 940 public void reCalcExecPlan(String nbbm){
907 List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); 941 List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
908 Collections.sort(list, schFCSJComparator); 942 Collections.sort(list, schFCSJComparator);
909 - carExecutePlanMap.put(nbbm, schAttrCalculator.calcCurrentExecSch(list)); 943 +
  944 + ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list);
  945 + carExecutePlanMap.put(nbbm, sch);
  946 +
  947 + try {
  948 + GpsEntity gps = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm));
  949 + if(gps != null && gps.isOnline()){
  950 + if(StringUtils.isNotEmpty(gps.getLineId()) && !gps.getLineId().equals(sch.getXlBm())){
  951 + //下发线路切换指令
  952 + DirectivePushQueue.put64(nbbm, sch.getXlBm(), "系统");
  953 + logger.info("车辆" + nbbm + "切换至" + sch.getXlBm() + " -原" + gps.getLineId() + " --重新计算当前执行班次!");
  954 + }
  955 + }
  956 + }catch (Exception e){
  957 + logger.error("", e);
  958 + }
910 } 959 }
911 960
912 /** 961 /**
@@ -1016,6 +1065,17 @@ public class DayOfSchedule { @@ -1016,6 +1065,17 @@ public class DayOfSchedule {
1016 return next(list, sch); 1065 return next(list, sch);
1017 } 1066 }
1018 1067
  1068 + /**
  1069 + * 获取该班次所在路牌的下一个班次,不考虑场既是站
  1070 + * @param sch
  1071 + * @return
  1072 + */
  1073 + public ScheduleRealInfo nextByLp2(ScheduleRealInfo sch) {
  1074 + List<ScheduleRealInfo> list = lpScheduleMap.get(sch.getXlBm() + "_" + sch.getLpName());
  1075 + Collections.sort(list, schFCSJComparator);
  1076 + return next2(list, sch);
  1077 + }
  1078 +
1019 public ArrayListMultimap<String, ScheduleRealInfo> getLpScheduleMap(){ 1079 public ArrayListMultimap<String, ScheduleRealInfo> getLpScheduleMap(){
1020 return lpScheduleMap; 1080 return lpScheduleMap;
1021 } 1081 }
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
@@ -49,25 +49,25 @@ public class SchAttrCalculator { @@ -49,25 +49,25 @@ public class SchAttrCalculator {
49 if (null == sch.getFcsjT()) 49 if (null == sch.getFcsjT())
50 calcFcsjTime(sch); 50 calcFcsjTime(sch);
51 51
52 - //計發時間 52 + //计发時間
53 if(sch.getFcsj().compareTo(conf.getStartOpt()) < 0){ 53 if(sch.getFcsj().compareTo(conf.getStartOpt()) < 0){
54 sch.setFcsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getFcsj()) + DAY_TIME); 54 sch.setFcsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getFcsj()) + DAY_TIME);
55 } 55 }
56 56
57 - //待時間 57 + //待時間
58 if(sch.getDfsj().compareTo(conf.getStartOpt()) < 0){ 58 if(sch.getDfsj().compareTo(conf.getStartOpt()) < 0){
59 sch.setDfsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getDfsj()) + DAY_TIME); 59 sch.setDfsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getDfsj()) + DAY_TIME);
60 } 60 }
61 else 61 else
62 sch.setDfsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getDfsj())); 62 sch.setDfsjAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getDfsj()));
63 63
64 - //實發時間 64 + //实发時間
65 if(StringUtils.isNotEmpty(sch.getFcsjActual()) && 65 if(StringUtils.isNotEmpty(sch.getFcsjActual()) &&
66 sch.getFcsjActual().compareTo(conf.getStartOpt()) < 0){ 66 sch.getFcsjActual().compareTo(conf.getStartOpt()) < 0){
67 sch.setFcsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getFcsjActual()) + DAY_TIME); 67 sch.setFcsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getFcsjActual()) + DAY_TIME);
68 } 68 }
69 69
70 - //實際終點時間 70 + //实际终点時間
71 if(StringUtils.isNotEmpty(sch.getZdsjActual()) && 71 if(StringUtils.isNotEmpty(sch.getZdsjActual()) &&
72 sch.getZdsjActual().compareTo(conf.getStartOpt()) < 0){ 72 sch.getZdsjActual().compareTo(conf.getStartOpt()) < 0){
73 sch.setZdsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getZdsjActual()) + DAY_TIME); 73 sch.setZdsjActualAll(fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+sch.getZdsjActual()) + DAY_TIME);
@@ -119,7 +119,7 @@ public class SchAttrCalculator { @@ -119,7 +119,7 @@ public class SchAttrCalculator {
119 119
120 if(prve.getZdzName().equals(curr.getQdzName()) 120 if(prve.getZdzName().equals(curr.getQdzName())
121 || prve.getZdzCode().equals(curr.getQdzCode())){ 121 || prve.getZdzCode().equals(curr.getQdzCode())){
122 - curr.setQdzArrDateJH(prve.getZdsj()); 122 + curr.setQdzArrDatejh(prve.getZdsj());
123 if(StringUtils.isNotEmpty(prve.getZdsjActual())) 123 if(StringUtils.isNotEmpty(prve.getZdsjActual()))
124 curr.setQdzArrDatesj(prve.getZdsjActual()); 124 curr.setQdzArrDatesj(prve.getZdsjActual());
125 } 125 }
@@ -147,16 +147,16 @@ public class SchAttrCalculator { @@ -147,16 +147,16 @@ public class SchAttrCalculator {
147 if(prve.getZdzName().equals(curr.getQdzName()) 147 if(prve.getZdzName().equals(curr.getQdzName())
148 || prve.getZdzCode().equals(curr.getQdzCode())){ 148 || prve.getZdzCode().equals(curr.getQdzCode())){
149 149
150 - if(curr.getQdzArrDateJH() != null && prve.getZdsj().equals(curr.getQdzArrDateJH())){ 150 + if(curr.getQdzArrDatejh() != null && prve.getZdsj().equals(curr.getQdzArrDatejh())){
151 prve = curr; 151 prve = curr;
152 continue; 152 continue;
153 } 153 }
154 154
155 - curr.setQdzArrDateJH(prve.getZdsj()); 155 + curr.setQdzArrDatejh(prve.getZdsj());
156 updateList.add(curr); 156 updateList.add(curr);
157 } 157 }
158 else{ 158 else{
159 - curr.setQdzArrDateJH(null); 159 + curr.setQdzArrDatejh(null);
160 updateList.add(curr); 160 updateList.add(curr);
161 } 161 }
162 prve = curr; 162 prve = curr;
src/main/java/com/bsth/data/schedule/edit_logs/FormLogger.java
@@ -54,8 +54,9 @@ public class FormLogger { @@ -54,8 +54,9 @@ public class FormLogger {
54 cc.setFgs(sch.getFgsBm()); 54 cc.setFgs(sch.getFgsBm());
55 cc.setXl(sch.getXlBm()); 55 cc.setXl(sch.getXlBm());
56 cc.setLp(sch.getLpName()); 56 cc.setLp(sch.getLpName());
57 - cc.setFssj(fmtHHmm.print(d.getTime())); 57 + cc.setFssj(sch.getFcsj());
58 cc.setXgsj(fmtHHmm.print(d.getTime())); 58 cc.setXgsj(fmtHHmm.print(d.getTime()));
  59 + cc.setsId(sch.getId());
59 if(user != null) 60 if(user != null)
60 cc.setXgr(user.getUserName()); 61 cc.setXgr(user.getUserName());
61 62
src/main/java/com/bsth/data/schedule/late_adjust/ScheduleLateThread.java
@@ -31,7 +31,7 @@ public class ScheduleLateThread extends Thread{ @@ -31,7 +31,7 @@ public class ScheduleLateThread extends Thread{
31 @Autowired 31 @Autowired
32 SendUtils sendUtils; 32 SendUtils sendUtils;
33 33
34 - private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.FCSJ(); 34 + private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.DFSJ();
35 35
36 @Override 36 @Override
37 public void run() { 37 public void run() {
@@ -54,7 +54,7 @@ public class ScheduleLateThread extends Thread{ @@ -54,7 +54,7 @@ public class ScheduleLateThread extends Thread{
54 && StringUtils.isEmpty(sch.getFcsjActual())){ 54 && StringUtils.isEmpty(sch.getFcsjActual())){
55 55
56 //检查应发未到 当前班次无起点到达时间 56 //检查应发未到 当前班次无起点到达时间
57 - if(StringUtils.isEmpty(sch.getQdzArrDateSJ())){ 57 + if(StringUtils.isEmpty(sch.getQdzArrDatesj())){
58 ScheduleRealInfo prev = dayOfSchedule.prev(sch); 58 ScheduleRealInfo prev = dayOfSchedule.prev(sch);
59 //上一个班次也没有实际终点到达时间 59 //上一个班次也没有实际终点到达时间
60 if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){ 60 if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){
src/main/java/com/bsth/entity/directive/DC0_A4.java
@@ -13,13 +13,21 @@ import javax.persistence.*; @@ -13,13 +13,21 @@ import javax.persistence.*;
13 @Entity 13 @Entity
14 @Table(name = "bsth_v_C0_A4") 14 @Table(name = "bsth_v_C0_A4")
15 public class DC0_A4 extends Directive{ 15 public class DC0_A4 extends Directive{
16 - 16 +
  17 +
17 @Id 18 @Id
18 - @GeneratedValue  
19 - private Integer id; 19 + private String id;
20 20
21 private DC0A4Data data; 21 private DC0A4Data data;
22 - 22 +
  23 + public String getId() {
  24 + return id;
  25 + }
  26 +
  27 + public void setId(String id) {
  28 + this.id = id;
  29 + }
  30 +
23 @Embeddable 31 @Embeddable
24 public static class DC0A4Data { 32 public static class DC0A4Data {
25 /** 33 /**
@@ -164,14 +172,6 @@ public class DC0_A4 extends Directive{ @@ -164,14 +172,6 @@ public class DC0_A4 extends Directive{
164 } 172 }
165 } 173 }
166 174
167 - public Integer getId() {  
168 - return id;  
169 - }  
170 -  
171 - public void setId(Integer id) {  
172 - this.id = id;  
173 - }  
174 -  
175 public DC0A4Data getData() { 175 public DC0A4Data getData() {
176 return data; 176 return data;
177 } 177 }
src/main/java/com/bsth/entity/excep/Speeding.java
@@ -74,6 +74,13 @@ public class Speeding { @@ -74,6 +74,13 @@ public class Speeding {
74 @Transient 74 @Transient
75 private String lpname; 75 private String lpname;
76 76
  77 + //结束时间,单位:秒/s
  78 + @Transient
  79 + private Long endtimestamp;
  80 +
  81 + @Transient
  82 + private String endtimestampDate;
  83 +
77 /** 84 /**
78 * 创建时间 85 * 创建时间
79 */ 86 */
@@ -169,6 +176,14 @@ public class Speeding { @@ -169,6 +176,14 @@ public class Speeding {
169 this.timestampDate = timestampDate; 176 this.timestampDate = timestampDate;
170 } 177 }
171 178
  179 + public String getEndtimestampDate() {
  180 + return endtimestampDate;
  181 + }
  182 +
  183 + public void setEndtimestampDate(String endtimestampDate) {
  184 + this.endtimestampDate = endtimestampDate;
  185 + }
  186 +
172 public String getNbbm() { 187 public String getNbbm() {
173 return nbbm; 188 return nbbm;
174 } 189 }
@@ -193,6 +208,12 @@ public class Speeding { @@ -193,6 +208,12 @@ public class Speeding {
193 this.lpname = lpname; 208 this.lpname = lpname;
194 } 209 }
195 210
  211 + public Long getEndtimestamp() {
  212 + return endtimestamp;
  213 + }
196 214
  215 + public void setEndtimestamp(Long endtimestamp) {
  216 + this.endtimestamp = endtimestamp;
  217 + }
197 218
198 } 219 }
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
@@ -648,22 +648,6 @@ public class ScheduleRealInfo { @@ -648,22 +648,6 @@ public class ScheduleRealInfo {
648 return ("schedule_" + this.id).hashCode(); 648 return ("schedule_" + this.id).hashCode();
649 } 649 }
650 650
651 - public String getQdzArrDateJH() {  
652 - return qdzArrDatejh;  
653 - }  
654 -  
655 - public void setQdzArrDateJH(String qdzArrDateJH) {  
656 - this.qdzArrDatejh = qdzArrDateJH;  
657 - }  
658 -  
659 - public String getQdzArrDateSJ() {  
660 - return qdzArrDatesj;  
661 - }  
662 -  
663 - public void setQdzArrDateSJ(String qdzArrDateSJ) {  
664 - this.qdzArrDatesj = qdzArrDateSJ;  
665 - }  
666 -  
667 public boolean isSflj() { 651 public boolean isSflj() {
668 return sflj; 652 return sflj;
669 } 653 }
src/main/java/com/bsth/repository/directive/DC0A4Repository.java 0 → 100644
  1 +package com.bsth.repository.directive;
  2 +
  3 +import com.bsth.entity.directive.DC0_A4;
  4 +import com.bsth.repository.BaseRepository;
  5 +import org.springframework.stereotype.Repository;
  6 +
  7 +/**
  8 + * C0_A4 设备回复(设备参数)
  9 + * Created by panzhao on 2017/6/28.
  10 + */
  11 +@Repository
  12 +public interface DC0A4Repository extends BaseRepository<DC0_A4, String>{
  13 +}
src/main/java/com/bsth/service/directive/DirectiveService.java
@@ -86,7 +86,7 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{ @@ -86,7 +86,7 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
86 86
87 D64 save64(D64 d64); 87 D64 save64(D64 d64);
88 88
89 - int sendC0A4(String nbbm); 89 + Map<String, Object> sendC0A4(String nbbm);
90 90
91 int sendC0A3(DC0_A3 c0a4); 91 int sendC0A3(DC0_A3 c0a4);
92 92
@@ -95,4 +95,6 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{ @@ -95,4 +95,6 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
95 int refreshLineFile(String deviceId); 95 int refreshLineFile(String deviceId);
96 96
97 int stateChange(String nbbm, Integer upDown, Integer state, String userName); 97 int stateChange(String nbbm, Integer upDown, Integer state, String userName);
  98 +
  99 + Map<String,Object> deviceCofigList(Map<String, String> map, int page, int size);
98 } 100 }
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
@@ -18,6 +18,7 @@ import com.bsth.repository.directive.D60Repository; @@ -18,6 +18,7 @@ import com.bsth.repository.directive.D60Repository;
18 import com.bsth.repository.directive.D64Repository; 18 import com.bsth.repository.directive.D64Repository;
19 import com.bsth.repository.directive.D80Repository; 19 import com.bsth.repository.directive.D80Repository;
20 import com.bsth.security.util.SecurityUtils; 20 import com.bsth.security.util.SecurityUtils;
  21 +import com.bsth.service.directive.dto.DeviceConfigDto;
21 import com.bsth.service.impl.BaseServiceImpl; 22 import com.bsth.service.impl.BaseServiceImpl;
22 import com.bsth.websocket.handler.RealControlSocketHandler; 23 import com.bsth.websocket.handler.RealControlSocketHandler;
23 import com.fasterxml.jackson.core.JsonProcessingException; 24 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -29,6 +30,8 @@ import org.joda.time.format.DateTimeFormatter; @@ -29,6 +30,8 @@ import org.joda.time.format.DateTimeFormatter;
29 import org.slf4j.Logger; 30 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory; 31 import org.slf4j.LoggerFactory;
31 import org.springframework.beans.factory.annotation.Autowired; 32 import org.springframework.beans.factory.annotation.Autowired;
  33 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  34 +import org.springframework.jdbc.core.JdbcTemplate;
32 import org.springframework.stereotype.Service; 35 import org.springframework.stereotype.Service;
33 36
34 import java.util.*; 37 import java.util.*;
@@ -36,486 +39,540 @@ import java.util.*; @@ -36,486 +39,540 @@ import java.util.*;
36 @Service 39 @Service
37 public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implements DirectiveService { 40 public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implements DirectiveService {
38 41
39 - Logger logger = LoggerFactory.getLogger(this.getClass());  
40 -  
41 - @Autowired  
42 - D60Repository d60Repository;  
43 -  
44 - @Autowired  
45 - GpsRealData gpsRealDataBuffer;  
46 -  
47 - @Autowired  
48 - D64Repository d64Repository;  
49 -  
50 - @Autowired  
51 - RealControlSocketHandler socketHandler;  
52 -  
53 - @Autowired  
54 - D80Repository d80Repository;  
55 -  
56 - @Autowired  
57 - DayOfDirectives dayOfDirectives;  
58 -  
59 - @Autowired  
60 - PilotReport pilotReport;  
61 -  
62 - @Autowired  
63 - DayOfSchedule dayOfSchedule;  
64 -  
65 - //static Long schDiff = 1000 * 60 * 60L;  
66 -  
67 - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm")  
68 - ,fmtHHmm_CN = DateTimeFormat.forPattern("HH点mm分");  
69 -  
70 - @Override  
71 - public int send60Phrase(String nbbm, String text, String sender) {  
72 - D60 d60 = null;  
73 - try {  
74 - d60 = create60Data(nbbm, text, (short) 0x00, null);  
75 - } catch (Exception e) {  
76 - logger.error("发送消息短语出现异常", e);  
77 - return -1;  
78 - }  
79 -  
80 - if (null == d60)  
81 - return -1;  
82 -  
83 - // 发送指令  
84 - int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));  
85 - if(null != sender)  
86 - d60.setSender(sender);  
87 - d60.setHttpCode(code);  
88 -  
89 - if (code == 0) {  
90 - // 添加到缓存  
91 - dayOfDirectives.put60(d60, true);  
92 - }  
93 - else{  
94 - d60.setErrorText("网关通讯失败, code: " + code);  
95 - d60Repository.save(d60);  
96 - dayOfDirectives.put60(d60, false);  
97 - }  
98 - return code;  
99 - }  
100 -  
101 - @Override  
102 - public int send60Dispatch(ScheduleRealInfo sch, int finish, String sender) {  
103 - D60 d60 = null;  
104 - try {  
105 - if(sch.isDestroy()){  
106 - logger.warn("烂班不允许发送调度指令....");  
107 - return -1;  
108 - }  
109 - String text = "已完成" + finish + "个班次,下一发车时间" + fmtHHmm_CN.print(sch.getDfsjT()) + ",由"  
110 - + sch.getQdzName() + "发往" + sch.getZdzName();  
111 -  
112 - //下发0x02指令 调度指令(闹钟有效)  
113 - Long alarmTime = System.currentTimeMillis() + 1000 * 30;  
114 - d60 = new DirectiveCreator().createD60_02(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir())  
115 - , 0, new Date(alarmTime));  
116 - } catch (Exception e) {  
117 - logger.error("生成调度指令时出现异常", e);  
118 - return -1;  
119 - }  
120 -  
121 - if (null == d60)  
122 - return -1;  
123 -  
124 - d60.setSender(sender);  
125 -  
126 - JSONObject jObj = JSON.parseObject(JSON.toJSONString(d60));  
127 -  
128 - //进场或者出场班次时,附加lock 标识  
129 - if(null != sch.getBcType()  
130 - && (sch.getBcType().equals("out") || sch.getBcType().equals("in"))){  
131 -  
132 - jObj.put("lock", 1);  
133 - }  
134 -  
135 - // 发送指令  
136 - int code = GatewayHttpUtils.postJson(jObj.toJSONString());  
137 -  
138 - d60.setDispatch(true);  
139 - d60.setSch(sch);  
140 - d60.setHttpCode(code);  
141 -  
142 - if (code == 0) {  
143 - sch.setDirectiveState(60);  
144 - // 添加到缓存,延迟入库  
145 - dayOfDirectives.put60(d60, true);  
146 - // 通知页面  
147 - sendD60ToPage(sch);  
148 - }  
149 - else{  
150 - d60.setErrorText("网关通讯失败, code: " + code);  
151 - dayOfDirectives.put60(d60, false);  
152 - d60Repository.save(d60);  
153 - }  
154 - return code;  
155 - }  
156 -  
157 - /**  
158 - *  
159 - * @Title: sendDirectiveState @Description: TODO(向页面推送班次指令状态) @throws  
160 - */  
161 - @Override  
162 - public void sendD60ToPage(ScheduleRealInfo sch) {  
163 - Map<String, Object> map = new HashMap<>();  
164 - map.put("fn", "directive");  
165 - map.put("t", sch);  
166 -  
167 - ObjectMapper mapper = new ObjectMapper();  
168 -  
169 - try {  
170 - socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));  
171 - } catch (JsonProcessingException e) {  
172 - logger.error("", e);  
173 - }  
174 - }  
175 -  
176 - @Override  
177 - public int send60Dispatch(Long id, String sender) {  
178 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
179 - // 车辆已完成班次  
180 - int finish = dayOfSchedule.doneSum(sch.getClZbh());  
181 - return send60Dispatch(sch, finish, sender);  
182 - }  
183 -  
184 - @Override  
185 - public int send60Operation(String nbbm, int state, int upDown, ScheduleRealInfo sch, String sender) {  
186 - logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown);  
187 -  
188 - String text = "切换为 " + (upDown == 0 ? "上行" : "下行") + (state == 0 ? "营运" : "未营运");  
189 - D60 d60 = new DirectiveCreator().createD60(nbbm, text, (short) 0x03, upDown, state);  
190 -  
191 - if (null == d60)  
192 - return -1;  
193 - if(null != sender)  
194 - d60.setSender(sender);  
195 - else  
196 - d60.setSender("系统");  
197 - // 发送指令  
198 - int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));  
199 - // 添加到缓存,等待入库  
200 - d60.setHttpCode(code);  
201 - if (null != sch)  
202 - d60.setSch(sch);  
203 -  
204 -  
205 - if (code == 0) {  
206 - dayOfDirectives.put60(d60, true);  
207 - }  
208 - else{  
209 - d60.setErrorText("网关通讯失败, code: " + code);  
210 - d60Repository.save(d60);  
211 - dayOfDirectives.put60(d60, false);  
212 - }  
213 - return code;  
214 - }  
215 -  
216 - /**  
217 - * 线路切换  
218 - */  
219 - @Override  
220 - public int lineChange(String nbbm, String lineCode, String sender) {  
221 - return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sender);  
222 - }  
223 -  
224 -  
225 - @Override  
226 - public int lineChangeByDeviceId(String deviceId, String lineCode, String sender){  
227 - DirectiveCreator crt = new DirectiveCreator();  
228 - Long t = System.currentTimeMillis();  
229 - //生成64数据包  
230 - D64 d64 = crt.create64(deviceId, lineCode, t);  
231 -  
232 - if(null != sender)  
233 - d64.setSender(sender);  
234 - else  
235 - d64.setSender("系统");  
236 -  
237 - //String deviceId = d64.getDeviceId();  
238 - int code = GatewayHttpUtils.postJson(JSON.toJSONString(d64));  
239 - // 入库  
240 - d64.setHttpCode(code);  
241 - d64.getData().setTxtContent("切换线路[" + lineCode + "]");  
242 - dayOfDirectives.put64(d64);  
243 -  
244 - // 通知设备刷新线路文件,忽略结果  
245 - if (code == 0)  
246 - GatewayHttpUtils.postJson(crt.createDeviceRefreshData(deviceId, lineCode));  
247 - else  
248 - d64.setErrorText(" 网关通讯失败, code: " + code);  
249 -  
250 - d64Repository.save(d64);  
251 - return code;  
252 - }  
253 -  
254 - public D60 create60Data(String nbbm, String text, Short dispatchInstruct, ScheduleRealInfo sch) {  
255 -  
256 - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
257 - if (null == deviceId) {  
258 - logger.error("没有设备号对照的车辆:" + nbbm);  
259 - return null;  
260 - }  
261 - // 根据当前GPS确定 上下行和营运状态  
262 - Byte upDown = null;  
263 - Integer state = null;  
264 - if (null == sch) {  
265 - GpsEntity gpsData = gpsRealDataBuffer.get(deviceId);  
266 - if (null == gpsData) {  
267 - /* 42 + Logger logger = LoggerFactory.getLogger(this.getClass());
  43 +
  44 + @Autowired
  45 + D60Repository d60Repository;
  46 +
  47 + @Autowired
  48 + GpsRealData gpsRealDataBuffer;
  49 +
  50 + @Autowired
  51 + D64Repository d64Repository;
  52 +
  53 + @Autowired
  54 + RealControlSocketHandler socketHandler;
  55 +
  56 + @Autowired
  57 + D80Repository d80Repository;
  58 +
  59 + @Autowired
  60 + DayOfDirectives dayOfDirectives;
  61 +
  62 + @Autowired
  63 + PilotReport pilotReport;
  64 +
  65 + @Autowired
  66 + DayOfSchedule dayOfSchedule;
  67 +
  68 + @Autowired
  69 + JdbcTemplate jdbcTemplate;
  70 +
  71 + //static Long schDiff = 1000 * 60 * 60L;
  72 +
  73 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"), fmtHHmm_CN = DateTimeFormat.forPattern("HH点mm分");
  74 +
  75 + @Override
  76 + public int send60Phrase(String nbbm, String text, String sender) {
  77 + D60 d60 = null;
  78 + try {
  79 + d60 = create60Data(nbbm, text, (short) 0x00, null);
  80 + } catch (Exception e) {
  81 + logger.error("发送消息短语出现异常", e);
  82 + return -1;
  83 + }
  84 +
  85 + if (null == d60)
  86 + return -1;
  87 +
  88 + // 发送指令
  89 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));
  90 + if (null != sender)
  91 + d60.setSender(sender);
  92 + d60.setHttpCode(code);
  93 +
  94 + if (code == 0) {
  95 + // 添加到缓存
  96 + dayOfDirectives.put60(d60, true);
  97 + } else {
  98 + d60.setErrorText("网关通讯失败, code: " + code);
  99 + d60Repository.save(d60);
  100 + dayOfDirectives.put60(d60, false);
  101 + }
  102 + return code;
  103 + }
  104 +
  105 + @Override
  106 + public int send60Dispatch(ScheduleRealInfo sch, int finish, String sender) {
  107 + D60 d60 = null;
  108 + try {
  109 + if (sch.isDestroy()) {
  110 + logger.warn("烂班不允许发送调度指令....");
  111 + return -1;
  112 + }
  113 + String text = "已完成" + finish + "个班次,下一发车时间" + fmtHHmm_CN.print(sch.getDfsjT()) + ",由"
  114 + + sch.getQdzName() + "发往" + sch.getZdzName();
  115 +
  116 + //下发0x01指令 调度指令(闹钟有效)
  117 + long t = System.currentTimeMillis(), alarmTime;
  118 + alarmTime = sch.getDfsjT();
  119 + if (sch.getDfsjT() < t)
  120 + alarmTime = t + 1000 * 30;
  121 +
  122 + d60 = new DirectiveCreator().createD60_01(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir())
  123 + , 0, new Date(alarmTime));
  124 + } catch (Exception e) {
  125 + logger.error("生成调度指令时出现异常", e);
  126 + return -1;
  127 + }
  128 +
  129 + if (null == d60)
  130 + return -1;
  131 +
  132 + d60.setSender(sender);
  133 +
  134 + JSONObject jObj = JSON.parseObject(JSON.toJSONString(d60));
  135 +
  136 + //进场或者出场班次时,附加lock 标识
  137 + if (null != sch.getBcType()
  138 + && (sch.getBcType().equals("out") || sch.getBcType().equals("in"))) {
  139 +
  140 + jObj.put("lock", 1);
  141 + }
  142 +
  143 + // 发送指令
  144 + int code = GatewayHttpUtils.postJson(jObj.toJSONString());
  145 +
  146 + d60.setDispatch(true);
  147 + d60.setSch(sch);
  148 + d60.setHttpCode(code);
  149 +
  150 + if (code == 0) {
  151 + sch.setDirectiveState(60);
  152 + // 添加到缓存,延迟入库
  153 + dayOfDirectives.put60(d60, true);
  154 + // 通知页面
  155 + sendD60ToPage(sch);
  156 + } else {
  157 + d60.setErrorText("网关通讯失败, code: " + code);
  158 + dayOfDirectives.put60(d60, false);
  159 + d60Repository.save(d60);
  160 + }
  161 + return code;
  162 + }
  163 +
  164 + /**
  165 + * @Title: sendDirectiveState @Description: TODO(向页面推送班次指令状态) @throws
  166 + */
  167 + @Override
  168 + public void sendD60ToPage(ScheduleRealInfo sch) {
  169 + Map<String, Object> map = new HashMap<>();
  170 + map.put("fn", "directive");
  171 + map.put("t", sch);
  172 +
  173 + ObjectMapper mapper = new ObjectMapper();
  174 +
  175 + try {
  176 + socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
  177 + } catch (JsonProcessingException e) {
  178 + logger.error("", e);
  179 + }
  180 + }
  181 +
  182 + @Override
  183 + public int send60Dispatch(Long id, String sender) {
  184 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  185 + // 车辆已完成班次
  186 + int finish = dayOfSchedule.doneSum(sch.getClZbh());
  187 + return send60Dispatch(sch, finish, sender);
  188 + }
  189 +
  190 + @Override
  191 + public int send60Operation(String nbbm, int state, int upDown, ScheduleRealInfo sch, String sender) {
  192 + logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown);
  193 +
  194 + String text = "切换为 " + (upDown == 0 ? "上行" : "下行") + (state == 0 ? "营运" : "未营运");
  195 + D60 d60 = new DirectiveCreator().createD60(nbbm, text, (short) 0x03, upDown, state);
  196 +
  197 + if (null == d60)
  198 + return -1;
  199 + if (null != sender)
  200 + d60.setSender(sender);
  201 + else
  202 + d60.setSender("系统");
  203 + // 发送指令
  204 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60));
  205 + // 添加到缓存,等待入库
  206 + d60.setHttpCode(code);
  207 + if (null != sch)
  208 + d60.setSch(sch);
  209 +
  210 +
  211 + if (code == 0) {
  212 + dayOfDirectives.put60(d60, true);
  213 + } else {
  214 + d60.setErrorText("网关通讯失败, code: " + code);
  215 + d60Repository.save(d60);
  216 + dayOfDirectives.put60(d60, false);
  217 + }
  218 + return code;
  219 + }
  220 +
  221 + /**
  222 + * 线路切换
  223 + */
  224 + @Override
  225 + public int lineChange(String nbbm, String lineCode, String sender) {
  226 + return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sender);
  227 + }
  228 +
  229 +
  230 + @Override
  231 + public int lineChangeByDeviceId(String deviceId, String lineCode, String sender) {
  232 + DirectiveCreator crt = new DirectiveCreator();
  233 + Long t = System.currentTimeMillis();
  234 + //生成64数据包
  235 + D64 d64 = crt.create64(deviceId, lineCode, t);
  236 +
  237 + if (null != sender)
  238 + d64.setSender(sender);
  239 + else
  240 + d64.setSender("系统");
  241 +
  242 + //String deviceId = d64.getDeviceId();
  243 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(d64));
  244 + // 入库
  245 + d64.setHttpCode(code);
  246 + d64.getData().setTxtContent("切换线路[" + lineCode + "]");
  247 + dayOfDirectives.put64(d64);
  248 +
  249 + // 通知设备刷新线路文件,忽略结果
  250 + if (code == 0)
  251 + GatewayHttpUtils.postJson(crt.createDeviceRefreshData(deviceId, lineCode));
  252 + else
  253 + d64.setErrorText(" 网关通讯失败, code: " + code);
  254 +
  255 + d64Repository.save(d64);
  256 + return code;
  257 + }
  258 +
  259 + public D60 create60Data(String nbbm, String text, Short dispatchInstruct, ScheduleRealInfo sch) {
  260 +
  261 + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  262 + if (null == deviceId) {
  263 + logger.error("没有设备号对照的车辆:" + nbbm);
  264 + return null;
  265 + }
  266 + // 根据当前GPS确定 上下行和营运状态
  267 + Byte upDown = null;
  268 + Integer state = null;
  269 + if (null == sch) {
  270 + GpsEntity gpsData = gpsRealDataBuffer.get(deviceId);
  271 + if (null == gpsData) {
  272 + /*
268 * 短语指令不会变更设备状态,所以在没有gps状态对照的情况下可以下发 273 * 短语指令不会变更设备状态,所以在没有gps状态对照的情况下可以下发
269 * 其他指令在不确定状态的情况下,一律不允许 274 * 其他指令在不确定状态的情况下,一律不允许
270 */ 275 */
271 - if(dispatchInstruct == 0){  
272 - upDown = 0;  
273 - state = 0;  
274 - }  
275 - else{  
276 - logger.error("没有找到gps对照,无法确认营运状态和上下行:" + nbbm);  
277 - return null;  
278 - }  
279 - }  
280 - else{  
281 - upDown = gpsData.getUpDown();  
282 - state = gpsData.getState();  
283 - }  
284 - } else {  
285 - upDown = Byte.parseByte(sch.getXlDir());  
286 - state = 0;  
287 - }  
288 -  
289 - return new DirectiveCreator().createD60(nbbm, text, dispatchInstruct, upDown, state);  
290 - }  
291 -  
292 - @Override  
293 - public int upDownChange(String nbbm, Integer upDown, String sender) {  
294 - return send60Operation(nbbm, 0, upDown, null, sender);  
295 - }  
296 -  
297 -  
298 - @Override  
299 - public Map<String, List<D80>> findNoCofm80(String lineCodes) {  
300 - List<String> lineList = Splitter.on(",").trimResults().splitToList(lineCodes);  
301 -  
302 - Map<String, List<D80>> rs = new HashMap<>();  
303 - for (String code : lineList)  
304 - rs.put(code, pilotReport.unconfirmed80(Integer.parseInt(code)));  
305 -  
306 - return rs;  
307 - }  
308 -  
309 - @Override  
310 - public Map<String, Object> reply80(int id, int reply) {  
311 - Map<String, Object> rs = new HashMap<>();  
312 -  
313 - D80 d80 = pilotReport.findById(id);  
314 - if (null == d80) {  
315 - rs.put("status", ResponseCode.ERROR);  
316 - rs.put("msg", "服务器没有找到对应数据!");  
317 - } else if (d80.isConfirm()) {  
318 - rs.put("status", ResponseCode.ERROR);  
319 - rs.put("msg", "该数据已经被处理了!");  
320 - } else {  
321 - SysUser user = SecurityUtils.getCurrentUser();  
322 - d80.setC0(reply, user.getUserName());  
323 - // 入库  
324 - d80Repository.save(d80);  
325 - //回复网关  
326 - int code = GatewayHttpUtils.postJson(JSON.toJSONString(d80.getC0()));  
327 -  
328 - rs.put("status", ResponseCode.SUCCESS);  
329 - if (code != 0)  
330 - rs.put("msg", "发送C0响应指令到车载设备失败,但该操作已经被系统记录!");  
331 -  
332 - pilotReport.reply(d80);  
333 - // 通知页面  
334 - Map<String, Object> sockMap = new HashMap<>();  
335 - sockMap.put("fn", "d80Confirm");  
336 - sockMap.put("id", d80.getId());  
337 - sockMap.put("lineId", d80.getData().getLineId());  
338 - socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), JSON.toJSONString(sockMap));  
339 - }  
340 -  
341 - return rs;  
342 - }  
343 -  
344 - @Override  
345 - public Map<String, Object> findDirective(String nbbm, int dType, int page, int size) {  
346 - Map<String, Object> rsMap = new HashMap<>();  
347 - List<Directive> list = new ArrayList<>();  
348 -  
349 - switch (dType) {  
350 - case -1:  
351 - //所有指令  
352 - list = new ArrayList<>(dayOfDirectives.all());  
353 - break;  
354 - case 0:  
355 - //调度指令  
356 - Collection<D60> dptArray = dayOfDirectives.all60();  
357 - for(D60 d60 : dptArray){  
358 - if(d60.isDispatch())  
359 - list.add(d60);  
360 - }  
361 - break;  
362 - case 1:  
363 - //运营指令  
364 - Collection<D60> yyArray = dayOfDirectives.all60();  
365 - for(D60 d60 : yyArray){  
366 - if(d60 != null && d60.getData().getDispatchInstruct() == (short)0x03  
367 - && !d60.isDispatch())  
368 - list.add(d60);  
369 - }  
370 - break;  
371 - case 2:  
372 - //线路切换指令  
373 - list.addAll(dayOfDirectives.all64());  
374 - break;  
375 - case 3:  
376 - //消息短语  
377 - Collection<D60> dyArray = dayOfDirectives.all60();  
378 - for(D60 d60 : dyArray){  
379 - if(d60 != null && d60.getData().getDispatchInstruct() == (short)0x00  
380 - && !d60.isDispatch())  
381 - list.add(d60);  
382 - }  
383 - break;  
384 - }  
385 -  
386 - // 时间倒序  
387 - Collections.sort(list, new DayOfDirectives.DComparator());  
388 - if(StringUtils.isNotBlank(nbbm)){  
389 - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
390 - //按车辆过滤  
391 - List<Directive> subList = new ArrayList<>();  
392 - for(Directive d : list){  
393 - if(d.getDeviceId().equals(deviceId)){  
394 - subList.add(d);  
395 - }  
396 - }  
397 - list = subList;  
398 - }  
399 -  
400 - int count = list.size();  
401 - // 分页  
402 - int s = page * size, e = s + size;  
403 -  
404 - if (e > count)  
405 - e = count;  
406 -  
407 - List<Directive> rs = list.subList(s, e);  
408 -  
409 - // 时间格式化,车辆自编号转换  
410 - for (Directive d : rs) {  
411 - if (d.getTimeHHmm() == null)  
412 - d.setTimeHHmm(fmtHHmm.print(d.getTimestamp()));  
413 - if (d.getNbbm() == null)  
414 - d.setNbbm(BasicData.deviceId2NbbmMap.get(d.getDeviceId()));  
415 - }  
416 -  
417 - rsMap.put("list", rs);  
418 - rsMap.put("totalPages", count % size == 0 ? (count / size - 1) : count / size);  
419 - rsMap.put("page", page);  
420 - return rsMap;  
421 - }  
422 -  
423 - @Override  
424 - public Map<String, Object> findAll80(Map<String, Object> map, int page, int size) {  
425 - List<D80> d80s = new ArrayList<>();  
426 -  
427 - Object nbbm = map.get("nbbm");  
428 - if(null != nbbm && StringUtils.isNotEmpty(nbbm.toString())){  
429 - d80s.addAll(pilotReport.findByCar(nbbm.toString()));  
430 - }  
431 - else{  
432 - d80s.addAll(pilotReport.findAll());  
433 - }  
434 -  
435 - Short requestCode = Short.parseShort(map.get("requestCode").toString());  
436 - if(requestCode != -1){  
437 - List<D80> temps = new ArrayList<>();  
438 - for(D80 d80 : d80s){  
439 - if(d80.getData().getRequestCode().equals(requestCode))  
440 - temps.add(d80);  
441 - }  
442 - d80s = temps;  
443 - }  
444 -  
445 - //排序  
446 - Collections.sort(d80s, new Comparator<D80>() {  
447 - @Override  
448 - public int compare(D80 o1, D80 o2) {  
449 - return (int) (o2.getTimestamp() - o1.getTimestamp());  
450 - }  
451 - });  
452 -  
453 - //分页  
454 - int count = d80s.size();  
455 - // 分页  
456 - int s = page * size, e = s + size;  
457 -  
458 - if (e > count)  
459 - e = count;  
460 -  
461 - //SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm");  
462 - List<D80> rs = d80s.subList(s, e);  
463 - for(D80 d80 : rs){  
464 - d80.setTimeStr(fmtHHmm.print(d80.getTimestamp()));  
465 - }  
466 -  
467 - Map<String, Object> rsMap = new HashMap<>();  
468 - rsMap.put("list", rs);  
469 - rsMap.put("totalPages", count % size == 0 ? count / size -1 : count / size);  
470 - rsMap.put("page", page);  
471 -  
472 - return rsMap;  
473 - }  
474 -  
475 - @Override  
476 - public D64 save64(D64 d64) {  
477 - return d64Repository.save(d64);  
478 - }  
479 -  
480 - @Override  
481 - public int sendC0A4(String nbbm) {  
482 - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
483 -  
484 - Map<String, Object> c0a4 = new HashMap<>();  
485 - c0a4.put("deviceId", deviceId);  
486 - c0a4.put("timestamp", System.currentTimeMillis());  
487 - c0a4.put("operCode", (short)0xC0);  
488 -  
489 - Map<String, Object> data = new HashMap<>();  
490 - data.put("deviceId", deviceId);  
491 - data.put("operCode2", (short)0xA4);  
492 - c0a4.put("data", data);  
493 -  
494 - return GatewayHttpUtils.postJson(JSON.toJSONString(c0a4));  
495 - }  
496 -  
497 - @Override  
498 - public int sendC0A3(DC0_A3 c0a3) {  
499 - GatewayHttpUtils.postJson(JSON.toJSONString(c0a3));  
500 - return 0;  
501 - }  
502 -  
503 - @Override  
504 - public int sendC0A5(String json) {  
505 - return GatewayHttpUtils.postJson(json);  
506 - }  
507 -  
508 - @Override  
509 - public int refreshLineFile(String deviceId) {  
510 - GpsEntity gps = gpsRealDataBuffer.get(deviceId);  
511 - if(gps == null)  
512 - return -1;  
513 -  
514 - return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId()));  
515 - }  
516 -  
517 - @Override  
518 - public int stateChange(String nbbm, Integer upDown, Integer state, String userName) {  
519 - return send60Operation(nbbm, state, upDown, null, userName);  
520 - } 276 + if (dispatchInstruct == 0) {
  277 + upDown = 0;
  278 + state = 0;
  279 + } else {
  280 + logger.error("没有找到gps对照,无法确认营运状态和上下行:" + nbbm);
  281 + return null;
  282 + }
  283 + } else {
  284 + upDown = gpsData.getUpDown();
  285 + state = gpsData.getState();
  286 + }
  287 + } else {
  288 + upDown = Byte.parseByte(sch.getXlDir());
  289 + state = 0;
  290 + }
  291 +
  292 + return new DirectiveCreator().createD60(nbbm, text, dispatchInstruct, upDown, state);
  293 + }
  294 +
  295 + @Override
  296 + public int upDownChange(String nbbm, Integer upDown, String sender) {
  297 + return send60Operation(nbbm, 0, upDown, null, sender);
  298 + }
  299 +
  300 +
  301 + @Override
  302 + public Map<String, List<D80>> findNoCofm80(String lineCodes) {
  303 + List<String> lineList = Splitter.on(",").trimResults().splitToList(lineCodes);
  304 +
  305 + Map<String, List<D80>> rs = new HashMap<>();
  306 + for (String code : lineList)
  307 + rs.put(code, pilotReport.unconfirmed80(Integer.parseInt(code)));
  308 +
  309 + return rs;
  310 + }
  311 +
  312 + @Override
  313 + public Map<String, Object> reply80(int id, int reply) {
  314 + Map<String, Object> rs = new HashMap<>();
  315 + D80 d80 = pilotReport.findById(id);
  316 + try {
  317 + if (null == d80) {
  318 + rs.put("status", ResponseCode.ERROR);
  319 + rs.put("msg", "服务器没有找到对应数据!");
  320 + } else if (d80.isConfirm()) {
  321 + rs.put("status", ResponseCode.ERROR);
  322 + rs.put("msg", "该数据已经被处理了!");
  323 + } else {
  324 + SysUser user = SecurityUtils.getCurrentUser();
  325 + d80.setC0(reply, user.getUserName());
  326 + // 入库
  327 + d80Repository.save(d80);
  328 + //回复网关
  329 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(d80.getC0()));
  330 +
  331 + rs.put("status", ResponseCode.SUCCESS);
  332 + if (code != 0)
  333 + rs.put("msg", "发送C0响应指令到车载设备失败,但该操作已经被系统记录!");
  334 +
  335 + pilotReport.reply(d80);
  336 + }
  337 + } catch (Exception e) {
  338 + logger.error("80响应出现异常...", e);
  339 + rs.put("status", ResponseCode.SUCCESS);
  340 + }
  341 + // 通知页面
  342 + Map<String, Object> sockMap = new HashMap<>();
  343 + sockMap.put("fn", "d80Confirm");
  344 + sockMap.put("id", d80.getId());
  345 + sockMap.put("lineId", d80.getData().getLineId());
  346 + socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), JSON.toJSONString(sockMap));
  347 +
  348 + return rs;
  349 + }
  350 +
  351 + @Override
  352 + public Map<String, Object> findDirective(String nbbm, int dType, int page, int size) {
  353 + Map<String, Object> rsMap = new HashMap<>();
  354 + List<Directive> list = new ArrayList<>();
  355 +
  356 + switch (dType) {
  357 + case -1:
  358 + //所有指令
  359 + list = new ArrayList<>(dayOfDirectives.all());
  360 + break;
  361 + case 0:
  362 + //调度指令
  363 + Collection<D60> dptArray = dayOfDirectives.all60();
  364 + for (D60 d60 : dptArray) {
  365 + if (d60.isDispatch())
  366 + list.add(d60);
  367 + }
  368 + break;
  369 + case 1:
  370 + //运营指令
  371 + Collection<D60> yyArray = dayOfDirectives.all60();
  372 + for (D60 d60 : yyArray) {
  373 + if (d60 != null && d60.getData().getDispatchInstruct() == (short) 0x03
  374 + && !d60.isDispatch())
  375 + list.add(d60);
  376 + }
  377 + break;
  378 + case 2:
  379 + //线路切换指令
  380 + list.addAll(dayOfDirectives.all64());
  381 + break;
  382 + case 3:
  383 + //消息短语
  384 + Collection<D60> dyArray = dayOfDirectives.all60();
  385 + for (D60 d60 : dyArray) {
  386 + if (d60 != null && d60.getData().getDispatchInstruct() == (short) 0x00
  387 + && !d60.isDispatch())
  388 + list.add(d60);
  389 + }
  390 + break;
  391 + }
  392 +
  393 + // 时间倒序
  394 + Collections.sort(list, new DayOfDirectives.DComparator());
  395 + if (StringUtils.isNotBlank(nbbm)) {
  396 + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  397 + //按车辆过滤
  398 + List<Directive> subList = new ArrayList<>();
  399 + for (Directive d : list) {
  400 + if (d.getDeviceId().equals(deviceId)) {
  401 + subList.add(d);
  402 + }
  403 + }
  404 + list = subList;
  405 + }
  406 +
  407 + int count = list.size();
  408 + // 分页
  409 + int s = page * size, e = s + size;
  410 +
  411 + if (e > count)
  412 + e = count;
  413 +
  414 + List<Directive> rs = list.subList(s, e);
  415 +
  416 + // 时间格式化,车辆自编号转换
  417 + for (Directive d : rs) {
  418 + if (d.getTimeHHmm() == null)
  419 + d.setTimeHHmm(fmtHHmm.print(d.getTimestamp()));
  420 + if (d.getNbbm() == null)
  421 + d.setNbbm(BasicData.deviceId2NbbmMap.get(d.getDeviceId()));
  422 + }
  423 +
  424 + rsMap.put("list", rs);
  425 + rsMap.put("totalPages", count % size == 0 ? (count / size - 1) : count / size);
  426 + rsMap.put("page", page);
  427 + return rsMap;
  428 + }
  429 +
  430 + @Override
  431 + public Map<String, Object> findAll80(Map<String, Object> map, int page, int size) {
  432 + List<D80> d80s = new ArrayList<>();
  433 +
  434 + Object nbbm = map.get("nbbm");
  435 + if (null != nbbm && StringUtils.isNotEmpty(nbbm.toString())) {
  436 + d80s.addAll(pilotReport.findByCar(nbbm.toString()));
  437 + } else {
  438 + d80s.addAll(pilotReport.findAll());
  439 + }
  440 +
  441 + Short requestCode = Short.parseShort(map.get("requestCode").toString());
  442 + if (requestCode != -1) {
  443 + List<D80> temps = new ArrayList<>();
  444 + for (D80 d80 : d80s) {
  445 + if (d80.getData().getRequestCode().equals(requestCode))
  446 + temps.add(d80);
  447 + }
  448 + d80s = temps;
  449 + }
  450 +
  451 + //排序
  452 + Collections.sort(d80s, new Comparator<D80>() {
  453 + @Override
  454 + public int compare(D80 o1, D80 o2) {
  455 + return (int) (o2.getTimestamp() - o1.getTimestamp());
  456 + }
  457 + });
  458 +
  459 + //分页
  460 + int count = d80s.size();
  461 + // 分页
  462 + int s = page * size, e = s + size;
  463 +
  464 + if (e > count)
  465 + e = count;
  466 +
  467 + //SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm");
  468 + List<D80> rs = d80s.subList(s, e);
  469 + for (D80 d80 : rs) {
  470 + d80.setTimeStr(fmtHHmm.print(d80.getTimestamp()));
  471 + }
  472 +
  473 + Map<String, Object> rsMap = new HashMap<>();
  474 + rsMap.put("list", rs);
  475 + rsMap.put("totalPages", count % size == 0 ? count / size - 1 : count / size);
  476 + rsMap.put("page", page);
  477 +
  478 + return rsMap;
  479 + }
  480 +
  481 + @Override
  482 + public D64 save64(D64 d64) {
  483 + return d64Repository.save(d64);
  484 + }
  485 +
  486 + @Override
  487 + public Map<String, Object> sendC0A4(String nbbm) {
  488 + Map<String, Object> rs = new HashMap<>();
  489 +
  490 + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  491 +
  492 + GpsEntity gps = gpsRealDataBuffer.get(deviceId);
  493 + if(gps == null || gps.isOffline()){
  494 + rs.put("status", ResponseCode.ERROR);
  495 + rs.put("msg", "下发指令失败,设备离线");
  496 + return rs;
  497 + }
  498 +
  499 + Map<String, Object> c0a4 = new HashMap<>();
  500 + c0a4.put("deviceId", deviceId);
  501 + c0a4.put("timestamp", System.currentTimeMillis());
  502 + c0a4.put("operCode", (short) 0xC0);
  503 +
  504 + Map<String, Object> data = new HashMap<>();
  505 + data.put("deviceId", deviceId);
  506 + data.put("operCode2", (short) 0xA4);
  507 + c0a4.put("data", data);
  508 +
  509 + int code = GatewayHttpUtils.postJson(JSON.toJSONString(c0a4));
  510 + if(code != 0){
  511 + rs.put("status", ResponseCode.ERROR);
  512 + rs.put("msg", "和网关通讯失败, code " + code);
  513 + }
  514 + else{
  515 + rs.put("status", ResponseCode.SUCCESS);
  516 + }
  517 + return rs;
  518 + }
  519 +
  520 + @Override
  521 + public int sendC0A3(DC0_A3 c0a3) {
  522 + GatewayHttpUtils.postJson(JSON.toJSONString(c0a3));
  523 + return 0;
  524 + }
  525 +
  526 + @Override
  527 + public int sendC0A5(String json) {
  528 + return GatewayHttpUtils.postJson(json);
  529 + }
  530 +
  531 + @Override
  532 + public int refreshLineFile(String deviceId) {
  533 + GpsEntity gps = gpsRealDataBuffer.get(deviceId);
  534 + if (gps == null)
  535 + return -1;
  536 +
  537 + return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId()));
  538 + }
  539 +
  540 + @Override
  541 + public int stateChange(String nbbm, Integer upDown, Integer state, String userName) {
  542 + return send60Operation(nbbm, state, upDown, null, userName);
  543 + }
  544 +
  545 + @Override
  546 + public Map<String, Object> deviceCofigList(Map<String, String> map, int page, int size) {
  547 + Map<String, Object> rs = new HashMap<>();
  548 + try {
  549 + String conts="";
  550 + if(StringUtils.isNotBlank(map.get("lineId"))){
  551 + conts+=" AND xl='" + map.get("lineId")+"'";
  552 + }
  553 + if(StringUtils.isNotBlank(map.get("nbbm"))){
  554 + conts+=" AND inside_code like '%" + map.get("nbbm")+"%'";
  555 + }
  556 + if(StringUtils.isNotBlank(map.get("deviceId"))){
  557 + conts+=" AND equipment_code like '%" + map.get("deviceId")+"%'";
  558 + }
  559 +
  560 + String sql = "select * from (SELECT * FROM (SELECT id AS cl_id,inside_code,equipment_code FROM bsth_c_cars ) t1 LEFT JOIN bsth_v_c0_a4 t2 ON t1.equipment_code = t2.id LEFT JOIN (SELECT xl,cl FROM bsth_c_s_ccinfo WHERE id IN (SELECT max(id) FROM bsth_c_s_ccinfo GROUP BY cl)) t3 ON t1.cl_id = t3.cl ORDER BY t2.`timestamp` DESC) t4 where 1=1 "+conts;
  561 +
  562 + int count = jdbcTemplate.queryForObject("select count(*) from ("+sql+") c1", Integer.class);
  563 + int totalPages = count % size == 0 ? count / size : count / size + 1;
  564 + int s = page * size;
  565 + List<DeviceConfigDto> list = jdbcTemplate.query(sql + " LIMIT " + s + "," + size, new BeanPropertyRowMapper<>(DeviceConfigDto.class));
  566 +
  567 + rs.put("status", ResponseCode.SUCCESS);
  568 + rs.put("list", list);
  569 + rs.put("totalPages", totalPages);
  570 + rs.put("page", page);
  571 + } catch (Exception e) {
  572 + e.printStackTrace();
  573 + logger.error("", e);
  574 + rs.put("status", ResponseCode.ERROR);
  575 + }
  576 + return rs;
  577 + }
521 } 578 }
src/main/java/com/bsth/service/directive/dto/DeviceConfigDto.java 0 → 100644
  1 +package com.bsth.service.directive.dto;
  2 +
  3 +/**
  4 + * Created by panzhao on 2017/6/28.
  5 + */
  6 +public class DeviceConfigDto {
  7 +
  8 + private String xl;
  9 + private String id;
  10 + private String insideCode;
  11 + private String equipmentCode;
  12 + /** 网关IP地址 */
  13 + private String ipAddress;
  14 + /** 网关端口 */
  15 + private Integer port;
  16 + /** 定时定距上报模式 */
  17 + private Short reportMode;
  18 + /** 定时上报时间间隔 */
  19 + private Integer interval;
  20 + /** 定距上报距离间隔 */
  21 + private String distance;
  22 + /** 非线路状态超速阀门 */
  23 + private Short speedingThreshold;
  24 + /** 预警阀门 */
  25 + private Short alarmThreshold;
  26 + /** pos机IP地址 */
  27 + private String posIpAddress;
  28 + /** pos机端口 */
  29 + private String posPort;
  30 + /** 延迟机关时间 */
  31 + private Integer delay;
  32 + /** 中门视频切换到码表界面速度阀门 默认45 */
  33 + private Short speedThreshold1;
  34 + /** 码表界面切换到中门视频速度阀门 默认35 */
  35 + private Short speedThreshold2;
  36 + /** 对比度 */
  37 + private Short contrast;
  38 + /** 亮度 */
  39 + private Short brightness;
  40 + /** 饱和度 */
  41 + private Short saturation;
  42 +
  43 + private Long timestamp;
  44 +
  45 + public String getId() {
  46 + return id;
  47 + }
  48 +
  49 + public void setId(String id) {
  50 + this.id = id;
  51 + }
  52 +
  53 + public String getEquipmentCode() {
  54 + return equipmentCode;
  55 + }
  56 +
  57 + public void setEquipmentCode(String equipmentCode) {
  58 + this.equipmentCode = equipmentCode;
  59 + }
  60 +
  61 + public String getIpAddress() {
  62 + return ipAddress;
  63 + }
  64 +
  65 + public void setIpAddress(String ipAddress) {
  66 + this.ipAddress = ipAddress;
  67 + }
  68 +
  69 + public Integer getPort() {
  70 + return port;
  71 + }
  72 +
  73 + public void setPort(Integer port) {
  74 + this.port = port;
  75 + }
  76 +
  77 + public Short getReportMode() {
  78 + return reportMode;
  79 + }
  80 +
  81 + public void setReportMode(Short reportMode) {
  82 + this.reportMode = reportMode;
  83 + }
  84 +
  85 + public Integer getInterval() {
  86 + return interval;
  87 + }
  88 +
  89 + public void setInterval(Integer interval) {
  90 + this.interval = interval;
  91 + }
  92 +
  93 + public String getDistance() {
  94 + return distance;
  95 + }
  96 +
  97 + public void setDistance(String distance) {
  98 + this.distance = distance;
  99 + }
  100 +
  101 + public Short getSpeedingThreshold() {
  102 + return speedingThreshold;
  103 + }
  104 +
  105 + public void setSpeedingThreshold(Short speedingThreshold) {
  106 + this.speedingThreshold = speedingThreshold;
  107 + }
  108 +
  109 + public Short getAlarmThreshold() {
  110 + return alarmThreshold;
  111 + }
  112 +
  113 + public void setAlarmThreshold(Short alarmThreshold) {
  114 + this.alarmThreshold = alarmThreshold;
  115 + }
  116 +
  117 + public String getPosIpAddress() {
  118 + return posIpAddress;
  119 + }
  120 +
  121 + public void setPosIpAddress(String posIpAddress) {
  122 + this.posIpAddress = posIpAddress;
  123 + }
  124 +
  125 + public String getPosPort() {
  126 + return posPort;
  127 + }
  128 +
  129 + public void setPosPort(String posPort) {
  130 + this.posPort = posPort;
  131 + }
  132 +
  133 + public Integer getDelay() {
  134 + return delay;
  135 + }
  136 +
  137 + public void setDelay(Integer delay) {
  138 + this.delay = delay;
  139 + }
  140 +
  141 + public Short getSpeedThreshold1() {
  142 + return speedThreshold1;
  143 + }
  144 +
  145 + public void setSpeedThreshold1(Short speedThreshold1) {
  146 + this.speedThreshold1 = speedThreshold1;
  147 + }
  148 +
  149 + public Short getSpeedThreshold2() {
  150 + return speedThreshold2;
  151 + }
  152 +
  153 + public void setSpeedThreshold2(Short speedThreshold2) {
  154 + this.speedThreshold2 = speedThreshold2;
  155 + }
  156 +
  157 + public Short getContrast() {
  158 + return contrast;
  159 + }
  160 +
  161 + public void setContrast(Short contrast) {
  162 + this.contrast = contrast;
  163 + }
  164 +
  165 + public Short getBrightness() {
  166 + return brightness;
  167 + }
  168 +
  169 + public void setBrightness(Short brightness) {
  170 + this.brightness = brightness;
  171 + }
  172 +
  173 + public Short getSaturation() {
  174 + return saturation;
  175 + }
  176 +
  177 + public void setSaturation(Short saturation) {
  178 + this.saturation = saturation;
  179 + }
  180 +
  181 + public Long getTimestamp() {
  182 + return timestamp;
  183 + }
  184 +
  185 + public void setTimestamp(Long timestamp) {
  186 + this.timestamp = timestamp;
  187 + }
  188 +
  189 + public String getInsideCode() {
  190 + return insideCode;
  191 + }
  192 +
  193 + public void setInsideCode(String insideCode) {
  194 + this.insideCode = insideCode;
  195 + }
  196 +
  197 + public String getXl() {
  198 + return xl;
  199 + }
  200 +
  201 + public void setXl(String xl) {
  202 + this.xl = xl;
  203 + }
  204 +}
src/main/java/com/bsth/service/excep/impl/OutboundServiceImpl.java
@@ -69,8 +69,8 @@ public class OutboundServiceImpl implements OutboundService{ @@ -69,8 +69,8 @@ public class OutboundServiceImpl implements OutboundService{
69 } 69 }
70 70
71 } 71 }
72 - sql +=" limit ?,?";  
73 - 72 + // sql +=" order by id limit ?,?";
  73 + sql +=" order by timestamp limit ?,?";
74 74
75 try { 75 try {
76 conn = DBUtils_MS.getConnection(); 76 conn = DBUtils_MS.getConnection();
@@ -95,15 +95,15 @@ public class OutboundServiceImpl implements OutboundService{ @@ -95,15 +95,15 @@ public class OutboundServiceImpl implements OutboundService{
95 Outbound outbound; 95 Outbound outbound;
96 while(rs.next()){ 96 while(rs.next()){
97 outbound=new Outbound(); 97 outbound=new Outbound();
98 - outbound.setId(Integer.valueOf(rs.getObject("id").toString()));  
99 - outbound.setLat(Float.valueOf(rs.getObject("lat").toString())); 98 + // outbound.setId(Integer.valueOf(rs.getObject("id").toString()));
100 outbound.setLine(Integer.valueOf(rs.getObject("line").toString())); 99 outbound.setLine(Integer.valueOf(rs.getObject("line").toString()));
  100 + outbound.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));
  101 + outbound.setLon(Float.valueOf(rs.getObject("lon").toString()));
  102 + outbound.setLat(Float.valueOf(rs.getObject("lat").toString()));
101 //run 时注解 103 //run 时注解
102 outbound.setLineName(BasicData.lineCode2NameMap.get(outbound.getLine().toString())); 104 outbound.setLineName(BasicData.lineCode2NameMap.get(outbound.getLine().toString()));
103 - outbound.setLon(Float.valueOf(rs.getObject("lon").toString()));  
104 outbound.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString()))); 105 outbound.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString())));
105 outbound.setTimestampDate(sdf.format(new Date(outbound.getTimestamp()))); 106 outbound.setTimestampDate(sdf.format(new Date(outbound.getTimestamp())));
106 - outbound.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));  
107 outbound.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString())); 107 outbound.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString()));
108 // outbound.setLocation(rs.getObject("location")==null?"":rs.getObject("location").toString()); 108 // outbound.setLocation(rs.getObject("location")==null?"":rs.getObject("location").toString());
109 list.add(outbound); 109 list.add(outbound);
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
@@ -43,8 +43,10 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -43,8 +43,10 @@ public class SpeedingServiceImpl implements SpeedingService {
43 Object line=map.get("line"); 43 Object line=map.get("line");
44 Object nbbm=map.get("nbbm"); 44 Object nbbm=map.get("nbbm");
45 Object updown=map.get("updown"); 45 Object updown=map.get("updown");
46 - Object date=map.get("date");  
47 - 46 + Object startDate=map.get("startDate");
  47 + Object endDate=map.get("endDate");
  48 +
  49 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
48 if(line!=null){ 50 if(line!=null){
49 sql +=" and line like'%"+line.toString().trim()+"%'"; 51 sql +=" and line like'%"+line.toString().trim()+"%'";
50 } 52 }
@@ -58,15 +60,23 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -58,15 +60,23 @@ public class SpeedingServiceImpl implements SpeedingService {
58 if(updown!=null){ 60 if(updown!=null){
59 sql +="and up_down like '%"+updown.toString()+"%'"; 61 sql +="and up_down like '%"+updown.toString()+"%'";
60 } 62 }
61 - if(date!=null){  
62 - if (date.toString().length()>0) {  
63 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 63 + if(startDate!=null){
  64 + if (startDate.toString().length()>0) {
64 try { 65 try {
65 - Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();  
66 - Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();  
67 - sql += " and timestamp >="+t1 +" and timestamp <="+t2; 66 + Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
  67 + sql += " and timestamp >="+t1;
  68 + } catch (ParseException e) {
  69 + e.printStackTrace();
  70 + }
  71 + }
  72 +
  73 + }
  74 + if(endDate!=null){
  75 + if (endDate.toString().length()>0) {
  76 + try {
  77 + Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
  78 + sql += " and timestamp <="+t2;
68 } catch (ParseException e) { 79 } catch (ParseException e) {
69 - // TODO Auto-generated catch block  
70 e.printStackTrace(); 80 e.printStackTrace();
71 } 81 }
72 } 82 }
@@ -74,18 +84,17 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -74,18 +84,17 @@ public class SpeedingServiceImpl implements SpeedingService {
74 } 84 }
75 85
76 86
77 - sql +=" order by id limit ?,?"; 87 + /*sql +=" order by id limit ?,?";*/
78 88
79 89
80 try { 90 try {
81 conn = DBUtils_MS.getConnection(); 91 conn = DBUtils_MS.getConnection();
82 ps = conn.prepareStatement(sql); 92 ps = conn.prepareStatement(sql);
83 - ps.setInt(1, page*10); // O-最大条数 -- M-起始条数 93 + /* ps.setInt(1, page*10); // O-最大条数 -- M-起始条数
84 ps.setInt(2, 10); // O-最小条数 -- M-显示条数 94 ps.setInt(2, 10); // O-最小条数 -- M-显示条数
85 - rs = ps.executeQuery(); 95 +*/ rs = ps.executeQuery();
86 list = resultSet2Set(rs); 96 list = resultSet2Set(rs);
87 } catch (SQLException e) { 97 } catch (SQLException e) {
88 - // TODO Auto-generated catch block  
89 e.printStackTrace(); 98 e.printStackTrace();
90 }finally { 99 }finally {
91 DBUtils_MS.close(rs, ps, conn); 100 DBUtils_MS.close(rs, ps, conn);
@@ -106,6 +115,7 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -106,6 +115,7 @@ public class SpeedingServiceImpl implements SpeedingService {
106 //run 时注解 115 //run 时注解
107 speeding.setLineName(BasicData.lineCode2NameMap.get(speeding.getLine().toString())); 116 speeding.setLineName(BasicData.lineCode2NameMap.get(speeding.getLine().toString()));
108 speeding.setLon(Float.valueOf(rs.getObject("lon").toString())); 117 speeding.setLon(Float.valueOf(rs.getObject("lon").toString()));
  118 + speeding.setSpeed(Float.valueOf(rs.getObject("speed").toString()));
109 speeding.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString()))); 119 speeding.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString())));
110 speeding.setTimestampDate(sdf.format(new Date(speeding.getTimestamp()))); 120 speeding.setTimestampDate(sdf.format(new Date(speeding.getTimestamp())));
111 speeding.setUpDown(Integer.valueOf(rs.getObject("up_down").toString())); 121 speeding.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));
@@ -114,16 +124,18 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -114,16 +124,18 @@ public class SpeedingServiceImpl implements SpeedingService {
114 } 124 }
115 return list; 125 return list;
116 } 126 }
  127 +
117 @Override 128 @Override
118 public PageObject<Speeding> Pagequery(Map<String, Object> map) { 129 public PageObject<Speeding> Pagequery(Map<String, Object> map) {
119 - // TODO Auto-generated method stub  
120 String sql="select count(*) record from bsth_c_speeding where 1=1 "; 130 String sql="select count(*) record from bsth_c_speeding where 1=1 ";
121 Object line=map.get("line"); 131 Object line=map.get("line");
122 Object nbbm=map.get("nbbm"); 132 Object nbbm=map.get("nbbm");
123 Object updown=map.get("updown"); 133 Object updown=map.get("updown");
  134 + Object startDate=map.get("startDate");
  135 + Object endDate=map.get("endDate");
  136 + //时间转换
  137 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
124 138
125 - Object date=map.get("date");  
126 -  
127 if(line!=null){ 139 if(line!=null){
128 sql +=" and line like'%"+line.toString().trim()+"%'"; 140 sql +=" and line like'%"+line.toString().trim()+"%'";
129 } 141 }
@@ -136,15 +148,23 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -136,15 +148,23 @@ public class SpeedingServiceImpl implements SpeedingService {
136 if(updown!=null){ 148 if(updown!=null){
137 sql +="and up_down like '%"+updown.toString()+"%'"; 149 sql +="and up_down like '%"+updown.toString()+"%'";
138 } 150 }
139 - if(date!=null){  
140 - if (date.toString().length()>0) {  
141 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS"); 151 + if(startDate!=null){
  152 + if (startDate.toString().length()>0) {
142 try { 153 try {
143 - Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();  
144 - Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();  
145 - sql += " and timestamp >="+t1 +" and timestamp <="+t2; 154 + Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
  155 + sql += " and timestamp >="+t1;
  156 + } catch (ParseException e) {
  157 + e.printStackTrace();
  158 + }
  159 + }
  160 +
  161 + }
  162 + if(endDate!=null){
  163 + if (endDate.toString().length()>0) {
  164 + try {
  165 + Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
  166 + sql += " and timestamp <="+t2;
146 } catch (ParseException e) { 167 } catch (ParseException e) {
147 - // TODO Auto-generated catch block  
148 e.printStackTrace(); 168 e.printStackTrace();
149 } 169 }
150 } 170 }
@@ -163,49 +183,68 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -163,49 +183,68 @@ public class SpeedingServiceImpl implements SpeedingService {
163 totalData=rs.getInt("record"); 183 totalData=rs.getInt("record");
164 } 184 }
165 } catch (SQLException e) { 185 } catch (SQLException e) {
166 - // TODO Auto-generated catch block  
167 e.printStackTrace(); 186 e.printStackTrace();
168 }finally { 187 }finally {
169 DBUtils_MS.close(rs, ps, conn); 188 DBUtils_MS.close(rs, ps, conn);
170 } 189 }
171 190
172 - PageHelper pageHelper = new PageHelper(totalData, map);  
173 - List<Speeding> list=findAll(pageHelper.getMap());  
174 - for (int i = 0; i < list.size(); i++) {  
175 - String nbbm2=list.get(i).getVehicle() ;  
176 - Long d1=list.get(i).getTimestamp();  
177 - Date datess = new Date(d1);  
178 - String dates=new SimpleDateFormat("yyyy-MM-dd").format(datess);  
179 - String sk=new SimpleDateFormat("HH:mm").format(datess);  
180 - String sqlPbb="SELECT * FROM ( select lp_name,cl_zbh,j_gh,j_name,MIN(fcsj) as fcsj,MAX(zdsj) as ddsj"  
181 - + " from bsth_c_s_sp_info_real where cl_zbh='"+nbbm2+"' and"  
182 - + " real_exec_date='"+dates+"' GROUP BY cl_zbh,lp_name,j_gh,j_name ) t WHERE t.fcsj<='"+sk+"' AND t.ddsj>='"+sk+"' " ;  
183 - List<ScheduleRealInfo> pbb =jdbcTemplate.query(sqlPbb,  
184 - new RowMapper<ScheduleRealInfo>(){  
185 - @Override  
186 - public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {  
187 - ScheduleRealInfo s = new ScheduleRealInfo();  
188 - s.setjGh(rs.getString("j_gh"));  
189 - s.setjName(rs.getString("j_name"));  
190 - s.setLpName(rs.getString("lp_name"));  
191 - return s;  
192 - }  
193 - });  
194 - if(pbb.size()>0){  
195 - list.get(i).setJsy(pbb.get(0).getjGh()+"/"+pbb.get(0).getjName());  
196 - list.get(i).setLpname(pbb.get(0).getLpName());  
197 - 191 + List<Speeding> list=findAll(map);
  192 + List<Speeding> listResult = new ArrayList<Speeding>();
  193 + int curPage;//页码
  194 + int pageData;//每页的记录条数
  195 + int start;//起始数据下标
  196 + int totalPage;//总页数
  197 + if(list.size()>1){
  198 + Speeding speedingNow;//下标为i的车
  199 + Speeding speedingLast;//下标为i-1的车
  200 + String strNow;
  201 + String strLast;
  202 + for(int i = 1;i<list.size();i++){
  203 + speedingNow = list.get(i);
  204 + speedingLast = list.get(i-1);
  205 + strNow = speedingNow.getVehicle()+speedingNow.getLine()+speedingNow.getUpDown();//同一车辆同一线路同一方向
  206 + strLast = speedingLast.getVehicle()+speedingLast.getLine()+speedingLast.getUpDown();
  207 + //同一车辆同一线路同一方向并且该记录的超速的开始时间减去上一条超速记录的结束时间小于等于10s,证明该车超速。//PS:祛除数据库中的重复发送数据
  208 + if(strNow.equals(strLast) && Math.abs(speedingNow.getTimestamp()-speedingLast.getTimestamp())<=10*1000 && (speedingNow.getTimestamp()-speedingLast.getTimestamp()!=0)){
  209 + speedingLast.setEndtimestamp(speedingNow.getTimestamp());
  210 + speedingLast.setEndtimestampDate(sdf.format(new Date(speedingNow.getTimestamp())));//设置结束时间
  211 + listResult.add(speedingLast);
  212 + }
198 } 213 }
199 214
  215 + totalData = listResult.size();//总记录条数。
  216 + if(map.get("curPage") == null || map.get("curPage").equals("0")){
  217 + curPage = 0;
  218 + }else{
  219 + curPage = Integer.parseInt((String) map.get("curPage"));
  220 + }
  221 + pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
  222 + start = (curPage - 0) * pageData; //起始记录下标。
  223 + totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数
  224 + if(curPage == totalPage-1){//如果当前页等于总页数。
  225 + listResult = listResult.subList(start, totalData);
  226 + }else{
  227 + listResult = listResult.subList(start, start+pageData);
  228 + }
  229 + }else{
  230 + curPage = 1;
  231 + pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
  232 + totalPage =1;
200 } 233 }
  234 + Map<String,Object> paramMap = new HashMap<String,Object>();
  235 + paramMap.put("totalPage", totalPage);
  236 + paramMap.put("curPage", curPage);
  237 + paramMap.put("pageData", pageData);
  238 + PageHelper pageHelper = new PageHelper(totalData, paramMap);
  239 + pageHelper.getMap();
201 PageObject<Speeding> pageObject = pageHelper.getPageObject(); 240 PageObject<Speeding> pageObject = pageHelper.getPageObject();
202 - pageObject.setDataList(list); 241 + pageObject.setDataList(listResult);
203 return pageObject; 242 return pageObject;
204 } 243 }
205 - 244 +
  245 +
206 @Override 246 @Override
207 public Map<String, Object> getReport(Map<String, Object> map) { 247 public Map<String, Object> getReport(Map<String, Object> map) {
208 - // TODO Auto-generated method stub  
209 String chartStr = ""; 248 String chartStr = "";
210 Map<String, Object> mapValue = new HashMap<String, Object>(); 249 Map<String, Object> mapValue = new HashMap<String, Object>();
211 try { 250 try {
@@ -309,10 +348,8 @@ public class SpeedingServiceImpl implements SpeedingService { @@ -309,10 +348,8 @@ public class SpeedingServiceImpl implements SpeedingService {
309 } 348 }
310 349
311 } catch (SQLException e) { 350 } catch (SQLException e) {
312 - // TODO Auto-generated catch block  
313 e.printStackTrace(); 351 e.printStackTrace();
314 }catch (ParseException e1) { 352 }catch (ParseException e1) {
315 - // TODO Auto-generated catch block  
316 e1.printStackTrace(); 353 e1.printStackTrace();
317 }finally { 354 }finally {
318 DBUtils_MS.close(rs, ps, conn); 355 DBUtils_MS.close(rs, ps, conn);
src/main/java/com/bsth/service/gps/GpsService.java
@@ -3,6 +3,7 @@ package com.bsth.service.gps; @@ -3,6 +3,7 @@ package com.bsth.service.gps;
3 import com.bsth.service.gps.entity.GpsOutbound_DTO; 3 import com.bsth.service.gps.entity.GpsOutbound_DTO;
4 import com.bsth.service.gps.entity.GpsSpeed_DTO; 4 import com.bsth.service.gps.entity.GpsSpeed_DTO;
5 5
  6 +import javax.servlet.http.HttpServletResponse;
6 import java.util.List; 7 import java.util.List;
7 import java.util.Map; 8 import java.util.Map;
8 9
@@ -29,4 +30,12 @@ public interface GpsService { @@ -29,4 +30,12 @@ public interface GpsService {
29 List<GpsOutbound_DTO> outbounds(String nbbm, long st, long et); 30 List<GpsOutbound_DTO> outbounds(String nbbm, long st, long et);
30 31
31 Map<String, Object> safeDrivList(Map<String, Object> map, int page, int size, String order, String direction); 32 Map<String, Object> safeDrivList(Map<String, Object> map, int page, int size, String order, String direction);
  33 +
  34 + Map<String,Object> history_v3(String nbbm, long st, long et);
  35 +
  36 + void trailExcel(String nbbm, long st, long et, HttpServletResponse resp);
  37 +
  38 + void abnormalExcel(String nbbm, long st, long et, HttpServletResponse resp);
  39 +
  40 + void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp);
32 } 41 }
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
@@ -5,6 +5,7 @@ import com.bsth.data.BasicData; @@ -5,6 +5,7 @@ import com.bsth.data.BasicData;
5 import com.bsth.data.forecast.entity.ArrivalEntity; 5 import com.bsth.data.forecast.entity.ArrivalEntity;
6 import com.bsth.data.gpsdata.GpsEntity; 6 import com.bsth.data.gpsdata.GpsEntity;
7 import com.bsth.data.gpsdata.GpsRealData; 7 import com.bsth.data.gpsdata.GpsRealData;
  8 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
8 import com.bsth.data.gpsdata.arrival.utils.GeoUtils; 9 import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
9 import com.bsth.data.safe_driv.SafeDriv; 10 import com.bsth.data.safe_driv.SafeDriv;
10 import com.bsth.data.safe_driv.SafeDrivCenter; 11 import com.bsth.data.safe_driv.SafeDrivCenter;
@@ -13,15 +14,20 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; @@ -13,15 +14,20 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo;
13 import com.bsth.repository.CarParkRepository; 14 import com.bsth.repository.CarParkRepository;
14 import com.bsth.repository.StationRepository; 15 import com.bsth.repository.StationRepository;
15 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 16 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
16 -import com.bsth.service.gps.entity.GpsOutbound_DTO;  
17 -import com.bsth.service.gps.entity.GpsSpeed_DTO;  
18 -import com.bsth.service.gps.entity.HistoryGps_DTO;  
19 -import com.bsth.service.gps.entity.Road_DTO; 17 +import com.bsth.service.gps.entity.*;
20 import com.bsth.util.DateUtils; 18 import com.bsth.util.DateUtils;
21 import com.bsth.util.TransGPS; 19 import com.bsth.util.TransGPS;
22 import com.bsth.util.TransGPS.Location; 20 import com.bsth.util.TransGPS.Location;
23 import com.bsth.util.db.DBUtils_MS; 21 import com.bsth.util.db.DBUtils_MS;
24 import org.apache.commons.lang3.StringUtils; 22 import org.apache.commons.lang3.StringUtils;
  23 +import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  24 +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  25 +import org.apache.poi.ss.usermodel.CellStyle;
  26 +import org.apache.poi.ss.usermodel.Row;
  27 +import org.apache.poi.ss.usermodel.Sheet;
  28 +import org.apache.poi.ss.usermodel.Workbook;
  29 +import org.joda.time.format.DateTimeFormat;
  30 +import org.joda.time.format.DateTimeFormatter;
25 import org.slf4j.Logger; 31 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory; 32 import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.annotation.Autowired; 33 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +35,12 @@ import org.springframework.dao.DataAccessException; @@ -29,7 +35,12 @@ import org.springframework.dao.DataAccessException;
29 import org.springframework.jdbc.core.JdbcTemplate; 35 import org.springframework.jdbc.core.JdbcTemplate;
30 import org.springframework.stereotype.Service; 36 import org.springframework.stereotype.Service;
31 37
  38 +import javax.servlet.http.HttpServletResponse;
  39 +import java.io.IOException;
  40 +import java.io.OutputStream;
  41 +import java.io.UnsupportedEncodingException;
32 import java.lang.reflect.Field; 42 import java.lang.reflect.Field;
  43 +import java.net.URLEncoder;
33 import java.sql.Connection; 44 import java.sql.Connection;
34 import java.sql.PreparedStatement; 45 import java.sql.PreparedStatement;
35 import java.sql.ResultSet; 46 import java.sql.ResultSet;
@@ -213,7 +224,7 @@ public class GpsServiceImpl implements GpsService { @@ -213,7 +224,7 @@ public class GpsServiceImpl implements GpsService {
213 // 查询到离站数据 224 // 查询到离站数据
214 Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear, st, et, inv); 225 Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear, st, et, inv);
215 226
216 - String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO,DIRECTION,LINE_ID,SPEED_GPS from bsth_c_gps_info where days_year=? and device_id in (" 227 + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO,DIRECTION,LINE_ID,SPEED_GPS,SECTION_CODE from bsth_c_gps_info where days_year=? and device_id in ("
217 + inv + ") and ts > ? and ts < ? ORDER BY device_id,ts,stop_no"; 228 + inv + ") and ts > ? and ts < ? ORDER BY device_id,ts,stop_no";
218 try { 229 try {
219 conn = DBUtils_MS.getConnection(); 230 conn = DBUtils_MS.getConnection();
@@ -268,6 +279,8 @@ public class GpsServiceImpl implements GpsService { @@ -268,6 +279,8 @@ public class GpsServiceImpl implements GpsService {
268 map.put("state", 0); 279 map.put("state", 0);
269 // 上下行 280 // 上下行
270 map.put("upDown", upDown); 281 map.put("upDown", upDown);
  282 + //路段编码
  283 + map.put("section_code", rs.getString("SECTION_CODE"));
271 list.add(map); 284 list.add(map);
272 } 285 }
273 } catch (Exception e) { 286 } catch (Exception e) {
@@ -562,6 +575,226 @@ public class GpsServiceImpl implements GpsService { @@ -562,6 +575,226 @@ public class GpsServiceImpl implements GpsService {
562 return rs; 575 return rs;
563 } 576 }
564 577
  578 +
  579 + @Override
  580 + public Map<String, Object> history_v3(String nbbm, long st, long et) {
  581 + Map<String, Object> rs = new HashMap<>();
  582 +
  583 + try {
  584 + //获取历史gps 数据
  585 + List<HistoryGps_DTOV3> list = HistoryGps_DTOV3.craete(history(new String[]{nbbm}, st, et));
  586 + if (list != null && list.size() > 0) {
  587 + //获取路段信息
  588 + /*String sql = "select ID, ST_AsText(GROAD_VECTOR) as GROAD_VECTOR,ROAD_CODE,ROAD_NAME,SPEED from bsth_c_road where road_code in(select section_code from bsth_c_sectionroute where line_code=? and destroy=0)";
  589 + List<Road_DTO> roads = Road_DTO.craete(jdbcTemplate.queryForList(sql, list.get(0).getLineId()));
  590 +
  591 + //为GPS数据关联路段信息
  592 + for (HistoryGps_DTOV3 gps : list) {
  593 + matchRoadToGps(gps, roads);
  594 + }*/
  595 + //关联路段名称
  596 + Map<String, String> sectionCode2Name = GeoCacheData.sectionCode2NameMap();
  597 + for(HistoryGps_DTOV3 gps : list){
  598 + if(StringUtils.isNotEmpty(gps.getSection_code()))
  599 + gps.setSection_name(sectionCode2Name.get(gps.getSection_code()));
  600 + else{
  601 + gps.setSection_code("-00404");
  602 + gps.setSection_name("未知路段");
  603 + }
  604 + }
  605 + }
  606 +
  607 + //超速数据
  608 + List<GpsSpeed_DTO> speedList = speeds(nbbm, st, et);
  609 +
  610 + //越界数据
  611 + List<GpsOutbound_DTO> outboundList = outbounds(nbbm, st, et);
  612 +
  613 + //计算里程
  614 + List<HistoryGps_DTOV3> effList = new ArrayList<>();
  615 + for(HistoryGps_DTOV3 gps : list){
  616 + if(gps.getLat() != 0 && gps.getLon() != 0)
  617 + effList.add(gps);
  618 + }
  619 + double sum = 0, dist;
  620 + for (int i = 0; i < effList.size() - 1; i++) {
  621 + dist = GeoUtils.getDistance(effList.get(i).getPoint(), effList.get(i + 1).getPoint());
  622 + //点位相同时,dist会NaN
  623 + if(String.valueOf(dist).matches("^[0.0-9.0]+$")){
  624 + if(dist > 0.8)
  625 + sum += dist;
  626 + }
  627 + }
  628 +
  629 + rs.put("status", ResponseCode.SUCCESS);
  630 + rs.put("list", removeDuplicateV3(effList));
  631 + rs.put("speedList", speedList);
  632 + rs.put("outboundList", outboundList);
  633 + rs.put("sumMileage", new DecimalFormat(".##").format(sum / 1000));
  634 + } catch (Exception e) {
  635 + logger.error("", e);
  636 + rs.put("status", ResponseCode.ERROR);
  637 + rs.put("msg", e.getMessage());
  638 + }
  639 + return rs;
  640 + }
  641 +
  642 + @Override
  643 + public void trailExcel(String nbbm, long st, long et, HttpServletResponse resp) {
  644 + //获取历史gps 数据
  645 + List<HistoryGps_DTOV3> list = HistoryGps_DTOV3.craete(history(new String[]{nbbm}, st, et));
  646 + if (list != null && list.size() > 0) {
  647 + //关联路段名称
  648 + Map<String, String> sectionCode2Name = GeoCacheData.sectionCode2NameMap();
  649 + for(HistoryGps_DTOV3 gps : list){
  650 + if(StringUtils.isNotEmpty(gps.getSection_code()))
  651 + gps.setSection_name(sectionCode2Name.get(gps.getSection_code()));
  652 + else{
  653 + gps.setSection_code("-00404");
  654 + gps.setSection_name("未知路段");
  655 + }
  656 + }
  657 + }
  658 +
  659 + //创建excel工作簿
  660 + Workbook wb = new HSSFWorkbook();
  661 + Sheet sheet = wb.createSheet("行车轨迹");
  662 + //表头
  663 + Row row = sheet.createRow(0);
  664 + row.setHeight((short) (1.5 * 256));
  665 + row.createCell(0).setCellValue("序号");
  666 + row.createCell(1).setCellValue("车辆");
  667 + row.createCell(2).setCellValue("所在道路");
  668 + row.createCell(3).setCellValue("经度");
  669 + row.createCell(4).setCellValue("纬度");
  670 + row.createCell(5).setCellValue("时间");
  671 + row.createCell(6).setCellValue("速度");
  672 + //数据
  673 + DateTimeFormatter fmtHHmmss = DateTimeFormat.forPattern("HH:mm.ss"),
  674 + fmt = DateTimeFormat.forPattern("yyyyMMddHHmm");
  675 + HistoryGps_DTOV3 gps;
  676 + for(int i = 0; i < list.size(); i ++){
  677 + gps = list.get(i);
  678 + row = sheet.createRow(i + 1);
  679 + row.createCell(0).setCellValue(i + 1);
  680 + row.createCell(1).setCellValue(gps.getNbbm());
  681 + row.createCell(2).setCellValue(gps.getSection_name());
  682 + row.createCell(3).setCellValue(gps.getLon());
  683 + row.createCell(4).setCellValue(gps.getLat());
  684 + row.createCell(5).setCellValue(fmtHHmmss.print(gps.getTimestamp()));
  685 + row.createCell(6).setCellValue(gps.getSpeed());
  686 + }
  687 +
  688 + st = st * 1000;
  689 + et = et * 1000;
  690 + String filename = nbbm + "轨迹数据" + fmt.print(st) + "至" + fmt.print(et) + ".xls";
  691 + try {
  692 + resp.setContentType("application/x-msdownload");
  693 + resp.addHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
  694 +
  695 + OutputStream out=resp.getOutputStream();
  696 + wb.write(out);
  697 + out.flush();
  698 + out.close();
  699 + } catch (UnsupportedEncodingException e) {
  700 + logger.error("", e);
  701 + } catch (IOException e) {
  702 + logger.error("", e);
  703 + }
  704 + }
  705 +
  706 + @Override
  707 + public void abnormalExcel(String nbbm, long st, long et, HttpServletResponse resp) {
  708 + //超速数据
  709 + List<GpsSpeed_DTO> speedList = speeds(nbbm, st, et);
  710 + //越界数据
  711 + List<GpsOutbound_DTO> outboundList = outbounds(nbbm, st, et);
  712 +
  713 + //创建excel工作簿
  714 + Workbook wb = new HSSFWorkbook();
  715 +
  716 + DateTimeFormatter fmtHHmmss = DateTimeFormat.forPattern("HH:mm.ss"),
  717 + fmt = DateTimeFormat.forPattern("yyyyMMddHHmm");
  718 + if(speedList.size() > 0){
  719 + Sheet sheet = wb.createSheet("超速");
  720 + //表头
  721 + Row row = sheet.createRow(0);
  722 + row.setHeight((short) (1.5 * 256));
  723 + row.createCell(0).setCellValue("异常信息");
  724 + row.createCell(1).setCellValue("最大速度");
  725 + row.createCell(2).setCellValue("开始时间");
  726 + row.createCell(3).setCellValue("结束时间");
  727 + row.createCell(4).setCellValue("持续(秒)");
  728 + row.createCell(5).setCellValue("所在路段");
  729 +
  730 + GpsSpeed_DTO speed;
  731 + for(int i = 0; i < speedList.size(); i++){
  732 + speed = speedList.get(i);
  733 + row = sheet.createRow(i + 1);
  734 + row.createCell(0).setCellValue("超速");
  735 + row.createCell(1).setCellValue(speed.getSpeed());
  736 + row.createCell(2).setCellValue(fmtHHmmss.print(speed.getSt()));
  737 + row.createCell(3).setCellValue(fmtHHmmss.print(speed.getEt()));
  738 + if(speed.getEt() != 0)
  739 + row.createCell(4).setCellValue((speed.getEt() - speed.getSt()) / 1000);
  740 + row.createCell(5).setCellValue("");
  741 + }
  742 + }
  743 +
  744 + if(outboundList.size() > 0){
  745 + Sheet sheet = wb.createSheet("越界");
  746 + //表头
  747 + Row row = sheet.createRow(0);
  748 + row.setHeight((short) (1.5 * 256));
  749 + row.createCell(0).setCellValue("异常信息");
  750 + row.createCell(1).setCellValue("开始时间");
  751 + row.createCell(2).setCellValue("结束时间");
  752 + row.createCell(3).setCellValue("持续(秒)");
  753 + row.createCell(4).setCellValue("所在路段");
  754 + row.createCell(5).setCellValue("路径");
  755 +
  756 + GpsOutbound_DTO outbound;
  757 + //设置路径单元格 水平对齐 填充
  758 + CellStyle cs = wb.createCellStyle();
  759 + cs.setAlignment(HSSFCellStyle.ALIGN_FILL);
  760 + for(int i = 0; i < outboundList.size(); i++){
  761 + outbound = outboundList.get(i);
  762 + row = sheet.createRow(i + 1);
  763 + row.createCell(0).setCellValue("超速");
  764 + row.createCell(1).setCellValue(fmtHHmmss.print(outbound.getSt()));
  765 + row.createCell(2).setCellValue(fmtHHmmss.print(outbound.getEt()));
  766 + if(outbound.getEt() != 0)
  767 + row.createCell(3).setCellValue((outbound.getEt() - outbound.getSt()) / 1000);
  768 + row.createCell(4).setCellValue("");
  769 + row.createCell(5).setCellValue(outbound.getLocations());
  770 +
  771 + row.getCell(5).setCellStyle(cs);
  772 + }
  773 + }
  774 +
  775 + st = st * 1000;
  776 + et = et * 1000;
  777 + String filename = nbbm + "异常信息" + fmt.print(st) + "至" + fmt.print(et) + ".xls";
  778 + try {
  779 + resp.setContentType("application/x-msdownload");
  780 + resp.addHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
  781 +
  782 + OutputStream out=resp.getOutputStream();
  783 + wb.write(out);
  784 + out.flush();
  785 + out.close();
  786 + } catch (UnsupportedEncodingException e) {
  787 + logger.error("", e);
  788 + } catch (IOException e) {
  789 + logger.error("", e);
  790 + }
  791 + }
  792 +
  793 + @Override
  794 + public void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp) {
  795 +
  796 + }
  797 +
565 @Override 798 @Override
566 public List<GpsSpeed_DTO> speeds(String nbbm, long st, long et) { 799 public List<GpsSpeed_DTO> speeds(String nbbm, long st, long et) {
567 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); 800 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
@@ -649,6 +882,31 @@ public class GpsServiceImpl implements GpsService { @@ -649,6 +882,31 @@ public class GpsServiceImpl implements GpsService {
649 gps.setRoadMinDistance(min); 882 gps.setRoadMinDistance(min);
650 } 883 }
651 884
  885 +
  886 + private void matchRoadToGps(HistoryGps_DTOV3 gps, List<Road_DTO> roads) {
  887 + double min = -1, distance;
  888 + Road_DTO nearRoad = null;
  889 + for (Road_DTO road : roads) {
  890 + distance = GeoUtils.getDistanceFromLine(road.getLineStr(), gps.getPoint());
  891 +
  892 + if (min > distance || min == -1) {
  893 + min = distance;
  894 + nearRoad = road;
  895 + }
  896 + }
  897 +
  898 + if(min < 200){
  899 + gps.setSection_code(nearRoad.getROAD_CODE());
  900 + gps.setSection_name(nearRoad.getROAD_NAME());
  901 + }
  902 + else {
  903 + gps.setSection_code("-00404");
  904 + gps.setSection_name("未知路段");
  905 + }
  906 + //gps.setRoad(nearRoad);
  907 + //gps.setRoadMinDistance(min);
  908 + }
  909 +
652 /** 910 /**
653 * 去重复 911 * 去重复
654 * 912 *
@@ -663,6 +921,21 @@ public class GpsServiceImpl implements GpsService { @@ -663,6 +921,21 @@ public class GpsServiceImpl implements GpsService {
663 return set; 921 return set;
664 } 922 }
665 923
  924 + /**
  925 + * 去重复
  926 + *
  927 + * @param list
  928 + * @return
  929 + */
  930 + private Set<HistoryGps_DTOV3> removeDuplicateV3(List<HistoryGps_DTOV3> list) {
  931 + Set<HistoryGps_DTOV3> set = new HashSet<>();
  932 + for (HistoryGps_DTOV3 gps : list) {
  933 + set.add(gps);
  934 + }
  935 + return set;
  936 + }
  937 +
  938 +
666 private void sortGpsList(final Field f, List<GpsEntity> rs) { 939 private void sortGpsList(final Field f, List<GpsEntity> rs) {
667 Collections.sort(rs, new Comparator<GpsEntity>() { 940 Collections.sort(rs, new Comparator<GpsEntity>() {
668 941
src/main/java/com/bsth/service/gps/entity/GpsOutbound_DTO.java
@@ -86,6 +86,11 @@ public class GpsOutbound_DTO { @@ -86,6 +86,11 @@ public class GpsOutbound_DTO {
86 */ 86 */
87 private String locations; 87 private String locations;
88 88
  89 + /**
  90 + * 所在路段
  91 + */
  92 + private String sectionName;
  93 +
89 private String abnormalType = "outbound"; 94 private String abnormalType = "outbound";
90 95
91 public String getDeviceId() { 96 public String getDeviceId() {
@@ -135,4 +140,12 @@ public class GpsOutbound_DTO { @@ -135,4 +140,12 @@ public class GpsOutbound_DTO {
135 public void setAbnormalType(String abnormalType) { 140 public void setAbnormalType(String abnormalType) {
136 this.abnormalType = abnormalType; 141 this.abnormalType = abnormalType;
137 } 142 }
  143 +
  144 + public String getSectionName() {
  145 + return sectionName;
  146 + }
  147 +
  148 + public void setSectionName(String sectionName) {
  149 + this.sectionName = sectionName;
  150 + }
138 } 151 }
src/main/java/com/bsth/service/gps/entity/GpsSpeed_DTO.java
@@ -84,6 +84,11 @@ public class GpsSpeed_DTO { @@ -84,6 +84,11 @@ public class GpsSpeed_DTO {
84 */ 84 */
85 private float speed; 85 private float speed;
86 86
  87 + /**
  88 + * 所在路段
  89 + */
  90 + private String sectionName;
  91 +
87 private String abnormalType = "speed"; 92 private String abnormalType = "speed";
88 93
89 public String getDeviceId() { 94 public String getDeviceId() {
@@ -133,4 +138,12 @@ public class GpsSpeed_DTO { @@ -133,4 +138,12 @@ public class GpsSpeed_DTO {
133 public void setAbnormalType(String abnormalType) { 138 public void setAbnormalType(String abnormalType) {
134 this.abnormalType = abnormalType; 139 this.abnormalType = abnormalType;
135 } 140 }
  141 +
  142 + public String getSectionName() {
  143 + return sectionName;
  144 + }
  145 +
  146 + public void setSectionName(String sectionName) {
  147 + this.sectionName = sectionName;
  148 + }
136 } 149 }
src/main/java/com/bsth/service/gps/entity/HistoryGps_DTOV3.java 0 → 100644
  1 +package com.bsth.service.gps.entity;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.data.forecast.entity.ArrivalEntity;
  6 +import com.fasterxml.jackson.annotation.JsonIgnore;
  7 +import com.vividsolutions.jts.geom.Coordinate;
  8 +import com.vividsolutions.jts.geom.GeometryFactory;
  9 +import com.vividsolutions.jts.geom.Point;
  10 +
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 历史GPS DTO
  16 + * Created by panzhao on 2017/4/5.
  17 + */
  18 +public class HistoryGps_DTOV3 {
  19 +
  20 + public static List<HistoryGps_DTOV3> craete(List<Map<String, Object>> mapList) {
  21 + List<HistoryGps_DTOV3> list = JSONObject.parseArray(JSON.toJSONString(mapList), HistoryGps_DTOV3.class);
  22 +
  23 + GeometryFactory geometryFactory = new GeometryFactory();
  24 + Point point;
  25 + for (HistoryGps_DTOV3 gps : list) {
  26 + point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  27 + gps.setPoint(point);
  28 + }
  29 + return list;
  30 + }
  31 +
  32 +
  33 + private double bd_lon;
  34 + private double bd_lat;
  35 +
  36 + private double lon;
  37 + private double lat;
  38 +
  39 + private String deviceId;
  40 + private long ts;
  41 + private long timestamp;
  42 + private String stopNo;
  43 + private float direction;
  44 +
  45 + private String lineId;
  46 + private float speed;
  47 + private ArrivalEntity inout_stop_info;
  48 + private int inout_stop;
  49 +
  50 + private String nbbm;
  51 + private int state;
  52 + private int upDown;
  53 +
  54 + private String section_code;
  55 + private String section_name;
  56 +
  57 + @JsonIgnore
  58 + private Point point;
  59 +
  60 + @Override
  61 + public int hashCode() {
  62 + return this.toString().hashCode();
  63 + }
  64 +
  65 + @Override
  66 + public boolean equals(Object obj) {
  67 + HistoryGps_DTOV3 g2 = (HistoryGps_DTOV3) obj;
  68 + return this.toString().equals(g2.toString());
  69 + }
  70 +
  71 +
  72 + @Override
  73 + public String toString() {
  74 + return (this.getDeviceId() + "_" + (inout_stop_info==null?this.getStopNo():inout_stop_info.getStopName()) + "_" + this.getTs() + "_" + this.getLon() + "_" + this.getLat());
  75 + }
  76 +
  77 + public double getBd_lon() {
  78 + return bd_lon;
  79 + }
  80 +
  81 + public void setBd_lon(double bd_lon) {
  82 + this.bd_lon = bd_lon;
  83 + }
  84 +
  85 + public double getBd_lat() {
  86 + return bd_lat;
  87 + }
  88 +
  89 + public void setBd_lat(double bd_lat) {
  90 + this.bd_lat = bd_lat;
  91 + }
  92 +
  93 + public String getDeviceId() {
  94 + return deviceId;
  95 + }
  96 +
  97 + public void setDeviceId(String deviceId) {
  98 + this.deviceId = deviceId;
  99 + }
  100 +
  101 + public long getTs() {
  102 + return ts;
  103 + }
  104 +
  105 + public void setTs(long ts) {
  106 + this.ts = ts;
  107 + }
  108 +
  109 + public long getTimestamp() {
  110 + return timestamp;
  111 + }
  112 +
  113 + public void setTimestamp(long timestamp) {
  114 + this.timestamp = timestamp;
  115 + }
  116 +
  117 + public String getStopNo() {
  118 + return stopNo;
  119 + }
  120 +
  121 + public void setStopNo(String stopNo) {
  122 + this.stopNo = stopNo;
  123 + }
  124 +
  125 + public float getDirection() {
  126 + return direction;
  127 + }
  128 +
  129 + public void setDirection(float direction) {
  130 + this.direction = direction;
  131 + }
  132 +
  133 + public String getLineId() {
  134 + return lineId;
  135 + }
  136 +
  137 + public void setLineId(String lineId) {
  138 + this.lineId = lineId;
  139 + }
  140 +
  141 + public float getSpeed() {
  142 + return speed;
  143 + }
  144 +
  145 + public void setSpeed(float speed) {
  146 + this.speed = speed;
  147 + }
  148 +
  149 + public ArrivalEntity getInout_stop_info() {
  150 + return inout_stop_info;
  151 + }
  152 +
  153 + public void setInout_stop_info(ArrivalEntity inout_stop_info) {
  154 + this.inout_stop_info = inout_stop_info;
  155 + }
  156 +
  157 + public int getInout_stop() {
  158 + return inout_stop;
  159 + }
  160 +
  161 + public void setInout_stop(int inout_stop) {
  162 + this.inout_stop = inout_stop;
  163 + }
  164 +
  165 + public String getNbbm() {
  166 + return nbbm;
  167 + }
  168 +
  169 + public void setNbbm(String nbbm) {
  170 + this.nbbm = nbbm;
  171 + }
  172 +
  173 + public int getState() {
  174 + return state;
  175 + }
  176 +
  177 + public void setState(int state) {
  178 + this.state = state;
  179 + }
  180 +
  181 + public int getUpDown() {
  182 + return upDown;
  183 + }
  184 +
  185 + public void setUpDown(int upDown) {
  186 + this.upDown = upDown;
  187 + }
  188 +
  189 + public double getLon() {
  190 + return lon;
  191 + }
  192 +
  193 + public void setLon(double lon) {
  194 + this.lon = lon;
  195 + }
  196 +
  197 + public double getLat() {
  198 + return lat;
  199 + }
  200 +
  201 + public void setLat(double lat) {
  202 + this.lat = lat;
  203 + }
  204 +
  205 + public Point getPoint() {
  206 + return point;
  207 + }
  208 +
  209 + public void setPoint(Point point) {
  210 + this.point = point;
  211 + }
  212 +
  213 + public String getSection_code() {
  214 + return section_code;
  215 + }
  216 +
  217 + public void setSection_code(String section_code) {
  218 + this.section_code = section_code;
  219 + }
  220 +
  221 + public String getSection_name() {
  222 + return section_name;
  223 + }
  224 +
  225 + public void setSection_name(String section_name) {
  226 + this.section_name = section_name;
  227 + }
  228 +}
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
@@ -69,10 +69,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ @@ -69,10 +69,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{
69 @Autowired 69 @Autowired
70 private StationRouteRepository stationRouteRepository; 70 private StationRouteRepository stationRouteRepository;
71 71
72 - // 线路标准信息repository  
73 - @Autowired  
74 - private LineInformationRepository lineInformationRepository;  
75 -  
76 // 车辆repository 72 // 车辆repository
77 @Autowired 73 @Autowired
78 private CarsRepository carsRepository; 74 private CarsRepository carsRepository;
@@ -89,14 +85,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ @@ -89,14 +85,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{
89 @Autowired 85 @Autowired
90 private TTInfoDetailRepository ttInfoDetailRepository; 86 private TTInfoDetailRepository ttInfoDetailRepository;
91 87
92 - // 车辆配置信息repository  
93 - @Autowired  
94 - private CarConfigInfoRepository carConfigInfoRepository;  
95 -  
96 - // 人员配置信息repository  
97 - @Autowired  
98 - private EmployeeConfigInfoRepository employeeConfigInfoRepository;  
99 -  
100 // 排班计划明细repository 88 // 排班计划明细repository
101 @Autowired 89 @Autowired
102 private SchedulePlanInfoRepository schedulePlanInfoRepository; 90 private SchedulePlanInfoRepository schedulePlanInfoRepository;
@@ -109,6 +97,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ @@ -109,6 +97,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{
109 @Autowired 97 @Autowired
110 private SKBUploadLoggerRepository skbUploadLoggerRepository; 98 private SKBUploadLoggerRepository skbUploadLoggerRepository;
111 99
  100 + // 线路站点repository
  101 + @Autowired
  102 + private StationRepository stationRepository;
  103 +
112 104
113 // 运管处接口 105 // 运管处接口
114 private InternalPortType portType = null;//new Internal().getInternalHttpSoap11Endpoint(); 106 private InternalPortType portType = null;//new Internal().getInternalHttpSoap11Endpoint();
@@ -367,7 +359,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ @@ -367,7 +359,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{
367 continue; 359 continue;
368 } 360 }
369 361
370 - scheduleRealInfo.getQdzCode();  
371 sf.append("<LD>"); 362 sf.append("<LD>");
372 sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>"); 363 sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>");
373 sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>"); 364 sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>");
@@ -822,13 +813,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ @@ -822,13 +813,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{
822 sBuffer.append("<BC>"); 813 sBuffer.append("<BC>");
823 sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); 814 sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>");
824 sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); 815 sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>");
825 - sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz().getStationName()).append("</FCZDMC>"); 816 + sBuffer.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
  817 + +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>");
826 // 起点站的参数 818 // 起点站的参数
827 otherMap.put("stationMark","B"); 819 otherMap.put("stationMark","B");
828 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); 820 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap);
829 sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); 821 sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>");
830 sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); 822 sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>");
831 - sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz().getStationName()).append("</DDZDMC>"); 823 + sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
  824 + +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>");
832 // 起点站的参数 825 // 起点站的参数
833 otherMap.put("stationMark","E"); 826 otherMap.put("stationMark","E");
834 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); 827 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap);
@@ -1331,9 +1324,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{ @@ -1331,9 +1324,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1331 if(otherParam != null && otherParam.get("stationMark") != null){ 1324 if(otherParam != null && otherParam.get("stationMark") != null){
1332 stationMark = otherParam.get("stationMark"); 1325 stationMark = otherParam.get("stationMark");
1333 if(stationMark.equals("B")){ // 起点站 1326 if(stationMark.equals("B")){ // 起点站
1334 - stationCode = ttid.getQdz().getStationCod(); 1327 + stationCode = ttid.getQdzCode();
1335 }else if(stationMark.equals("E")){ // 终点站 1328 }else if(stationMark.equals("E")){ // 终点站
1336 - stationCode = ttid.getZdz().getStationCod(); 1329 + stationCode = ttid.getZdzCode();
1337 } 1330 }
1338 } 1331 }
1339 } 1332 }
src/main/java/com/bsth/service/realcontrol/LineConfigService.java
@@ -22,4 +22,6 @@ public interface LineConfigService extends BaseService&lt;LineConfig, Integer&gt;{ @@ -22,4 +22,6 @@ public interface LineConfigService extends BaseService&lt;LineConfig, Integer&gt;{
22 Map<String,Object> bufferTimeDiff(String lineCode, String field, String value); 22 Map<String,Object> bufferTimeDiff(String lineCode, String field, String value);
23 23
24 Map<String,Object> yjtkSet(Map<String, String> map); 24 Map<String,Object> yjtkSet(Map<String, String> map);
  25 +
  26 + Map<String,Object> parkAndStationSet(Map<String, String> map);
25 } 27 }
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -172,4 +172,12 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -172,4 +172,12 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
172 Map<String,Object> addToHistory(ScheduleRealInfo sch); 172 Map<String,Object> addToHistory(ScheduleRealInfo sch);
173 173
174 Map<String, Object> deleteToHistory(Long id); 174 Map<String, Object> deleteToHistory(Long id);
  175 +
  176 + List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh, String lpName, String date, String line);
  177 +
  178 + Map<String,Object> findKMBC_mh_2(String jGh, String clZbh, String lpName, String date, String line);
  179 +
  180 + List<Map<String,Object>> statisticsDaily_mh_2(String line, String date, String xlName, String type);
  181 +
  182 + List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date);
175 } 183 }
src/main/java/com/bsth/service/realcontrol/impl/LineConfigServiceImpl.java
@@ -179,4 +179,28 @@ public class LineConfigServiceImpl extends BaseServiceImpl&lt;LineConfig, Integer&gt; @@ -179,4 +179,28 @@ public class LineConfigServiceImpl extends BaseServiceImpl&lt;LineConfig, Integer&gt;
179 } 179 }
180 return rs; 180 return rs;
181 } 181 }
  182 +
  183 + @Override
  184 + public Map<String, Object> parkAndStationSet(Map<String, String> map) {
  185 + String lineCode = map.get("lineCode").toString();
  186 + String twinsPark = map.get("twinsPark").toString();
  187 + String twinsStation = map.get("twinsStation").toString();
  188 +
  189 + Map<String, Object> rs = new HashMap<>();
  190 + try {
  191 + LineConfig conf = lineConfigData.get(lineCode);
  192 + conf.setTwinsPark(twinsPark);
  193 + conf.setTwinsStation(twinsStation);
  194 +
  195 + lineConfigData.set(conf);
  196 +
  197 + rs.put("status", ResponseCode.SUCCESS);
  198 + rs.put("conf", conf);
  199 + } catch (Exception e) {
  200 + rs.put("status", ResponseCode.ERROR);
  201 + rs.put("msg", e.getMessage());
  202 + logger.error("", e);
  203 + }
  204 + return rs;
  205 + }
182 } 206 }