从isc取车辆不安全行为识别数据(超速)
This commit is contained in:
parent
97c0f7d421
commit
649320930f
@ -73,10 +73,10 @@ public class CarDangerDetectRecord implements Serializable {
|
||||
private java.lang.String alarmDesc;
|
||||
|
||||
/**
|
||||
* 类型 1-烟感报警,2-明火报警,3-人员到底报警,4-未带安全帽报警,5-区域入侵报警,6-越界入侵报警,7-人员聚集报警, 8-反光衣、9-裸土覆盖,13口罩识别,14徘徊预警,15物体滞留监测,16绊线监测
|
||||
* 类型 1-车辆超速
|
||||
*/
|
||||
@Excel(name = "类型 1-烟感报警,2-明火报警,3-人员到底报警,4-未带安全帽报警,5-区域入侵报警,6-越界入侵报警,7-人员聚集报警, 8-反光衣、9-裸土覆盖,13口罩识别,14徘徊预警,15物体滞留监测,16绊线监测", width = 15)
|
||||
@ApiModelProperty(value = "类型 1-烟感报警,2-明火报警,3-人员到底报警,4-未带安全帽报警,5-区域入侵报警,6-越界入侵报警,7-人员聚集报警, 8-反光衣、9-裸土覆盖,13口罩识别,14徘徊预警,15物体滞留监测,16绊线监测")
|
||||
@Excel(name = "类型 1-车辆超速", width = 15)
|
||||
@ApiModelProperty(value = "类型 1-车辆超速")
|
||||
private java.lang.Integer alarmType;
|
||||
/**
|
||||
* 位置
|
||||
@ -152,8 +152,18 @@ public class CarDangerDetectRecord implements Serializable {
|
||||
private java.util.Date updateDate;
|
||||
@ApiModelProperty(value = "是否推送给承包商")
|
||||
private Boolean isPushed;
|
||||
@ApiModelProperty(value = "处置方式:1:违章再教育;2:加入黑名单;")
|
||||
@ApiModelProperty(value = "处置方式:1:违章再教育;2:加入黑名单;")
|
||||
private Integer handleType;
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
@ApiModelProperty(value = "车牌号")
|
||||
private String carNumber;
|
||||
/**
|
||||
* 当前车速(km/h)
|
||||
*/
|
||||
@ApiModelProperty(value = "当前车速(km/h)")
|
||||
private java.math.BigDecimal currentSpeed;
|
||||
/**
|
||||
* 推送人id字符串数组
|
||||
*/
|
||||
|
||||
@ -178,7 +178,7 @@ public class CarDangerDetectRecordServiceImpl extends ServiceImpl<CarDangerDetec
|
||||
}
|
||||
|
||||
private List<DictionaryItem> setAlarmTypeName(String projectSn, List<CarDangerDetectRecord> carDangerDetectRecords) {
|
||||
List<DictionaryItem> dictList = dictionaryItemService.getDictList(DictionaryConstant.AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE, projectSn);
|
||||
List<DictionaryItem> dictList = dictionaryItemService.getDictList(DictionaryConstant.CAR_DANGER_DETECT_RECORD_ALARM_TYPE, projectSn);
|
||||
Map<String, DictionaryItem> typeMap = dictList.stream().collect(Collectors.toMap(DictionaryItem::getData, Function.identity(), (dictionaryItem, dictionaryItem2) -> dictionaryItem));
|
||||
for (CarDangerDetectRecord record : carDangerDetectRecords) {
|
||||
DictionaryItem item = typeMap.get(record.getAlarmType() + "");
|
||||
@ -454,7 +454,7 @@ public class CarDangerDetectRecordServiceImpl extends ServiceImpl<CarDangerDetec
|
||||
entity.setCarDangerDetectRecordId(alarmRecord.getId());
|
||||
workerInfoToCarDangerDetectRecordMapper.insert(entity);
|
||||
String projectSn = alarmRecord.getProjectSn();
|
||||
DictionaryItem dict = dictionaryItemService.getDict(DictionaryConstant.AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE, alarmRecord.getAlarmType() + "", projectSn);
|
||||
DictionaryItem dict = dictionaryItemService.getDict(DictionaryConstant.CAR_DANGER_DETECT_RECORD_ALARM_TYPE, alarmRecord.getAlarmType() + "", projectSn);
|
||||
if (dict == null) {
|
||||
return;
|
||||
}
|
||||
@ -476,7 +476,7 @@ public class CarDangerDetectRecordServiceImpl extends ServiceImpl<CarDangerDetec
|
||||
workerInfoService.updateScoreSendAuth(map);
|
||||
|
||||
WorkerInfo wi = workerInfoMapper.selectById(id);
|
||||
List<DictionaryItem> dictList = dictionaryItemService.getDictList(DictionaryConstant.AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE, record.getProjectSn());
|
||||
List<DictionaryItem> dictList = dictionaryItemService.getDictList(DictionaryConstant.CAR_DANGER_DETECT_RECORD_ALARM_TYPE, record.getProjectSn());
|
||||
try {
|
||||
Map<String, DictionaryItem> typeMap = dictList.stream().collect(Collectors.toMap(DictionaryItem::getData, Function.identity(), (dictionaryItem, dictionaryItem2) -> dictionaryItem));
|
||||
DictionaryItem item = typeMap.get(record.getAlarmType() + "");
|
||||
@ -550,7 +550,7 @@ public class CarDangerDetectRecordServiceImpl extends ServiceImpl<CarDangerDetec
|
||||
entity.setCarDangerDetectRecordId(record.getId());
|
||||
workerInfoToCarDangerDetectRecordMapper.insert(entity);
|
||||
|
||||
List<DictionaryItem> dictList = dictionaryItemService.getDictList(DictionaryConstant.AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE, record.getProjectSn());
|
||||
List<DictionaryItem> dictList = dictionaryItemService.getDictList(DictionaryConstant.CAR_DANGER_DETECT_RECORD_ALARM_TYPE, record.getProjectSn());
|
||||
Map<String, DictionaryItem> typeMap = dictList.stream().collect(Collectors.toMap(DictionaryItem::getData, Function.identity(), (dictionaryItem, dictionaryItem2) -> dictionaryItem));
|
||||
DictionaryItem item = typeMap.get(record.getAlarmType() + "");
|
||||
String name = Optional.ofNullable(item).map(DictionaryItem::getName).orElse(String.valueOf(record.getAlarmType()));
|
||||
|
||||
@ -9,6 +9,10 @@ public interface DictionaryConstant {
|
||||
* AI分析硬件设备报警记录类型
|
||||
*/
|
||||
String AI_ANALYSE_HARD_WARE_ALARM_RECORD_TYPE = "ai_analyse_hard_ware_alarm_record_type";
|
||||
/**
|
||||
* 车辆不安全行为报警类型
|
||||
*/
|
||||
String CAR_DANGER_DETECT_RECORD_ALARM_TYPE = "car_danger_detect_record_alarm_type";
|
||||
/**
|
||||
* 隧道定位各项目的标签消失时间配置
|
||||
*/
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
@ -9,6 +11,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.base.HikvisionEventsPictureRq;
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.CarDangerDetect;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.CarDangerDetectRecord;
|
||||
import com.zhgd.xmgl.modules.baotou.service.ICarDangerDetectRecordService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.ICarDangerDetectService;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfoApprovalFlow;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarMeasureSpeedData;
|
||||
@ -63,6 +69,12 @@ public class CarInfoTask {
|
||||
private ICarMeasureSpeedDevService carMeasureSpeedDevService;
|
||||
@Autowired
|
||||
private ICarMeasureSpeedDataService carMeasureSpeedDataService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ICarDangerDetectRecordService carDangerDetectRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ICarDangerDetectService carDangerDetectService;
|
||||
|
||||
/**
|
||||
* 定时删除/更新过期的车辆,并下发新的预约时间的车辆到海康
|
||||
@ -108,64 +120,127 @@ public class CarInfoTask {
|
||||
} else {
|
||||
start = DateUtil.format(DateUtil.offsetDay(new Date(), -1), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
||||
}
|
||||
String end = DateUtil.format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
||||
String end = DateUtil.format(DateUtil.offsetMinute(new Date(), -2), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
||||
redisRepository.set(queryTimeKey, end);
|
||||
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
.eq(Project::getSyncHikvision, 1));
|
||||
List<CarMeasureSpeedDev> speedDevs = carMeasureSpeedDevService.list();
|
||||
Map<String, List<CarMeasureSpeedDev>> projectMap = speedDevs.stream().collect(Collectors.groupingBy(CarMeasureSpeedDev::getProjectSn));
|
||||
for (Map.Entry<String, List<CarMeasureSpeedDev>> entry : projectMap.entrySet()) {
|
||||
List<CarMeasureSpeedDev> list = entry.getValue();
|
||||
Map<String, CarMeasureSpeedDev> devMap = list.stream().collect(Collectors.toMap(CarMeasureSpeedDev::getDevSn, Function.identity()));
|
||||
String projectSn = entry.getKey();
|
||||
Optional<Project> hasProject = projects.stream().filter(project -> Objects.equals(project.getProjectSn(), projectSn)).findFirst();
|
||||
if (hasProject.isPresent()) {
|
||||
Project project = hasProject.get();
|
||||
try {
|
||||
JSONObject param = new JSONObject();
|
||||
HikvisionUtil.addPageParamIfAbsent(param);
|
||||
param.put("beginTime", start);
|
||||
param.put("endTime", DateUtil.format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"));
|
||||
JSONObject rsJo = HikvisionUtil.getSpeedDataList(project, param);
|
||||
if (HikvisionUtil.isSuccess(rsJo)) {
|
||||
JSONObject dataJo = HikvisionUtil.getJsonObjectData(rsJo);
|
||||
JSONArray listJa = dataJo.getJSONArray("list");
|
||||
if (CollUtil.isNotEmpty(listJa)) {
|
||||
for (int i = 0; i < listJa.size(); i++) {
|
||||
JSONObject jo = listJa.getJSONObject(i);
|
||||
Integer illegalType = jo.getInteger("illegalType");
|
||||
if (!Objects.equals(illegalType, 1) && !Objects.equals(illegalType, 7)) {
|
||||
continue;
|
||||
}
|
||||
String monitoringId = jo.getString("monitoringId");
|
||||
CarMeasureSpeedDev dev = devMap.get(monitoringId);
|
||||
if (dev == null) {
|
||||
continue;
|
||||
}
|
||||
String plateNo = jo.getString("plateNo");
|
||||
BigDecimal speed = jo.getBigDecimal("speed");
|
||||
Date time = DateUtil.parse(jo.getString("crossTime"));
|
||||
CarMeasureSpeedData data = new CarMeasureSpeedData();
|
||||
data.setDevSn(monitoringId);
|
||||
data.setCarNumber(plateNo);
|
||||
data.setIsExceed(NumberUtil.isGreater(speed, dev.getThreshold()) ? 1 : 0);
|
||||
data.setCurrentSpeed(speed);
|
||||
data.setExceedingThreshold(Objects.equals(data.getIsExceed(), 1) ? NumberUtil.sub(speed, dev.getThreshold()) : new BigDecimal("0"));
|
||||
String platePicUrl = jo.getString("carPicUri");
|
||||
String svrIndex = jo.getString("aswSyscode");
|
||||
if (StringUtils.isNotBlank(platePicUrl)) {
|
||||
data.setSnapshotImage(hikvisionCall.saveToLocal(HikvisionCall.getHikvisionEventsPicture(new HikvisionEventsPictureRq(svrIndex, platePicUrl), project.getArtemisConfigHost(), project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret())));
|
||||
}
|
||||
data.setUploadTime(time);
|
||||
data.setProjectSn(dev.getProjectSn());
|
||||
carMeasureSpeedDataService.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("定时到海康拉取车辆超速错误:", e);
|
||||
Map<String, List<CarMeasureSpeedDev>> projectMap = carMeasureSpeedDevService.list().stream().collect(Collectors.groupingBy(CarMeasureSpeedDev::getProjectSn));
|
||||
Map<String, List<CarDangerDetect>> dangerDetectProjectMap = carDangerDetectService.list().stream().collect(Collectors.groupingBy(CarDangerDetect::getProjectSn));
|
||||
for (Project project : projects) {
|
||||
try {
|
||||
JSONArray listJa = getSpeedDataList(start, project);
|
||||
if (CollUtil.isEmpty(listJa)) {
|
||||
continue;
|
||||
}
|
||||
Map<String, CarMeasureSpeedDev> devMap = Optional.ofNullable(projectMap.get(project.getProjectSn())).map(m -> m.stream().collect(Collectors.toMap(CarMeasureSpeedDev::getDevSn, Function.identity()))).orElse(null);
|
||||
List<CarMeasureSpeedData> speedDatas = buildSpeedData(listJa, devMap, project);
|
||||
if (CollUtil.isNotEmpty(speedDatas)) {
|
||||
carMeasureSpeedDataService.saveBatch(speedDatas);
|
||||
}
|
||||
|
||||
Map<String, CarDangerDetect> carDangerDevMap = Optional.ofNullable(dangerDetectProjectMap.get(project.getProjectSn())).map(m -> m.stream().collect(Collectors.toMap(CarDangerDetect::getHardwareId, Function.identity()))).orElse(null);
|
||||
List<CarDangerDetectRecord> carDangers = buildCarDangerData(listJa, carDangerDevMap, project);
|
||||
if (CollUtil.isNotEmpty(carDangers)) {
|
||||
carDangerDetectRecordService.saveBatch(carDangers);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("定时到海康拉取车辆超速错误:", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<CarDangerDetectRecord> buildCarDangerData(JSONArray listJa, Map<String, CarDangerDetect> carDangerDevMap, Project project) throws Exception {
|
||||
List<CarDangerDetectRecord> datas = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(listJa)) {
|
||||
for (int i = 0; i < listJa.size(); i++) {
|
||||
JSONObject jo = listJa.getJSONObject(i);
|
||||
Integer illegalType = jo.getInteger("illegalType");
|
||||
if (!Objects.equals(illegalType, 1) && !Objects.equals(illegalType, 7)) {
|
||||
continue;
|
||||
}
|
||||
String monitoringId = jo.getString("monitoringId");
|
||||
CarDangerDetect dev = carDangerDevMap.get(monitoringId);
|
||||
if (dev == null) {
|
||||
continue;
|
||||
}
|
||||
String plateNo = jo.getString("plateNo");
|
||||
BigDecimal speed = jo.getBigDecimal("speed");
|
||||
Date time = DateUtil.parse(jo.getString("crossTime"));
|
||||
CarDangerDetectRecord data = new CarDangerDetectRecord();
|
||||
data.setProjectSn(dev.getProjectSn());
|
||||
data.setHardwareName(dev.getHardwareName());
|
||||
data.setHardwareId(dev.getHardwareId());
|
||||
String platePicUrl = jo.getString("carPicUri");
|
||||
String svrIndex = jo.getString("aswSyscode");
|
||||
if (StringUtils.isNotBlank(platePicUrl)) {
|
||||
data.setImageUrl(hikvisionCall.saveToLocal(HikvisionCall.getHikvisionEventsPicture(new HikvisionEventsPictureRq(svrIndex, platePicUrl), project.getArtemisConfigHost(), project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret())));
|
||||
}
|
||||
data.setAlarmDesc(dev.getHardwareName());
|
||||
data.setAlarmType(1);
|
||||
data.setLocation(dev.getHardwareName());
|
||||
data.setCreateTime(DateUtil.formatDateTime(time));
|
||||
data.setIsPushed(false);
|
||||
data.setCarNumber(plateNo);
|
||||
data.setCurrentSpeed(speed);
|
||||
datas.add(data);
|
||||
}
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
|
||||
private List<CarMeasureSpeedData> buildSpeedData(JSONArray listJa, Map<String, CarMeasureSpeedDev> devMap, Project project) throws Exception {
|
||||
List<CarMeasureSpeedData> datas = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(listJa)) {
|
||||
for (int i = 0; i < listJa.size(); i++) {
|
||||
JSONObject jo = listJa.getJSONObject(i);
|
||||
Integer illegalType = jo.getInteger("illegalType");
|
||||
if (!Objects.equals(illegalType, 1) && !Objects.equals(illegalType, 7)) {
|
||||
continue;
|
||||
}
|
||||
String monitoringId = jo.getString("monitoringId");
|
||||
CarMeasureSpeedDev dev = devMap.get(monitoringId);
|
||||
if (dev == null) {
|
||||
continue;
|
||||
}
|
||||
String plateNo = jo.getString("plateNo");
|
||||
BigDecimal speed = jo.getBigDecimal("speed");
|
||||
Date time = DateUtil.parse(jo.getString("crossTime"));
|
||||
CarMeasureSpeedData data = new CarMeasureSpeedData();
|
||||
data.setDevSn(monitoringId);
|
||||
data.setCarNumber(plateNo);
|
||||
data.setIsExceed(NumberUtil.isGreater(speed, dev.getThreshold()) ? 1 : 0);
|
||||
data.setCurrentSpeed(speed);
|
||||
data.setExceedingThreshold(Objects.equals(data.getIsExceed(), 1) ? NumberUtil.sub(speed, dev.getThreshold()) : new BigDecimal("0"));
|
||||
String platePicUrl = jo.getString("carPicUri");
|
||||
String svrIndex = jo.getString("aswSyscode");
|
||||
if (StringUtils.isNotBlank(platePicUrl)) {
|
||||
data.setSnapshotImage(hikvisionCall.saveToLocal(HikvisionCall.getHikvisionEventsPicture(new HikvisionEventsPictureRq(svrIndex, platePicUrl), project.getArtemisConfigHost(), project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret())));
|
||||
}
|
||||
data.setUploadTime(time);
|
||||
data.setProjectSn(dev.getProjectSn());
|
||||
datas.add(data);
|
||||
}
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
|
||||
private JSONArray getSpeedDataList(String start, Project project) {
|
||||
try {
|
||||
JSONObject param = new JSONObject();
|
||||
HikvisionUtil.addPageParamIfAbsent(param);
|
||||
param.put("beginTime", start);
|
||||
param.put("endTime", DateUtil.format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"));
|
||||
JSONObject rsJo = HikvisionUtil.getSpeedDataList(project, param);
|
||||
if (HikvisionUtil.isSuccess(rsJo)) {
|
||||
JSONObject dataJo = HikvisionUtil.getJsonObjectData(rsJo);
|
||||
return dataJo.getJSONArray("list");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("定时http到海康拉取车辆超速错误:{}", e.getMessage());
|
||||
log.error("", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user