Commit f4dcb57c6c90782fe65632c22ec80caf86337e10

Authored by 王通
1 parent c1cb3544

1.线调中加入异常停车,车辆的电量信息

@@ -34,8 +34,6 @@ @@ -34,8 +34,6 @@
34 <groupId>org.springframework.boot</groupId> 34 <groupId>org.springframework.boot</groupId>
35 <artifactId>spring-boot-starter-security</artifactId> 35 <artifactId>spring-boot-starter-security</artifactId>
36 </dependency> 36 </dependency>
37 - <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId>  
38 - </dependency> -->  
39 <dependency> 37 <dependency>
40 <groupId>org.springframework.boot</groupId> 38 <groupId>org.springframework.boot</groupId>
41 <artifactId>spring-boot-starter-data-jpa</artifactId> 39 <artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -59,6 +57,10 @@ @@ -59,6 +57,10 @@
59 <optional>true</optional> 57 <optional>true</optional>
60 </dependency> 58 </dependency>
61 <dependency> 59 <dependency>
  60 + <groupId>org.springframework.kafka</groupId>
  61 + <artifactId>spring-kafka</artifactId>
  62 + </dependency>
  63 + <dependency>
62 <groupId>mysql</groupId> 64 <groupId>mysql</groupId>
63 <artifactId>mysql-connector-java</artifactId> 65 <artifactId>mysql-connector-java</artifactId>
64 <version>5.1.38</version> 66 <version>5.1.38</version>
src/main/java/com/bsth/data/gpsdata_v2/GpsRealData.java
1 -package com.bsth.data.gpsdata_v2;  
2 -  
3 -import com.bsth.data.BasicData;  
4 -import com.bsth.data.forecast.ForecastRealServer;  
5 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
6 -import com.bsth.data.schedule.DayOfSchedule;  
7 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
8 -import com.bsth.service.realcontrol.impl.ScheduleRealInfoServiceImpl;  
9 -import com.google.common.collect.TreeMultimap;  
10 -import org.apache.commons.lang3.StringUtils;  
11 -import org.slf4j.Logger;  
12 -import org.slf4j.LoggerFactory;  
13 -import org.springframework.beans.factory.annotation.Autowired;  
14 -import org.springframework.stereotype.Component;  
15 -  
16 -import java.util.*;  
17 -import java.util.concurrent.ConcurrentHashMap;  
18 -import java.util.concurrent.ConcurrentMap;  
19 -  
20 -/**  
21 - * @author PanZhao  
22 - * @ClassName: GpsRealData  
23 - * @Description: TODO(实时GPS数据集合)  
24 - * @date 2016年8月12日 下午2:04:41  
25 - */  
26 -@Component  
27 -public class GpsRealData {  
28 -  
29 - static Logger logger = LoggerFactory.getLogger(GpsRealData.class);  
30 -  
31 - private static ConcurrentMap<String, GpsEntity> gpsMap;  
32 -  
33 - //按线路分组设备号  
34 - private static TreeMultimap<String, String> lineCode2Devices;  
35 -  
36 - @Autowired  
37 - DayOfSchedule dayOfSchedule;  
38 -  
39 - @Autowired  
40 - ForecastRealServer forecastRealServer;  
41 -  
42 - /**  
43 - * 构造函数  
44 - */  
45 - public GpsRealData() {  
46 - gpsMap = new ConcurrentHashMap<>();  
47 - lineCode2Devices = TreeMultimap.create();  
48 - }  
49 -  
50 -  
51 - public void put(GpsEntity gps) {  
52 - String device = gps.getDeviceId();  
53 - GpsEntity old = gpsMap.get(device);  
54 -  
55 - try {  
56 - if (!StringUtils.isEmpty(gps.getStopNo())) {  
57 - //站点编码改变  
58 - if (null == old || !gps.getStopNo().equals(old.getStopNo())) {  
59 - gps.setArrTime(gps.getTimestamp());  
60 - //预测到达终点时间  
61 - forecastRealServer.forecast(gps.getNbbm(), gps);  
62 - } else {  
63 - gps.setArrTime(old.getArrTime());  
64 - //不预测, 重新计算终点时间  
65 - gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm()));  
66 - }  
67 - }  
68 -  
69 - //刷新对照  
70 - gpsMap.put(device, gps);  
71 - if (StringUtils.isNotBlank(gps.getLineId())) {  
72 - //站点名称  
73 - gps.setStationName(getStationName(gps));  
74 - lineCode2Devices.put(gps.getLineId(), device);  
75 -  
76 - if(old != null && !gps.getLineId().equals(old.getLineId()))  
77 - lineCode2Devices.remove(old.getLineId(), device);  
78 - }  
79 -  
80 - //车辆换设备了  
81 - String nbbm = gps.getNbbm();  
82 - if(old != null && StringUtils.isNotEmpty(nbbm) && !nbbm.equals(old.getNbbm())){  
83 - List<GpsEntity> list = findByNbbm(nbbm);  
84 - for(GpsEntity g : list){  
85 - if(!g.getDeviceId().equals(device))  
86 - gpsMap.remove(g.getDeviceId());  
87 - }  
88 - }  
89 - } catch (Exception e) {  
90 - logger.error("", e);  
91 - }  
92 - }  
93 -  
94 - public String getStationName(GpsEntity gps) {  
95 - return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_");  
96 - }  
97 -  
98 - /**  
99 - * @Title: get @Description: TODO(设备号获取GPS)  
100 - */  
101 - public static GpsEntity get(String deviceId) {  
102 - return gpsMap.get(deviceId);  
103 - }  
104 -  
105 - public List<GpsEntity> findByNbbm(String nbbm){  
106 - Collection<GpsEntity> arr = gpsMap.values();  
107 - List<GpsEntity> rs = new ArrayList<>();  
108 - for(GpsEntity g : arr){  
109 - if(nbbm.equals(g.getNbbm()))  
110 - rs.add(g);  
111 - }  
112 - return rs;  
113 - }  
114 -  
115 - public GpsEntity getByNbbm(String nbbm){  
116 - String device = BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
117 - if(StringUtils.isNotBlank(device))  
118 - return get(device);  
119 - else  
120 - return null;  
121 - }  
122 -  
123 - /**  
124 - * @Title: get @Description: TODO(线路编码获取GPS集合) @throws  
125 - */  
126 - public List<GpsEntity> getByLine(String lineCode) {  
127 - NavigableSet<String> set = lineCode2Devices.get(lineCode);//实际车载  
128 - if(null == set)  
129 - set = new TreeSet();  
130 - Set<String> nbbmSet = dayOfSchedule.findCarByLineCode(lineCode);//计划用车  
131 -  
132 - Map<String, String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse();  
133 - String deviceId;  
134 - for(String nbbm : nbbmSet){  
135 - deviceId = nbbm2deviceMap.get(nbbm);  
136 - if(StringUtils.isNotEmpty(deviceId))  
137 - set.add(deviceId);  
138 - }  
139 -  
140 - List<GpsEntity> rs = new ArrayList<>();  
141 - GpsEntity gps;  
142 - ScheduleRealInfo sch;  
143 - for (String device : set) {  
144 - gps = gpsMap.get(device);  
145 - //过滤异常GPS数据  
146 - if (gps == null || StringUtils.isBlank(gps.getNbbm()))  
147 - continue;  
148 -  
149 - sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());  
150 - if (null != sch){  
151 - gps.setSchId(sch.getId());  
152 - if(!sch.getXlBm().equals(lineCode)){  
153 - //车辆在其他线路营运  
154 - gps.setRemark("执行 " + sch.getXlName() + " " + sch.getDfsj() + " 班次");  
155 - gps.setPlanCode(sch.getXlBm());  
156 - }  
157 - }else  
158 - gps.setRemark(null);  
159 -  
160 - gps.setDvrcode(ScheduleRealInfoServiceImpl.DIRMAP.get(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())));;  
161 - rs.add(gps);  
162 - }  
163 -  
164 - return rs;  
165 - }  
166 -  
167 - public static Set<String> findDevices(String lineCode){  
168 - return lineCode2Devices.get(lineCode);  
169 - }  
170 -  
171 - public List<GpsEntity> get(List<String> pArray) {  
172 - List<GpsEntity> list = new ArrayList<>();  
173 -  
174 - for (String code : pArray)  
175 - list.addAll(getByLine(code));  
176 - return list;  
177 - }  
178 -  
179 - public Set<String> allDevices() {  
180 - return gpsMap.keySet();  
181 - }  
182 -  
183 - public Collection<GpsEntity> all() {  
184 - return gpsMap.values();  
185 - }  
186 -  
187 - public void remove(String device) {  
188 - gpsMap.remove(device);  
189 - } 1 +package com.bsth.data.gpsdata_v2;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.forecast.ForecastRealServer;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import com.bsth.message.buffer.CarEnergyBuffer;
  9 +import com.bsth.service.realcontrol.impl.ScheduleRealInfoServiceImpl;
  10 +import com.google.common.collect.TreeMultimap;
  11 +import org.apache.commons.lang3.StringUtils;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import java.util.*;
  18 +import java.util.concurrent.ConcurrentHashMap;
  19 +import java.util.concurrent.ConcurrentMap;
  20 +
  21 +/**
  22 + * @author PanZhao
  23 + * @ClassName: GpsRealData
  24 + * @Description: TODO(实时GPS数据集合)
  25 + * @date 2016年8月12日 下午2:04:41
  26 + */
  27 +@Component
  28 +public class GpsRealData {
  29 +
  30 + static Logger logger = LoggerFactory.getLogger(GpsRealData.class);
  31 +
  32 + private static ConcurrentMap<String, GpsEntity> gpsMap;
  33 +
  34 + //按线路分组设备号
  35 + private static TreeMultimap<String, String> lineCode2Devices;
  36 +
  37 + @Autowired
  38 + DayOfSchedule dayOfSchedule;
  39 +
  40 + @Autowired
  41 + ForecastRealServer forecastRealServer;
  42 +
  43 + /**
  44 + * 构造函数
  45 + */
  46 + public GpsRealData() {
  47 + gpsMap = new ConcurrentHashMap<>();
  48 + lineCode2Devices = TreeMultimap.create();
  49 + }
  50 +
  51 +
  52 + public void put(GpsEntity gps) {
  53 + String device = gps.getDeviceId();
  54 + GpsEntity old = gpsMap.get(device);
  55 +
  56 + try {
  57 + if (!StringUtils.isEmpty(gps.getStopNo())) {
  58 + //站点编码改变
  59 + if (null == old || !gps.getStopNo().equals(old.getStopNo())) {
  60 + gps.setArrTime(gps.getTimestamp());
  61 + //预测到达终点时间
  62 + forecastRealServer.forecast(gps.getNbbm(), gps);
  63 + } else {
  64 + gps.setArrTime(old.getArrTime());
  65 + //不预测, 重新计算终点时间
  66 + gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm()));
  67 + }
  68 + }
  69 +
  70 + //刷新对照
  71 + gpsMap.put(device, gps);
  72 + if (StringUtils.isNotBlank(gps.getLineId())) {
  73 + //站点名称
  74 + gps.setStationName(getStationName(gps));
  75 + lineCode2Devices.put(gps.getLineId(), device);
  76 +
  77 + if(old != null && !gps.getLineId().equals(old.getLineId()))
  78 + lineCode2Devices.remove(old.getLineId(), device);
  79 + }
  80 +
  81 + //车辆换设备了
  82 + String nbbm = gps.getNbbm();
  83 + if(old != null && StringUtils.isNotEmpty(nbbm) && !nbbm.equals(old.getNbbm())){
  84 + List<GpsEntity> list = findByNbbm(nbbm);
  85 + for(GpsEntity g : list){
  86 + if(!g.getDeviceId().equals(device))
  87 + gpsMap.remove(g.getDeviceId());
  88 + }
  89 + }
  90 +
  91 + // 设置车辆的电量
  92 + gps.setEnergy(CarEnergyBuffer.getCarEnergy(gps.getNbbm()));
  93 + } catch (Exception e) {
  94 + logger.error("", e);
  95 + }
  96 + }
  97 +
  98 + public String getStationName(GpsEntity gps) {
  99 + return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_");
  100 + }
  101 +
  102 + /**
  103 + * @Title: get @Description: TODO(设备号获取GPS)
  104 + */
  105 + public static GpsEntity get(String deviceId) {
  106 + return gpsMap.get(deviceId);
  107 + }
  108 +
  109 + public List<GpsEntity> findByNbbm(String nbbm){
  110 + Collection<GpsEntity> arr = gpsMap.values();
  111 + List<GpsEntity> rs = new ArrayList<>();
  112 + for(GpsEntity g : arr){
  113 + if(nbbm.equals(g.getNbbm()))
  114 + rs.add(g);
  115 + }
  116 + return rs;
  117 + }
  118 +
  119 + public GpsEntity getByNbbm(String nbbm){
  120 + String device = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  121 + if(StringUtils.isNotBlank(device))
  122 + return get(device);
  123 + else
  124 + return null;
  125 + }
  126 +
  127 + /**
  128 + * @Title: get @Description: TODO(线路编码获取GPS集合) @throws
  129 + */
  130 + public List<GpsEntity> getByLine(String lineCode) {
  131 + NavigableSet<String> set = lineCode2Devices.get(lineCode);//实际车载
  132 + if(null == set)
  133 + set = new TreeSet();
  134 + Set<String> nbbmSet = dayOfSchedule.findCarByLineCode(lineCode);//计划用车
  135 +
  136 + Map<String, String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse();
  137 + String deviceId;
  138 + for(String nbbm : nbbmSet){
  139 + deviceId = nbbm2deviceMap.get(nbbm);
  140 + if(StringUtils.isNotEmpty(deviceId))
  141 + set.add(deviceId);
  142 + }
  143 +
  144 + List<GpsEntity> rs = new ArrayList<>();
  145 + GpsEntity gps;
  146 + ScheduleRealInfo sch;
  147 + for (String device : set) {
  148 + gps = gpsMap.get(device);
  149 + //过滤异常GPS数据
  150 + if (gps == null || StringUtils.isBlank(gps.getNbbm()))
  151 + continue;
  152 +
  153 + sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
  154 + if (null != sch){
  155 + gps.setSchId(sch.getId());
  156 + if(!sch.getXlBm().equals(lineCode)){
  157 + //车辆在其他线路营运
  158 + gps.setRemark("执行 " + sch.getXlName() + " " + sch.getDfsj() + " 班次");
  159 + gps.setPlanCode(sch.getXlBm());
  160 + }
  161 + }else
  162 + gps.setRemark(null);
  163 +
  164 + gps.setDvrcode(ScheduleRealInfoServiceImpl.DIRMAP.get(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())));;
  165 + rs.add(gps);
  166 + }
  167 +
  168 + return rs;
  169 + }
  170 +
  171 + public static Set<String> findDevices(String lineCode){
  172 + return lineCode2Devices.get(lineCode);
  173 + }
  174 +
  175 + public List<GpsEntity> get(List<String> pArray) {
  176 + List<GpsEntity> list = new ArrayList<>();
  177 +
  178 + for (String code : pArray)
  179 + list.addAll(getByLine(code));
  180 + return list;
  181 + }
  182 +
  183 + public Set<String> allDevices() {
  184 + return gpsMap.keySet();
  185 + }
  186 +
  187 + public Collection<GpsEntity> all() {
  188 + return gpsMap.values();
  189 + }
  190 +
  191 + public void remove(String device) {
  192 + gpsMap.remove(device);
  193 + }
