Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -19,7 +19,7 @@ public interface PortfolioService extends IService<Portfolio> {
|
||||
|
||||
PortfolioVO detail(PortfolioDTO portfolioDTO);
|
||||
|
||||
UserLikeChooseVO choose(PortfolioDTO portfolioDTO);
|
||||
ProjectChooseVO choose(PortfolioDTO portfolioDTO);
|
||||
|
||||
Boolean designWorksRegister(DesignWorksRegisterDTO designWorksRegisterDTO);
|
||||
|
||||
|
||||
8
src/main/java/com/ai/da/service/ProductImageService.java
Normal file
8
src/main/java/com/ai/da/service/ProductImageService.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.model.dto.ProgressDTO;
|
||||
|
||||
public interface ProductImageService {
|
||||
void asyncInitialize(Long brandId);
|
||||
// double getInitializeProgress(Long brandId);
|
||||
}
|
||||
@@ -76,6 +76,8 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
Boolean productImageInitialize(ProductImageInitializeDTO productImageInitializeDTO);
|
||||
|
||||
InitializeProgressVO getInitializeProgress(ProductImageInitializeDTO productImageInitializeDTO);
|
||||
|
||||
IPage<ProjectVO> getPage(ProjectQueryDTO projectQueryDTO);
|
||||
|
||||
ModuleChooseVO getModuleContent(ProjectDTO projectDTO);
|
||||
@@ -102,7 +104,9 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
void getThreeDGlb(Long threeDSimpleId, HttpServletResponse response) throws MinioException, IOException;
|
||||
|
||||
void downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException;
|
||||
String downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException;
|
||||
|
||||
Boolean delete(Long projectId);
|
||||
|
||||
Boolean brandDNADelete(BrandDNADTO brandDNADTO);
|
||||
}
|
||||
|
||||
@@ -125,6 +125,9 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
@Resource
|
||||
private TagsMapper tagsMapper;
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long publish(MultipartFile file, String data) {
|
||||
@@ -154,9 +157,26 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
if (portfolioDTO.getOpenSource() == 1) {
|
||||
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
|
||||
|
||||
Long projectId = userLikeGroup.getProjectId();
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
|
||||
Long workspaceServiceByProjectId = workspaceService.getByProjectId(project.getId());
|
||||
Workspace workspace = workspaceMapper.selectById(workspaceServiceByProjectId);
|
||||
|
||||
project.setId(null);
|
||||
project.setAccountId(-1L);
|
||||
project.setCreateTime(LocalDateTime.now());
|
||||
projectMapper.insert(project);
|
||||
|
||||
workspace.setProjectId(project.getId());
|
||||
workspace.setAccountId(-1L);
|
||||
workspaceMapper.insert(workspace);
|
||||
|
||||
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
|
||||
userLikeGroupNew.setId(null);
|
||||
userLikeGroupNew.setAccountId(-1L);
|
||||
userLikeGroupNew.setProjectId(project.getId());
|
||||
Long collectionIdOld = userLikeGroup.getCollectionId();
|
||||
QueryWrapper<Design> designQueryWrapper = new QueryWrapper<>();
|
||||
designQueryWrapper.lambda().eq(Design::getCollectionId, collectionIdOld);
|
||||
@@ -173,6 +193,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setCollectionId(collectionIdNew);
|
||||
element.setProjectId(project.getId());
|
||||
element.setId(null);
|
||||
collectionElementMapper.insert(element);
|
||||
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
||||
@@ -631,19 +652,29 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public UserLikeChooseVO choose(PortfolioDTO portfolioDTO) {
|
||||
public ProjectChooseVO choose(PortfolioDTO portfolioDTO) {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||
QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
||||
userLikeGroupQueryWrapper.lambda().eq(UserLikeGroup::getCollectionId, portfolio.getCollectionId());
|
||||
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectOne(userLikeGroupQueryWrapper);
|
||||
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
||||
if (Objects.isNull(userLikeGroup)) {
|
||||
throw new BusinessException("");
|
||||
}
|
||||
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
||||
|
||||
Project project = projectMapper.selectById(userLikeGroup.getProjectId());
|
||||
Long projectIdOld = project.getId();
|
||||
project.setCreateTime(LocalDateTime.now());
|
||||
project.setId(null);
|
||||
project.setAccountId(authPrincipalVo.getId());
|
||||
project.setName(project.getName() + "_copy");
|
||||
projectMapper.insert(project);
|
||||
|
||||
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
|
||||
userLikeGroupNew.setId(null);
|
||||
userLikeGroupNew.setCreateDate(new Date());
|
||||
userLikeGroupNew.setProjectId(project.getId());
|
||||
if (portfolio.getOriginal() == 1) {
|
||||
if (Objects.equals(portfolio.getAccountId(), authPrincipalVo.getId())) {
|
||||
userLikeGroupNew.setOriginal(1);
|
||||
@@ -692,6 +723,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
||||
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setProjectId(project.getId());
|
||||
element.setCollectionId(collectionIdNew);
|
||||
element.setId(null);
|
||||
collectionElementMapper.insert(element);
|
||||
@@ -766,126 +798,136 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
}
|
||||
}
|
||||
|
||||
Long collectionId = portfolio.getCollectionId();
|
||||
QueryWrapper<Design> getWorkspaceQw = new QueryWrapper<>();
|
||||
getWorkspaceQw.lambda().eq(Design::getCollectionId, collectionId);
|
||||
List<Design> designs = designMapper.selectList(getWorkspaceQw);
|
||||
if (!CollectionUtils.isEmpty(designs)) {
|
||||
Design design1 = designs.get(0);
|
||||
Long accountId = authPrincipalVo.getId();
|
||||
QueryWrapper<Workspace> currentWorkspaceQw = new QueryWrapper<>();
|
||||
currentWorkspaceQw.lambda().eq(Workspace::getAccountId, accountId);
|
||||
currentWorkspaceQw.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
List<Workspace> workspaces = workspaceMapper.selectList(currentWorkspaceQw);
|
||||
if (!CollectionUtils.isEmpty(workspaces)) {
|
||||
Workspace workspace1 = workspaces.get(0);
|
||||
workspace1.setIsLastIndex(0);
|
||||
workspaceMapper.updateById(workspace1);
|
||||
Workspace workspaceNew = new Workspace();
|
||||
String workspaceName = "workspace of " + accountMapper.selectById(portfolio.getAccountId()).getUserName() + portfolio.getPortfolioName();
|
||||
QueryWrapper<Workspace> existSameNameQw = new QueryWrapper<>();
|
||||
existSameNameQw.lambda().eq(Workspace::getWorkSpaceName, workspaceName);
|
||||
existSameNameQw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId());
|
||||
List<Workspace> existSameNameList = workspaceMapper.selectList(existSameNameQw);
|
||||
if (!CollectionUtils.isEmpty(existSameNameList)) {
|
||||
workspaceName = workspaceName + "_copy";
|
||||
}
|
||||
workspaceNew.setWorkSpaceName(workspaceName);
|
||||
workspaceNew.setAccountId(accountId);
|
||||
workspaceNew.setIsDeleted(0);
|
||||
workspaceNew.setIsLastIndex(1);
|
||||
workspaceNew.setCreateTime(LocalDateTime.now());
|
||||
workspaceNew.setSystemDesignerPercentage((design1.getSystemScale().multiply(BigDecimal.valueOf(100)).intValue()));
|
||||
if (design1.getSingleOverall().equals("overall")) {
|
||||
workspaceNew.setPosition("Overall");
|
||||
} else {
|
||||
workspaceNew.setPosition(design1.getSwitchCategory());
|
||||
}
|
||||
workspaceMapper.insert(workspaceNew);
|
||||
if (design1.getModelType().equals("System")) {
|
||||
SysFile sysFile = sysFileMapper.selectById(design1.getTemplateId());
|
||||
if (sysFile.getLevel2Type().equals("Female")) {
|
||||
workspaceNew.setSex("Female");
|
||||
workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
||||
workspaceNew.setMannequinFemaleType("System");
|
||||
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
||||
QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
||||
styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
||||
Style style = styleMapper.selectOne(styleQueryWrapper);
|
||||
WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
||||
workspaceRelStyle.setStyleId(style.getId());
|
||||
workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
||||
workspaceRelStyleMapper.insert(workspaceRelStyle);
|
||||
}
|
||||
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
SysFile anotherOne = anotherList.get(0);
|
||||
workspaceNew.setMannequinMaleId(anotherOne.getId());
|
||||
workspaceNew.setMannequinMaleType("System");
|
||||
}
|
||||
} else {
|
||||
workspaceNew.setSex("Male");
|
||||
workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
||||
workspaceNew.setMannequinMaleType("System");
|
||||
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
||||
QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
||||
styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
||||
Style style = styleMapper.selectOne(styleQueryWrapper);
|
||||
WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
||||
workspaceRelStyle.setStyleId(style.getId());
|
||||
workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
||||
workspaceRelStyleMapper.insert(workspaceRelStyle);
|
||||
}
|
||||
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
SysFile anotherOne = anotherList.get(0);
|
||||
workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
||||
workspaceNew.setMannequinFemaleType("System");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Library library = libraryMapper.selectById(design1.getTemplateId());
|
||||
if (library.getLevel2Type().equals("Female")) {
|
||||
workspaceNew.setSex("Female");
|
||||
workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
||||
workspaceNew.setMannequinFemaleType("Library");
|
||||
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
SysFile anotherOne = anotherList.get(0);
|
||||
workspaceNew.setMannequinMaleId(anotherOne.getId());
|
||||
workspaceNew.setMannequinMaleType("System");
|
||||
}
|
||||
} else {
|
||||
workspaceNew.setSex("Male");
|
||||
workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
||||
workspaceNew.setMannequinMaleType("Library");
|
||||
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
SysFile anotherOne = anotherList.get(0);
|
||||
workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
||||
workspaceNew.setMannequinFemaleType("System");
|
||||
}
|
||||
}
|
||||
}
|
||||
workspaceMapper.updateById(workspaceNew);
|
||||
}
|
||||
}
|
||||
// Long collectionId = portfolio.getCollectionId();
|
||||
// QueryWrapper<Design> getWorkspaceQw = new QueryWrapper<>();
|
||||
// getWorkspaceQw.lambda().eq(Design::getCollectionId, collectionId);
|
||||
// List<Design> designs = designMapper.selectList(getWorkspaceQw);
|
||||
// if (!CollectionUtils.isEmpty(designs)) {
|
||||
// Design design1 = designs.get(0);
|
||||
// Long accountId = authPrincipalVo.getId();
|
||||
// QueryWrapper<Workspace> currentWorkspaceQw = new QueryWrapper<>();
|
||||
// currentWorkspaceQw.lambda().eq(Workspace::getAccountId, accountId);
|
||||
// currentWorkspaceQw.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
// List<Workspace> workspaces = workspaceMapper.selectList(currentWorkspaceQw);
|
||||
// if (!CollectionUtils.isEmpty(workspaces)) {
|
||||
// Workspace workspace1 = workspaces.get(0);
|
||||
// workspace1.setIsLastIndex(0);
|
||||
// workspaceMapper.updateById(workspace1);
|
||||
// Workspace workspaceNew = new Workspace();
|
||||
// String workspaceName = "workspace of " + accountMapper.selectById(portfolio.getAccountId()).getUserName() + portfolio.getPortfolioName();
|
||||
// QueryWrapper<Workspace> existSameNameQw = new QueryWrapper<>();
|
||||
// existSameNameQw.lambda().eq(Workspace::getWorkSpaceName, workspaceName);
|
||||
// existSameNameQw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId());
|
||||
// List<Workspace> existSameNameList = workspaceMapper.selectList(existSameNameQw);
|
||||
// if (!CollectionUtils.isEmpty(existSameNameList)) {
|
||||
// workspaceName = workspaceName + "_copy";
|
||||
// }
|
||||
// workspaceNew.setWorkSpaceName(workspaceName);
|
||||
// workspaceNew.setAccountId(accountId);
|
||||
// workspaceNew.setIsDeleted(0);
|
||||
// workspaceNew.setIsLastIndex(1);
|
||||
// workspaceNew.setCreateTime(LocalDateTime.now());
|
||||
// workspaceNew.setSystemDesignerPercentage((design1.getSystemScale().multiply(BigDecimal.valueOf(100)).intValue()));
|
||||
// if (design1.getSingleOverall().equals("overall")) {
|
||||
// workspaceNew.setPosition("Overall");
|
||||
// } else {
|
||||
// workspaceNew.setPosition(design1.getSwitchCategory());
|
||||
// }
|
||||
// workspaceMapper.insert(workspaceNew);
|
||||
// if (design1.getModelType().equals("System")) {
|
||||
// SysFile sysFile = sysFileMapper.selectById(design1.getTemplateId());
|
||||
// if (sysFile.getLevel2Type().equals("Female")) {
|
||||
// workspaceNew.setSex("Female");
|
||||
// workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinFemaleType("System");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
// if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
||||
// QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
||||
// styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
||||
// Style style = styleMapper.selectOne(styleQueryWrapper);
|
||||
// WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
||||
// workspaceRelStyle.setStyleId(style.getId());
|
||||
// workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
||||
// workspaceRelStyleMapper.insert(workspaceRelStyle);
|
||||
// }
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinMaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinMaleType("System");
|
||||
// }
|
||||
// } else {
|
||||
// workspaceNew.setSex("Male");
|
||||
// workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinMaleType("System");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
// if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
||||
// QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
||||
// styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
||||
// Style style = styleMapper.selectOne(styleQueryWrapper);
|
||||
// WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
||||
// workspaceRelStyle.setStyleId(style.getId());
|
||||
// workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
||||
// workspaceRelStyleMapper.insert(workspaceRelStyle);
|
||||
// }
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinFemaleType("System");
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Library library = libraryMapper.selectById(design1.getTemplateId());
|
||||
// if (library.getLevel2Type().equals("Female")) {
|
||||
// workspaceNew.setSex("Female");
|
||||
// workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinFemaleType("Library");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinMaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinMaleType("System");
|
||||
// }
|
||||
// } else {
|
||||
// workspaceNew.setSex("Male");
|
||||
// workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinMaleType("Library");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinFemaleType("System");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// workspaceMapper.updateById(workspaceNew);
|
||||
// }
|
||||
// }
|
||||
Long workspaceIdOld = workspaceService.getByProjectId(projectIdOld);
|
||||
Workspace workspaceCopy = workspaceMapper.selectById(workspaceIdOld);
|
||||
workspaceCopy.setAccountId(authPrincipalVo.getId());
|
||||
workspaceCopy.setProjectId(project.getId());
|
||||
workspaceCopy.setId(null);
|
||||
workspaceMapper.insert(workspaceCopy);
|
||||
|
||||
return userLikeGroupService.choose(userLikeGroupNew.getId());
|
||||
ProjectDTO projectDTO = new ProjectDTO();
|
||||
projectDTO.setId(project.getId());
|
||||
|
||||
|
||||
return userLikeGroupService.choose(projectDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.mapper.primary.BrandRelLibraryMapper;
|
||||
import com.ai.da.mapper.primary.LibraryMapper;
|
||||
import com.ai.da.mapper.primary.ProductImageAttributeMapper;
|
||||
import com.ai.da.mapper.primary.entity.BrandRelLibrary;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.mapper.primary.entity.ProductImageAttribute;
|
||||
import com.ai.da.mapper.secondary.entity.AttributeRecognitionJSON;
|
||||
import com.ai.da.model.dto.ProgressDTO;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.service.ProductImageService;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ProductImageServiceImpl implements ProductImageService {
|
||||
|
||||
@Autowired
|
||||
private BrandRelLibraryMapper brandRelLibraryMapper;
|
||||
|
||||
@Autowired
|
||||
private LibraryMapper libraryMapper;
|
||||
|
||||
@Autowired
|
||||
private ProductImageAttributeMapper productImageAttributeMapper;
|
||||
|
||||
@Autowired
|
||||
private PythonService pythonService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void asyncInitialize(Long brandId) {
|
||||
System.out.println(">>> [asyncInitialize] 当前线程:" + Thread.currentThread().getName());
|
||||
|
||||
String progressKey = String.valueOf(brandId);
|
||||
ProgressDTO progressDTO = new ProgressDTO(0, 0, false);
|
||||
redisUtil.setTaskProgressDTO(progressKey, progressDTO);
|
||||
|
||||
try {
|
||||
List<BrandRelLibrary> brandRelLibraries = brandRelLibraryMapper.selectList(
|
||||
new QueryWrapper<BrandRelLibrary>().lambda().eq(BrandRelLibrary::getBrandId, brandId)
|
||||
);
|
||||
Set<Long> libraryIds = brandRelLibraries.stream().map(BrandRelLibrary::getLibraryId).collect(Collectors.toSet());
|
||||
|
||||
progressDTO.setTotal(libraryIds.size());
|
||||
|
||||
int current = 0;
|
||||
for (Long libraryId : libraryIds) {
|
||||
Library library = libraryMapper.selectById(libraryId);
|
||||
String url = library.getUrl();
|
||||
|
||||
QueryWrapper<ProductImageAttribute> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ProductImageAttribute::getLibraryId, libraryId);
|
||||
List<ProductImageAttribute> productImageAttributes = productImageAttributeMapper.selectList(qw);
|
||||
if (!CollectionUtil.isNotEmpty(productImageAttributes)) {
|
||||
JSONObject result = pythonService.segProduct(url);
|
||||
JSONArray data = result.getJSONArray("data");
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject obj = data.getJSONObject(i);
|
||||
JSONObject attribute = obj.getJSONObject("attribute");
|
||||
AttributeRecognitionJSON attrJSON = attribute.toJavaObject(AttributeRecognitionJSON.class);
|
||||
ProductImageAttribute attr = toAttrDict(attrJSON);
|
||||
attr.setLibraryId(libraryId);
|
||||
productImageAttributeMapper.insert(attr);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新当前进度
|
||||
current++;
|
||||
progressDTO.setCurrent(current);
|
||||
redisUtil.setTaskProgressDTO(progressKey, progressDTO);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
// log.error("初始化失败", e);
|
||||
redisUtil.setTaskProgressDTO(progressKey, new ProgressDTO(0, 0, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public double getInitializeProgress(Long brandId) {
|
||||
// ProgressDTO dto = redisUtil.getTaskProgressDTO(String.valueOf(brandId));
|
||||
// if (dto.getTotal() == 0 || dto.isError()) return 0.0;
|
||||
// return (dto.getCurrent() * 1.0 / dto.getTotal());
|
||||
// }
|
||||
|
||||
private ProductImageAttribute toAttrDict(AttributeRecognitionJSON attrDictJSON) {
|
||||
ProductImageAttribute attributeRetrieval = new ProductImageAttribute();
|
||||
|
||||
// 处理 imgName
|
||||
// if (CollectionUtil.isNotEmpty(attrDictJSON.getImgName()) && attrDictJSON.getImgName().get(0) != null) {
|
||||
// attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
|
||||
// }
|
||||
// 处理 length
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getLength()) && attrDictJSON.getLength().get(0) != null) {
|
||||
attributeRetrieval.setLength(attrDictJSON.getLength().get(0));
|
||||
}
|
||||
// 处理 sleeveLength
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getSleeveLength()) && attrDictJSON.getSleeveLength().get(0) != null) {
|
||||
attributeRetrieval.setSleeveLength(attrDictJSON.getSleeveLength().get(0));
|
||||
}
|
||||
// 处理 sleeveShape
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getSleeveShape()) && attrDictJSON.getSleeveShape().get(0) != null) {
|
||||
attributeRetrieval.setSleeveShape(attrDictJSON.getSleeveShape().get(0));
|
||||
}
|
||||
// 处理 sleeveShoulder
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getSleeveShoulder()) && attrDictJSON.getSleeveShoulder().get(0) != null) {
|
||||
attributeRetrieval.setSleeveShoulder(attrDictJSON.getSleeveShoulder().get(0));
|
||||
}
|
||||
// 处理 neckline
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getNeckline()) && attrDictJSON.getNeckline().get(0) != null) {
|
||||
attributeRetrieval.setNeckline(attrDictJSON.getNeckline().get(0));
|
||||
}
|
||||
// 处理 collar
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getCollar()) && attrDictJSON.getCollar().get(0) != null) {
|
||||
attributeRetrieval.setCollar(attrDictJSON.getCollar().get(0));
|
||||
}
|
||||
// 处理 design
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getDesign()) && attrDictJSON.getDesign().get(0) != null) {
|
||||
attributeRetrieval.setDesign(attrDictJSON.getDesign().get(0));
|
||||
}
|
||||
// 处理 silhouette
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getSilhouette()) && attrDictJSON.getSilhouette().get(0) != null) {
|
||||
attributeRetrieval.setSilhouette(attrDictJSON.getSilhouette().get(0));
|
||||
}
|
||||
// 处理 type
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getType()) && attrDictJSON.getType().get(0) != null) {
|
||||
attributeRetrieval.setType(attrDictJSON.getType().get(0));
|
||||
}
|
||||
// 处理 openingType
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getOpeningType()) && attrDictJSON.getOpeningType().get(0) != null) {
|
||||
attributeRetrieval.setOpeningType(attrDictJSON.getOpeningType().get(0));
|
||||
}
|
||||
// 处理 subtype
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getSubtype()) && attrDictJSON.getSubtype().get(0) != null) {
|
||||
attributeRetrieval.setSubtype(attrDictJSON.getSubtype().get(0));
|
||||
}
|
||||
|
||||
return attributeRetrieval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
private ThreeDSimpleMapper threeDSimpleMapper;
|
||||
@Resource
|
||||
private ThreeDModuleMapper threeDModuleMapper;
|
||||
@Resource
|
||||
private ProductImageService productImageService;
|
||||
|
||||
@Override
|
||||
public void deleteUserGroup(Long userGroupId) {
|
||||
@@ -1156,42 +1158,38 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
@Override
|
||||
public Boolean productImageInitialize(ProductImageInitializeDTO productImageInitializeDTO) {
|
||||
|
||||
Long brandId = productImageInitializeDTO.getBrandId();
|
||||
QueryWrapper<BrandRelLibrary> brandRelLibraryQueryWrapper = new QueryWrapper<>();
|
||||
brandRelLibraryQueryWrapper.lambda().eq(BrandRelLibrary::getBrandId, brandId);
|
||||
List<BrandRelLibrary> brandRelLibraries = brandRelLibraryMapper.selectList(brandRelLibraryQueryWrapper);
|
||||
Set<Long> collect = brandRelLibraries.stream().map(BrandRelLibrary::getLibraryId).collect(Collectors.toSet());
|
||||
productImageService.asyncInitialize(productImageInitializeDTO.getBrandId());
|
||||
return true;
|
||||
}
|
||||
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
accountService.getById(authPrincipalVo.getId());
|
||||
@Override
|
||||
public InitializeProgressVO getInitializeProgress(ProductImageInitializeDTO productImageInitializeDTO) {
|
||||
InitializeProgressVO vo = new InitializeProgressVO();
|
||||
|
||||
for (Long libraryId : collect) {
|
||||
Library library = libraryMapper.selectById(libraryId);
|
||||
String url = library.getUrl();
|
||||
String gender = library.getLevel2Type();
|
||||
// QueryWrapper<>
|
||||
|
||||
// 提取sketch
|
||||
JSONObject jsonObject = pythonService.segProduct(url);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject jsonObject1 = data.getJSONObject(i);
|
||||
JSONObject attribute = jsonObject1.getJSONObject("attribute");
|
||||
AttributeRecognitionJSON attrDictJSON = attribute.toJavaObject(AttributeRecognitionJSON.class);
|
||||
ProductImageAttribute productImageAttribute = toAttrDict(attrDictJSON);
|
||||
productImageAttribute.setLibraryId(library.getId());
|
||||
productImageAttributeMapper.insert(productImageAttribute);
|
||||
}
|
||||
ProgressDTO dto = redisUtil.getTaskProgressDTO(String.valueOf(productImageInitializeDTO.getBrandId()));
|
||||
|
||||
if (Objects.isNull(dto)) {
|
||||
vo.setAnalyzed(false);
|
||||
return vo;
|
||||
}
|
||||
return null;
|
||||
vo.setAnalyzed(true);
|
||||
if (dto.getTotal() == 0 || dto.isError()) {
|
||||
vo.setPercent(0.0);
|
||||
return vo;
|
||||
}
|
||||
vo.setPercent(dto.getCurrent() * 1.0 / dto.getTotal());
|
||||
return vo;
|
||||
}
|
||||
|
||||
private ProductImageAttribute toAttrDict(AttributeRecognitionJSON attrDictJSON) {
|
||||
ProductImageAttribute attributeRetrieval = new ProductImageAttribute();
|
||||
|
||||
// 处理 imgName
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getImgName()) && attrDictJSON.getImgName().get(0) != null) {
|
||||
attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(attrDictJSON.getImgName()) && attrDictJSON.getImgName().get(0) != null) {
|
||||
// attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
|
||||
// }
|
||||
// 处理 length
|
||||
if (CollectionUtil.isNotEmpty(attrDictJSON.getLength()) && attrDictJSON.getLength().get(0) != null) {
|
||||
attributeRetrieval.setLength(attrDictJSON.getLength().get(0));
|
||||
@@ -2145,7 +2143,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException {
|
||||
public String downloadZip(Long threeDSimpleId, String sizeType, String size, HttpServletResponse response) throws MinioException, IOException {
|
||||
QueryWrapper<ThreeDDetail> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ThreeDDetail::getThreeDSimpleId, threeDSimpleId);
|
||||
qw.lambda().eq(ThreeDDetail::getSizeType, sizeType);
|
||||
@@ -2154,29 +2152,29 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (ObjectUtils.isAllFieldNull(threeDDetail)) {
|
||||
throw new BusinessException("3D file is not exist");
|
||||
}
|
||||
InputStream inputStream = minioUtil.download(threeDDetail.getUrl());
|
||||
return minioUtil.getPreSignedUrl(threeDDetail.getUrl(), 24 * 60);
|
||||
|
||||
// 设置响应头
|
||||
response.setContentType("application/zip"); // 确保 ZIP 格式
|
||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
String fileName = threeDDetail.getName();
|
||||
if (!fileName.toLowerCase().endsWith(".zip")) {
|
||||
fileName += ".zip";
|
||||
}
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString()));
|
||||
|
||||
// 将文件内容写入响应输出流
|
||||
try {
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
response.getOutputStream().write(buffer, 0, bytesRead);
|
||||
}
|
||||
inputStream.close();
|
||||
response.getOutputStream().flush();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to download ZIP file", e);
|
||||
}
|
||||
// // 设置响应头
|
||||
// response.setContentType("application/zip"); // 确保 ZIP 格式
|
||||
// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
// String fileName = threeDDetail.getName();
|
||||
// if (!fileName.toLowerCase().endsWith(".zip")) {
|
||||
// fileName += ".zip";
|
||||
// }
|
||||
// response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString()));
|
||||
//
|
||||
// // 将文件内容写入响应输出流
|
||||
// try {
|
||||
// byte[] buffer = new byte[8192];
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
// response.getOutputStream().write(buffer, 0, bytesRead);
|
||||
// }
|
||||
// inputStream.close();
|
||||
// response.getOutputStream().flush();
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException("Failed to download ZIP file", e);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2184,4 +2182,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
projectMapper.deleteById(projectId);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean brandDNADelete(BrandDNADTO brandDNADTO) {
|
||||
brandDNAMapper.deleteById(brandDNADTO.getId());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user