Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -23,6 +23,9 @@ public class QueryLibraryPageVO {
|
|||||||
@ApiModelProperty("二级类型")
|
@ApiModelProperty("二级类型")
|
||||||
private String level2Type;
|
private String level2Type;
|
||||||
|
|
||||||
|
@ApiModelProperty("三级类型")
|
||||||
|
private String level3Type;
|
||||||
|
|
||||||
@ApiModelProperty("design类型 用户design生成时候区别library和collection")
|
@ApiModelProperty("design类型 用户design生成时候区别library和collection")
|
||||||
private String designType;
|
private String designType;
|
||||||
|
|
||||||
|
|||||||
@@ -217,71 +217,75 @@ public class PythonService {
|
|||||||
public DesignPythonObjects covertDesignParam(BigDecimal systemScale, String singleOverall,
|
public DesignPythonObjects covertDesignParam(BigDecimal systemScale, String singleOverall,
|
||||||
String switchCategory, ValidateElementVO elementVO, String processId) {
|
String switchCategory, ValidateElementVO elementVO, String processId) {
|
||||||
DesignPythonObjects designPythonObjects = new DesignPythonObjects();
|
DesignPythonObjects designPythonObjects = new DesignPythonObjects();
|
||||||
List<DesignPythonObject> objects = Lists.newArrayList();
|
List<DesignPythonObject> objects = new ArrayList<>();
|
||||||
designPythonObjects.setObjects(objects);
|
designPythonObjects.setObjects(objects);
|
||||||
designPythonObjects.setProcess_id(processId);
|
designPythonObjects.setProcess_id(processId);
|
||||||
|
|
||||||
long pinPrintNum = calculateDesignPinPrintNum(elementVO.getPrintBoardElements());
|
long pinPrintNum = calculateDesignPinPrintNum(elementVO.getPrintBoardElements());
|
||||||
long noPinPrintNum = calculateDesignNoPinPrintNum(elementVO.getPrintBoardElements());
|
long noPinPrintNum = calculateDesignNoPinPrintNum(elementVO.getPrintBoardElements());
|
||||||
//没有print的
|
|
||||||
long noPrintNum = 8 - pinPrintNum - noPinPrintNum;
|
long noPrintNum = 8 - pinPrintNum - noPinPrintNum;
|
||||||
elementVO.setNoPinPrintNum(noPinPrintNum);
|
elementVO.setNoPinPrintNum(noPinPrintNum);
|
||||||
|
|
||||||
//系统比列
|
|
||||||
// BigDecimal sysRatio = systemScale;
|
|
||||||
int pinSketchNum = 0;
|
int pinSketchNum = 0;
|
||||||
int sysSketchNum = 0;
|
int sysSketchNum = 0;
|
||||||
int noPinSketchNum = 0;
|
int noPinSketchNum = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
//sketch计算
|
|
||||||
CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, pinSketchNum, sysSketchNum, noPinSketchNum, systemScale);
|
CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, pinSketchNum, sysSketchNum, noPinSketchNum, systemScale);
|
||||||
if (Objects.isNull(designPictureType)) {
|
if (designPictureType == null) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
//print计算
|
|
||||||
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
||||||
if (Objects.isNull(designPrintPictureType)) {
|
if (designPrintPictureType == null) break;
|
||||||
break;
|
|
||||||
}
|
updateSketchNumbers(designPictureType, pinSketchNum, sysSketchNum, noPinSketchNum);
|
||||||
switch (designPictureType) {
|
updatePrintNumbers(designPrintPictureType, pinPrintNum, noPinPrintNum, noPrintNum);
|
||||||
case PIN:
|
|
||||||
pinSketchNum ++;
|
|
||||||
break;
|
|
||||||
case NO_PIN:
|
|
||||||
noPinSketchNum --;
|
|
||||||
break;
|
|
||||||
case SYS_FILE:
|
|
||||||
sysSketchNum --;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
switch (designPrintPictureType) {
|
|
||||||
case PIN:
|
|
||||||
pinPrintNum--;
|
|
||||||
break;
|
|
||||||
case NO_PIN:
|
|
||||||
noPinPrintNum--;
|
|
||||||
break;
|
|
||||||
case NO:
|
|
||||||
noPrintNum--;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
//确定本次designSingle是否print
|
|
||||||
DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType);
|
DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType);
|
||||||
elementVO.setDesignPythonItemPrint(designPythonItemPrint);
|
elementVO.setDesignPythonItemPrint(designPythonItemPrint);
|
||||||
//参数透传 确定本次designSingle如果需要print对应的种类
|
|
||||||
elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPintPictureTypeLayout(elementVO.getModelSex()));
|
elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPintPictureTypeLayout(elementVO.getModelSex()));
|
||||||
//designSingle具体参数组装
|
|
||||||
DesignPythonObject pythonObject = new DesignPythonObject();
|
DesignPythonObject pythonObject = createDesignPythonObject(elementVO, designPictureType, systemScale, singleOverall, switchCategory);
|
||||||
pythonObject.setItems(coverToDesignPythonItemNew(elementVO, designPictureType, systemScale));
|
|
||||||
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0),
|
|
||||||
singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
|
|
||||||
objects.add(pythonObject);
|
objects.add(pythonObject);
|
||||||
}
|
}
|
||||||
return designPythonObjects;
|
return designPythonObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSketchNumbers(CurrentDesignPictureTypeEnum designPictureType, int pinSketchNum, int sysSketchNum, int noPinSketchNum) {
|
||||||
|
switch (designPictureType) {
|
||||||
|
case PIN:
|
||||||
|
pinSketchNum++;
|
||||||
|
break;
|
||||||
|
case NO_PIN:
|
||||||
|
noPinSketchNum--;
|
||||||
|
break;
|
||||||
|
case SYS_FILE:
|
||||||
|
sysSketchNum--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePrintNumbers(CurrentDesignPrintPictureTypeEnum designPrintPictureType, long pinPrintNum, long noPinPrintNum, long noPrintNum) {
|
||||||
|
switch (designPrintPictureType) {
|
||||||
|
case PIN:
|
||||||
|
pinPrintNum--;
|
||||||
|
break;
|
||||||
|
case NO_PIN:
|
||||||
|
noPinPrintNum--;
|
||||||
|
break;
|
||||||
|
case NO:
|
||||||
|
noPrintNum--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DesignPythonObject createDesignPythonObject(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale, String singleOverall, String switchCategory) {
|
||||||
|
DesignPythonObject pythonObject = new DesignPythonObject();
|
||||||
|
pythonObject.setItems(coverToDesignPythonItemNew(elementVO, designPictureType, systemScale));
|
||||||
|
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
|
||||||
|
return pythonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureTypeNew(ValidateElementVO elementVO, int pinSketchNum, int sysSketchNum, int noPinSketchNum, BigDecimal systemScale) {
|
private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureTypeNew(ValidateElementVO elementVO, int pinSketchNum, int sysSketchNum, int noPinSketchNum, BigDecimal systemScale) {
|
||||||
List<CollectionElement> pinData = getPinData(elementVO);
|
List<CollectionElement> pinData = getPinData(elementVO);
|
||||||
if (CollectionUtil.isNotEmpty(pinData)) {
|
if (CollectionUtil.isNotEmpty(pinData)) {
|
||||||
@@ -311,21 +315,21 @@ public class PythonService {
|
|||||||
return result.setScale(0, RoundingMode.HALF_UP).intValue();
|
return result.setScale(0, RoundingMode.HALF_UP).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculatePinSketchNum(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List) {
|
// private int calculatePinSketchNum(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List) {
|
||||||
List<CollectionElement> pinData = getPinData(sketchBoardElements, hasUseMd5List);
|
// List<CollectionElement> pinData = getPinData(sketchBoardElements, hasUseMd5List);
|
||||||
if (CollectionUtil.isEmpty(pinData)) {
|
// if (CollectionUtil.isEmpty(pinData)) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
// long topNum = sketchBoardElements.stream()
|
//// long topNum = sketchBoardElements.stream()
|
||||||
// .filter(skecth -> skecth.getHasPin() == 1
|
//// .filter(skecth -> skecth.getHasPin() == 1
|
||||||
// && DesignPythonItem.OUTWEAR_DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
|
//// && DesignPythonItem.OUTWEAR_DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
|
||||||
// long bottomNum = sketchBoardElements.stream()
|
//// long bottomNum = sketchBoardElements.stream()
|
||||||
// .filter(skecth -> skecth.getHasPin() == 1
|
//// .filter(skecth -> skecth.getHasPin() == 1
|
||||||
// && DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
|
//// && DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
|
||||||
// int num = Arrays.asList(topNum, bottomNum).stream().max(Comparator.comparing(Long::valueOf)).get().intValue();
|
//// int num = Arrays.asList(topNum, bottomNum).stream().max(Comparator.comparing(Long::valueOf)).get().intValue();
|
||||||
int num = pinData.size();
|
// int num = pinData.size();
|
||||||
return Math.min(num, 8);
|
// return Math.min(num, 8);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//计算当前的图片类型
|
//计算当前的图片类型
|
||||||
private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureType(int pinSketchNum, int sysSketchNum, int noPinSketchNum) {
|
private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureType(int pinSketchNum, int sysSketchNum, int noPinSketchNum) {
|
||||||
@@ -377,23 +381,23 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//计算Pin图片张数
|
//计算Pin图片张数
|
||||||
private int calculatePinPictureNum(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List) {
|
// private int calculatePinPictureNum(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List) {
|
||||||
List<CollectionElement> pinData = getPinData(sketchBoardElements, hasUseMd5List);
|
// List<CollectionElement> pinData = getPinData(sketchBoardElements, hasUseMd5List);
|
||||||
if (CollectionUtil.isEmpty(pinData)) {
|
// if (CollectionUtil.isEmpty(pinData)) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
long topNum = sketchBoardElements.stream()
|
// long topNum = sketchBoardElements.stream()
|
||||||
.filter(skecth -> skecth.getHasPin() == 1
|
// .filter(skecth -> skecth.getHasPin() == 1
|
||||||
&& DesignPythonItem.OUTWEAR_DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
|
// && DesignPythonItem.OUTWEAR_DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
|
||||||
long bottomNum = sketchBoardElements.stream()
|
// long bottomNum = sketchBoardElements.stream()
|
||||||
.filter(skecth -> skecth.getHasPin() == 1
|
// .filter(skecth -> skecth.getHasPin() == 1
|
||||||
&& DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
|
// && DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
|
||||||
int num = Arrays.asList(topNum, bottomNum).stream().max(Comparator.comparing(Long::valueOf)).get().intValue();
|
// int num = Arrays.asList(topNum, bottomNum).stream().max(Comparator.comparing(Long::valueOf)).get().intValue();
|
||||||
if (num > 8) {
|
// if (num > 8) {
|
||||||
return 8;
|
// return 8;
|
||||||
}
|
// }
|
||||||
return num;
|
// return num;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//计算当前的Print图片类型
|
//计算当前的Print图片类型
|
||||||
private CurrentDesignPrintPictureTypeEnum calculateCurrentDesignPintPictureType(long pinPrintNum, long noPinPrintNum, long noPrintNum) {
|
private CurrentDesignPrintPictureTypeEnum calculateCurrentDesignPintPictureType(long pinPrintNum, long noPinPrintNum, long noPrintNum) {
|
||||||
@@ -478,53 +482,51 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DesignPythonItem> coverToDesignPythonItem(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType) {
|
// private List<DesignPythonItem> coverToDesignPythonItem(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType) {
|
||||||
//Pin的数据
|
// //Pin的数据
|
||||||
List<CollectionElement> pinData = getPinData(elementVO.getSketchBoardElements(), elementVO.getHasUseMd5List());
|
// List<CollectionElement> pinData = getPinData(elementVO.getSketchBoardElements(), elementVO.getHasUseMd5List());
|
||||||
//计算填充PythonItemBlouse
|
// //计算填充PythonItemBlouse
|
||||||
List<DesignPythonItem> items = Lists.newArrayList();
|
// List<DesignPythonItem> items = Lists.newArrayList();
|
||||||
if (elementVO.getModelSex().equals("Female")) {
|
// if (elementVO.getModelSex().equals("Female")) {
|
||||||
List<DesignPythonItem> blouseList = calculatePythonItemBlouse(pinData, elementVO, designPictureType);
|
// List<DesignPythonItem> blouseList = calculatePythonItemBlouse(pinData, elementVO, designPictureType);
|
||||||
if (!CollectionUtils.isEmpty(blouseList)) {
|
// if (!CollectionUtils.isEmpty(blouseList)) {
|
||||||
items.addAll(blouseList);
|
// items.addAll(blouseList);
|
||||||
}
|
// }
|
||||||
//计算填充PythonItemSkirt
|
// //计算填充PythonItemSkirt
|
||||||
DesignPythonItem skirt = calculatePythonItemSkirt(pinData, elementVO, designPictureType);
|
// DesignPythonItem skirt = calculatePythonItemSkirt(pinData, elementVO, designPictureType);
|
||||||
if (Objects.nonNull(skirt)) {
|
// if (Objects.nonNull(skirt)) {
|
||||||
items.add(skirt);
|
// items.add(skirt);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// 男装逻辑
|
// // 男装逻辑
|
||||||
DesignPythonItem top = calculatePythonItemTop(pinData, elementVO, designPictureType);
|
// DesignPythonItem top = calculatePythonItemTop(pinData, elementVO, designPictureType);
|
||||||
if (Objects.nonNull(top)) {
|
// if (Objects.nonNull(top)) {
|
||||||
items.add(top);
|
// items.add(top);
|
||||||
}
|
// }
|
||||||
DesignPythonItem bottom = calculatePythonItemBottom(pinData, elementVO, designPictureType);
|
// DesignPythonItem bottom = calculatePythonItemBottom(pinData, elementVO, designPictureType);
|
||||||
if (Objects.nonNull(bottom)) {
|
// if (Objects.nonNull(bottom)) {
|
||||||
items.add(bottom);
|
// items.add(bottom);
|
||||||
}
|
// }
|
||||||
if (SingleOverallEnum.SINGLE.getRealName().equals(elementVO.getSingleOverall()) && elementVO.getSwitchCategory().equals("Outwear")) {
|
// if (SingleOverallEnum.SINGLE.getRealName().equals(elementVO.getSingleOverall()) && elementVO.getSwitchCategory().equals("Outwear")) {
|
||||||
DesignPythonItem outwear = calculatePythonItemOutwear(pinData, elementVO, designPictureType);
|
// DesignPythonItem outwear = calculatePythonItemOutwear(pinData, elementVO, designPictureType);
|
||||||
if (Objects.nonNull(outwear)) {
|
// if (Objects.nonNull(outwear)) {
|
||||||
items.add(outwear);
|
// items.add(outwear);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//计算填充Hairstyle Earring Shoes Body
|
// //计算填充Hairstyle Earring Shoes Body
|
||||||
items.addAll(calculatePythonItemHairstyleShoes(elementVO, elementVO.getDesignLibraryModelPoint()));
|
// items.addAll(calculatePythonItemHairstyleShoes(elementVO, elementVO.getDesignLibraryModelPoint()));
|
||||||
return items;
|
// return items;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private List<DesignPythonItem> coverToDesignPythonItemNew(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale) {
|
private List<DesignPythonItem> coverToDesignPythonItemNew(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale) {
|
||||||
List<DesignPythonItem> itemList = new ArrayList<>();
|
List<DesignPythonItem> itemList = new ArrayList<>();
|
||||||
// 根据当前designPictureType确定单一部位的sketch
|
|
||||||
DesignPythonItem designPythonItem = calculatePythonItem(elementVO, designPictureType);
|
DesignPythonItem designPythonItem = calculatePythonItem(elementVO, designPictureType);
|
||||||
if (Objects.nonNull(designPythonItem)) {
|
if (Objects.nonNull(designPythonItem)) {
|
||||||
itemList.add(designPythonItem);
|
itemList.add(designPythonItem);
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.OVERALL.getRealName())) {
|
if (elementVO.getSingleOverall().equals(SingleOverallEnum.OVERALL.getRealName())) {
|
||||||
// 根据确定的单一部位sketch,确定一整套穿搭
|
|
||||||
List<String> otherSketchCategoryList = getOtherSketchCategoryList(elementVO.getModelSex(), designPythonItem);
|
List<String> otherSketchCategoryList = getOtherSketchCategoryList(elementVO.getModelSex(), designPythonItem);
|
||||||
if (!CollectionUtils.isEmpty(otherSketchCategoryList)) {
|
if (!otherSketchCategoryList.isEmpty()) {
|
||||||
JSONObject attributeRecognition = getAttributeRecognition(designPythonItem, designPythonItem.getType(), elementVO.getModelSex());
|
JSONObject attributeRecognition = getAttributeRecognition(designPythonItem, designPythonItem.getType(), elementVO.getModelSex());
|
||||||
for (String styleCategory : otherSketchCategoryList) {
|
for (String styleCategory : otherSketchCategoryList) {
|
||||||
DesignPythonItem otherSketch = processAttributeRecognition(attributeRecognition, elementVO, designPictureType, styleCategory, systemScale);
|
DesignPythonItem otherSketch = processAttributeRecognition(attributeRecognition, elementVO, designPictureType, styleCategory, systemScale);
|
||||||
@@ -539,71 +541,62 @@ public class PythonService {
|
|||||||
|
|
||||||
private DesignPythonItem processAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, String styleCategory, BigDecimal systemScale) {
|
private DesignPythonItem processAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, String styleCategory, BigDecimal systemScale) {
|
||||||
switch (designPictureType) {
|
switch (designPictureType) {
|
||||||
case PIN: {
|
case PIN:
|
||||||
// 优先去pin里面找符合类别的
|
return processPinAttributeRecognition(attributeRecognition, elementVO, styleCategory, systemScale);
|
||||||
List<CollectionElement> collectPin = elementVO.getSketchBoardElements().stream().filter(o -> o.getHasPin() == 1 && o.getLevel2Type().equals(styleCategory)).collect(Collectors.toList());
|
|
||||||
if (CollectionUtil.isNotEmpty(collectPin)) {
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(collectPin.size());
|
|
||||||
elementVO.getHasUseMd5List().add(collectPin.get(randomNum).getMd5());
|
|
||||||
return coverSketchToDesignPythonItem(collectPin.get(randomNum).getId(), collectPin.get(randomNum), elementVO);
|
|
||||||
}else {
|
|
||||||
// 找不到就根据特征找一个系统池子,与noPinSketch组成一个池子,如果没有noPinSketch就只由系统池子作为池子。
|
|
||||||
List<CollectionElement> collectNoPin = elementVO.getSketchBoardElements().stream().filter(o -> o.getHasPin() == 0 && o.getLevel2Type().equals(styleCategory)).collect(Collectors.toList());
|
|
||||||
int poolNum = 20;
|
|
||||||
if (CollectionUtil.isNotEmpty(collectNoPin)) {
|
|
||||||
int collectionNoPinSize = collectNoPin.size();
|
|
||||||
if (systemScale.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(collectNoPin.size());
|
|
||||||
return coverSketchToDesignPythonItem(null, collectNoPin.get(randomNum), elementVO);
|
|
||||||
}else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
|
|
||||||
BigDecimal collectNoPinSize = BigDecimal.valueOf(collectNoPin.size());
|
|
||||||
poolNum = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN).intValue();
|
|
||||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
|
|
||||||
collectNoPin.addAll(list);
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(collectNoPin.size());
|
|
||||||
if (randomNum < collectionNoPinSize) {
|
|
||||||
return coverSketchToDesignPythonItem(collectNoPin.get(randomNum).getId(), collectNoPin.get(randomNum), elementVO);
|
|
||||||
}else {
|
|
||||||
return coverSketchToDesignPythonItem(null, collectNoPin.get(randomNum), elementVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(list.size());
|
|
||||||
return coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case NO_PIN:
|
case NO_PIN:
|
||||||
case SYS_FILE: {
|
case SYS_FILE:
|
||||||
List<CollectionElement> collectNoPin = elementVO.getSketchBoardElements().stream().filter(o -> o.getHasPin() == 0 && o.getLevel2Type().equals(styleCategory)).collect(Collectors.toList());
|
return processNoPinOrSysFileAttributeRecognition(attributeRecognition, elementVO, styleCategory, systemScale);
|
||||||
int poolNum = 20;
|
|
||||||
if (CollectionUtil.isNotEmpty(collectNoPin)) {
|
|
||||||
int collectionNoPinSize = collectNoPin.size();
|
|
||||||
if (systemScale.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(collectNoPin.size());
|
|
||||||
return coverSketchToDesignPythonItem(null, collectNoPin.get(randomNum), elementVO);
|
|
||||||
}else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
|
|
||||||
BigDecimal collectNoPinSize = BigDecimal.valueOf(collectNoPin.size());
|
|
||||||
poolNum = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN).intValue();
|
|
||||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
|
|
||||||
collectNoPin.addAll(list);
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(collectNoPin.size());
|
|
||||||
if (randomNum < collectionNoPinSize) {
|
|
||||||
return coverSketchToDesignPythonItem(collectNoPin.get(randomNum).getId(), collectNoPin.get(randomNum), elementVO);
|
|
||||||
}else {
|
|
||||||
return coverSketchToDesignPythonItem(null, collectNoPin.get(randomNum), elementVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
|
|
||||||
int randomNum = RandomsUtil.randomSysFile(list.size());
|
|
||||||
return coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
throw new BusinessException("unknown designPictureType");
|
throw new BusinessException("unknown designPictureType");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DesignPythonItem processPinAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||||
|
List<CollectionElement> collectPin = getFilteredCollectionElements(elementVO.getSketchBoardElements(), 1, styleCategory);
|
||||||
|
if (CollectionUtil.isNotEmpty(collectPin)) {
|
||||||
|
int randomNum = RandomsUtil.randomSysFile(collectPin.size());
|
||||||
|
elementVO.getHasUseMd5List().add(collectPin.get(randomNum).getMd5());
|
||||||
|
return coverSketchToDesignPythonItem(collectPin.get(randomNum).getId(), collectPin.get(randomNum), elementVO);
|
||||||
|
} else {
|
||||||
|
List<CollectionElement> collectNoPin = getFilteredCollectionElements(elementVO.getSketchBoardElements(), 0, styleCategory);
|
||||||
|
return processNoPinOrSysFileAttributeRecognitionWithPool(collectNoPin, attributeRecognition, elementVO, styleCategory, systemScale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DesignPythonItem processNoPinOrSysFileAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||||
|
List<CollectionElement> collectNoPin = getFilteredCollectionElements(elementVO.getSketchBoardElements(), 0, styleCategory);
|
||||||
|
return processNoPinOrSysFileAttributeRecognitionWithPool(collectNoPin, attributeRecognition, elementVO, styleCategory, systemScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DesignPythonItem processNoPinOrSysFileAttributeRecognitionWithPool(List<CollectionElement> collectionElements, JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||||
|
int poolNum = 20;
|
||||||
|
if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||||
|
int collectionNoPinSize = collectionElements.size();
|
||||||
|
if (systemScale.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
int randomNum = RandomsUtil.randomSysFile(collectionNoPinSize);
|
||||||
|
return coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||||
|
} else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
|
||||||
|
BigDecimal collectNoPinSize = BigDecimal.valueOf(collectionNoPinSize);
|
||||||
|
poolNum = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN).intValue();
|
||||||
|
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
|
||||||
|
collectionElements.addAll(list);
|
||||||
|
int randomNum = RandomsUtil.randomSysFile(collectionElements.size());
|
||||||
|
if (randomNum < collectionNoPinSize) {
|
||||||
|
return coverSketchToDesignPythonItem(collectionElements.get(randomNum).getId(), collectionElements.get(randomNum), elementVO);
|
||||||
|
} else {
|
||||||
|
return coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
|
||||||
|
int randomNum = RandomsUtil.randomSysFile(list.size());
|
||||||
|
return coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CollectionElement> getFilteredCollectionElements(List<CollectionElement> elements, int hasPin, String styleCategory) {
|
||||||
|
return CollectionUtil.isNotEmpty(elements) ? elements.stream().filter(o -> o.getHasPin() == hasPin && o.getLevel2Type().equals(styleCategory)).collect(Collectors.toList()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
private DesignPythonItem processAttributeRecognitionBySameCategory(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory) {
|
private DesignPythonItem processAttributeRecognitionBySameCategory(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory) {
|
||||||
List<CollectionElement> list = getSystemSketchPoolBySameCategory(attributeRecognition, styleCategory, elementVO.getModelSex());
|
List<CollectionElement> list = getSystemSketchPoolBySameCategory(attributeRecognition, styleCategory, elementVO.getModelSex());
|
||||||
int randomNum = RandomsUtil.randomSysFile(list.size());
|
int randomNum = RandomsUtil.randomSysFile(list.size());
|
||||||
@@ -745,16 +738,13 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getAttributeRecognition(DesignPythonItem designPythonItem, String styleCategory, String modelSex) {
|
public JSONObject getAttributeRecognition(DesignPythonItem designPythonItem, String styleCategory, String modelSex) {
|
||||||
// todo 限流校验
|
|
||||||
// AccessLimitUtils.validate("design",5);
|
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
.writeTimeout(60, TimeUnit.SECONDS)
|
||||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
|
||||||
.build();
|
.build();
|
||||||
MediaType mediaType = MediaType.parse("application/json");
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
|
||||||
JSONObject paramJSONObject = new JSONObject();
|
JSONObject paramJSONObject = new JSONObject();
|
||||||
paramJSONObject.put("category", styleCategory);
|
paramJSONObject.put("category", styleCategory);
|
||||||
paramJSONObject.put("colony", modelSex);
|
paramJSONObject.put("colony", modelSex);
|
||||||
@@ -762,42 +752,29 @@ public class PythonService {
|
|||||||
JSONArray paramArray = new JSONArray();
|
JSONArray paramArray = new JSONArray();
|
||||||
paramArray.add(paramJSONObject);
|
paramArray.add(paramJSONObject);
|
||||||
String param = JSON.toJSONString(paramArray, SerializerFeature.DisableCircularReferenceDetect);
|
String param = JSON.toJSONString(paramArray, SerializerFeature.DisableCircularReferenceDetect);
|
||||||
log.info("design请求python 参数:####{}", param);
|
|
||||||
|
log.info("PythonService##design 请求参数:####{}", param);
|
||||||
RequestBody body = RequestBody.create(mediaType, param);
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(accessPythonIp + ":" + accessPythonPort + "/api/attribute_recognition")
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/attribute_recognition")
|
||||||
.method("POST", body)
|
.method("POST", body)
|
||||||
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.build();
|
.build();
|
||||||
Response response;
|
|
||||||
String responseBody;
|
try (Response response = client.newCall(request).execute()) {
|
||||||
try {
|
if (response.isSuccessful()) {
|
||||||
response = client.newCall(request).execute();
|
String responseBody = Objects.requireNonNull(response.body()).string();
|
||||||
} catch (IOException ioException) {
|
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||||
AccessLimitUtils.validateOut("design");
|
log.info("PythonService##responseObject###{}", responseObject);
|
||||||
log.error("PythonService##design异常###{}", ExceptionUtil.getThrowableList(ioException));
|
return responseObject;
|
||||||
throw new BusinessException("design.interface.exception");
|
} else {
|
||||||
}
|
log.error("PythonService##design 请求异常:{}", response);
|
||||||
//去除限流
|
throw new BusinessException("attributeRecognition.interface.exception");
|
||||||
// AccessLimitUtils.validateOut("design");
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
try {
|
|
||||||
if (Objects.nonNull(response.body())) {
|
|
||||||
responseBody = response.body().string();
|
|
||||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
|
||||||
log.info("PythonService##responseObject###{}", responseObject);
|
|
||||||
return responseObject;
|
|
||||||
}
|
|
||||||
throw new BusinessException("design.interface.exception");
|
|
||||||
} catch (IOException | JSONException e) {
|
|
||||||
log.error("PythonService##design异常###{}", e.getMessage());
|
|
||||||
throw new BusinessException("design.interface.exception");
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("PythonService##design 请求异常:{}", e.getMessage());
|
||||||
|
throw new BusinessException("attributeRecognition.interface.exception");
|
||||||
}
|
}
|
||||||
log.error("PythonService##design异常response###{}", response);
|
|
||||||
//生成失败
|
|
||||||
throw new BusinessException("design.interface.exception");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getAttributeRecognitionBySameCategory(CollectionElement element, String modelSex) {
|
public JSONObject getAttributeRecognitionBySameCategory(CollectionElement element, String modelSex) {
|
||||||
@@ -871,92 +848,100 @@ public class PythonService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DesignPythonItem calculatePythonItem(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType) {
|
private DesignPythonItem calculatePythonItem(ValidateElementVO validateElementVO, CurrentDesignPictureTypeEnum currentDesignPictureType) {
|
||||||
switch (designPictureType) {
|
switch (currentDesignPictureType) {
|
||||||
case PIN: {
|
case PIN:
|
||||||
List<CollectionElement> pinData = getPinData(elementVO);
|
return calculatePinPythonItem(validateElementVO);
|
||||||
if (CollectionUtil.isEmpty(pinData)) {
|
case NO_PIN:
|
||||||
throw new BusinessException("pinData is null");
|
return calculateNoPinPythonItem(validateElementVO);
|
||||||
}
|
case SYS_FILE:
|
||||||
Random random = new Random();
|
return calculateSysFilePythonItem(validateElementVO);
|
||||||
int randomNumber = random.nextInt(pinData.size());
|
|
||||||
elementVO.getHasUseMd5List().add(pinData.get(randomNumber).getMd5());
|
|
||||||
return coverSketchToDesignPythonItem(pinData.get(randomNumber).getId(), pinData.get(randomNumber), elementVO);
|
|
||||||
}
|
|
||||||
case NO_PIN: {
|
|
||||||
List<CollectionElement> noPinData = getNoPinData(elementVO);
|
|
||||||
if (CollectionUtil.isEmpty(noPinData)) {
|
|
||||||
// 根据pin的获取 type
|
|
||||||
List<CollectionElement> sketchBoardPins = elementVO.getSketchBoardElements()
|
|
||||||
.stream().filter(v -> v.getHasPin() == 1).collect(Collectors.toList());
|
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
|
||||||
sketchBoardPins = sketchBoardPins.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (CollectionUtil.isNotEmpty(sketchBoardPins)) {
|
|
||||||
Integer randomNum = RandomsUtil.randomSysFile(sketchBoardPins.size());
|
|
||||||
CollectionElement element = sketchBoardPins.get(randomNum);
|
|
||||||
JSONObject attributeRecognition = getAttributeRecognitionBySameCategory(element, elementVO.getModelSex());
|
|
||||||
return processAttributeRecognitionBySameCategory(attributeRecognition, elementVO, element.getLevel2Type());
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryWrapper<Dressing> qw = new QueryWrapper<>();
|
|
||||||
qw.lambda().eq(Dressing::getApparel, elementVO.getModelSex());
|
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
|
||||||
qw.lambda().eq(Dressing::getStyleCategory, elementVO.getSwitchCategory());
|
|
||||||
}
|
|
||||||
List<Dressing> dressings = dressingMapper.selectList(qw);
|
|
||||||
if (CollectionUtil.isEmpty(dressings)) {
|
|
||||||
throw new BusinessException("dressings is null");
|
|
||||||
}
|
|
||||||
Integer randomNum = RandomsUtil.randomSysFile(dressings.size());
|
|
||||||
String category = dressings.get(randomNum).getStyleCategory();
|
|
||||||
String tableName;
|
|
||||||
tableName = getTableName(elementVO.getModelSex(), category);
|
|
||||||
|
|
||||||
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName);
|
|
||||||
CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, elementVO.getModelSex());
|
|
||||||
return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
|
||||||
}
|
|
||||||
Random random = new Random();
|
|
||||||
int randomNumber = random.nextInt(noPinData.size());
|
|
||||||
return coverSketchToDesignPythonItem(noPinData.get(randomNumber).getId(), noPinData.get(randomNumber), elementVO);
|
|
||||||
}
|
|
||||||
case SYS_FILE: {
|
|
||||||
// 根据pin noPin的获取 type
|
|
||||||
List<CollectionElement> sketchBoardPins = elementVO.getSketchBoardElements();
|
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
|
||||||
sketchBoardPins = sketchBoardPins.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (CollectionUtil.isNotEmpty(sketchBoardPins)) {
|
|
||||||
Integer randomNum = RandomsUtil.randomSysFile(sketchBoardPins.size());
|
|
||||||
CollectionElement element = sketchBoardPins.get(randomNum);
|
|
||||||
JSONObject attributeRecognition = getAttributeRecognitionBySameCategory(element, elementVO.getModelSex());
|
|
||||||
return processAttributeRecognitionBySameCategory(attributeRecognition, elementVO, element.getLevel2Type());
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryWrapper<Dressing> qw = new QueryWrapper<>();
|
|
||||||
qw.lambda().eq(Dressing::getApparel, elementVO.getModelSex());
|
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
|
||||||
qw.lambda().eq(Dressing::getStyleCategory, elementVO.getSwitchCategory());
|
|
||||||
}
|
|
||||||
List<Dressing> dressings = dressingMapper.selectList(qw);
|
|
||||||
if (CollectionUtil.isEmpty(dressings)) {
|
|
||||||
throw new BusinessException("dressings is null");
|
|
||||||
}
|
|
||||||
Integer randomNum = RandomsUtil.randomSysFile(dressings.size());
|
|
||||||
String category = dressings.get(randomNum).getStyleCategory();
|
|
||||||
String tableName;
|
|
||||||
tableName = getTableName(elementVO.getModelSex(), category);
|
|
||||||
|
|
||||||
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName);
|
|
||||||
CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, elementVO.getModelSex());
|
|
||||||
return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DesignPythonItem calculatePinPythonItem(ValidateElementVO validateElementVO) {
|
||||||
|
List<CollectionElement> pinCollectionData = getPinData(validateElementVO);
|
||||||
|
if (CollectionUtil.isEmpty(pinCollectionData)) {
|
||||||
|
throw new BusinessException("pinData is null");
|
||||||
|
}
|
||||||
|
Random random = new Random();
|
||||||
|
int randomNumber = random.nextInt(pinCollectionData.size());
|
||||||
|
validateElementVO.getHasUseMd5List().add(pinCollectionData.get(randomNumber).getMd5());
|
||||||
|
return coverSketchToDesignPythonItem(pinCollectionData.get(randomNumber).getId(), pinCollectionData.get(randomNumber), validateElementVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DesignPythonItem calculateNoPinPythonItem(ValidateElementVO validateElementVO) {
|
||||||
|
List<CollectionElement> noPinCollectionData = getNoPinData(validateElementVO);
|
||||||
|
if (CollectionUtil.isEmpty(noPinCollectionData)) {
|
||||||
|
List<CollectionElement> sketchBoardPins = getPinDataWhole(validateElementVO);
|
||||||
|
if (validateElementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> o.getLevel2Type().equals(validateElementVO.getSwitchCategory())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(sketchBoardPins)) {
|
||||||
|
Integer randomNum = RandomsUtil.randomSysFile(sketchBoardPins.size());
|
||||||
|
CollectionElement element = sketchBoardPins.get(randomNum);
|
||||||
|
JSONObject attributeRecognition = getAttributeRecognitionBySameCategory(element, validateElementVO.getModelSex());
|
||||||
|
return processAttributeRecognitionBySameCategory(attributeRecognition, validateElementVO, element.getLevel2Type());
|
||||||
|
}
|
||||||
|
QueryWrapper<Dressing> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(Dressing::getApparel, validateElementVO.getModelSex());
|
||||||
|
if (validateElementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
|
qw.lambda().eq(Dressing::getApparel, validateElementVO.getSwitchCategory());
|
||||||
|
}
|
||||||
|
List<Dressing> dressings = dressingMapper.selectList(qw);
|
||||||
|
if (CollectionUtil.isEmpty(dressings)) {
|
||||||
|
throw new BusinessException("dressings is null");
|
||||||
|
}
|
||||||
|
Integer randomNum = RandomsUtil.randomSysFile(dressings.size());
|
||||||
|
String category = dressings.get(randomNum).getStyleCategory();
|
||||||
|
String tableName = getTableName(validateElementVO.getModelSex(), category);
|
||||||
|
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName);
|
||||||
|
CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, validateElementVO.getModelSex());
|
||||||
|
return coverSketchToDesignPythonItem(null, collectionElement, validateElementVO);
|
||||||
|
}
|
||||||
|
Random random = new Random();
|
||||||
|
int randomNumber = random.nextInt(noPinCollectionData.size());
|
||||||
|
return coverSketchToDesignPythonItem(noPinCollectionData.get(randomNumber).getId(), noPinCollectionData.get(randomNumber), validateElementVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DesignPythonItem calculateSysFilePythonItem(ValidateElementVO validateElementVO) {
|
||||||
|
List<CollectionElement> sketchBoardCollectionElements = validateElementVO.getSketchBoardElements();
|
||||||
|
if (!CollectionUtils.isEmpty(sketchBoardCollectionElements)) {
|
||||||
|
if (validateElementVO.getModelSex().equals(Sex.MALE.getValue())) {
|
||||||
|
sketchBoardCollectionElements = sketchBoardCollectionElements.stream().filter(o -> MALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (validateElementVO.getModelSex().equals(Sex.FEMALE.getValue())) {
|
||||||
|
sketchBoardCollectionElements = sketchBoardCollectionElements.stream().filter(o -> FEMALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (validateElementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
|
sketchBoardCollectionElements = sketchBoardCollectionElements.stream().filter(o -> o.getLevel2Type().equals(validateElementVO.getSwitchCategory())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(sketchBoardCollectionElements)) {
|
||||||
|
Integer randomNum = RandomsUtil.randomSysFile(sketchBoardCollectionElements.size());
|
||||||
|
CollectionElement element = sketchBoardCollectionElements.get(randomNum);
|
||||||
|
JSONObject attributeRecognition = getAttributeRecognitionBySameCategory(element, validateElementVO.getModelSex());
|
||||||
|
return processAttributeRecognitionBySameCategory(attributeRecognition, validateElementVO, element.getLevel2Type());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QueryWrapper<Dressing> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(Dressing::getApparel, validateElementVO.getModelSex());
|
||||||
|
if (validateElementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
|
qw.lambda().eq(Dressing::getApparel, validateElementVO.getSwitchCategory());
|
||||||
|
}
|
||||||
|
List<Dressing> dressings = dressingMapper.selectList(qw);
|
||||||
|
if (CollectionUtil.isEmpty(dressings)) {
|
||||||
|
throw new BusinessException("dressings is null");
|
||||||
|
}
|
||||||
|
Integer randomNum = RandomsUtil.randomSysFile(dressings.size());
|
||||||
|
String category = dressings.get(randomNum).getStyleCategory();
|
||||||
|
String tableName = getTableName(validateElementVO.getModelSex(), category);
|
||||||
|
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName);
|
||||||
|
CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, validateElementVO.getModelSex());
|
||||||
|
return coverSketchToDesignPythonItem(null, collectionElement, validateElementVO);
|
||||||
|
}
|
||||||
|
|
||||||
private String getTableName(String modelSex, String category) {
|
private String getTableName(String modelSex, String category) {
|
||||||
switch (modelSex) {
|
switch (modelSex) {
|
||||||
case "Female": {
|
case "Female": {
|
||||||
@@ -2004,7 +1989,7 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<CollectionElement> getPinData(ValidateElementVO elementVO) {
|
private List<CollectionElement> getPinData(ValidateElementVO elementVO) {
|
||||||
List<CollectionElement> pinData = getPinData(elementVO.getSketchBoardElements(), elementVO.getHasUseMd5List());
|
List<CollectionElement> pinData = getPinData(elementVO.getSketchBoardElements(), elementVO.getHasUseMd5List(), elementVO.getModelSex());
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
if (!CollectionUtils.isEmpty(pinData)) {
|
if (!CollectionUtils.isEmpty(pinData)) {
|
||||||
return pinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
return pinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
||||||
@@ -2016,12 +2001,52 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CollectionElement> getPinData(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List) {
|
private List<CollectionElement> getPinDataWhole(ValidateElementVO elementVO) {
|
||||||
|
List<CollectionElement> pinData = getPinDataWhole(elementVO.getSketchBoardElements(), elementVO.getHasUseMd5List(), elementVO.getModelSex());
|
||||||
|
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
|
if (!CollectionUtils.isEmpty(pinData)) {
|
||||||
|
return pinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
||||||
|
}else {
|
||||||
|
return pinData;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return pinData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CollectionElement> getPinDataWhole(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List, String modelSex) {
|
||||||
|
if (CollectionUtils.isEmpty(sketchBoardElements)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<CollectionElement> sketchBoardPins = sketchBoardElements
|
||||||
|
.stream().filter(v -> v.getHasPin() == 1).collect(Collectors.toList());
|
||||||
|
if (modelSex.equals(Sex.MALE.getValue())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> MALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (modelSex.equals(Sex.FEMALE.getValue())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> FEMALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(sketchBoardPins)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return sketchBoardPins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static List<String> FEMALE_CATEGORY = Arrays.asList("Dress","Blouse","Skirt","Trousers","Outwear");
|
||||||
|
public final static List<String> MALE_CATEGORY = Arrays.asList("Tops","Bottoms","Outwear");
|
||||||
|
|
||||||
|
private List<CollectionElement> getPinData(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List, String modelSex) {
|
||||||
if (CollectionUtils.isEmpty(sketchBoardElements)) {
|
if (CollectionUtils.isEmpty(sketchBoardElements)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<CollectionElement> sketchBoardPins = sketchBoardElements
|
List<CollectionElement> sketchBoardPins = sketchBoardElements
|
||||||
.stream().filter(v -> v.getHasPin() == 1 && (!hasUseMd5List.contains(v.getMd5()))).collect(Collectors.toList());
|
.stream().filter(v -> v.getHasPin() == 1 && (!hasUseMd5List.contains(v.getMd5()))).collect(Collectors.toList());
|
||||||
|
if (modelSex.equals(Sex.MALE.getValue())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> MALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (modelSex.equals(Sex.FEMALE.getValue())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> FEMALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
if (CollectionUtils.isEmpty(sketchBoardPins)) {
|
if (CollectionUtils.isEmpty(sketchBoardPins)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2030,22 +2055,28 @@ public class PythonService {
|
|||||||
|
|
||||||
private List<CollectionElement> getNoPinData(ValidateElementVO elementVO) {
|
private List<CollectionElement> getNoPinData(ValidateElementVO elementVO) {
|
||||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
|
||||||
List<CollectionElement> noPinData = getNoPinData(elementVO.getSketchBoardElements());
|
List<CollectionElement> noPinData = getNoPinData(elementVO.getSketchBoardElements(), elementVO.getModelSex());
|
||||||
if (CollectionUtils.isEmpty(noPinData)) {
|
if (CollectionUtils.isEmpty(noPinData)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return noPinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
return noPinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
|
||||||
}else {
|
}else {
|
||||||
return getNoPinData(elementVO.getSketchBoardElements());
|
return getNoPinData(elementVO.getSketchBoardElements(), elementVO.getModelSex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CollectionElement> getNoPinData(List<CollectionElement> sketchBoardElements) {
|
private List<CollectionElement> getNoPinData(List<CollectionElement> sketchBoardElements, String modelSex) {
|
||||||
if (CollectionUtils.isEmpty(sketchBoardElements)) {
|
if (CollectionUtils.isEmpty(sketchBoardElements)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<CollectionElement> sketchBoardPins = sketchBoardElements
|
List<CollectionElement> sketchBoardPins = sketchBoardElements
|
||||||
.stream().filter(v -> v.getHasPin() == 0).collect(Collectors.toList());
|
.stream().filter(v -> v.getHasPin() == 0).collect(Collectors.toList());
|
||||||
|
if (modelSex.equals(Sex.MALE.getValue())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> MALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (modelSex.equals(Sex.FEMALE.getValue())) {
|
||||||
|
sketchBoardPins = sketchBoardPins.stream().filter(o -> FEMALE_CATEGORY.contains(o.getLevel2Type())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
if (CollectionUtils.isEmpty(sketchBoardPins)) {
|
if (CollectionUtils.isEmpty(sketchBoardPins)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,21 +304,36 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
//保存design
|
//保存design
|
||||||
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||||
//计算library
|
//计算library
|
||||||
calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
||||||
//组装design入参
|
//组装design入参
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||||
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId());
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
long totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("组装入参运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
// pythonObjects增加image_id关联
|
// pythonObjects增加image_id关联
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
List<Long> imageIds = relationImageIds(pythonObjects);
|
List<Long> imageIds = relationImageIds(pythonObjects);
|
||||||
System.out.println(imageIds);
|
endTime = System.currentTimeMillis();
|
||||||
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("增加image_id关联运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
//design
|
//design
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
JSONObject responseJSONObject = pythonService.designNew(pythonObjects);
|
JSONObject responseJSONObject = pythonService.designNew(pythonObjects);
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("design python端运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
//生成library
|
//生成library
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
generateLibrary(elementVO, designDTO.getTimeZone());
|
generateLibrary(elementVO, designDTO.getTimeZone());
|
||||||
//处理关联关系,修复element覆盖得情况
|
//处理关联关系,修复element覆盖得情况
|
||||||
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||||
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||||
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||||
|
log.info("处理关联关系运行时间:" + totalTimeInSeconds + " 秒");
|
||||||
//保存python返回信息;保存designItem和detail
|
//保存python返回信息;保存designItem和detail
|
||||||
return savePythonDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone(), responseJSONObject, designDTO.getSingleOverall());
|
return savePythonDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone(), responseJSONObject, designDTO.getSingleOverall());
|
||||||
}
|
}
|
||||||
@@ -702,10 +717,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
throw new BusinessException("collection.not.found");
|
throw new BusinessException("collection.not.found");
|
||||||
}
|
}
|
||||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||||
//查询用户 sketch library
|
// //查询用户 sketch library
|
||||||
List<LibraryVo> libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
// List<LibraryVo> libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||||
Arrays.asList(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName(),
|
// Arrays.asList(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName(),
|
||||||
CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
// CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||||
//校验collection element
|
//校验collection element
|
||||||
DesignCollectionDTO designCollectionDTO = CopyUtil.copyObject(reDesignDTO, DesignCollectionDTO.class);
|
DesignCollectionDTO designCollectionDTO = CopyUtil.copyObject(reDesignDTO, DesignCollectionDTO.class);
|
||||||
ValidateElementVO elementVO = collectionElementService.validateElement(designCollectionDTO);
|
ValidateElementVO elementVO = collectionElementService.validateElement(designCollectionDTO);
|
||||||
@@ -1015,49 +1030,41 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
public Integer designProcess(String processId) {
|
public Integer designProcess(String processId) {
|
||||||
ProcessIdObject object = new ProcessIdObject();
|
ProcessIdObject object = new ProcessIdObject();
|
||||||
object.setProcess_id(processId);
|
object.setProcess_id(processId);
|
||||||
|
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
.pingInterval(5, TimeUnit.SECONDS)
|
||||||
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
.writeTimeout(60, TimeUnit.SECONDS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MediaType mediaType = MediaType.parse("application/json");
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
|
||||||
String param = JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
|
String param = JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
|
||||||
log.info("designProcess请求python 参数:####{}", param);
|
log.info("designProcess请求python 参数:####{}", param);
|
||||||
RequestBody body = RequestBody.create(mediaType, param);
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
// .url("http://18.167.251.121:9991/api/get_progress")
|
|
||||||
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
|
||||||
.url(accessPythonIp + ":" + accessPythonPort + "/api/get_progress")
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/get_progress")
|
||||||
.method("POST", body)
|
.method("POST", body)
|
||||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.build();
|
.build();
|
||||||
Response response;
|
|
||||||
try {
|
try (Response response = client.newCall(request).execute()) {
|
||||||
response = client.newCall(request).execute();
|
if (response.isSuccessful()) {
|
||||||
} catch (IOException e) {
|
String responseBody = Objects.requireNonNull(response.body()).string();
|
||||||
log.error("PythonService##design进度条异常###{}", ExceptionUtil.getThrowableList(e));
|
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||||
return 0;
|
String num = responseObject.getString("data");
|
||||||
}
|
return Integer.valueOf(num);
|
||||||
if (response.isSuccessful()) {
|
|
||||||
try {
|
|
||||||
if (Objects.nonNull(response.body())) {
|
|
||||||
String responseBody = response.body().string();
|
|
||||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
|
||||||
String num = responseObject.getString("data");
|
|
||||||
return Integer.valueOf(num);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} catch (IOException | JSONException e) {
|
|
||||||
log.error("PythonService##design进度条异常###{}", ExceptionUtil.getThrowableList(e));
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
log.error("PythonService##design进度条异常###{}", ExceptionUtil.getThrowableList(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String converTypeToLevel1(String type) {
|
private String converTypeToLevel1(String type) {
|
||||||
if (StringUtils.isEmpty(type)) {
|
if (StringUtils.isEmpty(type)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user