修复bug
This commit is contained in:
parent
d771a5b068
commit
19775c580e
|
@ -221,14 +221,13 @@ public class RouteOrder extends BaseEntity {
|
|||
}
|
||||
|
||||
public void updateStatus() {
|
||||
// 首先检查所有项是否都为-1状态
|
||||
if (allItemsInStatus(-1)) {
|
||||
this.orderStatus = -1;
|
||||
} else if (allItemsInStatus(4)) {
|
||||
this.orderStatus = 4;
|
||||
} else if (allItemsInStatus(3)) {
|
||||
} else if (anyItemInStatus(3) && allOtherItemsInStatus(2)) {
|
||||
this.orderStatus = 3;
|
||||
} else if (allItemsInStatus(2)) {
|
||||
} else if (anyItemInStatus(2) && allOtherItemsInStatus(1)) {
|
||||
this.orderStatus = 2;
|
||||
} else if (allItemsInStatus(1)) {
|
||||
this.orderStatus = 1;
|
||||
|
@ -249,6 +248,31 @@ public class RouteOrder extends BaseEntity {
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean anyItemInStatus(int targetStatus) {
|
||||
for (Leg item : this.legItems) {
|
||||
if (item.getLegStatus() == targetStatus) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allOtherItemsInStatus(int targetStatus) {
|
||||
boolean foundHigherStatus = false;
|
||||
for (Leg item : this.legItems) {
|
||||
if (item.getLegStatus() > targetStatus) {
|
||||
if (foundHigherStatus) {
|
||||
// 如果已经找到一个更高状态,而且又遇到另一个,则不符合所有其他项目都处于目标状态的条件
|
||||
return false;
|
||||
}
|
||||
foundHigherStatus = true; // 标记已找到一个更高的状态
|
||||
} else if (item.getLegStatus() < targetStatus) {
|
||||
return false; // 如果找到状态低于目标状态的项目,则直接返回false
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String translateOrderStatus(int status) {
|
||||
return switch (status) {
|
||||
case ORDER_STATUS_PREPARE -> ORDER_STATUS_PREPARE_NAME;
|
||||
|
|
Loading…
Reference in New Issue