This commit is contained in:
2025-01-22 14:23:00 +08:00
parent f670fb2f91
commit 38c4b553bc
17 changed files with 178 additions and 131 deletions

View File

@ -64,75 +64,6 @@ public class DynamicTaskGenerator {
@Autowired
private FaceRepository faceRepository;
@Scheduled(cron = "0 0 * * * ?")
public void dynamicTask() {
List<ScenicRespVO> scenicList = scenicMapper.list(new ScenicReqQuery());
for (ScenicRespVO scenic : scenicList) {
log.info("定时任务执行,当前景区:{}", scenic.getName());
ScenicConfigEntity scenicConfig = scenicMapper.getConfig(scenic.getId());
if (scenicConfig == null || Integer.valueOf(2).equals(scenicConfig.getBookRoutine())) {
log.info("当前景区{},未启用提前预约流程", scenic.getName());
continue;
}
log.info("当前景区{},启用了提前预约流程", scenic.getName());
TemplateReqQuery templateQuery = new TemplateReqQuery();
templateQuery.setScenicId(scenic.getId());
List<TemplateRespVO> templateList = templateMapper.list(templateQuery);
for (TemplateRespVO template : templateList) {
log.info("当前景区{},启用了提前预约流程,模板:{}", scenic.getName(), template.getName());
if (template.getStatus() == 0) {
log.info("当前模板{}未启用,跳过", template.getName());
continue;
}
TemplateConfigEntity templateConfig = templateMapper.getConfig(template.getId());
if (templateConfig == null) {
log.info("当前模板{}未配置,跳过", template.getName());
continue;
}
if (templateConfig.getIsDefault() == 0) {
if (scenicConfig.getBookRoutine() == 1) {
log.info("当前模板{}未启用默认,且景区启用预约流程,跳过", template.getName());
continue;
}
}
// 查找人脸样本
List<FaceRespVO> list = faceMapper.listByScenicIdAndNotFinished(scenic.getId());
for (FaceRespVO face : list) {
log.info("当前模板{}启用默认,人脸样本:{}", template.getName(), face.getFaceUrl());
if (((new Date()).getTime() - face.getCreateAt().getTime()) > scenicConfig.getMaxJourneyHour() * 3600 * 1000) {
log.info("当前人脸样本{}已超过最大游玩{}小时,自动检测人脸", face.getFaceUrl(), scenicConfig.getMaxJourneyHour());
List<String> oldMatchedSampleListIds = new ArrayList<>();
if (face.getMatchSampleIds() != null) {
oldMatchedSampleListIds = Arrays.asList(face.getMatchSampleIds().split(","));
}
SearchFaceRespVo searchFace = faceService.searchFace(face.getId());
if (oldMatchedSampleListIds.size() == searchFace.getSampleListIds().size()) {
boolean isEqual = true;
for (Long sampleId : searchFace.getSampleListIds()) {
if (!oldMatchedSampleListIds.contains(sampleId.toString())) {
isEqual = false;
break;
}
}
if (isEqual) {
log.info("当前人脸样本{}已超过最大游玩{}小时,但人脸检测结果与上次相同,跳过", face.getFaceUrl(), scenicConfig.getMaxJourneyHour());
continue;
}
}
if (templateBiz.determineTemplateCanGenerate(template.getId(), face.getId())) {
log.info("当前人脸样本{}已超过最小占位素材,自动创建任务", face.getFaceUrl());
taskService.createRenderTask(scenic.getId(), template.getId(), face.getId());
faceMapper.finishedJourney(face.getId());
} else {
log.info("当前人脸样本{}未超过最小占位素材,未达到自动生成条件", face.getFaceUrl());
}
}
}
}
}
}
@Data
@AllArgsConstructor
public static class Task implements Delayed {