190 } 194 }
191 \ No newline at end of file 195 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
1 -package com.bsth.data.gpsdata_v2.entity;  
2 -  
3 -import com.fasterxml.jackson.annotation.JsonIgnore;  
4 -  
5 -/**  
6 - *  
7 - * @ClassName: GpsRealData  
8 - * @Description: TODO(HTTP接口的实时GPS数据)  
9 - * @author PanZhao  
10 - * @date 2016年5月11日 下午4:32:07  
11 - *  
12 - */  
13 -public class GpsEntity implements Cloneable{  
14 -  
15 - /** 公司代码 */  
16 - @JsonIgnore  
17 - private Short companyCode;  
18 -  
19 - /** 线路编码 */  
20 - private String lineId;  
21 -  
22 - /** 设备编码 */  
23 - private String deviceId;  
24 -  
25 - /** 停车场编码 */  
26 - private String carparkNo;  
27 -  
28 - /** 站点编码 */  
29 - private String stopNo;  
30 -  
31 - /** 站点名称 */  
32 - private String stationName;  
33 -  
34 - /** 到站时间 */  
35 - @JsonIgnore  
36 - private long arrTime;  
37 -  
38 - /** 经度 */  
39 - private Float lon;  
40 -  
41 - /** 纬度 */  
42 - private Float lat;  
43 -  
44 - /** GPS发送时间戳 */  
45 - private Long timestamp;  
46 -  
47 - /** 网关收到时间 */  
48 - private Long serverTimestamp;  
49 -  
50 - /** 速度 */  
51 - private Float speed;  
52 -  
53 - /** 方向(角度) */  
54 - private float direction;  
55 -  
56 - /** 营运状态( 0 营运 ,1 非营运, -1 无效) */  
57 - private Integer state;  
58 -  
59 - /** 上下行(0 上行 , 1 下行 , -1 无效) */  
60 - private Byte upDown;  
61 -  
62 - /**  
63 - * 设备原始走向_营运状态  
64 - * 当设备状态和系统不一致时,该字段有值  
65 - */  
66 - private String origStateStr;  
67 -  
68 - /** 车辆内部编码 */  
69 - private String nbbm;  
70 -  
71 - /** 预计到达终点时间 */  
72 - private Float expectStopTime;  
73 -  
74 - /** 当前执行班次ID */  
75 - private Long schId;  
76 -  
77 - private int version;  
78 -  
79 - /** 0: 站外 1:站内 2:场内 */  
80 - private int instation;  
81 -  
82 - /** 站点信息,站内时有值 */  
83 - @JsonIgnore  
84 - private StationRoute station;  
85 -  
86 - /**  
87 - * 前置约束 -站点编码  
88 - */  
89 - @JsonIgnore  
90 - private String premiseCode;  
91 -  
92 - /** 状态 */  
93 - private String signalState = "normal";  
94 -  
95 - /** 异常状态 */  
96 - private String abnormalStatus;  
97 -  
98 - /** 越界距离 */  
99 - private double outOfBoundDistance;  
100 -  
101 - /** gps是否有效 设备端发送的状态 */  
102 - private int valid;  
103 -  
104 - /**  
105 - * 数据来源  
106 - * 1:网关  
107 - * 0:转发  
108 - */  
109 - private int source = -1;  
110 -  
111 - private String remark;  
112 - private String planCode;  
113 -  
114 - private String dvrcode;  
115 -  
116 - public Object clone() {  
117 - try {  
118 - return super.clone();  
119 - } catch (CloneNotSupportedException e) {  
120 - return null;  
121 - }  
122 - }  
123 -  
124 - public String getDvrcode() {  
125 - return dvrcode;  
126 - }  
127 -  
128 - public void setDvrcode(String dvrcode) {  
129 - this.dvrcode = dvrcode;  
130 - }  
131 -  
132 - public String getDeviceId() {  
133 - return deviceId;  
134 - }  
135 -  
136 - public void setDeviceId(String deviceId) {  
137 - this.deviceId = deviceId;  
138 - }  
139 -  
140 - public String getCarparkNo() {  
141 - return carparkNo;  
142 - }  
143 -  
144 - public void setCarparkNo(String carparkNo) {  
145 - this.carparkNo = carparkNo;  
146 - }  
147 -  
148 - public String getStopNo() {  
149 - return stopNo;  
150 - }  
151 -  
152 - public void setStopNo(String stopNo) {  
153 - this.stopNo = stopNo;  
154 - }  
155 -  
156 - public Float getLon() {  
157 - return lon;  
158 - }  
159 -  
160 - public void setLon(Float lon) {  
161 - this.lon = lon;  
162 - }  
163 -  
164 - public Float getLat() {  
165 - return lat;  
166 - }  
167 -  
168 - public void setLat(Float lat) {  
169 - this.lat = lat;  
170 - }  
171 -  
172 - public Long getTimestamp() {  
173 - return timestamp;  
174 - }  
175 -  
176 - public void setTimestamp(Long timestamp) {  
177 - this.timestamp = timestamp;  
178 - }  
179 -  
180 -  
181 - public Integer getState() {  
182 - return state;  
183 - }  
184 -  
185 - public void setState(Integer state) {  
186 - this.state = state;  
187 - }  
188 -  
189 - public String getNbbm() {  
190 - return nbbm;  
191 - }  
192 -  
193 - public void setNbbm(String nbbm) {  
194 - this.nbbm = nbbm;  
195 - }  
196 -  
197 - public String getStationName() {  
198 - return stationName;  
199 - }  
200 -  
201 - public void setStationName(String stationName) {  
202 - this.stationName = stationName;  
203 - }  
204 -  
205 - public long getArrTime() {  
206 - return arrTime;  
207 - }  
208 -  
209 - public void setArrTime(long arrTime) {  
210 - this.arrTime = arrTime;  
211 - }  
212 -  
213 - public Float getExpectStopTime() {  
214 - return expectStopTime;  
215 - }  
216 -  
217 - public void setExpectStopTime(Float expectStopTime) {  
218 - this.expectStopTime = expectStopTime;  
219 - }  
220 -  
221 - public String getLineId() {  
222 - return lineId;  
223 - }  
224 -  
225 - public void setLineId(String lineId) {  
226 - this.lineId = lineId;  
227 - }  
228 -  
229 - public Long getSchId() {  
230 - return schId;  
231 - }  
232 -  
233 - public void setSchId(Long schId) {  
234 - this.schId = schId;  
235 - }  
236 -  
237 -  
238 - public int getVersion() {  
239 - return version;  
240 - }  
241 -  
242 - public void setVersion(int version) {  
243 - this.version = version;  
244 - }  
245 -  
246 - public StationRoute getStation() {  
247 - return station;  
248 - }  
249 -  
250 - public void setStation(StationRoute station) {  
251 - this.station = station;  
252 - }  
253 -  
254 - public String getSignalState() {  
255 - return signalState;  
256 - }  
257 -  
258 - public void setSignalState(String signalState) {  
259 - this.signalState = signalState;  
260 - }  
261 -  
262 - public int getInstation() {  
263 - return instation;  
264 - }  
265 -  
266 - public void setInstation(int instation) {  
267 - this.instation = instation;  
268 - }  
269 -  
270 - public String getAbnormalStatus() {  
271 - return abnormalStatus;  
272 - }  
273 -  
274 - public void setAbnormalStatus(String abnormalStatus) {  
275 - this.abnormalStatus = abnormalStatus;  
276 - }  
277 -  
278 - public double getOutOfBoundDistance() {  
279 - return outOfBoundDistance;  
280 - }  
281 -  
282 - public void setOutOfBoundDistance(double outOfBoundDistance) {  
283 - this.outOfBoundDistance = outOfBoundDistance;  
284 - }  
285 -  
286 - public int getValid() {  
287 - return valid;  
288 - }  
289 -  
290 - public void setValid(int valid) {  
291 - this.valid = valid;  
292 - }  
293 -  
294 -  
295 -  
296 - public short getCompanyCode() {  
297 - return companyCode;  
298 - }  
299 -  
300 - public void setCompanyCode(short companyCode) {  
301 - this.companyCode = companyCode;  
302 - }  
303 -  
304 - public Byte getUpDown() {  
305 - return upDown;  
306 - }  
307 -  
308 - public void setUpDown(Byte upDown) {  
309 - this.upDown = upDown;  
310 - }  
311 -  
312 -  
313 - public float getDirection() {  
314 - return direction;  
315 - }  
316 -  
317 - public void setDirection(float direction) {  
318 - this.direction = direction;  
319 - }  
320 -  
321 - public Float getSpeed() {  
322 - return speed;  
323 - }  
324 -  
325 - public void setSpeed(Float speed) {  
326 - this.speed = speed;  
327 - }  
328 -  
329 - public int getSource() {  
330 - return source;  
331 - }  
332 -  
333 - public void setSource(int source) {  
334 - this.source = source;  
335 - }  
336 -  
337 - public void offline(){  
338 - this.setAbnormalStatus("offline");  
339 - }  
340 -  
341 -/* public boolean isOnline(){  
342 - if(isOffline())  
343 - return false;  
344 -  
345 - long t = System.currentTimeMillis();  
346 -  
347 - if((t - this.getServerTimestamp()) > 1000 * 60 * 2){  
348 - return false;  
349 - }  
350 -  
351 - if((this.getServerTimestamp() - t) > 1000 * 60 * 3){  
352 - return false;  
353 - }  
354 - return true;  
355 - }*/  
356 -  
357 - /**  
358 - * 是否营运  
359 - * @return  
360 - */  
361 - public boolean isService(){  
362 - return state!=null && state==0;  
363 - }  
364 -  
365 - public boolean isOffline(){  
366 - return this.getAbnormalStatus() != null && this.getAbnormalStatus().equals("offline");  
367 - }  
368 -  
369 - public Long getServerTimestamp() {  
370 - return serverTimestamp;  
371 - }  
372 -  
373 - public void setServerTimestamp(Long serverTimestamp) {  
374 - this.serverTimestamp = serverTimestamp;  
375 - }  
376 -  
377 - public String getPremiseCode() {  
378 - return premiseCode;  
379 - }  
380 -  
381 - public void setPremiseCode(String premiseCode) {  
382 - this.premiseCode = premiseCode;  
383 - }  
384 -  
385 - public String getRemark() {  
386 - return remark;  
387 - }  
388 -  
389 - public void setRemark(String remark) {  
390 - this.remark = remark;  
391 - }  
392 -  
393 - public String getPlanCode() {  
394 - return planCode;  
395 - }  
396 -  
397 - public void setPlanCode(String planCode) {  
398 - this.planCode = planCode;  
399 - }  
400 -  
401 - public String getOrigStateStr() {  
402 - return origStateStr;  
403 - }  
404 -  
405 - public void setOrigStateStr(String origStateStr) {  
406 - this.origStateStr = origStateStr;  
407 - }  
408 -} 1 +package com.bsth.data.gpsdata_v2.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnore;
  4 +
  5 +/**
  6 + *
  7 + * @ClassName: GpsRealData
  8 + * @Description: TODO(HTTP接口的实时GPS数据)
  9 + * @author PanZhao
  10 + * @date 2016年5月11日 下午4:32:07
  11 + *
  12 + */
  13 +public class GpsEntity implements Cloneable{
  14 +
  15 + /** 公司代码 */
  16 + @JsonIgnore
  17 + private Short companyCode;
  18 +
  19 + /** 线路编码 */
  20 + private String lineId;
  21 +
  22 + /** 设备编码 */
  23 + private String deviceId;
  24 +
  25 + /** 停车场编码 */
  26 + private String carparkNo;
  27 +
  28 + /** 站点编码 */
  29 + private String stopNo;
  30 +
  31 + /** 站点名称 */
  32 + private String stationName;
  33 +
  34 + /** 到站时间 */
  35 + @JsonIgnore
  36 + private long arrTime;
  37 +
  38 + /** 经度 */
  39 + private Float lon;
  40 +
  41 + /** 纬度 */
  42 + private Float lat;
  43 +
  44 + /** GPS发送时间戳 */
  45 + private Long timestamp;
  46 +
  47 + /** 网关收到时间 */
  48 + private Long serverTimestamp;
  49 +
  50 + /** 速度 */
  51 + private Float speed;
  52 +
  53 + /** 方向(角度) */
  54 + private float direction;
  55 +
  56 + /** 营运状态( 0 营运 ,1 非营运, -1 无效) */
  57 + private Integer state;
  58 +
  59 + /** 上下行(0 上行 , 1 下行 , -1 无效) */
  60 + private Byte upDown;
  61 +
  62 + /**
  63 + * 设备原始走向_营运状态
  64 + * 当设备状态和系统不一致时,该字段有值
  65 + */
  66 + private String origStateStr;
  67 +
  68 + /** 车辆内部编码 */
  69 + private String nbbm;
  70 +
  71 + /** 预计到达终点时间 */
  72 + private Float expectStopTime;
  73 +
  74 + /** 当前执行班次ID */
  75 + private Long schId;
  76 +
  77 + private int version;
  78 +
  79 + /** 0: 站外 1:站内 2:场内 */
  80 + private int instation;
  81 +
  82 + /** 站点信息,站内时有值 */
  83 + @JsonIgnore
  84 + private StationRoute station;
  85 +
  86 + /**
  87 + * 前置约束 -站点编码
  88 + */
  89 + @JsonIgnore
  90 + private String premiseCode;
  91 +
  92 + /** 状态 */
  93 + private String signalState = "normal";
  94 +
  95 + /** 异常状态 */
  96 + private String abnormalStatus;
  97 +
  98 + /** 越界距离 */
  99 + private double outOfBoundDistance;
  100 +
  101 + /** gps是否有效 设备端发送的状态 */
  102 + private int valid;
  103 +
  104 + /**
  105 + * 数据来源
  106 + * 1:网关
  107 + * 0:转发
  108 + */
  109 + private int source = -1;
  110 +
  111 + private String remark;
  112 + private String planCode;
  113 +
  114 + private String dvrcode;
  115 +
  116 + /**
  117 + * 电量 单位:%
  118 + */
  119 + private int energy = -1;
  120 +
  121 + public Object clone() {
  122 + try {
  123 + return super.clone();
  124 + } catch (CloneNotSupportedException e) {
  125 + return null;
  126 + }
  127 + }
  128 +
  129 + public String getDvrcode() {
  130 + return dvrcode;
  131 + }
  132 +
  133 + public void setDvrcode(String dvrcode) {
  134 + this.dvrcode = dvrcode;
  135 + }
  136 +
  137 + public String getDeviceId() {
  138 + return deviceId;
  139 + }
  140 +
  141 + public void setDeviceId(String deviceId) {
  142 + this.deviceId = deviceId;
  143 + }
  144 +
  145 + public String getCarparkNo() {
  146 + return carparkNo;
  147 + }
  148 +
  149 + public void setCarparkNo(String carparkNo) {
  150 + this.carparkNo = carparkNo;
  151 + }
  152 +
  153 + public String getStopNo() {
  154 + return stopNo;
  155 + }
  156 +
  157 + public void setStopNo(String stopNo) {
  158 + this.stopNo = stopNo;
  159 + }
  160 +
  161 + public Float getLon() {
  162 + return lon;
  163 + }
  164 +
  165 + public void setLon(Float lon) {
  166 + this.lon = lon;
  167 + }
  168 +
  169 + public Float getLat() {
  170 + return lat;
  171 + }
  172 +
  173 + public void setLat(Float lat) {
  174 + this.lat = lat;
  175 + }
  176 +
  177 + public Long getTimestamp() {
  178 + return timestamp;
  179 + }
  180 +
  181 + public void setTimestamp(Long timestamp) {
  182 + this.timestamp = timestamp;
  183 + }
  184 +
  185 +
  186 + public Integer getState() {
  187 + return state;
  188 + }
  189 +
  190 + public void setState(Integer state) {
  191 + this.state = state;
  192 + }
  193 +
  194 + public String getNbbm() {
  195 + return nbbm;
  196 + }
  197 +
  198 + public void setNbbm(String nbbm) {
  199 + this.nbbm = nbbm;
  200 + }
  201 +
  202 + public String getStationName() {
  203 + return stationName;
  204 + }
  205 +
  206 + public void setStationName(String stationName) {
  207 + this.stationName = stationName;
  208 + }
  209 +
  210 + public long getArrTime() {
  211 + return arrTime;
  212 + }
  213 +
  214 + public void setArrTime(long arrTime) {
  215 + this.arrTime = arrTime;
  216 + }
  217 +
  218 + public Float getExpectStopTime() {
  219 + return expectStopTime;
  220 + }
  221 +
  222 + public void setExpectStopTime(Float expectStopTime) {
  223 + this.expectStopTime = expectStopTime;
  224 + }
  225 +
  226 + public String getLineId() {
  227 + return lineId;
  228 + }
  229 +
  230 + public void setLineId(String lineId) {
  231 + this.lineId = lineId;
  232 + }
  233 +
  234 + public Long getSchId() {
  235 + return schId;
  236 + }
  237 +
  238 + public void setSchId(Long schId) {
  239 + this.schId = schId;
  240 + }
  241 +
  242 +
  243 + public int getVersion() {
  244 + return version;
  245 + }
  246 +
  247 + public void setVersion(int version) {
  248 + this.version = version;
  249 + }
  250 +
  251 + public StationRoute getStation() {
  252 + return station;
  253 + }
  254 +
  255 + public void setStation(StationRoute station) {
  256 + this.station = station;
  257 + }
  258 +
  259 + public String getSignalState() {
  260 + return signalState;
  261 + }
  262 +
  263 + public void setSignalState(String signalState) {
  264 + this.signalState = signalState;
  265 + }
  266 +
  267 + public int getInstation() {
  268 + return instation;
  269 + }
  270 +
  271 + public void setInstation(int instation) {
  272 + this.instation = instation;
  273 + }
  274 +
  275 + public String getAbnormalStatus() {
  276 + return abnormalStatus;
  277 + }
  278 +
  279 + public void setAbnormalStatus(String abnormalStatus) {
  280 + this.abnormalStatus = abnormalStatus;
  281 + }
  282 +
  283 + public double getOutOfBoundDistance() {
  284 + return outOfBoundDistance;
  285 + }
  286 +
  287 + public void setOutOfBoundDistance(double outOfBoundDistance) {
  288 + this.outOfBoundDistance = outOfBoundDistance;
  289 + }
  290 +
  291 + public int getValid() {
  292 + return valid;
  293 + }
  294 +
  295 + public void setValid(int valid) {
  296 + this.valid = valid;
  297 + }
  298 +
  299 +
  300 +
  301 + public short getCompanyCode() {
  302 + return companyCode;
  303 + }
  304 +
  305 + public void setCompanyCode(short companyCode) {
  306 + this.companyCode = companyCode;
  307 + }
  308 +
  309 + public Byte getUpDown() {
  310 + return upDown;
  311 + }
  312 +
  313 + public void setUpDown(Byte upDown) {
  314 + this.upDown = upDown;
  315 + }
  316 +
  317 +
  318 + public float getDirection() {
  319 + return direction;
  320 + }
  321 +
  322 + public void setDirection(float direction) {
  323 + this.direction = direction;
  324 + }
  325 +
  326 + public Float getSpeed() {
  327 + return speed;
  328 + }
  329 +
  330 + public void setSpeed(Float speed) {
  331 + this.speed = speed;
  332 + }
  333 +
  334 + public int getSource() {
  335 + return source;
  336 + }
  337 +
  338 + public void setSource(int source) {
  339 + this.source = source;
  340 + }
  341 +
  342 + public void offline(){
  343 + this.setAbnormalStatus("offline");
  344 + }
  345 +
  346 +/* public boolean isOnline(){
  347 + if(isOffline())
  348 + return false;
  349 +
  350 + long t = System.currentTimeMillis();
  351 +
  352 + if((t - this.getServerTimestamp()) > 1000 * 60 * 2){
  353 + return false;
  354 + }
  355 +
  356 + if((this.getServerTimestamp() - t) > 1000 * 60 * 3){
  357 + return false;
  358 + }
  359 + return true;
  360 + }*/
  361 +
  362 + /**
  363 + * 是否营运
  364 + * @return
  365 + */
  366 + public boolean isService(){
  367 + return state!=null && state==0;
  368 + }
  369 +
  370 + public boolean isOffline(){
  371 + return this.getAbnormalStatus() != null && this.getAbnormalStatus().equals("offline");
  372 + }
  373 +
  374 + public Long getServerTimestamp() {
  375 + return serverTimestamp;
  376 + }
  377 +
  378 + public void setServerTimestamp(Long serverTimestamp) {
  379 + this.serverTimestamp = serverTimestamp;
  380 + }
  381 +
  382 + public String getPremiseCode() {
  383 + return premiseCode;
  384 + }
  385 +
  386 + public void setPremiseCode(String premiseCode) {
  387 + this.premiseCode = premiseCode;
  388 + }
  389 +
  390 + public String getRemark() {
  391 + return remark;
  392 + }
  393 +
  394 + public void setRemark(String remark) {
  395 + this.remark = remark;
  396 + }
  397 +
  398 + public String getPlanCode() {
  399 + return planCode;
  400 + }
  401 +
  402 + public void setPlanCode(String planCode) {
  403 + this.planCode = planCode;
  404 + }
  405 +
  406 + public String getOrigStateStr() {
  407 + return origStateStr;
  408 + }
  409 +
  410 + public void setOrigStateStr(String origStateStr) {
  411 + this.origStateStr = origStateStr;
  412 + }
  413 +
  414 + public int getEnergy() {
  415 + return energy;
  416 + }
  417 +
  418 + public void setEnergy(int energy) {
  419 + this.energy = energy;
  420 + }
  421 +}
