TASK:模特相关接口;

This commit is contained in:
shahaibo
2023-10-04 06:47:48 +08:00
parent 612fb61ac1
commit ee32111599
15 changed files with 127 additions and 43 deletions

View File

@@ -37,7 +37,7 @@ public interface WorkspaceService extends IService<Workspace> {
Workspace getByIdNew(Long id);
List<ModelsVO> getMannequins();
List<ModelsVO> getMannequins(String sex);
void systemFileCopy();
}

View File

@@ -11,6 +11,7 @@ import com.ai.da.mapper.CollectionElementMapper;
import com.ai.da.mapper.entity.*;
import com.ai.da.mapper.entity.Collection;
import com.ai.da.model.dto.*;
import com.ai.da.model.enums.ModelType;
import com.ai.da.model.vo.*;
import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonItem;
@@ -441,14 +442,24 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Assert.notNull(switchCategory, "unknown parameter switchCategory!");
}
//校验template
// if(Objects.nonNull(designDTO.getTemplateId())){
if(Objects.nonNull(designDTO.getTemplateId())){
// LibraryModelPoint modelPoint = libraryModelPointService.getById(designDTO.getTemplateId());
// Assert.notNull(modelPoint, "template cannot by empty!");
// Library library = libraryService.getById(modelPoint.getLibraryId());
// Assert.notNull(library, "template library cannot by empty!");
// elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,library.getHigh(),library.getWidth(),library.getUrl()));
// }
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(null,null,null,null));
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library byId = libraryService.getById(designDTO.getTemplateId());
QueryWrapper<LibraryModelPoint> qw = new QueryWrapper<>();
qw.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
qw.lambda().eq(LibraryModelPoint::getRelationId, byId.getId());
LibraryModelPoint modelPoint = libraryModelPointService.getOne(qw);
if (Objects.isNull(modelPoint)) {
throw new BusinessException("error modelPoint get");
}
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,1654,1170,byId.getUrl()));
}
}
// elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(null,1654,1170,null));
return elementVO;
}
@Override

View File

