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

添加服务追踪

parent f1787db6
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
}, },
], ],
columns: [ columns: [
{type: "selection", width: 60}, /* {type: "selection", width: 60},*/
{type: "index",label: "序号",width: 50}, {type: "index",label: "序号",width: 50},
{label: "姓名", prop: "name"}, {label: "姓名", prop: "name"},
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
{label: "排队编码", prop: "queueNum"}, {label: "排队编码", prop: "queueNum"},
{label: "办理位置", prop: "location"}, {label: "办理位置", prop: "location"},
{label: "识别截图", prop: "picture",formatter: (row) => { {label: "识别截图", prop: "picture",formatter: (row) => {
return row.picture != "" ? ( return row.picture != "" ? (
<el-image <el-image
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum DaySelectEnum {
今天(0, "今天"),
近七天(1, "近七天"),
近三十天(2, "近三十天"),
近三月(3, "近三月"),
今年(4, "今年");
private Integer value;
private String desc;
DaySelectEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static DaySelectEnum getByValue(Integer value) {
for (DaySelectEnum alarmLevelEnum : DaySelectEnum.values()) {
if (alarmLevelEnum.getValue() == value) {
return alarmLevelEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (DaySelectEnum item : DaySelectEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum TimeUnitEnum {
/** 小时 */
HOUR(0, "小时"),
/** 日 */
DAY(1, "每日"),
/** 月 */
MONTH(2, "月"),
/** 年 */
YEAR(3, "年");
private int value;
private String desc;
TimeUnitEnum(int value, String desc) {
this.value = value;
this.desc = desc;
}
public int getValue() {
return this.value;
}
public String getDesc() {
return desc;
}
public static TimeUnitEnum getByValue(int value) {
for (TimeUnitEnum yesNo : TimeUnitEnum.values()) {
if (yesNo.getValue() == value) {
return yesNo;
}
}
return null;
}
public static Map<String,String> getEnumMap(int... eItem) {
Map<String,String> resultMap= new LinkedHashMap<String,String>();
for (TimeUnitEnum item : TimeUnitEnum.values()) {
try{
boolean hasE = false;
for (int e : eItem){
if(item.getValue()==e){
hasE = true;
break;
}
}
if(!hasE){
resultMap.put(item.getValue()+"", item.getDesc());
}
}catch(Exception ex){
}
}
return resultMap;
}
}
...@@ -97,6 +97,18 @@ public final class Constant { ...@@ -97,6 +97,18 @@ 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 = "陌生人监控计划"; public final static String STRANGER_PLAN_DESC = "陌生人监控计划";
/**
* 预约监控计划
*/
public final static String APPOINTMENT_PLAN = "appointment_plan";
public final static String APPOINTMENT_PLAN_DESC = "预约人监控计划";
/**
* 预约人员分组
*/
public final static String APPOINTMENT_GROUP = "appointment_group";
/** /**
* 预约监控计划前缀 * 预约监控计划前缀
*/ */
......
...@@ -38,7 +38,11 @@ import java.util.stream.Collectors; ...@@ -38,7 +38,11 @@ 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;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER; import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/**
* 初始化部分计划数据等
* @author:
* @date: 2023/5/9 10:01
*/
@Component @Component
@Slf4j @Slf4j
public class SubEventStartedService implements IApplicationStartedService { public class SubEventStartedService implements IApplicationStartedService {
...@@ -77,10 +81,8 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -77,10 +81,8 @@ 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(PARAM_FACE_GROUP, "face_group_register,appointment_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) {
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(group)); FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(group));
if (ObjectUtils.isEmpty(faceGroupEntity)) { if (ObjectUtils.isEmpty(faceGroupEntity)) {
...@@ -104,73 +106,9 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -104,73 +106,9 @@ public class SubEventStartedService implements IApplicationStartedService {
} }
//创建陌生人计划 //创建陌生人计划
// facePlanService.createStrangerPlanByDay(); facePlanService.createStrangerPlan();
//创建预约人监控计划
// ImgReq imgReq = new ImgReq(); facePlanService.createAppointmentPlan();
///imgReq.setUrl("http://10.12.82.102:80/picture/Streaming/tracks/703/?name=ch00007_00000004885023469721600008659&size=8659");
// Rest<String> stringRest = hikFaceService.downloadPicture(imgReq);
//log.info(stringRest.getData());
//删除重点人员计划
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognInfo> delPlanList = planRecognBlackRest.getData();
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("预约计划删除成功!");
}
}
}*/
//删除创建陌生人员识别计划,todo
// String planBlackName = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_PLAN_BLACK, "取号监控");
/*
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
FacePlanEntity facePlanEntity = facePlanService.selectOne(new FacePlanQuery().name(planBlackName));
if (ObjectUtils.isEmpty(facePlanEntity)) {
//初始化新增取号监控识别计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setName(planBlackName);
planRecognBlackReq.setDescription(planBlackName);
planRecognBlackReq.setThreshold(threshold);
//设置人脸分组
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name("注册群众"));
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(planBlackName);
planEntity.setDescription(planBlackName);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
}
}
*/
//创建陌生人员识别计划
} }
......
package com.mortals.xhx.daemon.task;
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.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.service.DeviceService;
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.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
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;
/**
* 创建每日预约人群,并添加的预约人脸组中
* 执行时间需晚于预约人群同步时间
* @author:
* @date: 2023/5/9 13:44
*/
@Slf4j
//@Service("CreateAppointPersonToHikBlackPlanByDay")
public class CreateAppointPersonToHikBlackPlanByDayTaskImpl 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 {
log.info("创建每日预约人群任务");
facePlanService.createAppointmentPersonByDay();
log.info("创建每日预约人群完成");
}
private void createAppointmentPersonByDay() {
facePlanService.createAppointmentPersonByDay();
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognInfo> delPlanList = planRecognBlackRest.getData().stream().map(i -> {
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 {
}
}
package com.mortals.xhx.daemon.task; 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.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.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.upload.service.UploadService; 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.AppointmentConfigService;
import com.mortals.xhx.module.appointment.service.AppointmentConfigTimesService; import com.mortals.xhx.module.appointment.service.AppointmentConfigTimesService;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService; 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.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.FaceGroupPersonService;
import com.mortals.xhx.module.face.service.FaceGroupService; import com.mortals.xhx.module.face.service.FaceGroupService;
import com.mortals.xhx.module.face.service.FacePlanService; 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.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.service.PersonService; import com.mortals.xhx.module.person.service.PersonService;
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.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/** /**
* 每日创建预约人员监控计划 * 每日创建预约人员监控计划
...@@ -62,7 +28,7 @@ import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER; ...@@ -62,7 +28,7 @@ import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
* @date: 2023/4/17 17:52 * @date: 2023/4/17 17:52
*/ */
@Slf4j @Slf4j
@Service("CreateBlackPlanToHikByDayTask") //@Service("CreateBlackPlanToHikByDayTask")
public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService { public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
...@@ -98,7 +64,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService { ...@@ -98,7 +64,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
log.info("{}=>创建陌生人计划任务完成", DateUtils.getCurrStrDate()); log.info("{}=>创建陌生人计划任务完成", DateUtils.getCurrStrDate());
log.info("{}=>创建预约计划任务", DateUtils.getCurrStrDate()); log.info("{}=>创建预约计划任务", DateUtils.getCurrStrDate());
facePlanService.createAppointmentPlanByDay(); facePlanService.createAppointmentPersonByDay();
//createAppointmentPlanByDay(); //createAppointmentPlanByDay();
log.info("{}=>创建预约计划任务完成", DateUtils.getCurrStrDate()); log.info("{}=>创建预约计划任务完成", DateUtils.getCurrStrDate());
} }
...@@ -198,7 +164,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService { ...@@ -198,7 +164,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
private void createAppointmentPlanByDay() { private void createAppointmentPlanByDay() {
facePlanService.createAppointmentPlanByDay(); facePlanService.createAppointmentPersonByDay();
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq(); /* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq); Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
......
...@@ -49,11 +49,9 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -49,11 +49,9 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
statPeople(); statPeople();
donwnloadSnap(); donwnloadSnap();
} }
private void statPeople() { private void statPeople() {
...@@ -67,7 +65,7 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -67,7 +65,7 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
realtimeDataflowQuery.setCreateTimeStart(startTimeStr); realtimeDataflowQuery.setCreateTimeStart(startTimeStr);
realtimeDataflowQuery.setCreateTimeEnd(endTimeStr); realtimeDataflowQuery.setCreateTimeEnd(endTimeStr);
List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null); List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null);
if (ObjectUtils.isEmpty(realtimeDataflowEntities)) { if (!ObjectUtils.isEmpty(realtimeDataflowEntities)) {
Long strangerCount = realtimeDataflowEntities.parallelStream().filter(f -> ObjectUtils.isEmpty(f.getIdNumber())).count(); Long strangerCount = realtimeDataflowEntities.parallelStream().filter(f -> ObjectUtils.isEmpty(f.getIdNumber())).count();
int total = realtimeDataflowEntities.size(); int total = realtimeDataflowEntities.size();
Long recognizeCount = total - strangerCount; Long recognizeCount = total - strangerCount;
......
...@@ -114,6 +114,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService { ...@@ -114,6 +114,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
} }
cacheService.select(database);// cacheService.select(database);//
if (!ObjectUtils.isEmpty(waitPersonInfos)) { if (!ObjectUtils.isEmpty(waitPersonInfos)) {
log.info("waitPersonInfos:{}", JSON.toJSONString(waitPersonInfos));
List<CareRecordsEntity> recordsEntityList = waitPersonInfos.stream().map(item -> { List<CareRecordsEntity> recordsEntityList = waitPersonInfos.stream().map(item -> {
CareRecordsEntity careRecordsEntity = new CareRecordsEntity(); CareRecordsEntity careRecordsEntity = new CareRecordsEntity();
careRecordsEntity.initAttrValue(); careRecordsEntity.initAttrValue();
...@@ -141,6 +142,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService { ...@@ -141,6 +142,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
} }
} }
if (!ObjectUtils.isEmpty(finPersonInfos)) { if (!ObjectUtils.isEmpty(finPersonInfos)) {
log.info("finPersonInfos:{}", JSON.toJSONString(finPersonInfos));
List<Long> waitIdList = finPersonInfos.stream().map(item -> item.getWaitId()).collect(Collectors.toList()); List<Long> waitIdList = finPersonInfos.stream().map(item -> item.getWaitId()).collect(Collectors.toList());
Map<Long, FinPersonInfo> waitMap = finPersonInfos.stream().collect(Collectors.toMap(x -> x.getWaitId(), y -> y, (o, n) -> n)); Map<Long, FinPersonInfo> waitMap = finPersonInfos.stream().collect(Collectors.toMap(x -> x.getWaitId(), y -> y, (o, n) -> n));
......
...@@ -18,6 +18,7 @@ import com.mortals.xhx.common.code.YesNoEnum; ...@@ -18,6 +18,7 @@ import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity; import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import com.mortals.xhx.module.appointment.model.AppointmentPersonQuery; import com.mortals.xhx.module.appointment.model.AppointmentPersonQuery;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService; import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
import com.mortals.xhx.module.face.service.FacePlanService;
import com.mortals.xhx.module.person.model.PersonEntity; import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.model.PersonQuery; import com.mortals.xhx.module.person.model.PersonQuery;
import com.mortals.xhx.module.person.service.PersonService; import com.mortals.xhx.module.person.service.PersonService;
...@@ -54,6 +55,8 @@ public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService { ...@@ -54,6 +55,8 @@ public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService {
private PersonService personService; private PersonService personService;
@Autowired @Autowired
private AppointmentPersonService appointmentPersonService; private AppointmentPersonService appointmentPersonService;
@Autowired
private FacePlanService facePlanService;
@Value("${php.host:''}") @Value("${php.host:''}")
...@@ -66,8 +69,11 @@ public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService { ...@@ -66,8 +69,11 @@ public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService {
syncAppointmentPerson(); syncAppointmentPerson();
log.info("同步今天预约用户任务完成"); log.info("同步今天预约用户任务完成");
} log.info("创建每日预约人群任务");
facePlanService.createAppointmentPersonByDay();
log.info("创建每日预约人群完成");
}
private void syncAppointmentPerson() { private void syncAppointmentPerson() {
//根据数量查询 //根据数量查询
......
...@@ -63,7 +63,6 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService { ...@@ -63,7 +63,6 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
private void syncRegisterUsersPhotos() { private void syncRegisterUsersPhotos() {
String url = host.endsWith("/") ? host : host + "/"; String url = host.endsWith("/") ? host : host + "/";
List<PersonEntity> collect = personService.find(new PersonQuery()).stream() List<PersonEntity> collect = personService.find(new PersonQuery()).stream()
.filter(item -> ObjectUtils.isEmpty(item.getPhoto())) .filter(item -> ObjectUtils.isEmpty(item.getPhoto()))
.filter(item -> !ObjectUtils.isEmpty(item.getSourcePhotoUri())).collect(Collectors.toList()); .filter(item -> !ObjectUtils.isEmpty(item.getSourcePhotoUri())).collect(Collectors.toList());
...@@ -84,11 +83,9 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService { ...@@ -84,11 +83,9 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
List<PersonEntity> hikPerson = personService.find(new PersonQuery().source(SourceEnum.海康系统.getValue())).stream().filter(f -> ObjectUtils.isEmpty(f.getPhoto())).collect(Collectors.toList()); List<PersonEntity> hikPerson = personService.find(new PersonQuery().source(SourceEnum.海康系统.getValue())).stream().filter(f -> ObjectUtils.isEmpty(f.getPhoto())).collect(Collectors.toList());
for (PersonEntity person : hikPerson) { for (PersonEntity person : hikPerson) {
ImgReq imgReq = new ImgReq(); ImgReq imgReq = new ImgReq();
imgReq.setSvrIndexCode(person.getServerIndexCode()); imgReq.setSvrIndexCode(person.getServerIndexCode());
imgReq.setPicUri(person.getPicUrl()); imgReq.setPicUri(person.getPicUrl());
try { try {
InputStream inputStream = hikFaceService.callPostImgs(imgReq); InputStream inputStream = hikFaceService.callPostImgs(imgReq);
if (!ObjectUtils.isEmpty(inputStream)) { if (!ObjectUtils.isEmpty(inputStream)) {
......
...@@ -88,7 +88,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService { ...@@ -88,7 +88,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
private void syncRegisterUsers() { private void syncRegisterUsers() {
//查询本地最大id //查询本地最大id
int count=0; int count=0;
List<PersonEntity> max = personService.getDao().getMax(); List<PersonEntity> max = personService.getDao().getMax();
if(!ObjectUtils.isEmpty(max)){ if(!ObjectUtils.isEmpty(max)){
...@@ -200,13 +199,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService { ...@@ -200,13 +199,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
} }
// Map<String, Integer> params = new HashMap<>();
// params.put("page",1);
// params.put("size",1);
//
// HttpUtil.doGet(url,params)
} }
private void syncRegisterUsersPhotos() { private void syncRegisterUsersPhotos() {
......
...@@ -107,17 +107,11 @@ public class SyncUserToHikTaskImpl implements ITaskExcuteService { ...@@ -107,17 +107,11 @@ public class SyncUserToHikTaskImpl implements ITaskExcuteService {
faceGroupPersonEntity.setCreateTime(new Date()); faceGroupPersonEntity.setCreateTime(new Date());
faceGroupPersonEntity.setCreateUserId(1L); faceGroupPersonEntity.setCreateUserId(1L);
faceGroupPersonService.save(faceGroupPersonEntity); faceGroupPersonService.save(faceGroupPersonEntity);
//faceGroupPersonService;
} }
//log.info("picBase64Data=>{}", picBase64Data);
} }
} }
// FileUtil.read
} }
} }
} }
......
...@@ -17,13 +17,22 @@ import java.util.List; ...@@ -17,13 +17,22 @@ import java.util.List;
*/ */
public interface FacePlanService extends ICRUDService<FacePlanEntity, Long> { public interface FacePlanService extends ICRUDService<FacePlanEntity, Long> {
/**
* 创建陌生人监控计划
*/
Rest<List<PlanRecognInfo>> createStrangerPlan();
/** /**
* 创建陌生人监控计划 * 创建陌生人监控计划
*/ */
Rest<List<PlanRecognInfo>> createStrangerPlanByDay(); Rest<List<PlanRecognInfo>> createStrangerPlanByDay();
/**
* 每日创建预约人员监控计划
*/
void createAppointmentPersonByDay();
/** /**
* 创建预约人员监控计划 * 创建预约人员监控计划
*/ */
void createAppointmentPlanByDay(); Rest<String> createAppointmentPlan();
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.hutool.core.codec.Base64; ...@@ -4,6 +4,7 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
...@@ -52,6 +53,7 @@ import java.util.Date; ...@@ -52,6 +53,7 @@ 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.Constant.*;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER; import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/** /**
...@@ -89,8 +91,108 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -89,8 +91,108 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
@Autowired @Autowired
private AppointmentConfigTimesService appointmentConfigTimesService; private AppointmentConfigTimesService appointmentConfigTimesService;
@Override
public Rest<List<PlanRecognInfo>> createStrangerPlan() {
//初始化创建陌生人计划,如果已经有了则不添加
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);
//初始化新增取号监控识别计划
PlanRecognReq planRecognWhiteReq = new PlanRecognReq();
planRecognWhiteReq.setName(Constant.STRANGER_PLAN);
planRecognWhiteReq.setDescription(Constant.STRANGER_PLAN_DESC);
planRecognWhiteReq.setThreshold(threshold);
//设置人脸分组
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(PARAM_FACE_GROUP_REGISTER));
if (ObjectUtils.isEmpty(faceGroupEntity)) {
log.info("人脸组不存在!");
return Rest.fail();
}
List<String> faceGroupIndexCodes = new ArrayList<>();
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
planRecognWhiteReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).distinct().collect(Collectors.toList());
planRecognWhiteReq.setCameraIndexCodes(cameraIndexCodes);
//设置识别方式
planRecognWhiteReq.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getValue());
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);
}
if (ObjectUtils.isEmpty(planRecognWhiteInfo)) {
Rest<String> planRecognWhiteAddRest = hikPlanService.planRecognWhiteAdd(planRecognWhiteReq);
if (planRecognWhiteAddRest.getCode() == YesNoEnum.YES.getValue()) {
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_DESC);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
}
} else {
//判断计划运行状态
/* if (PlanStatusEnum.FAIL.getValue().equals(planRecognWhiteInfo.getStatus())) {
//计划下发识别,重新下发当前计划
// facePlanService.re
PlanRecognReq planRecognReq = new PlanRecognReq();
planRecognReq.setIndexCode(planRecognWhiteInfo.getIndexCode());
Rest<Boolean> booleanRest = hikPlanService.planRecognWhiteReStart(planRecognReq);
if (YesNoEnum.YES.getValue() == booleanRest.getCode()) {
return Rest.ok(booleanRest.getMsg());
} else {
return Rest.fail(booleanRest.getMsg());
}
} else if (PlanStatusEnum.RUNNING.getValue().equals(planRecognWhiteInfo.getStatus())) {
return Rest.ok(PlanStatusEnum.RUNNING.getDesc());
}*/
//更新计划
/* 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);
whitePlan.setUpdateUserName("system");
facePlanService.update(whitePlan);
}
}*/
}
}
return planRecognWhiteListRest;
}
@Override @Override
public Rest<List<PlanRecognInfo>> createStrangerPlanByDay() { public Rest<List<PlanRecognInfo>> createStrangerPlanByDay() {
//初始化创建陌生人计划,如果已经有了则不添加
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80); int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
//创建或者更新 //创建或者更新
PlanRecognListReq planRecognListReq = new PlanRecognListReq(); PlanRecognListReq planRecognListReq = new PlanRecognListReq();
...@@ -106,7 +208,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -106,7 +208,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
//初始化新增取号监控识别计划 //初始化新增取号监控识别计划
PlanRecognReq planRecognWhiteReq = new PlanRecognReq(); PlanRecognReq planRecognWhiteReq = new PlanRecognReq();
planRecognWhiteReq.setName(Constant.STRANGER_PLAN); planRecognWhiteReq.setName(Constant.STRANGER_PLAN);
planRecognWhiteReq.setDescription(Constant.STRANGER_PLAN); planRecognWhiteReq.setDescription(Constant.STRANGER_PLAN_DESC);
planRecognWhiteReq.setThreshold(threshold); planRecognWhiteReq.setThreshold(threshold);
//设置人脸分组 //设置人脸分组
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(PARAM_FACE_GROUP_REGISTER)); FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(PARAM_FACE_GROUP_REGISTER));
...@@ -171,7 +273,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -171,7 +273,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
} }
} else { } else {
//判断计划运行状态 //判断计划运行状态
if (PlanStatusEnum.FAIL.getValue().equals(planRecognWhiteInfo.getStatus())) { /* if (PlanStatusEnum.FAIL.getValue().equals(planRecognWhiteInfo.getStatus())) {
//计划下发识别,重新下发当前计划 //计划下发识别,重新下发当前计划
// facePlanService.re // facePlanService.re
PlanRecognReq planRecognReq = new PlanRecognReq(); PlanRecognReq planRecognReq = new PlanRecognReq();
...@@ -184,9 +286,9 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -184,9 +286,9 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
} }
} else if (PlanStatusEnum.RUNNING.getValue().equals(planRecognWhiteInfo.getStatus())) { } else if (PlanStatusEnum.RUNNING.getValue().equals(planRecognWhiteInfo.getStatus())) {
return Rest.ok(PlanStatusEnum.RUNNING.getDesc()); return Rest.ok(PlanStatusEnum.RUNNING.getDesc());
} }*/
//更新计划 //更新计划
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()));
...@@ -197,7 +299,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -197,7 +299,7 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
facePlanService.update(whitePlan); facePlanService.update(whitePlan);
} }
} }*/
} }
} }
...@@ -206,162 +308,154 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa ...@@ -206,162 +308,154 @@ public class FacePlanServiceImpl extends AbstractCRUDServiceImpl<FacePlanDao, Fa
} }
@Override @Override
public void createAppointmentPlanByDay() { public void createAppointmentPersonByDay() {
PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq(); //创建当前的预约人群人像 并同步到海康人脸库
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognInfo> delPlanList = planRecognBlackRest.getData().stream().map(i -> {
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 appointmentPersonQuery = new AppointmentPersonQuery();
appointmentPersonQuery.setAppointmentStartTimeStart(DateUtils.getCurrStrDate()); appointmentPersonQuery.setAppointmentStartTimeStart(DateUtils.getCurrStrDate());
appointmentPersonQuery.setAppointmentStartTimeEnd(DateUtils.getCurrStrDate()); appointmentPersonQuery.setAppointmentStartTimeEnd(DateUtils.getCurrStrDate());
List<AppointmentPersonEntity> appointmentPersonEntities = appointmentPersonService.find(appointmentPersonQuery); List<AppointmentPersonEntity> appointmentPersonEntities = appointmentPersonService.find(appointmentPersonQuery);
if (!ObjectUtils.isEmpty(appointmentPersonEntities)) { if (!ObjectUtils.isEmpty(appointmentPersonEntities)) {
//创建人脸分组 //将人脸同步添加到海康人脸库中,如果已经添加过的 则不添加
String group = Constant.APPOINTMENT_GROUP_PREFIX + DateUtils.getCurrStrDate(); FaceGroupEntity faceGroup = faceGroupService.selectOne(new FaceGroupQuery().name(APPOINTMENT_GROUP));
FaceGroupEntity faceGroup = faceGroupService.selectOne(new FaceGroupQuery().name(group)); if (!ObjectUtils.isEmpty(faceGroup)) {
if (ObjectUtils.isEmpty(faceGroup)) { //删除本地和远端人脸库,重新添加 todo
//创建分组 List<FaceGroupPersonEntity> delFacePerson = faceGroupPersonService.find(new FaceGroupPersonQuery().faceGroupId(faceGroup.getId()));
log.info("创建人脸分组..."); if(!ObjectUtils.isEmpty(delFacePerson)){
FaceGroupReq faceGroupReq = new FaceGroupReq(); FaceReq faceRequest = new FaceReq();
faceGroupReq.setName(group); faceRequest.setFaceGroupIndexCode(faceGroup.getIndexCode());
faceGroupReq.setDescription(group); faceRequest.setIndexCodes(delFacePerson.stream().map(i -> i.getIndexCode()).collect(Collectors.toList()));
Rest<FaceGroupEntity> rest = faceGroupService.saveFaceGroupToHik(faceGroupReq); Rest<Boolean> delRest = hikFaceService.faceSingleDel(faceRequest);
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (delRest.getCode()==YesNoEnum.YES.getValue()&&delRest.getData()) {
FaceGroupEntity newFaceGroupEntity = rest.getData(); faceGroupPersonService.remove(delFacePerson.stream().map(i -> i.getId()).toArray(Long[]::new), null);
//创建人脸tohik }else{
for (AppointmentPersonEntity appointmentPersonEntity : appointmentPersonEntities) { log.info("人脸删除失败==》{}",JSON.toJSONString(delRest));
PersonEntity personEntity = personService.getCache(appointmentPersonEntity.getPersonId().toString()); return;
if (ObjectUtils.isEmpty(personEntity)) { }
log.info("注册人员未空,persionId:{}", appointmentPersonEntity.getPersonId()); }
continue;
} //创建人脸tohik
//查询图片并转成base64 for (AppointmentPersonEntity appointmentPersonEntity : appointmentPersonEntities) {
if (!ObjectUtils.isEmpty(personEntity.getPhoto())) { PersonEntity personEntity = personService.getCache(appointmentPersonEntity.getPersonId().toString());
String filePath = uploadService.getFilePath(personEntity.getPhoto()); if (ObjectUtils.isEmpty(personEntity)) {
byte[] bytes = FileUtil.readBytes(filePath); log.info("注册人员不能为空,persionId:{}", appointmentPersonEntity.getPersonId());
if (bytes.length > 0) { continue;
String picBase64Data = Base64.encode(bytes); }
FaceReq faceReq = new FaceReq(); //查询图片并转成base64
FaceInfo faceInfo = new FaceInfo(); if (!ObjectUtils.isEmpty(personEntity.getPhoto())) {
faceInfo.setName(personEntity.getName()); String filePath = uploadService.getFilePath(personEntity.getPhoto());
faceInfo.setSex(personEntity.getGender() == GenderEnum..getValue() ? "1" : "2"); byte[] bytes = FileUtil.readBytes(filePath);
faceInfo.setCertificateType("111"); if (bytes.length > 0) {
faceInfo.setCertificateNum(personEntity.getIdCard()); String picBase64Data = Base64.encode(bytes);
faceReq.setFaceInfo(faceInfo); FaceReq faceReq = new FaceReq();
FacePic facePic = new FacePic(); FaceInfo faceInfo = new FaceInfo();
facePic.setFaceBinaryData(picBase64Data); faceInfo.setName(personEntity.getName());
faceReq.setFacePic(facePic); faceInfo.setSex(personEntity.getGender() == GenderEnum..getValue() ? "1" : "2");
faceReq.setFaceGroupIndexCode(faceGroup.getIndexCode()); faceInfo.setCertificateType("111");
Rest<FaceDataInfo> faceDataInfoRest = hikFaceService.faceSingleAdd(faceReq); faceInfo.setCertificateNum(personEntity.getIdCard());
if (faceDataInfoRest.getCode() == YesNoEnum.YES.getValue()) { faceReq.setFaceInfo(faceInfo);
//人脸添加成功,保存人脸组 FacePic facePic = new FacePic();
FaceGroupPersonEntity faceGroupPersonEntity = new FaceGroupPersonEntity(); facePic.setFaceBinaryData(picBase64Data);
faceGroupPersonEntity.initAttrValue(); faceReq.setFacePic(facePic);
faceGroupPersonEntity.setFaceGroupId(newFaceGroupEntity.getId()); faceReq.setFaceGroupIndexCode(faceGroup.getIndexCode());
faceGroupPersonEntity.setIndexCode(faceDataInfoRest.getData().getIndexCode()); Rest<FaceDataInfo> faceDataInfoRest = hikFaceService.faceSingleAdd(faceReq);
faceGroupPersonEntity.setCreateTime(new Date()); if (faceDataInfoRest.getCode() == YesNoEnum.YES.getValue()) {
faceGroupPersonEntity.setCreateUserId(1L); //人脸添加成功,保存人脸组
faceGroupPersonService.save(faceGroupPersonEntity); FaceGroupPersonEntity faceGroupPersonEntity = new FaceGroupPersonEntity();
} else { faceGroupPersonEntity.initAttrValue();
log.info("添加人脸异常=>{}", faceDataInfoRest.getMsg()); faceGroupPersonEntity.setFaceGroupId(faceGroup.getId());
} faceGroupPersonEntity.setIndexCode(faceDataInfoRest.getData().getIndexCode());
faceGroupPersonEntity.setCreateTime(new Date());
faceGroupPersonEntity.setCreateUserId(1L);
faceGroupPersonService.save(faceGroupPersonEntity);
} else { } else {
log.info("图片数据为空,filePath=>{}", filePath); log.info("添加人脸异常=>{}", faceDataInfoRest.getMsg());
} }
} else { } else {
log.info("人员图片photo为空,person=>{}", personEntity.getName()); 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.SUPER_BRAIN.getValue());
//设置识别资源
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());
planRecognBlackReq.setRecognitionResourceIndexCodes(recognitionResourceIndexCodes);
}
//设置时间段 默认全天候 @Override
AppointmentConfigEntity appointmentConfigEntity = appointmentConfigService.selectOne(new AppointmentConfigQuery()); public Rest<String> createAppointmentPlan() {
if (!ObjectUtils.isEmpty(appointmentConfigEntity)) { PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
List<AppointmentConfigTimesEntity> timesEntities = appointmentConfigTimesService.find(new AppointmentConfigTimesQuery().aotoCheckCfgId(appointmentConfigEntity.getId())); planRecognBlackListReq.setName(APPOINTMENT_PLAN);
if (!ObjectUtils.isEmpty(timesEntities)) { Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
List<TimeBlockListItem> timeBlockList = new ArrayList<>(); if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
if (ObjectUtils.isEmpty(planRecognBlackRest.getData())) {
TimeBlockListItem timeBlockListItem = new TimeBlockListItem(); //新建
//周一至周日 int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
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()) { PlanRecognReq planRecognBlackReq = new PlanRecognReq();
FacePlanEntity planEntity = new FacePlanEntity(); planRecognBlackReq.setName(Constant.APPOINTMENT_PLAN);
planEntity.initAttrValue(); planRecognBlackReq.setDescription(Constant.APPOINTMENT_PLAN_DESC);
planEntity.setIndexCode(planRecognBlackAddRest.getData()); planRecognBlackReq.setThreshold(threshold);
planEntity.setName(appointPlanName); //设置人脸分组
planEntity.setDescription(appointPlanName); FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(APPOINTMENT_GROUP));
planEntity.setCreateTime(new Date()); if (ObjectUtils.isEmpty(faceGroupEntity)) {
planEntity.setCreateUserId(1L); log.info("人脸组不存在!");
planEntity.setCreateUserName("admin"); return Rest.fail();
facePlanService.save(planEntity); }
} List<String> faceGroupIndexCodes = new ArrayList<>();
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
planRecognBlackReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).distinct().collect(Collectors.toList());
planRecognBlackReq.setCameraIndexCodes(cameraIndexCodes);
//设置识别方式
planRecognBlackReq.setRecognitionResourceType(RecognitionResourceEnum.SUPER_BRAIN.getValue());
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());
planRecognBlackReq.setRecognitionResourceIndexCodes(recognitionResourceIndexCodes);
}
Rest<String> planRecognBlackAddRest = hikPlanService.planRecognBlackAdd(planRecognBlackReq);
if (planRecognBlackAddRest.getCode() == YesNoEnum.YES.getValue()) {
FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue();
planEntity.setIndexCode(planRecognBlackAddRest.getData());
planEntity.setFaceGroupIndexCodes(faceGroupEntity.getIndexCode());
planEntity.setCameraIndexCodes(planRecognBlackReq.getCameraIndexCodes().stream().collect(Collectors.joining(",")));
planEntity.setRecognitionResourceIndexCodes(planRecognBlackReq.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(APPOINTMENT_PLAN);
planEntity.setDescription(APPOINTMENT_PLAN_DESC);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
} else { } else {
log.info("人员分组创建失败=>{}", rest.getMsg()); log.info("预约监控计划创建失败=>{}", planRecognBlackAddRest.getMsg());
} }
} else { } else {
log.info("当天人员分组以存在,人员分组名称=>{}", group); log.info("预约监控计划已经存在=>{}", JSON.toJSONString(planRecognBlackRest.getData()));
//判断状态 如果失败 则重新下发
} }
} else { } else {
log.info("当天无预约人员,不创建监控计划=>{}", DateUtils.getCurrStrDate()); log.info("预约查找计划异常=>{}", planRecognBlackRest.getMsg());
} }
return Rest.ok();
} }
} }
\ No newline at end of file
...@@ -111,16 +111,17 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe ...@@ -111,16 +111,17 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
@Override @Override
public Rest<Boolean> faceSingleDel(FaceReq faceReq) { public Rest<Boolean> faceSingleDel(FaceReq faceReq) {
ArtemisConfig config = getArtemisConfig(); ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/face/single/delete"; String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/deletion";
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
try { try {
log.info("face single delete req=>{}", JSON.toJSONString(faceReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() { HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
}); });
if (rest.getCode() == 0) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
} else { } else {
log.info("face single error resp=>{}", respJson); log.info("face single delete error resp=>{}", respJson);
return Rest.fail(rest.getMsg()); return Rest.fail(rest.getMsg());
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -136,9 +137,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe ...@@ -136,9 +137,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
try { try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<List<FaceGroupDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<FaceGroupDataInfo>>>() { HikApiRest<List<FaceGroupDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<FaceGroupDataInfo>>>() {
}); });
if (rest.getCode() == 0) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
} else { } else {
log.info("face group list error resp=>{}", respJson); log.info("face group list error resp=>{}", respJson);
...@@ -160,9 +161,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe ...@@ -160,9 +161,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
log.info("face single req=>{}", JSON.toJSONString(faceGroupReq)); log.info("face single req=>{}", JSON.toJSONString(faceGroupReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
log.info("face single resp=>{}", respJson); log.info("face single resp=>{}", respJson);
Rest<FaceGroupDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<FaceGroupDataInfo>>() { HikApiRest<FaceGroupDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<FaceGroupDataInfo>>() {
}); });
if (rest.getCode() == 0) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
} else { } else {
return Rest.fail(rest.getMsg()); return Rest.fail(rest.getMsg());
...@@ -180,9 +181,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe ...@@ -180,9 +181,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
try { try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() { HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
}); });
if (rest.getCode() == 0) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
} else { } else {
log.info("face single error resp=>{}", respJson); log.info("face single error resp=>{}", respJson);
...@@ -207,9 +208,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe ...@@ -207,9 +208,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
try { try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json");
Rest<List<ResRecognDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<ResRecognDataInfo>>>() { HikApiRest<List<ResRecognDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<ResRecognDataInfo>>>() {
}); });
if (rest.getCode() == 0) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
} else { } else {
log.info("face res list error resp=>{}", respJson); log.info("face res list error resp=>{}", respJson);
...@@ -250,9 +251,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe ...@@ -250,9 +251,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi); path.put(protocol, getCamsApi);
try { try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json");
Rest<List<ResourceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<ResourceDataInfo>>>() { HikApiRest<List<ResourceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<ResourceDataInfo>>>() {
}); });
if (rest.getCode() == 0) { if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData()); return Rest.ok(rest.getData());
} else { } else {
log.info("resource recognition list error resp=>{}", respJson); log.info("resource recognition list error resp=>{}", respJson);
......
package com.mortals.xhx.module.realtime.dao; package com.mortals.xhx.module.realtime.dao;
import com.mortals.framework.dao.ICRUDDao; import com.mortals.framework.dao.ICRUDDao;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity; import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatQuery;
import java.util.List; import java.util.List;
/** /**
* 人员流量统计Dao * 人员流量统计Dao
...@@ -13,5 +16,7 @@ import java.util.List; ...@@ -13,5 +16,7 @@ import java.util.List;
public interface RealtimeDataflowStatDao extends ICRUDDao<RealtimeDataflowStatEntity,Long>{ public interface RealtimeDataflowStatDao extends ICRUDDao<RealtimeDataflowStatEntity,Long>{
String SQLID_GET_STATLIST = "getStatList";
List<RealtimeDataflowStatEntity> getStatList(RealtimeDataflowStatQuery query, PageInfo pageInfo);
} }
package com.mortals.xhx.module.realtime.dao.ibatis; package com.mortals.xhx.module.realtime.dao.ibatis;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatQuery;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao; import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity; import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
...@@ -17,5 +21,14 @@ import java.util.List; ...@@ -17,5 +21,14 @@ import java.util.List;
public class RealtimeDataflowStatDaoImpl extends BaseCRUDDaoMybatis<RealtimeDataflowStatEntity,Long> implements RealtimeDataflowStatDao { public class RealtimeDataflowStatDaoImpl extends BaseCRUDDaoMybatis<RealtimeDataflowStatEntity,Long> implements RealtimeDataflowStatDao {
@Override
public List<RealtimeDataflowStatEntity> getStatList(RealtimeDataflowStatQuery query, PageInfo pageInfo) {
ParamDto queryParam = super.getQueryParam(query);
if (pageInfo.getPrePageResult() == -1) {
return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam);
} else {
RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam, rowBounds);
}
}
} }
...@@ -31,4 +31,6 @@ public class RealtimeDataflowStatVo extends BaseEntityLong { ...@@ -31,4 +31,6 @@ public class RealtimeDataflowStatVo extends BaseEntityLong {
private Integer recoginzeSum; private Integer recoginzeSum;
private Integer selected;
} }
\ No newline at end of file
package com.mortals.xhx.module.realtime.service; package com.mortals.xhx.module.realtime.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity; import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import java.util.List;
/** /**
* RealtimeDataflowStatService * RealtimeDataflowStatService
* * <p>
* 人员流量统计 service接口 * 人员流量统计 service接口
* *
* @author zxfei * @author zxfei
* @date 2023-04-19 * @date 2023-04-19
*/ */
public interface RealtimeDataflowStatService extends ICRUDService<RealtimeDataflowStatEntity,Long>{ public interface RealtimeDataflowStatService extends ICRUDService<RealtimeDataflowStatEntity, Long> {
List<RealtimeDataflowStatEntity> getBillInfos(Long siteId, Integer datePattern, PageInfo pageInfo, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.realtime.service.impl; package com.mortals.xhx.module.realtime.service.impl;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.code.DaySelectEnum;
import com.mortals.xhx.common.code.TimeUnitEnum;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatQuery;
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,95 @@ import com.mortals.framework.model.Context; ...@@ -6,14 +13,95 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao; import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity; import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import com.mortals.xhx.module.realtime.service.RealtimeDataflowStatService; import com.mortals.xhx.module.realtime.service.RealtimeDataflowStatService;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* RealtimeDataflowStatService * RealtimeDataflowStatService
* 人员流量统计 service实现 * 人员流量统计 service实现
* *
* @author zxfei * @author zxfei
* @date 2023-04-19 * @date 2023-04-19
*/ */
@Service("realtimeDataflowStatService") @Service("realtimeDataflowStatService")
public class RealtimeDataflowStatServiceImpl extends AbstractCRUDServiceImpl<RealtimeDataflowStatDao, RealtimeDataflowStatEntity, Long> implements RealtimeDataflowStatService { public class RealtimeDataflowStatServiceImpl extends AbstractCRUDServiceImpl<RealtimeDataflowStatDao, RealtimeDataflowStatEntity, Long> implements RealtimeDataflowStatService {
@Override
public Result<RealtimeDataflowStatEntity> find(RealtimeDataflowStatEntity query, PageInfo pageInfo, Context context) throws AppException {
Result<RealtimeDataflowStatEntity> statEntityResult = new Result<>();
if (!ObjectUtils.isEmpty(query.getSelected())) {
PageInfo page = new PageInfo();
List<RealtimeDataflowStatEntity> billInfos;
//转换日期
switch (DaySelectEnum.getByValue(query.getSelected())) {
case 今天:
page.setPrePageResult(1);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.DAY.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 近七天:
page.setPrePageResult(7);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.DAY.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 近三十天:
page.setPrePageResult(30);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.DAY.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 近三月:
page.setPrePageResult(3);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.MONTH.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 今年:
page.setPrePageResult(1);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.YEAR.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
default:
break;
}
return statEntityResult;
} else {
return super.find(query, pageInfo, context);
}
}
@Override
public List<RealtimeDataflowStatEntity> getBillInfos(Long siteId, Integer datePattern, PageInfo pageInfo, Context context) {
List<RealtimeDataflowStatEntity> statList;
RealtimeDataflowStatQuery query = new RealtimeDataflowStatQuery();
query.setSiteId(siteId);
if (datePattern == TimeUnitEnum.HOUR.getValue()) {
query.setGroupList(Arrays.asList("hour"));
query.setOrderColList(Arrays.asList(new OrderCol("hour", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.DAY.getValue()) {
query.setGroupList(Arrays.asList("day"));
query.setOrderColList(Arrays.asList(new OrderCol("day", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.MONTH.getValue()) {
query.setGroupList(Arrays.asList("month"));
query.setOrderColList(Arrays.asList(new OrderCol("month", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.YEAR.getValue()) {
query.setGroupList(Arrays.asList("year"));
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else {
throw new AppException("不支持当前日期格式查询统计!");
}
return statList;
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.realtime.dao.ibatis.RealtimeDataflowStatDaoImpl">
<!-- 获取统计列表 -->
<select id="getStatList" parameterType="paramDto" resultMap="RealtimeDataflowStatEntity-Map">
select
<!-- 获取分组字段 -->
<if test="groupList != null and !groupList.isEmpty()">
<foreach collection="groupList" open="" close="" index="index" item="item">
${item},
</foreach>
</if>
id,
siteId,
siteName,
createTime,
year,
month,
day,
hour,
sum(IFNULL(a.personSum, 0)) personSum,
sum(IFNULL(a.strangerSum, 0)) strangerSum,
sum(IFNULL(a.recoginzeSum,0)) recoginzeSum
from mortals_xhx_realtime_dataflow_stat as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
<include refid="_group_by_"/>
<include refid="_orderCols_"/>
</select>
</mapper>
\ No newline at end of file
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