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

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

parent 967b62eb
...@@ -43,8 +43,6 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -43,8 +43,6 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private RealtimeDataflowStatService realtimeDataflowStatService; private RealtimeDataflowStatService realtimeDataflowStatService;
@Autowired @Autowired
private IHikFaceService faceService;
@Autowired
private UploadService uploadService; private UploadService uploadService;
...@@ -56,16 +54,20 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService { ...@@ -56,16 +54,20 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
private void delFiles() { private void delFiles() {
//保留七天人脸数据 //保留七天人脸数据
log.info("定时删除人流数据");
String endTimeStr = DateUtil.offsetDay(new Date(), -7).toDateStr(); String endTimeStr = DateUtil.offsetDay(new Date(), -7).toDateStr();
RealtimeDataflowQuery realtimeDataflowQuery = new RealtimeDataflowQuery(); RealtimeDataflowQuery realtimeDataflowQuery = new RealtimeDataflowQuery();
realtimeDataflowQuery.setCreateTimeEnd(endTimeStr); realtimeDataflowQuery.setCreateTimeEnd(endTimeStr);
List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null); List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null);
Long[] delIds = realtimeDataflowEntities.stream().map(i -> i.getId()).toArray(Long[]::new); if (ObjectUtils.isEmpty(realtimeDataflowEntities)) {
realtimeDataflowStatService.remove(delIds, null); log.info("需要删除的实时监控数据量:{}", realtimeDataflowEntities.size());
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());
}
for (RealtimeDataflowEntity entity : realtimeDataflowEntities) {
if (ObjectUtils.isEmpty(entity.getPicture())) continue;
uploadService.deleteFile(entity.getPicture());
} }
} }
......
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