优化
This commit is contained in:
@@ -2,6 +2,7 @@ package com.baiyue.firstleg.mapper;
|
||||
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.PendingTask;
|
||||
import com.baiyue.firstleg.dto.SmartLoadingDtos.PalletCandidate;
|
||||
import com.baiyue.firstleg.dto.SmartLoadingDtos.GroupMemberCandidate;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
@@ -254,6 +255,17 @@ public interface DropshipPalletizationMapper {
|
||||
""")
|
||||
List<PrintSkuRow> printSkuRows(@Param("palletId") long palletId);
|
||||
|
||||
@Select("""
|
||||
SELECT o.tenant_id accountId,o.id inboundId,o.order_id orderId,o.order_no orderNo,
|
||||
o.inbound_code inboundCode,o.customer_name customerName,COUNT(DISTINCT c.id) availablePackageCount,
|
||||
o.process_status orderStatusSnapshot,o.expected_arrival_at expectedArrivalAt
|
||||
FROM fl_dropship_pallet_carton c
|
||||
JOIN fl_inbound_order o ON o.id=c.inbound_id AND o.tenant_id=c.tenant_id
|
||||
WHERE c.pallet_id=#{palletId}
|
||||
GROUP BY o.tenant_id,o.id,o.order_id,o.order_no,o.inbound_code,o.customer_name,o.process_status,o.expected_arrival_at
|
||||
ORDER BY o.inbound_code,o.id
|
||||
""") List<GroupMemberCandidate> palletInboundMembers(@Param("palletId") long palletId);
|
||||
|
||||
@Select("""
|
||||
SELECT p.id pallet_id,p.pallet_no,'SEALED_PALLET' unit_type,TRUE indivisible,COUNT(DISTINCT c.id) carton_count,
|
||||
(SELECT COUNT(DISTINCT sku.sku_code) FROM fl_dropship_pallet_carton pc
|
||||
|
||||
@@ -142,7 +142,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ba
|
||||
<script>
|
||||
SELECT current_group.id groupId,
|
||||
CASE WHEN current_group.id IS NULL THEN eligible.accountId END accountId,
|
||||
CASE WHEN current_group.id IS NULL THEN eligible.inboundId END inboundId,
|
||||
MIN(CASE WHEN current_group.id IS NULL THEN eligible.inboundId END) inboundId,
|
||||
CASE WHEN current_group.id IS NULL THEN eligible.palletId END palletId,
|
||||
MIN(eligible.expectedArrivalAt) sortArrivalAt,MIN(eligible.inboundId) sortInboundId
|
||||
FROM (
|
||||
@@ -202,7 +202,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ba
|
||||
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,
|
||||
CASE WHEN current_group.id IS NULL AND eligible.palletId IS NULL THEN eligible.inboundId END,
|
||||
CASE WHEN current_group.id IS NULL THEN eligible.palletId END
|
||||
HAVING (current_group.id IS NULL OR (
|
||||
COUNT(DISTINCT eligible.accountId,eligible.inboundId)=(SELECT COUNT(*) FROM fl_coload_group_member group_member_count
|
||||
@@ -230,7 +230,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ba
|
||||
<if test="query.createdEnd != null">AND MIN(eligible.createdAt)<DATE_ADD(#{query.createdEnd},INTERVAL 1 DAY)</if>
|
||||
<if test="query.expectedArrivalStart != null">AND MIN(eligible.expectedArrivalAt)>=#{query.expectedArrivalStart}</if>
|
||||
<if test="query.expectedArrivalEnd != null">AND MIN(eligible.expectedArrivalAt)<DATE_ADD(#{query.expectedArrivalEnd},INTERVAL 1 DAY)</if>
|
||||
ORDER BY sortArrivalAt IS NULL,sortArrivalAt,sortInboundId
|
||||
ORDER BY sortArrivalAt IS NULL,sortArrivalAt,sortInboundId,palletId
|
||||
</script>
|
||||
""")
|
||||
Page<CandidateUnit> globalCandidateUnits(Page<CandidateUnit> page,
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SmartLoadingService {
|
||||
Map<Long, List<Candidate>> grouped = candidates(bookingId, warehouseId).stream()
|
||||
.collect(java.util.stream.Collectors.groupingBy(Candidate::inboundId, LinkedHashMap::new,
|
||||
java.util.stream.Collectors.toList()));
|
||||
return grouped.values().stream().flatMap(details -> inboundCandidates(details).stream()).toList();
|
||||
return uniqueCandidateUnits(grouped.values().stream().flatMap(details -> inboundCandidates(details).stream()).toList());
|
||||
}
|
||||
|
||||
private List<InboundCandidate> recommendationCandidates(ContainerBookingEntity booking,
|
||||
@@ -289,7 +289,7 @@ public class SmartLoadingService {
|
||||
first.unitNetWeightKg(), pallet.cartonCount()==null||pallet.cartonCount()==0?null:pallet.volumeCbm().divide(BigDecimal.valueOf(pallet.cartonCount()),6,RoundingMode.HALF_UP),
|
||||
pallet.volumeCbm(),"SEALED_PALLET",pallet.palletId(),pallet.palletNo(),true,
|
||||
first.coLoadGroupId(), first.groupNo(), first.memberCount(),first.groupTotalBoxes(), false, !StringUtils.hasText(palletBlock), palletBlock,
|
||||
first.orderStatusSnapshot(),first.expectedArrivalAt(),List.of());
|
||||
first.orderStatusSnapshot(),first.expectedArrivalAt(),dropshipPallets.palletInboundMembers(pallet.palletId()));
|
||||
}).toList();
|
||||
return List.of(new InboundCandidate(first.accountId(), first.inboundId(), first.orderId(), first.orderNo(),
|
||||
first.inboundCode(), first.warehouseId(), first.channelCode(), first.channelName(),
|
||||
@@ -367,7 +367,17 @@ public class SmartLoadingService {
|
||||
}
|
||||
|
||||
private static String unitKey(Long groupId, Long accountId, Long inboundId, Long palletId) {
|
||||
return groupId == null ? "I|" + accountId + '|' + inboundId + '|' + palletId : "G|" + groupId;
|
||||
return groupId != null ? "G|" + groupId : palletId != null ? "P|" + palletId : "I|" + accountId + '|' + inboundId + '|' + palletId;
|
||||
}
|
||||
|
||||
private static List<InboundCandidate> uniqueCandidateUnits(List<InboundCandidate> candidates) {
|
||||
Map<String, InboundCandidate> units = new LinkedHashMap<>();
|
||||
for (InboundCandidate candidate : candidates) {
|
||||
String key = candidate.palletId() != null ? "P|" + candidate.palletId()
|
||||
: "I|" + candidate.accountId() + '|' + candidate.inboundId();
|
||||
units.putIfAbsent(key, candidate);
|
||||
}
|
||||
return List.copyOf(units.values());
|
||||
}
|
||||
|
||||
private static BigDecimal weightedAverage(List<InboundCandidate> members,
|
||||
|
||||
Reference in New Issue
Block a user