Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -5,8 +5,10 @@ import com.ai.da.common.utils.RedisUtil;
|
|||||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||||
import com.ai.da.model.vo.GenerateResultVO;
|
import com.ai.da.model.vo.GenerateResultVO;
|
||||||
import com.ai.da.model.vo.PoseTransformationVO;
|
import com.ai.da.model.vo.PoseTransformationVO;
|
||||||
|
import com.ai.da.service.DesignService;
|
||||||
import com.ai.da.service.GenerateService;
|
import com.ai.da.service.GenerateService;
|
||||||
import com.ai.da.service.UserLikeGroupService;
|
import com.ai.da.service.UserLikeGroupService;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
@@ -17,6 +19,7 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -34,6 +37,9 @@ public class GenerateConsumer {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserLikeGroupService userLikeGroupService;
|
private UserLikeGroupService userLikeGroupService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DesignService designService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RabbitMQProperties rabbitMQProperties;
|
private RabbitMQProperties rabbitMQProperties;
|
||||||
|
|
||||||
@@ -305,6 +311,170 @@ public class GenerateConsumer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processDesignBatchResult(Message msg, Channel channel) {
|
||||||
|
log.info("============processDesignBatchResult listening==========");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
Map<String, Object> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
||||||
|
log.info("designBatch response : {}", generateResult);
|
||||||
|
designService.processDesignBatch(generateResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processToProductImageBatchResult(Message msg, Channel channel) {
|
||||||
|
log.info("============processToProductImageResultBatch listening==========");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
JSONObject generateResult = JSONObject.parseObject(msg.getBody(), JSONObject.class);
|
||||||
|
log.info("toProductImageBatch response : {}", generateResult);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("tasks_id : {} start ", generateResult.get("task_id"));
|
||||||
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
|
String progress = generateResult.getString("progress");
|
||||||
|
JSONArray result = generateResult.getJSONArray("result");
|
||||||
|
String url = null;
|
||||||
|
if (!StringUtils.isEmpty(result)) {
|
||||||
|
url = result.getString(0);
|
||||||
|
}
|
||||||
|
String taskId = generateResult.getString("task_id");
|
||||||
|
userLikeGroupService.toProductBatch(taskId, url, progress);
|
||||||
|
} else {
|
||||||
|
// 修改redis中的数据状态为exception
|
||||||
|
String key = toProductImageResultKey + ":" + generateResult.get("task_id");
|
||||||
|
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("task_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
// 将异常信息存到exception中
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("data"));
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
try {
|
||||||
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
|
} catch (IOException exception) {
|
||||||
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
|
}
|
||||||
|
// 将入参和错误信息存入数据库
|
||||||
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
|
" Exception message : " + e.getMessage();
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(String.valueOf(generateResult.get("task_id")), exceptionMessage);
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("task_id"), generateResult.get("message"), (end - start));
|
||||||
|
log.info("============ProcessToProductImageBatchResult End listening==========");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processRelightBatchResult(Message msg, Channel channel) {
|
||||||
|
log.info("============processRelightResult listening==========");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
JSONObject generateResult = JSONObject.parseObject(msg.getBody(), JSONObject.class);
|
||||||
|
log.info("relightBatch response : {}", generateResult);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("task_id : {} start ", generateResult.get("task_id"));
|
||||||
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
|
String progress = generateResult.getString("progress");
|
||||||
|
JSONArray result = generateResult.getJSONArray("result");
|
||||||
|
String url = null;
|
||||||
|
if (!StringUtils.isEmpty(result)) {
|
||||||
|
url = result.getString(0);
|
||||||
|
String taskId = generateResult.getString("task_id");
|
||||||
|
userLikeGroupService.relightBatch(taskId, url, progress);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 修改redis中的数据状态为exception
|
||||||
|
String key = relightResultKey + ":" + generateResult.get("task_id");
|
||||||
|
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("task_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
// 将异常信息存到exception中
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("data"));
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
try {
|
||||||
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
|
} catch (IOException exception) {
|
||||||
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
|
}
|
||||||
|
// 将入参和错误信息存入数据库
|
||||||
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
|
" Exception message : " + e.getMessage();
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(String.valueOf(generateResult.get("task_id")), exceptionMessage);
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
log.info("task_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("task_id"), generateResult.get("message"), (end - start));
|
||||||
|
log.info("============ProcessRelightBatchResult End listening==========");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processPoseTransformBatchResult(Message msg, Channel channel) {
|
||||||
|
log.info("============ProcessPoseTransformBatchResult listening==========");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
JSONObject generateResult = JSONObject.parseObject(msg.getBody(), JSONObject.class);
|
||||||
|
log.info("PoseTransformationBatch response : {}", generateResult);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("task_id : {} start ", generateResult.get("task_id"));
|
||||||
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
|
JSONArray result = generateResult.getJSONArray("result");
|
||||||
|
if (!StringUtils.isEmpty(result)) {
|
||||||
|
JSONObject jsonObject = result.getJSONObject(0);
|
||||||
|
String gifUrl = jsonObject.getString("gif_url");
|
||||||
|
String taskId = generateResult.getString("task_id");
|
||||||
|
String videoUrl = jsonObject.getString("video_url");
|
||||||
|
String imageUrl = jsonObject.getString("first_image_url");
|
||||||
|
String progress = generateResult.getString("progress");
|
||||||
|
generateService.processPoseTransformResultBatch(taskId, gifUrl, videoUrl, imageUrl, progress);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 修改redis中的数据状态为exception
|
||||||
|
String key = generateResultKey + ":" + generateResult.getString("task_id");
|
||||||
|
redisUtil.addToString(key, new Gson().toJson(new PoseTransformationVO(null, generateResult.getString("task_id"),null, null, null, (byte)0, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
// 将异常信息存到exception中
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("message"));
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
try {
|
||||||
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
|
} catch (IOException exception) {
|
||||||
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
|
}
|
||||||
|
// 将入参和错误信息存入数据库
|
||||||
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
|
" Exception message : " + e.getMessage();
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(generateResult.getString("task_id"), exceptionMessage);
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
||||||
|
log.info("============ProcessPoseTransformResult End listening==========");
|
||||||
|
}
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void generateConsumer1(Message msg, Channel channel) {
|
public void generateConsumer1(Message msg, Channel channel) {
|
||||||
@@ -382,4 +552,26 @@ public class GenerateConsumer {
|
|||||||
public void getPoseTransformationResult(Message msg, Channel channel) {
|
public void getPoseTransformationResult(Message msg, Channel channel) {
|
||||||
processPoseTransformResult(msg, channel);
|
processPoseTransformResult(msg, channel);
|
||||||
}
|
}
|
||||||
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.designBatch}")
|
||||||
|
@RabbitHandler
|
||||||
|
public void getDesignBatchResult(Message msg, Channel channel) {
|
||||||
|
processDesignBatchResult(msg, channel);
|
||||||
|
}
|
||||||
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageBatch}")
|
||||||
|
@RabbitHandler
|
||||||
|
public void getToProductImageBatchResult(Message msg, Channel channel) {
|
||||||
|
processToProductImageBatchResult(msg, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.relightBatch}")
|
||||||
|
@RabbitHandler
|
||||||
|
public void getRelightBatchResult(Message msg, Channel channel) {
|
||||||
|
processRelightBatchResult(msg, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.poseTransformBatch}")
|
||||||
|
@RabbitHandler
|
||||||
|
public void getPoseTransformBatchResult(Message msg, Channel channel) {
|
||||||
|
processPoseTransformBatchResult(msg, channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ public class RabbitMQProperties {
|
|||||||
private String toProductImageResult;
|
private String toProductImageResult;
|
||||||
private String relightResult;
|
private String relightResult;
|
||||||
private String poseTransform;
|
private String poseTransform;
|
||||||
|
private String designBatch;
|
||||||
|
private String relightBatch;
|
||||||
|
private String toProductImageBatch;
|
||||||
|
private String poseTransformBatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.ai.da.controller;
|
package com.ai.da.controller;
|
||||||
|
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
import com.ai.da.common.response.Response;
|
import com.ai.da.common.response.Response;
|
||||||
|
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
import com.ai.da.model.vo.CollectionSketchVO;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.model.vo.DesignCollectionVO;
|
|
||||||
import com.ai.da.model.vo.DesignLikeVO;
|
|
||||||
import com.ai.da.service.DesignService;
|
import com.ai.da.service.DesignService;
|
||||||
|
import com.ai.da.service.UserLikeGroupService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
@@ -27,6 +28,8 @@ import java.util.List;
|
|||||||
public class DesignController {
|
public class DesignController {
|
||||||
@Resource
|
@Resource
|
||||||
private DesignService designService;
|
private DesignService designService;
|
||||||
|
@Resource
|
||||||
|
private UserLikeGroupService userLikeGroupService;
|
||||||
|
|
||||||
@ApiOperation(value = "设计 Conllection")
|
@ApiOperation(value = "设计 Conllection")
|
||||||
@PostMapping("/designCollection")
|
@PostMapping("/designCollection")
|
||||||
@@ -97,8 +100,19 @@ public class DesignController {
|
|||||||
|
|
||||||
@ApiOperation(value = "云生成")
|
@ApiOperation(value = "云生成")
|
||||||
@PostMapping("/designCloud")
|
@PostMapping("/designCloud")
|
||||||
@CrossOrigin
|
public Response<String> designCloud(@Valid @RequestBody CloudTaskDTO cloudTaskDTO) {
|
||||||
public Response<String> designCloud(@Valid @RequestBody DesignCollectionDTO designDTO) {
|
return Response.success(designService.designCloud(cloudTaskDTO));
|
||||||
return Response.success(designService.designCloud(designDTO));
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "云生成page")
|
||||||
|
@PostMapping("/cloudPage")
|
||||||
|
public Response<PageBaseResponse<CloudTaskVO>> cloudPage(@Valid @RequestBody CloudPageDTO cloudPageDTO) {
|
||||||
|
return Response.success(PageBaseResponse.success(designService.cloudPage(cloudPageDTO)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取design云生成结果")
|
||||||
|
@PostMapping("/getDesignCloudResult")
|
||||||
|
public Response<CloudTaskResultVO> getDesignCloudResult(@Valid @RequestBody DesignCloudResultQuery designCloudResultQuery) {
|
||||||
|
return Response.success(designService.getDesignCloudResult(designCloudResultQuery));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.ai.da.mapper.primary;
|
||||||
|
|
||||||
|
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||||
|
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||||
|
|
||||||
|
public interface CloudTaskMapper extends CommonMapper<CloudTask> {
|
||||||
|
}
|
||||||
47
src/main/java/com/ai/da/mapper/primary/entity/CloudTask.java
Normal file
47
src/main/java/com/ai/da/mapper/primary/entity/CloudTask.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package com.ai.da.mapper.primary.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.apache.poi.hpsf.Decimal;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("cloud_task")
|
||||||
|
public class CloudTask implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
private Long collectionId;
|
||||||
|
|
||||||
|
private Long designId;
|
||||||
|
|
||||||
|
private String buildType;
|
||||||
|
|
||||||
|
private Integer nums;
|
||||||
|
|
||||||
|
private Integer completedNum;
|
||||||
|
|
||||||
|
private Integer costCredits;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -88,4 +88,6 @@ public class CollectionElement implements Serializable {
|
|||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
|
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
private Integer isCompositeImage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public class Portfolio implements Serializable {
|
|||||||
|
|
||||||
private Long originalPortfolioId;
|
private Long originalPortfolioId;
|
||||||
|
|
||||||
|
private String snapshot;
|
||||||
|
|
||||||
@ApiModelProperty(value = "作品集作者ID")
|
@ApiModelProperty(value = "作品集作者ID")
|
||||||
private Long accountId;
|
private Long accountId;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public class PoseTransformation extends BaseEntity {
|
|||||||
|
|
||||||
private String uniqueId;
|
private String uniqueId;
|
||||||
|
|
||||||
|
private String taskIdBatch;
|
||||||
|
|
||||||
private String productImage;
|
private String productImage;
|
||||||
|
|
||||||
private int poseId;
|
private int poseId;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public class Project implements Serializable {
|
|||||||
|
|
||||||
private Long originalPortfolioId;
|
private Long originalPortfolioId;
|
||||||
|
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@@ -19,4 +20,7 @@ public class ThreeDModule implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
private Long threeDSimpleId;
|
private Long threeDSimpleId;
|
||||||
|
private Long collectionElementId;
|
||||||
|
private BigDecimal x;
|
||||||
|
private BigDecimal y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,4 +51,6 @@ public class ToProductImageResult implements Serializable {
|
|||||||
private String direction;
|
private String direction;
|
||||||
|
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
private String taskIdBatch;
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/main/java/com/ai/da/model/dto/CloudPageDTO.java
Normal file
9
src/main/java/com/ai/da/model/dto/CloudPageDTO.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import com.ai.da.model.vo.PageQueryBaseVo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CloudPageDTO extends PageQueryBaseVo {
|
||||||
|
private Long projectId;
|
||||||
|
}
|
||||||
15
src/main/java/com/ai/da/model/dto/CloudTaskDTO.java
Normal file
15
src/main/java/com/ai/da/model/dto/CloudTaskDTO.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CloudTaskDTO extends CloudTask {
|
||||||
|
private ToProductImageDTO toProductImage;
|
||||||
|
|
||||||
|
private List<PoseTransformBatchDTO> poseTransform;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import com.ai.da.model.vo.PageQueryBaseVo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DesignCloudResultQuery extends PageQueryBaseVo {
|
||||||
|
private String taskId;
|
||||||
|
private String buildType;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.DesignItemDetail;
|
||||||
|
import com.ai.da.mapper.primary.entity.DesignItemDetailPrint;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DesignItemDetailSnapshot extends DesignItemDetail {
|
||||||
|
private List<DesignItemDetailPrint> designItemDetailPrintList;
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ public class ModuleSaveDTO {
|
|||||||
@ApiModelProperty("手稿板图片id 数组")
|
@ApiModelProperty("手稿板图片id 数组")
|
||||||
private List<CollectionSketchDTO> sketchBoard;
|
private List<CollectionSketchDTO> sketchBoard;
|
||||||
|
|
||||||
private Long patternMaking3D;
|
private PatternMaking3DDTO patternMaking3D;
|
||||||
|
|
||||||
// private MoodBoardModuleChooseVO moodBoard;
|
// private MoodBoardModuleChooseVO moodBoard;
|
||||||
// private List<CollectionElementVO> printBoard;
|
// private List<CollectionElementVO> printBoard;
|
||||||
|
|||||||
13
src/main/java/com/ai/da/model/dto/PatternMaking3DDTO.java
Normal file
13
src/main/java/com/ai/da/model/dto/PatternMaking3DDTO.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PatternMaking3DDTO {
|
||||||
|
private Long threeDSimpleId;
|
||||||
|
private Long collectionElementId;
|
||||||
|
private BigDecimal x;
|
||||||
|
private BigDecimal y;
|
||||||
|
}
|
||||||
10
src/main/java/com/ai/da/model/dto/PoseTransformBatchDTO.java
Normal file
10
src/main/java/com/ai/da/model/dto/PoseTransformBatchDTO.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PoseTransformBatchDTO {
|
||||||
|
private String productImage;
|
||||||
|
|
||||||
|
private Integer poseId;
|
||||||
|
}
|
||||||
18
src/main/java/com/ai/da/model/dto/ProjectSnapshot.java
Normal file
18
src/main/java/com/ai/da/model/dto/ProjectSnapshot.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProjectSnapshot implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Project project;
|
||||||
|
private Workspace workspace;
|
||||||
|
private List<CollectionElement> collectionElementList;
|
||||||
|
private UserLikeGroup userLikeGroup;
|
||||||
|
private List<UserLikeSnapshot> userLikeList;
|
||||||
|
}
|
||||||
14
src/main/java/com/ai/da/model/dto/UserLikeSnapshot.java
Normal file
14
src/main/java/com/ai/da/model/dto/UserLikeSnapshot.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserLikeSnapshot extends UserLike {
|
||||||
|
private DesignItem designItem;
|
||||||
|
private TDesignPythonOutfit designPythonOutfit;
|
||||||
|
private List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetailList;
|
||||||
|
private List<DesignItemDetailSnapshot> designItemDetailList;
|
||||||
|
}
|
||||||
32
src/main/java/com/ai/da/model/enums/BuildType.java
Normal file
32
src/main/java/com/ai/da/model/enums/BuildType.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.ai.da.model.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum BuildType implements IEnumDisplay {
|
||||||
|
DESIGN("design"),
|
||||||
|
TO_PRODUCT_IMAGE("toProductImage"),
|
||||||
|
RELIGHT("relight"),
|
||||||
|
POSE_TRANSFORM("poseTransfer")
|
||||||
|
;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
BuildType(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BuildType getBuildType(String value) {
|
||||||
|
for (BuildType type : values()) {
|
||||||
|
if (type.value.equalsIgnoreCase(value)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/main/java/com/ai/da/model/vo/CloudTaskResultVO.java
Normal file
15
src/main/java/com/ai/da/model/vo/CloudTaskResultVO.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
|
import com.ai.da.mapper.primary.entity.TDesignPythonOutfit;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CloudTaskResultVO {
|
||||||
|
private List<DesignCollectionItemVO> design;
|
||||||
|
private List<MagicToolResultVO> toProductImage;
|
||||||
|
private List<MagicToolResultVO> relight;
|
||||||
|
private List<PoseTransformationVO> poseTransfer;
|
||||||
|
}
|
||||||
9
src/main/java/com/ai/da/model/vo/CloudTaskVO.java
Normal file
9
src/main/java/com/ai/da/model/vo/CloudTaskVO.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CloudTaskVO extends CloudTask {
|
||||||
|
private String process;
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -13,5 +15,5 @@ public class DesignModuleChooseVO {
|
|||||||
private Long userGroupId;
|
private Long userGroupId;
|
||||||
|
|
||||||
@ApiModelProperty("分组详细数组")
|
@ApiModelProperty("分组详细数组")
|
||||||
private java.util.List<UserLikeVO> userLikeDetails;
|
private List<UserLikeVO> userLikeDetails;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,5 +34,5 @@ public class ModuleChooseVO {
|
|||||||
// private moodBoardModuleChooseVO patternMaking3D;
|
// private moodBoardModuleChooseVO patternMaking3D;
|
||||||
private SketchReconstructionVO deReconstruction;
|
private SketchReconstructionVO deReconstruction;
|
||||||
|
|
||||||
private ThreeDVO patternMaking3D;
|
private ThreeDModuleVO patternMaking3D;
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/main/java/com/ai/da/model/vo/ThreeDModuleVO.java
Normal file
9
src/main/java/com/ai/da/model/vo/ThreeDModuleVO.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.ThreeDModule;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ThreeDModuleVO extends ThreeDModule {
|
||||||
|
private String printMinioUrl;
|
||||||
|
}
|
||||||
@@ -3,7 +3,9 @@ package com.ai.da.model.vo;
|
|||||||
import com.ai.da.mapper.primary.entity.ThreeDLayout;
|
import com.ai.da.mapper.primary.entity.ThreeDLayout;
|
||||||
import com.ai.da.mapper.primary.entity.ThreeDPatternLayout;
|
import com.ai.da.mapper.primary.entity.ThreeDPatternLayout;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.apache.poi.hpsf.Decimal;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -4250,4 +4250,136 @@ public class PythonService {
|
|||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean toProductImageBatch(String url, String taskId, String prompt, BigDecimal imageStrength, String productType) {
|
||||||
|
// todo 限流校验
|
||||||
|
// AccessLimitUtils.validate("design",5);
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||||
|
.build();
|
||||||
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
|
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("tasks_id", taskId);
|
||||||
|
map.put("image_url", url);
|
||||||
|
map.put("prompt", prompt);
|
||||||
|
map.put("image_strength", imageStrength);
|
||||||
|
map.put("product_type", productType);
|
||||||
|
map.put("batch_size", 1);
|
||||||
|
log.info("toProductImage请求python 参数:####{}", map);
|
||||||
|
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
|
System.out.println(param);
|
||||||
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
||||||
|
// .url(accessPythonIp + ":9996/api/generate_product_image")
|
||||||
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/batch_generate_product_image")
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
Response response;
|
||||||
|
String responseBody;
|
||||||
|
try {
|
||||||
|
response = client.newCall(request).execute();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
log.error("PythonService##toProductImage异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
|
throw new BusinessException("toProductImage.interface.exception");
|
||||||
|
}
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
log.error("PythonService##toProductImage异常response###{}", response);
|
||||||
|
//生成失败
|
||||||
|
throw new BusinessException("toProductImage.interface.exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean relightBatch(String url, String taskId, String prompt, String direction, String relightType) {
|
||||||
|
// todo 限流校验
|
||||||
|
// AccessLimitUtils.validate("design",5);
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||||
|
.build();
|
||||||
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
|
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("tasks_id", taskId);
|
||||||
|
map.put("image_url", url);
|
||||||
|
map.put("prompt", prompt);
|
||||||
|
map.put("direction", direction);
|
||||||
|
map.put("product_type", relightType);
|
||||||
|
map.put("batch_size", 1);
|
||||||
|
log.info("relightImage请求python 参数:####{}", map);
|
||||||
|
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
|
log.info(param);
|
||||||
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
||||||
|
// .url(accessPythonIp + ":9996/api/generate_product_image")
|
||||||
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/batch_generate_relight_image")
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
Response response;
|
||||||
|
String responseBody;
|
||||||
|
try {
|
||||||
|
response = client.newCall(request).execute();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
log.error("PythonService##relightImage异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
|
throw new BusinessException("relightImage.interface.exception");
|
||||||
|
}
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
log.error("PythonService##relightImage异常response###{}", response);
|
||||||
|
//生成失败
|
||||||
|
throw new BusinessException("relightImage.interface.exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean poseTransformationBatch(String productImage, Integer poseId, String taskId) {
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||||
|
.build();
|
||||||
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
|
Map<String, Object> content = Maps.newHashMap();
|
||||||
|
content.put("image_url", productImage);
|
||||||
|
content.put("tasks_id", taskId);
|
||||||
|
content.put("pose_id", String.valueOf(poseId));
|
||||||
|
content.put("batch_size", 1);
|
||||||
|
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||||
|
|
||||||
|
log.info("poseTransformation 请求地址: {}", accessPythonIp + ":" + accessPythonPort + "/api/batch_generate_pose_transform_image");
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/batch_generate_pose_transform_image")
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
Response response = null;
|
||||||
|
try {
|
||||||
|
response = client.newCall(request).execute();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
log.error("PythonService##poseTransferBatch异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
|
throw new BusinessException("poseTransferBatch.interface.exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
String responseBody = response.body().toString();
|
||||||
|
log.info("PythonService##poseTransferBatch返回内容###{}", responseBody);
|
||||||
|
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error("PythonService##poseTransferBatch接口调用失败###{}", response);
|
||||||
|
throw new BusinessException("poseTransferBatch.interface.exception");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/main/java/com/ai/da/service/CloudTaskService.java
Normal file
8
src/main/java/com/ai/da/service/CloudTaskService.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package com.ai.da.service;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
public interface CloudTaskService extends IService<CloudTask> {
|
||||||
|
CloudTask getByTaskId(String taskId);
|
||||||
|
}
|
||||||
@@ -27,6 +27,8 @@ public interface CreditsService extends IService<CreditsDetail> {
|
|||||||
|
|
||||||
Boolean creditsPreDeduction(CreditsEventsEnum event, Integer num);
|
Boolean creditsPreDeduction(CreditsEventsEnum event, Integer num);
|
||||||
|
|
||||||
|
Boolean creditsPreDeduction(Integer credits);
|
||||||
|
|
||||||
void addRecordToCreditsDeduction(Long accountId, String taskId, CreditsEventsEnum creditsEventsEnum);
|
void addRecordToCreditsDeduction(Long accountId, String taskId, CreditsEventsEnum creditsEventsEnum);
|
||||||
|
|
||||||
Boolean taskCreditsDeduction(Long accountId, String taskId);
|
Boolean taskCreditsDeduction(Long accountId, String taskId);
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package com.ai.da.service;
|
package com.ai.da.service;
|
||||||
|
|
||||||
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
import com.ai.da.mapper.primary.entity.Design;
|
import com.ai.da.mapper.primary.entity.Design;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
import com.ai.da.model.vo.CollectionSketchVO;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.model.vo.DesignCollectionVO;
|
|
||||||
import com.ai.da.model.vo.DesignItemDetailVO;
|
|
||||||
import com.ai.da.model.vo.DesignLikeVO;
|
|
||||||
import com.ai.da.python.vo.DesignPythonObjects;
|
import com.ai.da.python.vo.DesignPythonObjects;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -109,9 +108,13 @@ public interface DesignService extends IService<Design> {
|
|||||||
|
|
||||||
DesignCollectionVO getDesignResult(String requestId, List<String> objectSignList);
|
DesignCollectionVO getDesignResult(String requestId, List<String> objectSignList);
|
||||||
|
|
||||||
String designCloud(DesignCollectionDTO designDTO);
|
String designCloud(CloudTaskDTO cloudTaskDTO);
|
||||||
|
|
||||||
void processDesignBatch(Map<String, Object> designBatchResult);
|
void processDesignBatch(Map<String, Object> designBatchResult);
|
||||||
|
|
||||||
Boolean sort(UserLikeSortDTO userLikeSortDTO);
|
Boolean sort(UserLikeSortDTO userLikeSortDTO);
|
||||||
|
|
||||||
|
IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO);
|
||||||
|
|
||||||
|
CloudTaskResultVO getDesignCloudResult(DesignCloudResultQuery designCloudResultQuery);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,6 @@ public interface GenerateService extends IService<Generate> {
|
|||||||
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
||||||
|
|
||||||
List<Map<String, String>> getAllPose();
|
List<Map<String, String>> getAllPose();
|
||||||
|
|
||||||
|
void processPoseTransformResultBatch(String taskId, String gifUrl, String videoUrl, String imageUrl, String progress);
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/main/java/com/ai/da/service/ProjectService.java
Normal file
28
src/main/java/com/ai/da/service/ProjectService.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ai.da.service;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.entity.Design;
|
||||||
|
import com.ai.da.mapper.primary.entity.Project;
|
||||||
|
import com.ai.da.model.dto.*;
|
||||||
|
import com.ai.da.model.vo.CollectionSketchVO;
|
||||||
|
import com.ai.da.model.vo.DesignCollectionVO;
|
||||||
|
import com.ai.da.model.vo.DesignItemDetailVO;
|
||||||
|
import com.ai.da.model.vo.DesignLikeVO;
|
||||||
|
import com.ai.da.python.vo.DesignPythonObjects;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务类
|
||||||
|
*
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2022-09-11
|
||||||
|
*/
|
||||||
|
public interface ProjectService extends IService<Project> {
|
||||||
|
|
||||||
|
Set<Long> getChildProjectIdSet(Long projectId);
|
||||||
|
}
|
||||||
@@ -109,4 +109,8 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
|||||||
Boolean delete(Long projectId);
|
Boolean delete(Long projectId);
|
||||||
|
|
||||||
Boolean brandDNADelete(BrandDNADTO brandDNADTO);
|
Boolean brandDNADelete(BrandDNADTO brandDNADTO);
|
||||||
|
|
||||||
|
void toProductBatch(String taskId, String url, String progress);
|
||||||
|
|
||||||
|
void relightBatch(String taskId, String url, String progress);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1388,6 +1388,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
config.setJdbcUrl("jdbc:mysql://code-create.com.hk:3306/db1nfvsgmjp3b8");
|
config.setJdbcUrl("jdbc:mysql://code-create.com.hk:3306/db1nfvsgmjp3b8");
|
||||||
config.setUsername("uafqtz4gsvfrw");
|
config.setUsername("uafqtz4gsvfrw");
|
||||||
config.setPassword("aida123456.");
|
config.setPassword("aida123456.");
|
||||||
|
// config.setJdbcUrl("jdbc:mysql://18.167.251.121:33008/aida");
|
||||||
|
// config.setUsername("aida_con");
|
||||||
|
// config.setPassword("123456");
|
||||||
// config.setJdbcUrl("jdbc:mysql://localhost:3306/code-create-local?serverTimezone=UTC");
|
// config.setJdbcUrl("jdbc:mysql://localhost:3306/code-create-local?serverTimezone=UTC");
|
||||||
// config.setUsername("root");
|
// config.setUsername("root");
|
||||||
// config.setPassword("root");
|
// config.setPassword("root");
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ai.da.service.impl;
|
||||||
|
|
||||||
|
import com.ai.da.mapper.primary.AccountMapper;
|
||||||
|
import com.ai.da.mapper.primary.CloudTaskMapper;
|
||||||
|
import com.ai.da.mapper.primary.entity.Account;
|
||||||
|
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||||
|
import com.ai.da.service.ClassificationService;
|
||||||
|
import com.ai.da.service.CloudTaskService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class CloudTaskServiceImpl extends ServiceImpl<CloudTaskMapper, CloudTask> implements CloudTaskService {
|
||||||
|
@Resource
|
||||||
|
private CloudTaskMapper cloudTaskMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CloudTask getByTaskId(String taskId) {
|
||||||
|
QueryWrapper<CloudTask> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(CloudTask::getTaskId, taskId);
|
||||||
|
return cloudTaskMapper.selectOne(qw);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -227,6 +227,32 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
|||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean creditsPreDeduction(Integer credits) {
|
||||||
|
|
||||||
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
|
||||||
|
// 1、获取当前在积分预扣除区,未来需要预扣除的积分总和
|
||||||
|
Set<String> keys = redisUtil.getKeysFromString(creditsDeduction + ":" + accountId + ":*");
|
||||||
|
List<String> multiValue = redisUtil.getMultiValue(keys);
|
||||||
|
// 1.1 预扣除区 积分总和
|
||||||
|
int sum = multiValue.stream().mapToInt(Integer::parseInt).sum();
|
||||||
|
// 1.2 加上本次操作需要扣除的积分
|
||||||
|
sum += credits;
|
||||||
|
|
||||||
|
// 2、获取当前积分
|
||||||
|
BigDecimal existingCredits = accountMapper.selectById(accountId).getCredits();
|
||||||
|
BigDecimal subtract = existingCredits.subtract(new BigDecimal(sum));
|
||||||
|
|
||||||
|
// 3、判断剩余积分是否够本次操作
|
||||||
|
if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
// 3.1 不够,直接返回余额不够,充值
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRecordToCreditsDeduction(Long accountId, String taskId, CreditsEventsEnum creditsEventsEnum) {
|
public void addRecordToCreditsDeduction(Long accountId, String taskId, CreditsEventsEnum creditsEventsEnum) {
|
||||||
// 5、添加当前任务的预扣积分到redis 任务有效期一天,若待扣积分两天还没被移除,说明任务已经失败,待扣积分自动失效
|
// 5、添加当前任务的预扣积分到redis 任务有效期一天,若待扣积分两天还没被移除,说明任务已经失败,待扣积分自动失效
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ import com.ai.da.common.config.exception.BusinessException;
|
|||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
import com.ai.da.common.enums.*;
|
import com.ai.da.common.enums.*;
|
||||||
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.utils.*;
|
import com.ai.da.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
import com.ai.da.mapper.primary.entity.Collection;
|
import com.ai.da.mapper.primary.entity.Collection;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
|
import com.ai.da.model.enums.BuildType;
|
||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.python.PythonService;
|
import com.ai.da.python.PythonService;
|
||||||
import com.ai.da.python.vo.*;
|
import com.ai.da.python.vo.*;
|
||||||
@@ -22,8 +25,12 @@ import com.alibaba.fastjson.JSONException;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
@@ -37,6 +44,7 @@ import javax.annotation.Resource;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -93,6 +101,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
||||||
|
@Resource
|
||||||
|
private DesignItemDetailMapper designItemDetailMapper;
|
||||||
|
@Resource
|
||||||
|
private ToProductImageResultMapper toProductImageResultMapper;
|
||||||
|
@Resource
|
||||||
|
private ToProductElementMapper toProductElementMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MoodboardPositionMapper moodboardPositionMapper;
|
private MoodboardPositionMapper moodboardPositionMapper;
|
||||||
@@ -110,12 +124,26 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
private PoseTransformationMapper poseTransformationMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DesignBatchMapper designBatchMapper;
|
private DesignBatchMapper designBatchMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserLikeSortMapper userLikeSortMapper;
|
private UserLikeSortMapper userLikeSortMapper;
|
||||||
|
@Resource
|
||||||
|
private ProjectService projectService;
|
||||||
|
@Resource
|
||||||
|
private WorkspaceService workspaceService;
|
||||||
|
@Resource
|
||||||
|
private CloudTaskMapper cloudTaskMapper;
|
||||||
|
@Resource
|
||||||
|
private CloudTaskService cloudTaskService;
|
||||||
|
@Resource
|
||||||
|
private CreditsService creditsService;
|
||||||
|
@Resource
|
||||||
|
private ToProductImageRecordMapper toProductImageRecordMapper;
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@@ -308,8 +336,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
Long collectionId;
|
Long collectionId;
|
||||||
if (null == collectionIdParam) {
|
if (null == collectionIdParam) {
|
||||||
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
|
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
|
||||||
// String moodboardPosition = designDTO.getMoodboardPosition();
|
|
||||||
// parseMoodboardPosition(moodboardPosition, collectionId);
|
|
||||||
}else {
|
}else {
|
||||||
collectionId = collectionIdParam;
|
collectionId = collectionIdParam;
|
||||||
}
|
}
|
||||||
@@ -1769,23 +1795,427 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String designCloud(DesignCollectionDTO designDTO) {
|
public String designCloud(CloudTaskDTO cloudTaskDTO) {
|
||||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) {
|
||||||
//校验collection element
|
Long projectId = cloudTaskDTO.getProjectId();
|
||||||
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
// Project project = projectService.getById(projectId);
|
||||||
//design
|
// project.setParentId(projectId);
|
||||||
return designBatch(designDTO, userInfo, null, elementVO);
|
// project.setId(null);
|
||||||
|
// project.setName(project.getName() + "_cloud");
|
||||||
|
// LocalDateTime now = LocalDateTime.now();
|
||||||
|
// project.setCreateTime(now);
|
||||||
|
// project.setUpdateTime(now);
|
||||||
|
// projectService.getBaseMapper().insert(project);
|
||||||
|
// Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||||
|
// Workspace workspace = workspaceService.getById(workspaceId);
|
||||||
|
// workspace.setProjectId(project.getId());
|
||||||
|
// workspace.setId(null);
|
||||||
|
// workspaceService.getBaseMapper().insert(workspace);
|
||||||
|
|
||||||
|
DesignCollectionDTO designDTO = transDesignParam(projectId);
|
||||||
|
designDTO.setDesignNum(cloudTaskDTO.getNums());
|
||||||
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||||
|
|
||||||
|
//校验collection element
|
||||||
|
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
||||||
|
|
||||||
|
//design
|
||||||
|
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId);
|
||||||
|
return taskId;
|
||||||
|
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
||||||
|
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
||||||
|
// 判断用户当前积分是否够本次生成消耗
|
||||||
|
Boolean preDeduction = creditsService.creditsPreDeduction(cloudTaskDTO.getCostCredits());
|
||||||
|
if (!preDeduction) {
|
||||||
|
throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
|
||||||
|
}
|
||||||
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
|
|
||||||
|
String batchTaskId = UUID.randomUUID() + "-" + userHolder.getId();
|
||||||
|
|
||||||
|
Long projectId = cloudTaskDTO.getProjectId();
|
||||||
|
UserLikeGroup userLikeGroup = userLikeGroupService.getByProjectId(projectId);
|
||||||
|
Long userLikeGroupId = null;
|
||||||
|
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
||||||
|
toProductImageRecord.setProjectId(projectId);
|
||||||
|
if (Objects.nonNull(userLikeGroup)) {
|
||||||
|
userLikeGroupId = userLikeGroup.getId();
|
||||||
|
toProductImageRecord.setUserLikeGroupId(userLikeGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toProductImageRecord.setCreateTime(LocalDateTime.now());
|
||||||
|
if (!StringUtils.isEmpty(toProductImageDTO.getPrompt())) {
|
||||||
|
toProductImageRecord.setPrompt(toProductImageDTO.getPrompt());
|
||||||
|
}
|
||||||
|
toProductImageRecordMapper.insert(toProductImageRecord);
|
||||||
|
|
||||||
|
List<ToProductImageResult> result = new ArrayList<>();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
// 翻译
|
||||||
|
String prompt = toProductImageDTO.getPrompt();
|
||||||
|
StringBuilder sb = new StringBuilder("The best quality, masterpiece, real image.");
|
||||||
|
if (!StringUtil.isNullOrEmpty(prompt)) {
|
||||||
|
prompt = pythonService.promptTranslate(prompt);
|
||||||
|
}
|
||||||
|
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
||||||
|
String taskId;
|
||||||
|
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
|
||||||
|
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
|
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
|
||||||
|
|
||||||
|
Long designItemId = tDesignPythonOutfit.getDesignItemId();
|
||||||
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||||
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemId);
|
||||||
|
designItemDetailQueryWrapper.lambda().ne(DesignItemDetail::getType, "Body");
|
||||||
|
List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||||
|
String collect = designItemDetails.stream().map(DesignItemDetail::getType).collect(Collectors.joining(","));
|
||||||
|
|
||||||
|
Long designId = tDesignPythonOutfit.getDesignId();
|
||||||
|
Design design = designMapper.selectById(designId);
|
||||||
|
String productType = "overall";
|
||||||
|
if (design.getSingleOverall().equals("single")) {
|
||||||
|
productType = "single";
|
||||||
|
sb.append(collect);
|
||||||
|
}else {
|
||||||
|
if (collect.contains("Tops")) {
|
||||||
|
sb.append("a handsome man,");
|
||||||
|
}else {
|
||||||
|
sb.append("a beautiful women,");
|
||||||
|
}
|
||||||
|
sb.append("wearing ").append(collect);
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(prompt)) {
|
||||||
|
sb.append(",high quality clothing details,8K realistic,HDR");
|
||||||
|
}else {
|
||||||
|
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
|
||||||
|
}
|
||||||
|
// 走模型
|
||||||
|
pythonService.toProductImageBatch(tDesignPythonOutfit.getDesignUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), productType);
|
||||||
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
|
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
|
||||||
|
toProductImageResult.setElementType("DesignOutfit");
|
||||||
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
|
toProductImageResult.setIsLike(0);
|
||||||
|
toProductImageResult.setTaskId(taskId);
|
||||||
|
toProductImageResult.setProjectId(projectId);
|
||||||
|
toProductImageResult.setTaskIdBatch(batchTaskId);
|
||||||
|
if (userLikeGroupId != null) {
|
||||||
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
||||||
|
}
|
||||||
|
toProductImageResult.setImageStrength(toProductImageDTO.getImageStrength());
|
||||||
|
toProductImageResultMapper.insert(toProductImageResult);
|
||||||
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
|
result.add(toProductImageResult);
|
||||||
|
}else {
|
||||||
|
if (StringUtils.isEmpty(prompt)) {
|
||||||
|
sb.append(",high quality clothing details,8K realistic,HDR");
|
||||||
|
}else {
|
||||||
|
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
|
||||||
|
}
|
||||||
|
|
||||||
|
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||||
|
// 走模型
|
||||||
|
pythonService.toProductImageBatch(toProductElement.getUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), "overall");
|
||||||
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
|
toProductImageResult.setElementId(toProductElement.getId());
|
||||||
|
toProductImageResult.setElementType("ProductElement");
|
||||||
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
|
toProductImageResult.setIsLike(0);
|
||||||
|
toProductImageResult.setTaskId(taskId);
|
||||||
|
toProductImageResult.setProjectId(projectId);
|
||||||
|
toProductImageResult.setTaskIdBatch(batchTaskId);
|
||||||
|
if (userLikeGroupId != null) {
|
||||||
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
||||||
|
}
|
||||||
|
toProductImageResult.setImageStrength(toProductImageDTO.getImageStrength());
|
||||||
|
toProductImageResultMapper.insert(toProductImageResult);
|
||||||
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
|
result.add(toProductImageResult);
|
||||||
|
}
|
||||||
|
i ++;
|
||||||
|
sb = new StringBuilder("The best quality, masterpiece, real image.");
|
||||||
|
// 添加需要扣除的积分到预扣除区
|
||||||
|
creditsService.addRecordToCreditsDeduction(userHolder.getId(), taskId, CreditsEventsEnum.TO_PRODUCT_IMAGE);
|
||||||
|
}
|
||||||
|
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
||||||
|
cloudTask.setProjectId(projectId);
|
||||||
|
cloudTask.setTaskId(batchTaskId);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
cloudTask.setCreateTime(now);
|
||||||
|
cloudTask.setUpdateTime(now);
|
||||||
|
cloudTask.setStatus(0);
|
||||||
|
cloudTaskMapper.insert(cloudTask);
|
||||||
|
return batchTaskId;
|
||||||
|
}else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) {
|
||||||
|
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
||||||
|
// 判断用户当前积分是否够本次生成消耗
|
||||||
|
Boolean preDeduction = creditsService.creditsPreDeduction(cloudTaskDTO.getCostCredits());
|
||||||
|
if (!preDeduction) {
|
||||||
|
throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
|
String batchTaskId = UUID.randomUUID() + "-" + userHolder.getId();
|
||||||
|
Long projectId = cloudTaskDTO.getProjectId();
|
||||||
|
UserLikeGroup userLikeGroup = userLikeGroupService.getByProjectId(projectId);
|
||||||
|
Long userLikeGroupId = null;
|
||||||
|
|
||||||
|
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
||||||
|
toProductImageRecord.setProjectId(projectId);
|
||||||
|
if (Objects.nonNull(userLikeGroup)) {
|
||||||
|
userLikeGroupId = userLikeGroup.getId();
|
||||||
|
toProductImageRecord.setUserLikeGroupId(userLikeGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toProductImageRecord.setCreateTime(LocalDateTime.now());
|
||||||
|
if (!StringUtils.isEmpty(toProductImageDTO.getPrompt())) {
|
||||||
|
toProductImageRecord.setPrompt(toProductImageDTO.getPrompt());
|
||||||
|
}
|
||||||
|
toProductImageRecordMapper.insert(toProductImageRecord);
|
||||||
|
|
||||||
|
List<ToProductImageResult> result = new ArrayList<>();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
// 翻译
|
||||||
|
String prompt = toProductImageDTO.getPrompt();
|
||||||
|
String s = "";
|
||||||
|
if (!StringUtil.isNullOrEmpty(prompt)) {
|
||||||
|
s = pythonService.promptTranslate(prompt);
|
||||||
|
}else {
|
||||||
|
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")) {
|
||||||
|
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.relightBatch(toProductImageResult1.getUrl(), taskId, s, toProductImageDTO.getDirection(), relightType);
|
||||||
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
|
toProductImageResult.setElementId(toProductImageResult1.getId());
|
||||||
|
toProductImageResult.setElementType("ToProductImage");
|
||||||
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
|
toProductImageResult.setIsLike(0);
|
||||||
|
toProductImageResult.setTaskId(taskId);
|
||||||
|
toProductImageResult.setProjectId(projectId);
|
||||||
|
toProductImageResult.setTaskIdBatch(batchTaskId);
|
||||||
|
if (null != userLikeGroupId) {
|
||||||
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
||||||
|
}
|
||||||
|
if (toProductImageDTO.getBrightenValue() != null) {
|
||||||
|
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
||||||
|
}
|
||||||
|
toProductImageResult.setDirection(toProductImageDTO.getDirection());
|
||||||
|
toProductImageResultMapper.insert(toProductImageResult);
|
||||||
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
|
result.add(toProductImageResult);
|
||||||
|
}else {
|
||||||
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||||
|
// 走模型
|
||||||
|
pythonService.relightBatch(toProductElement.getUrl(), taskId, s, toProductImageDTO.getDirection(), "overall");
|
||||||
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
|
toProductImageResult.setElementId(toProductElement.getId());
|
||||||
|
toProductImageResult.setElementType("ProductElement");
|
||||||
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
|
toProductImageResult.setIsLike(0);
|
||||||
|
toProductImageResult.setTaskId(taskId);
|
||||||
|
toProductImageResult.setProjectId(projectId);
|
||||||
|
toProductImageResult.setTaskIdBatch(batchTaskId);
|
||||||
|
if (null != userLikeGroupId) {
|
||||||
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
||||||
|
}
|
||||||
|
if (toProductImageDTO.getBrightenValue() != null) {
|
||||||
|
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
||||||
|
}
|
||||||
|
toProductImageResult.setDirection(toProductImageDTO.getDirection());
|
||||||
|
toProductImageResultMapper.insert(toProductImageResult);
|
||||||
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
|
result.add(toProductImageResult);
|
||||||
|
}
|
||||||
|
// 添加需要扣除的积分到预扣除区
|
||||||
|
// creditsService.addRecordToCreditsDeduction(userHolder.getId(), taskId, CreditsEventsEnum.RELIGHT);
|
||||||
|
}
|
||||||
|
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
||||||
|
cloudTask.setProjectId(projectId);
|
||||||
|
cloudTask.setTaskId(batchTaskId);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
cloudTask.setCreateTime(now);
|
||||||
|
cloudTask.setUpdateTime(now);
|
||||||
|
cloudTask.setStatus(0);
|
||||||
|
cloudTaskMapper.insert(cloudTask);
|
||||||
|
return batchTaskId;
|
||||||
|
} else if (cloudTaskDTO.getBuildType().equals(BuildType.POSE_TRANSFORM.getValue())) {
|
||||||
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
Boolean preDeduction = creditsService.creditsPreDeduction(cloudTaskDTO.getCostCredits());
|
||||||
|
if (!preDeduction) {
|
||||||
|
throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}else {
|
||||||
|
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
||||||
|
cloudTask.setProjectId(cloudTask.getProjectId());
|
||||||
|
cloudTask.setTaskId(taskBatchId);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
cloudTask.setCreateTime(now);
|
||||||
|
cloudTask.setUpdateTime(now);
|
||||||
|
cloudTask.setStatus(0);
|
||||||
|
cloudTaskMapper.insert(cloudTask);
|
||||||
|
return taskBatchId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String designBatch(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, Long collectionIdParam, ValidateElementVO elementVO) {
|
private DesignCollectionDTO transDesignParam(Long projectId) {
|
||||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
DesignCollectionDTO designCollectionDTO = new DesignCollectionDTO();
|
||||||
//编辑sketchBoard
|
List<CollectionElement> collectionElementList = collectionElementService.getByProjectId(projectId);
|
||||||
collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
if (CollectionUtil.isNotEmpty(collectionElementList)) {
|
||||||
|
Map<String, List<CollectionElement>> groupedMap = collectionElementList.stream().collect(Collectors.groupingBy(CollectionElement::getLevel1Type));
|
||||||
|
if (CollectionUtil.isNotEmpty(groupedMap.get("Moodboard"))) {
|
||||||
|
List<DesignCollectionElementDTO> moodBoards = new ArrayList<>();
|
||||||
|
List<CollectionElement> moodboardList = groupedMap.get("Moodboard");
|
||||||
|
for (CollectionElement collectionElement : moodboardList) {
|
||||||
|
if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) {
|
||||||
|
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
||||||
|
designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId()));
|
||||||
|
}else {
|
||||||
|
DesignCollectionElementDTO dto = new DesignCollectionElementDTO();
|
||||||
|
dto.setId(collectionElement.getId());
|
||||||
|
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
|
moodBoards.add(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
designCollectionDTO.setMoodBoards(moodBoards);
|
||||||
|
}else {
|
||||||
|
designCollectionDTO.setMoodBoards(new ArrayList<>());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(groupedMap.get("Printboard"))) {
|
||||||
|
List<DesignCollectionPrintElementDTO> printBoards = new ArrayList<>();
|
||||||
|
List<CollectionElement> printBoardList = groupedMap.get("Printboard");
|
||||||
|
for (CollectionElement collectionElement : printBoardList) {
|
||||||
|
DesignCollectionPrintElementDTO dto = new DesignCollectionPrintElementDTO();
|
||||||
|
dto.setId(collectionElement.getId());
|
||||||
|
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
|
printBoards.add(dto);
|
||||||
|
}
|
||||||
|
designCollectionDTO.setPrintBoards(printBoards);
|
||||||
|
}else {
|
||||||
|
designCollectionDTO.setPrintBoards(new ArrayList<>());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(groupedMap.get("Colorboard"))) {
|
||||||
|
List<CollectionColorDTO> colorBoards = new ArrayList<>();
|
||||||
|
List<CollectionElement> colorBoardList = groupedMap.get("Colorboard");
|
||||||
|
for (CollectionElement collectionElement : colorBoardList) {
|
||||||
|
CollectionColorDTO dto = new CollectionColorDTO();
|
||||||
|
String name = collectionElement.getName();
|
||||||
|
if (name.contains("_")) {
|
||||||
|
String[] split = name.split("_");
|
||||||
|
dto.setId(Integer.valueOf(split[0]));
|
||||||
|
dto.setName(split[1]);
|
||||||
|
dto.setTcx(split[2]);
|
||||||
|
}
|
||||||
|
dto.setRgbValue(collectionElement.getColorRgb());
|
||||||
|
if (collectionElement.getGradientString() != null && !collectionElement.getGradientString().equals("null")) {
|
||||||
|
dto.setGradientString(collectionElement.getGradientString());
|
||||||
|
}
|
||||||
|
colorBoards.add(dto);
|
||||||
|
}
|
||||||
|
designCollectionDTO.setColorBoards(colorBoards);
|
||||||
|
}else {
|
||||||
|
designCollectionDTO.setColorBoards(new ArrayList<>());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(groupedMap.get("Sketchboard"))) {
|
||||||
|
List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
|
||||||
|
List<CollectionElement> sketchBoardList = groupedMap.get("Sketchboard");
|
||||||
|
for (CollectionElement collectionElement : sketchBoardList) {
|
||||||
|
CollectionSketchDTO dto = new CollectionSketchDTO();
|
||||||
|
dto.setSketchBoardId(collectionElement.getId());
|
||||||
|
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
|
dto.setLevel2Type(collectionElement.getLevel2Type());
|
||||||
|
dto.setIsPin(collectionElement.getHasPin());
|
||||||
|
sketchBoards.add(dto);
|
||||||
|
}
|
||||||
|
designCollectionDTO.setSketchBoards(sketchBoards);
|
||||||
|
}else {
|
||||||
|
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
designCollectionDTO.setMoodBoards(new ArrayList<>());
|
||||||
|
designCollectionDTO.setPrintBoards(new ArrayList<>());
|
||||||
|
designCollectionDTO.setColorBoards(new ArrayList<>());
|
||||||
|
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||||
//编辑printBoard
|
Workspace workspace = workspaceService.getById(workspaceId);
|
||||||
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
designCollectionDTO.setSystemScale(
|
||||||
|
BigDecimal.valueOf(workspace.getSystemDesignerPercentage())
|
||||||
|
.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)
|
||||||
|
);
|
||||||
|
designCollectionDTO.setModelSex(workspace.getSex());
|
||||||
|
if (workspace.getSex().equals("Female")) {
|
||||||
|
designCollectionDTO.setTemplateId(workspace.getMannequinFemaleId());
|
||||||
|
designCollectionDTO.setModelType(workspace.getMannequinFemaleType());
|
||||||
}
|
}
|
||||||
|
if (workspace.getPosition().equals("Overall")) {
|
||||||
|
designCollectionDTO.setSingleOverall("overall");
|
||||||
|
}else {
|
||||||
|
designCollectionDTO.setSingleOverall("single");
|
||||||
|
designCollectionDTO.setSwitchCategory(workspace.getPosition());
|
||||||
|
}
|
||||||
|
designCollectionDTO.setTimeZone("Etc/GMT-8");
|
||||||
|
return designCollectionDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String designBatch(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, Long collectionIdParam, ValidateElementVO elementVO, CloudTaskDTO cloudTaskDTO, Long projectId) {
|
||||||
//保存collection
|
//保存collection
|
||||||
Long collectionId;
|
Long collectionId;
|
||||||
if (null == collectionIdParam) {
|
if (null == collectionIdParam) {
|
||||||
@@ -1796,16 +2226,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
List<Long> elementIds = getElementId(elementVO);
|
List<Long> elementIds = getElementId(elementVO);
|
||||||
//批量关联element 到 collection
|
//批量关联element 到 collection
|
||||||
collectionElementService.relationCollection(elementIds, collectionId);
|
collectionElementService.relationCollection(elementIds, collectionId);
|
||||||
//library转化为collection(生成)
|
|
||||||
saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
|
||||||
//generate转化为collection(生成)
|
|
||||||
saveCollectionElemntsByGenerates(elementVO, collectionId);
|
|
||||||
//保存颜色版
|
|
||||||
collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
|
||||||
//保存design
|
//保存design
|
||||||
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||||
//计算library
|
|
||||||
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
|
||||||
//组装design入参
|
//组装design入参
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||||
@@ -1826,17 +2249,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
String taskId = pythonService.designBatch(pythonObjects, userHolder.getId(), elementVO.getDesignNum(), requestId);
|
String taskId = pythonService.designBatch(pythonObjects, userHolder.getId(), elementVO.getDesignNum(), requestId);
|
||||||
|
|
||||||
DesignBatch designBatch = new DesignBatch();
|
|
||||||
|
|
||||||
designBatch.setAccountId(userInfo.getId());
|
|
||||||
designBatch.setDesignId(designId);
|
|
||||||
designBatch.setCollectionId(collectionId);
|
|
||||||
designBatch.setTaskId(taskId);
|
|
||||||
designBatch.setCreateTime(LocalDateTime.now());
|
|
||||||
designBatch.setStatus(0);
|
|
||||||
designBatch.setTotalNum(elementVO.getDesignNum());
|
|
||||||
designBatchMapper.insert(designBatch);
|
|
||||||
|
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
totalTimeInSeconds = (endTime - startTime) / 1000;
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
log.info("design python端运行时间:" + totalTimeInSeconds + " 秒");
|
log.info("design python端运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
@@ -1844,9 +2256,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
generateLibrary(elementVO, designDTO.getTimeZone());
|
generateLibrary(elementVO, designDTO.getTimeZone());
|
||||||
//处理关联关系,修复element覆盖得情况
|
//处理关联关系,修复element覆盖得情况
|
||||||
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||||
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
// List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||||
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
// handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
totalTimeInSeconds = (endTime - startTime) / 1000;
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
log.info("处理关联关系运行时间:" + totalTimeInSeconds + " 秒");
|
log.info("处理关联关系运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
@@ -1863,6 +2275,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
|
|
||||||
// 将上下文存入全局设计上下文中
|
// 将上下文存入全局设计上下文中
|
||||||
designContext.put(taskId, context);
|
designContext.put(taskId, context);
|
||||||
|
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
||||||
|
cloudTask.setProjectId(projectId);
|
||||||
|
cloudTask.setDesignId(designId);
|
||||||
|
cloudTask.setCollectionId(collectionId);
|
||||||
|
cloudTask.setTaskId(taskId);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
cloudTask.setCreateTime(now);
|
||||||
|
cloudTask.setUpdateTime(now);
|
||||||
|
cloudTask.setStatus(0);
|
||||||
|
cloudTaskMapper.insert(cloudTask);
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1875,28 +2297,29 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
}
|
}
|
||||||
if (progress.equals("ok")) {
|
if (progress.equals("ok")) {
|
||||||
String taskId = (String) designBatchResult.get("task_id");
|
String taskId = (String) designBatchResult.get("task_id");
|
||||||
QueryWrapper<DesignBatch> qw = new QueryWrapper<>();
|
QueryWrapper<CloudTask> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(DesignBatch::getTaskId, taskId);
|
qw.lambda().eq(CloudTask::getTaskId, taskId);
|
||||||
List<DesignBatch> designBatches = designBatchMapper.selectList(qw);
|
List<CloudTask> cloudTaskList = cloudTaskMapper.selectList(qw);
|
||||||
if (CollectionUtil.isNotEmpty(designBatches)) {
|
if (CollectionUtil.isNotEmpty(cloudTaskList)) {
|
||||||
DesignBatch designBatch = designBatches.get(0);
|
CloudTask cloudTask = cloudTaskList.get(0);
|
||||||
designBatch.setStatus(1);
|
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||||
designBatchMapper.updateById(designBatch);
|
cloudTask.setStatus(1);
|
||||||
|
cloudTaskMapper.updateById(cloudTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
String taskId = (String) designBatchResult.get("task_id");
|
String taskId = (String) designBatchResult.get("task_id");
|
||||||
QueryWrapper<DesignBatch> qw = new QueryWrapper<>();
|
QueryWrapper<CloudTask> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(DesignBatch::getTaskId, taskId);
|
qw.lambda().eq(CloudTask::getTaskId, taskId);
|
||||||
List<DesignBatch> designBatches = designBatchMapper.selectList(qw);
|
List<CloudTask> cloudTaskList = cloudTaskMapper.selectList(qw);
|
||||||
if (CollectionUtil.isNotEmpty(designBatches)) {
|
if (CollectionUtil.isNotEmpty(cloudTaskList)) {
|
||||||
DesignBatch designBatch = designBatches.get(0);
|
CloudTask cloudTask = cloudTaskList.get(0);
|
||||||
if (designBatch.getCompletedNum() == null) {
|
if (cloudTask.getCompletedNum() == null) {
|
||||||
designBatch.setCompletedNum(1);
|
cloudTask.setCompletedNum(1);
|
||||||
}else {
|
}else {
|
||||||
designBatch.setCompletedNum(designBatch.getCompletedNum() + 1);
|
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||||
}
|
}
|
||||||
designBatchMapper.updateById(designBatch);
|
cloudTaskMapper.updateById(cloudTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer i = (Integer) progress;
|
Integer i = (Integer) progress;
|
||||||
@@ -1915,7 +2338,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
String timeZone = (String) context.get("timeZone");
|
String timeZone = (String) context.get("timeZone");
|
||||||
String singleOverall = (String) context.get("singleOverall");
|
String singleOverall = (String) context.get("singleOverall");
|
||||||
|
|
||||||
DesignPythonObject item = pythonObjects.getObjects().get(i);
|
DesignPythonObject item = pythonObjects.getObjects().get(i-1);
|
||||||
DesignItem designItem = new DesignItem();
|
DesignItem designItem = new DesignItem();
|
||||||
designItem.setAccountId(userInfo.getId());
|
designItem.setAccountId(userInfo.getId());
|
||||||
designItem.setCollectionId(collectionId);
|
designItem.setCollectionId(collectionId);
|
||||||
@@ -2029,12 +2452,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (int i = 0; i < pythonObjects.getObjects().size(); i++) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// response.setProcessId(pythonObjects.getProcess_id());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2050,4 +2467,168 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO) {
|
||||||
|
// 分页数据
|
||||||
|
Set<Long> childProjectIdSet = projectService.getChildProjectIdSet(cloudPageDTO.getProjectId());
|
||||||
|
childProjectIdSet.add(cloudPageDTO.getProjectId());
|
||||||
|
QueryWrapper<CloudTask> queryWrapper = new QueryWrapper<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(childProjectIdSet)) {
|
||||||
|
queryWrapper.lambda().in(CloudTask::getProjectId, childProjectIdSet);
|
||||||
|
}else {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
IPage<CloudTask> page = cloudTaskMapper.selectPage(
|
||||||
|
new Page<>(cloudPageDTO.getPage(), cloudPageDTO.getSize()), queryWrapper);
|
||||||
|
if (CollectionUtils.isEmpty(page.getRecords())) {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
IPage<CloudTaskVO> convert = page.convert((Function<CloudTask, CloudTaskVO>) cloudTask -> {
|
||||||
|
if (cloudTask != null) {
|
||||||
|
CloudTaskVO cloudTaskVO = CopyUtil.copyObject(cloudTask, CloudTaskVO.class);
|
||||||
|
if (cloudTaskVO.getCompletedNum() == null) {
|
||||||
|
cloudTaskVO.setProcess("0%");
|
||||||
|
}else {
|
||||||
|
BigDecimal completed = BigDecimal.valueOf(cloudTaskVO.getCompletedNum());
|
||||||
|
BigDecimal total = BigDecimal.valueOf(cloudTaskVO.getNums());
|
||||||
|
|
||||||
|
BigDecimal percent = completed
|
||||||
|
.divide(total, 4, RoundingMode.HALF_UP) // 先计算小数百分比,保留4位防止精度问题
|
||||||
|
.multiply(BigDecimal.valueOf(100)) // 乘以100变成百分比
|
||||||
|
.setScale(2, RoundingMode.HALF_UP); // 最终保留2位小数
|
||||||
|
|
||||||
|
cloudTaskVO.setProcess(percent.toPlainString() + "%");
|
||||||
|
}
|
||||||
|
return cloudTaskVO;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
return convert;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${redis.key.toProductImageResultKey}")
|
||||||
|
private String toProductImageResultKey;
|
||||||
|
@Value("${redis.key.relightResultKey}")
|
||||||
|
private String relightResultKey;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CloudTaskResultVO getDesignCloudResult(DesignCloudResultQuery query) {
|
||||||
|
CloudTaskResultVO result = new CloudTaskResultVO();
|
||||||
|
if (query.getBuildType().equals(BuildType.DESIGN.getValue())) {
|
||||||
|
CloudTask cloudTask = cloudTaskService.getByTaskId(query.getTaskId());
|
||||||
|
if (Objects.nonNull(cloudTask)) {
|
||||||
|
Long collectionId = cloudTask.getCollectionId();
|
||||||
|
if (null != collectionId) {
|
||||||
|
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, collectionId);
|
||||||
|
List<TDesignPythonOutfit> list = designPythonOutfitMapper.selectList(qw);
|
||||||
|
List<DesignCollectionItemVO> voList = new ArrayList<>();
|
||||||
|
for (TDesignPythonOutfit tDesignPythonOutfit : list) {
|
||||||
|
DesignCollectionItemVO vo = new DesignCollectionItemVO();
|
||||||
|
vo.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||||
|
vo.setDesignOutfitUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||||
|
vo.setDesignItemId(tDesignPythonOutfit.getDesignItemId());
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
|
result.setDesign(voList);
|
||||||
|
// IPage<DesignCollectionItemVO> convert = page.convert((Function<TDesignPythonOutfit, DesignCollectionItemVO>) outfit -> {
|
||||||
|
// if (outfit != null) {
|
||||||
|
// DesignCollectionItemVO vo = new DesignCollectionItemVO();
|
||||||
|
// vo.setDesignOutfitId(outfit.getId());
|
||||||
|
// vo.setDesignOutfitUrl(minioUtil.getPreSignedUrl(outfit.getDesignUrl(), 24 * 60));
|
||||||
|
// vo.setDesignItemId(outfit.getDesignItemId());
|
||||||
|
// return vo;
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// });
|
||||||
|
// result.setDesign(PageBaseResponse.success(convert));
|
||||||
|
return result;
|
||||||
|
}else {
|
||||||
|
result.setDesign(new ArrayList<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.setDesign(new ArrayList<>());
|
||||||
|
return result;
|
||||||
|
} else if (query.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
||||||
|
List<MagicToolResultVO> results = new ArrayList<>();
|
||||||
|
QueryWrapper<ToProductImageResult> toProductImageResultQueryWrapper = new QueryWrapper<>();
|
||||||
|
toProductImageResultQueryWrapper.lambda().eq(ToProductImageResult::getTaskIdBatch, query.getTaskId());
|
||||||
|
List<ToProductImageResult> toProductImageResultList = toProductImageResultMapper.selectList(toProductImageResultQueryWrapper);
|
||||||
|
for (ToProductImageResult toProductImageResult : toProductImageResultList) {
|
||||||
|
MagicToolResultVO magicToolResultVO = new MagicToolResultVO();
|
||||||
|
magicToolResultVO.setId(toProductImageResult.getId());
|
||||||
|
magicToolResultVO.setTaskId(toProductImageResult.getTaskId());
|
||||||
|
magicToolResultVO.setStatus("Success");
|
||||||
|
magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
||||||
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
||||||
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
||||||
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
||||||
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
||||||
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||||
|
}else {
|
||||||
|
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
|
||||||
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||||
|
}
|
||||||
|
results.add(magicToolResultVO);
|
||||||
|
}
|
||||||
|
result.setToProductImage(results);
|
||||||
|
return result;
|
||||||
|
} else if (query.getBuildType().equals(BuildType.RELIGHT.getValue())) {
|
||||||
|
List<MagicToolResultVO> results = new ArrayList<>();
|
||||||
|
QueryWrapper<ToProductImageResult> toProductImageResultQueryWrapper = new QueryWrapper<>();
|
||||||
|
toProductImageResultQueryWrapper.lambda().eq(ToProductImageResult::getTaskIdBatch, query.getTaskId());
|
||||||
|
List<ToProductImageResult> toProductImageResultList = toProductImageResultMapper.selectList(toProductImageResultQueryWrapper);
|
||||||
|
for (ToProductImageResult toProductImageResult : toProductImageResultList) {
|
||||||
|
MagicToolResultVO magicToolResultVO = new MagicToolResultVO();
|
||||||
|
magicToolResultVO.setId(toProductImageResult.getId());
|
||||||
|
magicToolResultVO.setTaskId(toProductImageResult.getTaskId());
|
||||||
|
magicToolResultVO.setStatus("Success");
|
||||||
|
magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
||||||
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
||||||
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
||||||
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
||||||
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
||||||
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||||
|
}else {
|
||||||
|
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId());
|
||||||
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
|
||||||
|
}
|
||||||
|
results.add(magicToolResultVO);
|
||||||
|
}
|
||||||
|
result.setRelight(results);
|
||||||
|
return result;
|
||||||
|
} else if (query.getBuildType().equals(BuildType.POSE_TRANSFORM.getValue())) {
|
||||||
|
String taskId = query.getTaskId();
|
||||||
|
QueryWrapper<PoseTransformation> poseTransformationQueryWrapper = new QueryWrapper<>();
|
||||||
|
poseTransformationQueryWrapper.lambda().eq(PoseTransformation::getTaskIdBatch, taskId);
|
||||||
|
List<PoseTransformation> poseTransformationList = poseTransformationMapper.selectList(poseTransformationQueryWrapper);
|
||||||
|
List<PoseTransformationVO> voList = new ArrayList<>();
|
||||||
|
for (PoseTransformation poseTransformation : poseTransformationList) {
|
||||||
|
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
|
||||||
|
poseTransformationVO.setId(poseTransformation.getId());
|
||||||
|
poseTransformationVO.setIsLiked(poseTransformation.getIsLiked());
|
||||||
|
poseTransformationVO.setStatus("Success");
|
||||||
|
poseTransformationVO.setTaskId(poseTransformation.getUniqueId());
|
||||||
|
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(poseTransformation.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
if (null != poseTransformation.getGifUrl()){
|
||||||
|
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
if (null != poseTransformation.getVideoUrl()){
|
||||||
|
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
if (null != poseTransformation.getFirstFrameUrl()){
|
||||||
|
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
voList.add(poseTransformationVO);
|
||||||
|
}
|
||||||
|
result.setPoseTransfer(voList);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -969,6 +969,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PoseTransformationMapper poseTransformationMapper;
|
private PoseTransformationMapper poseTransformationMapper;
|
||||||
|
@Resource
|
||||||
|
private CloudTaskMapper cloudTaskMapper;
|
||||||
|
|
||||||
public void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl){
|
public void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl){
|
||||||
// 1、存储模型返回的数据
|
// 1、存储模型返回的数据
|
||||||
@@ -1202,4 +1204,54 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
return Arrays.asList(resp);
|
return Arrays.asList(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processPoseTransformResultBatch(String taskId, String gifUrl, String videoUrl, String imageUrl, String progress) {
|
||||||
|
// 1、存储模型返回的数据
|
||||||
|
PoseTransformation poseTransformation;
|
||||||
|
QueryWrapper<PoseTransformation> qw = new QueryWrapper<>();
|
||||||
|
qw.eq("unique_id", taskId);
|
||||||
|
List<PoseTransformation> poseTransformations = poseTransformationMapper.selectList(qw);
|
||||||
|
if (poseTransformations != null && poseTransformations.size() > 1){
|
||||||
|
log.warn("通过taskId {} 查询到的PoseTransformation的结果不止一条", taskId);
|
||||||
|
}else if (poseTransformations == null || poseTransformations.isEmpty()){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
poseTransformation = poseTransformations.get(0);
|
||||||
|
poseTransformation.setGifUrl(gifUrl);
|
||||||
|
poseTransformation.setVideoUrl(videoUrl);
|
||||||
|
poseTransformation.setFirstFrameUrl(imageUrl);
|
||||||
|
poseTransformation.setUpdateTime(LocalDateTime.now());
|
||||||
|
poseTransformationMapper.updateById(poseTransformation);
|
||||||
|
|
||||||
|
String taskIdBatch = poseTransformation.getTaskIdBatch();
|
||||||
|
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||||
|
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||||
|
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||||
|
if (Objects.nonNull(cloudTask)) {
|
||||||
|
if (cloudTask.getCompletedNum() == null) {
|
||||||
|
cloudTask.setCompletedNum(1);
|
||||||
|
}else {
|
||||||
|
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||||
|
}
|
||||||
|
if (progress.equals("OK")) {
|
||||||
|
cloudTask.setStatus(1);
|
||||||
|
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||||
|
}
|
||||||
|
cloudTaskMapper.updateById(cloudTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = generateResultKey + ":" + taskId;
|
||||||
|
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(
|
||||||
|
poseTransformation.getId(), taskId, gifUrl, videoUrl, imageUrl, (byte) 0, "Success");
|
||||||
|
|
||||||
|
// 2、更新redis
|
||||||
|
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
|
||||||
|
// 3、执行积分扣除
|
||||||
|
String accountId = taskId.substring(taskId.lastIndexOf("-") + 1);
|
||||||
|
String uuid = taskId.substring(0, taskId.lastIndexOf("-"));
|
||||||
|
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), uuid);
|
||||||
|
if (flag) creditsService.updateChangedCredits(accountId, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ai.da.service.impl;
|
package com.ai.da.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
@@ -25,6 +26,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -135,7 +137,9 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||||
PortfolioDTO portfolioDTO = JSONObject.parseObject(data, PortfolioDTO.class);
|
PortfolioDTO portfolioDTO = JSONObject.parseObject(data, PortfolioDTO.class);
|
||||||
QueryWrapper<Portfolio> existSameNameQw = new QueryWrapper<>();
|
QueryWrapper<Portfolio> existSameNameQw = new QueryWrapper<>();
|
||||||
existSameNameQw.lambda().ne(Portfolio::getId, portfolioDTO.getId());
|
if (null != portfolioDTO.getId()) {
|
||||||
|
existSameNameQw.lambda().ne(Portfolio::getId, portfolioDTO.getId());
|
||||||
|
}
|
||||||
existSameNameQw.lambda().eq(Portfolio::getPortfolioName, portfolioDTO.getPortfolioName());
|
existSameNameQw.lambda().eq(Portfolio::getPortfolioName, portfolioDTO.getPortfolioName());
|
||||||
existSameNameQw.lambda().eq(Portfolio::getAccountId, authPrincipalVo.getId());
|
existSameNameQw.lambda().eq(Portfolio::getAccountId, authPrincipalVo.getId());
|
||||||
List<Portfolio> portfoliosSameName = portfolioMapper.selectList(existSameNameQw);
|
List<Portfolio> portfoliosSameName = portfolioMapper.selectList(existSameNameQw);
|
||||||
@@ -148,6 +152,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
}
|
}
|
||||||
if (file != null && file.getOriginalFilename() != null) {
|
if (file != null && file.getOriginalFilename() != null) {
|
||||||
Long portfolioId;
|
Long portfolioId;
|
||||||
|
// 上传画布到minio
|
||||||
String upload = minioUtil.upload("aida-canvas", String.valueOf(authPrincipalVo.getId()), file);
|
String upload = minioUtil.upload("aida-canvas", String.valueOf(authPrincipalVo.getId()), file);
|
||||||
Canvas canvas = new Canvas();
|
Canvas canvas = new Canvas();
|
||||||
canvas.setUrl(upload);
|
canvas.setUrl(upload);
|
||||||
@@ -155,21 +160,20 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
canvas.setAccountId(authPrincipalVo.getId());
|
canvas.setAccountId(authPrincipalVo.getId());
|
||||||
canvasMapper.insert(canvas);
|
canvasMapper.insert(canvas);
|
||||||
|
|
||||||
|
// 创建portfolio
|
||||||
Portfolio portfolio = new Portfolio();
|
Portfolio portfolio = new Portfolio();
|
||||||
QueryWrapper<Portfolio> portfolioQueryWrapper = new QueryWrapper<>();
|
if (null != portfolioDTO.getId()) {
|
||||||
portfolioQueryWrapper.lambda().eq(Portfolio::getProjectId, portfolioDTO.getProjectId());
|
portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||||
List<Portfolio> portfolioList = portfolioMapper.selectList(portfolioQueryWrapper);
|
|
||||||
if (!CollectionUtils.isEmpty(portfolioList)) {
|
|
||||||
portfolio = portfolioList.get(0);
|
|
||||||
}
|
}
|
||||||
|
// 关联的项目ID
|
||||||
Long projectId = portfolioDTO.getProjectId();
|
Long projectId = portfolioDTO.getProjectId();
|
||||||
|
// 复制project表
|
||||||
Project project = projectMapper.selectById(projectId);
|
Project project = projectMapper.selectById(projectId);
|
||||||
if (project.getOriginal() == 0) {
|
if (project.getOriginal() != null && project.getOriginal() == 0) {
|
||||||
portfolio.setOriginal(0);
|
portfolio.setOriginal(0);
|
||||||
portfolio.setOriginalAccountId(project.getOriginalAccountId());
|
portfolio.setOriginalAccountId(project.getOriginalAccountId());
|
||||||
// TODO
|
|
||||||
portfolio.setOriginalPortfolioId(project.getOriginalPortfolioId());
|
portfolio.setOriginalPortfolioId(project.getOriginalPortfolioId());
|
||||||
} else {
|
}else {
|
||||||
portfolio.setOriginal(1);
|
portfolio.setOriginal(1);
|
||||||
}
|
}
|
||||||
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
|
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
|
||||||
@@ -178,132 +182,79 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
portfolio.setUpdateDate(LocalDateTime.now());
|
portfolio.setUpdateDate(LocalDateTime.now());
|
||||||
portfolio.setStatus(1);
|
portfolio.setStatus(1);
|
||||||
portfolio.setIsDeleted(0);
|
portfolio.setIsDeleted(0);
|
||||||
portfolio.setUserLikeGroupSourceId(portfolioDTO.getUserLikeGroupId());
|
|
||||||
portfolio.setCanvasId(canvas.getId());
|
portfolio.setCanvasId(canvas.getId());
|
||||||
portfolio.setPortfolioDes(portfolioDTO.getPortfolioDes());
|
portfolio.setPortfolioDes(portfolioDTO.getPortfolioDes());
|
||||||
|
|
||||||
Long workspaceId = workspaceService.getByProjectId(project.getId());
|
|
||||||
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
|
||||||
|
|
||||||
project.setId(null);
|
|
||||||
project.setAccountId(-1L);
|
|
||||||
project.setCreateTime(LocalDateTime.now());
|
|
||||||
projectMapper.insert(project);
|
|
||||||
Long projectIdCopy = project.getId();
|
|
||||||
|
|
||||||
workspace.setProjectId(projectIdCopy);
|
|
||||||
workspace.setAccountId(-1L);
|
|
||||||
workspaceMapper.insert(workspace);
|
|
||||||
|
|
||||||
if (portfolioDTO.getOpenSource() == 1) {
|
if (portfolioDTO.getOpenSource() == 1) {
|
||||||
|
// 副本存储对象
|
||||||
|
ProjectSnapshot projectSnapshot = new ProjectSnapshot();
|
||||||
|
// 根据项目ID获取项目设置
|
||||||
|
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||||
|
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
||||||
|
|
||||||
|
project.setId(null);
|
||||||
|
projectSnapshot.setProject(project);
|
||||||
|
workspace.setId(null);
|
||||||
|
projectSnapshot.setWorkspace(workspace);
|
||||||
|
|
||||||
portfolio.setPortfolioType("History");
|
portfolio.setPortfolioType("History");
|
||||||
portfolio.setOpenSource(1);
|
portfolio.setOpenSource(1);
|
||||||
|
|
||||||
List<CollectionElement> collectionElementListOld = collectionElementService.getByProjectId(projectId);
|
List<CollectionElement> collectionElementListOld = collectionElementService.getByProjectId(projectId);
|
||||||
for (CollectionElement element : collectionElementListOld) {
|
projectSnapshot.setCollectionElementList(collectionElementListOld);
|
||||||
element.setProjectId(projectIdCopy);
|
|
||||||
element.setId(null);
|
|
||||||
collectionElementMapper.insert(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserLikeGroup userLikeGroup = userLikeService.getUserLikeGroupByProjectId(projectId);
|
UserLikeGroup userLikeGroup = userLikeService.getUserLikeGroupByProjectId(projectId);
|
||||||
if (Objects.nonNull(userLikeGroup)) {
|
if (Objects.nonNull(userLikeGroup)) {
|
||||||
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
|
projectSnapshot.setUserLikeGroup(userLikeGroup);
|
||||||
userLikeGroupNew.setId(null);
|
|
||||||
userLikeGroupNew.setAccountId(-1L);
|
|
||||||
userLikeGroupNew.setProjectId(projectIdCopy);
|
|
||||||
Long collectionIdOld = userLikeGroup.getCollectionId();
|
|
||||||
QueryWrapper<Design> designQueryWrapper = new QueryWrapper<>();
|
|
||||||
designQueryWrapper.lambda().eq(Design::getCollectionId, collectionIdOld);
|
|
||||||
Design designOld = designMapper.selectOne(designQueryWrapper);
|
|
||||||
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
|
||||||
|
|
||||||
collectionOld.setId(null);
|
|
||||||
collectionMapper.insert(collectionOld);
|
|
||||||
Long collectionIdNew = collectionOld.getId();
|
|
||||||
|
|
||||||
portfolio.setCollectionId(collectionIdNew);
|
|
||||||
|
|
||||||
for (CollectionElement element : collectionElementListOld) {
|
|
||||||
element.setCollectionId(collectionIdNew);
|
|
||||||
collectionElementMapper.updateById(element);
|
|
||||||
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
|
||||||
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
|
||||||
collectionElementRelationNew.setElementId(element.getId());
|
|
||||||
collectionElementRelationNew.setCreateDate(new Date());
|
|
||||||
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
|
||||||
}
|
|
||||||
|
|
||||||
designOld.setCollectionId(collectionIdNew);
|
|
||||||
designOld.setId(null);
|
|
||||||
designMapper.insert(designOld);
|
|
||||||
userLikeGroupNew.setCollectionId(collectionIdNew);
|
|
||||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
|
||||||
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
|
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
|
||||||
|
List<UserLikeSnapshot> list = new ArrayList<>();
|
||||||
for (UserLike userLike : userLikeList) {
|
for (UserLike userLike : userLikeList) {
|
||||||
|
UserLikeSnapshot userLikeSnapshot = CopyUtil.copyObject(userLike, UserLikeSnapshot.class);
|
||||||
|
|
||||||
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
||||||
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
||||||
designPythonOutfit.setDesignId(-1L);
|
|
||||||
designPythonOutfit.setDesignItemId(-1L);
|
|
||||||
designPythonOutfit.setCollectionId(collectionIdNew);
|
|
||||||
designPythonOutfit.setId(null);
|
|
||||||
Long designItemIdOld = userLike.getDesignItemId();
|
Long designItemIdOld = userLike.getDesignItemId();
|
||||||
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
||||||
designItemOld.setId(null);
|
|
||||||
designItemOld.setAccountId(-1L);
|
|
||||||
designItemOld.setDesignId(-1L);
|
|
||||||
designItemOld.setCollectionId(collectionIdNew);
|
|
||||||
designItemMapper.insert(designItemOld);
|
|
||||||
Long designItemIdNew = designItemOld.getId();
|
|
||||||
|
|
||||||
designPythonOutfit.setDesignItemId(designItemIdNew);
|
userLikeSnapshot.setDesignItem(designItemOld);
|
||||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
userLikeSnapshot.setDesignPythonOutfit(designPythonOutfit);
|
||||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
|
||||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
|
||||||
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
||||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetailList = designPythonOutfitDetailMapper.selectList(qw);
|
||||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
userLikeSnapshot.setTDesignPythonOutfitDetailList(tDesignPythonOutfitDetailList);
|
||||||
tDesignPythonOutfitDetail.setId(null);
|
|
||||||
tDesignPythonOutfitDetail.setDesignId(-1L);
|
|
||||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
|
||||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
|
||||||
}
|
|
||||||
|
|
||||||
userLike.setDesignItemId(designItemIdNew);
|
|
||||||
userLike.setId(null);
|
|
||||||
userLike.setDesignId(-1L);
|
|
||||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
|
||||||
userLikeMapper.insert(userLike);
|
|
||||||
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||||
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemIdOld);
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemIdOld);
|
||||||
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||||
|
List<DesignItemDetailSnapshot> designItemDetailSnapshotList = new ArrayList<>();
|
||||||
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
||||||
|
DesignItemDetailSnapshot designItemDetailSnapshot = CopyUtil.copyObject(designItemDetailOld, DesignItemDetailSnapshot.class);
|
||||||
Long designItemDetailIdOld = designItemDetailOld.getId();
|
Long designItemDetailIdOld = designItemDetailOld.getId();
|
||||||
designItemDetailOld.setId(null);
|
|
||||||
designItemDetailOld.setAccountId(-1L);
|
|
||||||
designItemDetailOld.setDesignId(-1L);
|
|
||||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
|
||||||
designItemDetailMapper.insert(designItemDetailOld);
|
|
||||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
|
||||||
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
||||||
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
||||||
List<DesignItemDetailPrint> designItemDetailPrints = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
||||||
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrints) {
|
designItemDetailSnapshot.setDesignItemDetailPrintList(designItemDetailPrintList);
|
||||||
designItemDetailPrint.setId(null);
|
designItemDetailSnapshotList.add(designItemDetailSnapshot);
|
||||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
|
||||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
userLikeSnapshot.setDesignItemDetailList(designItemDetailSnapshotList);
|
||||||
|
list.add(userLikeSnapshot);
|
||||||
}
|
}
|
||||||
|
projectSnapshot.setUserLikeList(list);
|
||||||
}
|
}
|
||||||
|
String snapshotJson = JSONObject.toJSONString(projectSnapshot);
|
||||||
|
portfolio.setSnapshot(snapshotJson);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
portfolio.setPortfolioType("Canvas");
|
portfolio.setPortfolioType("Canvas");
|
||||||
|
|
||||||
portfolio.setOpenSource(0);
|
portfolio.setOpenSource(0);
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(portfolioList)) {
|
if (null != portfolioDTO.getId()) {
|
||||||
portfolioMapper.updateById(portfolio);
|
portfolioMapper.updateById(portfolio);
|
||||||
} else {
|
} else {
|
||||||
portfolioMapper.insert(portfolio);
|
portfolioMapper.insert(portfolio);
|
||||||
@@ -551,22 +502,25 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||||
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
||||||
if (vo.getOpenSource() == 1) {
|
if (vo.getOpenSource() == 1) {
|
||||||
Long collectionId = portfolio.getCollectionId();
|
if (!StringUtils.isEmpty(portfolio.getSnapshot())) {
|
||||||
List<CollectionElement> collectionElementList = collectionElementService.getByCollectionId(collectionId);
|
ProjectSnapshot projectSnapshot = JSONObject.parseObject(portfolio.getSnapshot(), ProjectSnapshot.class);
|
||||||
for (CollectionElement element : collectionElementList) {
|
List<CollectionElement> collectionElementList = projectSnapshot.getCollectionElementList();
|
||||||
if (StringUtils.isEmpty(element.getUrl())) {
|
for (CollectionElement element : collectionElementList) {
|
||||||
continue;
|
if (StringUtils.isEmpty(element.getUrl())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
element.setUrl(minioUtil.getPreSignedUrl(element.getUrl(), 24 * 60));
|
||||||
}
|
}
|
||||||
element.setUrl(minioUtil.getPreSignedUrl(element.getUrl(), 24 * 60));
|
vo.setCollectionElementList(collectionElementList);
|
||||||
|
List<UserLikeSnapshot> userLikeList = projectSnapshot.getUserLikeList();
|
||||||
|
List<TDesignPythonOutfit> list = new ArrayList<>();
|
||||||
|
for (UserLikeSnapshot userLikeSnapshot : userLikeList) {
|
||||||
|
TDesignPythonOutfit designPythonOutfit = userLikeSnapshot.getDesignPythonOutfit();
|
||||||
|
designPythonOutfit.setDesignUrl(minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
|
||||||
|
list.add(designPythonOutfit);
|
||||||
|
}
|
||||||
|
vo.setDesignPythonOutfitList(list);
|
||||||
}
|
}
|
||||||
vo.setCollectionElementList(collectionElementList);
|
|
||||||
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
|
||||||
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId());
|
|
||||||
List<TDesignPythonOutfit> designPythonOutfitList = designPythonOutfitMapper.selectList(qw);
|
|
||||||
for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) {
|
|
||||||
tDesignPythonOutfit.setDesignUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
|
||||||
}
|
|
||||||
vo.setDesignPythonOutfitList(designPythonOutfitList);
|
|
||||||
}
|
}
|
||||||
Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
|
Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
|
||||||
vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
|
vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
|
||||||
@@ -636,14 +590,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||||
|
|
||||||
Long projectId = portfolio.getProjectId();
|
String snapshot = portfolio.getSnapshot();
|
||||||
|
ProjectSnapshot projectSnapshot = JSONObject.parseObject(snapshot, ProjectSnapshot.class);
|
||||||
|
|
||||||
// QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
Project project = projectSnapshot.getProject();
|
||||||
// userLikeGroupQueryWrapper.lambda().eq(UserLikeGroup::getCollectionId, portfolio.getCollectionId());
|
|
||||||
UserLikeGroup userLikeGroup = userLikeService.getUserLikeGroupByProjectId(projectId);
|
Long projectId = project.getId();
|
||||||
|
|
||||||
|
UserLikeGroup userLikeGroup = projectSnapshot.getUserLikeGroup();
|
||||||
|
|
||||||
Project project = projectMapper.selectById(projectId);
|
|
||||||
// Long projectIdOld = project.getId();
|
|
||||||
project.setCreateTime(LocalDateTime.now());
|
project.setCreateTime(LocalDateTime.now());
|
||||||
project.setId(null);
|
project.setId(null);
|
||||||
project.setAccountId(authPrincipalVo.getId());
|
project.setAccountId(authPrincipalVo.getId());
|
||||||
@@ -667,7 +622,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
|
|
||||||
Long projectIdNew = project.getId();
|
Long projectIdNew = project.getId();
|
||||||
|
|
||||||
List<CollectionElement> collectionElementListOld = collectionElementService.getByProjectId(projectId);
|
List<CollectionElement> collectionElementListOld = projectSnapshot.getCollectionElementList();
|
||||||
for (CollectionElement element : collectionElementListOld) {
|
for (CollectionElement element : collectionElementListOld) {
|
||||||
element.setProjectId(projectIdNew);
|
element.setProjectId(projectIdNew);
|
||||||
element.setId(null);
|
element.setId(null);
|
||||||
@@ -677,7 +632,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
if (Objects.nonNull(userLikeGroup)) {
|
if (Objects.nonNull(userLikeGroup)) {
|
||||||
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
||||||
|
|
||||||
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
|
UserLikeGroup userLikeGroupNew = projectSnapshot.getUserLikeGroup();
|
||||||
userLikeGroupNew.setId(null);
|
userLikeGroupNew.setId(null);
|
||||||
userLikeGroupNew.setCreateDate(new Date());
|
userLikeGroupNew.setCreateDate(new Date());
|
||||||
userLikeGroupNew.setProjectId(projectIdNew);
|
userLikeGroupNew.setProjectId(projectIdNew);
|
||||||
@@ -695,236 +650,78 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
||||||
}
|
}
|
||||||
userLikeGroupNew.setAccountId(authPrincipalVo.getId());
|
userLikeGroupNew.setAccountId(authPrincipalVo.getId());
|
||||||
Long collectionIdOld = userLikeGroup.getCollectionId();
|
|
||||||
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
|
||||||
// List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
|
|
||||||
collectionOld.setId(null);
|
|
||||||
collectionMapper.insert(collectionOld);
|
|
||||||
Long collectionIdNew = collectionOld.getId();
|
|
||||||
|
|
||||||
Long workspaceServiceByProjectId = workspaceService.getByProjectId(projectId);
|
userLikeGroupNew.setCollectionId(null);
|
||||||
Workspace workspace = workspaceMapper.selectById(workspaceServiceByProjectId);
|
|
||||||
Design design = new Design();
|
|
||||||
design.setCollectionId(collectionIdNew);
|
|
||||||
design.setAccountId(authPrincipalVo.getId());
|
|
||||||
if (workspace.getSex().equals(Sex.FEMALE.getValue())) {
|
|
||||||
design.setTemplateId(workspace.getMannequinFemaleId());
|
|
||||||
design.setModelType(workspace.getMannequinFemaleType());
|
|
||||||
} else {
|
|
||||||
design.setTemplateId(workspace.getMannequinMaleId());
|
|
||||||
design.setModelType(workspace.getMannequinMaleType());
|
|
||||||
}
|
|
||||||
design.setSystemScale(BigDecimal.valueOf(workspace.getSystemDesignerPercentage()));
|
|
||||||
if (workspace.getPosition().equals(Position.OVERALL.getValue())) {
|
|
||||||
design.setSingleOverall("overall");
|
|
||||||
design.setSwitchCategory("");
|
|
||||||
} else {
|
|
||||||
design.setSingleOverall("single");
|
|
||||||
design.setSwitchCategory(workspace.getPosition());
|
|
||||||
}
|
|
||||||
design.setCreateDate(new Date());
|
|
||||||
designMapper.insert(design);
|
|
||||||
|
|
||||||
userLikeGroupNew.setCollectionId(collectionIdNew);
|
|
||||||
userLikeGroupNew.setUpdateDate(new Date());
|
userLikeGroupNew.setUpdateDate(new Date());
|
||||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
userLikeGroupMapper.insert(userLikeGroupNew);
|
||||||
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
|
|
||||||
for (CollectionElement element : collectionElementListOld) {
|
|
||||||
element.setCollectionId(collectionIdNew);
|
|
||||||
collectionElementMapper.updateById(element);
|
|
||||||
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
|
||||||
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
|
||||||
collectionElementRelationNew.setElementId(element.getId());
|
|
||||||
collectionElementRelationNew.setCreateDate(new Date());
|
|
||||||
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
List<UserLikeSnapshot> userLikeList = projectSnapshot.getUserLikeList();
|
||||||
|
if (CollectionUtil.isNotEmpty(userLikeList)) {
|
||||||
|
for (UserLikeSnapshot userLike : userLikeList) {
|
||||||
|
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
||||||
|
TDesignPythonOutfit designPythonOutfit = userLike.getDesignPythonOutfit();
|
||||||
|
designPythonOutfit.setDesignId(null);
|
||||||
|
designPythonOutfit.setDesignItemId(-1L);
|
||||||
|
designPythonOutfit.setCollectionId(null);
|
||||||
|
|
||||||
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioUserLikeGroupId);
|
designPythonOutfit.setId(null);
|
||||||
|
designPythonOutfitMapper.insert(designPythonOutfit);
|
||||||
|
Long designOutfitIdNew = designPythonOutfit.getId();
|
||||||
|
userLike.setDesignOutfitId(designOutfitIdNew);
|
||||||
|
|
||||||
for (UserLike userLike : userLikeList) {
|
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
||||||
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
||||||
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = userLike.getTDesignPythonOutfitDetailList();
|
||||||
designPythonOutfit.setDesignId(design.getId());
|
if (CollectionUtil.isNotEmpty(tDesignPythonOutfitDetails)){
|
||||||
designPythonOutfit.setDesignItemId(-1L);
|
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||||
designPythonOutfit.setCollectionId(collectionIdNew);
|
tDesignPythonOutfitDetail.setId(null);
|
||||||
|
tDesignPythonOutfitDetail.setDesignId(null);
|
||||||
|
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
||||||
|
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
designPythonOutfit.setId(null);
|
DesignItem designItemOld = userLike.getDesignItem();
|
||||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
designItemOld.setId(null);
|
||||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
designItemOld.setAccountId(authPrincipalVo.getId());
|
||||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
designItemOld.setDesignId(null);
|
||||||
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
designItemOld.setCollectionId(null);
|
||||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
designItemMapper.insert(designItemOld);
|
||||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
Long designItemIdNew = designItemOld.getId();
|
||||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
|
||||||
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
|
|
||||||
tDesignPythonOutfitDetail.setId(null);
|
|
||||||
tDesignPythonOutfitDetail.setDesignId(design.getId());
|
|
||||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
|
||||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
|
||||||
}
|
|
||||||
|
|
||||||
Long designItemIdOld = userLike.getDesignItemId();
|
designPythonOutfit.setDesignItemId(designItemIdNew);
|
||||||
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
designPythonOutfitMapper.updateById(designPythonOutfit);
|
||||||
designItemOld.setId(null);
|
|
||||||
designItemOld.setAccountId(authPrincipalVo.getId());
|
|
||||||
designItemOld.setDesignId(design.getId());
|
|
||||||
designItemOld.setCollectionId(collectionIdNew);
|
|
||||||
designItemMapper.insert(designItemOld);
|
|
||||||
Long designItemIdNew = designItemOld.getId();
|
|
||||||
|
|
||||||
designPythonOutfit.setDesignItemId(designItemIdNew);
|
userLike.setDesignItemId(designItemIdNew);
|
||||||
designPythonOutfitMapper.updateById(designPythonOutfit);
|
userLike.setId(null);
|
||||||
|
userLike.setDesignId(null);
|
||||||
|
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
||||||
|
userLikeMapper.insert(userLike);
|
||||||
|
|
||||||
userLike.setDesignItemId(designItemIdNew);
|
List<DesignItemDetailSnapshot> designItemDetailList = userLike.getDesignItemDetailList();
|
||||||
userLike.setId(null);
|
if (CollectionUtil.isNotEmpty(designItemDetailList)) {
|
||||||
userLike.setDesignId(design.getId());
|
for (DesignItemDetailSnapshot designItemDetailOld : designItemDetailList) {
|
||||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
designItemDetailOld.setId(null);
|
||||||
userLikeMapper.insert(userLike);
|
designItemDetailOld.setAccountId(authPrincipalVo.getId());
|
||||||
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
designItemDetailOld.setDesignId(null);
|
||||||
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemIdOld);
|
designItemDetailOld.setDesignItemId(designItemIdNew);
|
||||||
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
designItemDetailMapper.insert(designItemDetailOld);
|
||||||
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
Long designItemDetailIdNew = designItemDetailOld.getId();
|
||||||
Long designItemDetailIdOld = designItemDetailOld.getId();
|
|
||||||
designItemDetailOld.setId(null);
|
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailOld.getDesignItemDetailPrintList();
|
||||||
designItemDetailOld.setAccountId(authPrincipalVo.getId());
|
if (CollectionUtil.isNotEmpty(designItemDetailPrintList)) {
|
||||||
designItemDetailOld.setDesignId(design.getId());
|
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
||||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
designItemDetailPrint.setId(null);
|
||||||
designItemDetailMapper.insert(designItemDetailOld);
|
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
||||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
||||||
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
}
|
||||||
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
}
|
||||||
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
}
|
||||||
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
|
||||||
designItemDetailPrint.setId(null);
|
|
||||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
|
||||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Workspace workspaceCopy = projectSnapshot.getWorkspace();
|
||||||
|
|
||||||
// Long collectionId = portfolio.getCollectionId();
|
|
||||||
// QueryWrapper<Design> getWorkspaceQw = new QueryWrapper<>();
|
|
||||||
// getWorkspaceQw.lambda().eq(Design::getCollectionId, collectionId);
|
|
||||||
// List<Design> designs = designMapper.selectList(getWorkspaceQw);
|
|
||||||
// if (!CollectionUtils.isEmpty(designs)) {
|
|
||||||
// Design design1 = designs.get(0);
|
|
||||||
// Long accountId = authPrincipalVo.getId();
|
|
||||||
// QueryWrapper<Workspace> currentWorkspaceQw = new QueryWrapper<>();
|
|
||||||
// currentWorkspaceQw.lambda().eq(Workspace::getAccountId, accountId);
|
|
||||||
// currentWorkspaceQw.lambda().eq(Workspace::getIsLastIndex, 1);
|
|
||||||
// List<Workspace> workspaces = workspaceMapper.selectList(currentWorkspaceQw);
|
|
||||||
// if (!CollectionUtils.isEmpty(workspaces)) {
|
|
||||||
// Workspace workspace1 = workspaces.get(0);
|
|
||||||
// workspace1.setIsLastIndex(0);
|
|
||||||
// workspaceMapper.updateById(workspace1);
|
|
||||||
// Workspace workspaceNew = new Workspace();
|
|
||||||
// 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);
|
|
||||||
// workspaceNew.setCreateTime(LocalDateTime.now());
|
|
||||||
// workspaceNew.setSystemDesignerPercentage((design1.getSystemScale().multiply(BigDecimal.valueOf(100)).intValue()));
|
|
||||||
// if (design1.getSingleOverall().equals("overall")) {
|
|
||||||
// workspaceNew.setPosition("Overall");
|
|
||||||
// } else {
|
|
||||||
// workspaceNew.setPosition(design1.getSwitchCategory());
|
|
||||||
// }
|
|
||||||
// workspaceMapper.insert(workspaceNew);
|
|
||||||
// if (design1.getModelType().equals("System")) {
|
|
||||||
// SysFile sysFile = sysFileMapper.selectById(design1.getTemplateId());
|
|
||||||
// if (sysFile.getLevel2Type().equals("Female")) {
|
|
||||||
// workspaceNew.setSex("Female");
|
|
||||||
// workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
|
||||||
// workspaceNew.setMannequinFemaleType("System");
|
|
||||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
|
||||||
// if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
|
||||||
// QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
|
||||||
// styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
|
||||||
// Style style = styleMapper.selectOne(styleQueryWrapper);
|
|
||||||
// WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
|
||||||
// workspaceRelStyle.setStyleId(style.getId());
|
|
||||||
// workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
|
||||||
// workspaceRelStyleMapper.insert(workspaceRelStyle);
|
|
||||||
// }
|
|
||||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
|
||||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
|
||||||
// SysFile anotherOne = anotherList.get(0);
|
|
||||||
// workspaceNew.setMannequinMaleId(anotherOne.getId());
|
|
||||||
// workspaceNew.setMannequinMaleType("System");
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// workspaceNew.setSex("Male");
|
|
||||||
// workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
|
||||||
// workspaceNew.setMannequinMaleType("System");
|
|
||||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
|
||||||
// if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
|
||||||
// QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
|
||||||
// styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
|
||||||
// Style style = styleMapper.selectOne(styleQueryWrapper);
|
|
||||||
// WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
|
||||||
// workspaceRelStyle.setStyleId(style.getId());
|
|
||||||
// workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
|
||||||
// workspaceRelStyleMapper.insert(workspaceRelStyle);
|
|
||||||
// }
|
|
||||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
|
||||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
|
||||||
// SysFile anotherOne = anotherList.get(0);
|
|
||||||
// workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
|
||||||
// workspaceNew.setMannequinFemaleType("System");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// Library library = libraryMapper.selectById(design1.getTemplateId());
|
|
||||||
// if (library.getLevel2Type().equals("Female")) {
|
|
||||||
// workspaceNew.setSex("Female");
|
|
||||||
// workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
|
||||||
// workspaceNew.setMannequinFemaleType("Library");
|
|
||||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
|
||||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
|
||||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
|
||||||
// SysFile anotherOne = anotherList.get(0);
|
|
||||||
// workspaceNew.setMannequinMaleId(anotherOne.getId());
|
|
||||||
// workspaceNew.setMannequinMaleType("System");
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// workspaceNew.setSex("Male");
|
|
||||||
// workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
|
||||||
// workspaceNew.setMannequinMaleType("Library");
|
|
||||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
|
||||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
|
||||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
|
||||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
|
||||||
// SysFile anotherOne = anotherList.get(0);
|
|
||||||
// workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
|
||||||
// workspaceNew.setMannequinFemaleType("System");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// workspaceMapper.updateById(workspaceNew);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
Long workspaceIdOld = workspaceService.getByProjectId(projectId);
|
|
||||||
Workspace workspaceCopy = workspaceMapper.selectById(workspaceIdOld);
|
|
||||||
workspaceCopy.setAccountId(authPrincipalVo.getId());
|
workspaceCopy.setAccountId(authPrincipalVo.getId());
|
||||||
workspaceCopy.setProjectId(projectIdNew);
|
workspaceCopy.setProjectId(projectIdNew);
|
||||||
workspaceCopy.setId(null);
|
workspaceCopy.setId(null);
|
||||||
|
|||||||
68
src/main/java/com/ai/da/service/impl/ProjectServiceImpl.java
Normal file
68
src/main/java/com/ai/da/service/impl/ProjectServiceImpl.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
package com.ai.da.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
|
import com.ai.da.common.config.FileProperties;
|
||||||
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
|
import com.ai.da.common.context.UserContext;
|
||||||
|
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||||
|
import com.ai.da.common.enums.DesignTypeEnum;
|
||||||
|
import com.ai.da.common.enums.SingleOverallEnum;
|
||||||
|
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
||||||
|
import com.ai.da.common.utils.*;
|
||||||
|
import com.ai.da.mapper.primary.*;
|
||||||
|
import com.ai.da.mapper.primary.entity.Collection;
|
||||||
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
|
import com.ai.da.model.dto.*;
|
||||||
|
import com.ai.da.model.vo.*;
|
||||||
|
import com.ai.da.python.PythonService;
|
||||||
|
import com.ai.da.python.vo.*;
|
||||||
|
import com.ai.da.service.*;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONException;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.ai.da.python.vo.DesignPythonItem.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
|
||||||
|
@Resource
|
||||||
|
private ProjectMapper projectMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Long> getChildProjectIdSet(Long projectId) {
|
||||||
|
QueryWrapper<Project> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(Project::getParentId, projectId);
|
||||||
|
List<Project> projectList = projectMapper.selectList(qw);
|
||||||
|
if (CollectionUtil.isNotEmpty(projectList)) {
|
||||||
|
return projectList.stream().map(Project::getId).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -355,6 +355,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
private ToProductImageRecordMapper toProductImageRecordMapper;
|
private ToProductImageRecordMapper toProductImageRecordMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ToProductImageResultMapper toProductImageResultMapper;
|
private ToProductImageResultMapper toProductImageResultMapper;
|
||||||
|
@Resource
|
||||||
|
private CloudTaskMapper cloudTaskMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PythonService pythonService;
|
private PythonService pythonService;
|
||||||
@@ -1283,6 +1285,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
queryWrapper.eq("account_id", authPrincipalVo.getId());
|
queryWrapper.eq("account_id", authPrincipalVo.getId());
|
||||||
|
queryWrapper.isNull("parent_id");
|
||||||
if (!StringUtils.isEmpty(query.getProjectName())) {
|
if (!StringUtils.isEmpty(query.getProjectName())) {
|
||||||
queryWrapper.like("name", query.getProjectName());
|
queryWrapper.like("name", query.getProjectName());
|
||||||
}
|
}
|
||||||
@@ -1400,51 +1403,35 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
MoodBoardModuleChooseVO moodBoardModuleChooseVO = new MoodBoardModuleChooseVO();
|
MoodBoardModuleChooseVO moodBoardModuleChooseVO = new MoodBoardModuleChooseVO();
|
||||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||||
// qw.lambda().ne(CollectionElement::getCollectionId, 0);
|
|
||||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||||
Long collectionId = null;
|
|
||||||
|
List<CollectionElementVO> list = new ArrayList<>();
|
||||||
for (CollectionElement collectionElement : collectionElements) {
|
for (CollectionElement collectionElement : collectionElements) {
|
||||||
if (collectionElement.getCollectionId() != null) {
|
if (null != collectionElement.getIsCompositeImage() && collectionElement.getIsCompositeImage() == 1) {
|
||||||
collectionId = collectionElement.getCollectionId();
|
moodBoardModuleChooseVO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
||||||
break;
|
moodBoardModuleChooseVO.setMoodTemplateName(collectionElement.getName());
|
||||||
}
|
moodBoardModuleChooseVO.setMoodTemplateUrl(minioUtil.getPreSignedUrl(collectionElement.getUrl(), 24 * 60));
|
||||||
}
|
|
||||||
Collection collection = collectionService.getById(collectionId);
|
String moodboardPositionString = collectionService.getMoodboardPositionString(collectionElement.getId());
|
||||||
if (Objects.nonNull(collection)) {
|
if (!StringUtils.isEmpty(moodboardPositionString)) {
|
||||||
if (null != collection.getMoodboardPosition()) {
|
|
||||||
String moodboardPositionString = collectionService.getMoodboardPositionString(collection.getId());
|
|
||||||
if (StringUtils.isEmpty(moodboardPositionString)) {
|
|
||||||
moodBoardModuleChooseVO.setMoodboardPosition(collection.getMoodboardPosition());
|
|
||||||
}else {
|
|
||||||
moodBoardModuleChooseVO.setMoodboardPosition(moodboardPositionString);
|
moodBoardModuleChooseVO.setMoodboardPosition(moodboardPositionString);
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (collection.getMoodTemplateId() != null) {
|
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||||
CollectionElement layoutElement = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
moodBoardModuleChooseVO.setMoodTemplateId(collection.getMoodTemplateId());
|
String url = collectionElement.getUrl();
|
||||||
moodBoardModuleChooseVO.setMoodTemplateName(layoutElement.getName());
|
collectionElementVO.setOriginalUrl(url);
|
||||||
moodBoardModuleChooseVO.setMoodTemplateUrl(minioUtil.getPreSignedUrl(layoutElement.getUrl(), 24 * 60));
|
if (minioUtil.doesObjectExist(url)) {
|
||||||
|
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||||
}
|
}
|
||||||
List<CollectionElementVO> list = new ArrayList<>();
|
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
||||||
for (CollectionElement collectionElement : collectionElements) {
|
list.add(collectionElementVO);
|
||||||
if (Objects.equals(collectionElement.getId(), Long.valueOf(collection.getMoodTemplateId()))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
|
||||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
|
||||||
String url = collectionElement.getUrl();
|
|
||||||
collectionElementVO.setOriginalUrl(url);
|
|
||||||
if (minioUtil.doesObjectExist(url)) {
|
|
||||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
|
||||||
}
|
|
||||||
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
|
||||||
list.add(collectionElementVO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
moodBoardModuleChooseVO.setMoodBoards(list);
|
|
||||||
moduleChooseVO.setMoodBoard(moodBoardModuleChooseVO);
|
|
||||||
}
|
}
|
||||||
|
moodBoardModuleChooseVO.setMoodBoards(list);
|
||||||
|
moduleChooseVO.setMoodBoard(moodBoardModuleChooseVO);
|
||||||
}else if (module.equals(Module.printBoard.name())) {
|
}else if (module.equals(Module.printBoard.name())) {
|
||||||
|
|
||||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||||
@@ -1655,8 +1642,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
List<ThreeDModule> threeDModules = threeDModuleMapper.selectList(qw);
|
List<ThreeDModule> threeDModules = threeDModuleMapper.selectList(qw);
|
||||||
if (CollectionUtil.isNotEmpty(threeDModules)) {
|
if (CollectionUtil.isNotEmpty(threeDModules)) {
|
||||||
ThreeDModule threeDModule = threeDModules.get(0);
|
ThreeDModule threeDModule = threeDModules.get(0);
|
||||||
ThreeDVO patternMaking3D = getLayoutDetail(threeDModule.getThreeDSimpleId());
|
if (null != threeDModule.getThreeDSimpleId()){
|
||||||
moduleChooseVO.setPatternMaking3D(patternMaking3D);
|
ThreeDModuleVO threeDModuleVO = CopyUtil.copyObject(threeDModule, ThreeDModuleVO.class);
|
||||||
|
if (null != threeDModule.getCollectionElementId()) {
|
||||||
|
CollectionElement collectionElement = collectionElementMapper.selectById(threeDModule.getCollectionElementId());
|
||||||
|
if (Objects.nonNull(collectionElement)) {
|
||||||
|
threeDModuleVO.setPrintMinioUrl(minioUtil.getPreSignedUrl(collectionElement.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moduleChooseVO.setPatternMaking3D(threeDModuleVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1677,6 +1672,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
CollectionElement compositeImage = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
|
CollectionElement compositeImage = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
|
||||||
if (compositeImage.getProjectId() == null) {
|
if (compositeImage.getProjectId() == null) {
|
||||||
compositeImage.setProjectId(moduleSaveDTO.getProjectId());
|
compositeImage.setProjectId(moduleSaveDTO.getProjectId());
|
||||||
|
compositeImage.setIsCompositeImage(1);
|
||||||
collectionElementMapper.updateById(compositeImage);
|
collectionElementMapper.updateById(compositeImage);
|
||||||
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
|
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
|
||||||
// 合成图位置信息通过collectElementId关联(旧逻辑通过collectionId关联)
|
// 合成图位置信息通过collectElementId关联(旧逻辑通过collectionId关联)
|
||||||
@@ -1904,7 +1900,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
collectionElementMapper.deleteBatchIds(old);
|
collectionElementMapper.deleteBatchIds(old);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (moduleSaveDTO.getPatternMaking3D() != null) {
|
if (Objects.nonNull(moduleSaveDTO.getPatternMaking3D())) {
|
||||||
|
PatternMaking3DDTO patternMaking3D = moduleSaveDTO.getPatternMaking3D();
|
||||||
|
|
||||||
QueryWrapper<ThreeDModule> threeDModuleQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ThreeDModule> threeDModuleQueryWrapper = new QueryWrapper<>();
|
||||||
threeDModuleQueryWrapper.lambda().eq(ThreeDModule::getProjectId, projectId);
|
threeDModuleQueryWrapper.lambda().eq(ThreeDModule::getProjectId, projectId);
|
||||||
@@ -1913,12 +1910,18 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
if (CollectionUtils.isEmpty(threeDModuleList)) {
|
if (CollectionUtils.isEmpty(threeDModuleList)) {
|
||||||
ThreeDModule threeDModule = new ThreeDModule();
|
ThreeDModule threeDModule = new ThreeDModule();
|
||||||
threeDModule.setProjectId(projectId);
|
threeDModule.setProjectId(projectId);
|
||||||
threeDModule.setThreeDSimpleId(moduleSaveDTO.getPatternMaking3D());
|
threeDModule.setThreeDSimpleId(patternMaking3D.getThreeDSimpleId());
|
||||||
|
threeDModule.setX(patternMaking3D.getX());
|
||||||
|
threeDModule.setY(patternMaking3D.getY());
|
||||||
|
threeDModule.setCollectionElementId(patternMaking3D.getCollectionElementId());
|
||||||
threeDModuleMapper.insert(threeDModule);
|
threeDModuleMapper.insert(threeDModule);
|
||||||
}else {
|
}else {
|
||||||
ThreeDModule threeDModule = threeDModuleList.get(0);
|
ThreeDModule threeDModule = threeDModuleList.get(0);
|
||||||
if (!Objects.equals(moduleSaveDTO.getPatternMaking3D(), threeDModule.getThreeDSimpleId())) {
|
if (!Objects.equals(patternMaking3D.getThreeDSimpleId(), threeDModule.getThreeDSimpleId())) {
|
||||||
threeDModule.setThreeDSimpleId(moduleSaveDTO.getPatternMaking3D());
|
threeDModule.setThreeDSimpleId(patternMaking3D.getThreeDSimpleId());
|
||||||
|
threeDModule.setX(patternMaking3D.getX());
|
||||||
|
threeDModule.setY(patternMaking3D.getY());
|
||||||
|
threeDModule.setCollectionElementId(patternMaking3D.getCollectionElementId());
|
||||||
threeDModuleMapper.updateById(threeDModule);
|
threeDModuleMapper.updateById(threeDModule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2217,4 +2220,98 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
brandDNAMapper.deleteById(brandDNADTO.getId());
|
brandDNAMapper.deleteById(brandDNADTO.getId());
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toProductBatch(String taskId, String url, String progress) {
|
||||||
|
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
|
||||||
|
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
|
||||||
|
if (Objects.nonNull(toProductImageResult)) {
|
||||||
|
toProductImageResult.setUrl(url);
|
||||||
|
toProductImageResultMapper.updateById(toProductImageResult);
|
||||||
|
String taskIdBatch = toProductImageResult.getTaskIdBatch();
|
||||||
|
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||||
|
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||||
|
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||||
|
if (Objects.nonNull(cloudTask)) {
|
||||||
|
if (cloudTask.getCompletedNum() == null) {
|
||||||
|
cloudTask.setCompletedNum(1);
|
||||||
|
}else {
|
||||||
|
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||||
|
}
|
||||||
|
if (progress.equals("OK")) {
|
||||||
|
cloudTask.setStatus(1);
|
||||||
|
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||||
|
}
|
||||||
|
cloudTaskMapper.updateById(cloudTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = toProductImageResultKey + ":" + taskId;
|
||||||
|
String imageName = url.substring(url.lastIndexOf("/") + 1);
|
||||||
|
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||||
|
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, null);
|
||||||
|
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.TO_PRODUCT_IMAGE.getName(),
|
||||||
|
CreditsEventsEnum.TO_PRODUCT_IMAGE.getValue(),
|
||||||
|
"negative", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void relightBatch(String taskId, String url, String progress) {
|
||||||
|
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
|
||||||
|
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
|
||||||
|
if (Objects.nonNull(toProductImageResult)) {
|
||||||
|
if (toProductImageResult.getBrightenValue() != null && toProductImageResult.getBrightenValue() != 1.0) {
|
||||||
|
pythonService.bright(url, toProductImageResult.getBrightenValue());
|
||||||
|
}
|
||||||
|
toProductImageResult.setUrl(url);
|
||||||
|
toProductImageResult.setResultType("Relight");
|
||||||
|
toProductImageResultMapper.updateById(toProductImageResult);
|
||||||
|
|
||||||
|
String taskIdBatch = toProductImageResult.getTaskIdBatch();
|
||||||
|
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||||
|
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||||
|
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||||
|
if (Objects.nonNull(cloudTask)) {
|
||||||
|
if (cloudTask.getCompletedNum() == null) {
|
||||||
|
cloudTask.setCompletedNum(1);
|
||||||
|
}else {
|
||||||
|
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||||
|
}
|
||||||
|
if (progress.equals("OK")) {
|
||||||
|
cloudTask.setStatus(1);
|
||||||
|
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||||
|
}
|
||||||
|
cloudTaskMapper.updateById(cloudTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = relightResultKey + ":" + taskId;
|
||||||
|
String imageName = url.substring(url.lastIndexOf("/") + 1);
|
||||||
|
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||||
|
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, null);
|
||||||
|
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", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ rabbitmq.queues.toProductImageResult=ToProductImage-dev
|
|||||||
rabbitmq.queues.relightResult=Relight-dev
|
rabbitmq.queues.relightResult=Relight-dev
|
||||||
rabbitmq.queues.poseTransform=PoseTransform-dev
|
rabbitmq.queues.poseTransform=PoseTransform-dev
|
||||||
rabbitmq.exchange.generate=generate-exchange
|
rabbitmq.exchange.generate=generate-exchange
|
||||||
|
rabbitmq.queues.designBatch=DesignBatch-dev
|
||||||
|
rabbitmq.queues.relightBatch=BatchRelight-dev
|
||||||
|
rabbitmq.queues.toProductImageBatch=BatchToProductImage-dev
|
||||||
|
rabbitmq.queues.poseTransformBatch=BatchPoseTransform-dev
|
||||||
|
|
||||||
orderList.link=https://develop.aida.com.hk/home/homePage?order=
|
orderList.link=https://develop.aida.com.hk/home/homePage?order=
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user