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

@@ -29,7 +29,7 @@ public enum CollectionLevel1TypeEnum {
*/
MARKETING_SKETCH("MarketingSketch"),
MANNEQUIN("Mannequin");
MODEL("Models");
private String realName;

View File

@@ -0,0 +1,10 @@
package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.CollectionElementRelModel;
import java.util.Set;
public interface CollectionElementRelModelMapper extends CommonMapper<CollectionElementRelModel> {
}

View File

@@ -0,0 +1,34 @@
package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("collection_element_rel_model")
public class CollectionElementRelModel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long relationId;
private String relationType;
private Long collectionElementId;
private String ageGroup;
}

View File

@@ -63,6 +63,9 @@ public class DesignItem implements Serializable {
@TableField("is_like")
private Byte hasLike;
private Long relationId;
private String modelType;
/**
* 创建时间
*/

View File

@@ -29,6 +29,8 @@ public class DesignCollectionDTO {
@ApiModelProperty("手稿板图片id 数组")
private List<CollectionSketchDTO> sketchBoards;
private List<MannequinDTO> mannequins;
@NotNull(message = "systemScale.cannot.be.empty")
@ApiModelProperty("系统取图比列")
private BigDecimal systemScale;

View File

@@ -9,6 +9,9 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class MannequinDTO {
private Long id;
private Long collectionElementId;
private String type;
// private String modelType;
}

View File

@@ -46,4 +46,7 @@ public class CollectionElementVO {
private List<String> segmentedImages;
private Long mannequinRelationId;
private String mannequinRelationType;
}

View File

@@ -40,5 +40,9 @@ public class DesignLibraryModelPointVO implements Serializable {
private String templateUrl;
private Long relationId;
private String relationType;
}

View File

@@ -35,4 +35,6 @@ public class ModuleChooseVO {
private SketchReconstructionVO deReconstruction;
private ThreeDModuleVO patternMaking3D;
private List<CollectionElementVO> mannequin;
}

View File

@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
@AllArgsConstructor
@Data
@ApiModel("用户choose详细-响应")
@@ -15,7 +17,7 @@ public class UserLikeChooseVO {
private Long userGroupId;
@ApiModelProperty("分组详细数组")
private java.util.List<UserLikeVO> userLikeDetails;
private List<UserLikeVO> userLikeDetails;
@ApiModelProperty("关联的collection")
private UserLikeCollectionVO collection;

View File

@@ -2,6 +2,7 @@ package com.ai.da.model.vo;
import com.ai.da.mapper.primary.entity.CollectionElement;
import com.ai.da.model.dto.CollectionColorDTO;
import com.ai.da.model.dto.MannequinDTO;
import com.ai.da.python.vo.DesignPythonItemPrint;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
@@ -59,4 +60,5 @@ public class ValidateElementVO {
private Long brandId;
private Double brandScale;
private List<DesignLibraryModelPointVO> mannequins;
}

View File

@@ -29,7 +29,6 @@ import com.google.common.collect.Maps;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -45,7 +44,6 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.HttpURLConnection;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
@@ -350,7 +348,7 @@ public class PythonService {
private DesignPythonObject createDesignPythonObject(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale, String singleOverall, String switchCategory, int i) {
DesignPythonObject pythonObject = new DesignPythonObject();
pythonObject.setItems(coverToDesignPythonItemNew(elementVO, designPictureType, systemScale));
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint(), elementVO.getMannequins()));
if (CollectionUtil.isNotEmpty(elementVO.getRequestIdList())) {
pythonObject.setObjectSign(elementVO.getRequestIdList().get(i));
}
@@ -2169,7 +2167,7 @@ public class PythonService {
}
private DesignPythonBasic coverToBasic(DesignPythonItem designPythonItem, String singleOverall,
String switchCategory, DesignLibraryModelPointVO designLibraryModelPoint) {
String switchCategory, DesignLibraryModelPointVO designLibraryModelPoint, List<DesignLibraryModelPointVO> mannequins) {
DesignPythonBasic basic = new DesignPythonBasic();
basic.setSingle_overall(singleOverall);
basic.setSwitch_category(switchCategory);
@@ -2182,12 +2180,25 @@ public class PythonService {
basic.setSelf_template(Boolean.TRUE);
}
basic.setScale_earrings(0.16);
basic.setBody_point_test(getMap(designLibraryModelPoint));
if (!CollectionUtils.isEmpty(mannequins)) {
DesignLibraryModelPointVO vo = getRandomDesignLibraryModelPoint(mannequins);
basic.setBody_point_test(getMap(vo));
}else {
basic.setBody_point_test(getMap(designLibraryModelPoint));
}
return basic;
}
private Map<String, List<Integer>> getMap(DesignLibraryModelPointVO designLibraryModelPointOld) {
Map<String, List<Integer>> body_point = Maps.newHashMap();
private DesignLibraryModelPointVO getRandomDesignLibraryModelPoint(List<DesignLibraryModelPointVO> mannequins) {
DesignLibraryModelPointVO vo = new DesignLibraryModelPointVO();
Random random = new Random();
int randomNumber = random.nextInt(mannequins.size());
return mannequins.get(randomNumber);
}
private Map<String, Object> getMap(DesignLibraryModelPointVO designLibraryModelPointOld) {
Map<String, Object> body_point = Maps.newHashMap();
if (Objects.nonNull(designLibraryModelPointOld)) {
DesignLibraryModelPointVO designLibraryModelPoint =
CopyUtil.copyObject(designLibraryModelPointOld, DesignLibraryModelPointVO.class);
@@ -2198,6 +2209,8 @@ public class PythonService {
body_point.put("waistband_right", resolve(designLibraryModelPoint.getWaistbandRight()));
body_point.put("hand_point_left", resolve(designLibraryModelPoint.getHandLeft()));
body_point.put("hand_point_right", resolve(designLibraryModelPoint.getHandRight()));
body_point.put("relation_id", designLibraryModelPoint.getRelationId());
body_point.put("relation_type", designLibraryModelPoint.getRelationType());
} else {
//默认是13个点
body_point.put("shoulder_left", Arrays.asList(755, 519));

View File

@@ -36,7 +36,7 @@ public class DesignPythonBasic {
private Double scale_earrings;
private Map<String, List<Integer>> body_point_test = Maps.newHashMap();
private Map<String, Object> body_point_test = Maps.newHashMap();
private Boolean layer_order = Boolean.FALSE;

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();