Commit 8aefd9d3173cd193af029656f6e192b1ba1aa84d

Authored by 徐烜
2 parents 52e8edf4 63cbb0a1
src/main/java/com/bsth/StartCommand.java
... ... @@ -82,7 +82,7 @@ public class StartCommand implements CommandLineRunner{
82 82 commonRefreshThread.start();
83 83 scheduler.scheduleWithFixedDelay(commonRefreshThread, HOUR_SECOND * 2 , HOUR_SECOND * 2, TimeUnit.SECONDS);
84 84 //等映射数据加载完......睡一会吧
85   - Thread.sleep(3000);
  85 + Thread.sleep(4000);
86 86  
87 87 /**
88 88 * GPS实时数据更新 线程
... ...
src/main/java/com/bsth/service/impl/StationServiceImpl.java
... ... @@ -192,7 +192,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem
192 192  
193 193 }
194 194  
195   - if(resultLine.getStartStationName()==null){
  195 + if(resultLine.getStartStationName().equals("")){
196 196  
197 197 for(int k =0;k<sizeL;k++) {
198 198  
... ... @@ -209,7 +209,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
209 209  
210 210 };
211 211  
212   - if(resultLine.getEndStationName()==null) {
  212 + if(resultLine.getEndStationName().equals("")) {
213 213  
214 214 for(int k =0;k<sizeL;k++) {
215 215  
... ... @@ -1334,153 +1334,8 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1334 1334 if(!stationJSON.equals("")) {
1335 1335  
1336 1336 // 保存站点与站点路由信息
1337   - resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine);
1338   -
1339   - /*
  1337 + // resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine);
1340 1338  
1341   - JSONArray stationsArray = JSONArray.parseArray(stationJSON);
1342   -
1343   - for(int i = 0;i <stationsArray.size();i++) {
1344   -
1345   - // 站点名称
1346   - String stationName = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("name").toString();
1347   -
1348   - String distanceStr = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("distance").toString();
1349   -
1350   - String durationStr = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("duration").toString();
1351   -
1352   - // 百度经纬度坐标
1353   - String bJwpoints = "";
1354   -
1355   - // 百度坐标经度
1356   - String bLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lng").toString();
1357   -
1358   - // 百度坐标纬度
1359   - String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString();
1360   -
1361   - // 百度经纬度
1362   - bJwpoints = bLonx + " " + bLatx;
1363   -
1364   - List<Object[]> stationNameList = repository.findStationName(stationName);
1365   -
1366   - boolean isHave = isHaveStationname(bJwpoints,stationNameList);
1367   -
1368   - // 初始化站点对象
1369   - Station arg0 = new Station();
1370   -
1371   - // 站点编码
1372   - long stationCode = 0L;
1373   -
1374   - if(isHave) {
1375   -
1376   - Integer stationId = Integer.parseInt(stationNameList.get(0)[1].toString());
1377   -
1378   - arg0 = repository.findOne(stationId);
1379   -
1380   - stationCode = Integer.parseInt(arg0.getStationCod());
1381   -
1382   - }else {
1383   -
1384   - stationCode = GetUIDAndCode.getStationId();
1385   -
1386   - int stationId = (int) (stationCode);
1387   -
1388   - arg0.setId(stationId);
1389   -
1390   - arg0.setStationName(stationName);
1391   -
1392   - // 原坐标类型
1393   - arg0.setDbType(dbType);
1394   -
1395   - // 站点地理位置WGS坐标经度
1396   - String gLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("WGSpotion").toString()).get("Lng").toString();
1397   - arg0.setgLonx(Float.parseFloat(gLonx));
1398   -
1399   - // 站点地理位置WGS坐标纬度
1400   - String gLaty = JSONObject.parseObject(stationsArray.getJSONObject(i).get("WGSpotion").toString()).get("Lat").toString();
1401   - arg0.setgLaty(Float.parseFloat(gLaty));
1402   -
1403   - // 半径
1404   - int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
1405   - arg0.setRadius(radius);
1406   -
1407   - // 图形类型
1408   - String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
1409   - arg0.setShapesType(shapesType);
1410   -
1411   - // 站点编码
1412   - arg0.setStationCod(String.valueOf(stationCode));
1413   -
1414   - // 是否想撤销
1415   - arg0.setDestroy(destroy);
1416   -
1417   - // 版本号
1418   - arg0.setVersions(versions);
1419   -
1420   - arg0.setbJwpoints(bJwpoints);
1421   -
1422   - // 插入站点信息
1423   - repository.save(arg0);
1424   -
1425   -
1426   - // 站点路由对象
1427   - StationRoute route = new StationRoute();
1428   -
1429   - // 站点名称
1430   - route.setStationName(stationName);
1431   -
1432   - route.setDistances(distance);
1433   -
1434   - route.setToTime(duration);
1435   -
1436   - route.setDestroy(destroy);
1437   -
1438   - // 站点编码
1439   - route.setStationCode(arg0.getStationCod());
1440   -
1441   - // 站点序号
1442   - route.setStationRouteCode((i+1)*100);
1443   -
1444   - // 站点类型
1445   - if(i==0) {
1446   -
1447   - // 起始站
1448   - route.setStationMark("B");
1449   -
1450   - }else if(i==stationsArray.size()-1) {
1451   -
1452   - // 终点站
1453   - route.setStationMark("E");
1454   -
1455   - }else {
1456   -
1457   - // 中途站
1458   - route.setStationMark("Z");
1459   -
1460   - }
1461   -
1462   - // 版本号
1463   - route.setVersions(versions);
1464   -
1465   - // 站点ID
1466   - route.setStation(arg0);
1467   -
1468   - // 方向
1469   - route.setDirections(directions);
1470   -
1471   - // 线路ID
1472   - route.setLine(resultLine);
1473   -
1474   - // 线路编码
1475   - route.setLineCode(resultLine.getLineCode());
1476   -
1477   -
1478   - // 插入站点路由信息
1479   - routeRepository.save(route);
1480   -
1481   - }
1482   - }
1483   - */
1484 1339 }
1485 1340  
1486 1341 // 路段长度
... ... @@ -1492,7 +1347,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1492 1347 // 如果路段信息JSON字符串不为空
1493 1348 if(!sectionJSON.equals("")) {
1494 1349  
1495   - manualSaveSectionAndSectionRoute(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType, versions, resultLine, destroy, directions);
  1350 + // manualSaveSectionAndSectionRoute(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType, versions, resultLine, destroy, directions);
1496 1351  
1497 1352 }
1498 1353  
... ... @@ -1504,11 +1359,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1504 1359 sumUpOrDownMileage = s.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
1505 1360  
1506 1361 // 更新里程
1507   - updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
  1362 + // updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
1508 1363  
1509 1364 if(directions==0) {
1510 1365  
1511   - lineUpdateStationName(resultLine);
  1366 + // lineUpdateStationName(resultLine);
1512 1367  
1513 1368 }
1514 1369  
... ...
src/main/java/com/bsth/vehicle/directive/buffer/DirectiveBuffer.java
... ... @@ -5,6 +5,7 @@ import java.util.Calendar;
5 5 import java.util.Collection;
6 6 import java.util.Comparator;
7 7 import java.util.HashMap;
  8 +import java.util.Iterator;
8 9 import java.util.LinkedList;
9 10 import java.util.List;
10 11 import java.util.Map;
... ... @@ -19,6 +20,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo;
19 20 import com.bsth.service.realcontrol.buffer.ScheduleBuffer;
20 21 import com.bsth.vehicle.common.CommonMapped;
21 22 import com.bsth.vehicle.directive.MsgIdGenerator;
  23 +import com.bsth.vehicle.directive.entity.Directive;
22 24 import com.bsth.vehicle.directive.entity.Directive60;
23 25 import com.bsth.vehicle.directive.entity.DirectiveReply;
24 26 import com.bsth.vehicle.directive.entity.Directive80;
... ... @@ -301,6 +303,8 @@ public class DirectiveBuffer {
301 303 directiveMap.put(d.getMsgId(), d);
302 304 }
303 305  
  306 + System.out.println(directiveMap.values());
  307 +
