生产更新:同步已提交的海外仓分析及业务修复(2026-10-16) #27

Merged
admin merged 138 commits from test into main 2026-10-16 18:02:59 +08:00
2 changed files with 20 additions and 6 deletions
Showing only changes of commit 03601ab0aa - Show all commits
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import java.util.List; import java.util.List;
import java.util.Collection;
@Mapper @Mapper
public interface InventoryPositionMapper extends BaseMapper<InventoryPosition> { public interface InventoryPositionMapper extends BaseMapper<InventoryPosition> {
@@ -17,6 +18,14 @@ public interface InventoryPositionMapper extends BaseMapper<InventoryPosition> {
List<InventoryPosition> listBalance(@Param("customerId") String customerId, List<InventoryPosition> listBalance(@Param("customerId") String customerId,
@Param("balanceId") Long balanceId); @Param("balanceId") Long balanceId);
@Select({"<script>",
"SELECT p.* FROM ll_inventory_position p JOIN ll_inventory_balance b ON b.id=p.balance_id",
"WHERE b.customer_id=#{customerId} AND p.balance_id IN",
"<foreach collection='balanceIds' item='id' open='(' separator=',' close=')'>#{id}</foreach>",
"ORDER BY p.balance_id,p.pallet_no,p.batch_no", "</script>"})
List<InventoryPosition> listBalances(@Param("customerId") String customerId,
@Param("balanceIds") Collection<Long> balanceIds);
@Select("SELECT * FROM ll_inventory_position WHERE id=#{positionId} AND customer_id=#{customerId} LIMIT 1") @Select("SELECT * FROM ll_inventory_position WHERE id=#{positionId} AND customer_id=#{customerId} LIMIT 1")
InventoryPosition findTenantPosition(@Param("customerId") String customerId, InventoryPosition findTenantPosition(@Param("customerId") String customerId,
@Param("positionId") Long positionId); @Param("positionId") Long positionId);
@@ -253,10 +253,13 @@ public class RelabelApplicationService implements WalletResultHandler {
.gt(InventoryBalance::getAvailablePackages, 0) .gt(InventoryBalance::getAvailablePackages, 0)
.like(StringUtils.hasText(inboundCode), InventoryBalance::getInboundCode, trim(inboundCode)) .like(StringUtils.hasText(inboundCode), InventoryBalance::getInboundCode, trim(inboundCode))
.orderByDesc(InventoryBalance::getUpdatedAt)); .orderByDesc(InventoryBalance::getUpdatedAt));
List<RelabelResponses.InventoryCandidate> result = new java.util.ArrayList<>(balances.stream().map(balance -> { Map<Long, List<InventoryPosition>> positionsByBalance = balances.isEmpty() ? Map.of()
List<RelabelResponses.InventoryPosition> positions = inventoryPositions.listBalance(customerId, balance.getId()) : inventoryPositions.listBalances(customerId, balances.stream().map(InventoryBalance::getId).toList())
.stream().filter(position -> value(position.getAvailablePackages()) > 0) .stream().filter(position -> value(position.getAvailablePackages()) > 0)
.map(position -> new RelabelResponses.InventoryPosition(position.getId(), position.getPalletNo(), .collect(Collectors.groupingBy(InventoryPosition::getBalanceId, LinkedHashMap::new, Collectors.toList()));
List<RelabelResponses.InventoryCandidate> result = new java.util.ArrayList<>(balances.stream().map(balance -> {
List<RelabelResponses.InventoryPosition> positions = positionsByBalance.getOrDefault(balance.getId(), List.of())
.stream().map(position -> new RelabelResponses.InventoryPosition(position.getId(), position.getPalletNo(),
position.getBatchNo(), position.getWarehouseLocationCode(), value(position.getAvailablePackages()))) position.getBatchNo(), position.getWarehouseLocationCode(), value(position.getAvailablePackages())))
.toList(); .toList();
long available = positions.stream().mapToLong(RelabelResponses.InventoryPosition::availablePackages).sum(); long available = positions.stream().mapToLong(RelabelResponses.InventoryPosition::availablePackages).sum();
@@ -298,14 +301,16 @@ public class RelabelApplicationService implements WalletResultHandler {
cartonLines.stream().mapToLong(line -> value(line.getRelabelledQuantity()) cartonLines.stream().mapToLong(line -> value(line.getRelabelledQuantity())
+ returnCartons.completedSkuQuantity(carton.getId(), line.getSkuCode())).sum()); + returnCartons.completedSkuQuantity(carton.getId(), line.getSkuCode())).sum());
long reserved = returnCartons.relabelReservedQuantity(carton.getId()); long reserved = returnCartons.relabelReservedQuantity(carton.getId());
List<String> mergedCartonMarks = StringUtils.hasText(carton.getSourceReturnNo()) ? List.of()
: returnPackingTraces.listCartonHistory(customerId, carton.getCartonMark()).stream()
.filter(history -> carton.getCartonMark().equals(history.sourceCartonMark()))
.map(history -> history.targetCartonMark()).distinct().toList();
result.add(new RelabelResponses.InventoryCandidate(null, null, carton.getSourceReturnNo(), result.add(new RelabelResponses.InventoryCandidate(null, null, carton.getSourceReturnNo(),
null, carton.getOverseasWarehouseId(), null, null, carton.getDestinationWarehouseCode(), null, carton.getOverseasWarehouseId(), null, null, carton.getDestinationWarehouseCode(),
carton.getDestinationWarehouseName(), skuCodes, productNames, availablePackages, 0, List.of(), carton.getDestinationWarehouseName(), skuCodes, productNames, availablePackages, 0, List.of(),
"PARCEL".equals(carton.getSourceUnitType()) ? "RETURN_PARCEL" : "RETURN_CARTON", carton.getId(), carton.getCartonMark(), cartonSkus, relabelledPackages, "PARCEL".equals(carton.getSourceUnitType()) ? "RETURN_PARCEL" : "RETURN_CARTON", carton.getId(), carton.getCartonMark(), cartonSkus, relabelledPackages,
com.baiyue.lastleg.returnreceipt.service.ReturnRelabelProgress.status(value(carton.getTotalQuantity()), relabelledPackages, reserved), relabelledPackages, reserved, java.util.Set.of("MERGED", "OUTBOUNDED").contains(carton.getStatus()) ? 0L : value(carton.getTotalQuantity()), carton.getStatus(), carton.getRelabelNo(), com.baiyue.lastleg.returnreceipt.service.ReturnRelabelProgress.status(value(carton.getTotalQuantity()), relabelledPackages, reserved), relabelledPackages, reserved, java.util.Set.of("MERGED", "OUTBOUNDED").contains(carton.getStatus()) ? 0L : value(carton.getTotalQuantity()), carton.getStatus(), carton.getRelabelNo(),
returnPackingTraces.listCartonHistory(customerId, carton.getCartonMark()).stream() mergedCartonMarks, returnCartons.hasOutbound(carton.getId()),
.filter(history -> carton.getCartonMark().equals(history.sourceCartonMark()))
.map(history -> history.targetCartonMark()).distinct().toList(), returnCartons.hasOutbound(carton.getId()),
skuConversionRows.listCarton(customerId, carton.getId()).stream() skuConversionRows.listCarton(customerId, carton.getId()).stream()
.map(com.baiyue.lastleg.returnreceipt.dto.ReturnInventoryResponses.SkuConversion::from).toList(), physicalSkus, cartonAvailable)); .map(com.baiyue.lastleg.returnreceipt.dto.ReturnInventoryResponses.SkuConversion::from).toList(), physicalSkus, cartonAvailable));
} }