Commit 99bf9bdc authored by 赵啸非's avatar 赵啸非

添加陌生人识别计划

parent 63430df8
...@@ -91,6 +91,11 @@ public final class Constant { ...@@ -91,6 +91,11 @@ public final class Constant {
*/ */
public static final String EXCHANGE_SPLIT = "."; public static final String EXCHANGE_SPLIT = ".";
/**
* 陌生人监控计划
*/
public final static String STRANGER_PLAN = "stranger_plan";
/** /**
* 预约监控计划前缀 * 预约监控计划前缀
*/ */
......
...@@ -10,6 +10,10 @@ public class ParamKey { ...@@ -10,6 +10,10 @@ public class ParamKey {
/** 默认人脸分组信息 */ /** 默认人脸分组信息 */
public static final String PARAM_FACE_GROUP = "face_group"; public static final String PARAM_FACE_GROUP = "face_group";
/** 注册人脸分组信息 */
public static final String PARAM_FACE_GROUP_REGISTER = "face_group_register";
/** 重点人员监控计划 */ /** 重点人员监控计划 */
public static final String PARAM_FACE_PLAN_BLACK = "plan_black"; public static final String PARAM_FACE_PLAN_BLACK = "plan_black";
/** 人脸识别阈值 */ /** 人脸识别阈值 */
......
...@@ -37,6 +37,9 @@ import java.util.Date; ...@@ -37,6 +37,9 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
//@Component //@Component
@Slf4j @Slf4j
...@@ -75,7 +78,10 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -75,7 +78,10 @@ public class SubEventStartedService implements IApplicationStartedService {
log.info("get events resp==>{}", JSON.toJSONString(events)); log.info("get events resp==>{}", JSON.toJSONString(events));
//查询本地指定人脸分组 如果没有则添加 并更新 //查询本地指定人脸分组 如果没有则添加 并更新
String groupStr = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_GROUP, "注册群众");
String groupStr = GlobalSysInfo.getParamValue(PARAM_FACE_GROUP, PARAM_FACE_GROUP_REGISTER);
List<String> groupList = StrUtil.split(groupStr, ",".charAt(0)); List<String> groupList = StrUtil.split(groupStr, ",".charAt(0));
for (String group : groupList) { for (String group : groupList) {
...@@ -101,8 +107,9 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -101,8 +107,9 @@ public class SubEventStartedService implements IApplicationStartedService {
} }
//删除创建陌生人员识别计划,todo //删除创建陌生人员识别计划,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)) {
...@@ -137,6 +144,7 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -137,6 +144,7 @@ public class SubEventStartedService implements IApplicationStartedService {
} }
} }
*/
//创建陌生人员识别计划 //创建陌生人员识别计划
......
...@@ -35,7 +35,7 @@ import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq; ...@@ -35,7 +35,7 @@ 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.TimeBlockListItem;
import com.mortals.xhx.module.hik.face.model.req.plan.TimeRangeItem; 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.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo; import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognInfo;
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;
import com.mortals.xhx.module.person.model.PersonEntity; import com.mortals.xhx.module.person.model.PersonEntity;
...@@ -50,9 +50,13 @@ import java.util.Date; ...@@ -50,9 +50,13 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/** /**
* 每日创建预约人员监控计划 * 每日创建预约人员监控计划
* 创建计划钱删除之前计划 * 创建计划前删除之前计划
* <p>
* 每日更新陌生人员监控计划
* *
* @author: * @author:
* @date: 2023/4/17 17:52 * @date: 2023/4/17 17:52
...@@ -86,12 +90,76 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService { ...@@ -86,12 +90,76 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
//删除计划
log.info("{}=>创建陌生人计划任务", DateUtils.getCurrStrDate());
createStrangerPlanByDay();
log.info("{}=>创建陌生人计划任务完成", DateUtils.getCurrStrDate());
log.info("{}=>创建预约计划任务", DateUtils.getCurrStrDate());
createAppointmentPlanByDay();
log.info("{}=>创建预约计划任务完成", DateUtils.getCurrStrDate());
}
private void createStrangerPlanByDay(){
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
//创建或者更新
PlanRecognListReq planRecognListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognWhiteListRest = hikPlanService.findPlanRecognWhiteList(planRecognListReq);
if (planRecognWhiteListRest.getCode() == YesNoEnum.YES.getValue()) {
PlanRecognInfo planRecognWhiteInfo = planRecognWhiteListRest.getData().stream().map(i -> {
i.getName();
if (i.getName().equals(Constant.STRANGER_PLAN)) {
return i;
}
return null;
}).filter(f -> f != null).findFirst().orElseGet(() -> null);
if(ObjectUtils.isEmpty(planRecognWhiteInfo)){
// todo 创建陌生人计划
//初始化新增取号监控识别计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setName(Constant.STRANGER_PLAN);
planRecognBlackReq.setDescription(Constant.STRANGER_PLAN);
planRecognBlackReq.setThreshold(threshold);
//设置人脸分组
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(PARAM_FACE_GROUP_REGISTER));
List<String> faceGroupIndexCodes = new ArrayList<>();
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
planRecognBlackReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).collect(Collectors.toList());
planRecognBlackReq.setCameraIndexCodes(cameraIndexCodes);
//设置识别方式
planRecognBlackReq.setRecognitionResourceType(RecognitionResourceEnum.COMPARISON.getValue());
//设置时间段 默认全天候
Rest<String> planRecognBlackAddRest = hikPlanService.planRecognBlackAdd(planRecognBlackReq);
if (planRecognBlackAddRest.getCode() == YesNoEnum.YES.getValue()) {
FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue();
planEntity.setIndexCode(planRecognBlackAddRest.getData());
planEntity.setName(Constant.STRANGER_PLAN);
planEntity.setDescription(Constant.STRANGER_PLAN);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
}
}else {
//更新计划
}
}
}
private void createAppointmentPlanByDay() {
PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq(); PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognBlackInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq); Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) { if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognBlackInfo> delPlanList = planRecognBlackRest.getData().stream().map(i -> { List<PlanRecognInfo> 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())) { if (StrUtil.startWith(i.getName(), Constant.APPOINTMENT_PLAN_PREFIX) && !i.getName().equals(Constant.APPOINTMENT_GROUP_PREFIX + DateUtils.getCurrStrDate())) {
return i; return i;
} }
......
...@@ -40,13 +40,14 @@ import org.springframework.util.ObjectUtils; ...@@ -40,13 +40,14 @@ import org.springframework.util.ObjectUtils;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/** /**
* 同步用户人脸数据到海康指定库。 * 同步用户人脸数据到海康指定库。
* 时间间隔以同步注册用户之后 * 时间间隔以同步注册用户之后
* 默认同步到一个人脸用户组,如要其它用户组 则页面上进行添加 * 默认同步到一个人脸用户组,如要其它用户组 则页面上进行添加
* 需要根据计划进行同步人脸链接 * 需要根据计划进行同步人脸链接
* 默认用户组 主要是陌生人识别 不在当前库中的 都是陌生人 * 默认用户组 主要是陌生人识别 不在当前库中的 都是陌生人
*
*/ */
@Slf4j @Slf4j
@Service("SyncUserToHikTask") @Service("SyncUserToHikTask")
...@@ -66,7 +67,7 @@ public class SyncUserToHikTaskImpl implements ITaskExcuteService { ...@@ -66,7 +67,7 @@ public class SyncUserToHikTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("同步用户人脸到海康任务"); log.info("同步用户人脸到海康任务");
FaceGroupEntity faceGroup = faceGroupService.selectOne(new FaceGroupQuery().name("注册群众")); FaceGroupEntity faceGroup = faceGroupService.selectOne(new FaceGroupQuery().name(PARAM_FACE_GROUP_REGISTER));
List<PersonEntity> personUnHikList = personService.find(new PersonQuery().inFaceHk(YesNoEnum.NO.getValue())); List<PersonEntity> personUnHikList = personService.find(new PersonQuery().inFaceHk(YesNoEnum.NO.getValue()));
if (!ObjectUtils.isEmpty(personUnHikList)) { if (!ObjectUtils.isEmpty(personUnHikList)) {
for (PersonEntity personEntity : personUnHikList) { for (PersonEntity personEntity : personUnHikList) {
......
...@@ -115,7 +115,8 @@ public class BlackPlanRecoginze extends EventTypeAbstract { ...@@ -115,7 +115,8 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
//查询当前是否为当天预约人员 //查询当前是否为当天预约人员
AppointmentPersonQuery appointmentPersonQuery = new AppointmentPersonQuery(); AppointmentPersonQuery appointmentPersonQuery = new AppointmentPersonQuery();
appointmentPersonQuery.setPersonId(personCache.getId()); appointmentPersonQuery.setPersonId(personCache.getId());
appointmentPersonQuery.setAppointmentStartTime(DateUtils.getCurrDate()); appointmentPersonQuery.setAppointmentStartTimeStart(DateUtils.getCurrStrDate());
appointmentPersonQuery.setAppointmentStartTimeEnd(DateUtils.getCurrStrDate());
List<AppointmentPersonEntity> appointmentPersonEntities = appointmentPersonService.find(appointmentPersonQuery); List<AppointmentPersonEntity> appointmentPersonEntities = appointmentPersonService.find(appointmentPersonQuery);
for (AppointmentPersonEntity appointmentPersonEntity : appointmentPersonEntities) { for (AppointmentPersonEntity appointmentPersonEntity : appointmentPersonEntities) {
...@@ -123,7 +124,8 @@ public class BlackPlanRecoginze extends EventTypeAbstract { ...@@ -123,7 +124,8 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
AppointmentRecordsQuery appointmentRecordsQuery = new AppointmentRecordsQuery(); AppointmentRecordsQuery appointmentRecordsQuery = new AppointmentRecordsQuery();
appointmentRecordsQuery.setPersonId(personCache.getId()); appointmentRecordsQuery.setPersonId(personCache.getId());
appointmentRecordsQuery.setReservationService(appointmentPersonEntity.getBussinessName()); appointmentRecordsQuery.setReservationService(appointmentPersonEntity.getBussinessName());
appointmentRecordsQuery.setCreateTime(DateUtils.getCurrDate()); appointmentRecordsQuery.setCreateTimeStart(DateUtils.getCurrStrDate());
appointmentRecordsQuery.setCreateTimeEnd(DateUtils.getCurrStrDate());
//设置 //设置
int count = appointmentRecordsService.count(appointmentRecordsQuery, null); int count = appointmentRecordsService.count(appointmentRecordsQuery, null);
if (count == 0) { if (count == 0) {
......
...@@ -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 PlanRecognBlackInfo{ public class PlanRecognInfo {
private List<String> cameraIndexCodes; private List<String> cameraIndexCodes;
private boolean available; private boolean available;
private String indexCode; private String indexCode;
......
...@@ -4,7 +4,7 @@ package com.mortals.xhx.module.hik.face.service; ...@@ -4,7 +4,7 @@ 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.PlanRecognListReq; 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.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo; import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognInfo;
import java.util.List; import java.util.List;
...@@ -23,7 +23,7 @@ public interface IHikPlanService { ...@@ -23,7 +23,7 @@ public interface IHikPlanService {
* @param planRecognListReq * @param planRecognListReq
* @return * @return
*/ */
Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognListReq planRecognListReq); Rest<List<PlanRecognInfo>> findPlanRecognBlackList(PlanRecognListReq planRecognListReq);
/** /**
* 添加人员监视计划 * 添加人员监视计划
...@@ -48,7 +48,7 @@ public interface IHikPlanService { ...@@ -48,7 +48,7 @@ public interface IHikPlanService {
* @param planRecognListReq * @param planRecognListReq
* @return * @return
*/ */
Rest<List<PlanRecognBlackInfo>> findPlanRecognWhiteList(PlanRecognListReq planRecognListReq); Rest<List<PlanRecognInfo>> findPlanRecognWhiteList(PlanRecognListReq planRecognListReq);
/** /**
* 添加陌生人监视计划 * 添加陌生人监视计划
......
...@@ -9,7 +9,7 @@ import com.mortals.xhx.module.hik.AbstractHikService; ...@@ -9,7 +9,7 @@ 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.PlanRecognListReq; 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.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo; import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognInfo;
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;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -27,13 +27,13 @@ import java.util.List; ...@@ -27,13 +27,13 @@ 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(PlanRecognListReq planRecognBlackListReq) { public Rest<List<PlanRecognInfo>> 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);
try { try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognBlackListReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognBlackListReq), null, null, "application/json");
HikApiRest<List<PlanRecognBlackInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<PlanRecognBlackInfo>>>() { HikApiRest<List<PlanRecognInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<PlanRecognInfo>>>() {
}); });
if (rest.getCode() == "0") { if (rest.getCode() == "0") {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
...@@ -117,13 +117,13 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe ...@@ -117,13 +117,13 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
} }
@Override @Override
public Rest<List<PlanRecognBlackInfo>> findPlanRecognWhiteList(PlanRecognListReq planRecognWhiteListReq) { public Rest<List<PlanRecognInfo>> findPlanRecognWhiteList(PlanRecognListReq planRecognWhiteListReq) {
ArtemisConfig config = getArtemisConfig(); ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/white"; String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/white";
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
try { try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognWhiteListReq), null, null, "application/json"); 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>>>() { HikApiRest<List<PlanRecognInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<PlanRecognInfo>>>() {
}); });
if (rest.getCode() == "0") { if (rest.getCode() == "0") {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
......
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