逻辑调整
This commit is contained in:
parent
958dc05836
commit
255ea42f81
@ -25,8 +25,6 @@ public class AppTaskController {
|
||||
private GoodsService goodsService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private TaskStatusBiz taskStatusBiz;
|
||||
|
||||
@GetMapping("/face/{faceId}")
|
||||
@IgnoreLogReq
|
||||
|
@ -4,7 +4,11 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VideoTaskStatusVO {
|
||||
/**
|
||||
* 0:未开始合成 2:合成中 1:合成成功 3:合成失败 4切片中
|
||||
*/
|
||||
private int status;
|
||||
private int cutStatus;
|
||||
private Long taskId;
|
||||
private Long videoId;
|
||||
private Long templateId;
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@ -33,7 +34,7 @@ public class FaceRepository {
|
||||
}
|
||||
FaceEntity face = faceMapper.get(id);
|
||||
if (face != null) {
|
||||
redisTemplate.opsForValue().set(String.format(FACE_CACHE_KEY, id), JSONObject.toJSONString(face));
|
||||
redisTemplate.opsForValue().set(String.format(FACE_CACHE_KEY, id), JSONObject.toJSONString(face), 60 * 60 * 24L, TimeUnit.SECONDS);
|
||||
}
|
||||
return face;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class VideoTaskRepository {
|
||||
@Autowired
|
||||
@ -23,7 +25,7 @@ public class VideoTaskRepository {
|
||||
} else {
|
||||
TaskEntity task = taskMapper.get(taskId);
|
||||
if (task != null && 1 == task.getStatus()) {
|
||||
redisTemplate.opsForValue().set(String.format(TASK_CACHE_KEY, taskId), JSONObject.toJSONString(task));
|
||||
redisTemplate.opsForValue().set(String.format(TASK_CACHE_KEY, taskId), JSONObject.toJSONString(task), 60 * 60 * 24L, TimeUnit.SECONDS);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.ycwl.basic.service.impl.mobile;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.mapper.*;
|
||||
import com.ycwl.basic.model.mobile.goods.*;
|
||||
@ -66,6 +67,8 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
private OrderBiz orderBiz;
|
||||
@Autowired
|
||||
private FaceRepository faceRepository;
|
||||
@Autowired
|
||||
private TaskStatusBiz taskStatusBiz;
|
||||
|
||||
public ApiResponse<List<GoodsPageVO>> goodsList(GoodsReqQuery query) {
|
||||
//查询原素材
|
||||
@ -256,7 +259,6 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
@Override
|
||||
public VideoTaskStatusVO getTaskStatusByFaceId(Long userId, Long faceId) {
|
||||
FaceEntity face = faceRepository.getFace(faceId);
|
||||
List<MemberVideoEntity> taskList = videoMapper.listRelationByFace(userId, faceId);
|
||||
VideoTaskStatusVO response = new VideoTaskStatusVO();
|
||||
response.setFaceId(faceId);
|
||||
if (face == null) {
|
||||
@ -264,6 +266,19 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
return response;
|
||||
}
|
||||
response.setScenicId(face.getScenicId());
|
||||
int faceCutStatus = taskStatusBiz.getFaceCutStatus(faceId);
|
||||
response.setCutStatus(faceCutStatus);
|
||||
if (faceCutStatus == 0) {
|
||||
// 切视频中,也显示正在处理
|
||||
response.setStatus(2);
|
||||
return response;
|
||||
}
|
||||
List<MemberVideoEntity> taskList = videoMapper.listRelationByFace(userId, faceId);
|
||||
if (faceCutStatus != 1 && taskList.isEmpty()) {
|
||||
// 视频切成了能够获取视频的状态,但是没有任务,还是显示正在处理
|
||||
response.setStatus(0);
|
||||
return response;
|
||||
}
|
||||
if (taskList.isEmpty()) {
|
||||
response.setStatus(0);
|
||||
return response;
|
||||
|
@ -26,7 +26,6 @@ import com.ycwl.basic.service.task.TaskService;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||
import com.ycwl.basic.storage.utils.StorageUtil;
|
||||
import com.ycwl.basic.task.VideoPieceGetter;
|
||||
import com.ycwl.basic.utils.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -188,7 +187,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
FaceRecognizeResp resp = new FaceRecognizeResp();
|
||||
resp.setUrl(faceUrl);
|
||||
resp.setFaceId(newFaceId);
|
||||
matchFaceId(newFaceId);
|
||||
matchFaceId(newFaceId, oldFaceId == null);
|
||||
return ApiResponse.success(resp);
|
||||
}
|
||||
|
||||
@ -197,8 +196,14 @@ public class FaceServiceImpl implements FaceService {
|
||||
return faceMapper.listByScenicAndUserId(scenicId, userId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SearchFaceRespVo matchFaceId(Long faceId) {
|
||||
return matchFaceId(faceId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchFaceRespVo matchFaceId(Long faceId, boolean isNew) {
|
||||
FaceEntity face = faceRepository.getFace(faceId);
|
||||
if (face == null) {
|
||||
return null;
|
||||
|
@ -27,4 +27,5 @@ public interface FaceService {
|
||||
List<FaceRespVO> listByUser(Long userId, String scenicId);
|
||||
SearchFaceRespVo matchFaceId(Long faceId);
|
||||
|
||||
SearchFaceRespVo matchFaceId(Long faceId, boolean isNew);
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
package com.ycwl.basic.service.task;
|
||||
|
||||
public interface TaskTemplateService {
|
||||
}
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.biz.TemplateBiz;
|
||||
import com.ycwl.basic.constant.TaskConstant;
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
@ -109,6 +110,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
@Autowired
|
||||
private OrderRepository orderRepository;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
@Autowired
|
||||
private TaskStatusBiz taskStatusBiz;
|
||||
|
||||
|
||||
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
||||
@ -370,6 +373,12 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (faceSampleList.isEmpty()) {
|
||||
log.info("faceId:{} sample list not exist", faceId);
|
||||
}
|
||||
if (automatic == 1) {
|
||||
if (templateBiz.determineTemplateCanGenerate(templateId, faceId, false)) {
|
||||
// 临时写死,当自动生成视频,切片也算合成中,并更新状态
|
||||
taskStatusBiz.setFaceCutStatus(face.getId(), 0);
|
||||
}
|
||||
}
|
||||
List<Long> faceSampleIds = faceSampleList.stream().map(FaceSampleEntity::getId).collect(Collectors.toList());
|
||||
List<SourceEntity> sourceList = sourceMapper.listVideoByScenicFaceRelation(face.getScenicId(), faceId);
|
||||
// ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(face.getScenicId());
|
||||
@ -493,6 +502,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
}
|
||||
}
|
||||
videoMapper.addRelation(memberVideoEntity);
|
||||
// 任务生成了,需要更新切割任务状态
|
||||
taskStatusBiz.setFaceCutStatus(faceId, 2);
|
||||
};
|
||||
if (faceSampleIds.isEmpty()) {
|
||||
// 没有人脸样本
|
||||
|
@ -1,31 +0,0 @@
|
||||
package com.ycwl.basic.service.task.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ycwl.basic.mapper.TemplateMapper;
|
||||
import com.ycwl.basic.model.pc.template.entity.TemplateConfigEntity;
|
||||
import com.ycwl.basic.service.task.TaskTemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TaskTemplateServiceImpl implements TaskTemplateService {
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
|
||||
private static final String TEMPLATE_KEY = "template:";
|
||||
private static final String TEMPLATE_CONFIG_KEY = "template:config:";
|
||||
|
||||
private TemplateConfigEntity getTemplateConfig(Long templateId) {
|
||||
if (redisTemplate.hasKey(TEMPLATE_CONFIG_KEY + templateId)) {
|
||||
return JSON.parseObject(redisTemplate.opsForValue().get(TEMPLATE_CONFIG_KEY + templateId), TemplateConfigEntity.class);
|
||||
}
|
||||
TemplateConfigEntity config = templateMapper.getConfig(templateId);
|
||||
if (config != null) {
|
||||
redisTemplate.opsForValue().set(TEMPLATE_CONFIG_KEY + templateId, JSON.toJSONString(config));
|
||||
}
|
||||
return config;
|
||||
}
|
||||
}
|
@ -97,9 +97,10 @@ public class VideoPieceGetter {
|
||||
} else {
|
||||
templatePlaceholder = null;
|
||||
}
|
||||
if (task.faceId != null) {
|
||||
taskStatusBiz.setFaceCutStatus(task.faceId, 0);
|
||||
}
|
||||
// 临时处理,只有逻辑层自己设置是否正在切片后再做更新
|
||||
// if (task.faceId != null) {
|
||||
// taskStatusBiz.setFaceCutStatus(task.faceId, 0);
|
||||
// }
|
||||
AtomicBoolean invoke = new AtomicBoolean(false);
|
||||
List<String> currentPlaceholder = new ArrayList<>();
|
||||
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
|
||||
|
@ -113,10 +113,6 @@ YfkdFNxtYLdVAwuylMoV3fKI
|
||||
# 商户APIV3密钥
|
||||
apiV3: ZHENTUAIzhentuaiZHENTUAIzhentuai
|
||||
|
||||
# 人脸合格得分
|
||||
face:
|
||||
score: 80
|
||||
|
||||
# 存储
|
||||
storage:
|
||||
defaultUse: "assets"
|
||||
|
@ -113,10 +113,6 @@ YfkdFNxtYLdVAwuylMoV3fKI
|
||||
# 商户APIV3密钥
|
||||
apiV3: ZHENTUAIzhentuaiZHENTUAIzhentuai
|
||||
|
||||
# 人脸合格得分
|
||||
face:
|
||||
score: 75
|
||||
|
||||
# 存储
|
||||
storage:
|
||||
defaultUse: "assets"
|
||||
|
Loading…
x
Reference in New Issue
Block a user