src/main/java/com/bsth/message/buffer/CarEnergyBuffer.java 0 → 100644
  1 +package com.bsth.message.buffer;
  2 +
  3 +import com.bsth.message.entity.CarEnergy;
  4 +
  5 +import java.util.Map;
  6 +import java.util.concurrent.ConcurrentHashMap;
  7 +
  8 +/**
  9 + * @author Hill
  10 + */
  11 +public class CarEnergyBuffer {
  12 +
  13 + private static Map<String, CarEnergy> code2energy = new ConcurrentHashMap<>();
  14 +
  15 + public static void put(CarEnergy carEnergy) {
  16 + code2energy.put(carEnergy.getNbbm(), carEnergy);
  17 + }
  18 +
  19 + public static int getCarEnergy(String carCode) {
  20 + CarEnergy carEnergy = code2energy.get(carCode);
  21 +
  22 + return carEnergy == null ? -1 : (int) (carEnergy.getEnergy() * 100);
  23 + }
  24 +}
src/main/java/com/bsth/message/entity/CarEnergy.java 0 → 100644
  1 +package com.bsth.message.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import com.fasterxml.jackson.annotation.JsonProperty;
  5 +
  6 +/**
  7 + * @author Hill
  8 + */
  9 +@JsonIgnoreProperties(ignoreUnknown = true)
  10 +public class CarEnergy {
  11 +
  12 + /**
  13 + * 车辆内部编码
  14 + */
  15 + @JsonProperty("carCode")
  16 + private String nbbm;
  17 +
  18 + /**
  19 + * 剩余电量
  20 + */
  21 + private double energy;
  22 +
  23 + /**
  24 + * 最后更新时间戳
  25 + */
  26 + private long updateTimestamp;
  27 +
  28 + public String getNbbm() {
  29 + return nbbm;
  30 + }
  31 +
  32 + public void setNbbm(String nbbm) {
  33 + this.nbbm = nbbm;
  34 + }
  35 +
  36 + public double getEnergy() {
  37 + return energy;
  38 + }
  39 +
  40 + public void setEnergy(double energy) {
  41 + this.energy = energy;
  42 + }
  43 +
  44 + public long getUpdateTimestamp() {
  45 + return updateTimestamp;
  46 + }
  47 +
  48 + public void setUpdateTimestamp(long updateTimestamp) {
  49 + this.updateTimestamp = updateTimestamp;
  50 + }
  51 +}
src/main/java/com/bsth/message/entity/CarErrorStop.java 0 → 100644
  1 +package com.bsth.message.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +
  5 +/**
  6 + * 企业信息化运行监控中心
  7 + * 车辆异常停车(理论上超过5分钟)
  8 + * @author Hill
  9 + */
  10 +@JsonIgnoreProperties(ignoreUnknown = true)
  11 +public class CarErrorStop {
  12 +
  13 + /**
  14 + * ID
  15 + */
  16 + private int id;
  17 +
  18 + /**
  19 + * 日期
  20 + */
  21 + private String rq;
  22 +
  23 + /**
  24 + * 公司编码
  25 + */
  26 + private String company;
  27 +
  28 + /**
  29 + * 分公司名称
  30 + */
  31 + private String branchCompany;
  32 +
  33 + /**
  34 + * 线路名称
  35 + */
  36 + private String line;
  37 +
  38 + /**
  39 + * 线路代码
  40 + */
  41 + private String lineId;
  42 +
  43 + /**
  44 + * 车辆内部编码
  45 + */
  46 + private String nbbm;
  47 +
  48 + private String carCode;
  49 +
  50 + private String driver;
  51 +
  52 + private double lat;
  53 +
  54 + private double lon;
  55 +
  56 + /**
  57 + * 发生地址
  58 + */
  59 + private String address;
  60 +
  61 + /**
  62 + * 异常停车起始时间
  63 + */
  64 + private String startTime;
  65 +
  66 + private long startTimestamp;
  67 +
  68 + /**
  69 + * 异常停车结束时间
  70 + */
  71 + private String endTime;
  72 +
  73 + private long endTimestamp;
  74 +
  75 + /**
  76 + * 上下行
  77 + */
  78 + private int upDown;
  79 +
  80 + /**
  81 + * 备注
  82 + */
  83 + private String remark;
  84 +
  85 + public int getId() {
  86 + return id;
  87 + }
  88 +
  89 + public void setId(int id) {
  90 + this.id = id;
  91 + }
  92 +
  93 + public String getRq() {
  94 + return rq;
  95 + }
  96 +
  97 + public void setRq(String rq) {
  98 + this.rq = rq;
  99 + }
  100 +
  101 + public String getCompany() {
  102 + return company;
  103 + }
  104 +
  105 + public void setCompany(String company) {
  106 + this.company = company;
  107 + }
  108 +
  109 + public String getBranchCompany() {
  110 + return branchCompany;
  111 + }
  112 +
  113 + public void setBranchCompany(String branchCompany) {
  114 + this.branchCompany = branchCompany;
  115 + }
  116 +
  117 + public String getLine() {
  118 + return line;
  119 + }
  120 +
  121 + public void setLine(String line) {
  122 + this.line = line;
  123 + }
  124 +
  125 + public String getLineId() {
  126 + return lineId;
  127 + }
  128 +
  129 + public void setLineId(String lineId) {
  130 + this.lineId = lineId;
  131 + }
  132 +
  133 + public String getNbbm() {
  134 + return nbbm;
  135 + }
  136 +
  137 + public void setNbbm(String nbbm) {
  138 + this.nbbm = nbbm;
  139 + }
  140 +
  141 + public String getCarCode() {
  142 + return carCode;
  143 + }
  144 +
  145 + public void setCarCode(String carCode) {
  146 + this.carCode = carCode;
  147 + }
  148 +
  149 + public String getDriver() {
  150 + return driver;
  151 + }
  152 +
  153 + public void setDriver(String driver) {
  154 + this.driver = driver;
  155 + }
  156 +
  157 + public double getLat() {
  158 + return lat;
  159 + }
  160 +
  161 + public void setLat(double lat) {
  162 + this.lat = lat;
  163 + }
  164 +
  165 + public double getLon() {
  166 + return lon;
  167 + }
  168 +
  169 + public void setLon(double lon) {
  170 + this.lon = lon;
  171 + }
  172 +
  173 + public String getAddress() {
  174 + return address;
  175 + }
  176 +
  177 + public void setAddress(String address) {
  178 + this.address = address;
  179 + }
  180 +
  181 + public String getStartTime() {
  182 + return startTime;
  183 + }
  184 +
  185 + public void setStartTime(String startTime) {
  186 + this.startTime = startTime;
  187 + }
  188 +
  189 + public long getStartTimestamp() {
  190 + return startTimestamp;
  191 + }
  192 +
  193 + public void setStartTimestamp(long startTimestamp) {
  194 + this.startTimestamp = startTimestamp;
  195 + }
  196 +
  197 + public String getEndTime() {
  198 + return endTime;
  199 + }
  200 +
  201 + public void setEndTime(String endTime) {
  202 + this.endTime = endTime;
  203 + }
  204 +
  205 + public long getEndTimestamp() {
  206 + return endTimestamp;
  207 + }
  208 +
  209 + public void setEndTimestamp(long endTimestamp) {
  210 + this.endTimestamp = endTimestamp;
  211 + }
  212 +
  213 + public int getUpDown() {
  214 + return upDown;
  215 + }
  216 +
  217 + public void setUpDown(int upDown) {
  218 + this.upDown = upDown;
  219 + }
  220 +
  221 + public String getRemark() {
  222 + return remark;
  223 + }
  224 +
  225 + public void setRemark(String remark) {
  226 + this.remark = remark;
  227 + }
  228 +
  229 + @Override
  230 + public boolean equals(Object o) {
  231 + return this.id == ((CarErrorStop) o).id;
  232 + }
  233 +
  234 + @Override
  235 + public int hashCode() {
  236 + return this.id;
  237 + }
  238 +}
