Commit 7c7b5034b6149a8ccbd8da3c93c3b65abb6c58eb

Authored by 王通
1 parent c6b5d968

1.轨迹回放时异常信息中超速和越界显示异常修正

src/main/java/com/bsth/service/gps/entity/GpsOutbound_DTO.java
1 -package com.bsth.service.gps.entity;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONObject;  
5 -import com.bsth.data.BasicData;  
6 -  
7 -import java.util.*;  
8 -  
9 -/**  
10 - * 越界异常 dto  
11 - * Created by panzhao on 2017/4/7.  
12 - */  
13 -public class GpsOutbound_DTO {  
14 -  
15 - public static List<GpsOutbound_DTO> create(List<Map<String, Object>> mapList){  
16 - //默认都是一辆车的数据  
17 - List<GpsOutbound> list = JSONObject.parseArray(JSON.toJSONString(mapList), GpsOutbound.class);  
18 - GpsOutbound outbound;  
19 -  
20 - //排序  
21 - Collections.sort(list, new Comparator<GpsOutbound>() {  
22 - @Override  
23 - public int compare(GpsOutbound o1, GpsOutbound o2) {  
24 - return (int) (o1.getTimestamp() - o2.getTimestamp());  
25 - }  
26 - });  
27 -  
28 - int space = 1000 * 60;  
29 - int size = list.size();  
30 - StringBuffer locations = new StringBuffer("");  
31 -  
32 - List<GpsOutbound_DTO> rsList = new ArrayList<>();  
33 - GpsOutbound_DTO dto = null;  
34 -  
35 - for(int i = 0; i < size; i++){  
36 - outbound = list.get(i);  
37 - locations.append(outbound.location() + ";");  
38 - if(dto == null){  
39 - dto = new GpsOutbound_DTO();  
40 - dto.setDeviceId(outbound.getVehicle());  
41 - dto.setNbbm(BasicData.deviceId2NbbmMap.get(outbound.getVehicle()));  
42 - dto.setSt(outbound.getTimestamp());  
43 - }  
44 - else{  
45 - //越界结束  
46 - if((i < size - 1 && list.get(i + 1).getTimestamp() - outbound.getTimestamp() > space)){  
47 - dto.setEt(outbound.getTimestamp());  
48 - dto.setLocations(locations.toString());  
49 -  
50 - rsList.add(dto);  
51 - dto = null;  
52 - locations = new StringBuffer("");  
53 - continue;  
54 - }  
55 -  
56 - if(i == size - 1)  
57 - rsList.add(dto);  
58 - }  
59 - }  
60 -  
61 - return rsList;  
62 - }  
63 -  
64 - /**  
65 - * 设备号  
66 - */  
67 - private String deviceId;  
68 -  
69 - /**  
70 - * 自编号  
71 - */  
72 - private String nbbm;  
73 -  
74 - /**  
75 - * 越界开始时间  
76 - */  
77 - private long st;  
78 -  
79 - /**  
80 - * 越界结束时间  
81 - */  
82 - private long et;  
83 -  
84 - /**  
85 - * 越界点位集合  
86 - */  
87 - private String locations;  
88 -  
89 - /**  
90 - * 所在路段  
91 - */  
92 - private String sectionName;  
93 -  
94 - private String abnormalType = "outbound";  
95 -  
96 - public String getDeviceId() {  
97 - return deviceId;  
98 - }  
99 -  
100 - public void setDeviceId(String deviceId) {  
101 - this.deviceId = deviceId;  
102 - }  
103 -  
104 - public String getNbbm() {  
105 - return nbbm;  
106 - }  
107 -  
108 - public void setNbbm(String nbbm) {  
109 - this.nbbm = nbbm;  
110 - }  
111 -  
112 - public long getSt() {  
113 - return st;  
114 - }  
115 -  
116 - public void setSt(long st) {  
117 - this.st = st;  
118 - }  
119 -  
120 - public long getEt() {  
121 - return et;  
122 - }  
123 -  
124 - public void setEt(long et) {  
125 - this.et = et;  
126 - }  
127 -  
128 - public String getLocations() {  
129 - return locations;  
130 - }  
131 -  
132 - public void setLocations(String locations) {  
133 - this.locations = locations;  
134 - }  
135 -  
136 - public String getAbnormalType() {  
137 - return abnormalType;  
138 - }  
139 -  
140 - public void setAbnormalType(String abnormalType) {  
141 - this.abnormalType = abnormalType;  
142 - }  
143 -  
144 - public String getSectionName() {  
145 - return sectionName;  
146 - }  
147 -  
148 - public void setSectionName(String sectionName) {  
149 - this.sectionName = sectionName;  
150 - }  
151 -} 1 +package com.bsth.service.gps.entity;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.data.BasicData;
  6 +
  7 +import java.util.*;
  8 +
  9 +/**
  10 + * 越界异常 dto
  11 + * Created by panzhao on 2017/4/7.
  12 + */
  13 +public class GpsOutbound_DTO {
  14 +
  15 + public static List<GpsOutbound_DTO> create(List<Map<String, Object>> mapList){
  16 + //默认都是一辆车的数据
  17 + List<GpsOutbound> list = JSONObject.parseArray(JSON.toJSONString(mapList), GpsOutbound.class);
  18 + GpsOutbound outbound;
  19 +
  20 + //排序
  21 + Collections.sort(list, new Comparator<GpsOutbound>() {
  22 + @Override
  23 + public int compare(GpsOutbound o1, GpsOutbound o2) {
  24 + return (int) (o1.getTimestamp() - o2.getTimestamp());
  25 + }
  26 + });
  27 +
  28 + int space = 1000 * 10;
  29 + int size = list.size();
  30 + StringBuffer locations = new StringBuffer("");
  31 +
  32 + List<GpsOutbound_DTO> rsList = new ArrayList<>();
  33 + GpsOutbound_DTO dto = null;
  34 +
  35 + for(int i = 0; i < size; i++){
  36 + outbound = list.get(i);
  37 + locations.append(outbound.location() + ";");
  38 + if(dto == null){
  39 + dto = new GpsOutbound_DTO();
  40 + dto.setDeviceId(outbound.getVehicle());
  41 + dto.setNbbm(BasicData.deviceId2NbbmMap.get(outbound.getVehicle()));
  42 + dto.setSt(outbound.getTimestamp());
  43 + }
  44 + if (dto != null) {
  45 + //越界结束
  46 + if((i < size - 1 && list.get(i + 1).getTimestamp() - outbound.getTimestamp() > space)){
  47 + dto.setEt(outbound.getTimestamp());
  48 + dto.setLocations(locations.toString());
  49 +
  50 + rsList.add(dto);
  51 + dto = null;
  52 + locations = new StringBuffer("");
  53 + continue;
  54 + }
  55 +
  56 + if(i == size - 1 && dto.getEt() > 0)
  57 + rsList.add(dto);
  58 + }
  59 + }
  60 +
  61 + return rsList;
  62 + }
  63 +
  64 + /**
  65 + * 设备号
  66 + */
  67 + private String deviceId;
  68 +
  69 + /**
  70 + * 自编号
  71 + */
  72 + private String nbbm;
  73 +
  74 + /**
  75 + * 越界开始时间
  76 + */
  77 + private long st;
  78 +
  79 + /**
  80 + * 越界结束时间
  81 + */
  82 + private long et;
  83 +
  84 + /**
  85 + * 越界点位集合
  86 + */
  87 + private String locations;
  88 +
  89 + /**
  90 + * 所在路段
  91 + */
  92 + private String sectionName;
  93 +
  94 + private String abnormalType = "outbound";
  95 +
  96 + public String getDeviceId() {
  97 + return deviceId;
  98 + }
  99 +
  100 + public void setDeviceId(String deviceId) {
  101 + this.deviceId = deviceId;
  102 + }
  103 +
  104 + public String getNbbm() {
  105 + return nbbm;
  106 + }
  107 +
  108 + public void setNbbm(String nbbm) {
  109 + this.nbbm = nbbm;
  110 + }
  111 +
  112 + public long getSt() {
  113 + return st;
  114 + }
  115 +
  116 + public void setSt(long st) {
  117 + this.st = st;
  118 + }
  119 +
  120 + public long getEt() {
  121 + return et;
  122 + }
  123 +
  124 + public void setEt(long et) {
  125 + this.et = et;
  126 + }
  127 +
  128 + public String getLocations() {
  129 + return locations;
  130 + }
  131 +
  132 + public void setLocations(String locations) {
  133 + this.locations = locations;
  134 + }
  135 +
  136 + public String getAbnormalType() {
  137 + return abnormalType;
  138 + }
  139 +
  140 + public void setAbnormalType(String abnormalType) {
  141 + this.abnormalType = abnormalType;
  142 + }
  143 +
  144 + public String getSectionName() {
  145 + return sectionName;
  146 + }
  147 +
  148 + public void setSectionName(String sectionName) {
  149 + this.sectionName = sectionName;
  150 + }
  151 +}
