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

添加服务追踪

parent 178b82d7
......@@ -95,6 +95,7 @@ public final class Constant {
* 陌生人监控计划
*/
public final static String STRANGER_PLAN = "stranger_plan";
public final static String STRANGER_PLAN_DESC = "陌生人监控计划";
/**
* 预约监控计划前缀
......
......@@ -103,7 +103,7 @@ public class SubEventStartedService implements IApplicationStartedService {
}
//创建陌生人计划
facePlanService.createStrangerPlanByDay();
// facePlanService.createStrangerPlanByDay();
//删除重点人员计划
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
......
......@@ -5,6 +5,7 @@ import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.RecognitionResourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
......@@ -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.CameraInfo;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -35,6 +39,8 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
private DeviceService deviceService;
@Autowired
private IHikCameraService hikCameraService;
@Autowired
private IHikFaceService hikFaceService;
@Override
......@@ -85,68 +91,82 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
* "updateTime": "2023-04-10T15:11:56.446+08:00"
*/
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)) {
log.info("设备删除,size:{}", delDeviceList.size());
deviceService.remove(delDeviceList, null);
if (!ObjectUtils.isEmpty(delDeviceList)) {
log.info("设备删除,size:{}", delDeviceList.size());
deviceService.remove(delDeviceList, null);
}
}
} else {
log.info("同步设备异常=>{}", JSON.toJSONString(rest));
}
} else {
log.info("同步设备异常=>{}", JSON.toJSONString(rest));
}
}
......
......@@ -2,10 +2,12 @@ package com.mortals.xhx.module.device.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceVo;
/**
* 设备业务实体对象
*
......@@ -110,351 +112,442 @@ public class DeviceEntity extends DeviceVo {
private String deviceRemark;
public DeviceEntity() {
}
public DeviceEntity(){}
/**
* 获取 站点Id
*
* @return Long
*/
public Long getSiteId(){
public Long getSiteId() {
return siteId;
}
/**
* 设置 站点Id
*
* @param siteId
*/
public void setSiteId(Long siteId){
public void setSiteId(Long siteId) {
this.siteId = siteId;
}
/**
* 获取 站点名称
*
* @return String
*/
public String getSiteName(){
public String getSiteName() {
return siteName;
}
/**
* 设置 站点名称
*
* @param siteName
*/
public void setSiteName(String siteName){
public void setSiteName(String siteName) {
this.siteName = siteName;
}
/**
* 获取 设备ID,海康
*
* @return String
*/
public String getDeviceId(){
public String getDeviceId() {
return deviceId;
}
/**
* 设置 设备ID,海康
*
* @param deviceId
*/
public void setDeviceId(String deviceId){
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
/**
* 获取 设备名称
*
* @return String
*/
public String getDeviceName(){
public String getDeviceName() {
return deviceName;
}
/**
* 设置 设备名称
*
* @param deviceName
*/
public void setDeviceName(String deviceName){
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
/**
* 获取 设备编码
*
* @return String
*/
public String getDeviceCode(){
public String getDeviceCode() {
return deviceCode;
}
/**
* 设置 设备编码
*
* @param deviceCode
*/
public void setDeviceCode(String deviceCode){
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
/**
* 获取 设备的MAC地址
*
* @return String
*/
public String getDeviceMac(){
public String getDeviceMac() {
return deviceMac;
}
/**
* 设置 设备的MAC地址
*
* @param deviceMac
*/
public void setDeviceMac(String deviceMac){
public void setDeviceMac(String deviceMac) {
this.deviceMac = deviceMac;
}
/**
* 获取 设备位置
*
* @return String
*/
public String getDeviceLocation(){
public String getDeviceLocation() {
return deviceLocation;
}
/**
* 设置 设备位置
*
* @param deviceLocation
*/
public void setDeviceLocation(String deviceLocation){
public void setDeviceLocation(String deviceLocation) {
this.deviceLocation = deviceLocation;
}
/**
* 获取 经度
*
* @return String
*/
public String getLon(){
public String getLon() {
return lon;
}
/**
* 设置 经度
*
* @param lon
*/
public void setLon(String lon){
public void setLon(String lon) {
this.lon = lon;
}
/**
* 获取 纬度
*
* @return String
*/
public String getLati(){
public String getLati() {
return lati;
}
/**
* 设置 纬度
*
* @param lati
*/
public void setLati(String lati){
public void setLati(String lati) {
this.lati = lati;
}
/**
* 获取 楼层
*
* @return Integer
*/
public Integer getFloor(){
public Integer getFloor() {
return floor;
}
/**
* 设置 楼层
*
* @param floor
*/
public void setFloor(Integer floor){
public void setFloor(Integer floor) {
this.floor = floor;
}
/**
* 获取 楼栋
*
* @return Integer
*/
public Integer getBuild(){
public Integer getBuild() {
return build;
}
/**
* 设置 楼栋
*
* @param build
*/
public void setBuild(Integer build){
public void setBuild(Integer build) {
this.build = build;
}
/**
* 获取 负责人
*
* @return String
*/
public String getLeadingOfficial(){
public String getLeadingOfficial() {
return leadingOfficial;
}
/**
* 设置 负责人
*
* @param leadingOfficial
*/
public void setLeadingOfficial(String leadingOfficial){
public void setLeadingOfficial(String leadingOfficial) {
this.leadingOfficial = leadingOfficial;
}
/**
* 获取 联系电话
*
* @return String
*/
public String getLeadingOfficialTelephone(){
public String getLeadingOfficialTelephone() {
return leadingOfficialTelephone;
}
/**
* 设置 联系电话
*
* @param leadingOfficialTelephone
*/
public void setLeadingOfficialTelephone(String leadingOfficialTelephone){
public void setLeadingOfficialTelephone(String leadingOfficialTelephone) {
this.leadingOfficialTelephone = leadingOfficialTelephone;
}
/**
* 获取 超时时间,单位天
*
* @return Integer
*/
public Integer getTimeOutPeriod(){
public Integer getTimeOutPeriod() {
return timeOutPeriod;
}
/**
* 设置 超时时间,单位天
*
* @param timeOutPeriod
*/
public void setTimeOutPeriod(Integer timeOutPeriod){
public void setTimeOutPeriod(Integer timeOutPeriod) {
this.timeOutPeriod = timeOutPeriod;
}
/**
* 获取 临近时间,单位天
*
* @return Integer
*/
public Integer getNearTime(){
public Integer getNearTime() {
return nearTime;
}
/**
* 设置 临近时间,单位天
*
* @param nearTime
*/
public void setNearTime(Integer nearTime){
public void setNearTime(Integer nearTime) {
this.nearTime = nearTime;
}
/**
* 获取 设备状态 (1.离线,2.在线)
*
* @return Integer
*/
public Integer getDeviceStatus(){
public Integer getDeviceStatus() {
return deviceStatus;
}
/**
* 设置 设备状态 (1.离线,2.在线)
*
* @param deviceStatus
*/
public void setDeviceStatus(Integer deviceStatus){
public void setDeviceStatus(Integer deviceStatus) {
this.deviceStatus = deviceStatus;
}
/**
* 获取 区域编码
*
* @return String
*/
public String getRegionIndexCode(){
public String getRegionIndexCode() {
return regionIndexCode;
}
/**
* 设置 区域编码
*
* @param regionIndexCode
*/
public void setRegionIndexCode(String regionIndexCode){
public void setRegionIndexCode(String regionIndexCode) {
this.regionIndexCode = regionIndexCode;
}
/**
* 获取 类型名称
*
* @return String
*/
public String getCameraTypeName(){
public String getCameraTypeName() {
return cameraTypeName;
}
/**
* 设置 类型名称
*
* @param cameraTypeName
*/
public void setCameraTypeName(String cameraTypeName){
public void setCameraTypeName(String cameraTypeName) {
this.cameraTypeName = cameraTypeName;
}
/**
* 获取 设备类型
*
* @return Integer
*/
public Integer getCameraType(){
public Integer getCameraType() {
return cameraType;
}
/**
* 设置 设备类型
*
* @param cameraType
*/
public void setCameraType(Integer cameraType){
public void setCameraType(Integer cameraType) {
this.cameraType = cameraType;
}
/**
* 获取 编码
*
* @return String
*/
public String getEncodeDevIndexCode(){
public String getEncodeDevIndexCode() {
return encodeDevIndexCode;
}
/**
* 设置 编码
*
* @param encodeDevIndexCode
*/
public void setEncodeDevIndexCode(String encodeDevIndexCode){
public void setEncodeDevIndexCode(String encodeDevIndexCode) {
this.encodeDevIndexCode = encodeDevIndexCode;
}
/**
* 获取 设备能力
*
* @return String
*/
public String getCapabilitySet(){
public String getCapabilitySet() {
return capabilitySet;
}
/**
* 设置 设备能力
*
* @param capabilitySet
*/
public void setCapabilitySet(String capabilitySet){
public void setCapabilitySet(String capabilitySet) {
this.capabilitySet = capabilitySet;
}
/**
* 获取 设备能力名称
*
* @return String
*/
public String getCapabilitySetName(){
public String getCapabilitySetName() {
return capabilitySetName;
}
/**
* 设置 设备能力名称
*
* @param capabilitySetName
*/
public void setCapabilitySetName(String capabilitySetName){
public void setCapabilitySetName(String capabilitySetName) {
this.capabilitySetName = capabilitySetName;
}
/**
* 获取 备注
*
* @return String
*/
public String getDeviceRemark(){
public String getDeviceRemark() {
return deviceRemark;
}
/**
* 设置 备注
*
* @param deviceRemark
*/
public void setDeviceRemark(String deviceRemark){
public void setDeviceRemark(String deviceRemark) {
this.deviceRemark = deviceRemark;
}
@Override
public int hashCode() {
return this.getEncodeDevIndexCode().hashCode();
return this.getDeviceId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof DeviceEntity) {
DeviceEntity tmp = (DeviceEntity) obj;
if (this.getEncodeDevIndexCode() .equals( tmp.getEncodeDevIndexCode())) {
if (this.getDeviceId().equals(tmp.getDeviceId())) {
return true;
}
}
return false;
}
public String toString(){
public String toString() {
StringBuilder sb = new StringBuilder("");
sb.append(",siteId:").append(getSiteId());
sb.append(",siteName:").append(getSiteName());
......@@ -482,7 +575,7 @@ public class DeviceEntity extends DeviceVo {
return sb.toString();
}
public void initAttrValue(){
public void initAttrValue() {
this.siteId = null;
......
......@@ -321,7 +321,7 @@ public class FacePlanEntity extends FacePlanVo {
this.status = "";
this.available = "";
this.available = "true";
this.description = "";
......
......@@ -118,12 +118,12 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
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<>();
temp.add(cameraIndexCodes.get(2));
//planRecognWhiteReq.setCameraIndexCodes(cameraIndexCodes);
planRecognWhiteReq.setCameraIndexCodes(temp);
// ArrayList<String> temp = new ArrayList<>();
// temp.add(cameraIndexCodes.get(2));
planRecognWhiteReq.setCameraIndexCodes(cameraIndexCodes);
//planRecognWhiteReq.setCameraIndexCodes(temp);
//设置识别方式
planRecognWhiteReq.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getValue());
......@@ -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.setDayOfWeek("7");
List<TimeRangeItem> timeRange=new ArrayList<>();
......@@ -147,7 +147,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
timeRange.add(timeRangeItem);
timeBlockListItem.setTimeRange(timeRange);
timeBlockListItemList.add(timeBlockListItem);
planRecognWhiteReq.setTimeBlockList(timeBlockListItemList);
planRecognWhiteReq.setTimeBlockList(timeBlockListItemList);*/
if (ObjectUtils.isEmpty(planRecognWhiteInfo)) {
Rest<String> planRecognWhiteAddRest = hikPlanService.planRecognWhiteAdd(planRecognWhiteReq);
......@@ -155,8 +155,15 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue();
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.setDescription(Constant.STRANGER_PLAN);
planEntity.setDescription(Constant.STRANGER_PLAN_DESC);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
......@@ -182,9 +189,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
planRecognWhiteReq.setIndexCode(planRecognWhiteInfo.getIndexCode());
Rest<Boolean> planRecognWhiteUpdateRest = hikPlanService.planRecognWhiteUpdate(planRecognWhiteReq);
if (planRecognWhiteUpdateRest.getCode() == YesNoEnum.YES.getValue() && planRecognWhiteUpdateRest.getData()) {
FacePlanEntity whitePlan = facePlanService.selectOne(new FacePlanQuery().indexCode(planRecognWhiteInfo.getIndexCode()));
if (!ObjectUtils.isEmpty(whitePlan)) {
whitePlan.setUpdateTime(new Date());
whitePlan.setUpdateUserId(1L);
......@@ -193,12 +198,9 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
}
}
}
}
return planRecognWhiteListRest;
}
......
......@@ -11,6 +11,7 @@ public class CameraListReq {
private String cameraIndexCodes;
//识别资源,默认超脑
private String encodeDevIndexCode;
private String regionIndexCode;
......
......@@ -149,7 +149,7 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
HikApiRest<String> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<String>>() {
});
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
return Rest.ok(rest.getMsg(),rest.getData());
} else {
log.info("plan recognize white add error resp=>{}", respJson);
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