src/main/java/com/bsth/message/handler/MessageHandler.java 0 → 100644
  1 +package com.bsth.message.handler;
  2 +
  3 +import com.bsth.message.buffer.CarEnergyBuffer;
  4 +import com.bsth.message.entity.CarEnergy;
  5 +import com.bsth.message.entity.CarErrorStop;
  6 +import com.bsth.websocket.handler.SendUtils;
  7 +import com.fasterxml.jackson.databind.ObjectMapper;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.kafka.annotation.KafkaListener;
  10 +import org.springframework.messaging.Message;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import java.io.IOException;
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * @author Hill
  18 + */
  19 +@Component
  20 +public class MessageHandler {
  21 +
  22 + @Autowired
  23 + private SendUtils sendUtils;
  24 +
  25 + @Autowired
  26 + private ObjectMapper mapper;
  27 +
  28 + @KafkaListener(topics="schedule-mainsys-carerrorstop")
  29 + public void receivedCarErrorStop(Message<String> message) {
  30 + try {
  31 + List<CarErrorStop> carErrorStopList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarErrorStop.class));
  32 + for (CarErrorStop carErrorStop : carErrorStopList) {
  33 + sendUtils.sendCarErrorStop(carErrorStop);
  34 + }
  35 + } catch (IOException e) {
  36 + e.printStackTrace();
  37 + }
  38 + }
  39 +
  40 + @KafkaListener(topics="schedule-mainsys-carenergy")
  41 + public void receivedCarEnergy(Message<String> message) {
  42 + try {
  43 + List<CarEnergy> carEnergyList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarEnergy.class));
  44 + for (CarEnergy carEnergy : carEnergyList) {
  45 + CarEnergyBuffer.put(carEnergy);
  46 + }
  47 + } catch (IOException e) {
  48 + e.printStackTrace();
  49 + }
  50 + }
  51 +}
src/main/java/com/bsth/websocket/handler/SendUtils.java
@@ -8,6 +8,7 @@ import com.bsth.data.maintenance_plan.MaintenancePlan; @@ -8,6 +8,7 @@ import com.bsth.data.maintenance_plan.MaintenancePlan;
8 import com.bsth.data.safe_driv.SafeDriv; 8 import com.bsth.data.safe_driv.SafeDriv;
9 import com.bsth.entity.directive.D80; 9 import com.bsth.entity.directive.D80;
10 import com.bsth.entity.realcontrol.ScheduleRealInfo; 10 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  11 +import com.bsth.message.entity.CarErrorStop;
11 import com.bsth.websocket.dto.WsScheduleRealInfo; 12 import com.bsth.websocket.dto.WsScheduleRealInfo;
12 import com.fasterxml.jackson.core.JsonProcessingException; 13 import com.fasterxml.jackson.core.JsonProcessingException;
13 import com.fasterxml.jackson.databind.ObjectMapper; 14 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -268,4 +269,22 @@ public class SendUtils{ @@ -268,4 +269,22 @@ public class SendUtils{
268 logger.error("sendMaintenancePlan", e); 269 logger.error("sendMaintenancePlan", e);
269 } 270 }
270 } 271 }
  272 +
  273 + /**
  274 + * 将车辆异常停车发送至线调页面
  275 + */
  276 + public void sendCarErrorStop(CarErrorStop carErrorStop) {
  277 + Map<String, Object> map = new HashMap<>();
  278 + map.put("fn", "carErrorStop");
  279 + map.put("data", carErrorStop);
  280 + ObjectMapper mapper = new ObjectMapper();
  281 +
  282 + try {
  283 + if (carErrorStop.getLineId() != null) {
  284 + socketHandler.sendMessageToLine(carErrorStop.getLineId(), mapper.writeValueAsString(map));
  285 + }
  286 + } catch (JsonProcessingException e) {
  287 + logger.error("sendCarErrorStop", e);
  288 + }
  289 + }
271 } 290 }
src/main/resources/application-cloud.properties
@@ -30,6 +30,12 @@ spring.datasource.hikari.connection-test-query= SELECT 1 @@ -30,6 +30,12 @@ spring.datasource.hikari.connection-test-query= SELECT 1
30 spring.datasource.hikari.validation-timeout= 3000 30 spring.datasource.hikari.validation-timeout= 3000
31 spring.datasource.hikari.register-mbeans=true 31 spring.datasource.hikari.register-mbeans=true
32 32
  33 +spring.kafka.consumer.bootstrap-servers= localhost:9092
  34 +spring.kafka.consumer.group-id= schedule-system
  35 +spring.kafka.consumer.auto-offset-reset= latest
  36 +spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer
  37 +spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer
  38 +
33 ## gps client data 39 ## gps client data
34 http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all 40 http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all
35 ## gateway real data 41 ## gateway real data
src/main/resources/static/real_control_v2/fragments/home/tooltip.html
1 -<div>  
2 - <script id="tooltip_gps_temp" type="text/html">  
3 - <div class="tooltip" data-id="{{deviceId}}">  
4 - <div class="tooltip-container">  
5 -  
6 - <div class="cont-text-panel home_svg_tips">  
7 - <div class="title">  
8 - <a href="javascript:;" data-for="station" class="tip_modal">  
9 - {{nbbm}}  
10 - {{if abnormalStatus == 'outBounds'}}  
11 - <span class="abnormal-text">越界</span>  
12 - {{else if abnormalStatus == 'overspeed'}}  
13 - <span class="abnormal-text">超速</span>  
14 - {{else if abnormalStatus == 'gps-offline'}}  
15 - <span class="abnormal-text">GPS掉线</span>  
16 - {{else if abnormalStatus == 'offline'}}  
17 - <span class="abnormal-text">已离线</span>  
18 - {{/if}}  
19 - </a>  
20 - </div>  
21 - <div>  
22 - <span class="field">车牌号:</span>{{plateNo}}  
23 - </div>  
24 - <div title="{{stationName}}">  
25 - <span class="field">站点:</span>{{stationName}}  
26 - </div>  
27 - <!-- <div>  
28 - {{lineName}} -{{if upDown==0}}上行{{else}}下行{{/if}}  
29 - </div> -->  
30 - <div>  
31 - <span class="field">设备:</span>{{deviceId}}  
32 - </div>  
33 - <!--<div>  
34 - <span class="field">坐标:</span>{{lon}} {{lat}}  
35 - </div>-->  
36 - {{if sch!=null}}  
37 - <div>  
38 - <span class="field">驾驶员:</span>{{sch.jGh}}/{{sch.jName}}  
39 - </div>  
40 - {{if sch.sGh!=null && sch.sGh!=""}}  
41 - <div>  
42 - <span class="field">售票员:</span>{{sch.sGh}}/{{sch.sName}}  
43 - </div>  
44 - {{/if}}  
45 - {{/if}}  
46 - <div>  
47 - <span class="field">速度:</span>{{speed>99?'..':speed}}</div>  
48 - <div>  
49 - <span class="field">时间:</span>{{dateStr}}</div>  
50 - {{if expectStopTime!=null}}  
51 - <div>  
52 - 预计 {{expectStopTime}} 分钟到达终点</div>  
53 - {{/if}}  
54 - </div>  
55 -  
56 - <div class="tip_map_wrap"></div>  
57 - </div>  
58 - </div>  
59 - </script>  
60 -  
61 - <script id="tooltip_multi_gps_temp" type="text/html">  
62 - <div class="multi-tooltip-wrap">  
63 - {{each list as gps i}}  
64 - <div class="tooltip multi-tooltip" >  
65 - <div class="tooltip-container">  
66 - <div class="title">  
67 - <a href="javascript:;" data-for="station" class="tip_modal">  
68 - {{gps.nbbm}}  
69 - </a>  
70 - </div>  
71 - <div>  
72 - <span class="field">车牌号:</span>{{gps.plateNo}}  
73 - </div>  
74 - <div>  
75 - <span class="field">站点:</span>{{gps.stationName}}  
76 - </div>  
77 - <div>  
78 - <span class="field">设备:</span>{{gps.deviceId}}  
79 - </div>  
80 - <div style="color: #747272;">  
81 - {{gps.dateStr}}  
82 - </div>  
83 - </div>  
84 - </div>  
85 - {{/each}}  
86 - </div>  
87 - <div class="tip_map_wrap multi"></div>  
88 - </script>  
89 -  
90 -  
91 - <script id="tooltip_multi_gps_cont_temp" type="text/html">  
92 - <div class="tooltip-container">  
93 - <div class="title">  
94 - <a href="javascript:;" data-for="station" class="tip_modal">  
95 - {{nbbm}}  
96 - </a>  
97 - </div>  
98 - <div>  
99 - <span class="field">站点:</span>{{stationName}}  
100 - </div>  
101 - <div>  
102 - <span class="field">设备:</span>{{deviceId}}  
103 - </div>  
104 - <div style="color: #747272;">  
105 - {{gps.dateStr}}  
106 - </div>  
107 - </div>  
108 - </script>  
109 -</div> 1 +<div>
  2 + <script id="tooltip_gps_temp" type="text/html">
  3 + <div class="tooltip" data-id="{{deviceId}}">
  4 + <div class="tooltip-container">
  5 +
  6 + <div class="cont-text-panel home_svg_tips">
  7 + <div class="title">
  8 + <a href="javascript:;" data-for="station" class="tip_modal">
  9 + {{nbbm}}
  10 + {{if abnormalStatus == 'outBounds'}}
  11 + <span class="abnormal-text">越界</span>
  12 + {{else if abnormalStatus == 'overspeed'}}
  13 + <span class="abnormal-text">超速</span>
  14 + {{else if abnormalStatus == 'gps-offline'}}
  15 + <span class="abnormal-text">GPS掉线</span>
  16 + {{else if abnormalStatus == 'offline'}}
  17 + <span class="abnormal-text">已离线</span>
  18 + {{/if}}
  19 + </a>
  20 + </div>
  21 + <div>
  22 + <span class="field">车牌号:</span>{{plateNo}}
  23 + </div>
  24 + <div title="{{stationName}}">
  25 + <span class="field">站点:</span>{{stationName}}
  26 + </div>
  27 + <!-- <div>
  28 + {{lineName}} -{{if upDown==0}}上行{{else}}下行{{/if}}
  29 + </div> -->
  30 + <div>
  31 + <span class="field">设备:</span>{{deviceId}}
  32 + </div>
  33 + <!--<div>
  34 + <span class="field">坐标:</span>{{lon}} {{lat}}
  35 + </div>-->
  36 + {{if sch!=null}}
  37 + <div>
  38 + <span class="field">驾驶员:</span>{{sch.jGh}}/{{sch.jName}}
  39 + </div>
  40 + {{if sch.sGh!=null && sch.sGh!=""}}
  41 + <div>
  42 + <span class="field">售票员:</span>{{sch.sGh}}/{{sch.sName}}
  43 + </div>
  44 + {{/if}}
  45 + {{/if}}
  46 + <div>
  47 + <span class="field">速度:</span>{{speed>99?'..':speed}}</div>
  48 + {{if energy > -1}}
  49 + <div><span class="field">电量:</span>{{energy}}%</div>
  50 + {{/if}}
  51 + <div>
  52 + <span class="field">时间:</span>{{dateStr}}</div>
  53 + {{if expectStopTime!=null}}
  54 + <div>
  55 + 预计 {{expectStopTime}} 分钟到达终点</div>
  56 + {{/if}}
  57 + </div>
  58 +
  59 + <div class="tip_map_wrap"></div>
  60 + </div>
  61 + </div>
  62 + </script>
  63 +
  64 + <script id="tooltip_multi_gps_temp" type="text/html">
  65 + <div class="multi-tooltip-wrap">
  66 + {{each list as gps i}}
  67 + <div class="tooltip multi-tooltip" >
  68 + <div class="tooltip-container">
  69 + <div class="title">
  70 + <a href="javascript:;" data-for="station" class="tip_modal">
  71 + {{gps.nbbm}}
  72 + </a>
  73 + </div>
  74 + <div>
  75 + <span class="field">车牌号:</span>{{gps.plateNo}}
  76 + </div>
  77 + <div>
  78 + <span class="field">站点:</span>{{gps.stationName}}
  79 + </div>
  80 + <div>
  81 + <span class="field">设备:</span>{{gps.deviceId}}
  82 + </div>
  83 + <div style="color: #747272;">
  84 + {{gps.dateStr}}
  85 + </div>
  86 + </div>
  87 + </div>
  88 + {{/each}}
  89 + </div>
  90 + <div class="tip_map_wrap multi"></div>
  91 + </script>
  92 +
  93 +
  94 + <script id="tooltip_multi_gps_cont_temp" type="text/html">
  95 + <div class="tooltip-container">
  96 + <div class="title">
  97 + <a href="javascript:;" data-for="station" class="tip_modal">
  98 + {{nbbm}}
  99 + </a>
  100 + </div>
  101 + <div>
  102 + <span class="field">站点:</span>{{stationName}}
  103 + </div>
  104 + <div>
  105 + <span class="field">设备:</span>{{deviceId}}
  106 + </div>
  107 + <div style="color: #747272;">
  108 + {{gps.dateStr}}
  109 + </div>
  110 + </div>
  111 + </script>
  112 +</div>
src/main/resources/static/real_control_v2/js/platform/carErrorStop.js 0 → 100644
  1 +/**
  2 + * 车辆异常停车相关
  3 + */
  4 +var gb_carerrorstop = (function () {
  5 + var $wrap = $('.multi_plat_msg_pop_wrap');
  6 + var max = 5;
  7 +
  8 + var pop = function (data) {
  9 + //时间格式化
  10 + var stm = moment(data.bysj);
  11 + data.timeStr = stm.format('HH时mm分');
  12 + data.dateTimeStr = stm.format('YYYY-MM-DD HH:mm')
  13 + data.type = 'ces';
  14 +
  15 + var htmlStr = template('ces_plat_msg_template', data);
  16 + var items = $wrap.find('.multi_plat_msg_pop'), len = items.length;
  17 + if (len >= max)
  18 + $wrap.find('.multi_plat_msg_pop:lt(' + (len - max) + ')').remove();
  19 +
  20 + $wrap.append(htmlStr);
  21 + };
  22 +
  23 + return {
  24 + pop: pop
  25 + }
  26 +})();
