|
@@ -3,8 +3,8 @@ package com.sd.business.service.work.impl.fixation.strategy;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.sd.business.entity.work.constant.MaterialsConstant;
|
|
|
+import com.sd.business.service.work.impl.fixation.CoordinateBo;
|
|
|
import com.sd.business.service.work.impl.fixation.FixationStrategy;
|
|
|
-import com.sd.business.service.work.impl.fixation.TypeSettingBo;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
@@ -38,7 +38,7 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
/**
|
|
|
* 第一列到第四列下边y坐标
|
|
|
*/
|
|
|
- private BigDecimal y1 = this.bl;
|
|
|
+ private BigDecimal y1 = BigDecimal.ZERO;
|
|
|
private BigDecimal y2 = BigDecimal.ZERO;
|
|
|
private BigDecimal y3 = BigDecimal.ZERO;
|
|
|
private BigDecimal y4 = BigDecimal.ZERO;
|
|
@@ -47,7 +47,7 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
Fixation_30_40 fixation3040 = new Fixation_30_40();
|
|
|
|
|
|
while (fixation3040.hasNext()) {
|
|
|
- TypeSettingBo demo = fixation3040.next();
|
|
|
+ CoordinateBo demo = fixation3040.next();
|
|
|
System.out.println(JSONObject.toJSONString(demo));
|
|
|
}
|
|
|
|
|
@@ -55,50 +55,22 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public TypeSettingBo next() {
|
|
|
+ public CoordinateBo next() {
|
|
|
|
|
|
if (!this.hasNext) {
|
|
|
throw new ServiceException("无法继续排版");
|
|
|
}
|
|
|
|
|
|
- if (this.typeSettingBo == null) {
|
|
|
- this.maxLength = this.bl;
|
|
|
- this.usedArea = this.bArea;
|
|
|
- this.schedulingNum = BigDecimal.ONE;
|
|
|
- setNextTypeSettingBo(BigDecimal.ZERO, BigDecimal.ZERO, false);
|
|
|
- return this.typeSettingBo;
|
|
|
- }
|
|
|
-
|
|
|
// 对比排第一列最大高度小还是第三列最大高度小
|
|
|
BigDecimal tempY1 = this.y1.add(this.bl);
|
|
|
BigDecimal tempY3 = this.y3.add(this.bw);
|
|
|
BigDecimal tempMinY3 = this.y3.add(this.bl);
|
|
|
|
|
|
- // 排版个数为偶数时,排第二列或者第四列
|
|
|
- if (schedulingNum.add(BigDecimal.ONE).intValue() % 2 == 0) {
|
|
|
- // 如果第一列和第二列轴不相等,则排第二列
|
|
|
- if (this.y1.compareTo(this.y2) != 0) {
|
|
|
- setNextTypeSettingBo(this.x2, this.y2, false);
|
|
|
- this.y2 = this.y2.add(this.bl);
|
|
|
- }
|
|
|
- // 否则排第四列
|
|
|
- else {
|
|
|
- setNextTypeSettingBo(this.x4, this.y4, true);
|
|
|
- this.y4 = this.y4.add(this.bw);
|
|
|
- }
|
|
|
- // 判断是否还能继续排版
|
|
|
- if (tempY1.compareTo(this.masterLength) > 0
|
|
|
- && tempY3.compareTo(this.masterLength) > 0
|
|
|
- && tempMinY3.compareTo(this.masterLength) > 0) {
|
|
|
- this.hasNext = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 排版个数为奇数时,排第一列或者第三列
|
|
|
- else {
|
|
|
+ // 排版个数为偶数时,排第一列或者第三列
|
|
|
+ if (schedulingNum.intValue() % 2 == 0) {
|
|
|
// 如果第一列后高度小于等于排第三列后高度,则排第一列
|
|
|
if (tempY1.compareTo(tempY3) <= 0) {
|
|
|
- setNextTypeSettingBo(this.x1, this.y1, false);
|
|
|
+ setCoordinateBo(this.x1, this.y1, false);
|
|
|
this.y1 = tempY1;
|
|
|
this.maxLength = this.y1.compareTo(this.y3) > 0 ? this.y1 : this.y3;
|
|
|
}
|
|
@@ -106,26 +78,45 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
else {
|
|
|
// 如果第三列高度无法旋转排版,则表示第三列第四列合并排版非选择垫子
|
|
|
if (tempY3.compareTo(masterLength) > 0) {
|
|
|
- setNextTypeSettingBo(this.x3, this.y3, false);
|
|
|
+ setCoordinateBo(this.x3, this.y3, false);
|
|
|
this.y3 = tempMinY3;
|
|
|
this.hasNext = false;
|
|
|
}
|
|
|
// 旋转排版
|
|
|
else {
|
|
|
- setNextTypeSettingBo(this.x3, this.y3, true);
|
|
|
+ setCoordinateBo(this.x3, this.y3, true);
|
|
|
this.y3 = tempY3;
|
|
|
this.maxLength = this.y1.compareTo(y3) > 0 ? this.y1 : this.y3;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 排版个数为奇数时,排第二列或者第四列
|
|
|
+ else {
|
|
|
+ // 如果第一列和第二列轴不相等,则排第二列
|
|
|
+ if (this.y1.compareTo(this.y2) != 0) {
|
|
|
+ setCoordinateBo(this.x2, this.y2, false);
|
|
|
+ this.y2 = this.y2.add(this.bl);
|
|
|
+ }
|
|
|
+ // 否则排第四列
|
|
|
+ else {
|
|
|
+ setCoordinateBo(this.x4, this.y4, true);
|
|
|
+ this.y4 = this.y4.add(this.bw);
|
|
|
+ }
|
|
|
+ // 判断是否还能继续排版
|
|
|
+ if (tempY1.compareTo(this.masterLength) > 0
|
|
|
+ && tempY3.compareTo(this.masterLength) > 0
|
|
|
+ && tempMinY3.compareTo(this.masterLength) > 0) {
|
|
|
+ this.hasNext = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.usedArea = this.usedArea.add(this.bArea);
|
|
|
this.schedulingNum = this.schedulingNum.add(BigDecimal.ONE);
|
|
|
|
|
|
- return this.typeSettingBo;
|
|
|
+ return this.coordinateBo;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 赋值下一个排版参数
|
|
|
*
|
|
@@ -133,8 +124,8 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
* @param y y轴
|
|
|
* @param hasRotate 是否旋转
|
|
|
*/
|
|
|
- private void setNextTypeSettingBo(BigDecimal x, BigDecimal y, Boolean hasRotate) {
|
|
|
- this.typeSettingBo = new TypeSettingBo(
|
|
|
+ private void setCoordinateBo(BigDecimal x, BigDecimal y, Boolean hasRotate) {
|
|
|
+ this.coordinateBo = new CoordinateBo(
|
|
|
x,
|
|
|
y,
|
|
|
hasRotate ? this.w : this.l,
|