feat(wms): 钢卷加工必须绑定合同
- 在 WmsMaterialCoilBo 中新增 contractId 字段 - 添加 IWmsCoilContractRelService 依赖注入 - 实现加工操作必须绑定合同的验证逻辑 - 添加分卷、合卷、单个更新等操作的合同验证 - 实现插入钢卷合同关联记录的功能 - 在各种钢卷操作完成后自动插入合同关联记录
This commit is contained in:
@@ -392,6 +392,11 @@ public class WmsMaterialCoilBo extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal theoreticalThickness;
|
||||
|
||||
/**
|
||||
* 合同ID
|
||||
*/
|
||||
private Long contractId;
|
||||
|
||||
/**
|
||||
* 排产厚度(单位:毫米)
|
||||
*/
|
||||
|
||||
@@ -82,6 +82,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
private final WmsDeliveryWaybillDetailMapper deliveryWaybillDetailMapper;
|
||||
private final WmsCoilWarehouseOperationLogMapper wmsCoilWarehouseOperationLogMapper;
|
||||
private final IWmsCoilAbnormalService coilAbnormalService;
|
||||
private final IWmsCoilContractRelService coilContractRelService;
|
||||
private final WmsCoilContractRelMapper coilContractRelMapper;
|
||||
private final WmsCoilQualityRejudgeMapper wmsCoilQualityRejudgeMapper;
|
||||
private final WmsCoilAbnormalMapper coilAbnormalMapper;
|
||||
@@ -2042,6 +2043,11 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
// validateCoilOperationPermission(bo.getCoilId(), "单个更新");
|
||||
// }
|
||||
|
||||
// 加工操作必须绑定合同
|
||||
if (bo.getContractId() == null && StringUtils.isBlank(qrcodeStepType)) {
|
||||
throw new RuntimeException("未填写合同");
|
||||
}
|
||||
|
||||
// 查询原钢卷
|
||||
WmsMaterialCoil oldCoil = baseMapper.selectById(bo.getCoilId());
|
||||
if (oldCoil == null) {
|
||||
@@ -2105,6 +2111,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
throw new RuntimeException("创建新钢卷失败");
|
||||
}
|
||||
|
||||
// 插入合同关联记录
|
||||
insertCoilContractRel(newCoil.getCoilId(), bo.getContractId());
|
||||
|
||||
// 检查长度/厚度偏差并插入告警
|
||||
// 退火工序没有actionId(不创建代操作记录),直接设置actionType=600
|
||||
if ("annealing".equals(qrcodeStepType)) {
|
||||
@@ -2268,7 +2277,6 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
throw new RuntimeException("钢卷已被独占(状态码:" + status + "),无法执行" + operation + "操作");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新(分卷/合卷)
|
||||
* @return 分卷时返回逗号分隔的新钢卷ID字符串,合卷时返回单个新钢卷ID字符串
|
||||
@@ -2333,6 +2341,14 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
throw new RuntimeException("分卷操作需要原钢卷信息");
|
||||
}
|
||||
|
||||
// 加工操作必须绑定合同:检查每个子钢卷是否填写了合同
|
||||
for (int i = 0; i < bo.getNewCoils().size(); i++) {
|
||||
WmsMaterialCoilBo newCoilBo = bo.getNewCoils().get(i);
|
||||
if (newCoilBo.getContractId() == null) {
|
||||
throw new RuntimeException("未填写合同:第" + (i + 1) + "个子钢卷[" + newCoilBo.getCurrentCoilNo() + "]未绑定合同");
|
||||
}
|
||||
}
|
||||
|
||||
// 检查每个子钢卷的当前钢卷号是否重复
|
||||
for (WmsMaterialCoilBo newCoilBo : bo.getNewCoils()) {
|
||||
Map<String, Object> duplicateCheck = checkCoilNoDuplicate(null, null, newCoilBo.getCurrentCoilNo(), null);
|
||||
@@ -2402,6 +2418,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
newCoil.setParentCoilId(String.valueOf(oldCoil.getCoilId()));
|
||||
baseMapper.insert(newCoil);
|
||||
|
||||
// 插入合同关联记录
|
||||
insertCoilContractRel(newCoil.getCoilId(), newCoilBo.getContractId());
|
||||
|
||||
// 检查长度/厚度偏差并插入告警
|
||||
newCoilBo.setActionId(bo.getCoilId());
|
||||
materialWarningService.checkAndInsertWarnings(newCoil, newCoilBo);
|
||||
@@ -2463,6 +2482,11 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
//在合卷之前需要判断前端传来的bo.getNewCoils()中的所有原始钢卷的coilId是否已经是历史卷
|
||||
validateOriginalCoilsForMerge(bo.getNewCoils());
|
||||
|
||||
// 加工操作必须绑定合同
|
||||
if (bo.getContractId() == null) {
|
||||
throw new RuntimeException("未填写合同");
|
||||
}
|
||||
|
||||
// 检查合卷后新钢卷的当前钢卷号是否重复
|
||||
if (StringUtils.isNotBlank(bo.getCurrentCoilNo())) {
|
||||
Map<String, Object> duplicateCheck = checkCoilNoDuplicate(null, null, bo.getCurrentCoilNo(), null);
|
||||
@@ -2553,6 +2577,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
|
||||
baseMapper.insert(newCoil);
|
||||
|
||||
// 插入合同关联记录
|
||||
insertCoilContractRel(newCoil.getCoilId(), bo.getContractId());
|
||||
|
||||
// 检查长度/厚度偏差并插入告警
|
||||
bo.setActionId(bo.getNewCoils().get(0).getActionId());
|
||||
materialWarningService.checkAndInsertWarnings(newCoil, bo);
|
||||
@@ -3029,6 +3056,18 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入钢卷合同关联记录
|
||||
*/
|
||||
private void insertCoilContractRel(Long coilId, Long contractId) {
|
||||
if (contractId != null) {
|
||||
WmsCoilContractRelBo relBo = new WmsCoilContractRelBo();
|
||||
relBo.setCoilId(coilId);
|
||||
relBo.setContractId(contractId);
|
||||
coilContractRelService.insertByBo(relBo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
@@ -5344,6 +5383,11 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
throw new RuntimeException("钢卷不存在");
|
||||
}
|
||||
|
||||
// 加工操作必须绑定合同
|
||||
if (childCoilBo.getContractId() == null) {
|
||||
throw new RuntimeException("未填写合同");
|
||||
}
|
||||
|
||||
// 2. 验证独占状态
|
||||
if (parentCoil.getExclusiveStatus() == null || parentCoil.getExclusiveStatus() != 1) {
|
||||
throw new RuntimeException("钢卷未处于分卷状态");
|
||||
@@ -5422,6 +5466,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
childCoil.setParentCoilId(String.valueOf(parentCoilId));
|
||||
baseMapper.insert(childCoil);
|
||||
|
||||
// 插入合同关联记录
|
||||
insertCoilContractRel(childCoil.getCoilId(), childCoilBo.getContractId());
|
||||
|
||||
// 检查长度/厚度偏差并插入告警
|
||||
childCoilBo.setActionId(pendingActionId);
|
||||
materialWarningService.checkAndInsertWarnings(childCoil, childCoilBo);
|
||||
|
||||
Reference in New Issue
Block a user