TASK:代码提交;
This commit is contained in:
@@ -22,6 +22,8 @@ import lombok.NoArgsConstructor;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,10 +104,25 @@ public class WorkspaceController {
|
|||||||
|
|
||||||
@PostMapping("system_file_copy")
|
@PostMapping("system_file_copy")
|
||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@ApiOperation(value = "文件复制", notes = "传入id")
|
@ApiOperation(value = "minio数据迁移")
|
||||||
public Response<Boolean> systemFileCopy() {
|
public Response<Boolean> systemFileCopy() {
|
||||||
workspaceService.systemFileCopy();
|
workspaceService.systemFileCopy();
|
||||||
return Response.success(true);
|
return Response.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("moveFile")
|
||||||
|
@ApiOperationSupport(order = 7)
|
||||||
|
@ApiOperation(value = "增加一级性别路径")
|
||||||
|
public Response<Boolean> moveFile() {
|
||||||
|
workspaceService.moveFile();
|
||||||
|
return Response.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("maleDataInsert")
|
||||||
|
@ApiOperationSupport(order = 7)
|
||||||
|
@ApiOperation(value = "男装数据入库入minio")
|
||||||
|
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
|
||||||
|
workspaceService.maleDataInsert();
|
||||||
|
return Response.success(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ public class Library implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String level2Type;
|
private String level2Type;
|
||||||
|
|
||||||
|
private String level3Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 元素名
|
* 元素名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class SysFile implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String level2Type;
|
private String level2Type;
|
||||||
|
|
||||||
|
private String level3Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名字
|
* 名字
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -61,17 +61,16 @@ public class Workspace implements Serializable {
|
|||||||
* 人体模型
|
* 人体模型
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "人体模型ID")
|
@ApiModelProperty(value = "人体模型ID")
|
||||||
private Long mannequinId;
|
private Long mannequinFemaleId;
|
||||||
/**
|
private Long mannequinMaleId;
|
||||||
* 人体模型
|
private Long mannequinChildId;
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "人体模型URL")
|
|
||||||
private String mannequinUrl;
|
|
||||||
/**
|
/**
|
||||||
* 人体模型
|
* 人体模型
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "人体模型类型")
|
@ApiModelProperty(value = "人体模型类型")
|
||||||
private String mannequinType;
|
private String mannequinFemaleType;
|
||||||
|
private String mannequinMaleType;
|
||||||
|
private String mannequinChildType;
|
||||||
/**
|
/**
|
||||||
* 最后使用的工作空间标识
|
* 最后使用的工作空间标识
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ public class DesignCollectionDTO {
|
|||||||
|
|
||||||
private String modelType;
|
private String modelType;
|
||||||
|
|
||||||
|
private String modelSex;
|
||||||
|
|
||||||
@ApiModelProperty("templateId")
|
@ApiModelProperty("templateId")
|
||||||
private Long templateId;
|
private Long templateId;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public class QueryLibraryPageServiceDTO extends PageQueryBaseVo {
|
|||||||
@ApiModelProperty("二级类型")
|
@ApiModelProperty("二级类型")
|
||||||
private String level2Type;
|
private String level2Type;
|
||||||
|
|
||||||
|
private String modelSex;
|
||||||
|
|
||||||
@ApiModelProperty("类型 Top , Bottom ,Print ")
|
@ApiModelProperty("类型 Top , Bottom ,Print ")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public class ReDesignCollectionDTO {
|
|||||||
@ApiModelProperty("templateId")
|
@ApiModelProperty("templateId")
|
||||||
private Long templateId;
|
private Long templateId;
|
||||||
|
|
||||||
|
private String modelType;
|
||||||
|
|
||||||
@NotBlank(message = "singleOverall cannot be empty!")
|
@NotBlank(message = "singleOverall cannot be empty!")
|
||||||
@ApiModelProperty("控制生成类型的参数,两个选项:outfit时候传 single , 另外一个传 overall")
|
@ApiModelProperty("控制生成类型的参数,两个选项:outfit时候传 single , 另外一个传 overall")
|
||||||
private String singleOverall;
|
private String singleOverall;
|
||||||
|
|||||||
@@ -7,19 +7,18 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
* @Date: 2023/08/01 17:21
|
* @Date: 2023/08/01 17:21
|
||||||
* @Description: 服装性别分类
|
* @Description: 服装性别分类
|
||||||
*/
|
*/
|
||||||
public enum Position implements IEnumDisplay {
|
public enum FemalePosition implements IEnumDisplay {
|
||||||
|
|
||||||
OUTWEAR("Outwear"),
|
OUTWEAR("Outwear"),
|
||||||
BLOUSE("Blouse"),
|
BLOUSE("Blouse"),
|
||||||
DRESS("Dress"),
|
DRESS("Dress"),
|
||||||
TROUSERS("Trousers"),
|
TROUSERS("Trousers"),
|
||||||
SKIRT("Skirt")
|
SKIRT("Skirt")
|
||||||
// SINGLE("Single"),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
Position(String value) {
|
FemalePosition(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
28
src/main/java/com/ai/da/model/enums/MalePosition.java
Normal file
28
src/main/java/com/ai/da/model/enums/MalePosition.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ai.da.model.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: SHAHAIBO
|
||||||
|
* @Date: 2023/08/01 17:21
|
||||||
|
* @Description: 服装性别分类
|
||||||
|
*/
|
||||||
|
public enum MalePosition implements IEnumDisplay {
|
||||||
|
|
||||||
|
TOPS("Tops"),
|
||||||
|
BOTTOMS("Bottoms"),
|
||||||
|
OUTWEAR("Outwear")
|
||||||
|
;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
MalePosition(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,10 @@ public class WorkspaceVO extends Workspace {
|
|||||||
|
|
||||||
private Long currentId;
|
private Long currentId;
|
||||||
|
|
||||||
private PageBaseResponse<Workspace> page;
|
private PageBaseResponse<WorkspaceVO> page;
|
||||||
|
|
||||||
|
private String femalePresignedUrl;
|
||||||
|
private String malePresignedUrl;
|
||||||
|
private String childPresignedUrl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1205,10 +1205,10 @@ public class PythonService {
|
|||||||
MediaType mediaType = MediaType.parse("application/json");
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
// .url(accessPythonIp+":11112/aifda/api/v1.0/attribute_retrieval")
|
.url("http://18.167.251.121:9991/api/attribute_retrieve")
|
||||||
.url(accessPythonIp+":9991/aifda/api/v1.0/attribute_retrieval")
|
// .url(accessPythonIp+":9991/aifda/api/v1.0/attribute_retrieval")
|
||||||
.method("POST", body)
|
.method("POST", body)
|
||||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.build();
|
.build();
|
||||||
Response response = null;
|
Response response = null;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,4 +41,8 @@ public interface WorkspaceService extends IService<Workspace> {
|
|||||||
List<ModelsVO> getMannequins(String sex);
|
List<ModelsVO> getMannequins(String sex);
|
||||||
|
|
||||||
void systemFileCopy();
|
void systemFileCopy();
|
||||||
|
|
||||||
|
void moveFile();
|
||||||
|
|
||||||
|
void maleDataInsert() throws FileNotFoundException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,10 +80,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
|||||||
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(uploadDTO.getLevel1Type());
|
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(uploadDTO.getLevel1Type());
|
||||||
Assert.notNull(level1TypeEnum, "unknown parameter level1Type!");
|
Assert.notNull(level1TypeEnum, "unknown parameter level1Type!");
|
||||||
|
|
||||||
// String path = calculateFileUrl(level1TypeEnum, userInfo.getId());aida-collection-element
|
|
||||||
String objectName = userInfo.getId() + "/" + level1TypeEnum.getRealName();
|
String objectName = userInfo.getId() + "/" + level1TypeEnum.getRealName();
|
||||||
String path = minioUtil.upload("aida-collection-element", objectName, uploadDTO.getFile());
|
String path = minioUtil.upload("aida-collection-element", objectName, uploadDTO.getFile());
|
||||||
// File file = FileUtil.upload(uploadDTO.getFile(), path);
|
|
||||||
//保存element元素
|
//保存element元素
|
||||||
CollectionElement collectionElement = resolveData(uploadDTO, userInfo, path);
|
CollectionElement collectionElement = resolveData(uploadDTO, userInfo, path);
|
||||||
saveOne(collectionElement);
|
saveOne(collectionElement);
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
|||||||
Assert.notEmpty(collectionElements,"collection element does not exist!");
|
Assert.notEmpty(collectionElements,"collection element does not exist!");
|
||||||
response.setCollectionId(id);
|
response.setCollectionId(id);
|
||||||
response.setMoodTemplateId(collection.getMoodTemplateId());
|
response.setMoodTemplateId(collection.getMoodTemplateId());
|
||||||
|
if (collection.getMoodTemplateId() != null) {
|
||||||
response.setMoodTemplateUrl(minioUtil.getPresignedUrl(collectionElementService.getById(response.getMoodTemplateId()).getUrl(), 10));
|
response.setMoodTemplateUrl(minioUtil.getPresignedUrl(collectionElementService.getById(response.getMoodTemplateId()).getUrl(), 10));
|
||||||
|
}
|
||||||
Map<String,List<CollectionElement>> maps = collectionElements
|
Map<String,List<CollectionElement>> maps = collectionElements
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.groupingBy(CollectionElement::getLevel1Type));
|
.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) {
|
private void calculateLibraryAndSysFile(DesignCollectionDTO designDTO, ValidateElementVO elementVO, AuthPrincipalVo userInfo) {
|
||||||
//查询用户 sketch library
|
//查询用户 sketch library
|
||||||
List<LibraryVo> libraryVos;
|
List<LibraryVo> libraryVos;
|
||||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||||
List<String> sketchUrlList = elementVO.getSketchBoardElements()
|
// List<String> sketchUrlList = elementVO.getSketchBoardElements()
|
||||||
.stream()
|
// .stream()
|
||||||
.map(CollectionElement::getUrl)
|
// .map(CollectionElement::getUrl)
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
DesignAttributeRetrievalDTO designAttributeRetrievalDTO =
|
// DesignAttributeRetrievalDTO designAttributeRetrievalDTO =
|
||||||
pythonService.generateAttributeRetrieval(sketchUrlList, userInfo.getId());
|
// pythonService.generateAttributeRetrieval(sketchUrlList, userInfo.getId());
|
||||||
if (CollectionUtils.isEmpty(designAttributeRetrievalDTO.getLibraryUrls())) {
|
// if (CollectionUtils.isEmpty(designAttributeRetrievalDTO.getLibraryUrls())) {
|
||||||
libraryVos = null;
|
// libraryVos = null;
|
||||||
} else {
|
// } else {
|
||||||
libraryVos = libraryService.getByUrlList(designAttributeRetrievalDTO.getLibraryUrls(), userInfo.getId());
|
// libraryVos = libraryService.getByUrlList(designAttributeRetrievalDTO.getLibraryUrls(), userInfo.getId());
|
||||||
}
|
// }
|
||||||
List<SysFileVO> sysFileVOS = sysFileService.getByUrlList(designAttributeRetrievalDTO.getSysFileUrlS());
|
// List<SysFileVO> sysFileVOS = sysFileService.getByUrlList(designAttributeRetrievalDTO.getSysFileUrlS());
|
||||||
elementVO.setSysFileVo(sysFileVOS);
|
// elementVO.setSysFileVo(sysFileVOS);
|
||||||
} else {
|
// } else {
|
||||||
|
// libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||||
|
// Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||||
|
// }
|
||||||
libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||||
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||||
}
|
|
||||||
elementVO.setLibraryVos(libraryVos);
|
elementVO.setLibraryVos(libraryVos);
|
||||||
//校验比列
|
//校验比列
|
||||||
validateRatio(designDTO, libraryVos);
|
validateRatio(designDTO, libraryVos);
|
||||||
@@ -227,48 +229,48 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DesignCollectionVO designOrRedesignOperate(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
// private DesignCollectionVO designOrRedesignOperate(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
||||||
Long collectionIdParam, ValidateElementVO elementVO) {
|
// Long collectionIdParam, ValidateElementVO elementVO) {
|
||||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||||
//编辑sketchBoard
|
// //编辑sketchBoard
|
||||||
collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
// collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
||||||
}
|
// }
|
||||||
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
// if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
||||||
//编辑printBoard
|
// //编辑printBoard
|
||||||
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
// collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||||
}
|
// }
|
||||||
//保存collection
|
// //保存collection
|
||||||
Long collectionId = (null == collectionIdParam) ?
|
// Long collectionId = (null == collectionIdParam) ?
|
||||||
collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId()) : collectionIdParam;
|
// collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId()) : collectionIdParam;
|
||||||
List<Long> elementIds = getElementId(elementVO);
|
// List<Long> elementIds = getElementId(elementVO);
|
||||||
//批量关联element 到 collection
|
// //批量关联element 到 collection
|
||||||
collectionElementService.relationCollection(elementIds, collectionId);
|
// collectionElementService.relationCollection(elementIds, collectionId);
|
||||||
//library转化为collection(生成)
|
// //library转化为collection(生成)
|
||||||
saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
// saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
||||||
//保存颜色版
|
// //保存颜色版
|
||||||
List<CollectionElementVO> colorElementList = collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
// List<CollectionElementVO> colorElementList = collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
||||||
//保存design
|
// //保存design
|
||||||
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
// Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||||
//计算library
|
// //计算library
|
||||||
calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
||||||
//组装design入参
|
// //组装design入参
|
||||||
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
// DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||||
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
// designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
||||||
//缓存保存的文件 方便后面处理进度问题 采用新的进度条获取方式 根据processId获取
|
// //缓存保存的文件 方便后面处理进度问题 采用新的进度条获取方式 根据processId获取
|
||||||
// setDesignProcess(userInfo.getId(), pythonObjects);
|
//// setDesignProcess(userInfo.getId(), pythonObjects);
|
||||||
//design
|
// //design
|
||||||
pythonService.design(pythonObjects);
|
// pythonService.design(pythonObjects);
|
||||||
//生成library
|
// //生成library
|
||||||
generateLibrary(elementVO, designDTO.getTimeZone());
|
// generateLibrary(elementVO, designDTO.getTimeZone());
|
||||||
//处理关联关系,修复element覆盖得情况
|
// //处理关联关系,修复element覆盖得情况
|
||||||
List<CollectionElement> reLationelements = collectionElementService.getByOnlyCollectionId(collectionId);
|
// List<CollectionElement> reLationelements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||||
List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
// List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||||
handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
|
// handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
|
||||||
//保存python返回信息
|
// //保存python返回信息
|
||||||
// return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
|
//// return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
|
||||||
//保存designItem 和detail
|
// //保存designItem 和detail
|
||||||
return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone());
|
// return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone());
|
||||||
}
|
// }
|
||||||
|
|
||||||
private DesignCollectionVO designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
private DesignCollectionVO designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
|
||||||
Long collectionIdParam, ValidateElementVO elementVO) {
|
Long collectionIdParam, ValidateElementVO elementVO) {
|
||||||
@@ -876,10 +878,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
MediaType mediaType = MediaType.parse("application/json");
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||||
String param = JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
|
String param = JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
|
||||||
log.info("design请求python 参数:####{}", param);
|
log.info("designProcess请求python 参数:####{}", param);
|
||||||
RequestBody body = RequestBody.create(mediaType, param);
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
Request request = new Request.Builder()
|
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")
|
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
||||||
.method("POST", body)
|
.method("POST", body)
|
||||||
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
// .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.response.PageBaseResponse;
|
||||||
import com.ai.da.common.utils.CopyUtil;
|
import com.ai.da.common.utils.CopyUtil;
|
||||||
import com.ai.da.common.utils.DateUtil;
|
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.common.utils.MinioUtil;
|
||||||
import com.ai.da.mapper.LibraryMapper;
|
import com.ai.da.mapper.LibraryMapper;
|
||||||
import com.ai.da.mapper.SysFileMapper;
|
import com.ai.da.mapper.SysFileMapper;
|
||||||
@@ -36,7 +35,6 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -91,6 +89,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
Assert.notNull(level1TypeEnum,"unknown level1Type " +query.getLevel1Type());
|
Assert.notNull(level1TypeEnum,"unknown level1Type " +query.getLevel1Type());
|
||||||
queryWrapper.eq("level1_type", 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())){
|
if(!StringUtils.isEmpty(query.getLevel2Type())){
|
||||||
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(query.getLevel2Type());
|
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(query.getLevel2Type());
|
||||||
Assert.notNull(level2TypeEnum,"unknown level2Type " +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)
|
Assert.isTrue(!( level1TypeEnum.equals(LibraryLevel1TypeEnum.SKETCH_BOARD)
|
||||||
&& StringUtils.isEmpty(libraryUploadDTO.getLevel2Type()) ),"level2Type cannot be empty!");
|
&& 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;
|
String bucketName = null;
|
||||||
switch (level1TypeEnum) {
|
switch (level1TypeEnum) {
|
||||||
case MODELS:
|
case MODELS:
|
||||||
@@ -174,7 +175,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
throw new BusinessException("unknown level1_type");
|
throw new BusinessException("unknown level1_type");
|
||||||
}
|
}
|
||||||
//保存element元素
|
//保存element元素
|
||||||
if (libraryUploadDTO.getModelType() != null) {
|
if (!StringUtils.isEmpty(libraryUploadDTO.getModelType())) {
|
||||||
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||||
String newFilePath = processMannequins(filePath);
|
String newFilePath = processMannequins(filePath);
|
||||||
@@ -185,7 +186,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
return libraryUpdateVo;
|
return libraryUpdateVo;
|
||||||
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||||
bucketName = "aida-sys-image";
|
bucketName = "aida-sys-image";
|
||||||
path = "models/" + libraryUploadDTO.getModelSex();
|
path = "models/" + libraryUploadDTO.getModelSex().toLowerCase();
|
||||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||||
String newFilePath = processMannequins(filePath);
|
String newFilePath = processMannequins(filePath);
|
||||||
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
||||||
@@ -262,12 +263,11 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
library.setUrl(filePath);
|
library.setUrl(filePath);
|
||||||
//按时区计算
|
//按时区计算
|
||||||
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
|
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
|
||||||
// String linuxDomain = fileProperties.getLinuxDomain();
|
if (uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||||
// if (!StringUtils.isEmpty(linuxDomain)) {
|
library.setLevel2Type(uploadDTO.getModelSex());
|
||||||
// //linux 系统
|
}else {
|
||||||
// String oldPath = fileProperties.getSys().getPath();
|
library.setLevel3Type(uploadDTO.getModelSex());
|
||||||
// library.setUrl(file.getAbsolutePath().replace(oldPath, linuxDomain));
|
}
|
||||||
// }
|
|
||||||
libraryMapper.insert(library);
|
libraryMapper.insert(library);
|
||||||
return library;
|
return library;
|
||||||
}else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
}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) {
|
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, String level2Type, String modelSex, Long userId) {
|
||||||
// String rootPath = fileProperties.getSys().getPath();
|
if (StringUtils.isEmpty(modelSex)) {
|
||||||
// String day = DateUtil.dateToStr(new Date(), DateUtil.YYYYMM);
|
|
||||||
return StringUtils.isEmpty(level2Type) ? userId + "/" + level1TypeEnum.getRealName().toLowerCase() : userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + level2Type;
|
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
|
@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.SysFileLevel1TypeEnum;
|
||||||
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
||||||
import com.ai.da.common.response.PageBaseResponse;
|
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.FileUtil;
|
||||||
|
import com.ai.da.common.utils.MD5Utils;
|
||||||
import com.ai.da.common.utils.MinioUtil;
|
import com.ai.da.common.utils.MinioUtil;
|
||||||
import com.ai.da.mapper.LibraryMapper;
|
import com.ai.da.mapper.LibraryMapper;
|
||||||
import com.ai.da.mapper.SysFileMapper;
|
import com.ai.da.mapper.SysFileMapper;
|
||||||
@@ -37,12 +39,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@@ -85,9 +85,23 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
workspace.setUserName(userInfo.getUsername());
|
workspace.setUserName(userInfo.getUsername());
|
||||||
if (null == workspace.getId()) {
|
if (null == workspace.getId()) {
|
||||||
workspace.setIsLastIndex(0);
|
workspace.setIsLastIndex(0);
|
||||||
workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714432.png");
|
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
||||||
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
|
systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||||
workspace.setSex(Sex.MALE.getValue());
|
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.setPosition("Overall");
|
||||||
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
||||||
int insert = workspaceMapper.insert(workspace);
|
int insert = workspaceMapper.insert(workspace);
|
||||||
@@ -115,22 +129,25 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
// 给用户新建默认workspace
|
// 给用户新建默认workspace
|
||||||
Workspace workspace = new Workspace();
|
Workspace workspace = new Workspace();
|
||||||
workspace.setWorkSpaceName(WORKSPACE_NAME);
|
workspace.setWorkSpaceName(WORKSPACE_NAME);
|
||||||
workspace.setSex(Sex.MALE.getValue());
|
workspace.setSex(Sex.FEMALE.getValue());
|
||||||
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
||||||
workspace.setPosition("Overall");
|
workspace.setPosition("Overall");
|
||||||
workspace.setUserName(userName);
|
workspace.setUserName(userName);
|
||||||
QueryWrapper<SysFile> systemQw = new QueryWrapper<>();
|
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
||||||
systemQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||||
systemQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
systemFemaleQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||||
List<SysFile> sysFiles = sysFileMapper.selectList(systemQw);
|
List<SysFile> sysFemaleFiles = sysFileMapper.selectList(systemFemaleQw);
|
||||||
if (!CollectionUtils.isEmpty(sysFiles)) {
|
if (!CollectionUtils.isEmpty(sysFemaleFiles)) {
|
||||||
workspace.setMannequinId(sysFiles.get(0).getId());
|
workspace.setMannequinFemaleId(sysFemaleFiles.get(0).getId());
|
||||||
workspace.setMannequinUrl(sysFiles.get(0).getUrl());
|
workspace.setMannequinFemaleType(MannequinType.SYSTEM.getValue());
|
||||||
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
|
}
|
||||||
}else {
|
QueryWrapper<SysFile> systemMaleQw = new QueryWrapper<>();
|
||||||
workspace.setMannequinId(null);
|
systemMaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||||
workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714432.png");
|
systemMaleQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||||
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
|
List<SysFile> sysMaleFiles = sysFileMapper.selectList(systemMaleQw);
|
||||||
|
if (!CollectionUtils.isEmpty(sysMaleFiles)) {
|
||||||
|
workspace.setMannequinMaleId(sysMaleFiles.get(0).getId());
|
||||||
|
workspace.setMannequinMaleType(MannequinType.SYSTEM.getValue());
|
||||||
}
|
}
|
||||||
workspace.setIsLastIndex(1);
|
workspace.setIsLastIndex(1);
|
||||||
int insert = workspaceMapper.insert(workspace);
|
int insert = workspaceMapper.insert(workspace);
|
||||||
@@ -138,23 +155,51 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
throw new BusinessException("save workspace failed");
|
throw new BusinessException("save workspace failed");
|
||||||
}
|
}
|
||||||
page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||||
page.getRecords().forEach(o -> {
|
IPage<WorkspaceVO> convert = page.convert(
|
||||||
String url = o.getMannequinUrl();
|
o -> {
|
||||||
if (url.startsWith("aida-")) {
|
WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class);
|
||||||
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 60*24));
|
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));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
vo.setPage(PageBaseResponse.success(page));
|
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());
|
vo.setId(workspace.getId());
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
page.getRecords().forEach(o -> {
|
IPage<WorkspaceVO> convert = page.convert(
|
||||||
String url = o.getMannequinUrl();
|
o -> {
|
||||||
if (url.startsWith("aida-")) {
|
WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class);
|
||||||
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 10));
|
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));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
vo.setPage(PageBaseResponse.success(page));
|
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<>();
|
QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>();
|
||||||
qwIsLastIndex.lambda().eq(Workspace::getUserName, userName);
|
qwIsLastIndex.lambda().eq(Workspace::getUserName, userName);
|
||||||
qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1);
|
qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||||
@@ -255,12 +300,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
if (file != null) {
|
if (file != null) {
|
||||||
String uploadMinioPath = sysFile.getLevel1Type().toLowerCase() + "/" + sysFile.getLevel2Type().toLowerCase() + "/" + file.getName();
|
String uploadMinioPath = sysFile.getLevel1Type().toLowerCase() + "/" + sysFile.getLevel2Type().toLowerCase() + "/" + file.getName();
|
||||||
String bucketName = "aida-sys-image";
|
String bucketName = "aida-sys-image";
|
||||||
// boolean b = minioUtil.doesObjectExist(bucketName, uploadMinioPath);
|
boolean b = minioUtil.doesObjectExist(bucketName, uploadMinioPath);
|
||||||
// if (!b) {
|
if (!b) {
|
||||||
// FileItem a = getMultipartFile(file, file.getName());
|
FileItem a = getMultipartFile(file, file.getName());
|
||||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||||
// minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
||||||
// }
|
}
|
||||||
sysFile.setUrl(bucketName + "/" + uploadMinioPath);
|
sysFile.setUrl(bucketName + "/" + uploadMinioPath);
|
||||||
sysFileMapper.updateById(sysFile);
|
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());
|
sb.append(o.getAccountId() + "/").append(o.getLevel1Type().toLowerCase() + "/").append(o.getLevel2Type().toLowerCase() + "/").append(file.getName());
|
||||||
}
|
}
|
||||||
String bucketName = "aida-users";
|
String bucketName = "aida-users";
|
||||||
// boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
|
boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
|
||||||
// if (!b) {
|
if (!b) {
|
||||||
// FileItem a = getMultipartFile(file, file.getName());
|
FileItem a = getMultipartFile(file, file.getName());
|
||||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||||
// minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
|
minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
|
||||||
// }
|
}
|
||||||
o.setUrl(bucketName + "/" + sb);
|
o.setUrl(bucketName + "/" + sb);
|
||||||
libraryMapper.updateById(o);
|
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
|
// 使用 DiskFileItemFactory 创建一个 FileItemFactory
|
||||||
FileItemFactory factory = new DiskFileItemFactory(16, null);
|
FileItemFactory factory = new DiskFileItemFactory(16, null);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user