Commit 980edfb4 by zhangxk

非机动车等违法改为事件数据对接

1 parent d52759df
......@@ -10,15 +10,14 @@ import com.viontech.utils.IntUtils;
import com.viontech.utils.VideoUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.util.Base64;
import java.util.Date;
import java.util.Optional;
import java.util.Properties;
import java.util.*;
@Component
@Slf4j
......@@ -36,6 +35,10 @@ public class TrafficProcess implements Process {
private Properties plateTypeProp;
@Resource
private FTPClientHelper ftpClientHelper;
@Value("${xcycle.illegal:71-xcycleinvehicle}")
private String xcycleIllegal;
@Resource
private BehaviorProcess behaviorProcess;
@Override
......@@ -48,9 +51,27 @@ public class TrafficProcess implements Process {
JSONObject lane = eventData.getJSONObject("lane");
JSONObject location = eventData.getJSONObject("location");
JSONObject illegal = eventData.getJSONObject("illegal");
if (illegal != null && illegal.getInteger("state") == 0) {
if (illegal == null || illegal.getInteger("state") == 0) {
return null;
}
String illegalCode = illegal.getString("code");
//非机动车违法转为事件推送
String[] illegalBehavior = xcycleIllegal.split(",");
Map<String,String> illegalBehaviorMap = new HashMap<>();
for (String s : illegalBehavior) {
String[] split = s.split("-");
illegalBehaviorMap.put(split[0],split[1]);
}
if(illegalBehaviorMap.containsKey(illegalCode)){
jsonObject.put("event_cate","behavior");
jsonObject.put("event_type",illegalBehaviorMap.get(illegalCode));
log.info("非机动车违法数据,转为事件推送");
JSONObject logs = JSONObject.parseObject(jsonObject.toJSONString());
logs.remove("pics");
logs.remove("video");
log.info("推送非机动车事件:"+logs);
return behaviorProcess.process(jsonObject);
}
log.info("收到繁星发来的一条违法记录");
JSONArray pics = jsonObject.getJSONArray("pics");
model.setSerialNum(IntUtils.next());
......
......@@ -6,3 +6,5 @@ ftp.password=hc123456
login.username=admin
login.password=admin
xcycle.illegal=71-xcycleinvehicle
\ No newline at end of file
......@@ -14,3 +14,4 @@ hengfu=00000027
jishui=0000003d
14=0000003e
daobantingche=00000062
xcycleinvehicle=0000000e
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!