Commit 63430df8 authored by 赵啸非's avatar 赵啸非

添加识别计划任务等逻辑

parent efa500ff
...@@ -91,6 +91,15 @@ public final class Constant { ...@@ -91,6 +91,15 @@ public final class Constant {
*/ */
public static final String EXCHANGE_SPLIT = "."; public static final String EXCHANGE_SPLIT = ".";
/**
* 预约监控计划前缀
*/
public final static String APPOINTMENT_PLAN_PREFIX = "appointment_plan_";
/**
* 预约人员分组
*/
public final static String APPOINTMENT_GROUP_PREFIX = "appointment_group_";
} }
...@@ -23,7 +23,7 @@ import com.mortals.xhx.module.hik.event.model.req.sub.EventSubReq; ...@@ -23,7 +23,7 @@ import com.mortals.xhx.module.hik.event.model.req.sub.EventSubReq;
import com.mortals.xhx.module.hik.event.model.rsp.EventInfo; import com.mortals.xhx.module.hik.event.model.rsp.EventInfo;
import com.mortals.xhx.module.hik.event.service.IHikEventService; import com.mortals.xhx.module.hik.event.service.IHikEventService;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq; import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackReq; import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo; import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService; import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService; import com.mortals.xhx.module.hik.face.service.IHikPlanService;
...@@ -100,14 +100,14 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -100,14 +100,14 @@ public class SubEventStartedService implements IApplicationStartedService {
} }
} }
//创建重点人员识别计划 //删除创建陌生人员识别计划,todo
String planBlackName = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_PLAN_BLACK, "取号监控"); String planBlackName = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_PLAN_BLACK, "取号监控");
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80); int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
FacePlanEntity facePlanEntity = facePlanService.selectOne(new FacePlanQuery().name(planBlackName)); FacePlanEntity facePlanEntity = facePlanService.selectOne(new FacePlanQuery().name(planBlackName));
if (ObjectUtils.isEmpty(facePlanEntity)) { if (ObjectUtils.isEmpty(facePlanEntity)) {
//初始化新增取号监控识别计划 //初始化新增取号监控识别计划
PlanRecognBlackReq planRecognBlackReq = new PlanRecognBlackReq(); PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setName(planBlackName); planRecognBlackReq.setName(planBlackName);
planRecognBlackReq.setDescription(planBlackName); planRecognBlackReq.setDescription(planBlackName);
planRecognBlackReq.setThreshold(threshold); planRecognBlackReq.setThreshold(threshold);
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.ap.GlobalSysInfo;
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.framework.util.DateUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.GenderEnum;
import com.mortals.xhx.common.code.RecognitionResourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.module.appointment.model.*;
import com.mortals.xhx.module.appointment.service.AppointmentConfigService;
import com.mortals.xhx.module.appointment.service.AppointmentConfigTimesService;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.face.model.*;
import com.mortals.xhx.module.face.service.FaceGroupPersonService;
import com.mortals.xhx.module.face.service.FaceGroupService;
import com.mortals.xhx.module.face.service.FacePlanService;
import com.mortals.xhx.module.hik.face.model.req.face.FaceInfo;
import com.mortals.xhx.module.hik.face.model.req.face.FacePic;
import com.mortals.xhx.module.hik.face.model.req.face.FaceReq;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.req.plan.TimeBlockListItem;
import com.mortals.xhx.module.hik.face.model.req.plan.TimeRangeItem;
import com.mortals.xhx.module.hik.face.model.rsp.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.service.PersonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 每日创建预约人员监控计划
* 创建计划钱删除之前计划
*
* @author:
* @date: 2023/4/17 17:52
*/
@Slf4j
@Service("CreateBlackPlanToHikByDayTask")
public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
@Autowired
private PersonService personService;
@Autowired
private IHikFaceService hikFaceService;
@Autowired
private IHikPlanService hikPlanService;
@Autowired
private DeviceService deviceService;
@Autowired
private FacePlanService facePlanService;
@Autowired
private UploadService uploadService;
@Autowired
private FaceGroupService faceGroupService;
@Autowired
private FaceGroupPersonService faceGroupPersonService;
@Autowired
private AppointmentPersonService appointmentPersonService;
@Autowired
private AppointmentConfigService appointmentConfigService;
@Autowired
private AppointmentConfigTimesService appointmentConfigTimesService;
@Override
public void excuteTask(ITask task) throws AppException {
//删除计划
PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognBlackInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognBlackInfo> delPlanList = planRecognBlackRest.getData().stream().map(i -> {
i.getName();
if (StrUtil.startWith(i.getName(), Constant.APPOINTMENT_PLAN_PREFIX) && !i.getName().equals(Constant.APPOINTMENT_GROUP_PREFIX + DateUtils.getCurrStrDate())) {
return i;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(delPlanList)) {
//删除计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setRecognitionResourceIndexCodes(delPlanList.stream().map(i -> i.getIndexCode()).collect(Collectors.toList()));
Rest<Boolean> delRest = hikPlanService.planRecognBlackDel(planRecognBlackReq);
if (delRest.getCode() == YesNoEnum.YES.getValue() && delRest.getData()) {
log.info("预约计划删除成功!");
}
}
}
log.info("每日创建预约人员监控计划");
//获取当天预约
AppointmentPersonQuery appointmentPersonQuery = new AppointmentPersonQuery();
appointmentPersonQuery.setAppointmentStartTimeStart(DateUtils.getCurrStrDate());
appointmentPersonQuery.setAppointmentStartTimeEnd(DateUtils.getCurrStrDate());
List<AppointmentPersonEntity> appointmentPersonEntities = appointmentPersonService.find(appointmentPersonQuery);
if (!ObjectUtils.isEmpty(appointmentPersonEntities)) {
//创建人脸分组
String group = Constant.APPOINTMENT_GROUP_PREFIX + DateUtils.getCurrStrDate();
FaceGroupEntity faceGroup = faceGroupService.selectOne(new FaceGroupQuery().name(group));
if (ObjectUtils.isEmpty(faceGroup)) {
//创建分组
log.info("创建人脸分组...");
FaceGroupReq faceGroupReq = new FaceGroupReq();
faceGroupReq.setName(group);
faceGroupReq.setDescription(group);
Rest<FaceGroupEntity> rest = faceGroupService.saveFaceGroupToHik(faceGroupReq);
if (rest.getCode() == YesNoEnum.YES.getValue()) {
FaceGroupEntity newFaceGroupEntity = rest.getData();
//创建人脸tohik
for (AppointmentPersonEntity appointmentPersonEntity : appointmentPersonEntities) {
PersonEntity personEntity = personService.getCache(appointmentPersonEntity.getPersonId().toString());
if (ObjectUtils.isEmpty(personEntity)) {
log.info("注册人员未空,persionId:{}", appointmentPersonEntity.getPersonId());
continue;
}
//查询图片并转成base64
if (!ObjectUtils.isEmpty(personEntity.getPhoto())) {
String filePath = uploadService.getFilePath(personEntity.getPhoto());
byte[] bytes = FileUtil.readBytes(filePath);
if (bytes.length > 0) {
String picBase64Data = Base64.encode(bytes);
FaceReq faceReq = new FaceReq();
FaceInfo faceInfo = new FaceInfo();
faceInfo.setName(personEntity.getName());
faceInfo.setSex(personEntity.getGender() == GenderEnum..getValue() ? "1" : "2");
faceInfo.setCertificateType("111");
faceInfo.setCertificateNum(personEntity.getIdCard());
faceReq.setFaceInfo(faceInfo);
FacePic facePic = new FacePic();
facePic.setFaceBinaryData(picBase64Data);
faceReq.setFacePic(facePic);
faceReq.setFaceGroupIndexCode(faceGroup.getIndexCode());
Rest<FaceDataInfo> faceDataInfoRest = hikFaceService.faceSingleAdd(faceReq);
if (faceDataInfoRest.getCode() == YesNoEnum.YES.getValue()) {
//人脸添加成功,保存人脸组
FaceGroupPersonEntity faceGroupPersonEntity = new FaceGroupPersonEntity();
faceGroupPersonEntity.initAttrValue();
faceGroupPersonEntity.setFaceGroupId(newFaceGroupEntity.getId());
faceGroupPersonEntity.setIndexCode(faceDataInfoRest.getData().getIndexCode());
faceGroupPersonEntity.setCreateTime(new Date());
faceGroupPersonEntity.setCreateUserId(1L);
faceGroupPersonService.save(faceGroupPersonEntity);
} else {
log.info("添加人脸异常=>{}", faceDataInfoRest.getMsg());
}
} else {
log.info("图片数据为空,filePath=>{}", filePath);
}
} else {
log.info("人员图片photo为空,person=>{}", personEntity.getName());
}
}
log.info("添加当天预约监控计划");
String appointPlanName = Constant.APPOINTMENT_GROUP_PREFIX + DateUtils.getCurrStrDate();
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
//初始化新增取号监控识别计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setName(appointPlanName);
planRecognBlackReq.setDescription(appointPlanName);
planRecognBlackReq.setThreshold(threshold);
//设置人脸分组
List<String> faceGroupIndexCodes = new ArrayList<>();
faceGroupIndexCodes.add(newFaceGroupEntity.getIndexCode());
planRecognBlackReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).collect(Collectors.toList());
planRecognBlackReq.setCameraIndexCodes(cameraIndexCodes);
//设置识别方式
planRecognBlackReq.setRecognitionResourceType(RecognitionResourceEnum.FACE_RECOGNITION_SERVER.getValue());
//设置时间段 默认全天候
AppointmentConfigEntity appointmentConfigEntity = appointmentConfigService.selectOne(new AppointmentConfigQuery());
if (!ObjectUtils.isEmpty(appointmentConfigEntity)) {
List<AppointmentConfigTimesEntity> timesEntities = appointmentConfigTimesService.find(new AppointmentConfigTimesQuery().aotoCheckCfgId(appointmentConfigEntity.getId()));
if (!ObjectUtils.isEmpty(timesEntities)) {
List<TimeBlockListItem> timeBlockList = new ArrayList<>();
TimeBlockListItem timeBlockListItem = new TimeBlockListItem();
//周一至周日
timeBlockListItem.setDayOfWeek("1-7");
List<TimeRangeItem> timeRange = new ArrayList<>();
for (AppointmentConfigTimesEntity timesEntity : timesEntities) {
TimeRangeItem timeRangeItem = new TimeRangeItem();
String startTimeStr = DateUtils.convertTime2Str(timesEntity.getServiceTimeStart().getTime(), "HH:ss");
String endTimeStr = DateUtils.convertTime2Str(timesEntity.getServiceTimeEnd().getTime(), "HH:ss");
timeRangeItem.setStartTime(startTimeStr);
timeRangeItem.setEndTime(endTimeStr);
timeRange.add(timeRangeItem);
}
timeBlockListItem.setTimeRange(timeRange);
timeBlockList.add(timeBlockListItem);
planRecognBlackReq.setTimeBlockList(timeBlockList);
}
}
Rest<String> planRecognBlackAddRest = hikPlanService.planRecognBlackAdd(planRecognBlackReq);
if (planRecognBlackAddRest.getCode() == YesNoEnum.YES.getValue()) {
FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue();
planEntity.setIndexCode(planRecognBlackAddRest.getData());
planEntity.setName(appointPlanName);
planEntity.setDescription(appointPlanName);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
}
} else {
log.info("人员分组创建失败=>{}", rest.getMsg());
}
} else {
log.info("当天人员分组以存在,人员分组名称=>{}", group);
}
} else {
log.info("当天无预约人员,不创建监控计划=>{}", DateUtils.getCurrStrDate());
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
...@@ -32,8 +32,6 @@ import java.util.List; ...@@ -32,8 +32,6 @@ import java.util.List;
@Service("SyncSubmitAppointTask") @Service("SyncSubmitAppointTask")
public class SyncSubmitAppointTaskImpl implements ITaskExcuteService { public class SyncSubmitAppointTaskImpl implements ITaskExcuteService {
@Autowired
private AppointmentPersonService appointmentPersonService;
@Autowired @Autowired
private AppointmentRecordsService appointmentRecordsService; private AppointmentRecordsService appointmentRecordsService;
......
...@@ -45,7 +45,7 @@ import java.util.List; ...@@ -45,7 +45,7 @@ import java.util.List;
* 时间间隔以同步注册用户之后 * 时间间隔以同步注册用户之后
* 默认同步到一个人脸用户组,如要其它用户组 则页面上进行添加 * 默认同步到一个人脸用户组,如要其它用户组 则页面上进行添加
* 需要根据计划进行同步人脸链接 * 需要根据计划进行同步人脸链接
* 默认 * 默认用户组 主要是陌生人识别 不在当前库中的 都是陌生人
* *
*/ */
@Slf4j @Slf4j
......
package com.mortals.xhx.module.face.service; package com.mortals.xhx.module.face.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.face.model.FaceGroupEntity; import com.mortals.xhx.module.face.model.FaceGroupEntity;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
/** /**
* FaceGroupService * FaceGroupService
* *
...@@ -11,4 +14,7 @@ import com.mortals.xhx.module.face.model.FaceGroupEntity; ...@@ -11,4 +14,7 @@ import com.mortals.xhx.module.face.model.FaceGroupEntity;
*/ */
public interface FaceGroupService extends ICRUDService<FaceGroupEntity,Long>{ public interface FaceGroupService extends ICRUDService<FaceGroupEntity,Long>{
Rest<FaceGroupEntity> saveFaceGroupToHik(FaceGroupReq faceGroupReq);
} }
\ No newline at end of file
package com.mortals.xhx.module.face.service.impl; package com.mortals.xhx.module.face.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -6,14 +13,37 @@ import com.mortals.framework.model.Context; ...@@ -6,14 +13,37 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.face.dao.FaceGroupDao; import com.mortals.xhx.module.face.dao.FaceGroupDao;
import com.mortals.xhx.module.face.model.FaceGroupEntity; import com.mortals.xhx.module.face.model.FaceGroupEntity;
import com.mortals.xhx.module.face.service.FaceGroupService; import com.mortals.xhx.module.face.service.FaceGroupService;
import java.util.Date;
/** /**
* FaceGroupService * FaceGroupService
* 人脸分组信息 service实现 * 人脸分组信息 service实现
* *
* @author zxfei * @author zxfei
* @date 2023-04-15 * @date 2023-04-15
*/ */
@Service("faceGroupService") @Service("faceGroupService")
public class FaceGroupServiceImpl extends AbstractCRUDServiceImpl<FaceGroupDao, FaceGroupEntity, Long> implements FaceGroupService { public class FaceGroupServiceImpl extends AbstractCRUDServiceImpl<FaceGroupDao, FaceGroupEntity, Long> implements FaceGroupService {
@Autowired
private IHikFaceService hikFaceService;
@Override
public Rest<FaceGroupEntity> saveFaceGroupToHik(FaceGroupReq faceGroupReq) {
Rest<FaceGroupDataInfo> faceGroupRest = hikFaceService.faceGroupSingleAdd(faceGroupReq);
if (faceGroupRest.getCode() == YesNoEnum.YES.getValue()) {
FaceGroupEntity groupEntity = new FaceGroupEntity();
groupEntity.initAttrValue();
groupEntity.setName(faceGroupReq.getName());
groupEntity.setDescription(faceGroupReq.getDescription());
groupEntity.setIndexCode(faceGroupRest.getData().getIndexCode());
groupEntity.setCreateTime(new Date());
groupEntity.setCreateUserId(1L);
groupEntity.setCreateUserName("admin");
this.save(groupEntity);
return Rest.ok(groupEntity);
}
return Rest.fail();
}
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ import java.util.List; ...@@ -4,7 +4,7 @@ import java.util.List;
import lombok.Data; import lombok.Data;
@Data @Data
public class PlanRecognBlackListReq{ public class PlanRecognListReq {
private List<String> faceGroupIndexCodes; private List<String> faceGroupIndexCodes;
private String name; private String name;
private String description; private String description;
......
...@@ -4,7 +4,7 @@ import java.util.List; ...@@ -4,7 +4,7 @@ import java.util.List;
import lombok.Data; import lombok.Data;
@Data @Data
public class PlanRecognBlackReq{ public class PlanRecognReq {
private List<String> cameraIndexCodes; private List<String> cameraIndexCodes;
private List<String> faceGroupIndexCodes; private List<String> faceGroupIndexCodes;
private String name; private String name;
......
...@@ -2,14 +2,15 @@ package com.mortals.xhx.module.hik.face.service; ...@@ -2,14 +2,15 @@ package com.mortals.xhx.module.hik.face.service;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackListReq; import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackReq; import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo; import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo;
import java.util.List; import java.util.List;
/** /**
* 海康门禁接口对接类 * 海康门禁接口对接类
*
* @author: * @author:
* @date: 2023/4/12 17:47 * @date: 2023/4/12 17:47
*/ */
...@@ -18,23 +19,51 @@ public interface IHikPlanService { ...@@ -18,23 +19,51 @@ public interface IHikPlanService {
/** /**
* 查询重点识别计划 * 查询重点识别计划
* @param planRecognBlackListReq *
* @param planRecognListReq
* @return * @return
*/ */
Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognBlackListReq planRecognBlackListReq); Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognListReq planRecognListReq);
/** /**
* 人员监视计划 * 添加人员监视计划
* @param planRecognBlackReq *
* @param planRecognReq
* @return * @return
*/ */
Rest<String> planRecognBlackAdd(PlanRecognBlackReq planRecognBlackReq); Rest<String> planRecognBlackAdd(PlanRecognReq planRecognReq);
/** /**
* 人员监视计划删除 * 人员监视计划删除
* @param planRecognBlackReq *
* @param planRecognReq
* @return * @return
*/ */
Rest<Boolean> planRecognBlackDel(PlanRecognBlackReq planRecognBlackReq); Rest<Boolean> planRecognBlackDel(PlanRecognReq planRecognReq);
/**
* 查询陌生人识别计划
*
* @param planRecognListReq
* @return
*/
Rest<List<PlanRecognBlackInfo>> findPlanRecognWhiteList(PlanRecognListReq planRecognListReq);
/**
* 添加陌生人监视计划
*
* @param planRecognReq
* @return
*/
Rest<String> planRecognWhiteAdd(PlanRecognReq planRecognReq);
/**
* 陌生人人员监视计划删除
*
* @param planRecognReq
* @return
*/
Rest<Boolean> planRecognWhiteDel(PlanRecognReq planRecognReq);
} }
...@@ -7,8 +7,8 @@ import com.hikvision.artemis.sdk.config.ArtemisConfig; ...@@ -7,8 +7,8 @@ import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.AbstractHikService; import com.mortals.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.HikApiRest; import com.mortals.xhx.module.hik.HikApiRest;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackListReq; import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackReq; import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo; import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo;
import com.mortals.xhx.module.hik.face.service.IHikPlanService; import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -27,7 +27,7 @@ import java.util.List; ...@@ -27,7 +27,7 @@ import java.util.List;
public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanService { public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanService {
@Override @Override
public Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognBlackListReq planRecognBlackListReq) { public Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognListReq planRecognBlackListReq) {
ArtemisConfig config = getArtemisConfig(); ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black"; String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black";
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
...@@ -68,11 +68,12 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe ...@@ -68,11 +68,12 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
* 当时间计划参数不传时,默认全天候。当传入此参数时,时间计划规则如下:按周计划进行配置,每一天的时间段上限为8,每一个时间段的开始时间必须小于结束时间。 * 当时间计划参数不传时,默认全天候。当传入此参数时,时间计划规则如下:按周计划进行配置,每一天的时间段上限为8,每一个时间段的开始时间必须小于结束时间。
* j)同一个深眸支持配置多个识别计划。 * j)同一个深眸支持配置多个识别计划。
* k)若设备上人脸分组达到上限,则有可能导致下发失败。 * k)若设备上人脸分组达到上限,则有可能导致下发失败。
*
* @param planRecognBlackReq * @param planRecognBlackReq
* @return * @return
*/ */
@Override @Override
public Rest<String> planRecognBlackAdd(PlanRecognBlackReq planRecognBlackReq) { public Rest<String> planRecognBlackAdd(PlanRecognReq planRecognBlackReq) {
ArtemisConfig config = getArtemisConfig(); ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black/addition"; String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black/addition";
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
...@@ -95,7 +96,7 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe ...@@ -95,7 +96,7 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
} }
@Override @Override
public Rest<Boolean> planRecognBlackDel(PlanRecognBlackReq planRecognBlackReq) { public Rest<Boolean> planRecognBlackDel(PlanRecognReq planRecognBlackReq) {
ArtemisConfig config = getArtemisConfig(); ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black/deletion"; String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black/deletion";
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
...@@ -114,4 +115,69 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe ...@@ -114,4 +115,69 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
return Rest.fail(e.getMessage()); return Rest.fail(e.getMessage());
} }
} }
@Override
public Rest<List<PlanRecognBlackInfo>> findPlanRecognWhiteList(PlanRecognListReq planRecognWhiteListReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/white";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognWhiteListReq), null, null, "application/json");
HikApiRest<List<PlanRecognBlackInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<PlanRecognBlackInfo>>>() {
});
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize white list error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("plan recognize white list error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<String> planRecognWhiteAdd(PlanRecognReq planRecognWhiteReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/white/addition";
path.put(protocol, getCamsApi);
try {
log.info("plan recognize white req=>{}", JSON.toJSONString(planRecognWhiteReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognWhiteReq), null, null, "application/json");
log.info("plan recognize white resp=>{}", respJson);
HikApiRest<String> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<String>>() {
});
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize white add error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("plan recognize white add error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<Boolean> planRecognWhiteDel(PlanRecognReq planRecognWhiteReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/white/deletion";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognWhiteReq), null, null, "application/json");
HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
});
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize white error del resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("plan recognize white del error异常", e);
return Rest.fail(e.getMessage());
}
}
} }
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