TASK:mannequin;

This commit is contained in:
shahaibo
2025-05-28 09:37:27 +08:00
parent d3b4d15df8
commit 1be4701f6d
16 changed files with 204 additions and 40 deletions

View File

@@ -601,18 +601,37 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
}
// 校验模特
if (!StringUtils.isEmpty(designDTO.getModelType())) {
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library byId = libraryService.getById(designDTO.getTemplateId());
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
elementVO.setStyle(byId.getLevel3Type());
if (!CollectionUtils.isEmpty(designDTO.getMannequins())) {
List<DesignLibraryModelPointVO> designLibraryModelPointVOList = new ArrayList<>();
for (MannequinDTO mannequin : designDTO.getMannequins()) {
if (mannequin.getType().equals("System")) {
Library byId = libraryService.getById(mannequin.getId());
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
}else {
SysFileVO byId = sysFileService.getById(mannequin.getId());
// if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
// elementVO.setStyle(byId.getLevel3Type());
// }
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
}
}
elementVO.setMannequins(designLibraryModelPointVOList);
}else {
if (!StringUtils.isEmpty(designDTO.getModelType())) {
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library byId = libraryService.getById(designDTO.getTemplateId());
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
elementVO.setStyle(byId.getLevel3Type());
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
}
}
elementVO.setModelSex(designDTO.getModelSex());
@@ -660,6 +679,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
libraryModelPoint.setWaistbandLeft(calculateTemplatePointOne(modelPoint.getWaistbandLeft(), high, width));
libraryModelPoint.setWaistbandRight(calculateTemplatePointOne(modelPoint.getWaistbandRight(), high, width));
libraryModelPoint.setTemplateUrl(templateUrl);
libraryModelPoint.setRelationId(modelPoint.getRelationId());
libraryModelPoint.setRelationType(modelPoint.getModelType());
return libraryModelPoint;
}

View File

@@ -759,6 +759,20 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItem.setDesignUrl(item.getBasic().getSave_name());
designItem.setHasLike((byte) 0);
//生成designItem
Map<String, Object> bodyPointTest = item.getBasic().getBody_point_test();
// 转换 relation_id (Long)
Long relationId = Optional.ofNullable(bodyPointTest.get("relation_id"))
.filter(Number.class::isInstance)
.map(num -> ((Number) num).longValue())
.orElseThrow(null);
// 转换 relation_type (String)
String relationType = Optional.ofNullable(bodyPointTest.get("relation_type"))
.filter(String.class::isInstance)
.map(String.class::cast)
.orElse(null);
designItem.setRelationId(relationId);
designItem.setModelType(relationType);
Long designItemId = designItemService.saveOne(designItem);
// python design返回入库及封装
// JSONObject outfit = data.getJSONObject(i + "");

View File

