Commit 4c71a3da authored by 高飞's avatar 高飞

自动规则匹配

parent a09b31b5
package com.hzjt.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.util.concurrent.RateLimiter;
import com.hzjt.domain.*;
......@@ -16,12 +15,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.InputStream;
......@@ -32,8 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@RestController
......@@ -85,7 +77,7 @@ public class TraffController {
@Value("${alarmrecord.check.enable}")
private String checkEnable;
Long ldir = new Long(180);
@Autowired
FLVCacheService flvCacheService;
......@@ -327,15 +319,12 @@ public class TraffController {
public ResultObj traffflow(@RequestBody Vehicles vehicles) {
if ("TRAFFIC_STATISTICS_VEHICLES".equalsIgnoreCase(vehicles.getType())) {
// String time=DateUtils.formatDate(new Date(Long.valueOf(vehicles.getTs())));
// vehicles.setTs(time);
String[] sbAndTd = vehicles.getVideo_id().split("_");
String sbbh = sbAndTd[0];
int tdbh = Integer.valueOf(sbAndTd[1]) + 1;
//重置videoid
vehicles.setVideo_id(sbbh + "_" + tdbh);
//直接放入表中
// traffFlowService.saveTraffFlow(vehicles);
List<Vehiclesdetail> vels = vehicles.getObjs();
int result = 0;
for (Vehiclesdetail detail : vels) {
......@@ -397,7 +386,48 @@ public class TraffController {
}
//自动车流量推送
@PostMapping("/autotraffflow")
public ResultObj autotraffflow(@RequestBody AutoVehicles vehicles) {
log.info("autotraffflow"+vehicles.toString());
if ("TRAFFIC_STATISTICS_VEHICLES".equalsIgnoreCase(vehicles.getType())) {
String[] sbAndTd = vehicles.getVideo_id().split("_");
String sbbh = sbAndTd[0];
int tdbh = Integer.valueOf(sbAndTd[1]) + 1;
//重置videoid
vehicles.setVideo_id(sbbh + "_" + tdbh);
//直接放入表中
List<AutoVehiclesdetail> vels = vehicles.getObjs();
int result = 0;
for (AutoVehiclesdetail detail : vels) {
Vehicle v = new Vehicle();
v.setId(UUID.randomUUID().toString());
v.setCreate_time(new Date(Long.valueOf(vehicles.getTs())));
v.setType(detail.getType());
v.setDirection(detail.getDirection());
v.setRuleTag(detail.getDirection().longValue()<=ldir.longValue()?"1":"2");
v.setClassification_confidence(detail.getClassification_confidence());
v.setVideo_id(vehicles.getVideo_id());
result = traffFlowService.saveTraffFlowDetail(v);
}
//查询近五分钟的车流量,当天车流量websocket 直接推送过去
//根据连接的name ,群发根据videoid 查询的结果
webSocket.GroupSendingByVideoid(vehicles.getVideo_id());
}
return ResultObj.ok();
}
//车流量推送
@GetMapping("/test")
@ResponseBody
public String test() {
Long ldir2 = new Long(180);
String result=ldir2.longValue()<=ldir.longValue()?"2":"1";
return result;
}
......
package com.hzjt.domain;
import lombok.Data;
import java.util.List;
@Data
public class AutoVehicles {
private String id;
private String type;
private String video_id;
private String ts;
List<AutoVehiclesdetail> objs;
}
package com.hzjt.domain;
import lombok.Data;
@Data
public class AutoVehiclesdetail {
private String obj_id;
private String vehiclesid;
private String type;
private Long direction;
private Long classification_confidence;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment