BUGFIX:印花优先级不从1开始传导致数组越界
This commit is contained in:
@@ -2912,72 +2912,71 @@ public class PythonService {
|
|||||||
|
|
||||||
private PrintToPython resolveDesignSinglePrint(List<DesignSinglePrint> printObject, String partialDesign) {
|
private PrintToPython resolveDesignSinglePrint(List<DesignSinglePrint> printObject, String partialDesign) {
|
||||||
PrintToPython printToPython = new PrintToPython();
|
PrintToPython printToPython = new PrintToPython();
|
||||||
// DesignPythonItemPrint printSingle = new DesignPythonItemPrint();
|
|
||||||
DesignPythonItemPrint printOverall = new DesignPythonItemPrint();
|
DesignPythonItemPrint printOverall = new DesignPythonItemPrint();
|
||||||
// printToPython.setSingle(printSingle);
|
|
||||||
printToPython.setOverall(printOverall);
|
printToPython.setOverall(printOverall);
|
||||||
printToPython.setPartial(StringUtil.isNullOrEmpty(partialDesign) ? null : partialDesign);
|
printToPython.setPartial(StringUtil.isNullOrEmpty(partialDesign) ? null : partialDesign);
|
||||||
if (Objects.isNull(printObject) || printObject.isEmpty()) {
|
if (Objects.isNull(printObject) || printObject.isEmpty()) {
|
||||||
return printToPython;
|
return printToPython;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没有印花时的参数设置
|
// 1. 先对 printObject 按 priority 排序(升序)
|
||||||
// if (printObject.getIfSingle().equals(Boolean.FALSE) && CollectionUtil.isEmpty(printObject.getPrints())) {
|
List<DesignSinglePrint> sortedPrints = printObject.stream()
|
||||||
// return new DesignPythonItemPrint(new ArrayList<>(), false);
|
.sorted(Comparator.comparingInt(DesignSinglePrint::getPriority))
|
||||||
// }
|
.toList();
|
||||||
// DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
|
|
||||||
|
|
||||||
int size = printObject.size();
|
// 2. 分别收集单印和非单印的数据
|
||||||
// 占位符填充数组
|
List<DesignSinglePrint> singlePrints = sortedPrints.stream()
|
||||||
List<List<Float>> locationS = new ArrayList<>(Collections.nCopies(size, null));
|
.filter(DesignSinglePrint::getIfSingle)
|
||||||
List<List<Float>> scaleS = new ArrayList<>(Collections.nCopies(size, null));
|
.toList();
|
||||||
List<Double> angleS = new ArrayList<>(Collections.nCopies(size, null));
|
|
||||||
ArrayList<String> pathsS = new ArrayList<>(Collections.nCopies(size, null));
|
|
||||||
|
|
||||||
List<List<Float>> locationO = new ArrayList<>(Collections.nCopies(size, null));
|
List<DesignSinglePrint> overallPrints = sortedPrints.stream()
|
||||||
List<List<Float>> scaleO = new ArrayList<>(Collections.nCopies(size, null));
|
.filter(p -> !p.getIfSingle())
|
||||||
List<Double> angleO = new ArrayList<>(Collections.nCopies(size, null));
|
.toList();
|
||||||
ArrayList<String> pathsO = new ArrayList<>(Collections.nCopies(size, null));
|
|
||||||
|
|
||||||
// 设置印花的位置、大小、旋转角度
|
// 3. 处理单印数据
|
||||||
// 优先级越大,越靠近顶层,在传输给python的数组中,越靠前
|
if (!singlePrints.isEmpty()) {
|
||||||
// List<DesignSinglePrint> prints = printObject.getPrints();
|
List<List<Float>> locationS = new ArrayList<>();
|
||||||
printObject.forEach(p -> {
|
List<List<Float>> scaleS = new ArrayList<>();
|
||||||
p.getLocation().set(0, p.getLocation().get(0));
|
List<Double> angleS = new ArrayList<>();
|
||||||
p.getLocation().set(1, p.getLocation().get(1));
|
List<String> pathsS = new ArrayList<>();
|
||||||
Integer priority = p.getPriority();
|
|
||||||
|
for (DesignSinglePrint p : singlePrints) {
|
||||||
setUriToMinioPath(p);
|
setUriToMinioPath(p);
|
||||||
// todo 下标越界问题
|
locationS.add(p.getLocation());
|
||||||
if (p.getIfSingle()) {
|
scaleS.add(p.getScale());
|
||||||
locationS.set(priority - 1, p.getLocation());
|
angleS.add(p.getAngle());
|
||||||
scaleS.set(priority - 1, p.getScale());
|
pathsS.add(p.getMinIOPath());
|
||||||
angleS.set(priority - 1, p.getAngle());
|
}
|
||||||
pathsS.set(priority - 1, p.getMinIOPath());
|
|
||||||
} else {
|
// 注意:如果 printOverall 中需要设置单印数据,请在这里添加相应的 setter
|
||||||
locationO.set(priority - 1, p.getLocation());
|
// 根据您的原始代码,似乎只设置了 overall(非单印)的数据
|
||||||
scaleO.set(priority - 1, p.getScale());
|
// 如果需要设置单印,请取消下面的注释并添加对应的字段
|
||||||
angleO.set(priority - 1, p.getAngle());
|
// printOverall.setSingleLocation(locationS);
|
||||||
pathsO.set(priority - 1, p.getMinIOPath());
|
// printOverall.setSingleScale(scaleS);
|
||||||
|
// printOverall.setSingleAngle(angleS);
|
||||||
|
// printOverall.setSinglePath(pathsS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 处理非单印数据(整体印花)
|
||||||
|
if (!overallPrints.isEmpty()) {
|
||||||
|
List<List<Float>> locationO = new ArrayList<>();
|
||||||
|
List<List<Float>> scaleO = new ArrayList<>();
|
||||||
|
List<Double> angleO = new ArrayList<>();
|
||||||
|
List<String> pathsO = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DesignSinglePrint p : overallPrints) {
|
||||||
|
setUriToMinioPath(p);
|
||||||
|
locationO.add(p.getLocation());
|
||||||
|
scaleO.add(p.getScale());
|
||||||
|
angleO.add(p.getAngle());
|
||||||
|
pathsO.add(p.getMinIOPath());
|
||||||
}
|
}
|
||||||
// log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO));
|
|
||||||
});
|
|
||||||
/*locationS.removeAll(Collections.singleton(null));
|
|
||||||
scaleS.removeAll(Collections.singleton(null));
|
|
||||||
angleS.removeAll(Collections.singleton(null));
|
|
||||||
pathsS.removeAll(Collections.singleton(null));
|
|
||||||
printSingle.setLocation(locationS);
|
|
||||||
printSingle.setPrint_scale_list(scaleS);
|
|
||||||
printSingle.setPrint_angle_list(angleS);
|
|
||||||
printSingle.setPrint_path_list(pathsS);*/
|
|
||||||
|
|
||||||
locationO.removeAll(Collections.singleton(null));
|
|
||||||
scaleO.removeAll(Collections.singleton(null));
|
|
||||||
angleO.removeAll(Collections.singleton(null));
|
|
||||||
pathsO.removeAll(Collections.singleton(null));
|
|
||||||
printOverall.setLocation(locationO);
|
printOverall.setLocation(locationO);
|
||||||
printOverall.setPrint_scale_list(scaleO);
|
printOverall.setPrint_scale_list(scaleO);
|
||||||
printOverall.setPrint_angle_list(angleO);
|
printOverall.setPrint_angle_list(angleO);
|
||||||
printOverall.setPrint_path_list(pathsO);
|
printOverall.setPrint_path_list(pathsO);
|
||||||
|
}
|
||||||
|
|
||||||
return printToPython;
|
return printToPython;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user