You've already forked FrameTour-BE
bug修复
This commit is contained in:
@ -96,26 +96,26 @@ public class DynamicTaskGenerator {
|
||||
if (task == null) {
|
||||
return;
|
||||
}
|
||||
log.info("开始执行任务:{}", task);
|
||||
// 根据人脸照片获取人脸样本ID
|
||||
FaceSampleRespVO faceSample = faceSampleMapper.getById(task.getFaceSampleId());
|
||||
if (faceSample == null) {
|
||||
log.info("人脸样本ID{}不存在", task.getFaceSampleId());
|
||||
log.debug("人脸样本ID{}不存在", task.getFaceSampleId());
|
||||
return;
|
||||
}
|
||||
if (faceSample.getScore() == null) {
|
||||
log.info("人脸样本ID{}人脸质量为空", task.getFaceSampleId());
|
||||
log.debug("人脸样本ID{}人脸质量为空", task.getFaceSampleId());
|
||||
return;
|
||||
}
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(faceSample.getScenicId());
|
||||
if (scenicConfig == null) {
|
||||
log.info("当前景区{},无配置", faceSample.getScenicId());
|
||||
log.debug("当前景区{},无配置", faceSample.getScenicId());
|
||||
return;
|
||||
}
|
||||
if (!Integer.valueOf(1).equals(scenicConfig.getBookRoutine()) && !Integer.valueOf(3).equals(scenicConfig.getBookRoutine())) {
|
||||
log.info("当前景区{}未启用预约流程,跳过", faceSample.getScenicId());
|
||||
log.debug("当前景区{}未启用预约流程,跳过", faceSample.getScenicId());
|
||||
return;
|
||||
}
|
||||
log.info("开始执行任务:{}", task);
|
||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME+faceSample.getScenicId(), faceSample.getFaceUrl());
|
||||
// 如果人脸样本ID在人脸样本库中,则创建任务
|
||||
if (!userDbSearchResult.getSampleListIds().isEmpty()) {
|
||||
|
@ -1,9 +1,16 @@
|
||||
package com.ycwl.basic.task;
|
||||
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.ScenicMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.model.pc.faceSample.req.FaceSampleReqQuery;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.service.task.TaskFaceService;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||
import com.ycwl.basic.storage.entity.StorageFileObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@ -20,7 +27,10 @@ public class FaceCleaner {
|
||||
private ScenicMapper scenicMapper;
|
||||
@Autowired
|
||||
private TaskFaceService faceService;
|
||||
|
||||
@Autowired
|
||||
private FaceSampleMapper faceSampleMapper;
|
||||
@Autowired
|
||||
private SourceMapper sourceMapper;
|
||||
|
||||
@Scheduled(cron = "0 0 4 * * ?")
|
||||
public void clean(){
|
||||
@ -31,4 +41,23 @@ public class FaceCleaner {
|
||||
faceService.batchDeleteExpiredFace(scenic.getId());
|
||||
});
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void deleteExpiredSource(){
|
||||
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 5 * * ?")
|
||||
public void clear(){
|
||||
log.info("开始清理人脸文件");
|
||||
List<FaceSampleRespVO> faceSampleRespVOS = faceSampleMapper.list(new FaceSampleReqQuery());
|
||||
IStorageAdapter adapter = StorageFactory.use("faces");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir("user-face");
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if(faceSampleRespVOS.parallelStream().noneMatch(faceSampleRespVO -> faceSampleRespVO.getFaceUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除人脸文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ 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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -21,8 +23,10 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@EnableScheduling
|
||||
@Component
|
||||
@Profile("prod")
|
||||
public class VideoTaskGenerator {
|
||||
@Autowired
|
||||
private FaceMapper faceMapper;
|
||||
@ -55,31 +59,10 @@ public class VideoTaskGenerator {
|
||||
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());
|
||||
log.info("task callback: 自动生成");
|
||||
taskTaskService.forceCreateTaskByFaceIdAndTempalteId(face.getId(), templateId);
|
||||
} else {
|
||||
log.info("task callback: 不自动生成");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user