Merge remote-tracking branch 'origin/dev_shb' into develop

# Conflicts:
#	src/main/java/com/ai/da/service/impl/DesignServiceImpl.java
#	src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java
This commit is contained in:
xupei
2023-09-20 13:02:02 +08:00
17 changed files with 618 additions and 376 deletions

View File

@@ -15,7 +15,8 @@ public enum DesignTypeEnum {
/**
* Library
*/
LIBRARY("Library");
LIBRARY("Library"),
GENERATE("Generate");
private String realName;

View File

@@ -3,8 +3,10 @@ package com.ai.da.controller;
import com.ai.da.common.response.Response;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.entity.Workspace;
import com.ai.da.model.dto.ModelsDotDTO;
import com.ai.da.model.dto.WorkspaceDTO;
import com.ai.da.model.enums.BizJson;
import com.ai.da.model.vo.ModelsVO;
import com.ai.da.model.vo.WorkspaceVO;
import com.ai.da.service.WorkspaceService;
import io.swagger.annotations.Api;
@@ -38,29 +40,6 @@ public class WorkspaceController {
@Resource
private WorkspaceService workspaceService;
@Resource
private MinioUtil minIoUtil;
@Value("${minio.endpoint}")
public String address;
@Value("${minio.bucketName}")
public String bucketName;
@PostMapping("/upload")
public Object upload(MultipartFile file) {
List<String> upload = minIoUtil.upload(new MultipartFile[]{file});
return address+"/"+bucketName+"/"+upload.get(0);
}
@PostMapping("/getUrl")
public Object getUrl() {
return minIoUtil.getPresignedUrl("test", "R-C_1694066189047.png", 5);
}
/**
* 详情
*/
@@ -112,5 +91,13 @@ public class WorkspaceController {
return Response.success(bizJsonList);
}
@GetMapping("/getMannequins")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "获取模特")
public Response<List<ModelsVO>> getMannequins() {
List<ModelsVO> modelsVO = workspaceService.getMannequins();
return Response.success(modelsVO);
}
}

View File

