Commit f0b6b57f by xmh

Merge branch 'master' into xmh-develop

2 parents 6bf89131 08efdff0
package com.viontech.controller; package com.viontech.controller;
import com.viontech.process.Process; import com.viontech.process.Process;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -14,9 +15,12 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,9 +15,12 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
public class DataController { public class DataController {
@Autowired
Process process;
@PostMapping("/data") @PostMapping("/data")
public Object receiveData(@RequestBody String dataStr) { public Object receiveData(@RequestBody String dataStr) throws Exception{
Process.process(dataStr); process.process(dataStr);
return null; return null;
} }
......
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 BehaviorProcess extends Process{
@Override
public void getData(Map jsonMap, ByteBuf byteBuf) throws Exception{
if(!jsonMap.get("event_cate").equals("behavior")){
return;
}
Integer event_refid=(Integer) jsonMap.get("event_refid");
byteBuf.writeInt(event_refid);
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(jsonMap.get("video")!=null){
List<Map> videoList= (List<Map>) jsonMap.get("video");
for (Map map : videoList) {
Date start_dt= (Date) map.get("start_dt");
Date end_dt= (Date) map.get("end_dt");
Date startDateSecond=dateFormat.parse(dateFormat.format(start_dt));
Date endDateSecond=dateFormat.parse(dateFormat.format(end_dt));
byteBuf.writeInt((int) startDateSecond.getTime());
byteBuf.writeInt((int) start_dt.getTime());
byteBuf.writeInt((int) endDateSecond.getTime());
byteBuf.writeInt((int) end_dt.getTime());
}
}else{
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
}
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 event_type= (String) jsonMap.get("event_type");
//事件类型需要转换
convertBehaviorCode(event_type,byteBuf);
Integer laneNumber=0;
String plate="";
String carType="";
String carColor="";
Integer speed=0;
String direction="";
String locationName="";
if(jsonMap.get("event_data")!=null){
Map event_data= (Map) jsonMap.get("event_data");
if(event_data.get("lane")!=null){
Map laneMap= (Map) event_data.get("lane");
if(laneMap.get("number")!=null){
laneNumber=(Integer) laneMap.get("number");
}
}
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");
}
}
if(event_data.get("uservehicle")!=null){
Map userVehicle= (Map) event_data.get("uservehicle");
carType= (String) userVehicle.get("vehicletype");
carColor= (String) userVehicle.get("vehiclecolor");
}
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");
}
}
byteBuf.writeInt(laneNumber);
if(jsonMap.get("pics")!=null){
List<Map> pics= (List<Map>) jsonMap.get("pics");
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"));
//这两个坐标不知道怎么赋值
byteBuf.writeInt(0);
byteBuf.writeInt(0);
}else{
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
}
//车牌需要转换一下
convertPlate(plate,byteBuf);
//事件录像存储位置不知道怎么赋值
byteBuf.writeBytes(new byte[128]);
//车辆类型没法给需要转换
convertCarType(carType,byteBuf);
//车身颜色需要转换
convertCarColor(carColor,byteBuf);
byteBuf.writeInt(speed);
//行驶方向需要转换
convertDirection(direction,byteBuf);
//地点名称暂时没有赋值,确认是不是用locationName
byteBuf.writeBytes(new byte[32]);
//事件快照路径不知道怎么赋值
byteBuf.writeBytes(new byte[128]);
//车身颜色2,3和权重暂时未赋值
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);
byteBuf.writeBytes(new byte[24]);
}
public void convertBehaviorCode(String event_type,ByteBuf byteBuf){
}
public void convertPlate(String plate,ByteBuf byteBuf){
}
public void convertCarType(String carType,ByteBuf byteBuf){
}
public void convertCarColor(String carColor,ByteBuf byteBuf){
}
public void convertDirection(String direction,ByteBuf byteBuf){
}
}
package com.viontech.process; package com.viontech.process;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.util.Map;
/** /**
* . * .
* *
...@@ -7,11 +13,22 @@ package com.viontech.process; ...@@ -7,11 +13,22 @@ package com.viontech.process;
* @date 2020/8/20 * @date 2020/8/20
*/ */
public class Process { public abstract class Process {
public static void process(String jsonStr) { public void process(String jsonStr) throws Exception{
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.ioBuffer();
ObjectMapper objectMapper=new ObjectMapper();
Map jsonMap=objectMapper.readValue(jsonStr,Map.class);
String vchan_refid= (String) jsonMap.get("vchan_refid");
//封装包头,暂未赋值
byteBuf.writeInt(0); //相机编号为String,他们要的是int,暂时保留
byteBuf.writeInt(0);
byteBuf.writeInt(0);
byteBuf.writeInt(0);
//封装包体
getData(jsonMap,byteBuf);
} }
public abstract void getData(Map jsonMap,ByteBuf byteBuf) throws Exception;
} }
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){
}
}
10=0
25=1
2=2
26=3
4=4
1=5
21=6
3=7
7=8
15=9
9=10
27=11
14=12
11=15
16=16
13=17
35=18
24=19
22=20
19=21
34=22
67=23
36=24
55=25
40=26
85=28
32=30
31=31
76=32
18=33
57=34
61=35
64=36
124=37
49=38
33=39
50=40
56=44
44=47
78=48
73=49
29=50
39=52
37=53
5=54
17=56
132=57
89=58
120=60
47=61
115=62
123=64
117=65
119=66
80=67
51=68
136=69
30=71
81=72
41=74
6=75
53=76
118=77
12=78
52=79
82=80
84=81
121=82
135=84
23=85
48=86
98=88
54=90
65=92
79=93
63=95
28=96
88=97
87=98
102=99
105=100
58=102
71=103
113=107
90=110
93=111
95=112
97=113
108=114
107=116
106=123
60=125
70=126
66=128
75=131
46=132
62=134
116=135
68=149
99=150
91=151
77=153
42=155
100=159
96=160
111=162
45=166
137=168
109=171
0=200000
\ No newline at end of file \ No newline at end of file
A=1
K=2
J=3
E=4
F=5
H=6
C=7
G=8
I=9
D=10
B=11
Z=12
\ No newline at end of file \ No newline at end of file
yichangtingche=0x00000001
nixing=0x00000002
24=0x00000003
huanxing=0x00000005
vehicle=0x0000000a
yongdu=0x00000007
1=0x0000001f
black=0x00000021
white=0x00000022
32=0x00000023
5=0x00000024
hengfu=0x00000027
4=0x00000028
jishui=0x0000003d
14=0x0000003e
daobantingche=0x00000062
\ No newline at end of file \ No newline at end of file
00=0
08=1
04=2
27=3
28=4
11=5
06=6
26=7
05=9
37=10
16=11
73=12
21=16
40=17
23=18
68=20
67=22
33=23
30=24
12=26
02=27
36=28
38=29
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!