Commit 274581b3 authored by 赵啸非's avatar 赵啸非

添加定时删除七天前的人流数据

parent 08e65041
......@@ -54,11 +54,11 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
private void delFiles() {
//保留七天人脸数据
log.info("定时删除人流数据");
String endTimeStr = DateUtil.offsetDay(new Date(), -7).toDateStr();
RealtimeDataflowQuery realtimeDataflowQuery = new RealtimeDataflowQuery();
realtimeDataflowQuery.setCreateTimeEnd(endTimeStr);
List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null);
log.info("定时删除人流数据,endTimeStr:{},size:{}", endTimeStr, realtimeDataflowEntities.size());
if (ObjectUtils.isEmpty(realtimeDataflowEntities)) {
log.info("需要删除的实时监控数据量:{}", realtimeDataflowEntities.size());
Long[] delIds = realtimeDataflowEntities.stream().map(i -> i.getId()).toArray(Long[]::new);
......
package com.mortals.xhx.module.hik.event.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.CheckInMethodEnum;
import com.mortals.xhx.common.code.HikEventTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
......@@ -20,6 +25,8 @@ import com.mortals.xhx.module.hik.event.model.req.callback.recognition.EventData
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.FaceMatchItem;
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.FaceRecognitionResult;
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.Snap;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.monitor.model.MonitorAlarmEntity;
import com.mortals.xhx.module.monitor.model.MonitorAlarmQuery;
import com.mortals.xhx.module.monitor.model.MonitorAlarmRecordEntity;
......@@ -32,7 +39,10 @@ import com.mortals.xhx.module.realtime.service.RealtimeDataflowService;
import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -59,6 +69,10 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
private MonitorAlarmRecordService monitorAlarmRecordService;
private IHikFaceService faceService;
private UploadService uploadService;
public BlackPlanRecoginze(int type) {
super(type);
......@@ -68,6 +82,8 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
this.appointmentPersonService = SpringUtils.getBean(AppointmentPersonService.class);
this.monitorAlarmService = SpringUtils.getBean(MonitorAlarmService.class);
this.monitorAlarmRecordService = SpringUtils.getBean(MonitorAlarmRecordService.class);
this.faceService = SpringUtils.getBean(IHikFaceService.class);
this.uploadService = SpringUtils.getBean(UploadService.class);
}
@Override
......@@ -201,6 +217,8 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
}
private void savedataFlow(EventsItem event, EventData eventData, Snap snap, PersonEntity personCache) {
RealtimeDataflowEntity realtimeDataflowEntity = new RealtimeDataflowEntity();
realtimeDataflowEntity.setDetectTime(event.getHappenTime());
String resIndexCodes = eventData.getResInfo().stream().map(i -> i.getIndexCode()).collect(Collectors.joining(","));
......@@ -217,7 +235,22 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
realtimeDataflowEntity.setCreateUserId(1L);
realtimeDataflowEntity.setCreateTime(new Date());
realtimeDataflowEntity.setCreateUserName("system");
realtimeDataflowEntity.initAttrValue();
ImgReq imgReq = new ImgReq();
imgReq.setUrl(realtimeDataflowEntity.getPicUri());
Rest<String> rest = faceService.downloadPicture(imgReq);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
byte[] bytes = Base64.decode(rest.getData());
if (!org.springframework.util.ObjectUtils.isEmpty(bytes)) {
InputStream inputStream = new ByteArrayInputStream(bytes);
MultipartFile file = ServletUtils.getMultipartFile(inputStream, "snap.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload/snap/" + DateUtil.today(), null);
realtimeDataflowEntity.setPicture(filePath);
}
}
dataflowService.save(realtimeDataflowEntity);
}
}
......@@ -18,7 +18,7 @@
</plugin>
<plugin interceptor="com.mortals.framework.thirty.mybatis.LogInterceptor">
<property name="enableExecutorTime" value="true" />
<property name="showSql" value="false" />
<property name="showSql" value="true" />
</plugin>
</plugins>
</configuration>
\ 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