87 lines
3.4 KiB
Java
87 lines
3.4 KiB
Java
package com.ycwl.basic.task;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import com.ycwl.basic.biz.TemplateBiz;
|
|
import com.ycwl.basic.mapper.FaceMapper;
|
|
import com.ycwl.basic.mapper.FaceSampleMapper;
|
|
import com.ycwl.basic.mapper.TemplateMapper;
|
|
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
|
import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
|
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
|
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
|
import com.ycwl.basic.repository.ScenicRepository;
|
|
import com.ycwl.basic.repository.TemplateRepository;
|
|
import com.ycwl.basic.service.task.TaskFaceService;
|
|
import com.ycwl.basic.service.task.impl.TaskTaskServiceImpl;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
@EnableScheduling
|
|
@Component
|
|
public class VideoTaskGenerator {
|
|
@Autowired
|
|
private FaceMapper faceMapper;
|
|
@Autowired
|
|
private TaskFaceService taskFaceService;
|
|
@Autowired
|
|
private TemplateBiz templateBiz;
|
|
@Autowired
|
|
private TaskTaskServiceImpl taskTaskService;
|
|
@Autowired
|
|
private TemplateMapper templateMapper;
|
|
|
|
// TODO: 可配置,现在赶时间暂时写死
|
|
|
|
@Scheduled(cron = "0 0 18 * * *")
|
|
public void generateVideoTask() {
|
|
// 指定,获取指定日期的未完成人脸样本,并生成任务
|
|
Long scenicId = 3946669713328836608L;
|
|
List<ContentPageVO> contentList = templateMapper.listFor(scenicId);
|
|
if (contentList.isEmpty()) {
|
|
return;
|
|
}
|
|
Long templateId = contentList.get(0).getTemplateId();
|
|
FaceReqQuery query = new FaceReqQuery();
|
|
query.setScenicId(scenicId);
|
|
query.setStartTime(DateUtil.beginOfDay(new Date()));
|
|
query.setEndTime(DateUtil.endOfDay(new Date()));
|
|
List<FaceRespVO> list = faceMapper.list(query);
|
|
list.stream().parallel().forEach(face -> {
|
|
taskFaceService.searchFace(face.getId());
|
|
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
|
if (canAutoGenerate) {
|
|
taskTaskService.autoCreateTaskByFaceId(face.getId());
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 30 4 * * *")
|
|
public void generateVideoTaskZTJQ() {
|
|
// 指定,获取指定日期的未完成人脸样本,并生成任务
|
|
Long scenicId = 3930324797233434624L;
|
|
List<ContentPageVO> contentList = templateMapper.listFor(scenicId);
|
|
if (contentList.isEmpty()) {
|
|
return;
|
|
}
|
|
Long templateId = contentList.get(0).getTemplateId();
|
|
FaceReqQuery query = new FaceReqQuery();
|
|
query.setScenicId(scenicId);
|
|
query.setStartTime(DateUtil.beginOfDay(new Date()));
|
|
query.setEndTime(DateUtil.endOfDay(new Date()));
|
|
List<FaceRespVO> list = faceMapper.list(query);
|
|
list.stream().parallel().forEach(face -> {
|
|
taskFaceService.searchFace(face.getId());
|
|
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
|
if (canAutoGenerate) {
|
|
taskTaskService.autoCreateTaskByFaceId(face.getId());
|
|
}
|
|
});
|
|
}
|
|
}
|