@@ -41,6 +41,8 @@ public class CollectionElement implements Serializable {
*/
private Long collectionId;
private String type;
/**
* 一级类型
*/

View File

@@ -0,0 +1,13 @@
package com.ai.da.model.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelVO {
private Long id;
private String url;
}

View File

@@ -0,0 +1,14 @@
package com.ai.da.model.vo;
import lombok.*;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelsVO {
private List<ModelVO> modelList;
private String type;
}

View File

@@ -28,6 +28,8 @@ public class ValidateElementVO {
List<Long> usedElementIds = Lists.newArrayList();
//用于存储library 生成collection
List<CollectionElement> libraryCollectionElements = Lists.newArrayList();
//用于存储generate 生成collection
List<CollectionElement> generateCollectionElements = Lists.newArrayList();
//存储template打点数据
DesignLibraryModelPointVO designLibraryModelPoint =null;
//存储本次design已经使用的上衣和下衣的的MD5list 去重用

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,15 @@
package com.ai.da.service;
import com.ai.da.mapper.entity.Design;
import com.ai.da.mapper.entity.Generate;
import com.ai.da.model.dto.GenerateLikeDTO;
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
import com.ai.da.model.vo.GenerateCaptionVO;
import com.ai.da.model.vo.GenerateCollectionVO;
import com.ai.da.model.vo.GenerateLikeVO;
import com.baomidou.mybatisplus.extension.service.IService;
public interface GenerateService {
public interface GenerateService extends IService<Generate> {
GenerateCaptionVO generateCaption(Long sketchElementId);

View File

@@ -4,6 +4,7 @@ package com.ai.da.service;
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.vo.ModelsVO;
import com.ai.da.model.vo.WorkspaceVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -35,4 +36,6 @@ public interface WorkspaceService extends IService<Workspace> {
List<BizJson> getEnumValues(String enumName);
Workspace getByIdNew(Long id);
List<ModelsVO> getMannequins();
}

View File

@@ -64,6 +64,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Resource
private LibraryService libraryService;
@Resource
private GenerateService generateService;
@Resource
private LibraryModelPointService libraryModelPointService;
@Resource
private TCollectionElementRelationService tCollectionElementRelationService;
@@ -231,6 +233,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
List<Long> usedElementIds = elementVO.getUsedElementIds();
List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements();
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements();
//校验moodboard
if (CollectionUtil.isNotEmpty(designDTO.getMoodBoards())) {
//校验designType
@@ -258,6 +261,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,null));
}
}
// generate
List<Long> generateIds = designDTO.getMoodBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(DesignCollectionElementDTO::getId)
.collect((Collectors.toList()));
if(CollectionUtil.isNotEmpty(generateIds)) {
List<Generate> generateList = generateService.listByIds(generateIds);
if(CollectionUtil.isNotEmpty(generateList)){
generateCollectionElements.addAll(covertGeneratesToCollections(generateList,null));
}
}
}
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
//校验designType
@@ -289,6 +303,20 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
libraryCollectionElements.addAll(covertLibrarysToPrintCollections(librarys,idToMap));
}
}
// generate
List<Long> generateIds = designDTO.getPrintBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(DesignCollectionPrintElementDTO::getId)
.collect((Collectors.toList()));
if(CollectionUtil.isNotEmpty(generateIds)) {
List<Generate> generateList = generateService.listByIds(generateIds);
if(CollectionUtil.isNotEmpty(generateList)){
Map<Long,DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
.stream()
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId,v ->v));
generateCollectionElements.addAll(covertGeneratesToPrintCollections(generateList,idToMap));
}
}
}
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
//校验PIN是否满足 上衣或者下衣必须不超过8
@@ -335,6 +363,20 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,idToMap));
}
}
// generate
List<Long> generateIds = designDTO.getSketchBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(CollectionSketchDTO::getSketchBoardId)
.collect((Collectors.toList()));
if(CollectionUtil.isNotEmpty(generateIds)) {
List<Generate> generateList = generateService.listByIds(generateIds);
if(CollectionUtil.isNotEmpty(generateList)){
Map<Long,CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId,v ->v));
generateCollectionElements.addAll(covertGeneratesToCollections(generateList,idToMap));
}
}
}
//校验marketingSketch
// 2023.12版本去掉了这个入参
@@ -411,11 +453,30 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
});
}
private List<CollectionElement> covertGeneratesToCollections(List<Generate> generates, Map<Long,CollectionSketchDTO> idToMap){
return CopyUtil.copyList(generates,CollectionElement.class,(o,d) ->{
if(null != idToMap){
CollectionSketchDTO sketchDTO = idToMap.get(o.getId());
d.setLevel2Type(sketchDTO.getLevel2Type());
d.setHasPin(sketchDTO.getIsPin());
}
});
}
private List<CollectionElement> covertLibrarysToPrintCollections(List<Library> libraries, Map<Long,DesignCollectionPrintElementDTO> idToMap){
return CopyUtil.copyList(libraries,CollectionElement.class,(o,d) ->{
if(null != idToMap){
DesignCollectionPrintElementDTO sketchDTO = idToMap.get(o.getId());
d.setHasPin(sketchDTO.getIsPin());
DesignCollectionPrintElementDTO printDTO = idToMap.get(o.getId());
d.setHasPin(printDTO.getIsPin());
}
});
}
private List<CollectionElement> covertGeneratesToPrintCollections(List<Generate> generates, Map<Long,DesignCollectionPrintElementDTO> idToMap){
return CopyUtil.copyList(generates,CollectionElement.class,(o,d) ->{
if(null != idToMap){
DesignCollectionPrintElementDTO printDTO = idToMap.get(o.getId());
d.setHasPin(printDTO.getIsPin());
}
});
}

View File

@@ -69,7 +69,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
private PanToneService panToneService;
@Resource
private MinioUtil minioUtil;
@Value("${minio.bucketName}")
@Value("${minio.bucketName.results}")
private String bucketName;
@Override

View File

