TASK:模块化;
This commit is contained in:
@@ -124,6 +124,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
|
||||
@Resource
|
||||
private DesignBatchMapper designBatchMapper;
|
||||
@@ -2062,6 +2064,45 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
cloudTask.setStatus(0);
|
||||
cloudTaskMapper.insert(cloudTask);
|
||||
return batchTaskId;
|
||||
} else if (cloudTaskDTO.getBuildType().equals(BuildType.POSE_TRANSFORM.getValue())) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
|
||||
List<PoseTransformBatchDTO> poseTransformList = cloudTaskDTO.getPoseTransform();
|
||||
if (CollectionUtil.isNotEmpty(poseTransformList)) {
|
||||
String taskBatchId = UUID.randomUUID().toString() + "-" + accountId;
|
||||
for (PoseTransformBatchDTO poseTransformBatchDTO : poseTransformList) {
|
||||
// 1、判断用户当前积分是否够本次生成消耗
|
||||
CreditsEventsEnum creditsEventsEnum = CreditsEventsEnum.POSE_TRANSFORMATION;
|
||||
Boolean preDeduction = creditsService.creditsPreDeduction(creditsEventsEnum, 1);
|
||||
if (!preDeduction) {
|
||||
throw new BusinessException("remaining.credits.insufficient", ResultEnum.WARNING.getCode());
|
||||
}
|
||||
|
||||
// 3、生成唯一id 使用uuid,由于uuid重复的几率很小,故取消对uuid重复性的校验
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String taskId = uuid + "-" + accountId;
|
||||
|
||||
PoseTransformation poseTransformation = new PoseTransformation();
|
||||
poseTransformation.setProjectId(cloudTaskDTO.getProjectId());
|
||||
poseTransformation.setAccountId(accountId);
|
||||
poseTransformation.setUniqueId(taskId);
|
||||
poseTransformation.setProductImage(poseTransformBatchDTO.getProductImage());
|
||||
poseTransformation.setPoseId(poseTransformBatchDTO.getPoseId());
|
||||
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||
poseTransformation.setTaskIdBatch(taskBatchId);
|
||||
poseTransformationMapper.insert(poseTransformation);
|
||||
|
||||
Boolean b = pythonService.poseTransformationBatch(poseTransformBatchDTO.getProductImage(), poseTransformBatchDTO.getPoseId(), taskId);
|
||||
if (b){
|
||||
// 6、添加预扣除积分到redis
|
||||
creditsService.addRecordToCreditsDeduction(accountId, uuid, creditsEventsEnum);
|
||||
// 6.1 添加积分扣除记录到db
|
||||
creditsService.preInsert(accountId, creditsEventsEnum.getName(), uuid, Boolean.TRUE, null);
|
||||
return taskId;
|
||||
}
|
||||
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user