304 308 //恢复80驾驶员上报
305 309 List<Directive80> d80List = d80Repository.findByGtTime(st);
306 310  
... ... @@ -341,8 +345,8 @@ public class DirectiveBuffer {
341 345 * @Description: TODO(获取缓存里的全部指令)
342 346 * @throws
343 347 */
344   - public static List<Object> findAll(){
345   - List<Object> all = new ArrayList<>();
  348 + public static List<Directive> findAll(){
  349 + List<Directive> all = new ArrayList<>();
346 350 //60
347 351 all.addAll(directiveMap.values());
348 352 //64
... ... @@ -350,23 +354,51 @@ public class DirectiveBuffer {
350 354 return all;
351 355 }
352 356  
353   - public static class DComparator implements Comparator<Object>{
354   -
355   - @Override
356   - public int compare(Object o1, Object o2) {
357   - Long t1,t2;
358   - if(o1 instanceof Directive60)
359   - t1 = ((Directive60)o1).getTimestamp();
360   - else
361   - t1 = ((Directive64)o1).getTimestamp();
  357 + /**
  358 + *
  359 + * @Title: findDispatch
  360 + * @Description: TODO(获取缓存里的调度指令)
  361 + * @throws
  362 + */
  363 + public static List<Directive> findDispatch(){
  364 + List<Directive> rs = new ArrayList<>();
  365 + for(Directive60 d60 : directiveMap.values()){
  366 + if(d60.isDispatch())
  367 + rs.add(d60);
  368 + }
362 369  
363   - if(o2 instanceof Directive60)
364   - t2 = ((Directive60)o2).getTimestamp();
365   - else
366   - t2 = ((Directive64)o2).getTimestamp();
  370 + return rs;
  371 + }
  372 +
  373 + /**
  374 + *
  375 + * @Title: findDispatch
  376 + * @Description: TODO(根据dispatchInstruct获取非调度指令)
  377 + * @throws
  378 + */
  379 + public static List<Directive> findByDispatchInstruct(short dispatchInstruct){
  380 + List<Directive> rs = new ArrayList<>();
  381 + for(Directive60 d60 : directiveMap.values()){
  382 + if(d60.getData() != null && d60.getData().getDispatchInstruct() == dispatchInstruct
  383 + && !d60.isDispatch())
  384 + rs.add(d60);
  385 + }
367 386  
368   - return (int) (t2 - t1);
  387 + return rs;
  388 + }
  389 +
  390 + public static class DComparator implements Comparator<Directive>{
  391 +
  392 + @Override
  393 + public int compare(Directive o1, Directive o2) {
  394 + return (int) (o2.getTimestamp() - o1.getTimestamp());
369 395 }
370 396  
371 397 }
  398 +
  399 + public static List<Directive> findLineChange() {
  400 + List<Directive> rs = new ArrayList<>();
  401 + rs.addAll(changeMap.values());
  402 + return rs;
  403 + }
372 404 }
... ...
src/main/java/com/bsth/vehicle/directive/controller/DirectiveController.java
... ... @@ -110,7 +110,7 @@ public class DirectiveController {
110 110 * @throws
111 111 */
112 112 @RequestMapping(value = "/list", method = RequestMethod.GET)
113   - public List<Object> findDirective(@RequestParam String nbbm,@RequestParam int dType
  113 + public Map<String, Object> findDirective(String nbbm,@RequestParam int dType
114 114 , @RequestParam(defaultValue = "0") int page,
115 115 @RequestParam(defaultValue = "10") int size){
116 116  
... ...
src/main/java/com/bsth/vehicle/directive/entity/Directive.java 0 → 100644
  1 +package com.bsth.vehicle.directive.entity;
  2 +
  3 +import javax.persistence.MappedSuperclass;
  4 +import javax.persistence.Transient;
  5 +
  6 +/**
  7 + *
  8 + * @ClassName: Directive
  9 + * @Description: TODO(指令基础类)
  10 + * @author PanZhao
  11 + * @date 2016年7月31日 下午8:35:56
  12 + *
  13 + */
  14 +@MappedSuperclass
  15 +public class Directive {
  16 +
  17 + /**
  18 + * 一级协议
  19 + */
  20 + protected short operCode;
  21 +
  22 + /**
  23 + * 设备号
  24 + */
  25 + protected String deviceId;
  26 +
  27 + /**
  28 + * 时间戳
  29 + */
  30 + protected Long timestamp;
  31 +
  32 + /**
  33 + * 时间 HH:mm
  34 + */
  35 + @Transient
  36 + private String timeHHmm;
  37 +
  38 + /**
  39 + * 车辆内部编码
  40 + */
  41 + @Transient
  42 + private String nbbm;
  43 +
  44 + private String errorText;
  45 +
  46 + private int httpCode;
  47 +
  48 + public short getOperCode() {
  49 + return operCode;
  50 + }
  51 +
  52 + public void setOperCode(short operCode) {
  53 + this.operCode = operCode;
  54 + }
  55 +
  56 + public String getDeviceId() {
  57 + return deviceId;
  58 + }
  59 +
  60 + public void setDeviceId(String deviceId) {
  61 + this.deviceId = deviceId;
  62 + }
  63 +
  64 + public Long getTimestamp() {
  65 + return timestamp;
  66 + }
  67 +
  68 + public void setTimestamp(Long timestamp) {
  69 + this.timestamp = timestamp;
  70 + }
  71 +
  72 + public String getTimeHHmm() {
  73 + return timeHHmm;
  74 + }
  75 +
  76 + public void setTimeHHmm(String timeHHmm) {
  77 + this.timeHHmm = timeHHmm;
  78 + }
  79 +
  80 + public String getNbbm() {
  81 + return nbbm;
  82 + }
  83 +
  84 + public void setNbbm(String nbbm) {
  85 + this.nbbm = nbbm;
  86 + }
  87 +
  88 + public String getErrorText() {
  89 + return errorText;
  90 + }
  91 +
  92 + public void setErrorText(String errorText) {
  93 + this.errorText = errorText;
  94 + }
  95 +
  96 + public int getHttpCode() {
  97 + return httpCode;
  98 + }
  99 +
  100 + public void setHttpCode(int httpCode) {
  101 + this.httpCode = httpCode;
  102 + }
  103 +}
... ...
src/main/java/com/bsth/vehicle/directive/entity/Directive60.java
... ... @@ -2,14 +2,19 @@ package com.bsth.vehicle.directive.entity;
2 2  
3 3 import javax.persistence.Embeddable;
4 4 import javax.persistence.Entity;
  5 +import javax.persistence.FetchType;
5 6 import javax.persistence.GeneratedValue;
6 7 import javax.persistence.Id;
7 8 import javax.persistence.ManyToOne;
  9 +import javax.persistence.NamedAttributeNode;
  10 +import javax.persistence.NamedEntityGraph;
  11 +import javax.persistence.NamedEntityGraphs;
8 12 import javax.persistence.Table;
9 13 import javax.persistence.Transient;
10 14  
11 15 import com.bsth.entity.realcontrol.ScheduleRealInfo;
12 16 import com.bsth.entity.sys.SysUser;
  17 +import com.fasterxml.jackson.annotation.JsonIgnore;
13 18  
14 19  
15 20 /**
... ... @@ -22,35 +27,23 @@ import com.bsth.entity.sys.SysUser;
22 27 */
23 28 @Entity
24 29 @Table(name = "bsth_v_directive_60")
25   -public class Directive60 {
  30 +@NamedEntityGraphs({
  31 + @NamedEntityGraph(name = "directive60_sch", attributeNodes = {
  32 + @NamedAttributeNode("sch")
  33 + })
  34 +})
  35 +public class Directive60 extends Directive{
26 36  
27 37 @Id
28 38 @GeneratedValue
29 39 private Integer id;
30 40  
31 41 /**
32   - * 一级协议
33   - */
34   - private short operCode;
35   -
36   - /**
37 42 * 数据
38 43 */
39 44 private DirectiveData data;
40 45  
41 46 /**
42   - * 设备号
43   - */
44   - @Transient
45   - private String deviceId;
46   -
47   - /**
48   - * 时间戳
49   - */
50   - @Transient
51   - private Long timestamp;
52   -
53   - /**
54 47 * 唯一标识
55 48 */
56 49 @Transient
... ... @@ -75,7 +68,8 @@ public class Directive60 {
75 68 /**
76 69 * 相关联的班次
77 70 */
78   - @ManyToOne
  71 + @JsonIgnore
  72 + @ManyToOne(fetch = FetchType.LAZY)
79 73 private ScheduleRealInfo sch;
80 74  
81 75 /**
... ... @@ -90,9 +84,11 @@ public class Directive60 {
90 84 private short companyCode;
91 85  
92 86 // 设备号
  87 + @Transient
93 88 private String deviceId;
94 89  
95 90 // 时间戳
  91 + @Transient
96 92 private Long timestamp;
97 93  
98 94 // 保留 默认0
... ... @@ -217,28 +213,31 @@ public class Directive60 {
217 213 this.data = data;
218 214 }
219 215  
220   - public String getDeviceId() {
221   - return deviceId;
222   - }
223   -
224   - public void setDeviceId(String deviceId) {
225   - this.deviceId = deviceId;
  216 + public Integer getMsgId() {
  217 + if(this.msgId != null)
  218 + return this.msgId;
  219 + else
  220 + return this.getData().getMsgId();
226 221 }
227 222  
228   - public Long getTimestamp() {
229   - return timestamp;
  223 + public void setMsgId(Integer msgId) {
  224 + this.msgId = msgId;
230 225 }
231   -
  226 +
  227 + @Override
232 228 public void setTimestamp(Long timestamp) {
  229 + if(this.data != null)
  230 + this.data.setTimestamp(timestamp);
  231 +
233 232 this.timestamp = timestamp;
234 233 }
235   -
236   - public Integer getMsgId() {
237   - return msgId;
238   - }
239   -
240   - public void setMsgId(Integer msgId) {
241   - this.msgId = msgId;
  234 +
  235 + @Override
  236 + public void setDeviceId(String deviceId) {
  237 + if(this.data != null)
  238 + this.data.setDeviceId(deviceId);
  239 +
  240 + this.deviceId = deviceId;
242 241 }
243 242  
244 243 public Short getReply46() {
... ...
src/main/java/com/bsth/vehicle/directive/entity/Directive64.java
... ... @@ -17,29 +17,13 @@ import javax.persistence.Id;
17 17 */
18 18 @Entity
19 19 @Table(name = "bsth_v_directive_64")
20   -public class Directive64 {
  20 +public class Directive64 extends Directive{
21 21  
22 22 @Id
23 23 @GeneratedValue
24 24 private Integer id;
25 25  
26 26 /**
27   - * 设备编号
28   - */
29   - @Transient
30   - private String deviceId;
31   -
32   - /**
33   - * 时间戳(ms)
34   - */
35   - private Long timestamp;
36   -
37   - /**
38   - * 一级协议
39   - */
40   - private Short operCode;
41   -
42   - /**
43 27 * 设备响应应答字
44 28 * 0x06同意 0x15不同意
45 29 */
... ... @@ -52,6 +36,7 @@ public class Directive64 {
52 36  
53 37 private Short cityCode;
54 38  
  39 + @Transient
55 40 private String deviceId;
56 41  
57 42 private String lineId;
... ... @@ -89,30 +74,6 @@ public class Directive64 {
89 74 this.id = id;
90 75 }
91 76  
92   - public String getDeviceId() {
93   - return deviceId;
94   - }
95   -
96   - public void setDeviceId(String deviceId) {
97   - this.deviceId = deviceId;
98   - }
99   -
100   - public Long getTimestamp() {
101   - return timestamp;
102   - }
103   -
104   - public void setTimestamp(Long timestamp) {
105   - this.timestamp = timestamp;
106   - }
107   -
108   - public Short getOperCode() {
109   - return operCode;
110   - }
111   -
112   - public void setOperCode(Short operCode) {
113   - this.operCode = operCode;
114   - }
115   -
116 77 public LineChangeData getData() {
117 78 return data;
118 79 }
... ... @@ -128,4 +89,12 @@ public class Directive64 {
128 89 public void setRespAck(Short respAck) {
129 90 this.respAck = respAck;
130 91 }
  92 +
  93 + @Override
  94 + public void setDeviceId(String deviceId) {
  95 + if(this.data != null)
  96 + this.data.setDeviceId(deviceId);
  97 +
  98 + this.deviceId = deviceId;
  99 + }
131 100 }
... ...
src/main/java/com/bsth/vehicle/directive/repository/Directive60Repository.java
... ... @@ -2,6 +2,10 @@ package com.bsth.vehicle.directive.repository;
2 2  
3 3 import java.util.List;
4 4  
  5 +import org.springframework.data.domain.Page;
  6 +import org.springframework.data.domain.Pageable;
  7 +import org.springframework.data.jpa.domain.Specification;
  8 +import org.springframework.data.jpa.repository.EntityGraph;
5 9 import org.springframework.data.jpa.repository.Query;
6 10 import org.springframework.stereotype.Repository;
7 11  
... ... @@ -11,10 +15,19 @@ import com.bsth.vehicle.directive.entity.Directive60;
11 15 @Repository
12 16 public interface Directive60Repository extends BaseRepository<Directive60, Integer>{
13 17  
14   -
15   - @Query("select d from Directive60 d where d.data.timestamp > ?1")
  18 + @EntityGraph(value = "directive60_sch", type = EntityGraph.EntityGraphType.FETCH)
  19 + @Query("select d from Directive60 d where d.timestamp > ?1")
16 20 public List<Directive60> findByGtTime(Long ts);
17 21  
18 22 @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(msg_id) as num FROM bsth_v_directive_60) d", nativeQuery = true)
19 23 Integer maxMsgId();
  24 +
  25 +
  26 + @EntityGraph(value = "directive60_sch", type = EntityGraph.EntityGraphType.FETCH)
  27 + @Override
  28 + Page<Directive60> findAll(Specification<Directive60> spec, Pageable pageable);
  29 +
  30 + @EntityGraph(value = "directive60_sch", type = EntityGraph.EntityGraphType.FETCH)
  31 + @Override
  32 + List<Directive60> findAll(Specification<Directive60> spec);
20 33 }
... ...
src/main/java/com/bsth/vehicle/directive/service/DirectiveService.java
... ... @@ -76,5 +76,5 @@ public interface DirectiveService extends BaseService&lt;Directive60, Integer&gt;{
76 76  
77 77 Map<String, Object> reply80(int id, int reply);
78 78  
79   - List<Object> findDirective(String nbbm, int dType, int page, int size);
  79 + Map<String, Object> findDirective(String nbbm, int dType, int page, int size);
80 80 }
... ...
src/main/java/com/bsth/vehicle/directive/service/DirectiveServiceImpl.java
... ... @@ -2,12 +2,12 @@ package com.bsth.vehicle.directive.service;
2 2  
3 3 import java.text.SimpleDateFormat;
4 4 import java.util.Collections;
5   -import java.util.Comparator;
6 5 import java.util.Date;
7 6 import java.util.HashMap;
8 7 import java.util.List;
9 8 import java.util.Map;
10 9  
  10 +import org.apache.commons.lang3.StringUtils;
11 11 import org.slf4j.Logger;
12 12 import org.slf4j.LoggerFactory;
13 13 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -23,6 +23,7 @@ import com.bsth.vehicle.common.CommonMapped;
23 23 import com.bsth.vehicle.directive.Consts;
24 24 import com.bsth.vehicle.directive.MsgIdGenerator;
25 25 import com.bsth.vehicle.directive.buffer.DirectiveBuffer;
  26 +import com.bsth.vehicle.directive.entity.Directive;
26 27 import com.bsth.vehicle.directive.entity.Directive60;
27 28 import com.bsth.vehicle.directive.entity.Directive60.DirectiveData;
28 29 import com.bsth.vehicle.directive.entity.DirectiveC0.DirectiveC0Data;
... ... @@ -40,136 +41,140 @@ import com.bsth.websocket.handler.RealControlSocketHandler;
40 41 import com.google.common.base.Splitter;
41 42  
42 43 @Service
43   -public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> implements DirectiveService{
  44 +public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> implements DirectiveService {
44 45  
45 46 Logger logger = LoggerFactory.getLogger(this.getClass());
46   -
  47 +
47 48 @Autowired
48 49 Directive60Repository directiveRepository;
49   -
  50 +
50 51 @Autowired
51 52 GpsRealDataBuffer gpsRealDataBuffer;
52   -
  53 +
53 54 @Autowired
54 55 LineChangeRepository lineChangeRepository;
55   -
  56 +
56 57 @Autowired
57 58 RealControlSocketHandler socketHandler;
58   -
  59 +
59 60 @Autowired
60 61 Directive80Repository d80Repository;
61   -
62   - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH点mm分");
63   -
  62 +
  63 + SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH点mm分"), sdfHHmm2 = new SimpleDateFormat("HH:mm");
  64 +
64 65 static Long schDiff = 1000 * 60 * 60L;
65   -
66   - //城市代码
  66 +
  67 + // 城市代码
67 68 static final short cityCode = 22;
68   -
  69 +
69 70 @Override
70 71 public int send60Phrase(String nbbm, String text) {
71 72 Directive60 directive = null;
72 73 try {
73   - directive = create60Data(nbbm, text, (short)0x00, null);
  74 + directive = create60Data(nbbm, text, (short) 0x00, null);
74 75 } catch (Exception e) {
75 76 logger.error("发送消息短语出现异常", e);
76 77 return -1;
77 78 }
78   -
79   - if(null == directive)
  79 +
  80 + if (null == directive)
80 81 return -1;
81   -
82   - //发送指令
  82 +
  83 + // 发送指令
83 84 int code = HttpUtils.postJson(JSON.toJSONString(directive));
84   -
85   - if(code == 0){
86   - //添加到缓存,等待入库
87   - DirectiveBuffer.put(directive);
88   - }else{
89   - logger.error("send60Phrase error, code: " + code);
  85 + directive.setHttpCode(code);
  86 + // 添加到缓存,等待入库
  87 + DirectiveBuffer.put(directive);
  88 +
  89 + if (code != 0) {
  90 + directive.setErrorText("网关通讯失败, code: " + code);
  91 + DirectiveBuffer.transientList.add(directive);
90 92 }
91 93 return code;
92 94 }
93   -
  95 +
94 96 @Override
95   - public int send60Dispatch(ScheduleRealInfo sch, int finish) {
  97 + public int send60Dispatch(ScheduleRealInfo sch, int finish) {
96 98 Directive60 directive = null;
97 99 try {
98   - //如果发车时间距当前时间较远,则不发送
99   - if(Math.abs(sch.getFcsjT() - System.currentTimeMillis()) > schDiff){
  100 + // 如果发车时间距当前时间较远,则不发送
  101 + if (Math.abs(sch.getFcsjT() - System.currentTimeMillis()) > schDiff) {
100 102 return -2;
101 103 }
102   -
103   - String text = "已完成" + finish + "个班次,下一发车时间" + sdfHHmm.format(new Date(sch.getFcsjT()))
104   - + ",由" + sch.getQdzName() + "发往" + sch.getZdzName();
105   -
106   - //目前使用短语协议下发调度指令
107   - directive = create60Data(sch.getClZbh(), text, (short)0x00, sch);
  104 +
  105 + String text = "已完成" + finish + "个班次,下一发车时间" + sdfHHmm.format(new Date(sch.getFcsjT())) + ",由"
  106 + + sch.getQdzName() + "发往" + sch.getZdzName();
  107 +
  108 + // 目前使用短语协议下发调度指令
  109 + directive = create60Data(sch.getClZbh(), text, (short) 0x00, sch);
108 110 } catch (Exception e) {
109 111 logger.error("生成调度指令时出现异常", e);
110 112 return -1;
111 113 }
112   -
113   - if(null == directive)
  114 +
  115 + if (null == directive)
114 116 return -1;
115   -
116   - //发送指令
  117 +
  118 + // 发送指令
117 119 int code = HttpUtils.postJson(JSON.toJSONString(directive));
118   -
119   - if(code == 0){
120   - sch.setDirectiveState(60);
121   - //添加到缓存,等待入库
122   - directive.setDispatch(true);
123   - directive.setSch(sch);
124   - DirectiveBuffer.put(directive);
125   - //通知页面,消息已发出
  120 +
  121 + sch.setDirectiveState(60);
  122 + // 添加到缓存,等待入库
  123 + directive.setDispatch(true);
  124 + directive.setSch(sch);
  125 + directive.setHttpCode(code);
  126 + DirectiveBuffer.put(directive);
  127 +
  128 + if (code == 0) {
  129 + // 通知页面,消息已发出
126 130 sendDirectiveToPage(sch);
127   - }else{
128   - logger.error("send60Phrase error, code: " + code);
  131 + } else {
  132 + directive.setErrorText("网关通讯失败, code: " + code);
  133 + DirectiveBuffer.transientList.add(directive);
129 134 }
130 135 return code;
131 136 }
132   -
  137 +
133 138 /**
134 139 *
135   - * @Title: sendDirectiveState
136   - * @Description: TODO(向页面推送班次指令状态)
137   - * @throws
  140 + * @Title: sendDirectiveState @Description: TODO(向页面推送班次指令状态) @throws
138 141 */
139 142 @Override
140   - public void sendDirectiveToPage(ScheduleRealInfo sch){
  143 + public void sendDirectiveToPage(ScheduleRealInfo sch) {
141 144 JSONObject json = new JSONObject();
142 145 json.put("fn", "directive");
143 146 json.put("t", sch);
144 147 socketHandler.sendMessageToLine(Integer.parseInt(sch.getXlBm()), json.toJSONString());
145 148 }
146 149  
147   -
148 150 @Override
149 151 public int send60Dispatch(Long id) {
150 152 ScheduleRealInfo sch = ScheduleBuffer.findOne(id);
151   - //车辆已完成班次
  153 + // 车辆已完成班次
152 154 int finish = ScheduleBuffer.getFinishSchNo(sch.getClZbh());
153 155 return send60Dispatch(sch, finish);
154 156 }
155   -
  157 +
156 158 @Override
157 159 public int send60Operation(String nbbm, int state, int upDown, ScheduleRealInfo sch) {
158   - logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown );
159   -
160   - Directive60 directive = createDirective60(nbbm, nbbm + "_" + upDown, (short) 0x03, upDown, state);
  160 + logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown);
  161 +
  162 + String text = "切换为 " + (upDown == 0 ? "上行" : "下行") + (state == 0 ? "营运" : "未营运");
  163 + Directive60 directive = createDirective60(nbbm, text, (short) 0x03, upDown, state);
161 164  
162   - if(null == directive)
  165 + if (null == directive)
163 166 return -1;
164   - //发送指令
  167 + // 发送指令
165 168 int code = HttpUtils.postJson(JSON.toJSONString(directive));
166   - if(code == 0){
167   - //添加到缓存,等待入库
168   - if(null != sch)
169   - directive.setSch(sch);
170   - DirectiveBuffer.put(directive);
171   - }else{
172   - logger.error("send60Phrase error, code: " + code);
  169 + // 添加到缓存,等待入库
  170 + directive.setHttpCode(code);
  171 + if (null != sch)
  172 + directive.setSch(sch);
  173 + DirectiveBuffer.put(directive);
  174 +
  175 + if (code != 0) {
  176 + directive.setErrorText("网关通讯失败, code: " + code);
  177 + DirectiveBuffer.transientList.add(directive);
173 178 }
174 179 return code;
175 180 }
... ... @@ -181,80 +186,80 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;Directive60, Integer&gt;
181 186 public int lineChange(String nbbm, Integer lineId) {
182 187 Long t = System.currentTimeMillis();
183 188 String deviceId = CommonMapped.vehicDeviceBiMap.inverse().get(nbbm);
184   -
  189 +
185 190 Directive64 change = new Directive64();
186 191 LineChangeData data = new LineChangeData();
187 192 data.setCityCode(cityCode);
188 193 data.setDeviceId(deviceId);
189 194 data.setLineId("00" + String.valueOf(lineId));
190   -
  195 +
191 196 change.setDeviceId(deviceId);
192 197 change.setOperCode((short) 0X64);
193 198 change.setTimestamp(t);
194 199 change.setData(data);
195   -
  200 +
196 201 int code = HttpUtils.postJson(JSON.toJSONString(change));
197   - if(code == 0){
198   - //入库
199   - lineChangeRepository.save(change);
200   - DirectiveBuffer.changeMap.put(deviceId + '_' + t , change);
201   - //通知设备刷新线路文件,忽略结果
  202 + // 入库
  203 + change.setHttpCode(code);
  204 + DirectiveBuffer.changeMap.put(deviceId + '_' + t, change);
  205 +
  206 + // 通知设备刷新线路文件,忽略结果
  207 + if (code == 0)
202 208 HttpUtils.postJson(createDeviceRefreshData(deviceId, lineId));
203   - }else{
204   - logger.error("send60Phrase error, code: " + code);
205   - }
  209 + else
  210 + change.setErrorText("网关通讯失败, code: " + code);
  211 +
  212 + lineChangeRepository.save(change);
206 213 return code;
207 214 }
208   -
209   -
210   - public Directive60 create60Data(String nbbm, String text, Short dispatchInstruct, ScheduleRealInfo sch){
211   -
212   - /*//向测试设备发送
213   - String deviceId = "ABCDFEGH";
214   - Short company = 5;*/
215   -
  215 +
  216 + public Directive60 create60Data(String nbbm, String text, Short dispatchInstruct, ScheduleRealInfo sch) {
  217 +
  218 + /*
  219 + * //向测试设备发送 String deviceId = "ABCDFEGH"; Short company = 5;
  220 + */
  221 +
216 222 String deviceId = CommonMapped.vehicDeviceBiMap.inverse().get(nbbm);
217   - if(null == deviceId){
  223 + if (null == deviceId) {
218 224 logger.error("没有设备号对照的车辆:" + nbbm);
219 225 return null;
220 226 }
221   - //上下行和营运状态
  227 + // 上下行和营运状态
222 228 Integer upDown = null, state = null;
223   - if(null == sch){
  229 + if (null == sch) {
224 230 GpsRealData gpsData = gpsRealDataBuffer.findOneByDeviceId(deviceId);
225   - if(null == gpsData){
  231 + if (null == gpsData) {
226 232 logger.error("没有找到gps对照,无法确认营运状态和上下行:" + nbbm);
227 233 return null;
228 234 }
229 235 upDown = gpsData.getUpDown();
230 236 state = gpsData.getState();
231   - }
232   - else{
  237 + } else {
233 238 upDown = Integer.parseInt(sch.getXlDir());
234 239 state = 0;
235 240 }
236   -
  241 +
237 242 return createDirective60(nbbm, text, dispatchInstruct, upDown, state);
238 243 }
239   -
240   - public Directive60 createDirective60(String nbbm, String text, Short dispatchInstruct,int upDown,int state){
  244 +
  245 + public Directive60 createDirective60(String nbbm, String text, Short dispatchInstruct, int upDown, int state) {
241 246 Long timestamp = System.currentTimeMillis();
242   -
  247 +
243 248 Short company = Short.parseShort(CommonMapped.vehicCompanyMap.get(nbbm));
244 249 String deviceId = CommonMapped.vehicDeviceBiMap.inverse().get(nbbm);
245   -
  250 +
246 251 int msgId = MsgIdGenerator.getMsgId();
247   -
  252 +
248 253 Directive60 directive = new Directive60();
249 254 DirectiveData data = new DirectiveData();
250   - //一级协议
  255 + // 一级协议
251 256 directive.setOperCode((short) 0x60);
252   - //设备号
  257 + // 设备号
253 258 directive.setDeviceId(deviceId);
254   - //时间戳
  259 + // 时间戳
255 260 directive.setTimestamp(timestamp);
256 261 directive.setMsgId(msgId);
257   - //构造数据
  262 + // 构造数据
258 263 data.setDeviceId(deviceId);
259 264 data.setDispatchInstruct(dispatchInstruct);
260 265 data.setTimestamp(timestamp);
... ... @@ -262,50 +267,45 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;Directive60, Integer&gt;
262 267 data.setMsgId(msgId);
263 268 directive.setData(data);
264 269 long serviceState;
265   - try{
  270 + try {
266 271 serviceState = Consts.SERVICE_STATE[upDown][state];
267   - }catch(IndexOutOfBoundsException e){
268   - //未知营运状态的直接默认为上行非营运
  272 + } catch (IndexOutOfBoundsException e) {
  273 + // 未知营运状态的直接默认为上行非营运
269 274 serviceState = Consts.SERVICE_STATE[0][1];
270 275 }
271 276 data.setServiceState(serviceState);
272 277 data.setTxtContent(text);
273   -
  278 +
274 279 return directive;
275 280 }
276   -
  281 +
277 282 @Override
278 283 public int upDownChange(String nbbm, Integer upDown) {
279   - /*Directive60 directive = createDirective60(nbbm, nbbm + "_" + upDown, (short) 0x03, upDown, 0);
280   -
281   - if(null == directive)
282   - return -1;
283   -
284   - int code = HttpUtils.postJson(JSON.toJSONString(directive));
285   - if(code == 0){
286   - //添加到缓存,等待入库
287   - DirectiveBuffer.put(directive);
288   - }else{
289   - logger.error("send60 upDownChange error, code: " + code);
290   - }*/
  284 + /*
  285 + * Directive60 directive = createDirective60(nbbm, nbbm + "_" + upDown,
  286 + * (short) 0x03, upDown, 0);
  287 + *
  288 + * if(null == directive) return -1;
  289 + *
  290 + * int code = HttpUtils.postJson(JSON.toJSONString(directive)); if(code
  291 + * == 0){ //添加到缓存,等待入库 DirectiveBuffer.put(directive); }else{
  292 + * logger.error("send60 upDownChange error, code: " + code); }
  293 + */
291 294 return send60Operation(nbbm, 0, upDown, null);
292 295 }
293   -
  296 +
294 297 /**
295 298 *
296   - * @Title: createDeviceRefreshData
297   - * @Description: TODO(生成设备线路刷新数据包)
298   - * @param @return 设定文件
299   - * @return String 返回类型
300   - * @throws
  299 + * @Title: createDeviceRefreshData @Description:
  300 + * TODO(生成设备线路刷新数据包) @param @return 设定文件 @return String 返回类型 @throws
301 301 */
302   - public String createDeviceRefreshData(String deviceId, Integer lineId){
303   - Long t = System.currentTimeMillis();
  302 + public String createDeviceRefreshData(String deviceId, Integer lineId) {
  303 + Long t = System.currentTimeMillis();
304 304 Map<String, Object> param = new HashMap<String, Object>();
305 305 param.put("deviceId", deviceId);
306 306 param.put("timestamp", t);
307 307 param.put("operCode", 0Xc0);
308   -
  308 +
309 309 Map<String, Object> data = new HashMap<String, Object>();
310 310 data.put("operCode", 0xa1);
311 311 data.put("cityCode", cityCode);
... ... @@ -316,39 +316,37 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;Directive60, Integer&gt;
316 316 data.put("lineVersion", 0);
317 317 data.put("carparkDataVersion", 0);
318 318 param.put("data", data);
319   -
  319 +
320 320 return JSON.toJSONString(param);
321 321 }
322 322  
323 323 @Override
324 324 public Map<String, List<Directive80>> findNoCofm80(String lineCodes) {
325 325 List<String> lineList = Splitter.on(",").trimResults().splitToList(lineCodes);
326   -
  326 +
327 327 Map<String, List<Directive80>> rs = new HashMap<>();
328   - for(String code : lineList){
  328 + for (String code : lineList) {
329 329 rs.put(code, DirectiveBuffer.findNoCofm80(Integer.parseInt(code)));
330 330 }
331   -
  331 +
332 332 return rs;
333 333 }
334 334  
335 335 @Override
336 336 public Map<String, Object> reply80(int id, int reply) {
337 337 Map<String, Object> rs = new HashMap<>();
338   -
  338 +
339 339 Directive80 d80 = DirectiveBuffer.findById80(id);
340   - if(null == d80){
  340 + if (null == d80) {
341 341 rs.put("status", ResponseCode.ERROR);
342 342 rs.put("msg", "服务器没有找到对应数据!");
343   - }
344   - else if(d80.isConfirm()){
  343 + } else if (d80.isConfirm()) {
345 344 rs.put("status", ResponseCode.ERROR);
346 345 rs.put("msg", "该数据已经被处理了!");
347   - }
348   - else{
  346 + } else {
349 347 d80.setConfirm(true);
350 348 d80.setConfirmRs(reply);
351   - //封装C0数据包并回复设备
  349 + // 封装C0数据包并回复设备
352 350 DirectiveC0 c0 = new DirectiveC0();
353 351 c0.setDeviceId(d80.getDeviceId());
354 352 c0.setTimestamp(d80.getTimestamp());
... ... @@ -356,48 +354,85 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;Directive60, Integer&gt;
356 354  
357 355 DirectiveC0Data data = new DirectiveC0Data();
358 356 data.setOperCode2((short) 0x86);
359   - data.setRequestAck((short)(reply==0?0x06:0x15));
360   -
  357 + data.setRequestAck((short) (reply == 0 ? 0x06 : 0x15));
  358 +
361 359 c0.setData(data);
362   -
  360 +
363 361 d80.setC0(c0);
364   - //入库
  362 + // 入库
365 363 d80Repository.save(d80);
366   -
  364 +
367 365 int code = HttpUtils.postJson(JSON.toJSONString(c0));
368   -
  366 +
369 367 rs.put("status", ResponseCode.SUCCESS);
370   - if(code != 0)
  368 + if (code != 0)
371 369 rs.put("msg", "发送C0响应指令到车载设备失败,但该操作已经被系统记录!");
372   -
373   - //通知页面
  370 +
  371 + // 通知页面
374 372 Map<String, Object> sockMap = new HashMap<>();
375 373 sockMap.put("fn", "d80Confirm");
376 374 sockMap.put("id", d80.getId());
377 375 socketHandler.sendMessageToLine(d80.getData().getLineId(), JSON.toJSONString(sockMap));
378 376 }
379   -
  377 +
380 378 return rs;
381 379 }
382 380  
383 381 @Override
384   - public List<Object> findDirective(String nbbm, int dType, int page, int size) {
385   - List<Object> list = null;
386   - if(dType == -1){
  382 + public Map<String, Object> findDirective(String nbbm, int dType, int page, int size) {
  383 + Map<String, Object> rsMap = new HashMap<>();
  384 + List<Directive> list = null;
  385 +
  386 + switch (dType) {
  387 + case -1:
  388 + //所有指令
387 389 list = DirectiveBuffer.findAll();
388   - //时间倒序
389   - Collections.sort(list, new DirectiveBuffer.DComparator());
390   -
391   - int count = list.size();
392   - //分页
393   - int s = page * size
394   - ,e = s + size;
395   -
396   - if(e > count)
397   - e = count;
  390 + break;
  391 + case 0:
  392 + //调度指令
  393 + list = DirectiveBuffer.findDispatch();
  394 + break;
  395 + case 1:
  396 + //运营指令
  397 + list = DirectiveBuffer.findByDispatchInstruct((short)0x03);
  398 + break;
  399 + case 2:
  400 + //线路切换指令
  401 + list = DirectiveBuffer.findLineChange();
  402 + break;
  403 + case 3:
  404 + //消息短语
  405 + list = DirectiveBuffer.findByDispatchInstruct((short)0x00);
  406 + break;
  407 + }
  408 +
  409 + // 时间倒序
  410 + Collections.sort(list, new DirectiveBuffer.DComparator());
  411 + if(StringUtils.isNotBlank(nbbm)){
  412 + //按车辆过滤
398 413  
399   - list.subList(s, e);
400 414 }
401   - return list;
  415 +
  416 + int count = list.size();
  417 + // 分页
  418 + int s = page * size, e = s + size;
  419 +
  420 + if (e > count)
  421 + e = count;
  422 +
  423 + List<Directive> rs = list.subList(s, e);
  424 +
  425 + // 时间格式化,车辆自编号转换
  426 + for (Directive d : rs) {
  427 + if (d.getTimeHHmm() == null)
  428 + d.setTimeHHmm(sdfHHmm2.format(new Date(d.getTimestamp())));
  429 + if (d.getNbbm() == null)
  430 + d.setNbbm(CommonMapped.vehicDeviceBiMap.get(d.getDeviceId()));
  431 + }
  432 +
  433 + rsMap.put("list", rs);
  434 + rsMap.put("totalPages", count % size == 0 ? count / size : count / size + 1);
  435 + rsMap.put("page", page);
  436 + return rsMap;
402 437 }
403 438 }
... ...
src/main/java/com/bsth/vehicle/directive/thread/FirstScheduleIssuedThread.java
... ... @@ -57,9 +57,9 @@ public class FirstScheduleIssuedThread extends Thread{
57 57  
58 58 sch = list.get(0);
59 59  
60   - if(sch.getOpDirectiveState()!= 100
  60 + if(sch.getOpDirectiveState() < 100
61 61 && sch.getStatus() == 0
62   - && Math.abs(sch.getFcsjT() - t) < space){
  62 + && Math.abs(sch.getDfsjT() - t) < space){
63 63  
64 64 /*if(sch.getDirectiveState() == -1){
65 65 //发送调度指令
... ...
src/main/java/com/bsth/vehicle/gpsdata/GpsOfflineMonitorThread.java
... ... @@ -30,7 +30,7 @@ public class GpsOfflineMonitorThread extends Thread{
30 30  
31 31 for(GpsRealData gps : allGps){
32 32 if(t - gps.getTimestamp()
33   - > GpsRealDataBuffer.OFFLINE_TIME){
  33 + > GpsRealDataBuffer.OFFLINE_TIME && gps.isOnline()){
34 34 gps.setOnline(false);
35 35 logger.info("设备:" + gps.getDeviceId() + " 掉线");
36 36 }
... ...
src/main/java/com/bsth/vehicle/gpsdata/buffer/GpsRealDataBuffer.java
... ... @@ -103,7 +103,8 @@ public class GpsRealDataBuffer {
103 103  
104 104 //更新GPS点
105 105 for(GpsRealData newGps : upGpsList){
106   - if(t - newGps.getTimestamp() < OFFLINE_TIME){
  106 + if(t - newGps.getTimestamp() < OFFLINE_TIME
  107 + && !newGps.isOnline()){
107 108 logger.info("设备:" + newGps.getDeviceId() + " 上线");
108 109 newGps.setOnline(true);
109 110 }
... ...
src/main/resources/static/pages/base/stationroute/addstationstemplate.html
... ... @@ -33,6 +33,26 @@
33 33 </div>
34 34  
35 35 <div class="form-group">
  36 + <label class="col-md-3 control-label">坐标系类型:</label>
  37 + <div class="col-md-9">
  38 + <div class="icheck-list">
  39 + <label>
  40 + <input type="radio" class="icheck" name="baseRes" value='No'> 暂无坐标系
  41 + </label>
  42 + <label>
  43 + <input type="radio" class="icheck" name="baseRes" value='GCJ-02' > 火星坐标系
  44 + </label>
  45 + <label >
  46 + <input type="radio" class="icheck" name="baseRes" value='BD-09'> 百度坐标系
  47 + </label>
  48 + <label >
  49 + <input type="radio" class="icheck" name="baseRes" value='WGS84' checked> WGS84坐标系
  50 + </label>
  51 + </div>
  52 + </div>
  53 + </div>
  54 +
  55 + <div class="form-group">
36 56 <div class="alert alert-info font-blue-chambray" style="background-color: #2C3E50">
37 57 <h5 class="block"><span class="help-block" style="color:#1bbc9b;"> * 手动添加站点规划说明: </span></h5>
38 58 <p>
... ... @@ -146,21 +166,135 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
146 166 // 弹出正在加载层
147 167 var i = layer.load(0,{offset:['200px', '280px']});
148 168  
149   - // 表单序列
  169 + // 表单序列
150 170 var params = form.serializeJSON();
151 171  
  172 + var baseResValue = params.baseRes;
  173 +
152 174 // 站点名称字符串切割
153 175 var paramsStationsArray = params.stations.split('\r\n');
154 176  
155   - var stationList = [];
156   -
157 177 var len = paramsStationsArray.length;
158 178  
159   - if(len>0) {
  179 + if(baseResValue=='No'){
160 180  
161   - for(var k =0;k<len;k++) {
  181 + debugger;
  182 +
  183 + var stationList = [];
  184 +
  185 + for(var k =0;k<len;k++)
  186 + stationList.push({name:paramsStationsArray[k]+'公交车站'});
  187 +
  188 +
  189 + console.log(stationList);
  190 +
  191 + return;
  192 +
  193 + // 根据站点名称获取百度坐标
  194 + map.stationsNameToPoints(stationList,function(resultJson) {
162 195  
163   - debugger;
  196 + // 根据坐标点获取两点之间的时间与距离
  197 + map.getDistanceAndDuration(resultJson,function(stationdataList) {
  198 +
  199 + // 根据坐标点获取两点之间的折线路段
  200 + map.getSectionListPlonly(stationdataList,function(sectiondata) {
  201 +
  202 + var addLine = LineObj.getLineObj();
  203 +
  204 + // 设置第一个站的距离
  205 + stationdataList[0].distance = '';
  206 +
  207 + // 设置第一个站的时间
  208 + stationdataList[0].duration = '';
  209 +
  210 + // 定义站点信息JSON字符串
  211 + var stationJSON = JSON.stringify(stationdataList);
  212 +
  213 + // 定义路段信息字符串
  214 + var sectionJSON = JSON.stringify(sectiondata);
  215 +
  216 + // 参数集合
  217 + var params = {};
  218 +
  219 + // 站点信息JSON字符串
  220 + params.stationJSON = stationJSON;
  221 +
  222 + // 线路ID
  223 + params.lineId = addLine.id;
  224 +
  225 + // 方向
  226 + params.directions = directionData;
  227 +
  228 + // 原始坐标类型
  229 + params.dbType = 'b';
  230 +
  231 + // 圆形半径
  232 + params.radius = '100';
  233 +
  234 + // 限速
  235 + params.speedLimit = '60';
  236 +
  237 + // 图形类型(r:圆形;p:多边形)
  238 + params.shapesType = 'r';
  239 +
  240 + // destroy:是否撤销
  241 + params.destroy = '0';
  242 +
  243 + // versions:版本号
  244 + params.versions = '1';
  245 +
  246 + // 路段信息JSON字符串
  247 + params.sectionJSON = sectionJSON;
  248 +
  249 + // 保存
  250 + ajaxd.manualSave(params,function(rd) {
  251 +
  252 + if(rd.status='SUCCESS') {
  253 +
  254 + layer.msg('保存成功!');
  255 +
  256 + }else {
  257 +
  258 + layer.msg('保存失败!');
  259 +
  260 + }
  261 +
  262 + // 关闭弹出层
  263 + layer.closeAll();
  264 +
  265 + // 清除地图覆盖物
  266 + map.clearMarkAndOverlays();
  267 +
  268 + // 刷新树
  269 + fun.resjtreeDate(addLine.id,directionData);
  270 +
  271 + // 查询上行路段信息
  272 + ajaxd.getSectionRouteInfo(addLine.id,directionData,function(data) {
  273 +
  274 + // 在地图上画出线路走向
  275 + fun.linePanlThree(data,directionData);
  276 +
  277 + });
  278 +
  279 + });
  280 +
  281 + });
  282 +
  283 + });
  284 +
  285 + });
  286 +
  287 + }else {
  288 +
  289 +
  290 +
  291 +
  292 + }
  293 +
  294 +
  295 + /* if(len>0) {
  296 +
  297 + for(var k =0;k<len;k++) {
164 298  
165 299 if(paramsStationsArray[k]=="")
166 300 continue;
... ... @@ -185,102 +319,7 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
185 319  
186 320 return;
187 321  
188   - }
189   - console.log(stationList);
190   - // 根据站点名称获取百度坐标
191   - map.stationsNameToPoints(stationList,function(resultJson) {
192   - console.log(resultJson);
193   - debugger;
194   - // 根据坐标点获取两点之间的时间与距离
195   - map.getDistanceAndDuration(resultJson,function(stationdataList) {
196   -
197   - // 根据坐标点获取两点之间的折线路段
198   - map.getSectionListPlonly(stationdataList,function(sectiondata) {
199   -
200   - var addLine = LineObj.getLineObj();
201   -
202   - // 设置第一个站的距离
203   - stationdataList[0].distance = '';
204   -
205   - // 设置第一个站的时间
206   - stationdataList[0].duration = '';
207   -
208   - // 定义站点信息JSON字符串
209   - var stationJSON = JSON.stringify(stationdataList);
210   -
211   - // 定义路段信息字符串
212   - var sectionJSON = JSON.stringify(sectiondata);
213   -
214   - // 参数集合
215   - var params = {};
216   -
217   - // 站点信息JSON字符串
218   - params.stationJSON = stationJSON;
219   -
220   - // 线路ID
221   - params.lineId = addLine.id;
222   -
223   - // 方向
224   - params.directions = directionData;
225   -
226   - // 原始坐标类型
227   - params.dbType = 'b';
228   -
229   - // 圆形半径
230   - params.radius = '100';
231   -
232   - // 限速
233   - params.speedLimit = '60';
234   -
235   - // 图形类型(r:圆形;p:多边形)
236   - params.shapesType = 'r';
237   -
238   - // destroy:是否撤销
239   - params.destroy = '0';
240   -
241   - // versions:版本号
242   - params.versions = '1';
243   -
244   - // 路段信息JSON字符串
245   - params.sectionJSON = sectionJSON;
246   -
247   - // 保存
248   - ajaxd.manualSave(params,function(rd) {
249   -
250   - if(rd.status='SUCCESS') {
251   -
252   - layer.msg('保存成功!');
253   -
254   - }else {
255   -
256   - layer.msg('保存失败!');
257   -
258   - }
259   -
260   - // 关闭弹出层
261   - layer.closeAll();
262   -
263   - // 清除地图覆盖物
264   - map.clearMarkAndOverlays();
265   -
266   - // 刷新树
267   - fun.resjtreeDate(addLine.id,directionData);
268   -
269   - // 查询上行路段信息
270   - ajaxd.getSectionRouteInfo(addLine.id,directionData,function(data) {
271   -
272   - // 在地图上画出线路走向
273   - fun.linePanlThree(data,directionData);
274   -
275   - });
276   -
277   - });
278   -
279   - });
280   -
281   - });
282   -
283   - });
  322 + } */
284 323  
285 324 }
286 325  
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-function.js
... ... @@ -301,11 +301,14 @@ var PublicFunctions = function () {
301 301 // 添加站点坐标
302 302 tempM.potion = BusLine.getBusStation(k).position;
303 303  
  304 + tempM.wgs = {x:'',y:''};
  305 +
304 306 // 添加
305 307 stationInfo.push(tempM);
306 308  
307 309 }
308   -
  310 + console.log(stationInfo);
  311 + debugger;
309 312 // 获取站点之间的距离与时间
310 313 WorldsBMap.getDistanceAndDuration(stationInfo,function(json) {
311 314  
... ...
src/main/resources/static/pages/control/line/child_pages/historyDirective.html 0 → 100644
  1 +<div id="historyMessagePanel" style="margin: 17px 0 0 0;">
  2 +
  3 + <form class="form-inline" >
  4 + <div class="form-group" style="margin: 18px;">
  5 + <label class="" for="directiveSelect">指令类型:</label>
  6 + <select class="form-control" id="directiveSelect" name="dType">
  7 + <option value="-1">全部</option>
  8 + <option value="0">调度指令</option>
  9 + <option value="1">运营指令</option>
  10 + <option value="2">线路切换指令</option>
  11 + <option value="3">消息短语</option>
  12 + </select>
  13 + </div>
  14 +
  15 + <div class="form-group" >
  16 + <label class="" for="carSelect">车辆:</label>
  17 + <select class="form-control" name="nbbm" id="carSelect" style="width: 170px;"></select>
  18 + </div>
  19 + </form>
  20 +
  21 + <div class="table-scrollable" style="min-height: 468px;">
  22 + <table class="table table-hover" style="table-layout: fixed;">
  23 + <thead>
  24 + <tr>
  25 + <th width="9%">车辆</th>
  26 + <th width="7%">时间</th>
  27 + <th width="47%">内容</th>
  28 + <th width="8%">发送人</th>
  29 + <th width="17%">状态</th>
  30 + </tr>
  31 + </thead>
  32 + <tbody>
  33 + </tbody>
  34 + </table>
  35 + </div>
  36 + <div style="text-align: right;margin: 15px 15px 5px;">
  37 + <ul id="pagination" class="pagination"></ul>
  38 + </div>
  39 +</div>
  40 +<script id="history_directive_list_temp" type="text/html">
  41 +{{each list as item i}}
  42 +<tr>
  43 + <td>{{item.nbbm}}</td>
  44 + <td>{{item.timeHHmm}}</td>
  45 + <td>
  46 + <div class="text-furl">
  47 + {{item.data.txtContent}}
  48 + </div>
  49 + </td>
  50 + <td>系统</td>
  51 + <td>
  52 + {{if item.errorText != null}}
  53 + <span class="label label-sm label-danger">{{item.errorText}}</span>
  54 + {{else}}
  55 + {{if item.reply46 != 0}}
  56 + <span class="label label-sm label-danger">设备无响应</span>
  57 + {{/if}}
  58 + {{if item.reply47 != 0}}
  59 + <span class="label label-sm label-warning">驾驶员未确认</span>
  60 + {{/if}}
  61 +
  62 + {{if item.reply46 == 0 && item.reply47 == 0}}
  63 + <span class="label label-sm label-success"> 成功</span>
  64 + {{/if}}
  65 + {{/if}}
  66 + </td>
  67 +</tr>
  68 +{{/each}}
  69 +</script>
  70 +
  71 +<script>
  72 +!function(){
  73 + var $car = $('#historyMessagePanel #carSelect')
  74 + ,$dType = $('#historyMessagePanel #directiveSelect')
  75 + ,$form = $('#historyMessagePanel form')
  76 + ,$table = $('#historyMessagePanel table')
  77 + ,$layer = $('#historyMessagePanel').parents('.layui-layer.layui-layer-page');
  78 + //车辆搜索框
  79 + createVehSearch($car).on('change', function(){
  80 + jsDoQuery(true);
  81 + });
  82 + //分页参数
  83 + var page=0,pSize=12;
  84 + //初始加载数据
  85 + jsDoQuery(true);
  86 +
  87 + //指令类型切换
  88 + $dType.on('change', function(){
  89 + jsDoQuery(true);
  90 + });
  91 +
  92 + function jsDoQuery(pagination){
  93 + var params = $form.serializeJSON();
  94 + params.page = page;
  95 + params.size = pSize;
  96 +
  97 + console.log(params);
  98 + $.get('/directive/list', params, function(rs){
  99 + console.log(rs);
  100 +
  101 + var htmlStr = template('history_directive_list_temp', rs);
  102 + $table.find('tbody').html(htmlStr);
  103 +
  104 + if(pagination){
  105 + showPagination(rs, true);
  106 + toCenter($layer);
  107 + }
  108 + });
  109 + }
  110 +
  111 + function showPagination(data, noQuery){
  112 + //分页
  113 + $('#pagination').jqPaginator({
  114 + totalPages: data.totalPages,
  115 + visiblePages: 6,
  116 + currentPage: page + 1,
  117 + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
  118 + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
  119 + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
  120 + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
  121 + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
  122 + onPageChange: function (num, type) {
  123 + if(noQuery){
  124 + noQuery = false;
  125 + return;
  126 + }
  127 +
  128 + page = num - 1;
  129 + jsDoQuery();
  130 + }
  131 + });
  132 + }
  133 +
  134 + //将元素垂直居中,无视padding, margin等
  135 + function toCenter($e){
  136 + var h = $(document.body).height();
  137 + var eh = $e.height();
  138 + if(eh < h)
  139 + $e.css('top', (h - eh) /2);
  140 + }
  141 +}();
  142 +</script>
0 143 \ No newline at end of file
... ...
src/main/resources/static/pages/control/line/child_pages/historyMessage.html deleted 100644 → 0
1   -<div id="historyMessagePanel" style="margin: 17px 5px 5px;">
2   -
3   - <form class="form-inline" >
4   - <div class="form-group" style="margin: 18px;">
5   - <label class="" for="directiveSelect">指令类型:</label>
6   - <select class="form-control" id="directiveSelect" name="dType">
7   - <option value="-1">全部</option>
8   - <option value="0">调度指令</option>
9   - <option value="1">运营指令</option>
10   - <option value="2">线路切换指令</option>
11   - <option value="3">消息短语</option>
12   - </select>
13   - </div>
14   -
15   - <div class="form-group" >
16   - <label class="" for="carSelect">车辆:</label>
17   - <select class="form-control" name="nbbm" id="carSelect" style="width: 170px;"></select>
18   - </div>
19   - </form>
20   -
21   - <div class="table-scrollable">
22   - <table class="table table-hover" style="table-layout: fixed;">
23   - <thead>
24   - <tr>
25   - <th width="9%">车辆</th>
26   - <th width="9%">时间</th>
27   - <th width="45%">内容</th>
28   - <th width="8%">发送人</th>
29   - <th width="15%">状态</th>
30   - </tr>
31   - </thead>
32   - <tbody>
33   - <tr>
34   - <td>B-84256</td>
35   - <td>11:32</td>
36   - <td>
37   - <div class="text-furl">已完成6个班次,下一发车时间19点05分,由兰坪路浦江路发往江南旅游服务有限公司浦西停车保养场</div>
38   - </td>
39   - <td>系统</td>
40   - <td><span class="label label-sm label-success">
41   - 设备收到,驾驶员确认 </span></td>
42   - </tr>
43   - <tr>
44   - <td>B-84256</td>
45   - <td>11:32</td>
46   - <td>
47   - <div class="text-furl">已完成6个班次,下一发车时间19点05分,由兰坪路浦江路发往江南旅游服务有限公司浦西停车保养场</div>
48   - </td>
49   - <td>系统</td>
50   - <td><span class="label label-sm label-success">
51   - 设备收到,驾驶员确认 </span></td>
52   - </tr>
53   - <tr>
54   - <td>B-84256</td>
55   - <td>11:32</td>
56   - <td>
57   - <div class="text-furl">已完成6个班次,下一发车时间19点05分,由兰坪路浦江路发往江南旅游服务有限公司浦西停车保养场</div>
58   - </td>
59   - <td>系统</td>
60   - <td><span class="label label-sm label-warning">
61   - 设备未响应 </span></td>
62   - </tr>
63   - <tr>
64   - <td>B-84256</td>
65   - <td>11:32</td>
66   - <td>
67   - <div class="text-furl">已完成6个班次,下一发车时间19点05分,由兰坪路浦江路发往江南旅游服务有限公司浦西停车保养场</div>
68   - </td>
69   - <td>系统</td>
70   - <td><span class="label label-sm label-danger">
71   - 网关通讯失败 </span> <i class="fa fa-link"></i></td>
72   - </tr>
73   - <tr>
74   - <td>B-84256</td>
75   - <td>11:32</td>
76   - <td>
77   - <div class="text-furl">运营指令 - 上行营运</div>
78   - </td>
79   - <td>系统</td>
80   - <td><span class="label label-sm label-success">
81   - 切换成功 </span></td>
82   - </tr>
83   -
84   - <tr>
85   - <td>B-84256</td>
86   - <td>11:32</td>
87   - <td>
88   - <div class="text-furl">线路切换 - 778 路</div>
89   - </td>
90   - <td>系统</td>
91   - <td><span class="label label-sm label-success">
92   - 切换成功 </span></td>
93   - </tr>
94   - </tbody>
95   - </table>
96   - </div>
97   -</div>
98   -
99   -<script>
100   -!function(){
101   - var $car = $('#historyMessagePanel #carSelect')
102   - ,$dType = $('#historyMessagePanel #directiveSelect');
103   - createVehSearch($car);
104   -}();
105   -</script>
106 0 \ No newline at end of file
src/main/resources/static/pages/control/line/css/lineControl.css
... ... @@ -450,6 +450,10 @@ body{
450 450 text-rendering: auto;
451 451 }
452 452  
  453 +.pagination .page.active a:before{
  454 + content: none;
  455 +}
  456 +
453 457 .text-load{
454 458 color:gray;
455 459 font-size: 12px;
... ...
src/main/resources/static/pages/control/line/js/toolbarEvent.js
... ... @@ -15,17 +15,17 @@
15 15 });
16 16 //调度指令
17 17 $('#msgAndDirect').on('click', function(){
18   - layer.msg('功能测试中...稍后开放!');
19   - /*$.get('/pages/control/line/child_pages/historyMessage.html', function(content){
  18 + $.get('/pages/control/line/child_pages/historyDirective.html', function(content){
20 19 layer.open({
21 20 type: 1,
22 21 area: '930px',
23 22 content: content,
24 23 title : false,
  24 + shift: 5,
25 25 success: function(){
26 26 }
27 27 });
28   - });*/
  28 + });
29 29 });
30 30  
31 31 //设备上报
... ...
src/main/resources/static/pages/control/lineallot/allot.html
... ... @@ -310,7 +310,6 @@ $(function(){
310 310 }
311 311  
312 312 layer.closeAll();
313   - //跳转到线路调度
314 313 loadPage('/pages/control/line/index.html');
315 314 });
316 315 //window.location.href = '/pages/control/line/index.html';
... ...