@@ -164,7 +164,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.nonNull(design.getTemplateId())){
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
Assert.notNull(modelPoint,"template does not exists!");
Library library = libraryService.getById(modelPoint.getLibraryId());
Library library = libraryService.getById(modelPoint.getRelationId());
// ??和上面重复
Assert.notNull(modelPoint,"template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
@@ -205,7 +205,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.nonNull(design.getTemplateId())){
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
Assert.notNull(modelPoint,"template does not exists!");
Library library = libraryService.getById(modelPoint.getLibraryId());
Library library = libraryService.getById(modelPoint.getRelationId());
Assert.notNull(modelPoint,"template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
}
@@ -386,7 +386,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.nonNull(design.getTemplateId())){
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
Assert.notNull(modelPoint,"template does not exists!");
Library library = libraryService.getById(modelPoint.getLibraryId());
Library library = libraryService.getById(modelPoint.getRelationId());
Assert.notNull(library,"template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
}

View File

@@ -12,6 +12,7 @@ import com.ai.da.model.dto.DesignSingleDTO;
import com.ai.da.model.dto.DesignSingleItemDTO;
import com.ai.da.model.dto.LibraryModelPointDTO;
import com.ai.da.model.dto.ModelsDotDTO;
import com.ai.da.model.enums.ModelType;
import com.ai.da.model.vo.LibraryModelPointVO;
import com.ai.da.model.vo.LibraryUpdateVo;
import com.ai.da.python.PythonService;
@@ -51,7 +52,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
@Override
public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) {
Library library = libraryService.getById(libraryModelPointDTO.getLibraryId());
Library library = libraryService.getById(libraryModelPointDTO.getRelationId());
Assert.notNull(library,"library does not exist!");
LibraryModelPointVO libraryModelPointVO =CopyUtil.copyObject(libraryModelPointDTO,LibraryModelPointVO.class);;
if(Objects.isNull(libraryModelPointDTO.getTemplateId())){
@@ -87,6 +88,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
@Override
public List<LibraryModelPointVO> selectByLibraryIds(List<Long> libraryIds) {
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
queryWrapper.in("library_id", libraryIds);
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
if(CollectionUtils.isEmpty(libraryModelPoints)){

View File

@@ -10,8 +10,10 @@ 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;
import com.ai.da.mapper.entity.*;
import com.ai.da.model.dto.*;
import com.ai.da.model.enums.ModelType;
import com.ai.da.model.vo.*;
import com.ai.da.service.LibraryModelPointService;
import com.ai.da.service.LibraryService;
@@ -44,6 +46,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
@Resource
private LibraryMapper libraryMapper;
@Resource
private SysFileMapper sysFileMapper;
@Resource
private FileProperties fileProperties;
@Resource
private LibraryModelPointService libraryModelPointService;
@@ -157,34 +161,53 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
bucketName = users;
break;
case MARKETING_SKETCH:
break;
throw new BusinessException("MARKETING_SKETCH type have been removed");
default:
throw new BusinessException("unknown level1_type");
}
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
//保存element元素
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(filePath, 480));
return libraryUpdateVo;
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(filePath, 480));
return libraryUpdateVo;
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
return null;
}
return null;
}
private Library resolveData(LibraryUploadDTO uploadDTO, AuthPrincipalVo userInfo, String filePath) {
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
library.setAccountId(userInfo.getId());
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
library.setUrl(filePath);
//按时区计算
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
if (uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
library.setAccountId(userInfo.getId());
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
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));
// }
libraryMapper.insert(library);
return library;
libraryMapper.insert(library);
return library;
}else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFile sysFile = new SysFile();
sysFile.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
sysFile.setLevel1Type("Models");
sysFile.setLevel2Type(uploadDTO.getModelSex());
sysFile.setUrl(filePath);
sysFile.setMd5(uploadDTO.getMd5());
sysFileMapper.insert(sysFile);
return null;
}else {
throw new BusinessException("unknown model type");
}
}
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, String level2Type, Long userId) {

View File

@@ -184,7 +184,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
}
@Override
public List<ModelsVO> getMannequins() {
public List<ModelsVO> getMannequins(String sex) {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
List<ModelsVO> result = new ArrayList<>();
QueryWrapper<Library> libraryQueryWrapper = new QueryWrapper<>();
@@ -197,11 +197,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
ModelVO modelVO = new ModelVO();
modelVO.setId(library.getId());
modelVO.setUrl(library.getUrl());
if (library.getUrl().startsWith("aida-")) {
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 10));
}else {
modelVO.setPresignedUrl(library.getUrl());
}
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 480));
modelVOList.add(modelVO);
}
ModelsVO vo = new ModelsVO();
@@ -210,8 +206,10 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
result.add(vo);
}
QueryWrapper<SysFile> sysFileQueryWrapper = new QueryWrapper<>();
sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, SysFileLevel1TypeEnum.ACCESSORIES.getRealName());
sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, SysFileLevel2TypeEnum.BODY.getRealName());
// sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, SysFileLevel1TypeEnum.ACCESSORIES.getRealName());
// sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, SysFileLevel2TypeEnum.BODY.getRealName());
sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, "Models");
sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, sex);
List<SysFile> sysFileList = sysFileMapper.selectList(sysFileQueryWrapper);
if (!CollectionUtils.isEmpty(sysFileList)) {
List<ModelVO> modelVOList = new ArrayList<>();
@@ -219,11 +217,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
ModelVO modelVO = new ModelVO();
modelVO.setId(sysFile.getId());
modelVO.setUrl(sysFile.getUrl());
if (sysFile.getUrl().startsWith("aida-")) {
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 10));
}else {
modelVO.setPresignedUrl(sysFile.getUrl());
}
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 480));
modelVOList.add(modelVO);
}
ModelsVO vo = new ModelsVO();