@@ -5,6 +5,7 @@ import com.ai.da.common.config.FileProperties;
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.DesignTypeEnum;
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
import com.ai.da.common.utils.*;
import com.ai.da.mapper.DesignMapper;
@@ -83,7 +84,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
private PythonTAllInfoService pythonTAllInfoService;
@Value("${minio.endpoint}")
private String endpoint;
@Value("${minio.bucketName}")
@Value("${minio.bucketName.results}")
private String bucketName;
// @Transactional
@@ -95,6 +96,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
//design
return designOrRedesignOperateNew(designDTO, userInfo, null, elementVO);
}
private void calculateLibraryAndSysFile(DesignCollectionDTO designDTO, ValidateElementVO elementVO, AuthPrincipalVo userInfo) {
//查询用户 sketch library
List<LibraryVo> libraryVos;
@@ -120,6 +122,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
//校验比列
validateRatio(designDTO, libraryVos);
}
private void validateRatio(DesignCollectionDTO designDTO, List<LibraryVo> libraryVos) {
//校验系统比列,先去掉 考虑到程序已经进入比较后面了,该校验不重要,且会产生脏数据
// BigDecimal bigDecimal = designDTO.getSystemScale();
@@ -130,6 +133,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// throw new BusinessException("No sketch, please increase the system rate");
// }
}
private void saveCollectionElemntsByLibrarys(ValidateElementVO elementVO, Long collectionId) {
if (CollectionUtils.isEmpty(elementVO.getLibraryCollectionElements())) {
return;
@@ -142,6 +146,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
element.setHasPin((byte) 0);
}
element.setId(null);
// element.setType(DesignTypeEnum.LIBRARY.getRealName());
});
List<CollectionElement> saveElements = elementVO.getLibraryCollectionElements();
collectionElementService.saveBatch(saveElements);
@@ -160,7 +165,55 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (!CollectionUtils.isEmpty(newPrintboard)) {
elementVO.getPrintBoardElements().addAll(newPrintboard);
}
//mood
List<CollectionElement> newMoodboard = saveElements.stream()
.filter(f -> f.getLevel1Type().equals(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(newMoodboard)) {
elementVO.getMoodBoardElements().addAll(newMoodboard);
}
}
private void saveCollectionElemntsByGenerates(ValidateElementVO elementVO, Long collectionId) {
if (CollectionUtils.isEmpty(elementVO.getGenerateCollectionElements())) {
return;
}
elementVO.getGenerateCollectionElements()
.forEach(element -> {
element.setCollectionId(collectionId);
Byte hasPin = element.getHasPin();
if (Objects.isNull(hasPin)) {
element.setHasPin((byte) 0);
}
element.setId(null);
// element.setType(DesignTypeEnum.GENERATE.getRealName());
});
List<CollectionElement> saveElements = elementVO.getGenerateCollectionElements();
collectionElementService.saveBatch(saveElements);
elementVO.getUsedElementIds().addAll(saveElements.stream().map(CollectionElement::getId).collect(Collectors.toList()));
//sketch
List<CollectionElement> newSketchAboard = saveElements.stream()
.filter(f -> f.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(newSketchAboard)) {
elementVO.getSketchBoardElements().addAll(newSketchAboard);
}
//print
List<CollectionElement> newPrintboard = saveElements.stream()
.filter(f -> f.getLevel1Type().equals(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(newPrintboard)) {
elementVO.getPrintBoardElements().addAll(newPrintboard);
}
//mood
List<CollectionElement> newMoodboard = saveElements.stream()
.filter(f -> f.getLevel1Type().equals(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(newMoodboard)) {
elementVO.getMoodBoardElements().addAll(newMoodboard);
}
}
private DesignCollectionVO designOrRedesignOperate(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
Long collectionIdParam, ValidateElementVO elementVO) {
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
@@ -222,6 +275,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElementService.relationCollection(elementIds, collectionId);
//library转化为collection(生成)
saveCollectionElemntsByLibrarys(elementVO, collectionId);
//generate转化为collection(生成)
saveCollectionElemntsByGenerates(elementVO, collectionId);
//保存颜色版
List<CollectionElementVO> colorElementList = collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
//保存design
@@ -260,10 +315,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path();
Long imageId = pythonTAllInfoService.getImageIdByPath(bodyPath);
item.setImageId(imageId);
item.setImage_id(imageId);
} else {
Long imageId = pythonTAllInfoService.getImageIdByPath(path);
item.setImageId(imageId);
item.setImage_id(imageId);
}
}
}
@@ -287,6 +342,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
.build()
).collect(Collectors.toList()));
}
private void generateLibrary(ValidateElementVO elementVO, String timeZone) {
List<CollectionElement> elements = Lists.newArrayList();
if (!CollectionUtils.isEmpty(elementVO.getMoodBoardElements())) {
@@ -303,6 +359,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
collectionElementService.saveLibraryByCollectionElement(elements, timeZone);
}
@Override
public BigDecimal countDesignProcess() {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
@@ -337,12 +394,14 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
private void setDesignProcess(Long userId, DesignPythonObjects pythonObjects) {
List<String> saveNames = pythonObjects.getObjects().stream().map(object -> {
return object.getBasic().getSave_name();}).collect(Collectors.toList());
return object.getBasic().getSave_name();
}).collect(Collectors.toList());
LocalCacheUtils.setDesignProcessCache(userId, saveNames);
}
@Resource
private MinioUtil minIoUtil;
private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject responseJSONObject) {
DesignCollectionVO response = new DesignCollectionVO();
@@ -420,7 +479,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designCollectionItemVO.setDesignItemId(designItemId);
designCollectionItemVO.setDesignItemUrl(designItem.getDesignUrl());
designCollectionItemVO.setDesignOutfitId(designPythonOutfit.getId());
designCollectionItemVO.setDesignOutfitUrl(minIoUtil.getPresignedUrl(bucketName, designPythonOutfit.getDesignUrl(), 5));
String designUrl = designPythonOutfit.getDesignUrl();
if (!StringUtils.isEmpty(designUrl) && designUrl.contains("/")) {
int firstIndex = designUrl.indexOf("/");
designCollectionItemVO.setDesignOutfitUrl(minIoUtil.getPresignedUrl(designUrl.substring(0,firstIndex), designUrl.substring(firstIndex+1), 5));
}
//response
designCollectionItems.add(designCollectionItemVO);
@@ -498,6 +561,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
});
return response;
}
private List<Long> getElementId(ValidateElementVO elementVO) {
List<Long> elementIds = Lists.newArrayList();
// collection type
@@ -541,6 +605,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return designOrRedesignOperate(CopyUtil.copyObject(
reDesignDTO, DesignCollectionDTO.class), userInfo, reDesignDTO.getCollectionId(), elementVO);
}
private List<Long> calculateNoRelationElement(Long collectionId, List<Long> usedElementIds) {
List<CollectionElement> collectionElements = collectionElementService.getByCollectionId(collectionId);
if (CollectionUtils.isEmpty(collectionElements)) {
@@ -565,6 +630,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
return new DesignCollectionVO(designId, design.getCollectionId(), coverDesignItemToVO(designItems));
}
private List<DesignCollectionItemVO> coverDesignItemToVO(List<DesignItem> designItems) {
List<DesignCollectionItemVO> response = Lists.newArrayList();
designItems.forEach(designItem -> {
@@ -643,6 +709,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
});
return adds;
}
private int calculateGroupNum(List<CollectionElement> thisElement, List<Long> adds) {
int num = 0;
List<Long> groupOldIds = thisElement.stream().map(CollectionElement::getId).collect(Collectors.toList());
@@ -653,6 +720,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
return num + thisElement.size();
}
private UserLike resolveUserLike(Long userGroupId, Long designId, Long designItemId, String designUrl, String timeZone) {
UserLike userLike = new UserLike();
userLike.setCreateDate(DateUtil.getByTimeZone(timeZone));
@@ -762,6 +830,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
minIoUtil.splitThenGetPreviewUrl(designItem.getDesignUrl(),480),
editResponseColor(designItemDetails,response));
}
private String converTypeToLevel1(String type) {
if (StringUtils.isEmpty(type)) {
return null;
@@ -781,6 +850,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
queryWrapper.eq("collection_id", collectionId);
return designMapper.selectOne(queryWrapper);
}
private int deleteByCollectionId(Long collectionId) {
QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("collection_id", collectionId);
@@ -878,6 +948,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} else {
designItemDetailVO.setDesignItemUrl(designItemUrl);
}
return designItemDetailVO;
}
}

