Commit 967b62eb authored by 赵啸非's avatar 赵啸非

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

parent 573ac88b
...@@ -51,7 +51,23 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -51,7 +51,23 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
statPeople(); statPeople();
// donwnloadSnap(); delFiles();
}
private void delFiles() {
//保留七天人脸数据
String endTimeStr = DateUtil.offsetDay(new Date(), -7).toDateStr();
RealtimeDataflowQuery realtimeDataflowQuery = new RealtimeDataflowQuery();
realtimeDataflowQuery.setCreateTimeEnd(endTimeStr);
List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null);
Long[] delIds = realtimeDataflowEntities.stream().map(i -> i.getId()).toArray(Long[]::new);
realtimeDataflowStatService.remove(delIds, null);
for (RealtimeDataflowEntity entity : realtimeDataflowEntities) {
if (ObjectUtils.isEmpty(entity.getPicture())) continue;
uploadService.deleteFile(entity.getPicture());
}
} }
private void statPeople() { private void statPeople() {
...@@ -71,7 +87,7 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -71,7 +87,7 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
Long recognizeCount = total - strangerCount; Long recognizeCount = total - strangerCount;
Date date = new Date(); Date date = new Date();
int year = DateUtil.year(date); int year = DateUtil.year(date);
int month = DateUtil.month(date)+1; int month = DateUtil.month(date) + 1;
int day = DateUtil.dayOfMonth(date); int day = DateUtil.dayOfMonth(date);
int hour = DateUtil.hour(date, true); int hour = DateUtil.hour(date, true);
...@@ -107,7 +123,6 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -107,7 +123,6 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
} }
@Override @Override
public void stopTask(ITask task) throws AppException { public void stopTask(ITask task) throws AppException {
......
...@@ -103,24 +103,7 @@ public class BlackPlanRecoginze extends EventTypeAbstract { ...@@ -103,24 +103,7 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
continue; continue;
} }
//保存人流信息 //保存人流信息
RealtimeDataflowEntity realtimeDataflowEntity = new RealtimeDataflowEntity(); savedataFlow(event, eventData, snap, personCache);
realtimeDataflowEntity.setDetectTime(event.getHappenTime());
String resIndexCodes = eventData.getResInfo().stream().map(i -> i.getIndexCode()).collect(Collectors.joining(","));
realtimeDataflowEntity.setDevice(resIndexCodes);
realtimeDataflowEntity.setPicUri(snap.getFaceUrl());
realtimeDataflowEntity.setEventId(event.getEventId());
realtimeDataflowEntity.setSiteId(personCache.getSiteId());
realtimeDataflowEntity.setSiteName(personCache.getSiteName());
realtimeDataflowEntity.setIdNumber(personCache.getIdCard());
realtimeDataflowEntity.setName(personCache.getName());
realtimeDataflowEntity.setIsBooking(YesNoEnum.YES.getValue());
realtimeDataflowEntity.setContact(personCache.getPhoto());
realtimeDataflowEntity.setEventType(HikEventTypeEnum.重点人员识别事件.getValue().longValue());
realtimeDataflowEntity.setCreateUserId(1L);
realtimeDataflowEntity.setCreateTime(new Date());
realtimeDataflowEntity.setCreateUserName("system");
realtimeDataflowEntity.initAttrValue();
dataflowService.save(realtimeDataflowEntity);
//查询当前是否为当天预约人员 //查询当前是否为当天预约人员
AppointmentPersonQuery appointmentPersonQuery = new AppointmentPersonQuery(); AppointmentPersonQuery appointmentPersonQuery = new AppointmentPersonQuery();
...@@ -216,4 +199,25 @@ public class BlackPlanRecoginze extends EventTypeAbstract { ...@@ -216,4 +199,25 @@ 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(","));
realtimeDataflowEntity.setDevice(resIndexCodes);
realtimeDataflowEntity.setPicUri(snap.getFaceUrl());
realtimeDataflowEntity.setEventId(event.getEventId());
realtimeDataflowEntity.setSiteId(personCache.getSiteId());
realtimeDataflowEntity.setSiteName(personCache.getSiteName());
realtimeDataflowEntity.setIdNumber(personCache.getIdCard());
realtimeDataflowEntity.setName(personCache.getName());
realtimeDataflowEntity.setIsBooking(YesNoEnum.YES.getValue());
realtimeDataflowEntity.setContact(personCache.getPhoto());
realtimeDataflowEntity.setEventType(HikEventTypeEnum.重点人员识别事件.getValue().longValue());
realtimeDataflowEntity.setCreateUserId(1L);
realtimeDataflowEntity.setCreateTime(new Date());
realtimeDataflowEntity.setCreateUserName("system");
realtimeDataflowEntity.initAttrValue();
dataflowService.save(realtimeDataflowEntity);
}
} }
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