TASK:代码提交;
This commit is contained in:
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,4 +41,8 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
List<ModelsVO> getMannequins(String sex);
|
||||
|
||||
void systemFileCopy();
|
||||
|
||||
void moveFile();
|
||||
|
||||
void maleDataInsert() throws FileNotFoundException;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(uploadDTO.getLevel1Type());
|
||||
Assert.notNull(level1TypeEnum, "unknown parameter level1Type!");
|
||||
|
||||
// String path = calculateFileUrl(level1TypeEnum, userInfo.getId());aida-collection-element
|
||||
String objectName = userInfo.getId() + "/" + level1TypeEnum.getRealName();
|
||||
String path = minioUtil.upload("aida-collection-element", objectName, uploadDTO.getFile());
|
||||
// File file = FileUtil.upload(uploadDTO.getFile(), path);
|
||||
|
||||
//保存element元素
|
||||
CollectionElement collectionElement = resolveData(uploadDTO, userInfo, path);
|
||||
saveOne(collectionElement);
|
||||
|
||||
@@ -75,7 +75,9 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
Assert.notEmpty(collectionElements,"collection element does not exist!");
|
||||
response.setCollectionId(id);
|
||||
response.setMoodTemplateId(collection.getMoodTemplateId());
|
||||
response.setMoodTemplateUrl(minioUtil.getPresignedUrl(collectionElementService.getById(response.getMoodTemplateId()).getUrl(), 10));
|
||||
if (collection.getMoodTemplateId() != null) {
|
||||
response.setMoodTemplateUrl(minioUtil.getPresignedUrl(collectionElementService.getById(response.getMoodTemplateId()).getUrl(), 10));
|
||||
}
|
||||
Map<String,List<CollectionElement>> maps = collectionElements
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(CollectionElement::getLevel1Type));
|
||||
|
||||
@@ -110,24 +110,26 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private void calculateLibraryAndSysFile(DesignCollectionDTO designDTO, ValidateElementVO elementVO, AuthPrincipalVo userInfo) {
|
||||
//查询用户 sketch library
|
||||
List<LibraryVo> libraryVos;
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
List<String> sketchUrlList = elementVO.getSketchBoardElements()
|
||||
.stream()
|
||||
.map(CollectionElement::getUrl)
|
||||
.collect(Collectors.toList());
|
||||
DesignAttributeRetrievalDTO designAttributeRetrievalDTO =
|
||||
pythonService.generateAttributeRetrieval(sketchUrlList, userInfo.getId());
|
||||
if (CollectionUtils.isEmpty(designAttributeRetrievalDTO.getLibraryUrls())) {
|
||||
libraryVos = null;
|
||||
} else {
|
||||
libraryVos = libraryService.getByUrlList(designAttributeRetrievalDTO.getLibraryUrls(), userInfo.getId());
|
||||
}
|
||||
List<SysFileVO> sysFileVOS = sysFileService.getByUrlList(designAttributeRetrievalDTO.getSysFileUrlS());
|
||||
elementVO.setSysFileVo(sysFileVOS);
|
||||
} else {
|
||||
libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
// List<String> sketchUrlList = elementVO.getSketchBoardElements()
|
||||
// .stream()
|
||||
// .map(CollectionElement::getUrl)
|
||||
// .collect(Collectors.toList());
|
||||
// DesignAttributeRetrievalDTO designAttributeRetrievalDTO =
|
||||
// pythonService.generateAttributeRetrieval(sketchUrlList, userInfo.getId());
|
||||
// if (CollectionUtils.isEmpty(designAttributeRetrievalDTO.getLibraryUrls())) {
|
||||
// libraryVos = null;
|
||||
// } else {
|
||||
// libraryVos = libraryService.getByUrlList(designAttributeRetrievalDTO.getLibraryUrls(), userInfo.getId());
|
||||
// }
|
||||
// List<SysFileVO> sysFileVOS = sysFileService.getByUrlList(designAttributeRetrievalDTO.getSysFileUrlS());
|
||||
// elementVO.setSysFileVo(sysFileVOS);
|
||||
// } else {
|
||||
// libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
// Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||
// }
|
||||
libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||
elementVO.setLibraryVos(libraryVos);
|
||||
//校验比列
|
||||
validateRatio(designDTO, libraryVos);
|
||||
@@ -227,48 +229,48 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
}
|
||||
|
||||
private DesignCollectionVO designOrRedesignOperate(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
||||
Long collectionIdParam, ValidateElementVO elementVO) {
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
//编辑sketchBoard
|
||||
collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
||||
//编辑printBoard
|
||||
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||
}
|
||||
//保存collection
|
||||
Long collectionId = (null == collectionIdParam) ?
|
||||
collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId()) : collectionIdParam;
|
||||
List<Long> elementIds = getElementId(elementVO);
|
||||
//批量关联element 到 collection
|
||||
collectionElementService.relationCollection(elementIds, collectionId);
|
||||
//library转化为collection(生成)
|
||||
saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
||||
//保存颜色版
|
||||
List<CollectionElementVO> colorElementList = collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
||||
//保存design
|
||||
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||
//计算library
|
||||
calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
||||
//组装design入参
|
||||
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
||||
//缓存保存的文件 方便后面处理进度问题 采用新的进度条获取方式 根据processId获取
|
||||
// setDesignProcess(userInfo.getId(), pythonObjects);
|
||||
//design
|
||||
pythonService.design(pythonObjects);
|
||||
//生成library
|
||||
generateLibrary(elementVO, designDTO.getTimeZone());
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
List<CollectionElement> reLationelements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||
List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||
handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
|
||||
//保存python返回信息
|
||||
// return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
|
||||
//保存designItem 和detail
|
||||
return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone());
|
||||
}
|
||||
// private DesignCollectionVO designOrRedesignOperate(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
||||
// Long collectionIdParam, ValidateElementVO elementVO) {
|
||||
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
// //编辑sketchBoard
|
||||
// collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
||||
// }
|
||||
// if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
||||
// //编辑printBoard
|
||||
// collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||
// }
|
||||
// //保存collection
|
||||
// Long collectionId = (null == collectionIdParam) ?
|
||||
// collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId()) : collectionIdParam;
|
||||
// List<Long> elementIds = getElementId(elementVO);
|
||||
// //批量关联element 到 collection
|
||||
// collectionElementService.relationCollection(elementIds, collectionId);
|
||||
// //library转化为collection(生成)
|
||||
// saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
||||
// //保存颜色版
|
||||
// List<CollectionElementVO> colorElementList = collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
||||
// //保存design
|
||||
// Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||
// //计算library
|
||||
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
||||
// //组装design入参
|
||||
// DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||
// designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
||||
// //缓存保存的文件 方便后面处理进度问题 采用新的进度条获取方式 根据processId获取
|
||||
//// setDesignProcess(userInfo.getId(), pythonObjects);
|
||||
// //design
|
||||
// pythonService.design(pythonObjects);
|
||||
// //生成library
|
||||
// generateLibrary(elementVO, designDTO.getTimeZone());
|
||||
// //处理关联关系,修复element覆盖得情况
|
||||
// List<CollectionElement> reLationelements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||
// List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||
// handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
|
||||
// //保存python返回信息
|
||||
//// return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
|
||||
// //保存designItem 和detail
|
||||
// return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone());
|
||||
// }
|
||||
|
||||
private DesignCollectionVO designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
||||
Long collectionIdParam, ValidateElementVO elementVO) {
|
||||
@@ -876,10 +878,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||
String param = JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.info("design请求python 参数:####{}", param);
|
||||
log.info("designProcess请求python 参数:####{}", param);
|
||||
RequestBody body = RequestBody.create(mediaType, param);
|
||||
Request request = new Request.Builder()
|
||||
.url("http://18.167.251.121:9991/api/model_process")
|
||||
.url("http://18.167.251.121:9991/api/get_progress")
|
||||
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
||||
.method("POST", body)
|
||||
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.ai.da.common.enums.*;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.LibraryMapper;
|
||||
import com.ai.da.mapper.SysFileMapper;
|
||||
@@ -36,7 +35,6 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -91,6 +89,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
Assert.notNull(level1TypeEnum,"unknown level1Type " +query.getLevel1Type());
|
||||
queryWrapper.eq("level1_type", query.getLevel1Type());
|
||||
}
|
||||
if (!StringUtils.isEmpty(query.getModelSex()) && query.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
|
||||
queryWrapper.eq("level3_type", query.getModelSex());
|
||||
}
|
||||
if(!StringUtils.isEmpty(query.getLevel2Type())){
|
||||
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(query.getLevel2Type());
|
||||
Assert.notNull(level2TypeEnum,"unknown level2Type " +query.getLevel2Type());
|
||||
@@ -159,7 +160,7 @@ 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, libraryUploadDTO.getLevel2Type(), userInfo.getId());
|
||||
String path = calculateFileUrl(level1TypeEnum, libraryUploadDTO.getLevel2Type(), libraryUploadDTO.getModelSex(), userInfo.getId());
|
||||
String bucketName = null;
|
||||
switch (level1TypeEnum) {
|
||||
case MODELS:
|
||||
@@ -174,7 +175,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
throw new BusinessException("unknown level1_type");
|
||||
}
|
||||
//保存element元素
|
||||
if (libraryUploadDTO.getModelType() != null) {
|
||||
if (!StringUtils.isEmpty(libraryUploadDTO.getModelType())) {
|
||||
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||
String newFilePath = processMannequins(filePath);
|
||||
@@ -185,7 +186,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
return libraryUpdateVo;
|
||||
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
bucketName = "aida-sys-image";
|
||||
path = "models/" + libraryUploadDTO.getModelSex();
|
||||
path = "models/" + libraryUploadDTO.getModelSex().toLowerCase();
|
||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||
String newFilePath = processMannequins(filePath);
|
||||
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
||||
@@ -262,12 +263,11 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
library.setUrl(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));
|
||||
// }
|
||||
if (uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
library.setLevel2Type(uploadDTO.getModelSex());
|
||||
}else {
|
||||
library.setLevel3Type(uploadDTO.getModelSex());
|
||||
}
|
||||
libraryMapper.insert(library);
|
||||
return library;
|
||||
}else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
@@ -288,10 +288,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
}
|
||||
}
|
||||
|
||||
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, String level2Type, Long userId) {
|
||||
// String rootPath = fileProperties.getSys().getPath();
|
||||
// String day = DateUtil.dateToStr(new Date(), DateUtil.YYYYMM);
|
||||
return StringUtils.isEmpty(level2Type) ? userId + "/" + level1TypeEnum.getRealName().toLowerCase() : userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + level2Type;
|
||||
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, String level2Type, String modelSex, Long userId) {
|
||||
if (StringUtils.isEmpty(modelSex)) {
|
||||
return StringUtils.isEmpty(level2Type) ? userId + "/" + level1TypeEnum.getRealName().toLowerCase() : userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + level2Type;
|
||||
}else {
|
||||
return StringUtils.isEmpty(level2Type) ? userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + modelSex : userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + modelSex + "/" + level2Type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,9 @@ 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.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.LibraryMapper;
|
||||
import com.ai.da.mapper.SysFileMapper;
|
||||
@@ -37,12 +39,10 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -85,9 +85,23 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
workspace.setUserName(userInfo.getUsername());
|
||||
if (null == workspace.getId()) {
|
||||
workspace.setIsLastIndex(0);
|
||||
workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714432.png");
|
||||
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
|
||||
workspace.setSex(Sex.MALE.getValue());
|
||||
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
||||
systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
systemFemaleQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
List<SysFile> sysFemaleFiles = sysFileMapper.selectList(systemFemaleQw);
|
||||
if (!CollectionUtils.isEmpty(sysFemaleFiles)) {
|
||||
workspace.setMannequinFemaleId(sysFemaleFiles.get(0).getId());
|
||||
workspace.setMannequinFemaleType(MannequinType.SYSTEM.getValue());
|
||||
}
|
||||
QueryWrapper<SysFile> systemMaleQw = new QueryWrapper<>();
|
||||
systemMaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
systemMaleQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
List<SysFile> sysMaleFiles = sysFileMapper.selectList(systemFemaleQw);
|
||||
if (!CollectionUtils.isEmpty(sysMaleFiles)) {
|
||||
workspace.setMannequinMaleId(sysMaleFiles.get(0).getId());
|
||||
workspace.setMannequinMaleType(MannequinType.SYSTEM.getValue());
|
||||
}
|
||||
workspace.setSex(Sex.FEMALE.getValue());
|
||||
workspace.setPosition("Overall");
|
||||
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
||||
int insert = workspaceMapper.insert(workspace);
|
||||
@@ -115,22 +129,25 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
// 给用户新建默认workspace
|
||||
Workspace workspace = new Workspace();
|
||||
workspace.setWorkSpaceName(WORKSPACE_NAME);
|
||||
workspace.setSex(Sex.MALE.getValue());
|
||||
workspace.setSex(Sex.FEMALE.getValue());
|
||||
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
||||
workspace.setPosition("Overall");
|
||||
workspace.setUserName(userName);
|
||||
QueryWrapper<SysFile> systemQw = new QueryWrapper<>();
|
||||
systemQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
systemQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
List<SysFile> sysFiles = sysFileMapper.selectList(systemQw);
|
||||
if (!CollectionUtils.isEmpty(sysFiles)) {
|
||||
workspace.setMannequinId(sysFiles.get(0).getId());
|
||||
workspace.setMannequinUrl(sysFiles.get(0).getUrl());
|
||||
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
|
||||
}else {
|
||||
workspace.setMannequinId(null);
|
||||
workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714432.png");
|
||||
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
|
||||
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
||||
systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
systemFemaleQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
List<SysFile> sysFemaleFiles = sysFileMapper.selectList(systemFemaleQw);
|
||||
if (!CollectionUtils.isEmpty(sysFemaleFiles)) {
|
||||
workspace.setMannequinFemaleId(sysFemaleFiles.get(0).getId());
|
||||
workspace.setMannequinFemaleType(MannequinType.SYSTEM.getValue());
|
||||
}
|
||||
QueryWrapper<SysFile> systemMaleQw = new QueryWrapper<>();
|
||||
systemMaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
systemMaleQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
List<SysFile> sysMaleFiles = sysFileMapper.selectList(systemMaleQw);
|
||||
if (!CollectionUtils.isEmpty(sysMaleFiles)) {
|
||||
workspace.setMannequinMaleId(sysMaleFiles.get(0).getId());
|
||||
workspace.setMannequinMaleType(MannequinType.SYSTEM.getValue());
|
||||
}
|
||||
workspace.setIsLastIndex(1);
|
||||
int insert = workspaceMapper.insert(workspace);
|
||||
@@ -138,23 +155,51 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
throw new BusinessException("save workspace failed");
|
||||
}
|
||||
page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||
page.getRecords().forEach(o -> {
|
||||
String url = o.getMannequinUrl();
|
||||
if (url.startsWith("aida-")) {
|
||||
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 60*24));
|
||||
}
|
||||
});
|
||||
vo.setPage(PageBaseResponse.success(page));
|
||||
IPage<WorkspaceVO> convert = page.convert(
|
||||
o -> {
|
||||
WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class);
|
||||
if (o.getMannequinFemaleId() != null) {
|
||||
if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
|
||||
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 60));
|
||||
}else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
|
||||
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 60));
|
||||
}
|
||||
}
|
||||
if (o.getMannequinMaleId() != null) {
|
||||
if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
|
||||
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 60));
|
||||
}else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
|
||||
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 60));
|
||||
}
|
||||
}
|
||||
return workspaceVO;
|
||||
}
|
||||
);
|
||||
vo.setPage(PageBaseResponse.success(convert));
|
||||
vo.setId(workspace.getId());
|
||||
return vo;
|
||||
}
|
||||
page.getRecords().forEach(o -> {
|
||||
String url = o.getMannequinUrl();
|
||||
if (url.startsWith("aida-")) {
|
||||
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 10));
|
||||
}
|
||||
});
|
||||
vo.setPage(PageBaseResponse.success(page));
|
||||
IPage<WorkspaceVO> convert = page.convert(
|
||||
o -> {
|
||||
WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class);
|
||||
if (o.getMannequinFemaleId() != null) {
|
||||
if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
|
||||
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 60));
|
||||
}else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
|
||||
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 60));
|
||||
}
|
||||
}
|
||||
if (o.getMannequinMaleId() != null) {
|
||||
if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
|
||||
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 60));
|
||||
}else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
|
||||
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 60));
|
||||
}
|
||||
}
|
||||
return workspaceVO;
|
||||
}
|
||||
);
|
||||
vo.setPage(PageBaseResponse.success(convert));
|
||||
QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>();
|
||||
qwIsLastIndex.lambda().eq(Workspace::getUserName, userName);
|
||||
qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
@@ -255,12 +300,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
if (file != null) {
|
||||
String uploadMinioPath = sysFile.getLevel1Type().toLowerCase() + "/" + sysFile.getLevel2Type().toLowerCase() + "/" + file.getName();
|
||||
String bucketName = "aida-sys-image";
|
||||
// boolean b = minioUtil.doesObjectExist(bucketName, uploadMinioPath);
|
||||
// if (!b) {
|
||||
// FileItem a = getMultipartFile(file, file.getName());
|
||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
// minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
||||
// }
|
||||
boolean b = minioUtil.doesObjectExist(bucketName, uploadMinioPath);
|
||||
if (!b) {
|
||||
FileItem a = getMultipartFile(file, file.getName());
|
||||
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
||||
}
|
||||
sysFile.setUrl(bucketName + "/" + uploadMinioPath);
|
||||
sysFileMapper.updateById(sysFile);
|
||||
}
|
||||
@@ -287,12 +332,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
sb.append(o.getAccountId() + "/").append(o.getLevel1Type().toLowerCase() + "/").append(o.getLevel2Type().toLowerCase() + "/").append(file.getName());
|
||||
}
|
||||
String bucketName = "aida-users";
|
||||
// boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
|
||||
// if (!b) {
|
||||
// FileItem a = getMultipartFile(file, file.getName());
|
||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
// minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
|
||||
// }
|
||||
boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
|
||||
if (!b) {
|
||||
FileItem a = getMultipartFile(file, file.getName());
|
||||
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
|
||||
}
|
||||
o.setUrl(bucketName + "/" + sb);
|
||||
libraryMapper.updateById(o);
|
||||
}
|
||||
@@ -309,7 +354,157 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
// }
|
||||
}
|
||||
|
||||
private FileItem getMultipartFile(File file, String fieldName){
|
||||
@Override
|
||||
public void moveFile() {
|
||||
QueryWrapper<SysFile> sysFileQw = new QueryWrapper<>();
|
||||
sysFileQw.lambda().eq(SysFile::getLevel1Type, "Images");
|
||||
List<SysFile> sysFiles = sysFileMapper.selectList(sysFileQw);
|
||||
for (SysFile sysFile : sysFiles) {
|
||||
if (sysFile.getUrl().contains("/female")) {
|
||||
continue;
|
||||
}
|
||||
String[] urls = sysFile.getUrl().split("/images");
|
||||
String newUrl = urls[0] + "/images/female" + urls[1];
|
||||
sysFile.setUrl(newUrl);
|
||||
sysFileMapper.updateById(sysFile);
|
||||
}
|
||||
|
||||
QueryWrapper<Library> libraryQw = new QueryWrapper<>();
|
||||
libraryQw.lambda().eq(Library::getLevel1Type, "Sketchboard");
|
||||
List<Library> libraryList = libraryMapper.selectList(libraryQw);
|
||||
for (Library library : libraryList) {
|
||||
String oldUrl = library.getUrl();
|
||||
if (oldUrl.contains("/sketchboard")) {
|
||||
String[] oldUrls = oldUrl.split("/sketchboard");
|
||||
String newUrl = oldUrls[0] + "/sketchboard/female" + oldUrls[1];
|
||||
library.setUrl(newUrl);
|
||||
libraryMapper.updateById(library);
|
||||
}else if (oldUrl.contains("/images")) {
|
||||
String[] oldUrls = oldUrl.split("/images");
|
||||
String newUrl = oldUrls[0] + "/images/female" + oldUrls[1];
|
||||
library.setUrl(newUrl);
|
||||
libraryMapper.updateById(library);
|
||||
}
|
||||
}
|
||||
|
||||
QueryWrapper<Library> modelQw = new QueryWrapper<>();
|
||||
modelQw.lambda().eq(Library::getLevel1Type, "Models");
|
||||
List<Library> modelList = libraryMapper.selectList(modelQw);
|
||||
for (Library library : modelList) {
|
||||
String oldUrl = library.getUrl();
|
||||
if (oldUrl.contains("/models")) {
|
||||
String[] oldUrls = oldUrl.split("/models");
|
||||
String newUrl = oldUrls[0] + "/models/female" + oldUrls[1];
|
||||
library.setUrl(newUrl);
|
||||
libraryMapper.updateById(library);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maleDataInsert() throws FileNotFoundException {
|
||||
String directoryPath = "C:\\workspace\\fileData\\aida_men_library";
|
||||
List<File> pngFiles = getPNGFiles(directoryPath);
|
||||
for (File pngFile : pngFiles) {
|
||||
SysFile sysFile = new SysFile();
|
||||
String fileName = pngFile.getName();
|
||||
sysFile.setName(fileName);
|
||||
sysFile.setLevel1Type("Images");
|
||||
sysFile.setLevel3Type("Male");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("aida-sys-image/images/male");
|
||||
String absolutePath = pngFile.getAbsolutePath();
|
||||
if (absolutePath.contains("bottom")) {
|
||||
sysFile.setLevel2Type("Bottoms");
|
||||
sb.append("/bottoms/");
|
||||
}else if(absolutePath.contains("top")) {
|
||||
sysFile.setLevel2Type("Tops");
|
||||
sb.append("/tops/");
|
||||
}else if(absolutePath.contains("outer")) {
|
||||
sysFile.setLevel2Type("Outwear");
|
||||
sb.append("/outwear/");
|
||||
}
|
||||
sb.append(fileName);
|
||||
String url = sb.toString();
|
||||
sysFile.setUrl(url);
|
||||
sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile)));
|
||||
// boolean b = minioUtil.doesObjectExist("aida-sys-image", uploadMinioPath);
|
||||
// if (!b) {
|
||||
// FileItem a = getMultipartFile(file, file.getName());
|
||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
// minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
||||
// }
|
||||
FileItem a = getMultipartFile(pngFile, fileName);
|
||||
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
minioUtil.upload(url.substring(0,14), url.substring(15), multipartFile, "");
|
||||
sysFile.setCreateDate(new Date());
|
||||
sysFileMapper.insert(sysFile);
|
||||
}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws FileNotFoundException {
|
||||
// String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png";
|
||||
// File pngFile = new File(b);
|
||||
// SysFile sysFile = new SysFile();
|
||||
// String fileName = pngFile.getName();
|
||||
// sysFile.setName(fileName);
|
||||
// sysFile.setLevel1Type("Images");
|
||||
// sysFile.setLevel3Type("Male");
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append("aida-sys-image/images/male");
|
||||
// String absolutePath = pngFile.getAbsolutePath();
|
||||
// if (absolutePath.contains("bottom")) {
|
||||
// sysFile.setLevel2Type("Bottoms");
|
||||
// sb.append("/bottoms/");
|
||||
// }else if(absolutePath.contains("top")) {
|
||||
// sysFile.setLevel2Type("Tops");
|
||||
// sb.append("/tops/");
|
||||
// }else if(absolutePath.contains("outer")) {
|
||||
// sysFile.setLevel2Type("Outwear");
|
||||
// sb.append("/outwear/");
|
||||
// }
|
||||
// sb.append(fileName);
|
||||
// String url = sb.toString();
|
||||
// sysFile.setUrl(url);
|
||||
// sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile)));
|
||||
//// boolean b = minioUtil.doesObjectExist("aida-sys-image", uploadMinioPath);
|
||||
//// if (!b) {
|
||||
//// FileItem a = getMultipartFile(file, file.getName());
|
||||
//// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
//// minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
||||
//// }
|
||||
// FileItem a = getMultipartFile(pngFile, fileName);
|
||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
// System.out.println(url.substring(0,14));
|
||||
// System.out.println(url.substring(15));
|
||||
//// minioUtil.upload(url.substring(0,14), url.substring(15), multipartFile, "");
|
||||
// sysFile.setCreateDate(new Date());
|
||||
// }
|
||||
|
||||
public static List<File> getPNGFiles(String directoryPath) {
|
||||
List<File> pngFiles = new ArrayList<>();
|
||||
File directory = new File(directoryPath);
|
||||
|
||||
if (directory.isDirectory()) {
|
||||
File[] subDirectories = directory.listFiles(File::isDirectory);
|
||||
|
||||
if (subDirectories != null) {
|
||||
for (File subDirectory : subDirectories) {
|
||||
File[] imageFiles = subDirectory.listFiles((dir, name) -> name.toLowerCase().endsWith(".png"));
|
||||
|
||||
if (imageFiles != null) {
|
||||
for (File imageFile : imageFiles) {
|
||||
pngFiles.add(imageFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pngFiles;
|
||||
}
|
||||
|
||||
private static FileItem getMultipartFile(File file, String fieldName){
|
||||
// 使用 DiskFileItemFactory 创建一个 FileItemFactory
|
||||
FileItemFactory factory = new DiskFileItemFactory(16, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user