Merge remote-tracking branch 'origin/dev/dev' into dev/dev
# Conflicts: # src/main/java/com/ai/da/mapper/primary/entity/DesignItem.java
This commit is contained in:
@@ -27,7 +27,9 @@ public enum CollectionLevel1TypeEnum {
|
||||
/**
|
||||
* 市场
|
||||
*/
|
||||
MARKETING_SKETCH("MarketingSketch");
|
||||
MARKETING_SKETCH("MarketingSketch"),
|
||||
|
||||
MODEL("Models");
|
||||
|
||||
private String realName;
|
||||
|
||||
|
||||
@@ -55,17 +55,21 @@ public class LLMController {
|
||||
@CrossOrigin
|
||||
@GetMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public SseEmitter streamPrompt(@RequestParam String prompt,
|
||||
@RequestParam Long projectId,
|
||||
@RequestParam(required = false) Long projectId,
|
||||
@RequestParam(required = false) String fileUrl,
|
||||
@RequestParam(required = false) List<String> imageUrlList,
|
||||
@RequestParam String token) {
|
||||
return llmService.stream(prompt, projectId, fileUrl, imageUrlList, token);
|
||||
@RequestParam(required = false) String process,
|
||||
@RequestParam String token,
|
||||
@RequestParam Boolean enableThinking) {
|
||||
return llmService.stream(prompt, projectId, fileUrl, imageUrlList, token, enableThinking, process);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "对话创建项目")
|
||||
@GetMapping(value = "/chatCreateProject")
|
||||
public Response<Long> chatCreateProject(@RequestParam String prompt, @RequestParam String process) {
|
||||
return Response.success(llmService.chatCreateProject(prompt, process));
|
||||
public Response<Long> chatCreateProject(@RequestParam String prompt, @RequestParam String process,
|
||||
@RequestParam(required = false) String fileUrl,
|
||||
@RequestParam(required = false) List<String> imageUrlList) {
|
||||
return Response.success(llmService.chatCreateProject(prompt, process, fileUrl, imageUrlList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "上传文件")
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElementRelModel;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface CollectionElementRelModelMapper extends CommonMapper<CollectionElementRelModel> {
|
||||
|
||||
}
|
||||
@@ -31,5 +31,7 @@ public class ChatMessage implements Serializable {
|
||||
|
||||
private Long accountId;
|
||||
|
||||
private Integer isImage;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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 lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("collection_element_rel_model")
|
||||
public class CollectionElementRelModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long relationId;
|
||||
|
||||
private String relationType;
|
||||
|
||||
private Long collectionElementId;
|
||||
|
||||
private String ageGroup;
|
||||
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class Workspace implements Serializable {
|
||||
|
||||
private Long projectId;
|
||||
|
||||
private Integer userBrandDna;
|
||||
private Long userBrandDna;
|
||||
|
||||
private Integer brandPercentage;
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ public class DesignCollectionDTO {
|
||||
@ApiModelProperty("手稿板图片id 数组")
|
||||
private List<CollectionSketchDTO> sketchBoards;
|
||||
|
||||
private List<MannequinDTO> mannequins;
|
||||
|
||||
@NotNull(message = "systemScale.cannot.be.empty")
|
||||
@ApiModelProperty("系统取图比列")
|
||||
private BigDecimal systemScale;
|
||||
|
||||
@@ -9,6 +9,9 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class MannequinDTO {
|
||||
private Long id;
|
||||
|
||||
private Long collectionElementId;
|
||||
|
||||
private String type;
|
||||
// private String modelType;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.model.vo.CollectionColorVO;
|
||||
import com.ai.da.model.vo.CollectionElementVO;
|
||||
import com.ai.da.model.vo.MoodBoardModuleChooseVO;
|
||||
@@ -29,6 +30,8 @@ public class ModuleSaveDTO {
|
||||
|
||||
private PatternMaking3DDTO patternMaking3D;
|
||||
|
||||
private List<MannequinDTO> mannequin;
|
||||
|
||||
// private MoodBoardModuleChooseVO moodBoard;
|
||||
// private List<CollectionElementVO> printBoard;
|
||||
// private List<CollectionColorVO> colorBoard;
|
||||
|
||||
@@ -31,6 +31,8 @@ public class QueryLibraryPageServiceDTO extends PageQueryBaseVo {
|
||||
@ApiModelProperty("1交集2并集")
|
||||
private Integer intersection;
|
||||
|
||||
private String ageGroup;
|
||||
|
||||
private Long brandId;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ public class ReceiveCollectionElement {
|
||||
private String level2Type;
|
||||
private String rgb;
|
||||
private String hsv;
|
||||
private String minioUrl;
|
||||
}
|
||||
|
||||
8
src/main/java/com/ai/da/model/vo/ChatMessageVO.java
Normal file
8
src/main/java/com/ai/da/model/vo/ChatMessageVO.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.ChatMessage;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ChatMessageVO extends ChatMessage {
|
||||
}
|
||||
@@ -46,4 +46,7 @@ public class CollectionElementVO {
|
||||
|
||||
private List<String> segmentedImages;
|
||||
|
||||
private Long mannequinRelationId;
|
||||
private String mannequinRelationType;
|
||||
|
||||
}
|
||||
|
||||
@@ -40,5 +40,9 @@ public class DesignLibraryModelPointVO implements Serializable {
|
||||
|
||||
private String templateUrl;
|
||||
|
||||
private Long relationId;
|
||||
|
||||
private String relationType;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,6 @@ public class ModuleChooseVO {
|
||||
private SketchReconstructionVO deReconstruction;
|
||||
|
||||
private ThreeDModuleVO patternMaking3D;
|
||||
|
||||
private List<CollectionElementVO> mannequin;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@ApiModel("用户choose详细-响应")
|
||||
@@ -15,7 +17,7 @@ public class UserLikeChooseVO {
|
||||
private Long userGroupId;
|
||||
|
||||
@ApiModelProperty("分组详细数组")
|
||||
private java.util.List<UserLikeVO> userLikeDetails;
|
||||
private List<UserLikeVO> userLikeDetails;
|
||||
|
||||
@ApiModelProperty("关联的collection")
|
||||
private UserLikeCollectionVO collection;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
import com.ai.da.model.dto.CollectionColorDTO;
|
||||
import com.ai.da.model.dto.MannequinDTO;
|
||||
import com.ai.da.python.vo.DesignPythonItemPrint;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -59,4 +60,6 @@ public class ValidateElementVO {
|
||||
private Long brandId;
|
||||
|
||||
private Double brandScale;
|
||||
private List<DesignLibraryModelPointVO> mannequins;
|
||||
private DesignLibraryModelPointVO designLibraryModelPointVO;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ public class WorkspaceVO extends Workspace {
|
||||
|
||||
private String style;
|
||||
|
||||
private String userBrandDnaImg;
|
||||
private String userBrandDnaName;
|
||||
|
||||
private Map<String, List<String>> allKeywordsByStyle;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.google.common.collect.Maps;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -45,7 +44,6 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -350,7 +348,7 @@ public class PythonService {
|
||||
private DesignPythonObject createDesignPythonObject(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale, String singleOverall, String switchCategory, int i) {
|
||||
DesignPythonObject pythonObject = new DesignPythonObject();
|
||||
pythonObject.setItems(coverToDesignPythonItemNew(elementVO, designPictureType, systemScale));
|
||||
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
|
||||
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint(), elementVO.getDesignLibraryModelPointVO()));
|
||||
if (CollectionUtil.isNotEmpty(elementVO.getRequestIdList())) {
|
||||
pythonObject.setObjectSign(elementVO.getRequestIdList().get(i));
|
||||
}
|
||||
@@ -1698,12 +1696,20 @@ public class PythonService {
|
||||
//类型
|
||||
pythonItem.setType(type);
|
||||
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(type)) {
|
||||
if (Objects.nonNull(designLibraryModelPoint)) {
|
||||
pythonItem.setBody_path(designLibraryModelPoint.getTemplateUrl());
|
||||
if (!CollectionUtils.isEmpty(elementVO.getMannequins())) {
|
||||
DesignLibraryModelPointVO vo = getRandomDesignLibraryModelPoint(elementVO.getMannequins());
|
||||
pythonItem.setBody_path(vo.getTemplateUrl());
|
||||
elementVO.setDesignLibraryModelPointVO(vo);
|
||||
} else {
|
||||
// pythonItem.setBody_path("/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png");
|
||||
pythonItem.setBody_path("aida-mannequins/model_1693218345.2714432.png");
|
||||
}
|
||||
// if (Objects.nonNull(designLibraryModelPoint)) {
|
||||
// pythonItem.setBody_path(designLibraryModelPoint.getTemplateUrl());
|
||||
// } else {
|
||||
//// pythonItem.setBody_path("/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png");
|
||||
// pythonItem.setBody_path("aida-mannequins/model_1693218345.2714432.png");
|
||||
// }
|
||||
} else {
|
||||
SysFileVO sysFileVO = getRandomSysFileByLevel2Type(type, Lists.newArrayList(), elementVO.getModelSex());
|
||||
pythonItem.setPath(sysFileVO.getUrl());
|
||||
@@ -2169,7 +2175,7 @@ public class PythonService {
|
||||
}
|
||||
|
||||
private DesignPythonBasic coverToBasic(DesignPythonItem designPythonItem, String singleOverall,
|
||||
String switchCategory, DesignLibraryModelPointVO designLibraryModelPoint) {
|
||||
String switchCategory, DesignLibraryModelPointVO designLibraryModelPoint, DesignLibraryModelPointVO designLibraryModelPointVO) {
|
||||
DesignPythonBasic basic = new DesignPythonBasic();
|
||||
basic.setSingle_overall(singleOverall);
|
||||
basic.setSwitch_category(switchCategory);
|
||||
@@ -2182,12 +2188,24 @@ public class PythonService {
|
||||
basic.setSelf_template(Boolean.TRUE);
|
||||
}
|
||||
basic.setScale_earrings(0.16);
|
||||
basic.setBody_point_test(getMap(designLibraryModelPoint));
|
||||
if (Objects.nonNull(designLibraryModelPointVO)) {
|
||||
basic.setBody_point_test(getMap(designLibraryModelPointVO));
|
||||
}else {
|
||||
basic.setBody_point_test(getMap(designLibraryModelPoint));
|
||||
}
|
||||
return basic;
|
||||
}
|
||||
|
||||
private Map<String, List<Integer>> getMap(DesignLibraryModelPointVO designLibraryModelPointOld) {
|
||||
Map<String, List<Integer>> body_point = Maps.newHashMap();
|
||||
private DesignLibraryModelPointVO getRandomDesignLibraryModelPoint(List<DesignLibraryModelPointVO> mannequins) {
|
||||
DesignLibraryModelPointVO vo = new DesignLibraryModelPointVO();
|
||||
Random random = new Random();
|
||||
int randomNumber = random.nextInt(mannequins.size());
|
||||
return mannequins.get(randomNumber);
|
||||
|
||||
}
|
||||
|
||||
private Map<String, Object> getMap(DesignLibraryModelPointVO designLibraryModelPointOld) {
|
||||
Map<String, Object> body_point = Maps.newHashMap();
|
||||
if (Objects.nonNull(designLibraryModelPointOld)) {
|
||||
DesignLibraryModelPointVO designLibraryModelPoint =
|
||||
CopyUtil.copyObject(designLibraryModelPointOld, DesignLibraryModelPointVO.class);
|
||||
@@ -2198,6 +2216,8 @@ public class PythonService {
|
||||
body_point.put("waistband_right", resolve(designLibraryModelPoint.getWaistbandRight()));
|
||||
body_point.put("hand_point_left", resolve(designLibraryModelPoint.getHandLeft()));
|
||||
body_point.put("hand_point_right", resolve(designLibraryModelPoint.getHandRight()));
|
||||
body_point.put("relation_id", designLibraryModelPoint.getRelationId());
|
||||
body_point.put("relation_type", designLibraryModelPoint.getRelationType());
|
||||
} else {
|
||||
//默认是13个点
|
||||
body_point.put("shoulder_left", Arrays.asList(755, 519));
|
||||
@@ -4383,7 +4403,7 @@ public class PythonService {
|
||||
throw new BusinessException("poseTransferBatch.interface.exception");
|
||||
}
|
||||
|
||||
public JSONObject getProjectParam(String prompt) {
|
||||
public JSONObject getProjectParam(String prompt, String fileUrl, List<String> imageUrlList) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
@@ -4393,6 +4413,8 @@ public class PythonService {
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
Map<String, Object> content = Maps.newHashMap();
|
||||
content.put("prompt", prompt);
|
||||
content.put("image_list", !CollectionUtils.isEmpty(imageUrlList) ? imageUrlList : new ArrayList<>());
|
||||
content.put("file_list", !StringUtils.isEmpty(fileUrl) ? Collections.singletonList(fileUrl) : new ArrayList<>());
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
|
||||
log.info("getProjectParam 请求地址: {}", accessPythonIp + ":" + accessPythonPort + "/api/extraction_project_info");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DesignPythonBasic {
|
||||
|
||||
private Double scale_earrings;
|
||||
|
||||
private Map<String, List<Integer>> body_point_test = Maps.newHashMap();
|
||||
private Map<String, Object> body_point_test = Maps.newHashMap();
|
||||
|
||||
private Boolean layer_order = Boolean.FALSE;
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ import java.util.Set;
|
||||
*/
|
||||
public interface LLMService {
|
||||
|
||||
SseEmitter stream(String prompt, Long projectId, String fileUrl, List<String> imageUrlList, String token);
|
||||
SseEmitter stream(String prompt, Long projectId, String fileUrl, List<String> imageUrlList, String token, Boolean enableThinking, String process);
|
||||
|
||||
Long chatCreateProject(String prompt, String process);
|
||||
Long chatCreateProject(String prompt, String process, String fileUrl, List<String> imageUrlList);
|
||||
|
||||
List<String> uploadFile(MultipartFile file);
|
||||
|
||||
|
||||
@@ -601,18 +601,37 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
}
|
||||
// 校验模特
|
||||
if (!StringUtils.isEmpty(designDTO.getModelType())) {
|
||||
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
Library byId = libraryService.getById(designDTO.getTemplateId());
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
|
||||
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
|
||||
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
|
||||
elementVO.setStyle(byId.getLevel3Type());
|
||||
if (!CollectionUtils.isEmpty(designDTO.getMannequins())) {
|
||||
List<DesignLibraryModelPointVO> designLibraryModelPointVOList = new ArrayList<>();
|
||||
for (MannequinDTO mannequin : designDTO.getMannequins()) {
|
||||
if (mannequin.getType().equals("System")) {
|
||||
SysFileVO byId = sysFileService.getById(mannequin.getId());
|
||||
// if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
|
||||
// elementVO.setStyle(byId.getLevel3Type());
|
||||
// }
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), mannequin.getType());
|
||||
designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
|
||||
}else {
|
||||
Library byId = libraryService.getById(mannequin.getId());
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), mannequin.getType());
|
||||
designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
|
||||
}
|
||||
}
|
||||
elementVO.setMannequins(designLibraryModelPointVOList);
|
||||
}else {
|
||||
if (!StringUtils.isEmpty(designDTO.getModelType())) {
|
||||
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
Library byId = libraryService.getById(designDTO.getTemplateId());
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
|
||||
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
|
||||
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
|
||||
elementVO.setStyle(byId.getLevel3Type());
|
||||
}
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
|
||||
}
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
|
||||
}
|
||||
}
|
||||
elementVO.setModelSex(designDTO.getModelSex());
|
||||
@@ -660,6 +679,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
libraryModelPoint.setWaistbandLeft(calculateTemplatePointOne(modelPoint.getWaistbandLeft(), high, width));
|
||||
libraryModelPoint.setWaistbandRight(calculateTemplatePointOne(modelPoint.getWaistbandRight(), high, width));
|
||||
libraryModelPoint.setTemplateUrl(templateUrl);
|
||||
libraryModelPoint.setRelationId(modelPoint.getRelationId());
|
||||
libraryModelPoint.setRelationType(modelPoint.getModelType());
|
||||
return libraryModelPoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -759,6 +759,20 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designItem.setDesignUrl(item.getBasic().getSave_name());
|
||||
designItem.setHasLike((byte) 0);
|
||||
//生成designItem
|
||||
Map<String, Object> bodyPointTest = item.getBasic().getBody_point_test();
|
||||
// 转换 relation_id (Long)
|
||||
Long relationId = Optional.ofNullable(bodyPointTest.get("relation_id"))
|
||||
.filter(Number.class::isInstance)
|
||||
.map(num -> ((Number) num).longValue())
|
||||
.orElseThrow(null);
|
||||
|
||||
// 转换 relation_type (String)
|
||||
String relationType = Optional.ofNullable(bodyPointTest.get("relation_type"))
|
||||
.filter(String.class::isInstance)
|
||||
.map(String.class::cast)
|
||||
.orElse(null);
|
||||
designItem.setModelId(relationId);
|
||||
designItem.setModelType(relationType);
|
||||
Long designItemId = designItemService.saveOne(designItem);
|
||||
// python design返回入库及封装
|
||||
// JSONObject outfit = data.getJSONObject(i + "");
|
||||
@@ -1753,6 +1767,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean receiveDesignResults(JSONObject responseJSONObject) {
|
||||
// String requestId = "UUID.randomUUID().toString()";
|
||||
System.out.println(responseJSONObject.toJSONString());
|
||||
String requestId = responseJSONObject.getString("requestId");
|
||||
Map<String, Object> context;
|
||||
synchronized (designContext) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.model.dto.ChatHistoryDTO;
|
||||
import com.ai.da.model.dto.ReceiveCollectionElement;
|
||||
import com.ai.da.model.dto.ReceiveDesignParam;
|
||||
import com.ai.da.model.enums.*;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
@@ -18,10 +19,12 @@ import com.ai.da.service.DesignService;
|
||||
import com.ai.da.service.LLMService;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
@@ -34,10 +37,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class LLMServiceImpl implements LLMService {
|
||||
private final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
@Override
|
||||
public SseEmitter stream(String prompt, Long projectId, String fileUrl, List<String> imageUrlList, String token) {
|
||||
public SseEmitter stream(String prompt, Long projectParamId, String fileUrl, List<String> imageUrlList, String token, Boolean enableThinking, String process) {
|
||||
SseEmitter emitter = new SseEmitter(0L); // 永不超时
|
||||
|
||||
executor.submit(() -> {
|
||||
@@ -76,38 +76,60 @@ public class LLMServiceImpl implements LLMService {
|
||||
if (validate) {
|
||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(token);
|
||||
Long accountId = principal.getId();
|
||||
int userSeq = getNextSeq(projectId); // 获取当前session下一条消息序号
|
||||
String url = "http://18.167.251.121:10002/chat-stream";
|
||||
// String url = "http://10.1.1.240:1013/chat-stream";
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
Long projectId = null;
|
||||
if (null == projectParamId) {
|
||||
Project project = new Project();
|
||||
project.setCreateTime(LocalDateTime.now());
|
||||
projectMapper.insert(project);
|
||||
projectId = project.getId();
|
||||
}else {
|
||||
projectId = projectParamId;
|
||||
}
|
||||
|
||||
JSONObject jsonBodyObject = new JSONObject();
|
||||
jsonBodyObject.put("session_id", projectId.toString());
|
||||
jsonBodyObject.put("project_id", projectId.toString());
|
||||
jsonBodyObject.put("role", "user");
|
||||
jsonBodyObject.put("image", imageUrlList); // 可扩展
|
||||
jsonBodyObject.put("file", fileUrl != null ? fileUrl : "");
|
||||
jsonBodyObject.put("image", !CollectionUtils.isEmpty(imageUrlList) ? imageUrlList : new ArrayList<>()); // 可扩展
|
||||
// jsonBodyObject.put("image", ""); // 可扩展
|
||||
jsonBodyObject.put("file", !StringUtils.isEmpty(fileUrl) ? Collections.singletonList(fileUrl) : new ArrayList<>());
|
||||
jsonBodyObject.put("message", prompt);
|
||||
jsonBodyObject.put("enable_thinking", false);
|
||||
jsonBodyObject.put("enable_thinking", enableThinking);
|
||||
jsonBodyObject.put("process", !StringUtils.isEmpty(process) ? process : "");
|
||||
jsonBodyObject.put("is_create_project", false);
|
||||
|
||||
// 1. 存储用户输入
|
||||
ChatMessage userMessage = new ChatMessage();
|
||||
userMessage.setRole("user");
|
||||
userMessage.setProjectId(projectId);
|
||||
userMessage.setSeq(userSeq);
|
||||
userMessage.setSeq(getNextSeq(projectId));
|
||||
userMessage.setCreateTime(LocalDateTime.now());
|
||||
userMessage.setContent(jsonBodyObject.toJSONString());
|
||||
userMessage.setAccountId(accountId);
|
||||
chatMessageMapper.insert(userMessage);
|
||||
|
||||
try (OutputStream os = conn.getOutputStream()) {
|
||||
System.out.println(jsonBodyObject.toJSONString());
|
||||
byte[] input = jsonBodyObject.toJSONString().getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
|
||||
// 2. 流式接收并累积内容
|
||||
StringBuilder responseBuilder = new StringBuilder();
|
||||
// 3. 存储系统回复
|
||||
ChatMessage systemMessage = new ChatMessage();
|
||||
systemMessage.setRole("system");
|
||||
systemMessage.setIsImage(0);
|
||||
systemMessage.setProjectId(projectId);
|
||||
// systemMessage.setCreateTime(LocalDateTime.now());
|
||||
// systemMessage.setContent(responseBuilder.toString());
|
||||
systemMessage.setAccountId(accountId);
|
||||
// chatMessageMapper.insert(systemMessage);
|
||||
StringBuilder responseContentBuilder = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
@@ -117,42 +139,169 @@ public class LLMServiceImpl implements LLMService {
|
||||
System.out.println(jsonStr);
|
||||
JSONObject json = JSON.parseObject(jsonStr);
|
||||
String status = json.getString("status");
|
||||
|
||||
if ("[DONE]".equals(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(status)) {
|
||||
String content = json.getString("content");
|
||||
if (!status.equals("[RUNNING]") && !status.equals("[DESIGN_SIGNAL]")) {
|
||||
// 结束标识
|
||||
if ("[DONE]".equals(status)) {
|
||||
break;
|
||||
}else if ("[RUNNING]".equals(status)) {
|
||||
if (content.startsWith("\n[TOOL_CALL]") || content.startsWith("\n[TOOL_RESPONSE]")) {
|
||||
// 不发送不存储
|
||||
}else {
|
||||
responseContentBuilder.append(content);
|
||||
emitter.send(json.toJSONString());
|
||||
}
|
||||
}else {
|
||||
if (responseContentBuilder.length() != 0) {
|
||||
systemMessage.setSeq(getNextSeq(projectId));
|
||||
systemMessage.setCreateTime(LocalDateTime.now());
|
||||
systemMessage.setContent(responseContentBuilder.toString());
|
||||
chatMessageMapper.insert(systemMessage);
|
||||
systemMessage.setId(null);
|
||||
responseContentBuilder = new StringBuilder();
|
||||
}
|
||||
JSONObject toolsData = json.getJSONObject("tools_data");
|
||||
ReceiveDesignParam receiveDesignParam = JSONObject.parseObject(JSONObject.toJSONString(toolsData), ReceiveDesignParam.class);
|
||||
receiveDesignParam.setProjectId(projectId);
|
||||
designService.receiveDesignParams(receiveDesignParam);
|
||||
}
|
||||
if (content != null) {
|
||||
responseBuilder.append(content);
|
||||
if (Objects.nonNull(toolsData) && !status.equals("[DESIGN_SIGNAL]") && !status.equals("[PROJECT_CREATE_SIGNAL]")) {
|
||||
boolean color = true;
|
||||
ReceiveDesignParam receiveDesignParam = JSONObject.parseObject(JSONObject.toJSONString(toolsData), ReceiveDesignParam.class);
|
||||
receiveDesignParam.setProjectId(projectId);
|
||||
designService.receiveDesignParams(receiveDesignParam);
|
||||
for (ReceiveCollectionElement receiveCollectionElement : receiveDesignParam.getReceiveCollectionElementList()) {
|
||||
if (!StringUtils.isEmpty(receiveCollectionElement.getUrl())) {
|
||||
color = false;
|
||||
receiveCollectionElement.setMinioUrl(minioUtil.getPreSignedUrl(receiveCollectionElement.getUrl(), 24 * 60));
|
||||
}
|
||||
}
|
||||
String jsonString = JSONObject.toJSONString(receiveDesignParam);
|
||||
json.put("tools_data", jsonString);
|
||||
ChatMessage systemImage = new ChatMessage();
|
||||
systemImage.setRole("system");
|
||||
if (color) {
|
||||
systemImage.setIsImage(1);
|
||||
}else {
|
||||
systemImage.setIsImage(2);
|
||||
}
|
||||
systemImage.setProjectId(projectId);
|
||||
systemImage.setSeq(getNextSeq(projectId));
|
||||
systemImage.setCreateTime(LocalDateTime.now());
|
||||
systemImage.setContent(JSONObject.toJSONString(receiveDesignParam.getReceiveCollectionElementList()));
|
||||
systemImage.setAccountId(accountId);
|
||||
chatMessageMapper.insert(systemImage);
|
||||
}
|
||||
// if (status.equals("[PROJECT_CREATE_SIGNAL]")) {
|
||||
// JSONObject data = toolsData;
|
||||
// Project project = projectMapper.selectById(projectId);
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
// project.setUpdateTime(now);
|
||||
// project.setAccountId(accountId);
|
||||
// project.setName(data.getString("project_name"));
|
||||
// project.setOriginal(1);
|
||||
// project.setProcess(process);
|
||||
// projectMapper.updateById(project);
|
||||
//
|
||||
// Workspace workspace = new Workspace();
|
||||
// workspace.setAccountId(accountId);
|
||||
// workspace.setCreateTime(now);
|
||||
// String ageGroup = data.getString("ageGroup");
|
||||
// if (StringUtils.isEmpty(ageGroup)) {
|
||||
// workspace.setAgeGroup("Adult");
|
||||
// }else {
|
||||
// if (AgeGroup.isValidName(process)) {
|
||||
// workspace.setAgeGroup(ageGroup);
|
||||
// }else {
|
||||
// workspace.setAgeGroup("Adult");
|
||||
// }
|
||||
// }
|
||||
// String gender = data.getString("gender");
|
||||
// if (StringUtils.isEmpty(gender)) {
|
||||
// workspace.setSex("Female");
|
||||
// }else {
|
||||
// if (Sex.isValidName(gender)) {
|
||||
// workspace.setSex(gender);
|
||||
// }else {
|
||||
// workspace.setSex("Female");
|
||||
// }
|
||||
// }
|
||||
// String position = data.getString("position");
|
||||
// if (process.equals(DesignProcess.SERIES_DESIGN.name())) {
|
||||
// workspace.setPosition("Overall");
|
||||
// }else {
|
||||
// if (StringUtils.isEmpty(position)) {
|
||||
// if (workspace.getSex().equals("Female")) {
|
||||
// workspace.setPosition(Position.BLOUSE.getValue());
|
||||
// }else {
|
||||
// workspace.setPosition(Position.TOPS.getValue());
|
||||
// }
|
||||
// }else {
|
||||
// if (Position.isValidName(position)) {
|
||||
// workspace.setPosition(position);
|
||||
// }else {
|
||||
// if (workspace.getSex().equals("Female")) {
|
||||
// workspace.setPosition(Position.BLOUSE.getValue());
|
||||
// }else {
|
||||
// workspace.setPosition(Position.TOPS.getValue());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// workspace.setSystemDesignerPercentage(30);
|
||||
// workspace.setProjectId(project.getId());
|
||||
// workspace.setAccountId(accountId);
|
||||
// String style = data.getString("style");
|
||||
// String styleName = null;
|
||||
// if (StringUtils.isEmpty(style)) {
|
||||
// styleName = StyleEnum.NEW_CHINESE.name();
|
||||
// }else {
|
||||
// if (StyleEnum.isValidName(style)) {
|
||||
// styleName = style;
|
||||
// }else {
|
||||
// styleName = StyleEnum.NEW_CHINESE.name();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// SysFile sysFile = sysFileService.getOneBySex(styleName, workspace.getSex(), workspace.getAgeGroup());
|
||||
//
|
||||
// if (workspace.getSex().equals(Sex.FEMALE.getValue())) {
|
||||
// workspace.setMannequinFemaleId(sysFile.getId());
|
||||
// workspace.setMannequinFemaleType("System");
|
||||
// }else {
|
||||
// workspace.setMannequinMaleId(sysFile.getId());
|
||||
// workspace.setMannequinMaleType("System");
|
||||
// }
|
||||
//
|
||||
// workspaceMapper.insert(workspace);
|
||||
//
|
||||
// if (!StringUtils.isEmpty(styleName)) {
|
||||
// QueryWrapper<Style> qw = new QueryWrapper<>();
|
||||
// qw.lambda().eq(Style::getName, styleName);
|
||||
// Style style1 = styleMapper.selectOne(qw);
|
||||
// if (Objects.nonNull(style1)) {
|
||||
// WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
// rel.setWorkspaceId(workspace.getId());
|
||||
// rel.setStyleId(style1.getId());
|
||||
// workspaceRelStyleMapper.insert(rel);
|
||||
// }
|
||||
// }
|
||||
// toolsData.put("projectId", projectId);
|
||||
// json.put("tools_data", toolsData.toJSONString());
|
||||
// }
|
||||
emitter.send(json.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (responseContentBuilder.length() != 0) {
|
||||
systemMessage.setSeq(getNextSeq(projectId));
|
||||
systemMessage.setCreateTime(LocalDateTime.now());
|
||||
systemMessage.setContent(responseContentBuilder.toString());
|
||||
chatMessageMapper.insert(systemMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 存储系统回复
|
||||
int systemSeq = getNextSeq(projectId);
|
||||
ChatMessage systemMessage = new ChatMessage();
|
||||
systemMessage.setRole("user");
|
||||
systemMessage.setProjectId(projectId);
|
||||
systemMessage.setSeq(systemSeq);
|
||||
systemMessage.setCreateTime(LocalDateTime.now());
|
||||
systemMessage.setContent(responseBuilder.toString());
|
||||
systemMessage.setAccountId(accountId);
|
||||
chatMessageMapper.insert(systemMessage);
|
||||
}
|
||||
|
||||
emitter.complete();
|
||||
} catch (Exception e) {
|
||||
System.out.println("走进异常");
|
||||
emitter.completeWithError(e);
|
||||
}
|
||||
});
|
||||
@@ -161,9 +310,9 @@ public class LLMServiceImpl implements LLMService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long chatCreateProject(String prompt, String process) {
|
||||
public Long chatCreateProject(String prompt, String process, String fileUrl, List<String> imageUrlList) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
JSONObject jsonObject = pythonService.getProjectParam(prompt);
|
||||
JSONObject jsonObject = pythonService.getProjectParam(prompt, fileUrl, imageUrlList);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
Project project = new Project();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
@@ -209,13 +358,25 @@ public class LLMServiceImpl implements LLMService {
|
||||
}
|
||||
}
|
||||
String position = data.getString("position");
|
||||
if (StringUtils.isEmpty(position)) {
|
||||
if (process.equals(DesignProcess.SERIES_DESIGN.name())) {
|
||||
workspace.setPosition("Overall");
|
||||
}else {
|
||||
if (Position.isValidName(position)) {
|
||||
workspace.setPosition(position);
|
||||
if (StringUtils.isEmpty(position)) {
|
||||
if (workspace.getSex().equals("Female")) {
|
||||
workspace.setPosition(Position.BLOUSE.getValue());
|
||||
}else {
|
||||
workspace.setPosition(Position.TOPS.getValue());
|
||||
}
|
||||
}else {
|
||||
workspace.setPosition("Overall");
|
||||
if (Position.isValidName(position) && !position.equals(Position.OVERALL.getValue())) {
|
||||
workspace.setPosition(position);
|
||||
}else {
|
||||
if (workspace.getSex().equals("Female")) {
|
||||
workspace.setPosition(Position.BLOUSE.getValue());
|
||||
}else {
|
||||
workspace.setPosition(Position.TOPS.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
workspace.setSystemDesignerPercentage(30);
|
||||
@@ -263,7 +424,7 @@ public class LLMServiceImpl implements LLMService {
|
||||
@Override
|
||||
public List<String> uploadFile(MultipartFile file) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
String minioUrl = minioUtil.upload("chat-message", userHolder.getId() + "", file);
|
||||
String minioUrl = minioUtil.upload("chat-message", userHolder.getId() + "/" + file.getOriginalFilename(), file, null);
|
||||
String preSignedUrl = minioUtil.getPreSignedUrl(minioUrl, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add(minioUrl);
|
||||
@@ -274,9 +435,47 @@ public class LLMServiceImpl implements LLMService {
|
||||
@Override
|
||||
public PageBaseResponse<ChatMessage> getChatHistory(ChatHistoryDTO chatHistoryDTO) {
|
||||
QueryWrapper<ChatMessage> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ChatMessage::getProjectId, chatHistoryDTO);
|
||||
qw.lambda().eq(ChatMessage::getProjectId, chatHistoryDTO.getProjectId());
|
||||
qw.lambda().orderByDesc(ChatMessage::getSeq);
|
||||
Page<ChatMessage> chatMessagePage = chatMessageMapper.selectPage(new Page<>(chatHistoryDTO.getPage(), chatHistoryDTO.getSize()), qw);
|
||||
for (ChatMessage record : chatMessagePage.getRecords()) {
|
||||
if (record.getIsImage() != null && record.getIsImage() == 1) {
|
||||
String content = record.getContent();
|
||||
List<ReceiveCollectionElement> list = JSONObject.parseArray(content, ReceiveCollectionElement.class);
|
||||
for (ReceiveCollectionElement receiveCollectionElement : list) {
|
||||
if (!StringUtils.isEmpty(receiveCollectionElement.getUrl())) {
|
||||
receiveCollectionElement.setMinioUrl(minioUtil.getPreSignedUrl(receiveCollectionElement.getUrl(), 24 * 60));
|
||||
}
|
||||
}
|
||||
record.setContent(JSONObject.toJSONString(list));
|
||||
}
|
||||
if (record.getRole().equals("user")) {
|
||||
String content = record.getContent();
|
||||
JSONObject jsonObject = JSONObject.parseObject(content);
|
||||
JSONArray fileArray = jsonObject.getJSONArray("file");
|
||||
if (!CollectionUtils.isEmpty(fileArray)) {
|
||||
for (int i = 0; i < fileArray.size(); i++) {
|
||||
String string = fileArray.getString(i);
|
||||
if (!StringUtils.isEmpty(string)) {
|
||||
fileArray.set(i, minioUtil.getPreSignedUrl(string, 24 * 60));
|
||||
}
|
||||
}
|
||||
jsonObject.put("file", fileArray);
|
||||
}
|
||||
|
||||
JSONArray imageArray = jsonObject.getJSONArray("image");
|
||||
if (!CollectionUtils.isEmpty(imageArray)) {
|
||||
for (int i = 0; i < imageArray.size(); i++) {
|
||||
String string = imageArray.getString(i);
|
||||
if (!StringUtils.isEmpty(string)) {
|
||||
imageArray.set(i, minioUtil.getPreSignedUrl(string, 24 * 60));
|
||||
}
|
||||
}
|
||||
jsonObject.put("image", imageArray);
|
||||
}
|
||||
record.setContent(JSONObject.toJSONString(jsonObject));
|
||||
}
|
||||
}
|
||||
return PageBaseResponse.success(chatMessagePage);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,10 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
queryWrapper.like("name", query.getPictureName());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(query.getAgeGroup())) {
|
||||
queryWrapper.eq("level3_type", query.getAgeGroup());
|
||||
}
|
||||
|
||||
if (query.getBrandId() != null) {
|
||||
QueryWrapper<BrandRelLibrary> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(BrandRelLibrary::getBrandId, query.getBrandId());
|
||||
|
||||
@@ -131,6 +131,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
private ThreeDModuleMapper threeDModuleMapper;
|
||||
@Resource
|
||||
private ProductImageService productImageService;
|
||||
@Resource
|
||||
private CollectionElementRelModelMapper collectionElementRelModelMapper;
|
||||
|
||||
@Override
|
||||
public void deleteUserGroup(Long userGroupId) {
|
||||
@@ -1653,11 +1655,36 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
moduleChooseVO.setPatternMaking3D(threeDModuleVO);
|
||||
}
|
||||
}
|
||||
}else if (module.equals(Module.mannequin.name())) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
CollectionElementRelModel relModel = getCollectionElementRelModel(collectionElementVO.getId());
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(collectionElementVO.getUrl(), 24 * 60));
|
||||
collectionElementVO.setMannequinRelationId(relModel.getRelationId());
|
||||
collectionElementVO.setMannequinRelationType(relModel.getRelationType());
|
||||
collectionElementVO.setCollectionId(collectionElement.getId());
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setMannequin(list);
|
||||
}
|
||||
}
|
||||
return moduleChooseVO;
|
||||
}
|
||||
|
||||
private CollectionElementRelModel getCollectionElementRelModel(Long id) {
|
||||
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElementRelModel::getCollectionElementId, id);
|
||||
CollectionElementRelModel collectionElementRelModel = collectionElementRelModelMapper.selectOne(qw);
|
||||
return collectionElementRelModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ModuleChooseVO saveModuleContent(ModuleSaveDTO moduleSaveDTO) {
|
||||
@@ -1902,6 +1929,85 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(moduleSaveDTO.getMannequin())) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectId);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
|
||||
// Set<String> oldUrl = collectionElements.stream().map(CollectionElement::getUrl).collect(Collectors.toSet());
|
||||
List<MannequinDTO> mannequin = moduleSaveDTO.getMannequin();
|
||||
for (MannequinDTO dto : mannequin) {
|
||||
if (null != dto.getCollectionElementId()) {
|
||||
old.remove(dto.getId());
|
||||
continue;
|
||||
}
|
||||
if (dto.getType().equals("System")) {
|
||||
SysFile sysFile = sysFileMapper.selectById(dto.getId());
|
||||
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setName(sysFile.getName());
|
||||
collectionElement.setUrl(sysFile.getUrl());
|
||||
// collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(sysFile.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
collectionElementRelModel.setRelationId(dto.getId());
|
||||
collectionElementRelModel.setRelationType("System");
|
||||
collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
}else if (dto.getType().equals("Library")) {
|
||||
Library library = libraryMapper.selectById(dto.getId());
|
||||
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setName(library.getName());
|
||||
collectionElement.setUrl(library.getUrl());
|
||||
// collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(library.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
collectionElementRelModel.setRelationId(dto.getId());
|
||||
collectionElementRelModel.setRelationType("System");
|
||||
collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
|
||||
}else {
|
||||
// if (old.contains(dto.getId())) {
|
||||
// CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
|
||||
//// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
//// collectionElement.setHasPin(board.getIsPin());
|
||||
// collectionElement.setUpdateDate(new Date());
|
||||
// collectionElementMapper.updateById(collectionElement);
|
||||
// old.remove(dto.getId());
|
||||
// }else {
|
||||
// CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
|
||||
// collectionElement.setProjectId(projectId);
|
||||
//// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
//// collectionElement.setHasPin(board.getIsPin());
|
||||
// collectionElement.setUpdateDate(new Date());
|
||||
// collectionElementMapper.updateById(collectionElement);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(old)) {
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
// 删除关联关系
|
||||
deleteByCollectionElementIdList(old);
|
||||
}
|
||||
|
||||
}
|
||||
if (boundingBox) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
|
||||
@@ -1932,6 +2038,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
return result;
|
||||
}
|
||||
|
||||
private void deleteByCollectionElementIdList(Set<Long> old) {
|
||||
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(CollectionElementRelModel::getCollectionElementId, old);
|
||||
collectionElementRelModelMapper.delete(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryLibraryPageVO getMannequinDetail(MannequinDTO mannequinDTO) {
|
||||
QueryLibraryPageVO vo = new QueryLibraryPageVO();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||
import com.ai.da.common.enums.LibraryLevel1TypeEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.ResultEnum;
|
||||
@@ -61,6 +62,8 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
|
||||
@Resource
|
||||
private LibraryMapper libraryMapper;
|
||||
@Resource
|
||||
private BrandDNAMapper brandDNAMapper;
|
||||
|
||||
@Resource
|
||||
private SysFileMapper sysFileMapper;
|
||||
@@ -82,6 +85,10 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
@Resource
|
||||
private CollectionElementMapper collectionElementMapper;
|
||||
@Resource
|
||||
private CollectionElementRelModelMapper collectionElementRelModelMapper;
|
||||
|
||||
@Override
|
||||
public IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace) {
|
||||
@@ -396,6 +403,11 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
vo.setStyleName(styleEnum.getChinese());
|
||||
}
|
||||
}
|
||||
if (null != vo.getUserBrandDna()) {
|
||||
BrandDNA brandDNA = brandDNAMapper.selectById(vo.getUserBrandDna());
|
||||
vo.setUserBrandDnaName(brandDNA.getBrandName());
|
||||
vo.setUserBrandDnaImg(minioUtil.getPreSignedUrl(brandDNA.getBrandLogo(), 24 * 60));
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -687,47 +699,48 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
projectMapper.updateById(project);
|
||||
}
|
||||
|
||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Workspace::getProjectId, projectDTO.getId());
|
||||
List<Workspace> workspaces = workspaceMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(workspaces)) {
|
||||
throw new BusinessException("Lack of associated workspace.");
|
||||
}else {
|
||||
Workspace workspace = workspaces.get(0);
|
||||
Workspace workspaceNew = CopyUtil.copyObject(projectDTO.getWorkspace(), Workspace.class);
|
||||
workspaceNew.setId(workspace.getId());
|
||||
workspace.setUpdateTime(LocalDateTime.now());
|
||||
workspaceMapper.updateById(workspaceNew);
|
||||
}
|
||||
|
||||
if (projectDTO.getStyleId() != null) {
|
||||
QueryWrapper<WorkspaceRelStyle> wRSQW = new QueryWrapper<>();
|
||||
wRSQW.lambda().eq(WorkspaceRelStyle::getWorkspaceId, projectDTO.getWorkspace().getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(wRSQW);
|
||||
if (CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(projectDTO.getWorkspace().getId());
|
||||
rel.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
if (Objects.nonNull(projectDTO.getWorkspace())) {
|
||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Workspace::getProjectId, projectDTO.getId());
|
||||
List<Workspace> workspaces = workspaceMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(workspaces)) {
|
||||
throw new BusinessException("Lack of associated workspace.");
|
||||
}else {
|
||||
WorkspaceRelStyle workspaceRelStyleOld = workspaceRelStyles.get(0);
|
||||
if (!Objects.equals(workspaceRelStyleOld.getStyleId(), projectDTO.getStyleId())) {
|
||||
workspaceRelStyleOld.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.updateById(workspaceRelStyleOld);
|
||||
Workspace workspace = workspaces.get(0);
|
||||
Workspace workspaceNew = CopyUtil.copyObject(projectDTO.getWorkspace(), Workspace.class);
|
||||
workspaceNew.setId(workspace.getId());
|
||||
workspace.setUpdateTime(LocalDateTime.now());
|
||||
workspaceMapper.updateById(workspaceNew);
|
||||
}
|
||||
if (projectDTO.getStyleId() != null) {
|
||||
QueryWrapper<WorkspaceRelStyle> wRSQW = new QueryWrapper<>();
|
||||
wRSQW.lambda().eq(WorkspaceRelStyle::getWorkspaceId, projectDTO.getWorkspace().getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(wRSQW);
|
||||
if (CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(projectDTO.getWorkspace().getId());
|
||||
rel.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
}else {
|
||||
WorkspaceRelStyle workspaceRelStyleOld = workspaceRelStyles.get(0);
|
||||
if (!Objects.equals(workspaceRelStyleOld.getStyleId(), projectDTO.getStyleId())) {
|
||||
workspaceRelStyleOld.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.updateById(workspaceRelStyleOld);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
QueryWrapper<WorkspaceRelStyle> wRSQW = new QueryWrapper<>();
|
||||
wRSQW.lambda().eq(WorkspaceRelStyle::getWorkspaceId, projectDTO.getWorkspace().getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(wRSQW);
|
||||
if (!CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
workspaceRelStyleMapper.deleteBatchIds(workspaceRelStyles);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
QueryWrapper<WorkspaceRelStyle> wRSQW = new QueryWrapper<>();
|
||||
wRSQW.lambda().eq(WorkspaceRelStyle::getWorkspaceId, projectDTO.getWorkspace().getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(wRSQW);
|
||||
if (!CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
workspaceRelStyleMapper.deleteBatchIds(workspaceRelStyles);
|
||||
}
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
WorkspaceVO byIdForProject = workspaceService.getByIdForProject(workspaceId);
|
||||
vo.setWorkspaceVO(byIdForProject);
|
||||
}
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
WorkspaceVO byIdForProject = workspaceService.getByIdForProject(workspaceId);
|
||||
vo.setId(projectId);
|
||||
vo.setWorkspaceVO(byIdForProject);
|
||||
return vo;
|
||||
}else {
|
||||
Project project = CopyUtil.copyObject(projectDTO, Project.class);
|
||||
@@ -737,36 +750,52 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
project.setUpdateTime(now);
|
||||
projectMapper.insert(project);
|
||||
|
||||
Workspace workspace = CopyUtil.copyObject(projectDTO.getWorkspace(), Workspace.class);
|
||||
workspace.setIsLastIndex(0);
|
||||
workspace.setAccountId(userInfo.getId());
|
||||
workspace.setProjectId(project.getId());
|
||||
workspace.setCreateTime(LocalDateTime.now());
|
||||
workspace.setUpdateTime(LocalDateTime.now());
|
||||
if (Objects.nonNull(projectDTO.getWorkspace())) {
|
||||
Workspace workspace = CopyUtil.copyObject(projectDTO.getWorkspace(), Workspace.class);
|
||||
workspace.setIsLastIndex(0);
|
||||
workspace.setAccountId(userInfo.getId());
|
||||
workspace.setProjectId(project.getId());
|
||||
workspace.setCreateTime(LocalDateTime.now());
|
||||
workspace.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
if (projectDTO.getProcess().equals(DesignProcess.SERIES_DESIGN.name()) || projectDTO.getProcess().equals(DesignProcess.SKETCH_COLLAGE_PROCESS.name())) {
|
||||
SysFile sysFile = sysFileService.getOneBySex(projectDTO.getStyleId(), projectDTO.getWorkspace().getSex(), projectDTO.getWorkspace().getAgeGroup());
|
||||
|
||||
if (projectDTO.getWorkspace().getSex().equals(Sex.FEMALE.getValue())) {
|
||||
workspace.setMannequinFemaleId(sysFile.getId());
|
||||
workspace.setMannequinFemaleType("System");
|
||||
}else {
|
||||
workspace.setMannequinMaleId(sysFile.getId());
|
||||
workspace.setMannequinMaleType("System");
|
||||
if (projectDTO.getProcess().equals(DesignProcess.SERIES_DESIGN.name()) || projectDTO.getProcess().equals(DesignProcess.SKETCH_COLLAGE_PROCESS.name())) {
|
||||
SysFile sysFile = sysFileService.getOneBySex(projectDTO.getStyleId(), projectDTO.getWorkspace().getSex(), projectDTO.getWorkspace().getAgeGroup());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(userInfo.getId());
|
||||
collectionElement.setProjectId(project.getId());
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
collectionElement.setName(sysFile.getName());
|
||||
collectionElement.setUrl(sysFile.getUrl());
|
||||
collectionElement.setMd5(sysFile.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
collectionElementRelModel.setRelationId(sysFile.getId());
|
||||
collectionElementRelModel.setRelationType("System");
|
||||
collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
if (projectDTO.getWorkspace().getSex().equals(Sex.FEMALE.getValue())) {
|
||||
workspace.setMannequinFemaleId(sysFile.getId());
|
||||
workspace.setMannequinFemaleType("System");
|
||||
}else {
|
||||
workspace.setMannequinMaleId(sysFile.getId());
|
||||
workspace.setMannequinMaleType("System");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
workspaceMapper.insert(workspace);
|
||||
workspaceMapper.insert(workspace);
|
||||
|
||||
if (projectDTO.getStyleId() != null) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(workspace.getId());
|
||||
rel.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
if (projectDTO.getStyleId() != null) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(workspace.getId());
|
||||
rel.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
}
|
||||
WorkspaceVO byIdForProject = workspaceService.getByIdForProject(workspace.getId());
|
||||
vo.setWorkspaceVO(byIdForProject);
|
||||
}
|
||||
WorkspaceVO byIdForProject = workspaceService.getByIdForProject(workspace.getId());
|
||||
vo.setId(project.getId());
|
||||
vo.setWorkspaceVO(byIdForProject);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user