This commit is contained in:
2026-09-22 14:26:46 +08:00
parent 2813be3581
commit 81517945f6
4 changed files with 27 additions and 6 deletions
@@ -43,7 +43,7 @@ public class OpenApiInboundMeasurementController {
private MojiaMeasurementOpenApiService mojiaService;
@Operation(summary = "墨家设备按箱码上传单箱测量结果",
description = "首轮联调使用固定 X-App-Key;JSON 中 picture 为 JPEG Data URL,boxCode 原样取自设备条码;带 # 的箱唛继续走箱唛测量,不带 # 的 SKU 进入一件代发 SKU 同步收件;weightKg 为 kg")
description = "首轮联调使用固定 X-App-Key;JSON 中 picture 为 JPEG Data URL,boxCode 原样取自设备条码;带 # 的箱唛继续走箱唛测量,不带 # 的 SKU 进入SKU同步收件;weightKg 为 kg")
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
public ApiResponse<UploadResponse> receiveMojia(
@RequestHeader("X-App-Key") String appKey,
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import feign.FeignException;
import org.springframework.dao.DataAccessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -99,7 +100,7 @@ public class InboundMeasurementService {
? List.of() : repository.listItems(tenantId, measurement.getId());
List<InboundWeightResultEntity> weights = repository.listWeights(tenantId, inbound.getId());
List<com.baiyue.firstleg.entity.InboundPalletAllocationEntity> allocationSlots =
palletAllocations.list(tenantId, inbound.getId());
loadAllocationSlotsForDetail(tenantId, inbound.getId());
Map<Long, com.baiyue.firstleg.entity.InboundPalletAllocationEntity> allocationsByWeight =
allocationSlots.stream()
.filter(item -> item.getWeightResultId() != null)
@@ -605,8 +606,28 @@ public class InboundMeasurementService {
}
private boolean customerFeeConfirmed(long tenantId, long inboundId) {
var latestFee = pricingRepository.findLatestFee(tenantId, inboundId);
return latestFee != null && latestFee.getCustomerConfirmedAt() != null;
try {
var latestFee = pricingRepository.findLatestFee(tenantId, inboundId);
return latestFee != null && latestFee.getCustomerConfirmedAt() != null;
} catch (DataAccessException exception) {
// Fee confirmation is an edit-lock hint only; it must not prevent opening the review page.
LOGGER.warn("读取入库费用确认状态失败,继续返回测量详情: tenantId={}, inboundId={}",
tenantId, inboundId, exception);
return false;
}
}
private List<com.baiyue.firstleg.entity.InboundPalletAllocationEntity> loadAllocationSlotsForDetail(
long tenantId, long inboundId) {
try {
return palletAllocations.list(tenantId, inboundId);
} catch (DataAccessException exception) {
// The location guide is supplementary evidence. A missing/old allocation table must not
// turn a measurement review read into an opaque 500 response.
LOGGER.warn("读取入库库位分配快照失败,继续返回测量详情: tenantId={}, inboundId={}",
tenantId, inboundId, exception);
return List.of();
}
}
private static InboundMeasurementResponses.PalletLocationGuide toPalletLocationGuide(
@@ -81,7 +81,7 @@ public class MojiaMeasurementOpenApiService {
}
long machineWarehouseId = requireMachineWarehouse(app, request.machineNo());
// 墨家同一个 boxCode 字段同时承载箱唛和 SKU:带 # 的继续走既有箱唛链路,
// 不带 # 的只进入一件代发 SKU 同步收件,不得误走箱码匹配。
// 不带 # 的只进入SKU同步收件,不得误走箱码匹配。
if (!request.boxCode().contains("#")) {
return saveSkuPending(app, request, image);
}