提交
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
package com.baiyue.lastleg.dropship.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record DropshipPalletSnapshot(String sourcePalletNo, long packageCount,
|
||||
List<Sku> skus) {
|
||||
public record Sku(String skuCode, String productName, long packageCount, long productQuantity) {}
|
||||
}
|
||||
+24
-10
@@ -7,6 +7,7 @@ import com.baiyue.lastleg.dropship.mapper.*;
|
||||
import com.baiyue.lastleg.entity.LastlegOrder;
|
||||
import com.baiyue.lastleg.inboundplan.pda.entity.InboundStockReceipt;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import com.baiyue.lastleg.dropship.model.DropshipPalletSnapshot;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -109,6 +110,21 @@ public class DropshipOrderService {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<DropshipPalletSnapshot> palletSnapshots(String customerId, Long orderId) {
|
||||
List<DropshipOrderProfile> orderProfiles = profiles.listOrder(customerId, orderId);
|
||||
Map<Long, List<DropshipSkuInventory>> skusByProfile = skuInventory.listOrder(customerId, orderId).stream()
|
||||
.collect(Collectors.groupingBy(DropshipSkuInventory::getProfileId));
|
||||
return orderProfiles.stream().map(profile -> {
|
||||
List<DropshipPalletSnapshot.Sku> skus = skusByProfile.getOrDefault(profile.getId(), List.of()).stream()
|
||||
.map(sku -> new DropshipPalletSnapshot.Sku(sku.getSkuCode(), sku.getProductName(),
|
||||
value(sku.getPackageCount()), value(sku.getProductQuantity())))
|
||||
.toList();
|
||||
return new DropshipPalletSnapshot(profile.getSourcePalletNo(),
|
||||
skus.stream().mapToLong(DropshipPalletSnapshot.Sku::packageCount).sum(), skus);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void activateAfterStockIn(String customerId, Long orderId, Long taskId,
|
||||
List<InboundStockReceipt> receipts) {
|
||||
@@ -118,20 +134,18 @@ public class DropshipOrderService {
|
||||
if (profilesForOrder.stream().anyMatch(profile -> "ACTIVE".equals(profile.getStatus()))) {
|
||||
throw conflict("Dropship pallet activation is incomplete; repair profiles before retrying");
|
||||
}
|
||||
Map<Long, List<InboundStockReceipt>> receiptsByPallet = receipts.stream()
|
||||
.filter(receipt -> receipt.getWarehousePalletId() != null)
|
||||
.collect(Collectors.groupingBy(InboundStockReceipt::getWarehousePalletId));
|
||||
Map<String, List<InboundStockReceipt>> receiptsByPallet = receipts.stream()
|
||||
.filter(receipt -> receipt.getPalletNo() != null)
|
||||
.collect(Collectors.groupingBy(InboundStockReceipt::getPalletNo));
|
||||
if (receiptsByPallet.size() != profilesForOrder.size()) {
|
||||
throw conflict("PDA pallet count does not match dropship source pallet count");
|
||||
}
|
||||
List<DropshipOrderProfile> orderedProfiles = profilesForOrder.stream()
|
||||
.sorted(java.util.Comparator.comparing(DropshipOrderProfile::getSourcePalletNo)).toList();
|
||||
List<List<InboundStockReceipt>> orderedReceipts = receiptsByPallet.values().stream()
|
||||
.sorted(java.util.Comparator.comparing(value -> value.get(0).getWarehousePalletId())).toList();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (int index = 0; index < orderedProfiles.size(); index++) {
|
||||
DropshipOrderProfile profile = orderedProfiles.get(index);
|
||||
List<InboundStockReceipt> actual = orderedReceipts.get(index);
|
||||
for (DropshipOrderProfile profile : profilesForOrder) {
|
||||
List<InboundStockReceipt> actual = receiptsByPallet.get(profile.getSourcePalletNo());
|
||||
if (actual == null || actual.isEmpty()) {
|
||||
throw conflict("PDA receipt is missing for dropship source pallet " + profile.getSourcePalletNo());
|
||||
}
|
||||
List<DropshipCarton> profileCartons = cartons.listProfile(customerId, profile.getId());
|
||||
long expected = profileCartons.size();
|
||||
long received = actual.stream().mapToLong(value -> value.getReceivedPackages() == null ? 0 : value.getReceivedPackages()).sum();
|
||||
|
||||
Reference in New Issue
Block a user