优化
This commit is contained in:
@@ -87,6 +87,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ba
|
||||
FROM (
|
||||
SELECT o.tenant_id accountId,o.id inboundId,o.inbound_code inboundCode,
|
||||
o.expected_arrival_at expectedArrivalAt,o.created_at createdAt,
|
||||
CASE WHEN o.process_status='WAIT_SPLIT' THEN 'WAIT_SPLIT'
|
||||
WHEN o.process_status='LOADING' THEN 'LOADING' ELSE 'WAIT_MEASURE' END candidateStatus,
|
||||
CASE WHEN o.process_status='WAIT_SPLIT' THEN
|
||||
COALESCE((SELECT SUM(mi.package_count) FROM fl_inbound_measurement m
|
||||
JOIN fl_inbound_measurement_item mi
|
||||
@@ -132,7 +134,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ba
|
||||
ON current_member.tenant_id=eligible.accountId AND current_member.inbound_id=eligible.inboundId
|
||||
AND current_member.active_flag=1
|
||||
LEFT JOIN fl_coload_group current_group
|
||||
ON current_group.id=current_member.group_id AND current_group.group_status IN ('ACTIVE','LOCKED')
|
||||
ON current_group.id=current_member.group_id AND current_group.group_status IN ('ACTIVE','LOCKED')
|
||||
WHERE eligible.candidateStatus<>'WAIT_SPLIT' OR eligible.availablePackageCount>0
|
||||
GROUP BY current_group.id,
|
||||
CASE WHEN current_group.id IS NULL THEN eligible.accountId END,
|
||||
CASE WHEN current_group.id IS NULL THEN eligible.inboundId END
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.*;
|
||||
/** 智能装柜的自动计划、候选、推荐、人工分配和删除编排。 */
|
||||
@Service
|
||||
public class SmartLoadingService {
|
||||
private static final BigDecimal CAPACITY_LIMIT_RATIO = new BigDecimal("1.10");
|
||||
private static final BigDecimal CAPACITY_LIMIT_RATIO = new BigDecimal("1.50");
|
||||
private static final Map<String, Set<String>> WORKBENCH_CHANNEL_GROUPS = Map.of(
|
||||
"MATSON_CLX", Set.of("MATSON_CLX_TRUCK", "MATSON_CLX_PARCEL"),
|
||||
"MATSON_MAX", Set.of("MATSON_MAX_TRUCK", "MATSON_MAX_PARCEL"),
|
||||
@@ -278,7 +278,8 @@ public class SmartLoadingService {
|
||||
.sorted(Comparator.comparing(InboundCandidate::inboundId)).toList();
|
||||
InboundCandidate first = ordered.get(0);
|
||||
int packages = ordered.stream().map(InboundCandidate::availablePackageCount).mapToInt(Integer::intValue).sum();
|
||||
if (packages != metadata.groupTotalBoxes()) return null;
|
||||
boolean occupied = ordered.stream().anyMatch(candidate -> Boolean.TRUE.equals(candidate.locked()));
|
||||
if (!occupied && packages != metadata.groupTotalBoxes()) return null;
|
||||
boolean hasVolume = ordered.stream().anyMatch(candidate -> candidate.availableVolumeCbm() != null);
|
||||
BigDecimal volume = hasVolume ? ordered.stream().map(InboundCandidate::availableVolumeCbm)
|
||||
.filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_UP) : null;
|
||||
@@ -299,7 +300,7 @@ public class SmartLoadingService {
|
||||
first.destinationWarehouseId(), first.destinationWarehouseCode(), first.destinationWarehouseName(),
|
||||
customers, goods, packages, gross, net, averageVolume, volume, metadata.coLoadGroupId(), metadata.groupNo(),
|
||||
metadata.memberCount(), metadata.groupTotalBoxes(),
|
||||
ordered.stream().anyMatch(candidate -> Boolean.TRUE.equals(candidate.locked())),
|
||||
occupied,
|
||||
ordered.stream().allMatch(candidate -> Boolean.TRUE.equals(candidate.canAssign())),
|
||||
ordered.stream().map(InboundCandidate::blockReason).filter(StringUtils::hasText).findFirst().orElse(null),
|
||||
groupStatus(ordered),
|
||||
@@ -1017,7 +1018,7 @@ public class SmartLoadingService {
|
||||
result.put(member.inboundId(), details);
|
||||
}
|
||||
if (!groupFits(booking, planItems, group, available)) {
|
||||
throw validation("同柜不可拆组整体超过货柜容积或重量的110%上限");
|
||||
throw validation("同柜不可拆组整体超过货柜容积或重量的150%上限");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1270,7 +1271,7 @@ public class SmartLoadingService {
|
||||
if (b.getCapacityCbm()==null || b.getMaxWeightKg()==null) throw validation("货柜容量和最大承重未配置");
|
||||
if (v.compareTo(b.getCapacityCbm().multiply(CAPACITY_LIMIT_RATIO))>0
|
||||
|| w.compareTo(b.getMaxWeightKg().multiply(CAPACITY_LIMIT_RATIO))>0) {
|
||||
throw validation("超过货柜容积或重量的110%上限");
|
||||
throw validation("超过货柜容积或重量的150%上限");
|
||||
}
|
||||
}
|
||||
private void checkPlanCapacity(ContainerBookingEntity booking, List<LoadingPlanItemEntity> items) {
|
||||
@@ -1280,12 +1281,12 @@ public class SmartLoadingService {
|
||||
BigDecimal weight = items.stream().map(x -> unit(x.getGrossWeightKg()))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (weight.compareTo(booking.getMaxWeightKg().multiply(CAPACITY_LIMIT_RATIO)) > 0) {
|
||||
throw validation("超过货柜重量的110%上限");
|
||||
throw validation("超过货柜重量的150%上限");
|
||||
}
|
||||
BigDecimal volume = items.stream().map(x -> unit(x.getVolumeCbm()))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (volume.compareTo(booking.getCapacityCbm().multiply(CAPACITY_LIMIT_RATIO)) > 0) {
|
||||
throw validation("超过货柜容积的110%上限");
|
||||
throw validation("超过货柜容积的150%上限");
|
||||
}
|
||||
}
|
||||
private int fittingBoxes(ContainerBookingEntity b,List<LoadingPlanItemEntity> lines,Candidate c){
|
||||
|
||||
Reference in New Issue
Block a user