design single接口疏通
This commit is contained in:
@@ -4,56 +4,28 @@ public class PantoneUtils {
|
||||
|
||||
public static int[] rgbToHsv(int[] rgb) {
|
||||
//切割rgb数组
|
||||
int R = rgb[0];
|
||||
int G = rgb[1];
|
||||
int B = rgb[2];
|
||||
//公式运算 /255
|
||||
float R_1 = R / 255f;
|
||||
float G_1 = G / 255f;
|
||||
float B_1 = B / 255f;
|
||||
//重新拼接运算用数组
|
||||
float[] all = {R_1, G_1, B_1};
|
||||
float max = all[0];
|
||||
float min = all[0];
|
||||
//循环查找最大值和最小值
|
||||
for (int i = 0; i < all.length; i++) {
|
||||
if (max <= all[i]) {
|
||||
max = all[i];
|
||||
}
|
||||
if (min >= all[i]) {
|
||||
min = all[i];
|
||||
}
|
||||
}
|
||||
float C_max = max;
|
||||
float C_min = min;
|
||||
//计算差值
|
||||
float diff = C_max - C_min;
|
||||
float hue = 0f;
|
||||
//判断情况计算色调H
|
||||
if (diff == 0f) {
|
||||
hue = 0f;
|
||||
} else {
|
||||
if (C_max == R_1) {
|
||||
hue = (((G_1 - B_1) / diff) % 6) * 60f;
|
||||
}
|
||||
if (C_max == G_1) {
|
||||
hue = (((B_1 - R_1) / diff) + 2f) * 60f;
|
||||
}
|
||||
if (C_max == B_1) {
|
||||
hue = (((R_1 - G_1) / diff) + 4f) * 60f;
|
||||
}
|
||||
}
|
||||
//计算饱和度S
|
||||
float saturation;
|
||||
if (C_max == 0f) {
|
||||
saturation = 0f;
|
||||
} else {
|
||||
saturation = diff / C_max;
|
||||
}
|
||||
//计算明度V
|
||||
float value = C_max;
|
||||
int[] result = {Math.round(hue), Math.round(saturation * 100), Math.round(value * 100)};
|
||||
return result;
|
||||
int red = rgb[0];
|
||||
int green= rgb[1];
|
||||
int blue = rgb[2];
|
||||
|
||||
float r = (float) red / 255;
|
||||
float g = (float) green / 255;
|
||||
float b = (float) blue / 255;
|
||||
|
||||
float min = Math.min(Math.min(r, g), b);
|
||||
|
||||
float[] hsv = {60, 0, Math.max(Math.max(r, g), b)};
|
||||
|
||||
hsv[1] = (hsv[2] == 0) ? 0 : 1 - min / hsv[2];
|
||||
|
||||
hsv[0] = 60 * (
|
||||
(hsv[2] == min) ? Float.NaN :
|
||||
(hsv[2] == r) ? (g - b) / (hsv[2] - min) + ((g < b) ? 6 : 0) :
|
||||
(hsv[2] == g) ? (b - r) / (hsv[2] - min) + 2:
|
||||
(r - g) / (hsv[2] - min) + 4
|
||||
);
|
||||
|
||||
return new int[]{Math.round(hsv[0]), Math.round(hsv[1] * 100), Math.round(hsv[2] * 100)};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,4 +93,9 @@ public class DesignItemDetail implements Serializable {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateDate;
|
||||
|
||||
/**
|
||||
* 逻辑删除 1->删除 0->未删除 默认null
|
||||
*/
|
||||
private Byte isDeleted;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.List;
|
||||
public class DesignSinglePrint {
|
||||
|
||||
@ApiModelProperty("印花位置")
|
||||
@Range(max = 1L,message = "印花坐标需用大于等于0小于等于1的数表示")
|
||||
private List<Float> location;
|
||||
|
||||
@ApiModelProperty("印花大小")
|
||||
|
||||
@@ -1643,7 +1643,7 @@ public class PythonService {
|
||||
content.put("category", category);
|
||||
content.put("mode",mode);
|
||||
content.put("str", text);
|
||||
content.put("version","2");
|
||||
content.put("version",modelName);
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content,SerializerFeature.WriteMapNullValue));
|
||||
Request request = new Request.Builder()
|
||||
// .url(accessPythonIp + ":2828/aida/diffusion")
|
||||
|
||||
@@ -41,13 +41,18 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
|
||||
public int deleteByDesignItemId(Long designItemId) {
|
||||
QueryWrapper<DesignItemDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("design_item_id", designItemId);
|
||||
return designItemDetailMapper.delete(queryWrapper);
|
||||
DesignItemDetail designItemDetail = new DesignItemDetail();
|
||||
designItemDetail.setIsDeleted((byte)1);
|
||||
return designItemDetailMapper.update(designItemDetail,queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DesignItemDetail> selectByDesignItemId(Long designItemId) {
|
||||
QueryWrapper<DesignItemDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("design_item_id", designItemId);
|
||||
queryWrapper.eq("design_item_id", designItemId)
|
||||
.isNull("is_deleted")
|
||||
.or()
|
||||
.ne("is_deleted",(byte)1);
|
||||
return designItemDetailMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,6 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
private PanToneService panToneService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Value("${minio.bucketName.results}")
|
||||
private String bucketName;
|
||||
|
||||
@Override
|
||||
public Long saveOne(DesignItem designItem) {
|
||||
@@ -290,13 +288,13 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
designItem.setDesignUrl(url);
|
||||
designItem.setId(designItemId);
|
||||
|
||||
//更新item
|
||||
//更新designItem
|
||||
updateById(designItem);
|
||||
//删除itemDetail
|
||||
//删除designItemDetail(逻辑删除)
|
||||
designItemDetailService.deleteByDesignItemId(designItemId);
|
||||
|
||||
List<DesignItemDetail> designItemDetails = Lists.newArrayList();
|
||||
// 保存designItem
|
||||
// 保存新的designItemDetail
|
||||
pythonObjects.getObjects().get(0).getItems().forEach(detail ->{
|
||||
if(null == detail){
|
||||
return;
|
||||
@@ -328,7 +326,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
designPythonOutfit.setUpdateDate(LocalDateTime.now(ZoneId.of(timeZone)));
|
||||
designPythonOutfitService.updateById(designPythonOutfit);
|
||||
|
||||
// 删除designPythonOutfitDetail表中原始的图层信息
|
||||
// 删除designPythonOutfitDetail表中原始的图层信息(逻辑删除)
|
||||
designPythonOutfitDetailService.deleteByDesignPythonOutfitId(designPythonOutfit.getId());
|
||||
|
||||
// 将新生成的图层信息存入designPythonOutfitDetail表
|
||||
|
||||
@@ -82,10 +82,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private PanToneService panToneService;
|
||||
@Resource
|
||||
private PythonTAllInfoService pythonTAllInfoService;
|
||||
@Value("${minio.endpoint}")
|
||||
private String endpoint;
|
||||
@Value("${minio.bucketName.results}")
|
||||
private String bucketName;
|
||||
|
||||
// @Transactional
|
||||
@Override
|
||||
@@ -811,7 +807,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<DesignItemDetail> filterDetail = designItemDetails.stream()
|
||||
.filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType()))
|
||||
.collect(Collectors.toList());
|
||||
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
|
||||
// todo 填充图层需要筛选已经被删除的图层
|
||||
response.setClothes(CopyUtil.copyList(filterDetail,DesignItemClothesDetailVO.class,(o,d)->{
|
||||
d.setId(o.getBusinessId());
|
||||
d.setLevel1Type(converTypeToLevel1(o.getType()));
|
||||
String printJson = o.getPrintJson();
|
||||
@@ -832,7 +829,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
d.setPrintObject(new DesignPythonItemPrint());
|
||||
}));
|
||||
return editDesignItemLayer(flag,designPythonOutfit,
|
||||
minIoUtil.splitThenGetPreviewUrl(designItem.getDesignUrl(),480),
|
||||
minIoUtil.splitThenGetPreviewUrl(designPythonOutfit.getDesignUrl(),480),
|
||||
editResponseColor(designItemDetails,response));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,11 +52,7 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
||||
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
|
||||
designPythonOutfitVO.setPosition(StringUtil.isNullOrEmpty(detail.getPosition()) ? null : (List<Long>) JSON.parse(detail.getPosition()));
|
||||
designPythonOutfitVO.setImageSize(StringUtil.isNullOrEmpty(detail.getImageSize()) ? null : (List<Long>) JSON.parse(detail.getImageSize()));
|
||||
if (detail.getImageCategory().equals("body")){
|
||||
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getImageUrl(),480));
|
||||
}else {
|
||||
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getImageUrl(),480));
|
||||
}
|
||||
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getImageUrl(),480));
|
||||
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getMaskUrl(),480));
|
||||
return designPythonOutfitVO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user