Commit ab1e98d2 authored by 赵啸非's avatar 赵啸非

添加服务追踪

parent 178b82d7
...@@ -95,6 +95,7 @@ public final class Constant { ...@@ -95,6 +95,7 @@ public final class Constant {
* 陌生人监控计划 * 陌生人监控计划
*/ */
public final static String STRANGER_PLAN = "stranger_plan"; public final static String STRANGER_PLAN = "stranger_plan";
public final static String STRANGER_PLAN_DESC = "陌生人监控计划";
/** /**
* 预约监控计划前缀 * 预约监控计划前缀
......
...@@ -103,7 +103,7 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -103,7 +103,7 @@ public class SubEventStartedService implements IApplicationStartedService {
} }
//创建陌生人计划 //创建陌生人计划
facePlanService.createStrangerPlanByDay(); // facePlanService.createStrangerPlanByDay();
//删除重点人员计划 //删除重点人员计划
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq(); /* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
......
...@@ -5,6 +5,7 @@ import com.mortals.framework.common.Rest; ...@@ -5,6 +5,7 @@ import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.RecognitionResourceEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery; import com.mortals.xhx.module.device.model.DeviceQuery;
...@@ -14,6 +15,9 @@ import com.mortals.xhx.module.hik.camera.model.req.CameraReq; ...@@ -14,6 +15,9 @@ import com.mortals.xhx.module.hik.camera.model.req.CameraReq;
import com.mortals.xhx.module.hik.camera.model.rsp.CameraDataInfo; import com.mortals.xhx.module.hik.camera.model.rsp.CameraDataInfo;
import com.mortals.xhx.module.hik.camera.model.rsp.CameraInfo; import com.mortals.xhx.module.hik.camera.model.rsp.CameraInfo;
import com.mortals.xhx.module.hik.camera.service.IHikCameraService; import com.mortals.xhx.module.hik.camera.service.IHikCameraService;
import com.mortals.xhx.module.hik.face.model.req.resource.ResourceReq;
import com.mortals.xhx.module.hik.face.model.rsp.resource.ResourceDataInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -35,6 +39,8 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -35,6 +39,8 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
private DeviceService deviceService; private DeviceService deviceService;
@Autowired @Autowired
private IHikCameraService hikCameraService; private IHikCameraService hikCameraService;
@Autowired
private IHikFaceService hikFaceService;
@Override @Override
...@@ -85,68 +91,82 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService { ...@@ -85,68 +91,82 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
* "updateTime": "2023-04-10T15:11:56.446+08:00" * "updateTime": "2023-04-10T15:11:56.446+08:00"
*/ */
private void syncDevice() { private void syncDevice() {
CameraListReq cameraListReq = new CameraListReq();
cameraListReq.setPageNo(1);
cameraListReq.setPageSize(200);
cameraListReq.setRegionIndexCode("root000000");
Rest<CameraDataInfo> rest = hikCameraService.findCameraList(cameraListReq);
if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<CameraInfo> cameraDataInfoList = rest.getData().getList();
log.info("视频设备总数量:{}", cameraDataInfoList.size());
if (!ObjectUtils.isEmpty(cameraDataInfoList)) {
List<DeviceEntity> newDeviceList = cameraDataInfoList.stream().map(camera -> {
DeviceEntity deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue();
deviceEntity.setDeviceName(camera.getCameraName());
deviceEntity.setDeviceId(camera.getCameraIndexCode());
deviceEntity.setDeviceCode(camera.getCameraIndexCode());
deviceEntity.setCameraType(camera.getCameraType());
deviceEntity.setCameraTypeName(camera.getCameraTypeName());
deviceEntity.setCapabilitySet(camera.getCapabilitySet());
deviceEntity.setCapabilitySetName(camera.getCapabilitySetName());
deviceEntity.setRegionIndexCode(camera.getRegionIndexCode());
deviceEntity.setEncodeDevIndexCode(camera.getEncodeDevIndexCode());
deviceEntity.setCreateTime(camera.getCreateTime());
deviceEntity.setUpdateTime(camera.getUpdateTime());
return deviceEntity;
}).collect(Collectors.toList());
List<DeviceEntity> oldDeviceList = deviceService.find(new DeviceQuery());
Map<String, DeviceEntity> oldDeviceMap = oldDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n));
Map<String, DeviceEntity> newDeviceMap = newDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n));
List<DeviceEntity> saveDeviceList = newDeviceList.stream().map(item -> {
if (!oldDeviceMap.containsKey(item.getDeviceCode())) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
//做差集
List<Long> delDeviceList = oldDeviceList.stream().map(item -> {
if (!newDeviceMap.containsKey(item.getDeviceCode())) {
return item.getId();
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(saveDeviceList)) { //获取识别资源
log.info("设备新增,size:{}", saveDeviceList.size());
deviceService.save(saveDeviceList); ResourceReq resourceReq = new ResourceReq();
} resourceReq.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getValue());
Rest<List<ResourceDataInfo>> resourceRecognition = hikFaceService.getResourceRecognition(resourceReq);
if (resourceRecognition.getCode() == YesNoEnum.YES.getValue() && !ObjectUtils.isEmpty(resourceRecognition.getData())) {
ArrayList<String> recognitionResourceIndexCodes = new ArrayList<>();
recognitionResourceIndexCodes.add(resourceRecognition.getData().get(0).getIndexCode());
// planRecognWhiteReq.setRecognitionResourceIndexCodes(recognitionResourceIndexCodes);
CameraListReq cameraListReq = new CameraListReq();
cameraListReq.setPageNo(1);
cameraListReq.setPageSize(200);
cameraListReq.setEncodeDevIndexCode(resourceRecognition.getData().get(0).getIndexCode());
//cameraListReq.setRegionIndexCode("root000000");
Rest<CameraDataInfo> rest = hikCameraService.findCameraList(cameraListReq);
if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<CameraInfo> cameraDataInfoList = rest.getData().getList();
log.info("视频设备总数量:{}", cameraDataInfoList.size());
if (!ObjectUtils.isEmpty(cameraDataInfoList)) {
List<DeviceEntity> newDeviceList = cameraDataInfoList.stream().map(camera -> {
DeviceEntity deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue();
deviceEntity.setDeviceName(camera.getCameraName());
deviceEntity.setDeviceId(camera.getCameraIndexCode());
deviceEntity.setDeviceCode(camera.getCameraIndexCode());
deviceEntity.setCameraType(camera.getCameraType());
deviceEntity.setCameraTypeName(camera.getCameraTypeName());
deviceEntity.setCapabilitySet(camera.getCapabilitySet());
deviceEntity.setCapabilitySetName(camera.getCapabilitySetName());
deviceEntity.setRegionIndexCode(camera.getRegionIndexCode());
deviceEntity.setEncodeDevIndexCode(camera.getEncodeDevIndexCode());
deviceEntity.setCreateTime(camera.getCreateTime());
deviceEntity.setUpdateTime(camera.getUpdateTime());
return deviceEntity;
}).collect(Collectors.toList());
List<DeviceEntity> oldDeviceList = deviceService.find(new DeviceQuery());
Map<String, DeviceEntity> oldDeviceMap = oldDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n));
Map<String, DeviceEntity> newDeviceMap = newDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n));
List<DeviceEntity> saveDeviceList = newDeviceList.stream().map(item -> {
if (!oldDeviceMap.containsKey(item.getDeviceCode())) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
//做差集
List<Long> delDeviceList = oldDeviceList.stream().map(item -> {
if (!newDeviceMap.containsKey(item.getDeviceCode())) {
return item.getId();
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(saveDeviceList)) {
log.info("设备新增,size:{}", saveDeviceList.size());
deviceService.save(saveDeviceList);
}
if (!ObjectUtils.isEmpty(delDeviceList)) { if (!ObjectUtils.isEmpty(delDeviceList)) {
log.info("设备删除,size:{}", delDeviceList.size()); log.info("设备删除,size:{}", delDeviceList.size());
deviceService.remove(delDeviceList, null); deviceService.remove(delDeviceList, null);
}
} }
} else {
log.info("同步设备异常=>{}", JSON.toJSONString(rest));
} }
} else {
log.info("同步设备异常=>{}", JSON.toJSONString(rest));
} }
} }
......
...@@ -321,7 +321,7 @@ public class FacePlanEntity extends FacePlanVo { ...@@ -321,7 +321,7 @@ public class FacePlanEntity extends FacePlanVo {
this.status = ""; this.status = "";
this.available = ""; this.available = "true";
this.description = ""; this.description = "";
......
...@@ -118,12 +118,12 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -118,12 +118,12 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode()); faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
planRecognWhiteReq.setFaceGroupIndexCodes(faceGroupIndexCodes); planRecognWhiteReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点 //设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().distinct().map(DeviceEntity::getDeviceCode).collect(Collectors.toList()); List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).distinct().collect(Collectors.toList());
ArrayList<String> temp = new ArrayList<>(); // ArrayList<String> temp = new ArrayList<>();
temp.add(cameraIndexCodes.get(2)); // temp.add(cameraIndexCodes.get(2));
//planRecognWhiteReq.setCameraIndexCodes(cameraIndexCodes); planRecognWhiteReq.setCameraIndexCodes(cameraIndexCodes);
planRecognWhiteReq.setCameraIndexCodes(temp); //planRecognWhiteReq.setCameraIndexCodes(temp);
//设置识别方式 //设置识别方式
planRecognWhiteReq.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getValue()); planRecognWhiteReq.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getValue());
...@@ -137,7 +137,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -137,7 +137,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
} }
//设置时间段 默认全天候 //设置时间段 默认全天候
List<TimeBlockListItem> timeBlockListItemList=new ArrayList<>(); /* List<TimeBlockListItem> timeBlockListItemList=new ArrayList<>();
TimeBlockListItem timeBlockListItem = new TimeBlockListItem(); TimeBlockListItem timeBlockListItem = new TimeBlockListItem();
timeBlockListItem.setDayOfWeek("7"); timeBlockListItem.setDayOfWeek("7");
List<TimeRangeItem> timeRange=new ArrayList<>(); List<TimeRangeItem> timeRange=new ArrayList<>();
...@@ -147,7 +147,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -147,7 +147,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
timeRange.add(timeRangeItem); timeRange.add(timeRangeItem);
timeBlockListItem.setTimeRange(timeRange); timeBlockListItem.setTimeRange(timeRange);
timeBlockListItemList.add(timeBlockListItem); timeBlockListItemList.add(timeBlockListItem);
planRecognWhiteReq.setTimeBlockList(timeBlockListItemList); planRecognWhiteReq.setTimeBlockList(timeBlockListItemList);*/
if (ObjectUtils.isEmpty(planRecognWhiteInfo)) { if (ObjectUtils.isEmpty(planRecognWhiteInfo)) {
Rest<String> planRecognWhiteAddRest = hikPlanService.planRecognWhiteAdd(planRecognWhiteReq); Rest<String> planRecognWhiteAddRest = hikPlanService.planRecognWhiteAdd(planRecognWhiteReq);
...@@ -155,8 +155,15 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -155,8 +155,15 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
FacePlanEntity planEntity = new FacePlanEntity(); FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue(); planEntity.initAttrValue();
planEntity.setIndexCode(planRecognWhiteAddRest.getData()); planEntity.setIndexCode(planRecognWhiteAddRest.getData());
planEntity.setFaceGroupIndexCodes(faceGroupEntity.getIndexCode());
planEntity.setCameraIndexCodes(planRecognWhiteReq.getCameraIndexCodes().stream().collect(Collectors.joining(",")));
planEntity.setRecognitionResourceIndexCodes(planRecognWhiteReq.getRecognitionResourceIndexCodes().stream().collect(Collectors.joining(",")));
planEntity.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getDesc());
planEntity.setThreshold(threshold);
planEntity.setStatus(PlanStatusEnum.RUNNING.getValue());
planEntity.setStartTime(new Date());
planEntity.setName(Constant.STRANGER_PLAN); planEntity.setName(Constant.STRANGER_PLAN);
planEntity.setDescription(Constant.STRANGER_PLAN); planEntity.setDescription(Constant.STRANGER_PLAN_DESC);
planEntity.setCreateTime(new Date()); planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L); planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin"); planEntity.setCreateUserName("admin");
...@@ -182,9 +189,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -182,9 +189,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
planRecognWhiteReq.setIndexCode(planRecognWhiteInfo.getIndexCode()); planRecognWhiteReq.setIndexCode(planRecognWhiteInfo.getIndexCode());
Rest<Boolean> planRecognWhiteUpdateRest = hikPlanService.planRecognWhiteUpdate(planRecognWhiteReq); Rest<Boolean> planRecognWhiteUpdateRest = hikPlanService.planRecognWhiteUpdate(planRecognWhiteReq);
if (planRecognWhiteUpdateRest.getCode() == YesNoEnum.YES.getValue() && planRecognWhiteUpdateRest.getData()) { if (planRecognWhiteUpdateRest.getCode() == YesNoEnum.YES.getValue() && planRecognWhiteUpdateRest.getData()) {
FacePlanEntity whitePlan = facePlanService.selectOne(new FacePlanQuery().indexCode(planRecognWhiteInfo.getIndexCode())); FacePlanEntity whitePlan = facePlanService.selectOne(new FacePlanQuery().indexCode(planRecognWhiteInfo.getIndexCode()));
if (!ObjectUtils.isEmpty(whitePlan)) { if (!ObjectUtils.isEmpty(whitePlan)) {
whitePlan.setUpdateTime(new Date()); whitePlan.setUpdateTime(new Date());
whitePlan.setUpdateUserId(1L); whitePlan.setUpdateUserId(1L);
...@@ -193,12 +198,9 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -193,12 +198,9 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
} }
} }
} }
} }
return planRecognWhiteListRest; return planRecognWhiteListRest;
} }
......
...@@ -11,6 +11,7 @@ public class CameraListReq { ...@@ -11,6 +11,7 @@ public class CameraListReq {
private String cameraIndexCodes; private String cameraIndexCodes;
//识别资源,默认超脑
private String encodeDevIndexCode; private String encodeDevIndexCode;
private String regionIndexCode; private String regionIndexCode;
......
...@@ -149,7 +149,7 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe ...@@ -149,7 +149,7 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
HikApiRest<String> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<String>>() { HikApiRest<String> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<String>>() {
}); });
if ("0".equals(rest.getCode())) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getMsg(),rest.getData());
} else { } else {
log.info("plan recognize white add error resp=>{}", respJson); log.info("plan recognize white add error resp=>{}", respJson);
return Rest.fail(rest.getMsg()); return Rest.fail(rest.getMsg());
......
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