获取design detail

This commit is contained in:
xupei
2023-09-07 15:31:52 +08:00
parent 1201f57291
commit 165449084b
9 changed files with 84 additions and 21 deletions

View File

@@ -75,5 +75,5 @@ public interface DesignService extends IService<Design> {
* @param designItemId
* @return
*/
DesignItemDetailVO detail(Long designItemId);
DesignItemDetailVO detail(Long designPythonOutfitId,Long designItemId);
}

View File

@@ -6,6 +6,8 @@ import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* design item详情表 服务类
*
@@ -23,4 +25,10 @@ public interface ITDesignPythonOutfitDetailService extends IService<TDesignPytho
*/
IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
/**
* 通过DesignPythonOutfitId获取designPythonOutfitDetail
* @param designPythonOutfitId
* @return
*/
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
}

View File

@@ -6,6 +6,7 @@ import com.ai.da.model.vo.PantoneVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 服务类
@@ -41,6 +42,8 @@ public interface PanToneService extends IService<PanTone> {
*/
PantoneVO getByRGB(Integer r,Integer g,Integer b);
Map<String,PantoneVO> getPantoneByRgbBatch(List<String> colors);
PantoneVO getPantoneByRgb(String color);
/**

View File

@@ -5,21 +5,17 @@ import com.ai.da.common.config.FileProperties;
import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
import com.ai.da.common.enums.SingleOverallEnum;
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.DateUtil;
import com.ai.da.common.utils.FileUtil;
import com.ai.da.common.utils.LocalCacheUtils;
import com.ai.da.mapper.DesignMapper;
import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
import com.ai.da.mapper.TDesignPythonOutfitMapper;
import com.ai.da.mapper.entity.*;
import com.ai.da.mapper.entity.Collection;
import com.ai.da.model.dto.*;
import com.ai.da.model.vo.*;
import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonItem;
import com.ai.da.python.vo.DesignPythonItemPrint;
import com.ai.da.python.vo.DesignPythonObjects;
import com.ai.da.service.*;
@@ -31,12 +27,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.operators.relational.OldOracleJoinBinaryExpression;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import sun.security.krb5.internal.crypto.Des;
import javax.annotation.Resource;
import java.io.File;
@@ -650,7 +644,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
@Override
public DesignItemDetailVO detail(Long designItemId) {
public DesignItemDetailVO detail(Long designPythonOutfitId,Long designItemId) {
DesignItem designItem = designItemService.getById(designItemId);
Assert.notNull(designItem,"design item does not exist!");
Design design = getById(designItem.getDesignId());
@@ -658,7 +652,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
List<DesignItemDetail> designItemDetails = designItemDetailService.selectByDesignItemId(designItemId);
Assert.notEmpty(designItemDetails,"designItemDetails does not exist!");
// 添加判断designPythonOutfitId是否存在
TDesignPythonOutfit designPythonOutfit = new TDesignPythonOutfit();
Boolean flag = Boolean.FALSE;
if (Objects.nonNull(designPythonOutfitId)){
designPythonOutfit = designPythonOutfitService.getById(designPythonOutfitId);
Assert.notNull(designPythonOutfit,"designPythonOutfit does not exist!");
flag = Boolean.TRUE;
}
DesignItemDetailVO response = new DesignItemDetailVO();
response.setSingleOverall(design.getSingleOverall());
@@ -688,7 +688,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
d.setId(o.getBusinessId());
d.setPrintObject(new DesignPythonItemPrint());
}));
return editResponseColor(designItemDetails,response);
return editDesignItemLayer(flag,designPythonOutfit,designItem.getDesignUrl(),editResponseColor(designItemDetails,response));
}
private String converTypeToLevel1(String type){
if(StringUtils.isEmpty(type)){
@@ -735,7 +735,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
* @return
*/
private DesignItemDetailVO editResponseColor(List<DesignItemDetail> designItemDetails,DesignItemDetailVO designItemDetailVO){
designItemDetails.forEach(d -> {
/*designItemDetails.forEach(d -> {
if (!StringUtil.isNullOrEmpty(d.getColor())){
PantoneVO pantoneByRgb = panToneService.getPantoneByRgb(d.getColor());
DesignItemClothesDetailVO clothesDetailVO = designItemDetailVO.getClothes().stream()
@@ -753,21 +753,50 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
}
}
});*/
HashMap<Long, String> businessIdColor = new HashMap<>();
designItemDetails.forEach(designItemDetail -> {
if (!StringUtil.isNullOrEmpty(designItemDetail.getColor())){
businessIdColor.put(designItemDetail.getBusinessId(),designItemDetail.getColor());
}
});
Map<String, PantoneVO> pantoneByRgbBatch = panToneService.getPantoneByRgbBatch(new ArrayList<>(businessIdColor.values()));
designItemDetailVO.getClothes().forEach(c -> {
PantoneVO pantoneVO = pantoneByRgbBatch.get(businessIdColor.get(c.getId()));
c.setColor(pantoneVO);
});
designItemDetailVO.getOthers().forEach(o -> {
PantoneVO pantoneVO = pantoneByRgbBatch.get(businessIdColor.get(o.getId()));
o.setColor(pantoneVO);
});
return designItemDetailVO;
}
private DesignItemDetailVO editDesignItemLayer(Long designPythonOutfitId,DesignItemDetailVO designItemDetailVO){
// 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误
private DesignItemDetailVO editDesignItemLayer(Boolean flag,TDesignPythonOutfit designPythonOutfit,String designItemId,DesignItemDetailVO designItemDetailVO){
DesignPythonOutfitVO designPythonOutfitVO = new DesignPythonOutfitVO();
// 2、将查询出的图层信息填充到designItemDetailVO中
if (flag){
// 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误
List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
Assert.notEmpty(details,"Some errors occurred, please restart the design");
// 2、将查询出的图层信息填充到designItemDetailVO中
designPythonOutfitVO.setDesignPythonOutfitId(designPythonOutfit.getId());
designPythonOutfitVO.setDesignPythonOutfitUrl(designPythonOutfit.getDesignUrl());
designPythonOutfitVO.setDesignItemDetailLayers(details);
}else{
designPythonOutfitVO.setDesignPythonOutfitUrl(designItemId);
}
return null;
designItemDetailVO.setDesignItemUrl(designPythonOutfitVO);
return designItemDetailVO;
}
}

View File

@@ -71,6 +71,7 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
return coverPanToneToVo(panTones);
}
@Override
public Map<String,PantoneVO> getPantoneByRgbBatch(List<String> colors){
HashMap<Integer,String> colorValueRgb = new HashMap<>();
@@ -89,13 +90,18 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
colorIndexRgb.put(colorValue.getColorIndex(),colorValueRgb.get(colorValue.getColorValue()));
});
List<PanTone> panTones = panToneService.listByIds(colorIndexRgb.values());
List<PanTone> panTones = panToneService.listByIds(colorIndexRgb.keySet());
ArrayList<PantoneVO> pantoneVOS = new ArrayList<>();
panTones.forEach(panTone -> {
pantoneVOS.add(coverPanToneToVo(panTone));
});
return null;
HashMap<String, PantoneVO> colorPantoneVO = new HashMap<>();
pantoneVOS.forEach(pantoneVO -> {
colorPantoneVO.put(colorIndexRgb.get(pantoneVO.getId()),pantoneVO);
});
return colorPantoneVO;
}

View File

@@ -4,10 +4,13 @@ import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
import com.ai.da.service.ITDesignPythonOutfitDetailService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* design item详情表 服务实现类
*
@@ -22,4 +25,13 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
return page.setRecords(baseMapper.selectTDesignPythonOutfitDetailPage(page, tDesignPythonOutfitDetail));
}
@Override
public List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId){
QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_python_outfit_id",designPythonOutfitId);
return baseMapper.selectList(queryWrapper);
}
}