装柜修改
This commit is contained in:
@@ -247,7 +247,7 @@ public class InboundOrderRepository {
|
||||
Function.identity(), (left, right) -> left));
|
||||
}
|
||||
|
||||
private Map<Long, String> locationCodesMap(Long tenantId, Map<Long, Long> tenantByInbound) {
|
||||
public Map<Long, String> locationCodesMap(Long tenantId, Map<Long, Long> tenantByInbound) {
|
||||
if (tenantByInbound.isEmpty()) {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
+8
-6
@@ -33,10 +33,13 @@ public class InboundPalletAllocationRepository {
|
||||
.eq(InboundPalletAllocationEntity::getInboundId, inboundId));
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
int allocationCount = result.allocations().size();
|
||||
int perAllocation = allocationCount == 0 ? 0
|
||||
: (int) Math.ceil((double) totalPackageCount / allocationCount);
|
||||
int remaining = totalPackageCount;
|
||||
for (var source : result.allocations()) {
|
||||
if (allocationCount > totalPackageCount) {
|
||||
throw new IllegalArgumentException("托盘数量不能超过入库单总箱数");
|
||||
}
|
||||
int basePackageCount = allocationCount == 0 ? 0 : totalPackageCount / allocationCount;
|
||||
int remainder = allocationCount == 0 ? 0 : totalPackageCount % allocationCount;
|
||||
for (int index = 0; index < result.allocations().size(); index++) {
|
||||
var source = result.allocations().get(index);
|
||||
InboundPalletAllocationEntity value = new InboundPalletAllocationEntity();
|
||||
value.setTenantId(tenantId);
|
||||
value.setInboundId(inboundId);
|
||||
@@ -47,10 +50,9 @@ public class InboundPalletAllocationRepository {
|
||||
value.setPalletCode(source.palletCode());
|
||||
value.setPalletCapacityCbm(capacity);
|
||||
value.setAllocatedVolumeCbm(source.allocatedVolumeCbm());
|
||||
int allocatedPackages = Math.min(perAllocation, remaining);
|
||||
int allocatedPackages = basePackageCount + (index < remainder ? 1 : 0);
|
||||
value.setAllocatedPackageCount(allocatedPackages);
|
||||
value.setPickedPackageCount(0);
|
||||
remaining -= allocatedPackages;
|
||||
value.setLocationId(source.locationId());
|
||||
value.setLocationCode(source.locationCode());
|
||||
value.setReservationId(source.reservationId());
|
||||
|
||||
+10
-9
@@ -7,6 +7,7 @@ import com.baiyue.firstleg.entity.InboundOutboxEntity;
|
||||
import com.baiyue.firstleg.repository.FinanceFeeSourceOutboxRepository;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import feign.FeignException;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -32,19 +33,19 @@ public class FinanceFeeSourceOutboxRelay {
|
||||
FinanceFeeSourceOutboxService.ADJUSTED,
|
||||
FinanceFeeSourceOutboxService.VOIDED);
|
||||
|
||||
private final FinanceFeeSourceOutboxRepository repository;
|
||||
private final FinanceFeeSourceEventClient client;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final Clock clock;
|
||||
private final String workerId;
|
||||
@Resource
|
||||
private FinanceFeeSourceOutboxRepository repository;
|
||||
@Resource
|
||||
private FinanceFeeSourceEventClient client;
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
private Clock clock = Clock.systemDefaultZone();
|
||||
private String workerId = UUID.randomUUID().toString();
|
||||
@Value("${baiyue.security.internal-service-token}")
|
||||
private String internalToken;
|
||||
|
||||
@Autowired
|
||||
public FinanceFeeSourceOutboxRelay(FinanceFeeSourceOutboxRepository repository,
|
||||
FinanceFeeSourceEventClient client,
|
||||
ObjectMapper objectMapper) {
|
||||
this(repository, client, objectMapper, Clock.systemDefaultZone(), UUID.randomUUID().toString());
|
||||
public FinanceFeeSourceOutboxRelay() {
|
||||
}
|
||||
|
||||
FinanceFeeSourceOutboxRelay(FinanceFeeSourceOutboxRepository repository,
|
||||
|
||||
+5
-1
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class MeasurementLocationOccupationService {
|
||||
@@ -38,7 +39,10 @@ public class MeasurementLocationOccupationService {
|
||||
long warehouseId = requireWarehouse(order);
|
||||
long resourceTenantId = PLATFORM_WAREHOUSE_RESOURCE_TENANT_ID;
|
||||
BigDecimal volume = requireVolume(order);
|
||||
String key = "measure-" + inboundId + "-" + measurementId + "-" + measurementVersion;
|
||||
// 补偿释放后的预占记录需要保留审计,失败重试必须使用新的物理预占键;
|
||||
// 若仍存在活动预占,仓储侧会按业务单据复用,不会创建新的资源占用。
|
||||
String key = "measure-" + inboundId + "-" + measurementId + "-" + measurementVersion
|
||||
+ "-" + UUID.randomUUID();
|
||||
WarehousePalletLocationClient.BatchResult reserved = requireSuccess(call(() -> warehouse.reserve(
|
||||
internalToken, new WarehousePalletLocationClient.ReserveRequest(resourceTenantId, warehouseId,
|
||||
SOURCE_SERVICE, inboundId, order.getInboundCode(), key, operatorId, volume,
|
||||
|
||||
@@ -79,7 +79,7 @@ public class UnifiedInboundQueryService {
|
||||
}
|
||||
InboundTransportSnapshotEntity transport = includePhaseThree
|
||||
? operations.findTransport(tenantId, inbound.getId()) : null;
|
||||
return new UnifiedInboundDetail(summary(inbound, detail, preload, pick, evidence, deliveryAt, transport), timeline);
|
||||
return new UnifiedInboundDetail(summary(inbound, detail, preload, pick, evidence, deliveryAt, transport, null), timeline);
|
||||
}
|
||||
|
||||
private List<UnifiedInboundSummary> summaries(List<InboundOrderEntity> records) {
|
||||
@@ -92,17 +92,20 @@ public class UnifiedInboundQueryService {
|
||||
var evidences = operations.findEvidence(phaseThreeOwners);
|
||||
var deliveries = operations.findDeliveryHistory(phaseThreeOwners);
|
||||
var transports = operations.findTransports(phaseThreeOwners);
|
||||
Map<Long, Long> owners = records.stream().collect(Collectors.toMap(
|
||||
InboundOrderEntity::getId, InboundOrderEntity::getTenantId, (left, right) -> left));
|
||||
var locationCodes = inbounds.locationCodesMap(null, owners);
|
||||
return records.stream().map(inbound -> summary(inbound, null, preloads.get(inbound.getId()),
|
||||
picks.get(inbound.getId()), evidences.getOrDefault(inbound.getId(), List.of()),
|
||||
deliveries.get(inbound.getId()) == null ? null : deliveries.get(inbound.getId()).getOccurredAt(),
|
||||
transports.get(inbound.getId()))).toList();
|
||||
transports.get(inbound.getId()), locationCodes.get(inbound.getId()))).toList();
|
||||
}
|
||||
|
||||
private UnifiedInboundSummary summary(InboundOrderEntity inbound, InboundOrderDetail detail,
|
||||
com.baiyue.firstleg.split.entity.PreloadPlanEntity preload,
|
||||
com.baiyue.firstleg.loading.entity.InboundLoadingPickTaskEntity pick,
|
||||
List<LoadingEvidenceEntity> evidence, LocalDateTime deliveryAt,
|
||||
InboundTransportSnapshotEntity transport) {
|
||||
InboundTransportSnapshotEntity transport, String locationCodes) {
|
||||
String mainStatus = mainStatus(inbound.getProcessStatus());
|
||||
List<LoadingEvidenceEntity> activeEvidence = evidence.stream()
|
||||
.filter(item -> item.getStatus() == null || "ACTIVE".equals(item.getStatus())).toList();
|
||||
@@ -121,7 +124,7 @@ public class UnifiedInboundQueryService {
|
||||
"DELIVERED".equals(mainStatus) ? "COMPLETED" : "PENDING", deliveryAt,
|
||||
inbound.getExpressTrackingNo()) : null;
|
||||
var inboundSummary = detail == null
|
||||
? com.baiyue.firstleg.dto.InboundOrderSummary.from(inbound, transport, null) : detail.summary();
|
||||
? com.baiyue.firstleg.dto.InboundOrderSummary.from(inbound, transport, locationCodes) : detail.summary();
|
||||
return new UnifiedInboundSummary(inboundSummary, mainStatus,
|
||||
nextAction(mainStatus, inbound.getProcessStatus(), preload == null ? null : preload.getStatus()),
|
||||
preloadSummary, loadingSummary, deliverySummary);
|
||||
|
||||
Reference in New Issue
Block a user