fix: gate device scans by actual measurement submission state
This commit is contained in:
@@ -147,7 +147,7 @@ public class CartonMeasurementService {
|
||||
if (inbound == null) {
|
||||
throw new BizException(ResultCode.NOT_FOUND, "入库单不存在");
|
||||
}
|
||||
if (!DEVICE_WRITABLE_STATUSES.contains(inbound.getProcessStatus())) {
|
||||
if (!deviceWritable(inbound, tenantId)) {
|
||||
throw new BizException(ResultCode.CONFLICT, "测量已提交,设备不能新增或覆盖数据");
|
||||
}
|
||||
InboundMeasurementItemEntity item = repository.findItemByBoxCode(tenantId, boxCode);
|
||||
@@ -245,7 +245,6 @@ public class CartonMeasurementService {
|
||||
item.setTotalVolumeCbm(totalVolume);
|
||||
item.setVolumeWeightKg(totalVolume.multiply(VOLUME_WEIGHT_FACTOR).setScale(3, RoundingMode.CEILING));
|
||||
item.setCalculationRuleVersion(weighted.calculationRuleVersion());
|
||||
item.setOverLimitWarning(weighted.warning());
|
||||
item.setOuterLengthCm(weighted.outerLengthCm());
|
||||
item.setOuterWidthCm(weighted.outerWidthCm());
|
||||
item.setOuterHeightCm(weighted.outerHeightCm());
|
||||
@@ -306,12 +305,25 @@ public class CartonMeasurementService {
|
||||
if (inbound == null) {
|
||||
throw new BizException(ResultCode.NOT_FOUND, "入库单不存在");
|
||||
}
|
||||
if (!DEVICE_WRITABLE_STATUSES.contains(inbound.getProcessStatus())) {
|
||||
if (!deviceWritable(inbound, tenantId)) {
|
||||
throw new BizException(ResultCode.CONFLICT, "测量已提交,设备不能新增或覆盖数据");
|
||||
}
|
||||
return inbound;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备回传门禁以入库流程状态为主,并用测量批次状态兜底校验提交语义。
|
||||
* RECEIVED/DRAFT 只是设备资料,不能把处于 WAIT_MEASURE 的入库单误判为已提交;
|
||||
* SUBMITTED/APPROVED 则必须继续保留设备覆盖保护,即使旧数据的主状态快照滞后。
|
||||
*/
|
||||
private boolean deviceWritable(InboundOrderEntity inbound, long tenantId) {
|
||||
if (!DEVICE_WRITABLE_STATUSES.contains(inbound.getProcessStatus())) {
|
||||
return false;
|
||||
}
|
||||
InboundMeasurementEntity latest = repository.findLatestMeasurement(tenantId, inbound.getId());
|
||||
return latest == null || !Set.of("SUBMITTED", "APPROVED").contains(latest.getStatus());
|
||||
}
|
||||
|
||||
private InboundOrderEntity requireManualCountEditableInbound(long tenantId, long inboundId) {
|
||||
InboundOrderEntity inbound = repository.findInbound(tenantId, inboundId);
|
||||
if (inbound == null) {
|
||||
|
||||
Reference in New Issue
Block a user