View File

@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function;
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;
@@ -48,6 +49,10 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
private LibraryModelPointService libraryModelPointService;
@Resource
private MinioUtil minioUtil;
@Value("minio.bucketName.mannequins")
private String mannequins;
@Value("minio.bucketName.users")
private String users;
private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
CollectionLevel2TypeEnum.OUTWEAR.getRealName(),CollectionLevel2TypeEnum.BLOUSE.getRealName());
@@ -144,39 +149,49 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
Assert.isTrue(!( level1TypeEnum.equals(LibraryLevel1TypeEnum.SKETCH_BOARD)
&& StringUtils.isEmpty(libraryUploadDTO.getLevel2Type()) ),"level2Type cannot be empty!");
String path = calculateFileUrl(level1TypeEnum, userInfo.getId());
File file = FileUtil.upload(libraryUploadDTO.getFile(), path);
String bucketName = null;
switch (level1TypeEnum) {
case MODELS:
bucketName = mannequins;
break;
case MOOD_BOARD:
case PRINT_BOARD:
case SKETCH_BOARD:
bucketName = users;
break;
case MARKETING_SKETCH:
break;
default:
throw new BusinessException("unknown level1_type");
}
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
//保存element元素
Library library = resolveData(libraryUploadDTO, userInfo, file);
saveOne(library);
Library library = resolveData(libraryUploadDTO, userInfo, filePath, bucketName);
return CopyUtil.copyObject(library,LibraryUpdateVo.class);
}
private Library resolveData(LibraryUploadDTO uploadDTO, AuthPrincipalVo userInfo, File file) {
private Library resolveData(LibraryUploadDTO uploadDTO, AuthPrincipalVo userInfo, String filePath, String bucketName) {
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
library.setAccountId(userInfo.getId());
String pictureName = file.getName();
//获取图片后缀
String suffix = pictureName.substring(pictureName.lastIndexOf("."));
//获取图片前缀
String prefix = pictureName.substring(0,pictureName.lastIndexOf("."));
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
library.setUrl(file.getAbsolutePath());
library.setUrl(bucketName + File.separator + filePath);
//按时区计算
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
String linuxDomain = fileProperties.getLinuxDomain();
if (!StringUtils.isEmpty(linuxDomain)) {
//linux 系统
String oldPath = fileProperties.getSys().getPath();
library.setUrl(file.getAbsolutePath().replace(oldPath, linuxDomain));
}
// String linuxDomain = fileProperties.getLinuxDomain();
// if (!StringUtils.isEmpty(linuxDomain)) {
// //linux 系统
// String oldPath = fileProperties.getSys().getPath();
// library.setUrl(file.getAbsolutePath().replace(oldPath, linuxDomain));
// }
libraryMapper.insert(library);
return library;
}
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, Long userId) {
String rootPath = fileProperties.getSys().getPath();
// String rootPath = fileProperties.getSys().getPath();
String day = DateUtil.dateToStr(new Date(), DateUtil.YYYYMM);
return rootPath + day + File.separator + "userFile" + File.separator + "library"
+ File.separator + level1TypeEnum.getRealName() + File.separator + userId + File.separator+UUID.randomUUID().toString();
return day + File.separator + "userFile" + File.separator + "library"
+ File.separator + level1TypeEnum.getRealName() + File.separator + userId;
}
@Override

