BUGFIX:aida;
This commit is contained in:
@@ -742,6 +742,17 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, category);
|
||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
Long accountId = Long.parseLong(taskId.substring(taskId.lastIndexOf("-") + 1));
|
||||
if (!status.equals("Invalid")){
|
||||
// 4、扣除积分
|
||||
Boolean b = creditsService.taskCreditsDeduction(accountId, taskId);
|
||||
// 3、记录积分变更
|
||||
if (b) creditsService.insertToCreditsDetail(accountId,
|
||||
CreditsEventsEnum.RELIGHT.getName(),
|
||||
CreditsEventsEnum.RELIGHT.getValue(),
|
||||
"negative");
|
||||
}
|
||||
}
|
||||
|
||||
// 判断试用用户试用generate机会是否使用完毕 每个board 3次机会
|
||||
|
||||
@@ -496,6 +496,27 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
vo.setOriginalUserName(accountMapper.selectById(vo.getOriginalAccountId()).getUserName());
|
||||
vo.setOriginalPortfolioName(portfolioMapper.selectById(vo.getOriginalPortfolioId()).getPortfolioName());
|
||||
}
|
||||
if (userHolder == null) {
|
||||
vo.setIsMine(0);
|
||||
vo.setSelected(0);
|
||||
}else {
|
||||
if (Objects.equals(vo.getAccountId(), userHolder.getId()) || Objects.equals(vo.getOriginalAccountId(), userHolder.getId())) {
|
||||
vo.setIsMine(1);
|
||||
vo.setSelected(1);
|
||||
}else {
|
||||
vo.setIsMine(0);
|
||||
QueryWrapper<UserLikeGroup> getSelectedQw = new QueryWrapper<>();
|
||||
getSelectedQw.lambda().eq(UserLikeGroup::getAccountId, userHolder.getId());
|
||||
getSelectedQw.lambda().eq(UserLikeGroup::getOriginalPortfolioId, vo.getId());
|
||||
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(getSelectedQw);
|
||||
if (CollectionUtils.isEmpty(userLikeGroups)) {
|
||||
vo.setSelected(0);
|
||||
}else {
|
||||
vo.setSelected(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -652,7 +673,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
workspace1.setIsLastIndex(0);
|
||||
workspaceMapper.updateById(workspace1);
|
||||
Workspace workspaceNew = new Workspace();
|
||||
workspaceNew.setWorkSpaceName("workspace of " + portfolio.getPortfolioName());
|
||||
String workspaceName = "workspace of " + accountMapper.selectById(portfolio.getAccountId()).getUserName() + portfolio.getPortfolioName();
|
||||
QueryWrapper<Workspace> existSameNameQw = new QueryWrapper<>();
|
||||
existSameNameQw.lambda().eq(Workspace::getWorkSpaceName, workspaceName);
|
||||
existSameNameQw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId());
|
||||
List<Workspace> existSameNameList = workspaceMapper.selectList(existSameNameQw);
|
||||
if (!CollectionUtils.isEmpty(existSameNameList)) {
|
||||
workspaceName = workspaceName + "_copy";
|
||||
}
|
||||
workspaceNew.setWorkSpaceName(workspaceName);
|
||||
workspaceNew.setAccountId(accountId);
|
||||
workspaceNew.setIsDeleted(0);
|
||||
workspaceNew.setIsLastIndex(1);
|
||||
|
||||
@@ -256,8 +256,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
|
||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
|
||||
Long designId = tDesignPythonOutfit.getDesignId();
|
||||
Design design = designMapper.selectById(designId);
|
||||
String productType = "overall";
|
||||
if (design.getSingleOverall().equals("single")) {
|
||||
productType = "single";
|
||||
}
|
||||
// 走模型
|
||||
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, s, toProductImageDTO.getImageStrength());
|
||||
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, s, toProductImageDTO.getImageStrength(), productType);
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
|
||||
toProductImageResult.setElementType("DesignOutfit");
|
||||
@@ -274,7 +280,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||
// 走模型
|
||||
pythonService.toProductImage(toProductElement.getUrl(), taskId, s, toProductImageDTO.getImageStrength());
|
||||
pythonService.toProductImage(toProductElement.getUrl(), taskId, s, toProductImageDTO.getImageStrength(), "overall");
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
toProductImageResult.setElementId(toProductElement.getId());
|
||||
toProductImageResult.setElementType("ProductElement");
|
||||
@@ -455,6 +461,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ToProductImageResult> relight(ToProductImageDTO toProductImageDTO) {
|
||||
// 判断用户当前积分是否够本次生成消耗
|
||||
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, toProductImageDTO.getToProductImageVOList().size());
|
||||
if (!preDeduction) {
|
||||
throw new BusinessException("Not enough Credits");
|
||||
}
|
||||
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
Long userLikeGroupId = toProductImageDTO.getUserLikeGroupId();
|
||||
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
||||
@@ -477,12 +489,22 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
s = "Snow moutain, snowy day, natural light";
|
||||
}
|
||||
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
||||
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||
i ++;
|
||||
if (toProductImageVO.getElementType().equals("ToProductImage")) {
|
||||
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||
i ++;
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId());
|
||||
String relightType = "overall";
|
||||
if (toProductImageResult1.getElementType().equals("DesignOutfit")) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult1.getElementId());
|
||||
Long designId = tDesignPythonOutfit.getDesignId();
|
||||
Design design = designMapper.selectById(designId);
|
||||
if (design.getSingleOverall().equals("single")) {
|
||||
relightType = "single";
|
||||
}
|
||||
}
|
||||
|
||||
// 走模型
|
||||
pythonService.relight(toProductImageResult1.getUrl(), taskId, s, toProductImageDTO.getDirection());
|
||||
pythonService.relight(toProductImageResult1.getUrl(), taskId, s, toProductImageDTO.getDirection(), relightType);
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
toProductImageResult.setElementId(toProductImageResult1.getId());
|
||||
toProductImageResult.setElementType("ToProductImage");
|
||||
@@ -496,10 +518,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
}else {
|
||||
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||
// 走模型
|
||||
pythonService.relight(toProductElement.getUrl(), taskId, s, toProductImageDTO.getDirection());
|
||||
pythonService.relight(toProductElement.getUrl(), taskId, s, toProductImageDTO.getDirection(), "overall");
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
toProductImageResult.setElementId(toProductElement.getId());
|
||||
toProductImageResult.setElementType("ProductElement");
|
||||
@@ -512,6 +533,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
}
|
||||
// 添加需要扣除的积分到预扣除区
|
||||
creditsService.addRecordToCreditsDeduction(userHolder.getId(), taskId, CreditsEventsEnum.RELIGHT);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user