Commit 980edfb4 by zhangxk

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

1 parent d52759df
...@@ -10,15 +10,14 @@ import com.viontech.utils.IntUtils; ...@@ -10,15 +10,14 @@ import com.viontech.utils.IntUtils;
import com.viontech.utils.VideoUtil; import com.viontech.utils.VideoUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.ParseException; import java.text.ParseException;
import java.util.Base64; import java.util.*;
import java.util.Date;
import java.util.Optional;
import java.util.Properties;
@Component @Component
@Slf4j @Slf4j
...@@ -36,6 +35,10 @@ public class TrafficProcess implements Process { ...@@ -36,6 +35,10 @@ public class TrafficProcess implements Process {
private Properties plateTypeProp; private Properties plateTypeProp;
@Resource @Resource
private FTPClientHelper ftpClientHelper; private FTPClientHelper ftpClientHelper;
@Value("${xcycle.illegal:71-xcycleinvehicle}")
private String xcycleIllegal;
@Resource
private BehaviorProcess behaviorProcess;
@Override @Override
...@@ -48,9 +51,27 @@ public class TrafficProcess implements Process { ...@@ -48,9 +51,27 @@ public class TrafficProcess implements Process {
JSONObject lane = eventData.getJSONObject("lane"); JSONObject lane = eventData.getJSONObject("lane");
JSONObject location = eventData.getJSONObject("location"); JSONObject location = eventData.getJSONObject("location");
JSONObject illegal = eventData.getJSONObject("illegal"); JSONObject illegal = eventData.getJSONObject("illegal");
if (illegal != null && illegal.getInteger("state") == 0) { if (illegal == null || illegal.getInteger("state") == 0) {
return null; 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("收到繁星发来的一条违法记录"); log.info("收到繁星发来的一条违法记录");
JSONArray pics = jsonObject.getJSONArray("pics"); JSONArray pics = jsonObject.getJSONArray("pics");
model.setSerialNum(IntUtils.next()); model.setSerialNum(IntUtils.next());
......
...@@ -5,4 +5,6 @@ ftp.username=myusername ...@@ -5,4 +5,6 @@ ftp.username=myusername
ftp.password=hc123456 ftp.password=hc123456
login.username=admin login.username=admin
login.password=admin
\ No newline at end of file \ No newline at end of file
login.password=admin
xcycle.illegal=71-xcycleinvehicle
\ No newline at end of file \ No newline at end of file
...@@ -13,4 +13,5 @@ hengfu=00000027 ...@@ -13,4 +13,5 @@ hengfu=00000027
4=00000028 4=00000028
jishui=0000003d jishui=0000003d
14=0000003e 14=0000003e
daobantingche=00000062
\ No newline at end of file \ No newline at end of file
daobantingche=00000062
xcycleinvehicle=0000000e
\ No newline at end of file \ 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!