View File

@@ -28,7 +28,7 @@ import java.util.Objects;
@Service
public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPythonOutfitDetailMapper, TDesignPythonOutfitDetail> implements ITDesignPythonOutfitDetailService {
@Value("${minio.bucketName2}")
@Value("${minio.bucketName.clothing}")
private String bucketName2;
@Value("${minio.bucketName3}")
private String bucketName3;

View File

@@ -2,9 +2,15 @@ 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.LibraryLevel1TypeEnum;
import com.ai.da.common.enums.SysFileLevel1TypeEnum;
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.mapper.LibraryMapper;
import com.ai.da.mapper.SysFileMapper;
import com.ai.da.mapper.WorkspaceMapper;
import com.ai.da.mapper.entity.Account;
import com.ai.da.mapper.entity.Library;
import com.ai.da.mapper.entity.SysFile;
import com.ai.da.mapper.entity.Workspace;
import com.ai.da.model.dto.WorkspaceDTO;
import com.ai.da.model.enums.BizJson;
@@ -12,21 +18,20 @@ 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.ModelVO;
import com.ai.da.model.vo.ModelsVO;
import com.ai.da.model.vo.WorkspaceVO;
import com.ai.da.service.LibraryService;
import com.ai.da.service.SysFileService;
import com.ai.da.service.WorkspaceService;
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 org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -42,6 +47,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
@Resource
private WorkspaceMapper workspaceMapper;
@Resource
private LibraryMapper libraryMapper;
@Resource
private SysFileMapper sysFileMapper;
@Override
public IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace) {
return page.setRecords(baseMapper.selectWorkspacePage(page, workspace));
@@ -134,6 +145,45 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return newIsLastIndex;
}
@Override
public List<ModelsVO> getMannequins() {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
List<ModelsVO> result = new ArrayList<>();
QueryWrapper<Library> libraryQueryWrapper = new QueryWrapper<>();
libraryQueryWrapper.lambda().eq(Library::getAccountId, userInfo.getId());
libraryQueryWrapper.lambda().eq(Library::getLevel1Type, LibraryLevel1TypeEnum.MODELS.getRealName());
List<Library> libraries = libraryMapper.selectList(libraryQueryWrapper);
if (!CollectionUtils.isEmpty(libraries)) {
List<ModelVO> modelVOList = new ArrayList<>();
for (Library library : libraries) {
ModelVO modelVO = new ModelVO();
modelVO.setId(library.getId());
modelVO.setUrl(library.getUrl());
}
ModelsVO vo = new ModelsVO();
vo.setModelList(modelVOList);
vo.setType("Library");
result.add(vo);
}
QueryWrapper<SysFile> sysFileQueryWrapper = new QueryWrapper<>();
sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, SysFileLevel1TypeEnum.ACCESSORIES.getRealName());
sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, SysFileLevel2TypeEnum.BODY.getRealName());
List<SysFile> sysFileList = sysFileMapper.selectList(sysFileQueryWrapper);
if (!CollectionUtils.isEmpty(sysFileList)) {
List<ModelVO> modelVOList = new ArrayList<>();
for (SysFile sysFile : sysFileList) {
ModelVO modelVO = new ModelVO();
modelVO.setId(sysFile.getId());
modelVO.setUrl(sysFile.getUrl());
}
ModelsVO vo = new ModelsVO();
vo.setModelList(modelVOList);
vo.setType("System");
result.add(vo);
}
return result;
}
private List<BizJson> getEnumValues(Class clazz) {
List<BizJson> kvs = new ArrayList<BizJson>();
IEnumDisplay[] items = (IEnumDisplay[]) clazz.getEnumConstants();

View File

@@ -1,10 +1,11 @@
server.port=5566
server.port=5567
#datasource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://18.167.251.121:3306/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.url=jdbc:mysql://18.167.251.121:33006/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=QWa998345
spring.datasource.password=root
#spring.datasource.password=QWa998345
#security
spring.security.jwtSecret=JWTSECRET
@@ -14,7 +15,7 @@ spring.security.jwtTokenPrefix=Bearer-
spring.security.jwtExpiration=8640000000
#spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/workspace/**
spring.security.authApi=/auth/login
@@ -24,6 +25,9 @@ rsa.private_key=MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8
mybatis-plus.global-config.banner=false
mybatis-plus.mapper-locations=classpath:mapper/*Mapper.xml
#mybatis-plus.configuration.log-impl= org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus.global-config.db-config.logic-delete-field=isDeleted
mybatis-plus.global-config.db-config.logic-delete-value=1
mybatis-plus.global-config.db-config.logic-not-delete-value=0
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
@@ -36,3 +40,14 @@ spring.servlet.multipart.max-file-size = 5MB
spring.servlet.multipart.max-request-size= 5MB
#访问python服务的ip(对应环境)
access.python.ip=http://43.198.80.117
#access.python.ip=http://18.167.251.121
#access.python.ip=http://18.167.251.121:9991/
minio.endpoint=http://18.167.251.121:9000
minio.accessKey=minioadmin
minio.secretKey=minioadmin
minio.bucketName.clothing=aida-clothing
minio.bucketName.mannequins=aida-mannequins
minio.bucketName.results=aida-results
minio.bucketName.sysImage=aida-sys-image
minio.bucketName.users=aida-users

View File

@@ -1,5 +1,5 @@
#<23><><EFBFBD><EFBFBD>application-test<73>ļ<EFBFBD>(<28><><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>)
spring.profiles.active=test
spring.profiles.active=prod
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
#spring.profiles.active=prod