This commit is contained in:
2026-06-13 11:15:42 +08:00
2 changed files with 16 additions and 5 deletions

View File

@@ -1870,6 +1870,10 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
}
// 检查长度/厚度偏差并插入告警
// 退火工序没有actionId不创建代操作记录直接设置actionType=600
if ("annealing".equals(qrcodeStepType)) {
bo.setActionType(600);
}
materialWarningService.checkAndInsertWarnings(newCoil, bo);
// 如果实际库区id为-1则清空钢卷上的实际库区绑定

View File

@@ -198,6 +198,10 @@ public class WmsMaterialWarningServiceImpl implements IWmsMaterialWarningService
log.warn("查询产线类型失败, actionId={}", bo.getActionId(), e);
}
}
// 兜底如果没有actionId如退火工序不创建代操作记录直接使用bo中的actionType
if (actionType == null && bo != null && bo.getActionType() != null) {
actionType = bo.getActionType();
}
if (actionType != null) {
for (WmsMaterialWarning w : warnings) {
w.setActionType(actionType);
@@ -281,16 +285,19 @@ public class WmsMaterialWarningServiceImpl implements IWmsMaterialWarningService
}
// 理论厚度 - 规格厚度 > 阈值 → 触发
BigDecimal diff = theoreticalThickness.subtract(specThickness);
if (diff.compareTo(threshold) > 0) {
// 先统一 round 到 3 位小数再比较,避免理论厚度公式计算引入的高精度尾数
// 导致比较结果与存储值不一致(如 diff=-0.0096 > -0.01 触发,但存储时都 round 成 -0.010
BigDecimal diff = theoreticalThickness.subtract(specThickness).setScale(3, RoundingMode.HALF_UP);
BigDecimal scaledThreshold = threshold.setScale(3, RoundingMode.HALF_UP);
if (diff.compareTo(scaledThreshold) > 0) {
WmsMaterialWarning warning = new WmsMaterialWarning();
warning.setCoilId(coil.getCoilId());
warning.setWarningType("THICKNESS");
warning.setTheoreticalVal(theoreticalThickness.setScale(3, RoundingMode.HALF_UP));
warning.setActualVal(specThickness.setScale(3, RoundingMode.HALF_UP));
warning.setAllowDeviation(threshold.setScale(3, RoundingMode.HALF_UP));
warning.setDeviationValue(theoreticalThickness.subtract(specThickness).setScale(3, RoundingMode.HALF_UP));
BigDecimal rate = diff.divide(specThickness, 10, RoundingMode.HALF_UP)
warning.setAllowDeviation(scaledThreshold);
warning.setDeviationValue(diff);
BigDecimal rate = diff.divide(specThickness.setScale(3, RoundingMode.HALF_UP), 10, RoundingMode.HALF_UP)
.multiply(new BigDecimal("100")).setScale(1, RoundingMode.HALF_UP);
warning.setDeviationRate(rate);
warning.setWarningLevel("WARNING");