You've already forked FrameTour-BE
指定设备提前预约
This commit is contained in:
@@ -4,10 +4,14 @@ 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.ScenicMapper;
|
||||
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.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
@@ -20,6 +24,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,31 +43,71 @@ public class VideoTaskGenerator {
|
||||
private TaskTaskServiceImpl taskTaskService;
|
||||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
@Autowired
|
||||
private ScenicMapper scenicMapper;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
|
||||
// TODO: 可配置,现在赶时间暂时写死
|
||||
|
||||
@Scheduled(cron = "0 0 18 * * *")
|
||||
@Scheduled(cron = "0 0 * * * *")
|
||||
public void generateVideoTask() {
|
||||
// 指定,获取指定日期的未完成人脸样本,并生成任务
|
||||
Long scenicId = 3946669713328836608L;
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(scenicId);
|
||||
if (contentList.isEmpty()) {
|
||||
List<ScenicRespVO> scenicList = scenicMapper.list(new ScenicReqQuery());
|
||||
if (scenicList.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) {
|
||||
log.info("task callback: 自动生成");
|
||||
taskTaskService.forceCreateTaskByFaceIdAndTempalteId(face.getId(), templateId);
|
||||
} else {
|
||||
log.info("task callback: 不自动生成");
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
calendar.clear();
|
||||
scenicList.parallelStream().forEach(scenic -> {
|
||||
Long scenicId = scenic.getId();
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenicId);
|
||||
if (scenicConfig == null) {
|
||||
log.info("当前景区{},无配置信息", scenic.getName());
|
||||
return;
|
||||
}
|
||||
if (Integer.valueOf(1).equals(scenicConfig.getBookRoutine()) || Integer.valueOf(3).equals(scenicConfig.getBookRoutine())) {
|
||||
Integer hour = scenicConfig.getForceFinishTime();
|
||||
if (hour != currentHour) {
|
||||
return;
|
||||
}
|
||||
// 定时逻辑
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(scenicId);
|
||||
if (contentList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
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());
|
||||
if (Integer.valueOf(3).equals(scenicConfig.getBookRoutine())) {
|
||||
// 全部生成
|
||||
contentList.forEach(content -> {
|
||||
Long templateId = content.getTemplateId();
|
||||
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
||||
if (canAutoGenerate) {
|
||||
log.info("task callback: 自动生成");
|
||||
taskTaskService.forceCreateTaskByFaceIdAndTempalteId(face.getId(), templateId);
|
||||
} else {
|
||||
log.info("task callback: 不自动生成");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Long templateId = contentList.get(0).getTemplateId();
|
||||
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
||||
if (canAutoGenerate) {
|
||||
log.info("task callback: 自动生成");
|
||||
taskTaskService.forceCreateTaskByFaceIdAndTempalteId(face.getId(), templateId);
|
||||
} else {
|
||||
log.info("task callback: 不自动生成");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user