TrafficProcess.java
8.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
package com.viontech.process;
import io.netty.buffer.ByteBuf;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class TrafficProcess extends Process{
@Override
public void getData(Map jsonMap, ByteBuf byteBuf) throws Exception {
if(!jsonMap.get("event_cate").equals("traffic")){
return;
}
Integer event_refid=(Integer) jsonMap.get("event_refid");
byteBuf.writeInt(event_refid);
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date event_dt= (Date) jsonMap.get("event_dt");
Date eventDateSecond=dateFormat.parse(dateFormat.format(event_dt));
byteBuf.writeInt((int) eventDateSecond.getTime());
byteBuf.writeInt((int) event_dt.getTime());
String plate="";
String plateColor="";
Integer plateScore=0;
Integer laneNumber=0;
String carType="";
String carColor="";
Integer speed=0;
String direction="";
String logoType="";
String locationName="";
String illegalType="";
Integer limit_speed=0;
Integer spark_speed=0;
Integer red_start_time=0;
Integer red_end_time=0;
Integer red_start_second=0;
Integer red_end_second=0;
if(jsonMap.get("event_data")!=null){
Map event_data= (Map) jsonMap.get("event_data");
if(event_data.get("vehicle")!=null){
Map vehicle= (Map) event_data.get("vehicle");
if(vehicle.get("plate")!=null){
Map plateMap= (Map) vehicle.get("plate");
plate= (String) plateMap.get("text");
plateScore= (Integer) plateMap.get("score");
}
}
if(event_data.get("uservehicle")!=null){
Map userVehicle= (Map) event_data.get("uservehicle");
plateColor= (String) userVehicle.get("platetype");
carType= (String) userVehicle.get("vehicletype");
carColor= (String) userVehicle.get("vehiclecolor");
logoType= (String) userVehicle.get("logotype");
}
if(event_data.get("lane")!=null){
Map laneMap= (Map) event_data.get("lane");
if(laneMap.get("number")!=null){
laneNumber=(Integer) laneMap.get("number");
}
}
speed=Integer.valueOf(String.valueOf((Double)event_data.get("speed")));
if(event_data.get("location")!=null){
Map locationMap= (Map) event_data.get("location");
if(locationMap.get("drive_direction")!=null){
Map directionMap= (Map) locationMap.get("drive_direction");
direction= (String) directionMap.get("code");
}
locationName= (String) locationMap.get("name");
}
if(event_data.get("illegal")!=null){
Map illegalMap= (Map) event_data.get("illegal");
if((Integer)illegalMap.get("state")==1){
illegalType= (String) illegalMap.get("code");
if(illegalMap.get("detail")!=null){
Map detailMap= (Map) illegalMap.get("detail");
Date red_start_dt= (Date) detailMap.get("start_dt");
Date red_end_dt= (Date) detailMap.get("end_dt");
Date startDateSecond=dateFormat.parse(dateFormat.format(red_start_dt));
Date endDateSecond=dateFormat.parse(dateFormat.format(red_end_dt));
red_start_time=(int)red_start_dt.getTime();
red_end_time=(int)red_end_dt.getTime();
red_start_second=(int)startDateSecond.getTime();
red_end_second=(int)endDateSecond.getTime();
limit_speed=Integer.valueOf(String.valueOf((Double)event_data.get("limit_speed")));
spark_speed=Integer.valueOf(String.valueOf((Double)event_data.get("spark_speed")));
}
}
}
}
//车牌需要转换一下
convertPlate(plate,byteBuf);
//车牌类型(颜色)需要转换一下
convertPlateColor(plateColor,byteBuf);
byteBuf.writeInt(plateScore);
byteBuf.writeInt(laneNumber);
//车辆类型需要转换
convertCarType(carType,byteBuf);
if(jsonMap.get("pics")!=null){
List<Map> pics= (List<Map>) jsonMap.get("pics");
if(pics.size()<2){
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
}else{
String picbase64= (String) pics.get(1).get("pic_base64");
byteBuf.writeInt(picbase64.getBytes().length);
byteBuf.writeInt((Integer) pics.get(1).get("width"));
byteBuf.writeInt((Integer) pics.get(1).get("hight"));
}
String picbase64= (String) pics.get(0).get("pic_base64");
byteBuf.writeInt(picbase64.getBytes().length);
byteBuf.writeInt((Integer) pics.get(0).get("width"));
byteBuf.writeInt((Integer) pics.get(0).get("hight"));
if(pics.get(0).get("object_rect")!=null){
Map object_rect= (Map) pics.get(0).get("object_rect");
byteBuf.writeInt(Integer.valueOf(String.valueOf((Double)object_rect.get("left"))));
byteBuf.writeInt(Integer.valueOf(String.valueOf((Double)object_rect.get("top"))));
byteBuf.writeInt(Integer.valueOf(String.valueOf((Double)object_rect.get("right"))));
byteBuf.writeInt(Integer.valueOf(String.valueOf((Double)object_rect.get("bottom"))));
}else{
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
}
}else{
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
}
//车身颜色需要转换
convertCarColor(carColor,byteBuf);
byteBuf.writeInt(speed);
//行驶方向需要转换
convertDirection(direction,byteBuf);
//车商标志需要转换
convertLogo(logoType,byteBuf);
//地点名称暂时没有赋值,确认是不是用locationName
byteBuf.writeBytes(new byte[32]);
//录像路径不知道怎么赋值
byteBuf.writeBytes(new byte[128]);
//第一张全景图路径不知道怎么赋值
byteBuf.writeBytes(new byte[128]);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
//车型细分暂时未赋值
byteBuf.writeInt(0);
//车牌结构暂时未赋值
byteBuf.writeInt(0);
//违章类型需要转换
convertIllegalType(illegalType,byteBuf);
byteBuf.writeInt(0);
//第二张图片时间不知道
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(red_start_second);
byteBuf.writeInt(red_start_time);
byteBuf.writeInt(red_end_second);
byteBuf.writeInt(red_end_time);
byteBuf.writeInt(limit_speed);
byteBuf.writeInt(spark_speed);
//保留字段,char[4]
byteBuf.writeBytes(new byte[64]);
}
public void convertPlate(String plate,ByteBuf byteBuf){
}
public void convertPlateColor(String plateColor,ByteBuf byteBuf){
}
public void convertCarType(String carType,ByteBuf byteBuf){
}
public void convertCarColor(String carColor,ByteBuf byteBuf){
}
public void convertDirection(String direction,ByteBuf byteBuf){
}
public void convertLogo(String logo,ByteBuf byteBuf){
}
public void convertIllegalType(String illegal,ByteBuf byteBuf){
}
}