src/main/java/com/bsth/service/gps/entity/GpsSpeed_DTO.java
1 -package com.bsth.service.gps.entity;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONObject;  
5 -import com.bsth.data.BasicData;  
6 -  
7 -import java.util.*;  
8 -  
9 -/**  
10 - * 超速异常 dto  
11 - * Created by panzhao on 2017/4/7.  
12 - */  
13 -public class GpsSpeed_DTO {  
14 -  
15 - public static List<GpsSpeed_DTO> create(List<Map<String, Object>> mapList){  
16 - //默认都是一辆车的数据  
17 - List<GpsSpeed> list = JSONObject.parseArray(JSON.toJSONString(mapList), GpsSpeed.class);  
18 - GpsSpeed gs;  
19 - //排序  
20 - Collections.sort(list, new Comparator<GpsSpeed>() {  
21 - @Override  
22 - public int compare(GpsSpeed o1, GpsSpeed o2) {  
23 - return (int) (o1.getTimestamp() - o2.getTimestamp());  
24 - }  
25 - });  
26 -  
27 - int space = 1000 * 60;  
28 - int size = list.size();  
29 -  
30 - List<GpsSpeed_DTO> rsList = new ArrayList<>();  
31 - GpsSpeed_DTO dto = null;  
32 -  
33 - for(int i = 0; i < size; i++){  
34 - gs = list.get(i);  
35 - if(dto == null){  
36 - dto = new GpsSpeed_DTO();  
37 - dto.setDeviceId(gs.getVehicle());  
38 - dto.setNbbm(BasicData.deviceId2NbbmMap.get(gs.getVehicle()));  
39 - dto.setSt(gs.getTimestamp());  
40 - dto.setSpeed(gs.getSpeed());  
41 - }  
42 - else{  
43 - //超速结束  
44 - if((i < size - 1 && list.get(i + 1).getTimestamp() - gs.getTimestamp() > space)){  
45 - dto.setEt(gs.getTimestamp());  
46 - rsList.add(dto);  
47 - dto = null;  
48 - continue;  
49 - }  
50 -  
51 - //记录最大速度  
52 - if(gs.getSpeed() > dto.getSpeed())  
53 - dto.setSpeed(gs.getSpeed());  
54 -  
55 - if(i == size - 1)  
56 - rsList.add(dto);  
57 - }  
58 - }  
59 - return rsList;  
60 - }  
61 -  
62 - /**  
63 - * 设备号  
64 - */  
65 - private String deviceId;  
66 -  
67 - /**  
68 - * 自编号  
69 - */  
70 - private String nbbm;  
71 -  
72 - /**  
73 - * 超速开始时间  
74 - */  
75 - private long st;  
76 -  
77 - /**  
78 - * 超速结束时间  
79 - */  
80 - private long et;  
81 -  
82 - /**  
83 - * 速度  
84 - */  
85 - private float speed;  
86 -  
87 - /**  
88 - * 所在路段  
89 - */  
90 - private String sectionName;  
91 -  
92 - private String abnormalType = "speed";  
93 -  
94 - public String getDeviceId() {  
95 - return deviceId;  
96 - }  
97 -  
98 - public void setDeviceId(String deviceId) {  
99 - this.deviceId = deviceId;  
100 - }  
101 -  
102 - public String getNbbm() {  
103 - return nbbm;  
104 - }  
105 -  
106 - public void setNbbm(String nbbm) {  
107 - this.nbbm = nbbm;  
108 - }  
109 -  
110 - public long getSt() {  
111 - return st;  
112 - }  
113 -  
114 - public void setSt(long st) {  
115 - this.st = st;  
116 - }  
117 -  
118 - public long getEt() {  
119 - return et;  
120 - }  
121 -  
122 - public void setEt(long et) {  
123 - this.et = et;  
124 - }  
125 -  
126 - public float getSpeed() {  
127 - return speed;  
128 - }  
129 -  
130 - public void setSpeed(float speed) {  
131 - this.speed = speed;  
132 - }  
133 -  
134 - public String getAbnormalType() {  
135 - return abnormalType;  
136 - }  
137 -  
138 - public void setAbnormalType(String abnormalType) {  
139 - this.abnormalType = abnormalType;  
140 - }  
141 -  
142 - public String getSectionName() {  
143 - return sectionName;  
144 - }  
145 -  
146 - public void setSectionName(String sectionName) {  
147 - this.sectionName = sectionName;  
148 - }  
149 -} 1 +package com.bsth.service.gps.entity;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.data.BasicData;
  6 +
  7 +import java.util.*;
  8 +
  9 +/**
  10 + * 超速异常 dto
  11 + * Created by panzhao on 2017/4/7.
  12 + */
  13 +public class GpsSpeed_DTO {
  14 +
  15 + public static List<GpsSpeed_DTO> create(List<Map<String, Object>> mapList){
  16 + //默认都是一辆车的数据
  17 + List<GpsSpeed> list = JSONObject.parseArray(JSON.toJSONString(mapList), GpsSpeed.class);
  18 + GpsSpeed gs;
  19 + //排序
  20 + Collections.sort(list, new Comparator<GpsSpeed>() {
  21 + @Override
  22 + public int compare(GpsSpeed o1, GpsSpeed o2) {
  23 + return (int) (o1.getTimestamp() - o2.getTimestamp());
  24 + }
  25 + });
  26 +
  27 + int space = 1000 * 10;
  28 + int size = list.size();
  29 +
  30 + List<GpsSpeed_DTO> rsList = new ArrayList<>();
  31 + GpsSpeed_DTO dto = null;
  32 +
  33 + for(int i = 0; i < size; i++){
  34 + gs = list.get(i);
  35 + if(dto == null){
  36 + dto = new GpsSpeed_DTO();
  37 + dto.setDeviceId(gs.getVehicle());
  38 + dto.setNbbm(BasicData.deviceId2NbbmMap.get(gs.getVehicle()));
  39 + dto.setSt(gs.getTimestamp());
  40 + dto.setSpeed(gs.getSpeed());
  41 + }
  42 + if (dto != null) {
  43 + //超速结束
  44 + if((i < size - 1 && list.get(i + 1).getTimestamp() - gs.getTimestamp() > space)){
  45 + dto.setEt(gs.getTimestamp());
  46 + rsList.add(dto);
  47 + dto = null;
  48 + continue;
  49 + }
  50 +
  51 + //记录最大速度
  52 + if(gs.getSpeed() > dto.getSpeed())
  53 + dto.setSpeed(gs.getSpeed());
  54 +
  55 + if(i == size - 1 && dto.getEt() > 0)
  56 + rsList.add(dto);
  57 + }
  58 + }
  59 + return rsList;
  60 + }
  61 +
  62 + /**
  63 + * 设备号
  64 + */
  65 + private String deviceId;
  66 +
  67 + /**
  68 + * 自编号
  69 + */
  70 + private String nbbm;
  71 +
  72 + /**
  73 + * 超速开始时间
  74 + */
  75 + private long st;
  76 +
  77 + /**
  78 + * 超速结束时间
  79 + */
  80 + private long et;
  81 +
  82 + /**
  83 + * 速度
  84 + */
  85 + private float speed;
  86 +
  87 + /**
  88 + * 所在路段
  89 + */
  90 + private String sectionName;
  91 +
  92 + private String abnormalType = "speed";
  93 +
  94 + public String getDeviceId() {
  95 + return deviceId;
  96 + }
  97 +
  98 + public void setDeviceId(String deviceId) {
  99 + this.deviceId = deviceId;
  100 + }
  101 +
  102 + public String getNbbm() {
  103 + return nbbm;
  104 + }
  105 +
  106 + public void setNbbm(String nbbm) {
  107 + this.nbbm = nbbm;
  108 + }
  109 +
  110 + public long getSt() {
  111 + return st;
  112 + }
  113 +
  114 + public void setSt(long st) {
  115 + this.st = st;
  116 + }
  117 +
  118 + public long getEt() {
  119 + return et;
  120 + }
  121 +
  122 + public void setEt(long et) {
  123 + this.et = et;
  124 + }
  125 +
  126 + public float getSpeed() {
  127 + return speed;
  128 + }
  129 +
  130 + public void setSpeed(float speed) {
  131 + this.speed = speed;
  132 + }
  133 +
  134 + public String getAbnormalType() {
  135 + return abnormalType;
  136 + }
  137 +
  138 + public void setAbnormalType(String abnormalType) {
  139 + this.abnormalType = abnormalType;
  140 + }
  141 +
  142 + public String getSectionName() {
  143 + return sectionName;
  144 + }
  145 +
  146 + public void setSectionName(String sectionName) {
  147 + this.sectionName = sectionName;
  148 + }
  149 +}