3
This commit is contained in:
parent
348a3801df
commit
6907615658
@ -72,6 +72,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@ -111,6 +112,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
private VideoRepository videoRepository;
|
||||
@Autowired
|
||||
private OrderRepository orderRepository;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
|
||||
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
||||
String accessKey = req.getAccessKey();
|
||||
@ -166,6 +169,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
} else {
|
||||
updTemplateList = templateRepository.getAllEnabledTemplateList();
|
||||
}
|
||||
try {
|
||||
if (lock.tryLock(2, TimeUnit.SECONDS)) {
|
||||
List<TaskRespVO> taskList = taskMapper.selectNotRunning();
|
||||
resp.setTasks(taskList);
|
||||
resp.setTemplates(updTemplateList);
|
||||
@ -173,6 +178,9 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
taskMapper.assignToWorker(task.getId(), worker.getId());
|
||||
videoTaskRepository.clearTaskCache(task.getId());
|
||||
});
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
// return Task
|
||||
return resp;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
@ -28,21 +29,47 @@ public class VideoTaskGenerator {
|
||||
@Autowired
|
||||
private TaskFaceService taskFaceService;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
@Autowired
|
||||
private TemplateBiz templateBiz;
|
||||
@Autowired
|
||||
private FaceSampleMapper faceSampleMapper;
|
||||
@Autowired
|
||||
private TaskTaskServiceImpl taskTaskService;
|
||||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
|
||||
// TODO: 可配置,现在赶时间暂时写死
|
||||
|
||||
@Scheduled(cron = "0 0 18 * * *")
|
||||
public void generateVideoTask() {
|
||||
// 指定,获取指定日期的未完成人脸样本,并生成任务
|
||||
Long scenicId = 3946669713328836608L;
|
||||
Long templateId = 3947461229940969472L;
|
||||
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()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user