BUGFIX:aida;
This commit is contained in:
@@ -27,6 +27,7 @@ public enum CreditsEventsEnum {
|
|||||||
MOOD_BOARD("MoodBoard","5"),
|
MOOD_BOARD("MoodBoard","5"),
|
||||||
SKETCH_BOARD("SketchBoard","5"),
|
SKETCH_BOARD("SketchBoard","5"),
|
||||||
TO_PRODUCT_IMAGE("ToProductImage","5"),
|
TO_PRODUCT_IMAGE("ToProductImage","5"),
|
||||||
|
RELIGHT("Relight","5"),
|
||||||
QUESTIONNAIRE("Questionnaire","100"),
|
QUESTIONNAIRE("Questionnaire","100"),
|
||||||
|
|
||||||
OTHER("Other","5");
|
OTHER("Other","5");
|
||||||
|
|||||||
@@ -22,4 +22,8 @@ public class PortfolioVO extends Portfolio {
|
|||||||
private String originalUserName;
|
private String originalUserName;
|
||||||
|
|
||||||
private String originalPortfolioName;
|
private String originalPortfolioName;
|
||||||
|
|
||||||
|
private Integer isMine;
|
||||||
|
|
||||||
|
private Integer selected;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3311,7 +3311,7 @@ public class PythonService {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean toProductImage(String url, String taskId, String prompt, BigDecimal imageStrength) {
|
public Boolean toProductImage(String url, String taskId, String prompt, BigDecimal imageStrength, String productType) {
|
||||||
// todo 限流校验
|
// todo 限流校验
|
||||||
// AccessLimitUtils.validate("design",5);
|
// AccessLimitUtils.validate("design",5);
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
@@ -3327,6 +3327,7 @@ public class PythonService {
|
|||||||
map.put("image_url", url);
|
map.put("image_url", url);
|
||||||
map.put("prompt", prompt);
|
map.put("prompt", prompt);
|
||||||
map.put("image_strength", imageStrength);
|
map.put("image_strength", imageStrength);
|
||||||
|
map.put("product_type", productType);
|
||||||
log.info("toProductImage请求python 参数:####{}", map);
|
log.info("toProductImage请求python 参数:####{}", map);
|
||||||
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
System.out.println(param);
|
System.out.println(param);
|
||||||
@@ -3334,7 +3335,7 @@ public class PythonService {
|
|||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
||||||
// .url(accessPythonIp + ":9996/api/generate_product_image")
|
// .url(accessPythonIp + ":9996/api/generate_product_image")
|
||||||
.url(accessPythonIp + ":9994/api/generate_product_image")
|
.url(accessPythonIp + ":9996/api/generate_product_image")
|
||||||
.method("POST", body)
|
.method("POST", body)
|
||||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
@@ -3355,7 +3356,7 @@ public class PythonService {
|
|||||||
throw new BusinessException("toProductImage.interface.exception");
|
throw new BusinessException("toProductImage.interface.exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean relight(String url, String taskId, String prompt, String direction) {
|
public Boolean relight(String url, String taskId, String prompt, String direction, String relightType) {
|
||||||
// todo 限流校验
|
// todo 限流校验
|
||||||
// AccessLimitUtils.validate("design",5);
|
// AccessLimitUtils.validate("design",5);
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
@@ -3371,6 +3372,7 @@ public class PythonService {
|
|||||||
map.put("image_url", url);
|
map.put("image_url", url);
|
||||||
map.put("prompt", prompt);
|
map.put("prompt", prompt);
|
||||||
map.put("direction", direction);
|
map.put("direction", direction);
|
||||||
|
map.put("product_type", relightType);
|
||||||
log.info("relightImage请求python 参数:####{}", map);
|
log.info("relightImage请求python 参数:####{}", map);
|
||||||
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
log.info(param);
|
log.info(param);
|
||||||
|
|||||||
@@ -742,6 +742,17 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||||
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, category);
|
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, category);
|
||||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
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次机会
|
// 判断试用用户试用generate机会是否使用完毕 每个board 3次机会
|
||||||
|
|||||||
@@ -496,6 +496,27 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
vo.setOriginalUserName(accountMapper.selectById(vo.getOriginalAccountId()).getUserName());
|
vo.setOriginalUserName(accountMapper.selectById(vo.getOriginalAccountId()).getUserName());
|
||||||
vo.setOriginalPortfolioName(portfolioMapper.selectById(vo.getOriginalPortfolioId()).getPortfolioName());
|
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;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,7 +673,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
workspace1.setIsLastIndex(0);
|
workspace1.setIsLastIndex(0);
|
||||||
workspaceMapper.updateById(workspace1);
|
workspaceMapper.updateById(workspace1);
|
||||||
Workspace workspaceNew = new Workspace();
|
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.setAccountId(accountId);
|
||||||
workspaceNew.setIsDeleted(0);
|
workspaceNew.setIsDeleted(0);
|
||||||
workspaceNew.setIsLastIndex(1);
|
workspaceNew.setIsLastIndex(1);
|
||||||
|
|||||||
@@ -256,8 +256,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
|
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
|
||||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
|
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 toProductImageResult = new ToProductImageResult();
|
||||||
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
|
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
|
||||||
toProductImageResult.setElementType("DesignOutfit");
|
toProductImageResult.setElementType("DesignOutfit");
|
||||||
@@ -274,7 +280,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
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 toProductImageResult = new ToProductImageResult();
|
||||||
toProductImageResult.setElementId(toProductElement.getId());
|
toProductImageResult.setElementId(toProductElement.getId());
|
||||||
toProductImageResult.setElementType("ProductElement");
|
toProductImageResult.setElementType("ProductElement");
|
||||||
@@ -455,6 +461,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<ToProductImageResult> relight(ToProductImageDTO toProductImageDTO) {
|
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();
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
Long userLikeGroupId = toProductImageDTO.getUserLikeGroupId();
|
Long userLikeGroupId = toProductImageDTO.getUserLikeGroupId();
|
||||||
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
||||||
@@ -477,12 +489,22 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
s = "Snow moutain, snowy day, natural light";
|
s = "Snow moutain, snowy day, natural light";
|
||||||
}
|
}
|
||||||
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
||||||
if (toProductImageVO.getElementType().equals("ToProductImage")) {
|
|
||||||
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
i ++;
|
i ++;
|
||||||
|
if (toProductImageVO.getElementType().equals("ToProductImage")) {
|
||||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId());
|
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 toProductImageResult = new ToProductImageResult();
|
||||||
toProductImageResult.setElementId(toProductImageResult1.getId());
|
toProductImageResult.setElementId(toProductImageResult1.getId());
|
||||||
toProductImageResult.setElementType("ToProductImage");
|
toProductImageResult.setElementType("ToProductImage");
|
||||||
@@ -496,10 +518,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
result.add(toProductImageResult);
|
result.add(toProductImageResult);
|
||||||
}else {
|
}else {
|
||||||
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
|
||||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
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 toProductImageResult = new ToProductImageResult();
|
||||||
toProductImageResult.setElementId(toProductElement.getId());
|
toProductImageResult.setElementId(toProductElement.getId());
|
||||||
toProductImageResult.setElementType("ProductElement");
|
toProductImageResult.setElementType("ProductElement");
|
||||||
@@ -512,6 +533,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
result.add(toProductImageResult);
|
result.add(toProductImageResult);
|
||||||
}
|
}
|
||||||
|
// 添加需要扣除的积分到预扣除区
|
||||||
|
creditsService.addRecordToCreditsDeduction(userHolder.getId(), taskId, CreditsEventsEnum.RELIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user