0 \ No newline at end of file 27 \ No newline at end of file
src/main/resources/static/real_control_v2/js/safe_driv/safeDriv.js
@@ -90,6 +90,16 @@ var gb_safe_driv = (function () { @@ -90,6 +90,16 @@ var gb_safe_driv = (function () {
90 window.localStorage.setItem('mtPlanModal', JSON.stringify(data)); 90 window.localStorage.setItem('mtPlanModal', JSON.stringify(data));
91 open_modal('/real_control_v2/fragments/multi_plat_msg/mt_plan_modal.html', {}, {center: false, bgclose: false}); 91 open_modal('/real_control_v2/fragments/multi_plat_msg/mt_plan_modal.html', {}, {center: false, bgclose: false});
92 break; 92 break;
  93 + // 企业信息化运行监控中心
  94 + case 'ces':
  95 + var data = { nbbm: $(this).data('zbh'), clZbh: $(this).data('zbh'), start: $(this).data('start'), fcsjActualTime: $(this).data('start'), end: $(this).data('end'), zdsjActualTime: $(this).data('end'),};
  96 + $(this).remove();
  97 + if(!$('.layui-layer.play_back-layer').is(':visible')){
  98 + gb_map_play_back.initParams(data);
  99 + } else {
  100 + gb_map_play_back.setParam(data);
  101 + }
  102 + break;
93 default: 103 default:
94 break; 104 break;
95 } 105 }
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
@@ -200,6 +200,10 @@ var gb_sch_websocket = (function () { @@ -200,6 +200,10 @@ var gb_sch_websocket = (function () {
200 gb_mt_plan.pop(msg.data); 200 gb_mt_plan.pop(msg.data);
201 }; 201 };
202 202
  203 + var carErrorStop = function (msg){
  204 + gb_carerrorstop.pop(msg.data);
  205 + };
  206 +
203 var msgHandle = { 207 var msgHandle = {
204 report80: report80, 208 report80: report80,
205 faChe: faChe, 209 faChe: faChe,
@@ -213,7 +217,8 @@ var gb_sch_websocket = (function () { @@ -213,7 +217,8 @@ var gb_sch_websocket = (function () {
213 auto_wdtz: autoWdtz, 217 auto_wdtz: autoWdtz,
214 rfid: refreshRfid, 218 rfid: refreshRfid,
215 contingencyPlan: contingencyPlan, 219 contingencyPlan: contingencyPlan,
216 - maintenancePlan: maintenancePlan 220 + maintenancePlan: maintenancePlan,
  221 + carErrorStop: carErrorStop
217 }; 222 };
218 223
219 function currentSecond() { 224 function currentSecond() {
src/main/resources/static/real_control_v2/main.html
@@ -230,6 +230,7 @@ @@ -230,6 +230,7 @@
230 <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-nbbm="{{clzbh}}" data-type="{{yczltype}}" data-title="{{clzbh}} {{timeStr}} {{ycztText}}" data-url="{{url}}" data-ts="{{ts}}"> 230 <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-nbbm="{{clzbh}}" data-type="{{yczltype}}" data-title="{{clzbh}} {{timeStr}} {{ycztText}}" data-url="{{url}}" data-ts="{{ts}}">
231 <div> 231 <div>
232 <span class="title">异常&nbsp;{{clzbh}}</span> 232 <span class="title">异常&nbsp;{{clzbh}}</span>
  233 + <br/>
233 <span class="text"> {{timeStr}} 出现违规驾驶({{ycztText}})</span> 234 <span class="text"> {{timeStr}} 出现违规驾驶({{ycztText}})</span>
234 <span class="desc">--安全驾驶监管平台</span> 235 <span class="desc">--安全驾驶监管平台</span>
235 </div> 236 </div>
@@ -239,6 +240,7 @@ @@ -239,6 +240,7 @@
239 <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-id="{{id}}" data-title="{{responseState}}" data-ts="{{ts}}"> 240 <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-id="{{id}}" data-title="{{responseState}}" data-ts="{{ts}}">
240 <div> 241 <div>
241 <span class="title">应急预案</span> 242 <span class="title">应急预案</span>
  243 + <br/>
242 <span class="text"> {{instructionsContent}}</span> 244 <span class="text"> {{instructionsContent}}</span>
243 <span class="desc">--应急预案平台</span> 245 <span class="desc">--应急预案平台</span>
244 </div> 246 </div>
@@ -248,15 +250,27 @@ @@ -248,15 +250,27 @@
248 <div class="multi_plat_msg_pop uk-animation-slide-bottom" style="background-color: #0aae0a;" data-type="{{type}}" data-confirm="维修保养计划" data-line="{{line}}" data-zbh="{{zbh}}" data-bydj="{{bydj}}" data-bysj="{{dateTimeStr}}" data-bydd="{{bydd}}"> 250 <div class="multi_plat_msg_pop uk-animation-slide-bottom" style="background-color: #0aae0a;" data-type="{{type}}" data-confirm="维修保养计划" data-line="{{line}}" data-zbh="{{zbh}}" data-bydj="{{bydj}}" data-bysj="{{dateTimeStr}}" data-bydd="{{bydd}}">
249 <div> 251 <div>
250 <span class="title">维修保养计划</span> 252 <span class="title">维修保养计划</span>
  253 + <br/>
251 <span class="text"> {{zbh}}&nbsp;&nbsp;{{timeStr}}&nbsp;&nbsp;进场保养</span> 254 <span class="text"> {{zbh}}&nbsp;&nbsp;{{timeStr}}&nbsp;&nbsp;进场保养</span>
252 <span class="desc">--浦东公交维修库</span> 255 <span class="desc">--浦东公交维修库</span>
253 </div> 256 </div>
254 </div> 257 </div>
255 </script> 258 </script>
  259 +<script id="ces_plat_msg_template" type="text/html">
  260 + <div class="multi_plat_msg_pop uk-animation-slide-bottom" style="background-color: #00ccff;" data-type="{{type}}" data-zbh="{{nbbm}}" data-start="{{startTimestamp}}" data-end="{{endTimestamp}}">
  261 + <div>
  262 + <span class="title">车辆异常停车</span>
  263 + <br/>
  264 + <span class="text"> {{line}}&nbsp;{{nbbm}}&nbsp;&nbsp;在&nbsp;{{address}}&nbsp;&nbsp;异常停车</span>
  265 + <span class="desc">--企业信息化运行监控中心</span>
  266 + </div>
  267 + </div>
  268 +</script>
256 269
257 <script src="/real_control_v2/js/safe_driv/safeDriv.js" merge="custom_js"></script> 270 <script src="/real_control_v2/js/safe_driv/safeDriv.js" merge="custom_js"></script>
258 <script src="/real_control_v2/js/con_plan/conPlan.js" merge="custom_js"></script> 271 <script src="/real_control_v2/js/con_plan/conPlan.js" merge="custom_js"></script>
259 <script src="/real_control_v2/js/mt_plan/mtPlan.js" merge="custom_js"></script> 272 <script src="/real_control_v2/js/mt_plan/mtPlan.js" merge="custom_js"></script>
  273 +<script src="/real_control_v2/js/platform/carErrorStop.js" merge="custom_js"></script>
260 <!-- #### 安全驾驶 end ### --> 274 <!-- #### 安全驾驶 end ### -->
261 275
262 <!-- 打电话 --> 276 <!-- 打电话 -->
src/main/resources/static/real_control_v2/mapmonitor/fragments/map_infowindow.html
@@ -32,6 +32,9 @@ @@ -32,6 +32,9 @@
32 <p>角度:{{direction}}</p> 32 <p>角度:{{direction}}</p>
33 <p>经度:{{lon}}</p> 33 <p>经度:{{lon}}</p>
34 <p>纬度:{{lat}}</p> 34 <p>纬度:{{lat}}</p>
  35 + {{if energy > -1}}
  36 + <p>电量:{{energy}}%</p>
  37 + {{/if}}
35 38
36 <p class="date-str">{{dateStr}}</p> 39 <p class="date-str">{{dateStr}}</p>
37 <hr> 40 <hr>
@@ -40,7 +43,7 @@ @@ -40,7 +43,7 @@
40 {{/if}} 43 {{/if}}
41 <a href="javascript:;" style="float: left;" onclick="javascript:window.open('http://211.95.61.66:9020/transport_server/dvr_monitor2.html?userid=4&zbh={{nbbm}}');">DVR</a> 44 <a href="javascript:;" style="float: left;" onclick="javascript:window.open('http://211.95.61.66:9020/transport_server/dvr_monitor2.html?userid=4&zbh={{nbbm}}');">DVR</a>
42 {{if dvrcode != null}}<a href="W9:1@139.196.29.203@?method=call&1111:{{dvrcode}}" style="margin-left: 50px;" >拨打电话</a>{{/if}} 45 {{if dvrcode != null}}<a href="W9:1@139.196.29.203@?method=call&1111:{{dvrcode}}" style="margin-left: 50px;" >拨打电话</a>{{/if}}
43 - <a href="javascript:;" style="float: right;" onclick="javascript:gb_map_play_back.initParams('{{deviceId}}', '{{nbbm}}');">轨迹回放</a> 46 + <a href="javascript:;" style="float: right;" onclick="javascript:gb_map_play_back.initParams({deviceId: '{{deviceId}}', nbbm: '{{nbbm}}'});">轨迹回放</a>
44 </div> 47 </div>
45 </script> 48 </script>
46 49
src/main/resources/static/real_control_v2/mapmonitor/fragments/playback_v3/left.html
1 -<div class="play-back-form bg-grey">  
2 - <form class="uk-form uk-form-horizontal">  
3 - <div class="uk-form-row">  
4 - <label class="uk-form-label">车辆编码</label>  
5 - <div class="uk-form-controls">  
6 - <div class="uk-autocomplete uk-form autocomplete-nbbm" style="width: calc(100% - 60px)">  
7 - <div class="uk-autocomplete uk-form autocomplete-nbbm">  
8 - <input name="nbbm" required/>  
9 - </div>  
10 - </div>  
11 - <a style="color: #009688;margin-left: 5px;" data-uk-offcanvas="{target:'#carSelectOffcanvas'}">选择</a>  
12 - </div>  
13 - </div>  
14 -  
15 - <div class="uk-form-row">  
16 - <label class="uk-form-label">开始时间</label>  
17 - <div class="uk-form-controls">  
18 - <input class="flatpickr_input" name="startTime" required/>  
19 - </div>  
20 - </div>  
21 -  
22 - <div class="uk-form-row">  
23 - <label class="uk-form-label">结束时间</label>  
24 - <div class="uk-form-controls">  
25 - <input class="flatpickr_input" name="endTime" required/>  
26 - </div>  
27 - </div>  
28 - <div style="text-align: center;margin-top: 20px;">  
29 - <button class="uk-button uk-button-large uk-button-link p_back_form_submit" type="submit"><i  
30 - class="uk-icon-search"> </i> 搜索轨迹  
31 - </button>  
32 - </div>  
33 - </form>  
34 - <div class="form-error-text">  
35 - <a href="" class="uk-close uk-close-alt"></a><span></span>  
36 - </div>  
37 -</div>  
38 -  
39 -<!-- 异常table -->  
40 -<div class="play-back-abnormal_table_wrap bg-grey">  
41 - <div class="pback_abnormal_table_panel"  
42 - style="height: 100%;overflow: auto;">  
43 - <div class="ct_table abnormal_table" style="height: calc(100% - 30px);width: 500px;background: #e6e6e6;">  
44 - <div class="ct_table_head" style="background: #e6e6e6;">  
45 - <dl>  
46 - <dt>异常信息</dt>  
47 - <dt>开始时间</dt>  
48 - <dt>结束时间</dt>  
49 - <dt>所在路段</dt>  
50 - </dl>  
51 - </div>  
52 - <div class="ct_table_body">  
53 - </div>  
54 - </div>  
55 - </div>  
56 -</div>  
57 -  
58 -<!-- 行车轨迹和到离站 -->  
59 -<div class="play-back-trail-info-wrap bg-grey">  
60 - <div class="uk-width-medium-1-1">  
61 -  
62 - <ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:'#playBackV3TrailCont', swiping: false}" style="padding-left: 12px;">  
63 - <li class="uk-active"><a>行车轨迹</a></li>  
64 - <li><a>到离站信息</a></li>  
65 - </ul>  
66 - <span class="sum_mileage_span"></span>  
67 -  
68 - <ul class="uk-switcher uk-margin real_gps_info_tab_content" id="playBackV3TrailCont">  
69 - <li class="uk-active" style="height: 100%;">  
70 - <div class="trail-info-wrap" >  
71 - <div class="ct_table trail-info-table" style="height: calc(100% - 30px);">  
72 - <div class="ct_table_head" style="background: #e6e6e6;">  
73 - <dl>  
74 - <dt>时间</dt>  
75 - <dt>速度</dt>  
76 - <dt>上下行</dt>  
77 - <dt>所在路段</dt>  
78 - <dt>车载线路</dt>  
79 - </dl>  
80 - </div>  
81 - <div class="ct_table_body"></div>  
82 - </div>  
83 - </div>  
84 - </li>  
85 - <!-- 到离站数据 -->  
86 - <li style="height: 100%;">  
87 - <div class="inout_table_wrap" style="height: 100%;overflow: auto;">  
88 - <div class="ct_table" style="height: calc(100% - 30px);">  
89 - <div class="ct_table_head" style="background: #e6e6e6;">  
90 - <dl>  
91 - <dt>站点</dt>  
92 - <dt>进站时间</dt>  
93 - <dt>离站时间</dt>  
94 - <dt>上客</dt>  
95 - <dt>下客</dt>  
96 - </dl>  
97 - </div>  
98 - <div class="ct_table_body">  
99 - </div>  
100 - </div>  
101 - </div>  
102 - </li>  
103 - </ul>  
104 - </div>  
105 -</div>  
106 -  
107 -<!-- 车辆选择抽屉 -->  
108 -<div id="carSelectOffcanvas" class="uk-offcanvas">  
109 - <div class="uk-offcanvas-bar">  
110 - <div class="uk-panel offcanvas-cont">  
111 - <div class="spinner">  
112 - <div class="rect1"></div>  
113 - <div class="rect2"></div>  
114 - <div class="rect3"></div>  
115 - <div class="rect4"></div>  
116 - <div class="rect5"></div>  
117 - </div>  
118 - </div>  
119 - </div>  
120 -</div>  
121 -  
122 -<script>  
123 - var gb_playback_v3_leftpanel = (function () {  
124 -  
125 - var leftWrap = '.gps-play-back-panel-v3>div.left-panel';  
126 - var f = $('.play-back-form form', leftWrap);  
127 - var params;  
128 -  
129 - $(leftWrap).one('init-left-dom', function (e, data) {  
130 - e.stopPropagation();  
131 - params = data;  
132 -  
133 - //初始化表单  
134 - initForm();  
135 -  
136 - //固定表头  
137 - gb_ct_table.fixedHead($('.trail-info-wrap', leftWrap));  
138 - gb_ct_table.fixedHead($('.pback_abnormal_table_panel', leftWrap));  
139 - gb_ct_table.fixedHead($('.inout_table_wrap', leftWrap));  
140 - //滚动条  
141 - createScrollbar();  
142 -  
143 - //show title  
144 - /*UIkit.notify("设备端自身标识为无效的GPS点位,将不会再进入回放通路", {  
145 - status: 'info'  
146 - });*/  
147 - });  
148 -  
149 - /**  
150 - * 初始化表单  
151 - */  
152 - var initForm = function () {  
153 - if (params.nbbm)  
154 - $('[name=nbbm]', f).val(params.nbbm);  
155 - var st = moment().subtract(2, 'hour');  
156 - if (params.st)  
157 - st = moment(data.st, 'YYYY-MM-DD HH:mm');  
158 - $('[name=startTime]', f).val(st.format('YYYY-MM-DD HH:mm'));  
159 - var et = moment();  
160 - if (params.et)  
161 - et = moment(data.et, 'YYYY-MM-DD HH:mm');  
162 - $('[name=endTime]', f).val(et.format('YYYY-MM-DD HH:mm'));  
163 -  
164 - //初始化 flatpickr  
165 - var sConf = $.extend(gb_common.flatpickrDateTimeConfig, {  
166 - defaultHour: st.format('HH'),  
167 - defaultMinute: st.format('mm')  
168 - });  
169 - var eConf = $.extend(gb_common.flatpickrDateTimeConfig, {  
170 - defaultHour: et.format('HH'),  
171 - defaultMinute: et.format('mm')  
172 - });  
173 - flatpickr(leftWrap + ' .flatpickr_input[name=startTime]', sConf);  
174 - flatpickr(leftWrap + ' .flatpickr_input[name=endTime]', eConf);  
175 - };  
176 -  
177 - //搜索轨迹  
178 - var ONE_DAY = 60 * 60 * 24;  
179 - var MIN_SPACE = 60;  
180 - $('button[type=submit]', f).on('click', function (e) {  
181 - e.stopPropagation();  
182 - try {  
183 - var data = f.serializeJSON();  
184 -  
185 - //校验时间间隔  
186 - var fs = 'YYYY-MM-DD HH:mm';  
187 - var st = parseInt(moment(data.startTime, fs).format('X'));  
188 - var et = parseInt(moment(data.endTime, fs).format('X'));  
189 - data.st = st;  
190 - data.et = et;  
191 -  
192 - if (!data.nbbm || !data.nbbm.trim())  
193 - notify_err('你必须输入车辆编码');  
194 - else if (!data.startTime || !data.startTime.trim())  
195 - notify_err('你必须输入开始时间');  
196 - else if (!data.endTime || !data.endTime.trim())  
197 - notify_err('你必须输入结束时间');  
198 - else if (et < st)  
199 - notify_err('结束时间不能小于开始时间!');  
200 - else if ((et - st) > ONE_DAY)  
201 - notify_err('查询范围不能超过24小时!');  
202 - else if ((et - st) < MIN_SPACE)  
203 - notify_err('最小间隔1分钟!');  
204 - else {  
205 - show_load_btn(this);  
206 - //查询数据  
207 - get_server_trail_data(data, function (rs) {  
208 - //线路名称  
209 - var code2Name = gb_data_basic.lineCode2NameAll();  
210 - $.each(rs.list, function () {  
211 - this.lineName = code2Name[this.lineId];  
212 - this.nbbm = data.nbbm;  
213 - });  
214 - //排序  
215 - rs.list.sort(function (a, b) {  
216 - return parseInt((a.ts - b.ts) + '' + (a.stop_no - b.stop_no));  
217 - });  
218 - fillTrailTable(rs.list);//填充行车轨迹表格  
219 - fillArivalStationTable(rs.list);//填充到离站表格  
220 - $('.sum_mileage_span', leftWrap).text('共约 ' + rs.sumMileage + ' 公里');  
221 - fillAbnormalTable(rs['outboundList'], rs['speedList'],rs['gpsInvalid'],rs['gpslineSwitch'],rs['lineVerson'],rs['gpslonlatex']);//填充异常信息表格  
222 - //准备播放  
223 - rs.arrivalData = arrivalData;  
224 - $('.gps-play-back-panel-v3>div.right-panel .play-back-tools-wrap').trigger('ready-to-play', rs);  
225 -  
226 - //更新滚动条  
227 - resetScrollbar();  
228 -  
229 - /**  
230 - * 显示设备更换信息  
231 - */  
232 - var deviceStr='', fs='YYYY-MM-DD HH:mm';  
233 - for(var i=0,dc;dc=rs.dcs[i++];){  
234 - deviceStr+=dc.device + ',';  
235 - dc.stStr = dc.st>0?moment(dc.st).format(fs):'';  
236 - dc.etStr = dc.et>0?moment(dc.et).format(fs):'';  
237 - }  
238 - deviceStr=deviceStr.substr(0, deviceStr.length-1);  
239 -  
240 - $('.play-back-form>.dynamic_devices', leftWrap).remove();  
241 - $('.play-back-form>.dynamic_devices_dropdown', leftWrap).remove();  
242 - var htmlStr = template('pbv3_park_form_devices-temp', {deviceStr:deviceStr}),  
243 - htmlStr2 = template('pbv3_park_devices_dropdown-temp', {dcs:rs.dcs});  
244 - $('.play-back-form', leftWrap).append(htmlStr).append(htmlStr2);  
245 - });  
246 - }  
247 - } catch (e) {  
248 - console.log(e);  
249 - }  
250 - return false;  
251 - });  
252 -  
253 - function resetScrollbar() {  
254 - $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0);  
255 - $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0);  
256 - $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0);  
257 - }  
258 -  
259 - function destoryScrollbar() {  
260 - $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy');  
261 - $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy');  
262 - $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy');  
263 - }  
264 -  
265 - function createScrollbar() {  
266 - $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar();  
267 - $('.trail-info-wrap', leftWrap).perfectScrollbar();  
268 - $('.inout_table_wrap', leftWrap).perfectScrollbar();  
269 - }  
270 -  
271 - $('.form-error-text .uk-close', leftWrap).on('click', function (e) {  
272 - e.stopPropagation();  
273 - $('.form-error-text').removeClass('show').find('span').text('');  
274 - return false;  
275 - });  
276 -  
277 - function notify_err(t) {  
278 - $('.form-error-text', leftWrap).addClass('show').find('span').text(t);  
279 - }  
280 -  
281 - function show_load_btn(btn) {  
282 - $(btn).attr('disabled', 'disabled').html('<i class="uk-icon-spinner uk-icon-spin"> </i> ');  
283 - }  
284 -  
285 - function hide_load_btn() {  
286 - $('button[type=submit]', f).removeAttr('disabled').html('<i class="uk-icon-search"> </i> 搜索轨迹');  
287 - }  
288 -  
289 - //车辆 autocomplete  
290 - gb_common.carAutocomplete($('.autocomplete-nbbm', leftWrap), gb_data_basic.carsArray());  
291 - $('.autocomplete-nbbm', leftWrap).on('input', function () {  
292 - $('.play-back-form>.dynamic_devices', leftWrap).remove();  
293 - });  
294 -  
295 - /**  
296 - * 车辆选择抽屉显示  
297 - */  
298 - var fw = '#carSelectOffcanvas .search-form-wrap';  
299 - $('#carSelectOffcanvas').on('show.uk.offcanvas', function () {  
300 - var that = this;  
301 - $.get('/basic/ccInfo/lineArray', {idx: gb_data_basic.line_idx}, function (rs) {  
302 - if (!rs || rs.length == 0)  
303 - return;  
304 -  
305 - rs.sort(function (a, b) {  
306 - if (a.lineName == b.lineName)  
307 - return a.nbbm.localeCompare(b.nbbm);  
308 - return a.lineName.localeCompare(b.lineName);  
309 - });  
310 -  
311 - var lineNames = {};  
312 - $.each(rs, function () {  
313 - lineNames[this.lineName] = 1;  
314 - });  
315 -  
316 - var bodyStr = template('pbv3_park_list_dropdown-temp', {  
317 - list: rs,  
318 - lineNameArray: gb_common.get_keys(lineNames)  
319 - });  
320 - $('.offcanvas-cont', that).html(bodyStr);  
321 -  
322 - $('select[name=lineName]', fw).on('change', offcanvasTableFilter);  
323 - $('input[name=deviceId]', fw).on('input', offcanvasTableFilter);  
324 - $('.offcanvas-cont .uk-table tr').dblclick(function () {  
325 - var nbbm = $('td:eq(0)', this).text();  
326 - $('[name=nbbm]', f).val(nbbm);  
327 - $.UIkit.offcanvas.hide([force = false]);  
328 - });  
329 - });  
330 - });  
331 - var carTab = '.offcanvas-cont .uk-table';  
332 - var offcanvasTableFilter = function () {  
333 - var lineName = $('select[name=lineName]', fw).val();  
334 - var deviceId = $('input[name=deviceId]', fw).val();  
335 - $('tr', carTab).show().each(function () {  
336 - if (lineName && $('td:eq(2)', this).text() != lineName)  
337 - $(this).hide();  
338 -  
339 - if (deviceId && $('td:eq(1)', this).text().indexOf(deviceId) == -1)  
340 - $(this).hide();  
341 - });  
342 - };  
343 -  
344 -  
345 - /**  
346 - * 从服务器获取轨迹数据  
347 - * @param data  
348 - */  
349 - function get_server_trail_data(data, cb) {  
350 - $.ajax({  
351 - url: '/gps/history_v3/' + data.nbbm,  
352 - data: {st: data.st, et: data.et},  
353 - success: function (rs) {  
354 - $('.bg-grey', leftWrap).removeClass('bg-grey');  
355 - hide_load_btn();  
356 - if(rs.status=='ERROR'){  
357 - notify_err('异常:' + rs.msg);  
358 - }  
359 - else if(rs.status=='SUCCESS'){  
360 - if(!rs.list || rs.list.length==0){  
361 - notify_err('没有查询到历史轨迹信息');  
362 - }  
363 - cb && cb(rs);  
364 - }  
365 - },  
366 - error: function () {  
367 - hide_load_btn();  
368 - notify_err('服务器出现异常,请联系管理员!');  
369 - }  
370 - });  
371 - }  
372 -  
373 - /**  
374 - * 填充行车轨迹表格  
375 - */  
376 - function fillTrailTable(list){  
377 - var array = [];  
378 - for (var i = 0, gps; gps = list[i++];) {  
379 - //格式化时间  
380 - gps.timeStr = moment(gps.timestamp).format('HH:mm.ss');  
381 - try {  
382 - if (i > 0 && array[array.length - 1]['section_code'] == gps['section_code'])  
383 - array.pop();  
384 - }  
385 - catch (e) {  
386 - }  
387 -  
388 - if (gps['section_code'])  
389 - array.push(gps);  
390 - }  
391 - var htmlStr = template('pbv3_trail_tbody-temp', {array: array});  
392 - $('.trail-info-table .ct_table_body', leftWrap).html(htmlStr);  
393 - }  
394 -  
395 - /**  
396 - * 填充到离站数据表格  
397 - * @param list  
398 - */  
399 - var arrivalData;  
400 - function fillArivalStationTable(list){  
401 - var data, f, prev;  
402 - var $wrap = $('.inout_table_wrap', leftWrap);  
403 - var $tbody = $('.ct_table_body', $wrap);  
404 -  
405 - data = [];  
406 - $.each(list, function (i, gps) {  
407 - prev = data[data.length - 1];  
408 - if (gps['inout_stop'] == -1)  
409 - return true;  
410 - if (gps['inout_stop'] == 0 && gps['inout_stop_info']) {  
411 - //连续进站信号,取第一个  
412 - if(prev && prev['out_ts'] == null  
413 - && prev['stopName'] == gps['inout_stop_info'].stopName){  
414 - return true;  
415 - }  
416 - data.push(createIn(gps));  
417 - }  
418 - else if (gps['inout_stop'] == 1) {  
419 - f = matchOut(prev, gps);  
420 - if(f)  
421 - data.push(f);  
422 - }  
423 - });  
424 - //格式化时间  
425 - $.each(data, function (i) {  
426 - if (this.in_ts)  
427 - this.in_time_str = moment(this.in_ts).format('HH:mm.ss');  
428 - if (this.out_ts)  
429 - this.out_time_str = moment(this.out_ts).format('HH:mm.ss');  
430 - //id  
431 - this.id = 'in_out_' + i;  
432 - });  
433 -  
434 - var htmlStr = template('pbv3_inout_station_tbody-temp', {list: data});  
435 - $tbody.html(htmlStr);  
436 - arrivalData = data;  
437 - }  
438 -  
439 - var createIn = function (gps) {  
440 - var info = gps['inout_stop_info'];  
441 - return {in_ts: info.ts, stopNo: info.stopNo, stopName: info.stopName}  
442 - };  
443 - var matchOut = function (prevInfo, gps) {  
444 - var oi = gps['inout_stop_info'];  
445 - if(!oi)  
446 - return;  
447 - if(prevInfo && prevInfo.stopName == oi.stopName){  
448 - prevInfo['out_ts'] = oi.ts;  
449 - return null;  
450 - }  
451 - else {  
452 - return {out_ts: oi.ts,stopNo: oi.stopNo,stopName: oi.stopName}  
453 - }  
454 - };  
455 -  
456 - /**  
457 - * 填充异常信息表格  
458 - */  
459 - function fillAbnormalTable(){  
460 - var array = [];  
461 - for(var i = 0; i < arguments.length; i ++){  
462 - if(arguments[i]!=null)  
463 - array = array.concat(arguments[i]);  
464 - }  
465 - var i=null;  
466 - //格式化时间  
467 - $.each(array, function () {  
468 - if(!this.abnormalType&&this.version){  
469 - i=array.indexOf(this);  
470 - }  
471 - if(this.st)  
472 - this.st_str = moment(this.st).format('HH:mm.ss');  
473 - if(this.et)  
474 - this.et_str = moment(this.et).format('HH:mm.ss');  
475 - });  
476 -  
477 - if(i){  
478 - array.splice(i,1);  
479 - }  
480 - //排序  
481 - array.sort(function (a, b) {  
482 - return a.st - b.st;  
483 - });  
484 - var htmlStr = template('pbv3_abnormal_table_temp', {array: array});  
485 - $('.abnormal_table .ct_table_body', leftWrap).html(htmlStr);  
486 - }  
487 -  
488 - $(leftWrap).on('mouseover', '.dynamic_devices', function () {  
489 - $('.dynamic_devices_dropdown', leftWrap).show();  
490 - }).on('mouseout', function () {  
491 - $('.dynamic_devices_dropdown', leftWrap).hide();  
492 - });  
493 -  
494 - return {  
495 - fillTrailTable: fillTrailTable,  
496 - fillArivalStationTable: fillArivalStationTable,  
497 - destoryScrollbar: destoryScrollbar,  
498 - createScrollbar: createScrollbar  
499 - }  
500 - })(); 1 +<div class="play-back-form bg-grey">
  2 + <form class="uk-form uk-form-horizontal">
  3 + <div class="uk-form-row">
  4 + <label class="uk-form-label">车辆编码</label>
  5 + <div class="uk-form-controls">
  6 + <div class="uk-autocomplete uk-form autocomplete-nbbm" style="width: calc(100% - 60px)">
  7 + <div class="uk-autocomplete uk-form autocomplete-nbbm">
  8 + <input name="nbbm" required/>
  9 + </div>
  10 + </div>
  11 + <a style="color: #009688;margin-left: 5px;" data-uk-offcanvas="{target:'#carSelectOffcanvas'}">选择</a>
  12 + </div>
  13 + </div>
  14 +
  15 + <div class="uk-form-row">
  16 + <label class="uk-form-label">开始时间</label>
  17 + <div class="uk-form-controls">
  18 + <input class="flatpickr_input" name="startTime" required/>
  19 + </div>
  20 + </div>
  21 +
  22 + <div class="uk-form-row">
  23 + <label class="uk-form-label">结束时间</label>
  24 + <div class="uk-form-controls">
  25 + <input class="flatpickr_input" name="endTime" required/>
  26 + </div>
  27 + </div>
  28 + <div style="text-align: center;margin-top: 20px;">
  29 + <button class="uk-button uk-button-large uk-button-link p_back_form_submit" type="submit"><i
  30 + class="uk-icon-search"> </i> 搜索轨迹
  31 + </button>
  32 + </div>
  33 + </form>
  34 + <div class="form-error-text">
  35 + <a href="" class="uk-close uk-close-alt"></a><span></span>
  36 + </div>
  37 +</div>
  38 +
  39 +<!-- 异常table -->
  40 +<div class="play-back-abnormal_table_wrap bg-grey">
  41 + <div class="pback_abnormal_table_panel"
  42 + style="height: 100%;overflow: auto;">
  43 + <div class="ct_table abnormal_table" style="height: calc(100% - 30px);width: 500px;background: #e6e6e6;">
  44 + <div class="ct_table_head" style="background: #e6e6e6;">
  45 + <dl>
  46 + <dt>异常信息</dt>
  47 + <dt>开始时间</dt>
  48 + <dt>结束时间</dt>
  49 + <dt>所在路段</dt>
  50 + </dl>
  51 + </div>
  52 + <div class="ct_table_body">
  53 + </div>
  54 + </div>
  55 + </div>
  56 +</div>
  57 +
  58 +<!-- 行车轨迹和到离站 -->
  59 +<div class="play-back-trail-info-wrap bg-grey">
  60 + <div class="uk-width-medium-1-1">
  61 +
  62 + <ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:'#playBackV3TrailCont', swiping: false}" style="padding-left: 12px;">
  63 + <li class="uk-active"><a>行车轨迹</a></li>
  64 + <li><a>到离站信息</a></li>
  65 + </ul>
  66 + <span class="sum_mileage_span"></span>
  67 +
  68 + <ul class="uk-switcher uk-margin real_gps_info_tab_content" id="playBackV3TrailCont">
  69 + <li class="uk-active" style="height: 100%;">
  70 + <div class="trail-info-wrap" >
  71 + <div class="ct_table trail-info-table" style="height: calc(100% - 30px);">
  72 + <div class="ct_table_head" style="background: #e6e6e6;">
  73 + <dl>
  74 + <dt>时间</dt>
  75 + <dt>速度</dt>
  76 + <dt>上下行</dt>
  77 + <dt>所在路段</dt>
  78 + <dt>车载线路</dt>
  79 + </dl>
  80 + </div>
  81 + <div class="ct_table_body"></div>
  82 + </div>
  83 + </div>
  84 + </li>
  85 + <!-- 到离站数据 -->
  86 + <li style="height: 100%;">
  87 + <div class="inout_table_wrap" style="height: 100%;overflow: auto;">
  88 + <div class="ct_table" style="height: calc(100% - 30px);">
  89 + <div class="ct_table_head" style="background: #e6e6e6;">
  90 + <dl>
  91 + <dt>站点</dt>
  92 + <dt>进站时间</dt>
  93 + <dt>离站时间</dt>
  94 + <dt>上客</dt>
  95 + <dt>下客</dt>
  96 + </dl>
  97 + </div>
  98 + <div class="ct_table_body">
  99 + </div>
  100 + </div>
  101 + </div>
  102 + </li>
  103 + </ul>
  104 + </div>
  105 +</div>
  106 +
  107 +<!-- 车辆选择抽屉 -->
  108 +<div id="carSelectOffcanvas" class="uk-offcanvas">
  109 + <div class="uk-offcanvas-bar">
  110 + <div class="uk-panel offcanvas-cont">
  111 + <div class="spinner">
  112 + <div class="rect1"></div>
  113 + <div class="rect2"></div>
  114 + <div class="rect3"></div>
  115 + <div class="rect4"></div>
  116 + <div class="rect5"></div>
  117 + </div>
  118 + </div>
  119 + </div>
  120 +</div>
  121 +
  122 +<script>
  123 + var gb_playback_v3_leftpanel = (function () {
  124 +
  125 + var leftWrap = '.gps-play-back-panel-v3>div.left-panel';
  126 + var f = $('.play-back-form form', leftWrap);
  127 + var params;
  128 +
  129 + $(leftWrap).one('init-left-dom', function (e, data) {
  130 + e.stopPropagation();
  131 + params = data;
  132 +
  133 + //初始化表单
  134 + initForm();
  135 +
  136 + //固定表头
  137 + gb_ct_table.fixedHead($('.trail-info-wrap', leftWrap));
  138 + gb_ct_table.fixedHead($('.pback_abnormal_table_panel', leftWrap));
  139 + gb_ct_table.fixedHead($('.inout_table_wrap', leftWrap));
  140 + //滚动条
  141 + createScrollbar();
  142 +
  143 + //show title
  144 + /*UIkit.notify("设备端自身标识为无效的GPS点位,将不会再进入回放通路", {
  145 + status: 'info'
  146 + });*/
  147 + });
  148 +
  149 + /**
  150 + * 初始化表单
  151 + */
  152 + var initForm = function () {
  153 + if (params.nbbm)
  154 + $('[name=nbbm]', f).val(params.nbbm);
  155 + var st = moment().subtract(2, 'hour'), et = moment();
  156 + if (params.start)
  157 + st = moment(params.start - 300000);
  158 + $('[name=startTime]', f).val(st.format('YYYY-MM-DD HH:mm'));
  159 + if (params.end)
  160 + et = moment(params.end + 300000);
  161 + $('[name=endTime]', f).val(et.format('YYYY-MM-DD HH:mm'));
  162 +
  163 + //初始化 flatpickr
  164 + var sConf = $.extend(gb_common.flatpickrDateTimeConfig, {
  165 + defaultHour: st.format('HH'),
  166 + defaultMinute: st.format('mm')
  167 + });
  168 + var eConf = $.extend(gb_common.flatpickrDateTimeConfig, {
  169 + defaultHour: et.format('HH'),
  170 + defaultMinute: et.format('mm')
  171 + });
  172 + flatpickr(leftWrap + ' .flatpickr_input[name=startTime]', sConf);
  173 + flatpickr(leftWrap + ' .flatpickr_input[name=endTime]', eConf);
  174 + };
  175 +
  176 + //搜索轨迹
  177 + var ONE_DAY = 60 * 60 * 24;
  178 + var MIN_SPACE = 60;
  179 + $('button[type=submit]', f).on('click', function (e) {
  180 + e.stopPropagation();
  181 + try {
  182 + var data = f.serializeJSON();
  183 +
  184 + //校验时间间隔
  185 + var fs = 'YYYY-MM-DD HH:mm';
  186 + var st = parseInt(moment(data.startTime, fs).format('X'));
  187 + var et = parseInt(moment(data.endTime, fs).format('X'));
  188 + data.st = st;
  189 + data.et = et;
  190 +
  191 + if (!data.nbbm || !data.nbbm.trim())
  192 + notify_err('你必须输入车辆编码');
  193 + else if (!data.startTime || !data.startTime.trim())
  194 + notify_err('你必须输入开始时间');
  195 + else if (!data.endTime || !data.endTime.trim())
  196 + notify_err('你必须输入结束时间');
  197 + else if (et < st)
  198 + notify_err('结束时间不能小于开始时间!');
  199 + else if ((et - st) > ONE_DAY)
  200 + notify_err('查询范围不能超过24小时!');
  201 + else if ((et - st) < MIN_SPACE)
  202 + notify_err('最小间隔1分钟!');
  203 + else {
  204 + show_load_btn(this);
  205 + //查询数据
  206 + get_server_trail_data(data, function (rs) {
  207 + //线路名称
  208 + var code2Name = gb_data_basic.lineCode2NameAll();
  209 + $.each(rs.list, function () {
  210 + this.lineName = code2Name[this.lineId];
  211 + this.nbbm = data.nbbm;
  212 + });
  213 + //排序
  214 + rs.list.sort(function (a, b) {
  215 + return parseInt((a.ts - b.ts) + '' + (a.stop_no - b.stop_no));
  216 + });
  217 + fillTrailTable(rs.list);//填充行车轨迹表格
  218 + fillArivalStationTable(rs.list);//填充到离站表格
  219 + $('.sum_mileage_span', leftWrap).text('共约 ' + rs.sumMileage + ' 公里');
  220 + fillAbnormalTable(rs['outboundList'], rs['speedList'],rs['gpsInvalid'],rs['gpslineSwitch'],rs['lineVerson'],rs['gpslonlatex']);//填充异常信息表格
  221 + //准备播放
  222 + rs.arrivalData = arrivalData;
  223 + $('.gps-play-back-panel-v3>div.right-panel .play-back-tools-wrap').trigger('ready-to-play', rs);
  224 +
  225 + //更新滚动条
  226 + resetScrollbar();
  227 +
  228 + /**
  229 + * 显示设备更换信息
  230 + */
  231 + var deviceStr='', fs='YYYY-MM-DD HH:mm';
  232 + for(var i=0,dc;dc=rs.dcs[i++];){
  233 + deviceStr+=dc.device + ',';
  234 + dc.stStr = dc.st>0?moment(dc.st).format(fs):'';
  235 + dc.etStr = dc.et>0?moment(dc.et).format(fs):'';
  236 + }
  237 + deviceStr=deviceStr.substr(0, deviceStr.length-1);
  238 +
  239 + $('.play-back-form>.dynamic_devices', leftWrap).remove();
  240 + $('.play-back-form>.dynamic_devices_dropdown', leftWrap).remove();
  241 + var htmlStr = template('pbv3_park_form_devices-temp', {deviceStr:deviceStr}),
  242 + htmlStr2 = template('pbv3_park_devices_dropdown-temp', {dcs:rs.dcs});
  243 + $('.play-back-form', leftWrap).append(htmlStr).append(htmlStr2);
  244 + });
  245 + }
  246 + } catch (e) {
  247 + console.log(e);
  248 + }
  249 + return false;
  250 + });
  251 +
  252 + function resetScrollbar() {
  253 + $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0);
  254 + $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0);
  255 + $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0);
  256 + }
  257 +
  258 + function destoryScrollbar() {
  259 + $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy');
  260 + $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy');
  261 + $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy');
  262 + }
  263 +
  264 + function createScrollbar() {
  265 + $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar();
  266 + $('.trail-info-wrap', leftWrap).perfectScrollbar();
  267 + $('.inout_table_wrap', leftWrap).perfectScrollbar();
  268 + }
  269 +
  270 + $('.form-error-text .uk-close', leftWrap).on('click', function (e) {
  271 + e.stopPropagation();
  272 + $('.form-error-text').removeClass('show').find('span').text('');
  273 + return false;
  274 + });
  275 +
  276 + function notify_err(t) {
  277 + $('.form-error-text', leftWrap).addClass('show').find('span').text(t);
  278 + }
  279 +
  280 + function show_load_btn(btn) {
  281 + $(btn).attr('disabled', 'disabled').html('<i class="uk-icon-spinner uk-icon-spin"> </i> ');
  282 + }
  283 +
  284 + function hide_load_btn() {
  285 + $('button[type=submit]', f).removeAttr('disabled').html('<i class="uk-icon-search"> </i> 搜索轨迹');
  286 + }
  287 +
  288 + //车辆 autocomplete
  289 + gb_common.carAutocomplete($('.autocomplete-nbbm', leftWrap), gb_data_basic.carsArray());
  290 + $('.autocomplete-nbbm', leftWrap).on('input', function () {
  291 + $('.play-back-form>.dynamic_devices', leftWrap).remove();
  292 + });
  293 +
  294 + /**
  295 + * 车辆选择抽屉显示
  296 + */
  297 + var fw = '#carSelectOffcanvas .search-form-wrap';
  298 + $('#carSelectOffcanvas').on('show.uk.offcanvas', function () {
  299 + var that = this;
  300 + $.get('/basic/ccInfo/lineArray', {idx: gb_data_basic.line_idx}, function (rs) {
  301 + if (!rs || rs.length == 0)
  302 + return;
  303 +
  304 + rs.sort(function (a, b) {
  305 + if (a.lineName == b.lineName)
  306 + return a.nbbm.localeCompare(b.nbbm);
  307 + return a.lineName.localeCompare(b.lineName);
  308 + });
  309 +
  310 + var lineNames = {};
  311 + $.each(rs, function () {
  312 + lineNames[this.lineName] = 1;
  313 + });
  314 +
  315 + var bodyStr = template('pbv3_park_list_dropdown-temp', {
  316 + list: rs,
  317 + lineNameArray: gb_common.get_keys(lineNames)
  318 + });
  319 + $('.offcanvas-cont', that).html(bodyStr);
  320 +
  321 + $('select[name=lineName]', fw).on('change', offcanvasTableFilter);
  322 + $('input[name=deviceId]', fw).on('input', offcanvasTableFilter);
  323 + $('.offcanvas-cont .uk-table tr').dblclick(function () {
  324 + var nbbm = $('td:eq(0)', this).text();
  325 + $('[name=nbbm]', f).val(nbbm);
  326 + $.UIkit.offcanvas.hide([force = false]);
  327 + });
  328 + });
  329 + });
  330 + var carTab = '.offcanvas-cont .uk-table';
  331 + var offcanvasTableFilter = function () {
  332 + var lineName = $('select[name=lineName]', fw).val();
  333 + var deviceId = $('input[name=deviceId]', fw).val();
  334 + $('tr', carTab).show().each(function () {
  335 + if (lineName && $('td:eq(2)', this).text() != lineName)
  336 + $(this).hide();
  337 +
  338 + if (deviceId && $('td:eq(1)', this).text().indexOf(deviceId) == -1)
  339 + $(this).hide();
  340 + });
  341 + };
  342 +
  343 +
  344 + /**
  345 + * 从服务器获取轨迹数据
  346 + * @param data
  347 + */
  348 + function get_server_trail_data(data, cb) {
  349 + $.ajax({
  350 + url: '/gps/history_v3/' + data.nbbm,
  351 + data: {st: data.st, et: data.et},
  352 + success: function (rs) {
  353 + $('.bg-grey', leftWrap).removeClass('bg-grey');
  354 + hide_load_btn();
  355 + if(rs.status=='ERROR'){
  356 + notify_err('异常:' + rs.msg);
  357 + }
  358 + else if(rs.status=='SUCCESS'){
  359 + if(!rs.list || rs.list.length==0){
  360 + notify_err('没有查询到历史轨迹信息');
  361 + }
  362 + cb && cb(rs);
  363 + }
  364 + },
  365 + error: function () {
  366 + hide_load_btn();
  367 + notify_err('服务器出现异常,请联系管理员!');
  368 + }
  369 + });
  370 + }
  371 +
  372 + /**
  373 + * 填充行车轨迹表格
  374 + */
  375 + function fillTrailTable(list){
  376 + var array = [];
  377 + for (var i = 0, gps; gps = list[i++];) {
  378 + //格式化时间
  379 + gps.timeStr = moment(gps.timestamp).format('HH:mm.ss');
  380 + try {
  381 + if (i > 0 && array[array.length - 1]['section_code'] == gps['section_code'])
  382 + array.pop();
  383 + }
  384 + catch (e) {
  385 + }
  386 +
  387 + if (gps['section_code'])
  388 + array.push(gps);
  389 + }
  390 + var htmlStr = template('pbv3_trail_tbody-temp', {array: array});
  391 + $('.trail-info-table .ct_table_body', leftWrap).html(htmlStr);
  392 + }
  393 +
  394 + /**
  395 + * 填充到离站数据表格
  396 + * @param list
  397 + */
  398 + var arrivalData;
  399 + function fillArivalStationTable(list){
  400 + var data, f, prev;
  401 + var $wrap = $('.inout_table_wrap', leftWrap);
  402 + var $tbody = $('.ct_table_body', $wrap);
  403 +
  404 + data = [];
  405 + $.each(list, function (i, gps) {
  406 + prev = data[data.length - 1];
  407 + if (gps['inout_stop'] == -1)
  408 + return true;
  409 + if (gps['inout_stop'] == 0 && gps['inout_stop_info']) {
  410 + //连续进站信号,取第一个
  411 + if(prev && prev['out_ts'] == null
  412 + && prev['stopName'] == gps['inout_stop_info'].stopName){
  413 + return true;
  414 + }
  415 + data.push(createIn(gps));
  416 + }
  417 + else if (gps['inout_stop'] == 1) {
  418 + f = matchOut(prev, gps);
  419 + if(f)
  420 + data.push(f);
  421 + }
  422 + });
  423 + //格式化时间
  424 + $.each(data, function (i) {
  425 + if (this.in_ts)
  426 + this.in_time_str = moment(this.in_ts).format('HH:mm.ss');
  427 + if (this.out_ts)
  428 + this.out_time_str = moment(this.out_ts).format('HH:mm.ss');
  429 + //id
  430 + this.id = 'in_out_' + i;
  431 + });
  432 +
  433 + var htmlStr = template('pbv3_inout_station_tbody-temp', {list: data});
  434 + $tbody.html(htmlStr);
  435 + arrivalData = data;
  436 + }
  437 +
  438 + var createIn = function (gps) {
  439 + var info = gps['inout_stop_info'];
  440 + return {in_ts: info.ts, stopNo: info.stopNo, stopName: info.stopName}
  441 + };
  442 + var matchOut = function (prevInfo, gps) {
  443 + var oi = gps['inout_stop_info'];
  444 + if(!oi)
  445 + return;
  446 + if(prevInfo && prevInfo.stopName == oi.stopName){
  447 + prevInfo['out_ts'] = oi.ts;
  448 + return null;
  449 + }
  450 + else {
  451 + return {out_ts: oi.ts,stopNo: oi.stopNo,stopName: oi.stopName}
  452 + }
  453 + };
  454 +
  455 + /**
  456 + * 填充异常信息表格
  457 + */
  458 + function fillAbnormalTable(){
  459 + var array = [];
  460 + for(var i = 0; i < arguments.length; i ++){
  461 + if(arguments[i]!=null)
  462 + array = array.concat(arguments[i]);
  463 + }
  464 + var i=null;
  465 + //格式化时间
  466 + $.each(array, function () {
  467 + if(!this.abnormalType&&this.version){
  468 + i=array.indexOf(this);
  469 + }
  470 + if(this.st)
  471 + this.st_str = moment(this.st).format('HH:mm.ss');
  472 + if(this.et)
  473 + this.et_str = moment(this.et).format('HH:mm.ss');
  474 + });
  475 +
  476 + if(i){
  477 + array.splice(i,1);
  478 + }
  479 + //排序
  480 + array.sort(function (a, b) {
  481 + return a.st - b.st;
  482 + });
  483 + var htmlStr = template('pbv3_abnormal_table_temp', {array: array});
  484 + $('.abnormal_table .ct_table_body', leftWrap).html(htmlStr);
  485 + }
  486 +
  487 + $(leftWrap).on('mouseover', '.dynamic_devices', function () {
  488 + $('.dynamic_devices_dropdown', leftWrap).show();
  489 + }).on('mouseout', function () {
  490 + $('.dynamic_devices_dropdown', leftWrap).hide();
  491 + });
  492 +
  493 + return {
  494 + fillTrailTable: fillTrailTable,
  495 + fillArivalStationTable: fillArivalStationTable,
  496 + destoryScrollbar: destoryScrollbar,
  497 + createScrollbar: createScrollbar
  498 + }
  499 + })();
501 </script> 500 </script>
502 \ No newline at end of file 501 \ No newline at end of file
src/main/resources/static/real_control_v2/mapmonitor/js/playback.js
1 -/* 地图模块 轨迹回放 */  
2 -  
3 -var gb_map_play_back = (function () {  
4 -  
5 - var dom;  
6 -/* $.get('/real_control_v2/mapmonitor/fragments/playback_v2/main.html', function (rs) {  
7 - dom = rs;  
8 - });*/  
9 - $.get('/real_control_v2/mapmonitor/fragments/playback_v3/layout.html', function (rs) {  
10 - dom = rs;  
11 - });  
12 -  
13 - var setParam = function (sch) {  
14 - console.log('sch', sch);  
15 - var f = $('.play-back-form form'),  
16 - st = (sch['fcsjActualTime']?sch['fcsjActualTime']:sch['dfsjT']) - 1000 * 60 * 5,  
17 - et = (sch['zdsjActualTime']?sch['zdsjActualTime']:sch['zdsjT']) + 1000 * 60 * 5,  
18 - fs = 'YYYY-MM-DD HH:mm';  
19 -  
20 - $('[name=nbbm]', f).val(sch.clZbh);  
21 - $('[name=startTime]', f).val(moment(st).format(fs));  
22 - $('[name=endTime]', f).val(moment(et).format(fs));  
23 - };  
24 -  
25 - var initParams = function (deviceId, nbbm) {  
26 - //关闭infowindow  
27 - if (deviceId)  
28 - gb_map_imap.call('closeWin', deviceId);  
29 -  
30 - //show modal  
31 - //open_modal_dom(dom, {deviceId: deviceId, nbbm: nbbm});  
32 -  
33 - var pbv3MapWrap = '.gps-play-back-panel-v3>div.right-panel .play-back-map-wrap';  
34 - var resizeFlag;  
35 - var index = layer.open({  
36 - id: 'play_back_v3_modal',  
37 - type: 1,  
38 - title: '<i class="uk-icon-play-circle"></i> 轨迹回放',  
39 - shadeClose: true,  
40 - shade: false,  
41 - moveOut: true,  
42 - maxmin: true, //开启最大化最小化按钮  
43 - area: ['1299px', '754px'],  
44 - //moveOut: true,  
45 - skin:'layui-layer-molv play_back-layer',  
46 - content: dom,  
47 - zIndex: layer.zIndex,  
48 - success: function(layero){  
49 - layer.setTop(layero);  
50 - $('.gps-play-back-panel-v3').trigger('init', {deviceId: deviceId, nbbm: nbbm});  
51 - },  
52 - end: function () {  
53 -  
54 - },  
55 - resizing: function () {  
56 - if(resizeFlag)  
57 - return;  
58 - resizeFlag = true;  
59 - setTimeout(function () {  
60 - $(pbv3MapWrap).trigger('reset-map');  
61 - resizeFlag = false;  
62 - }, 1200);  
63 - },  
64 - full: function () {  
65 - $(pbv3MapWrap).trigger('reset-map');  
66 - },  
67 - min: function () {  
68 - $(pbv3MapWrap).trigger('reset-map');  
69 - },  
70 - restore: function () {  
71 - $(pbv3MapWrap).trigger('reset-map');  
72 - },  
73 - cancel: function () {  
74 - $(pbv3MapWrap).trigger('close');  
75 - //删除所有的flatpickr元素,避免元素堆积  
76 - $('.flatpickr-calendar.showTimeInput').remove();  
77 - }  
78 - });  
79 - layer.full(index);  
80 - };  
81 -  
82 - //导出excel  
83 - var listToExcel = function (list) {  
84 - var temp = '<html>' +  
85 - ' <head> '+  
86 - ' </head>' +  
87 - ' <body>' +  
88 - ' <table border="1">' +  
89 - ' <tr><th>序号</th><th>车辆</th><th>所在道路</th><th>经度</th><th>纬度</th><th>时间</th><th>速度</th></tr>' +  
90 - ' {{each list as gps i}}' +  
91 - ' <tr><td>{{i+1}}</td><td>{{gps.nbbm}}</td><td>{{gps.section_name}}</td><td>{{gps.lon}}</td><td>{{gps.lat}}</td><td>{{gps.timeStr}}</td><td>{{gps.speed}}</td></tr>' +  
92 - ' {{/each}}' +  
93 - ' </table>' +  
94 - ' </body>' +  
95 - ' </html>';  
96 -  
97 - var rs = template.compile(temp)({list: list});  
98 -  
99 - var uri = 'data:application/vnd.ms-excel;base64,';  
100 - return uri + base64(rs);  
101 - //location.href = uri + base64(rs);  
102 - };  
103 -  
104 -  
105 - function base64(string) {  
106 - return window.btoa(unescape(encodeURIComponent(string)));  
107 - }  
108 -  
109 - return {  
110 - initParams: initParams,  
111 - listToExcel: listToExcel,  
112 - setParam: setParam  
113 - } 1 +/* 地图模块 轨迹回放 */
  2 +
  3 +var gb_map_play_back = (function () {
  4 +
  5 + var dom;
  6 +/* $.get('/real_control_v2/mapmonitor/fragments/playback_v2/main.html', function (rs) {
  7 + dom = rs;
  8 + });*/
  9 + $.get('/real_control_v2/mapmonitor/fragments/playback_v3/layout.html', function (rs) {
  10 + dom = rs;
  11 + });
  12 +
  13 + var setParam = function (sch) {
  14 + console.log('sch', sch);
  15 + var f = $('.play-back-form form'),
  16 + st = (sch['fcsjActualTime']?sch['fcsjActualTime']:sch['dfsjT']) - 1000 * 60 * 5,
  17 + et = (sch['zdsjActualTime']?sch['zdsjActualTime']:sch['zdsjT']) + 1000 * 60 * 5,
  18 + fs = 'YYYY-MM-DD HH:mm';
  19 +
  20 + $('[name=nbbm]', f).val(sch.clZbh);
  21 + $('[name=startTime]', f).val(moment(st).format(fs));
  22 + $('[name=endTime]', f).val(moment(et).format(fs));
  23 + };
  24 +
  25 + var initParams = function (params) {
  26 + //关闭infowindow
  27 + if (params && params.deviceId)
  28 + gb_map_imap.call('closeWin', params.deviceId);
  29 +
  30 + //show modal
  31 + //open_modal_dom(dom, {deviceId: deviceId, nbbm: nbbm});
  32 +
  33 + var pbv3MapWrap = '.gps-play-back-panel-v3>div.right-panel .play-back-map-wrap';
  34 + var resizeFlag;
  35 + var index = layer.open({
  36 + id: 'play_back_v3_modal',
  37 + type: 1,
  38 + title: '<i class="uk-icon-play-circle"></i> 轨迹回放',
  39 + shadeClose: true,
  40 + shade: false,
  41 + moveOut: true,
  42 + maxmin: true, //开启最大化最小化按钮
  43 + area: ['1299px', '754px'],
  44 + //moveOut: true,
  45 + skin:'layui-layer-molv play_back-layer',
  46 + content: dom,
  47 + zIndex: layer.zIndex,
  48 + success: function(layero){
  49 + layer.setTop(layero);
  50 + $('.gps-play-back-panel-v3').trigger('init', params);
  51 + },
  52 + end: function () {
  53 +
  54 + },
  55 + resizing: function () {
  56 + if(resizeFlag)
  57 + return;
  58 + resizeFlag = true;
  59 + setTimeout(function () {
  60 + $(pbv3MapWrap).trigger('reset-map');
  61 + resizeFlag = false;
  62 + }, 1200);
  63 + },
  64 + full: function () {
  65 + $(pbv3MapWrap).trigger('reset-map');
  66 + },
  67 + min: function () {
  68 + $(pbv3MapWrap).trigger('reset-map');
  69 + },
  70 + restore: function () {
  71 + $(pbv3MapWrap).trigger('reset-map');
  72 + },
  73 + cancel: function () {
  74 + $(pbv3MapWrap).trigger('close');
  75 + //删除所有的flatpickr元素,避免元素堆积
  76 + $('.flatpickr-calendar.showTimeInput').remove();
  77 + }
  78 + });
  79 + layer.full(index);
  80 + };
  81 +
  82 + //导出excel
  83 + var listToExcel = function (list) {
  84 + var temp = '<html>' +
  85 + ' <head> '+
  86 + ' </head>' +
  87 + ' <body>' +
  88 + ' <table border="1">' +
  89 + ' <tr><th>序号</th><th>车辆</th><th>所在道路</th><th>经度</th><th>纬度</th><th>时间</th><th>速度</th></tr>' +
  90 + ' {{each list as gps i}}' +
  91 + ' <tr><td>{{i+1}}</td><td>{{gps.nbbm}}</td><td>{{gps.section_name}}</td><td>{{gps.lon}}</td><td>{{gps.lat}}</td><td>{{gps.timeStr}}</td><td>{{gps.speed}}</td></tr>' +
  92 + ' {{/each}}' +
  93 + ' </table>' +
  94 + ' </body>' +
  95 + ' </html>';
  96 +
  97 + var rs = template.compile(temp)({list: list});
  98 +
  99 + var uri = 'data:application/vnd.ms-excel;base64,';
  100 + return uri + base64(rs);
  101 + //location.href = uri + base64(rs);
  102 + };
  103 +
  104 +
  105 + function base64(string) {
  106 + return window.btoa(unescape(encodeURIComponent(string)));
  107 + }
  108 +
  109 + return {
  110 + initParams: initParams,
  111 + listToExcel: listToExcel,
  112 + setParam: setParam
  113 + }
114 })(); 114 })();
115 \ No newline at end of file 115 \ No newline at end of file