Merge remote-tracking branch 'origin/dev_shb' into dev-xp
# Conflicts: # src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java # src/main/java/com/ai/da/python/PythonService.java # src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java
This commit is contained in:
@@ -22,7 +22,7 @@ public interface DesignService extends IService<Design> {
|
||||
* @param designDTO
|
||||
* @return
|
||||
*/
|
||||
JSONObject designCollection(DesignCollectionDTO designDTO);
|
||||
DesignCollectionVO designCollection(DesignCollectionDTO designDTO);
|
||||
|
||||
/**
|
||||
* redesign
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
/**
|
||||
* design item详情表 服务类
|
||||
*
|
||||
* @author Arcana
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-09-04
|
||||
*/
|
||||
public interface ITDesignPythonOutfitDetailService extends IService<TDesignPythonOutfitDetail> {
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
/**
|
||||
* design item表 存对应design的8张图片 服务类
|
||||
*
|
||||
* @author Arcana
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-09-04
|
||||
*/
|
||||
public interface ITDesignPythonOutfitService extends IService<TDesignPythonOutfit> {
|
||||
|
||||
18
src/main/java/com/ai/da/service/PythonTAllInfoService.java
Normal file
18
src/main/java/com/ai/da/service/PythonTAllInfoService.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
|
||||
|
||||
import com.ai.da.mapper.entity.PythonTAllInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* (PythonTAllInfo)表服务接口
|
||||
*
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-09-08 17:03:47
|
||||
*/
|
||||
public interface PythonTAllInfoService extends IService<PythonTAllInfo> {
|
||||
|
||||
|
||||
Long getImageIdByPath(String path);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author Arcana
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-08-01
|
||||
*/
|
||||
public interface WorkspaceService extends IService<Workspace> {
|
||||
@@ -30,7 +30,9 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
|
||||
boolean saveOrUpdate(Workspace workspace);
|
||||
|
||||
IPage<Workspace> getPage(WorkspaceDTO query);
|
||||
WorkspaceVO getPage(WorkspaceDTO query);
|
||||
|
||||
List<BizJson> getEnumValues(String enumName);
|
||||
|
||||
Workspace getByIdNew(Long id);
|
||||
}
|
||||
|
||||
@@ -337,33 +337,34 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
}
|
||||
//校验marketingSketch
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getMarketingSketchs())) {
|
||||
//校验designType
|
||||
validateDesignType(designDTO.getMarketingSketchs(),"marketingSketchs");
|
||||
List<Long> printBoardIds = designDTO.getMarketingSketchs().stream()
|
||||
.filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
|
||||
.map(DesignCollectionElementDTO::getId)
|
||||
.collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(printBoardIds)){
|
||||
List<CollectionElement> marketingSketchElements = collectionElementMapper.selectBatchIds(printBoardIds);
|
||||
Assert.isTrue(CollectionUtil.isNotEmpty(marketingSketchElements)
|
||||
&& marketingSketchElements.size() == printBoardIds.size(), "get marketingSketch data is mismatch");
|
||||
elementVO.setMarketingSketchElements(marketingSketchElements);
|
||||
usedElementIds.addAll(printBoardIds);
|
||||
}
|
||||
//library
|
||||
List<Long> libraryIds = designDTO.getMarketingSketchs().stream()
|
||||
.filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
|
||||
.map(DesignCollectionElementDTO::getId)
|
||||
.collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(libraryIds)){
|
||||
List<Library> librarys = libraryService.getByIds(libraryIds);
|
||||
//不校验了防止用户在library删除 对应不上
|
||||
if(CollectionUtil.isNotEmpty(librarys)){
|
||||
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,null));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2023.12版本去掉了这个入参
|
||||
// if (CollectionUtil.isNotEmpty(designDTO.getMarketingSketchs())) {
|
||||
// //校验designType
|
||||
// validateDesignType(designDTO.getMarketingSketchs(),"marketingSketchs");
|
||||
// List<Long> printBoardIds = designDTO.getMarketingSketchs().stream()
|
||||
// .filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
|
||||
// .map(DesignCollectionElementDTO::getId)
|
||||
// .collect(Collectors.toList());
|
||||
// if(!CollectionUtils.isEmpty(printBoardIds)){
|
||||
// List<CollectionElement> marketingSketchElements = collectionElementMapper.selectBatchIds(printBoardIds);
|
||||
// Assert.isTrue(CollectionUtil.isNotEmpty(marketingSketchElements)
|
||||
// && marketingSketchElements.size() == printBoardIds.size(), "get marketingSketch data is mismatch");
|
||||
// elementVO.setMarketingSketchElements(marketingSketchElements);
|
||||
// usedElementIds.addAll(printBoardIds);
|
||||
// }
|
||||
// //library
|
||||
// List<Long> libraryIds = designDTO.getMarketingSketchs().stream()
|
||||
// .filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
|
||||
// .map(DesignCollectionElementDTO::getId)
|
||||
// .collect(Collectors.toList());
|
||||
// if(!CollectionUtils.isEmpty(libraryIds)){
|
||||
// List<Library> librarys = libraryService.getByIds(libraryIds);
|
||||
// //不校验了防止用户在library删除 对应不上
|
||||
// if(CollectionUtil.isNotEmpty(librarys)){
|
||||
// libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,null));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//校验控制生成类型
|
||||
SingleOverallEnum singleOverall = SingleOverallEnum.of(designDTO.getSingleOverall());
|
||||
Assert.notNull(singleOverall, "unknown parameter singleOverall!");
|
||||
|
||||
@@ -16,7 +16,9 @@ import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.python.vo.DesignPythonItem;
|
||||
import com.ai.da.python.vo.DesignPythonItemPrint;
|
||||
import com.ai.da.python.vo.DesignPythonObject;
|
||||
import com.ai.da.python.vo.DesignPythonObjects;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -27,6 +29,7 @@ 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 org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -36,6 +39,7 @@ import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ai.da.python.vo.DesignPythonItem.*;
|
||||
@@ -79,10 +83,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
|
||||
@Resource
|
||||
private PanToneService panToneService;
|
||||
@Resource
|
||||
private PythonTAllInfoService pythonTAllInfoService;
|
||||
@Value("${minio.endpoint}")
|
||||
private String endpoint;
|
||||
@Value("${minio.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
// @Transactional
|
||||
@Override
|
||||
public JSONObject designCollection(DesignCollectionDTO designDTO) {
|
||||
public DesignCollectionVO designCollection(DesignCollectionDTO designDTO) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
//校验collection element
|
||||
ValidateElementVO elementVO =collectionElementService.validateElement(designDTO);
|
||||
@@ -180,12 +190,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
//计算library
|
||||
calculateLibraryAndSysFile(designDTO,elementVO,userInfo);
|
||||
//组装design入参
|
||||
DesignPythonObjects pythonObjects =pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||
designDTO.getSingleOverall(),designDTO.getSwitchCategory(),elementVO);
|
||||
//缓存保存的文件 方便后面处理进度问题
|
||||
setDesignProcess(userInfo.getId(),pythonObjects);
|
||||
//design
|
||||
JSONObject responseJSONObject= pythonService.designNew(pythonObjects);
|
||||
pythonService.design(pythonObjects);
|
||||
//生成library
|
||||
generateLibrary(elementVO,designDTO.getTimeZone());
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
@@ -198,7 +208,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
return saveDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone());
|
||||
}
|
||||
|
||||
private JSONObject designOrRedesignOperateNew(DesignCollectionDTO designDTO,AuthPrincipalVo userInfo,
|
||||
private DesignCollectionVO designOrRedesignOperateNew(DesignCollectionDTO designDTO,AuthPrincipalVo userInfo,
|
||||
Long collectionIdParam,ValidateElementVO elementVO){
|
||||
if(CollectionUtil.isNotEmpty(designDTO.getSketchBoards())){
|
||||
//编辑sketchBoard
|
||||
@@ -211,7 +221,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
//保存collection
|
||||
Long collectionId = (null == collectionIdParam) ?
|
||||
collectionService.saveCollection(userInfo.getId(),designDTO.getTimeZone(),designDTO.getMoodTemplateId()) : collectionIdParam;
|
||||
List<Long> elementIds =getElementId(elementVO);
|
||||
List<Long> elementIds = getElementId(elementVO);
|
||||
//批量关联element 到 collection
|
||||
collectionElementService.relationCollection(elementIds,collectionId);
|
||||
//library转化为collection(生成)
|
||||
@@ -227,8 +237,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designDTO.getSingleOverall(),designDTO.getSwitchCategory(),elementVO);
|
||||
//缓存保存的文件 方便后面处理进度问题
|
||||
setDesignProcess(userInfo.getId(),pythonObjects);
|
||||
// pythonObjects增加image_id关联
|
||||
relationImageId(pythonObjects);
|
||||
//design
|
||||
JSONObject responseJSONObject= pythonService.designNew(pythonObjects);
|
||||
JSONObject responseJSONObject = pythonService.designNew(pythonObjects);
|
||||
//生成library
|
||||
generateLibrary(elementVO,designDTO.getTimeZone());
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
@@ -240,6 +252,28 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
//保存designItem 和detail
|
||||
// return saveDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone());
|
||||
}
|
||||
|
||||
private void relationImageId(DesignPythonObjects pythonObjects) {
|
||||
if(Objects.isNull(pythonObjects)) {
|
||||
return;
|
||||
}
|
||||
pythonObjects.getObjects().forEach(
|
||||
o -> {
|
||||
for (DesignPythonItem item : o.getItems()) {
|
||||
String path = item.getPath();
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
String bodyPath = item.getBody_path();
|
||||
Long imageId = pythonTAllInfoService.getImageIdByPath(bodyPath);
|
||||
item.setImageId(imageId);
|
||||
}else {
|
||||
Long imageId = pythonTAllInfoService.getImageIdByPath(path);
|
||||
item.setImageId(imageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void handleCollectionElementRelation(Long collectionId ,Boolean isEdit,List<Long> elementIds ){
|
||||
if (CollectionUtils.isEmpty(elementIds) || collectionId == null){
|
||||
return;
|
||||
@@ -310,15 +344,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
return object.getBasic().getSave_name();}).collect(Collectors.toList());
|
||||
LocalCacheUtils.setDesignProcessCache(userId,saveNames);
|
||||
}
|
||||
private JSONObject savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects
|
||||
private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects
|
||||
,Long designId,Long collectionId,AuthPrincipalVo userInfo,String timeZone, JSONObject responseJSONObject){
|
||||
DesignCollectionVO response = new DesignCollectionVO();
|
||||
response.setDesignId(designId);
|
||||
response.setCollectionId(collectionId);
|
||||
List<DesignCollectionItemVO> designCollectionItems = Lists.newArrayList();
|
||||
response.setDesignCollectionItems(designCollectionItems);
|
||||
|
||||
pythonObjects.getObjects().forEach(item ->{
|
||||
JSONObject data = responseJSONObject.getJSONObject("data");
|
||||
for (int i = 0; i < pythonObjects.getObjects().size(); i++) {
|
||||
DesignPythonObject item = pythonObjects.getObjects().get(i);
|
||||
DesignItem designItem = new DesignItem();
|
||||
designItem.setAccountId(userInfo.getId());
|
||||
designItem.setCollectionId(collectionId);
|
||||
@@ -329,8 +364,63 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designItem.setHasLike((byte)0);
|
||||
//生成designItem
|
||||
Long designItemId = designItemService.saveOne(designItem);
|
||||
// python design返回入库及封装
|
||||
JSONObject outfit = data.getJSONObject(i + "");
|
||||
if (null == outfit) {
|
||||
continue;
|
||||
}
|
||||
TDesignPythonOutfit designPythonOutfit = new TDesignPythonOutfit();
|
||||
designPythonOutfit.setDesignItemId(designItemId);
|
||||
designPythonOutfit.setUserId(userInfo.getId());
|
||||
designPythonOutfit.setDesignId(designId);
|
||||
designPythonOutfit.setCollectionId(collectionId);
|
||||
designPythonOutfit.setDesignUrl(outfit.getString("synthesis_url"));
|
||||
designPythonOutfitService.save(designPythonOutfit);
|
||||
JSONArray layers = outfit.getJSONArray("layers");
|
||||
List<TDesignPythonOutfitDetail> list = new ArrayList<>();
|
||||
for (int i1 = 0; i1 < layers.size(); i1++) {
|
||||
JSONObject jsonObject = layers.getJSONObject(i1);
|
||||
TDesignPythonOutfitDetail designPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
||||
designPythonOutfitDetail.setDesignId(designId);
|
||||
designPythonOutfitDetail.setDesignPythonOutfitId(designPythonOutfit.getId());
|
||||
JSONArray position = jsonObject.getJSONArray("position");
|
||||
if (position != null && !CollectionUtils.isEmpty(position)) {
|
||||
StringBuilder builder = null;
|
||||
for (int i2 = 0; i2 < position.size(); i2++) {
|
||||
if (i2 != position.size() - 1) {
|
||||
builder.append(position.getInteger(i2)).append(",");
|
||||
}else {
|
||||
builder.append(position.getInteger(i2));
|
||||
}
|
||||
}
|
||||
designPythonOutfitDetail.setPosition(builder.toString());
|
||||
}
|
||||
JSONArray imageSize = jsonObject.getJSONArray("image_size");
|
||||
if (imageSize != null && !CollectionUtils.isEmpty(position)) {
|
||||
StringBuilder builder = null;
|
||||
for (int i2 = 0; i2 < imageSize.size(); i2++) {
|
||||
if (i2 != imageSize.size() - 1) {
|
||||
builder.append(imageSize.getInteger(i2)).append(",");
|
||||
}else {
|
||||
builder.append(imageSize.getInteger(i2));
|
||||
}
|
||||
}
|
||||
designPythonOutfitDetail.setImageSize(builder.toString());
|
||||
}
|
||||
designPythonOutfitDetail.setImageUrl(jsonObject.getString("image_url"));
|
||||
designPythonOutfitDetail.setImageCategory(jsonObject.getString("image_category"));
|
||||
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
|
||||
designPythonOutfitDetail.setUserId(userInfo.getId());
|
||||
list.add(designPythonOutfitDetail);
|
||||
}
|
||||
designPythonOutfitDetailService.saveBatch(list);
|
||||
DesignCollectionItemVO designCollectionItemVO = new DesignCollectionItemVO();
|
||||
designCollectionItemVO.setDesignItemId(designItemId);
|
||||
designCollectionItemVO.setDesignItemUrl(designItem.getDesignUrl());
|
||||
designCollectionItemVO.setDesignOutfitId(designPythonOutfit.getId());
|
||||
designCollectionItemVO.setDesignOutfitUrl(endpoint + "/" + bucketName + "/" + designPythonOutfit.getDesignUrl());
|
||||
//response
|
||||
designCollectionItems.add(new DesignCollectionItemVO(designItemId,designItem.getDesignUrl()));
|
||||
designCollectionItems.add(designCollectionItemVO);
|
||||
|
||||
List<DesignItemDetail> designItemDetails = Lists.newArrayList();
|
||||
item.getItems().forEach(detail ->{
|
||||
@@ -354,33 +444,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designItemDetails.add(designItemDetail);
|
||||
});
|
||||
designItemDetailService.saveBatch(designItemDetails);
|
||||
});
|
||||
JSONObject data = responseJSONObject.getJSONObject("data");
|
||||
for (int i = 0; i < 8; i++) {
|
||||
JSONObject outfit = data.getJSONObject(i + "");
|
||||
TDesignPythonOutfit designPythonOutfit = new TDesignPythonOutfit();
|
||||
designPythonOutfit.setUserId(userInfo.getId());
|
||||
designPythonOutfit.setDesignId(designId);
|
||||
designPythonOutfit.setCollectionId(collectionId);
|
||||
designPythonOutfit.setDesignUrl(outfit.getString("synthesis_url"));
|
||||
designPythonOutfitService.save(designPythonOutfit);
|
||||
JSONArray layers = outfit.getJSONArray("layers");
|
||||
List<TDesignPythonOutfitDetail> list = new ArrayList<>();
|
||||
for (int i1 = 0; i1 < layers.size(); i1++) {
|
||||
JSONObject jsonObject = layers.getJSONObject(i1);
|
||||
TDesignPythonOutfitDetail designPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
||||
designPythonOutfitDetail.setDesignId(designId);
|
||||
designPythonOutfitDetail.setDesignPythonOutfitId(designPythonOutfit.getId());
|
||||
designPythonOutfitDetail.setPosition(jsonObject.getString("position"));
|
||||
designPythonOutfitDetail.setImageUrl(jsonObject.getString("image_url"));
|
||||
designPythonOutfitDetail.setImageCategory(jsonObject.getString("image_category"));
|
||||
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
|
||||
designPythonOutfitDetail.setUserId(userInfo.getId());
|
||||
list.add(designPythonOutfitDetail);
|
||||
}
|
||||
designPythonOutfitDetailService.saveBatch(list);
|
||||
}
|
||||
return responseJSONObject;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private DesignCollectionVO saveDesignItemAndDetail(DesignPythonObjects pythonObjects
|
||||
@@ -403,7 +469,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
//生成designItem
|
||||
Long designItemId = designItemService.saveOne(designItem);
|
||||
//response
|
||||
designCollectionItems.add(new DesignCollectionItemVO(designItemId,designItem.getDesignUrl()));
|
||||
designCollectionItems.add(new DesignCollectionItemVO(designItemId,designItem.getDesignUrl(), null, null));
|
||||
|
||||
List<DesignItemDetail> designItemDetails = Lists.newArrayList();
|
||||
item.getItems().forEach(detail ->{
|
||||
@@ -432,6 +498,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
private List<Long> getElementId(ValidateElementVO elementVO){
|
||||
List<Long> elementIds = Lists.newArrayList();
|
||||
// collection type
|
||||
if(CollectionUtil.isNotEmpty(elementVO.getSketchBoardElements())){
|
||||
elementIds.addAll(elementVO.getSketchBoardElements().stream().map(CollectionElement::getId).collect(Collectors.toList()));
|
||||
}
|
||||
@@ -441,9 +508,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
if(CollectionUtil.isNotEmpty(elementVO.getPrintBoardElements())){
|
||||
elementIds.addAll(elementVO.getPrintBoardElements().stream().map(CollectionElement::getId).collect(Collectors.toList()));
|
||||
}
|
||||
if(CollectionUtil.isNotEmpty(elementVO.getMarketingSketchElements())){
|
||||
elementIds.addAll(elementVO.getMarketingSketchElements().stream().map(CollectionElement::getId).collect(Collectors.toList()));
|
||||
}
|
||||
// if(CollectionUtil.isNotEmpty(elementVO.getMarketingSketchElements())){
|
||||
// elementIds.addAll(elementVO.getMarketingSketchElements().stream().map(CollectionElement::getId).collect(Collectors.toList()));
|
||||
// }
|
||||
return elementIds;
|
||||
}
|
||||
|
||||
@@ -499,7 +566,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private List<DesignCollectionItemVO> coverDesignItemToVO( List<DesignItem> designItems){
|
||||
List<DesignCollectionItemVO> response = Lists.newArrayList();
|
||||
designItems.forEach(designItem -> {
|
||||
response.add(new DesignCollectionItemVO(designItem.getId(),designItem.getDesignUrl()));
|
||||
response.add(new DesignCollectionItemVO(designItem.getId(),designItem.getDesignUrl(), null, null));
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
|
||||
@Override
|
||||
public List<PantoneVO> getRgbByHsvBatch(List<GetRgbByHsvBatchDTO> hsvBatch) {
|
||||
if(hsvBatch.size() >15){
|
||||
throw new BusinessException("hsv value cannot exceed the maximum of 15");
|
||||
if(hsvBatch.size() >8){
|
||||
throw new BusinessException("hsv value cannot exceed the maximum of 8");
|
||||
}
|
||||
List<Integer> colorValues = Lists.newArrayList();
|
||||
Map<Integer,GetRgbByHsvBatchDTO> valueToHsv = Maps.newHashMap();
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.mapper.PythonTAllInfoMapper;
|
||||
import com.ai.da.mapper.entity.PythonTAllInfo;
|
||||
import com.ai.da.service.PythonTAllInfoService;
|
||||
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 org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (PythonTAllInfo)表服务实现类
|
||||
*
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-09-08 17:03:47
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PythonTAllInfoServiceImpl extends ServiceImpl<PythonTAllInfoMapper, PythonTAllInfo> implements PythonTAllInfoService {
|
||||
@Resource
|
||||
private PythonTAllInfoMapper pythonTAllInfoMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Long getImageIdByPath(String path) {
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
throw new BusinessException("path不能为空");
|
||||
}
|
||||
QueryWrapper<PythonTAllInfo> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(PythonTAllInfo::getImagePath, path);
|
||||
qw.lambda().last("limit 1");
|
||||
List<PythonTAllInfo> pythonTAllInfos = pythonTAllInfoMapper.selectList(qw);
|
||||
if (!CollectionUtils.isEmpty(pythonTAllInfos)) {
|
||||
return pythonTAllInfos.get(0).getId();
|
||||
}
|
||||
PythonTAllInfo pythonTAllInfo = new PythonTAllInfo();
|
||||
pythonTAllInfo.setImagePath(path);
|
||||
int insert = pythonTAllInfoMapper.insert(pythonTAllInfo);
|
||||
if (insert != 1) {
|
||||
throw new BusinessException("插入失败");
|
||||
}
|
||||
return pythonTAllInfo.getId();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,15 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail){
|
||||
if (Objects.isNull(detail)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail){
|
||||
if (Objects.isNull(detail)) {
|
||||
return null;
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
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.response.PageBaseResponse;
|
||||
import com.ai.da.mapper.WorkspaceMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.Workspace;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
import com.ai.da.model.enums.IEnumDisplay;
|
||||
import com.ai.da.model.enums.Position;
|
||||
import com.ai.da.model.enums.Sex;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
@@ -29,7 +33,7 @@ import java.util.List;
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
* @author Arcana
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-08-01
|
||||
*/
|
||||
@Service
|
||||
@@ -47,20 +51,61 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
public boolean saveOrUpdate(Workspace workspace) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
workspace.setUserName(userInfo.getUsername());
|
||||
workspace.setIsLastIndex(0);
|
||||
if (null == workspace.getId()) {
|
||||
return workspaceMapper.insert(workspace) == 1;
|
||||
int insert = workspaceMapper.insert(workspace);
|
||||
if (insert <= 0) {
|
||||
throw new BusinessException("insert workspace failed");
|
||||
}
|
||||
return true;
|
||||
}else {
|
||||
return workspaceMapper.updateById(workspace) == 1;
|
||||
int update = workspaceMapper.updateById(workspace);
|
||||
if (update <= 0) {
|
||||
throw new BusinessException("update workspace failed");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private final static String WORKSPACE_NAME = "默认workspace名称";
|
||||
private final static Integer SYSTEM_DESIGNER_PERCENTAGE = 30;
|
||||
|
||||
@Override
|
||||
public IPage<Workspace> getPage(WorkspaceDTO query) {
|
||||
public WorkspaceVO getPage(WorkspaceDTO query) {
|
||||
WorkspaceVO vo = new WorkspaceVO();
|
||||
String userName = UserContext.getUserHolder().getUsername();
|
||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Workspace::getUserName, userName);
|
||||
IPage<Workspace> page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||
return page;
|
||||
if (page.getTotal() == 0L) {
|
||||
// 给用户新建默认workspace
|
||||
Workspace workspace = new Workspace();
|
||||
workspace.setWorkSpaceName(WORKSPACE_NAME);
|
||||
workspace.setSex(Sex.MALE.getValue());
|
||||
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
||||
workspace.setPosition(Position.OVERALL.getValue());
|
||||
workspace.setUserName(userName);
|
||||
workspace.setIsLastIndex(1);
|
||||
int insert = workspaceMapper.insert(workspace);
|
||||
if (insert <= 0) {
|
||||
throw new BusinessException("save workspace failed");
|
||||
}
|
||||
page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||
vo.setPage(PageBaseResponse.success(page));
|
||||
vo.setId(workspace.getId());
|
||||
return vo;
|
||||
}
|
||||
vo.setPage(PageBaseResponse.success(page));
|
||||
QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>();
|
||||
qwIsLastIndex.lambda().eq(Workspace::getUserName, userName);
|
||||
qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
qwIsLastIndex.last("limit 1");
|
||||
List<Workspace> workspaces = workspaceMapper.selectList(qwIsLastIndex);
|
||||
if (CollectionUtils.isEmpty(workspaces)) {
|
||||
throw new BusinessException("用户工作空间未查询到最后使用标识");
|
||||
}
|
||||
vo.setId(workspaces.get(0).getId());
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,6 +119,21 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
return getEnumValues(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Workspace getByIdNew(Long id) {
|
||||
String userName = UserContext.getUserHolder().getUsername();
|
||||
QueryWrapper<Workspace> qwOld = new QueryWrapper<>();
|
||||
qwOld.lambda().eq(Workspace::getUserName, userName);
|
||||
qwOld.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
Workspace oldIsLastIndex = workspaceMapper.selectOne(qwOld);
|
||||
oldIsLastIndex.setIsLastIndex(0);
|
||||
workspaceMapper.updateById(oldIsLastIndex);
|
||||
Workspace newIsLastIndex= workspaceMapper.selectById(id);
|
||||
newIsLastIndex.setIsLastIndex(1);
|
||||
workspaceMapper.updateById(newIsLastIndex);
|
||||
return newIsLastIndex;
|
||||
}
|
||||
|
||||
private List<BizJson> getEnumValues(Class clazz) {
|
||||
List<BizJson> kvs = new ArrayList<BizJson>();
|
||||
IEnumDisplay[] items = (IEnumDisplay[]) clazz.getEnumConstants();
|
||||
|
||||
Reference in New Issue
Block a user