Merge branch 'dev-lyhfive' of http://git.buggoglobal.com/java-project/baiyue-firstleg into dev
This commit is contained in:
+4
@@ -15,4 +15,8 @@ public interface DropshipCartonMapper extends BaseMapper<DropshipCarton> {
|
||||
|
||||
@Select("SELECT * FROM ll_dropship_carton WHERE customer_id=#{customerId} AND order_id=#{orderId} ORDER BY profile_id,carton_sequence")
|
||||
List<DropshipCarton> listOrder(@Param("customerId") String customerId, @Param("orderId") Long orderId);
|
||||
@Select("SELECT * FROM ll_dropship_carton WHERE customer_id=#{customerId} AND profile_id=#{profileId} AND sku_code=#{sku} AND status='AVAILABLE' ORDER BY carton_sequence LIMIT #{packages} FOR UPDATE")
|
||||
List<DropshipCarton> lockAvailable(@Param("customerId") String customerId, @Param("profileId") Long profileId, @Param("sku") String sku, @Param("packages") long packages);
|
||||
@Update("UPDATE ll_dropship_carton SET status='AVAILABLE', outbound_order_no=NULL, updated_at=NOW(3) WHERE customer_id=#{customerId} AND outbound_order_no=#{outboundNo} AND status='SHIPPED'")
|
||||
int restoreOutbound(@Param("customerId") String customerId, @Param("outboundNo") String outboundNo);
|
||||
}
|
||||
|
||||
+2
@@ -9,4 +9,6 @@ import java.util.List;
|
||||
public interface DropshipOrderProfileMapper extends BaseMapper<DropshipOrderProfile> {
|
||||
@Select("SELECT * FROM ll_dropship_order_profile WHERE customer_id=#{customerId} AND order_id=#{orderId} ORDER BY source_pallet_no")
|
||||
List<DropshipOrderProfile> listOrder(@Param("customerId") String customerId, @Param("orderId") Long orderId);
|
||||
@Select("SELECT * FROM ll_dropship_order_profile WHERE customer_id=#{customerId} AND inventory_position_id=#{positionId} LIMIT 1")
|
||||
DropshipOrderProfile findPosition(@Param("customerId") String customerId, @Param("positionId") Long positionId);
|
||||
}
|
||||
|
||||
+5
@@ -6,6 +6,7 @@ import com.baiyue.lastleg.dropship.entity.DropshipSkuInventory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,4 +14,8 @@ import java.util.List;
|
||||
public interface DropshipSkuInventoryMapper extends BaseMapper<DropshipSkuInventory> {
|
||||
@Select("SELECT * FROM ll_dropship_sku_inventory WHERE customer_id=#{customerId} AND order_id=#{orderId} ORDER BY profile_id,sku_code")
|
||||
List<DropshipSkuInventory> listOrder(@Param("customerId") String customerId, @Param("orderId") Long orderId);
|
||||
@Update("UPDATE ll_dropship_sku_inventory SET package_count=package_count-#{packages},updated_at=NOW(3) WHERE customer_id=#{customerId} AND profile_id=#{profileId} AND sku_code=#{sku} AND package_count>=#{packages}")
|
||||
int deduct(@Param("customerId") String customerId, @Param("profileId") Long profileId, @Param("sku") String sku, @Param("packages") long packages);
|
||||
@Update("UPDATE ll_dropship_sku_inventory SET package_count=package_count+#{packages},updated_at=NOW(3) WHERE customer_id=#{customerId} AND profile_id=#{profileId} AND sku_code=#{sku}")
|
||||
int restore(@Param("customerId") String customerId, @Param("profileId") Long profileId, @Param("sku") String sku, @Param("packages") long packages);
|
||||
}
|
||||
|
||||
+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