@@ -131,6 +131,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
private ThreeDModuleMapper threeDModuleMapper;
@Resource
private ProductImageService productImageService;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
@Override
public void deleteUserGroup(Long userGroupId) {
@@ -1653,11 +1655,36 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
moduleChooseVO.setPatternMaking3D(threeDModuleVO);
}
}
}else if (module.equals(Module.mannequin.name())) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
List<CollectionElementVO> list = new ArrayList<>();
if (CollectionUtil.isNotEmpty(collectionElements)) {
for (CollectionElement collectionElement : collectionElements) {
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
CollectionElementRelModel relModel = getCollectionElementRelModel(collectionElementVO.getId());
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(collectionElementVO.getUrl(), 24 * 60));
collectionElementVO.setMannequinRelationId(relModel.getRelationId());
collectionElementVO.setMannequinRelationType(relModel.getRelationType());
collectionElementVO.setCollectionId(collectionElement.getId());
list.add(collectionElementVO);
}
}
moduleChooseVO.setMannequin(list);
}
}
return moduleChooseVO;
}
private CollectionElementRelModel getCollectionElementRelModel(Long id) {
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElementRelModel::getCollectionElementId, id);
CollectionElementRelModel collectionElementRelModel = collectionElementRelModelMapper.selectOne(qw);
return collectionElementRelModel;
}
@Override
@Transactional
public ModuleChooseVO saveModuleContent(ModuleSaveDTO moduleSaveDTO) {
@@ -1905,61 +1932,79 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (CollectionUtil.isNotEmpty(moduleSaveDTO.getMannequin())) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionElement::getProjectId, projectId);
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MANNEQUIN.getRealName());
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName());
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
// Set<String> oldUrl = collectionElements.stream().map(CollectionElement::getUrl).collect(Collectors.toSet());
List<MannequinDTO> mannequin = moduleSaveDTO.getMannequin();
for (MannequinDTO dto : mannequin) {
if (null != dto.getCollectionElementId()) {
old.remove(dto.getId());
continue;
}
if (dto.getType().equals("System")) {
SysFile sysFile = sysFileMapper.selectById(dto.getId());
CollectionElement collectionElement = new CollectionElement();
collectionElement.setAccountId(accountId);
collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MANNEQUIN.getRealName());
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
// collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setName(sysFile.getName());
collectionElement.setUrl(sysFile.getUrl());
// collectionElement.setHasPin(board.getIsPin());
collectionElement.setMd5(sysFile.getMd5());
collectionElement.setCreateDate(new Date());
collectionElement.setHasPin((byte) 0);
collectionElementMapper.insert(collectionElement);
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
collectionElementRelModel.setRelationId(dto.getId());
collectionElementRelModel.setRelationType("System");
collectionElementRelModelMapper.insert(collectionElementRelModel);
}else if (dto.getType().equals("Library")) {
Library library = libraryMapper.selectById(dto.getId());
CollectionElement collectionElement = new CollectionElement();
collectionElement.setAccountId(accountId);
collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MANNEQUIN.getRealName());
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
// collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setName(library.getName());
collectionElement.setUrl(library.getUrl());
// collectionElement.setHasPin(board.getIsPin());
collectionElement.setMd5(library.getMd5());
collectionElement.setCreateDate(new Date());
collectionElement.setHasPin((byte) 0);
collectionElementMapper.insert(collectionElement);
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
collectionElementRelModel.setRelationId(dto.getId());
collectionElementRelModel.setRelationType("System");
collectionElementRelModelMapper.insert(collectionElementRelModel);
}else {
if (old.contains(dto.getId())) {
CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
// collectionElement.setLevel2Type(board.getLevel2Type());
// collectionElement.setHasPin(board.getIsPin());
collectionElement.setUpdateDate(new Date());
collectionElementMapper.updateById(collectionElement);
old.remove(dto.getId());
}else {
CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
collectionElement.setProjectId(projectId);
// collectionElement.setLevel2Type(board.getLevel2Type());
// collectionElement.setHasPin(board.getIsPin());
collectionElement.setUpdateDate(new Date());
collectionElementMapper.updateById(collectionElement);
}
// if (old.contains(dto.getId())) {
// CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
//// collectionElement.setLevel2Type(board.getLevel2Type());
//// collectionElement.setHasPin(board.getIsPin());
// collectionElement.setUpdateDate(new Date());
// collectionElementMapper.updateById(collectionElement);
// old.remove(dto.getId());
// }else {
// CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
// collectionElement.setProjectId(projectId);
//// collectionElement.setLevel2Type(board.getLevel2Type());
//// collectionElement.setHasPin(board.getIsPin());
// collectionElement.setUpdateDate(new Date());
// collectionElementMapper.updateById(collectionElement);
// }
}
}
if (!CollectionUtils.isEmpty(old)) {
collectionElementMapper.deleteBatchIds(old);
// 删除关联关系
deleteByCollectionElementIdList(old);
}
}
@@ -1993,6 +2038,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
return result;
}
private void deleteByCollectionElementIdList(Set<Long> old) {
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
qw.lambda().in(CollectionElementRelModel::getCollectionElementId, old);
collectionElementRelModelMapper.delete(qw);
}
@Override
public QueryLibraryPageVO getMannequinDetail(MannequinDTO mannequinDTO) {
QueryLibraryPageVO vo = new QueryLibraryPageVO();