Commit 832e8feb01d83aa4565b8b94f397c331aa44d506
1 parent
613abe9a
✨ feat(mes): 重构物料和产品的校验逻辑,简化数据校验流程
将物料和产品的校验逻辑集中到新的方法中,提升代码可读性和维护性。通过统一的校验方法,减少重复代码,提高了代码的整洁性和一致性。
Showing
9 changed files
with
128 additions
and
120 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemServiceImpl.java
| @@ -62,14 +62,8 @@ public class MesMdItemServiceImpl implements MesMdItemService { | @@ -62,14 +62,8 @@ public class MesMdItemServiceImpl implements MesMdItemService { | ||
| 62 | 62 | ||
| 63 | @Override | 63 | @Override |
| 64 | public Long createItem(MesMdItemSaveReqVO createReqVO) { | 64 | public Long createItem(MesMdItemSaveReqVO createReqVO) { |
| 65 | - // 校验物料编码的唯一性 | ||
| 66 | - validateItemCodeUnique(null, createReqVO.getCode()); | ||
| 67 | - // 校验物料名称的唯一性 | ||
| 68 | - validateItemNameUnique(null, createReqVO.getName()); | ||
| 69 | - // 校验物料分类存在 | ||
| 70 | - validateItemTypeExists(createReqVO.getItemTypeId()); | ||
| 71 | - // 校验计量单位存在 | ||
| 72 | - validateUnitMeasureExists(createReqVO.getUnitMeasureId()); | 65 | + // 校验数据 |
| 66 | + validateItemSaveData(createReqVO); | ||
| 73 | 67 | ||
| 74 | // 插入 | 68 | // 插入 |
| 75 | MesMdItemDO item = BeanUtils.toBean(createReqVO, MesMdItemDO.class); | 69 | MesMdItemDO item = BeanUtils.toBean(createReqVO, MesMdItemDO.class); |
| @@ -87,14 +81,8 @@ public class MesMdItemServiceImpl implements MesMdItemService { | @@ -87,14 +81,8 @@ public class MesMdItemServiceImpl implements MesMdItemService { | ||
| 87 | public void updateItem(MesMdItemSaveReqVO updateReqVO) { | 81 | public void updateItem(MesMdItemSaveReqVO updateReqVO) { |
| 88 | // 校验存在 | 82 | // 校验存在 |
| 89 | validateItemExists(updateReqVO.getId()); | 83 | validateItemExists(updateReqVO.getId()); |
| 90 | - // 校验物料编码的唯一性 | ||
| 91 | - validateItemCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 92 | - // 校验物料名称的唯一性 | ||
| 93 | - validateItemNameUnique(updateReqVO.getId(), updateReqVO.getName()); | ||
| 94 | - // 校验物料分类存在 | ||
| 95 | - validateItemTypeExists(updateReqVO.getItemTypeId()); | ||
| 96 | - // 校验计量单位存在 | ||
| 97 | - validateUnitMeasureExists(updateReqVO.getUnitMeasureId()); | 84 | + // 校验数据 |
| 85 | + validateItemSaveData(updateReqVO); | ||
| 98 | 86 | ||
| 99 | // 更新 | 87 | // 更新 |
| 100 | MesMdItemDO updateObj = BeanUtils.toBean(updateReqVO, MesMdItemDO.class); | 88 | MesMdItemDO updateObj = BeanUtils.toBean(updateReqVO, MesMdItemDO.class); |
| @@ -102,6 +90,17 @@ public class MesMdItemServiceImpl implements MesMdItemService { | @@ -102,6 +90,17 @@ public class MesMdItemServiceImpl implements MesMdItemService { | ||
| 102 | itemMapper.updateById(updateObj); | 90 | itemMapper.updateById(updateObj); |
| 103 | } | 91 | } |
| 104 | 92 | ||
| 93 | + private void validateItemSaveData(MesMdItemSaveReqVO reqVO) { | ||
| 94 | + // 校验物料编码的唯一性 | ||
| 95 | + validateItemCodeUnique(reqVO.getId(), reqVO.getCode()); | ||
| 96 | + // 校验物料名称的唯一性 | ||
| 97 | + validateItemNameUnique(reqVO.getId(), reqVO.getName()); | ||
| 98 | + // 校验物料分类存在 | ||
| 99 | + validateItemTypeExists(reqVO.getItemTypeId()); | ||
| 100 | + // 校验计量单位存在 | ||
| 101 | + validateUnitMeasureExists(reqVO.getUnitMeasureId()); | ||
| 102 | + } | ||
| 103 | + | ||
| 105 | @Override | 104 | @Override |
| 106 | public void updateItemStatus(Long id, Integer status) { | 105 | public void updateItemStatus(Long id, Integer status) { |
| 107 | // 校验存在 | 106 | // 校验存在 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java
| @@ -35,12 +35,8 @@ public class MesMdItemTypeServiceImpl implements MesMdItemTypeService { | @@ -35,12 +35,8 @@ public class MesMdItemTypeServiceImpl implements MesMdItemTypeService { | ||
| 35 | 35 | ||
| 36 | @Override | 36 | @Override |
| 37 | public Long createItemType(MesMdItemTypeSaveReqVO createReqVO) { | 37 | public Long createItemType(MesMdItemTypeSaveReqVO createReqVO) { |
| 38 | - // 校验父分类编号的有效性 | ||
| 39 | - validateParentItemType(null, createReqVO.getParentId()); | ||
| 40 | - // 校验分类名称的唯一性 | ||
| 41 | - validateItemTypeNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); | ||
| 42 | - // 校验分类编码的唯一性 | ||
| 43 | - validateItemTypeCodeUnique(null, createReqVO.getParentId(), createReqVO.getCode()); | 38 | + // 校验数据 |
| 39 | + validateItemTypeSaveData(createReqVO); | ||
| 44 | 40 | ||
| 45 | // 插入 | 41 | // 插入 |
| 46 | MesMdItemTypeDO itemType = BeanUtils.toBean(createReqVO, MesMdItemTypeDO.class); | 42 | MesMdItemTypeDO itemType = BeanUtils.toBean(createReqVO, MesMdItemTypeDO.class); |
| @@ -52,18 +48,23 @@ public class MesMdItemTypeServiceImpl implements MesMdItemTypeService { | @@ -52,18 +48,23 @@ public class MesMdItemTypeServiceImpl implements MesMdItemTypeService { | ||
| 52 | public void updateItemType(MesMdItemTypeSaveReqVO updateReqVO) { | 48 | public void updateItemType(MesMdItemTypeSaveReqVO updateReqVO) { |
| 53 | // 校验存在 | 49 | // 校验存在 |
| 54 | validateItemTypeExists(updateReqVO.getId()); | 50 | validateItemTypeExists(updateReqVO.getId()); |
| 55 | - // 校验父分类编号的有效性 | ||
| 56 | - validateParentItemType(updateReqVO.getId(), updateReqVO.getParentId()); | ||
| 57 | - // 校验分类名称的唯一性 | ||
| 58 | - validateItemTypeNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); | ||
| 59 | - // 校验分类编码的唯一性 | ||
| 60 | - validateItemTypeCodeUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getCode()); | 51 | + // 校验数据 |
| 52 | + validateItemTypeSaveData(updateReqVO); | ||
| 61 | 53 | ||
| 62 | // 更新 | 54 | // 更新 |
| 63 | MesMdItemTypeDO updateObj = BeanUtils.toBean(updateReqVO, MesMdItemTypeDO.class); | 55 | MesMdItemTypeDO updateObj = BeanUtils.toBean(updateReqVO, MesMdItemTypeDO.class); |
| 64 | itemTypeMapper.updateById(updateObj); | 56 | itemTypeMapper.updateById(updateObj); |
| 65 | } | 57 | } |
| 66 | 58 | ||
| 59 | + private void validateItemTypeSaveData(MesMdItemTypeSaveReqVO reqVO) { | ||
| 60 | + // 校验父分类编号的有效性 | ||
| 61 | + validateParentItemType(reqVO.getId(), reqVO.getParentId()); | ||
| 62 | + // 校验分类名称的唯一性 | ||
| 63 | + validateItemTypeNameUnique(reqVO.getId(), reqVO.getParentId(), reqVO.getName()); | ||
| 64 | + // 校验分类编码的唯一性 | ||
| 65 | + validateItemTypeCodeUnique(reqVO.getId(), reqVO.getParentId(), reqVO.getCode()); | ||
| 66 | + } | ||
| 67 | + | ||
| 67 | @Override | 68 | @Override |
| 68 | public void deleteItemType(Long id) { | 69 | public void deleteItemType(Long id) { |
| 69 | // 1.1 校验存在 | 70 | // 1.1 校验存在 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdProductBomServiceImpl.java
| @@ -36,15 +36,9 @@ public class MesMdProductBomServiceImpl implements MesMdProductBomService { | @@ -36,15 +36,9 @@ public class MesMdProductBomServiceImpl implements MesMdProductBomService { | ||
| 36 | 36 | ||
| 37 | @Override | 37 | @Override |
| 38 | public Long createProductBom(MesMdProductBomSaveReqVO createReqVO) { | 38 | public Long createProductBom(MesMdProductBomSaveReqVO createReqVO) { |
| 39 | - // 1.1 校验物料产品存在 | ||
| 40 | - validateItemExists(createReqVO.getItemId()); | ||
| 41 | - // 1.2 校验BOM物料存在 | ||
| 42 | - validateItemExists(createReqVO.getBomItemId()); | ||
| 43 | - // 1.3 校验不能自引用 | ||
| 44 | - if (createReqVO.getItemId().equals(createReqVO.getBomItemId())) { | ||
| 45 | - throw exception(MD_PRODUCT_BOM_SELF_REFERENCE); | ||
| 46 | - } | ||
| 47 | - // 1.4 校验不能形成闭环 | 39 | + // 1.1 校验数据 |
| 40 | + validateProductBomSaveData(createReqVO); | ||
| 41 | + // 1.2 校验不能形成闭环 | ||
| 48 | if (hasBomCycle(createReqVO.getItemId(), createReqVO.getBomItemId())) { | 42 | if (hasBomCycle(createReqVO.getItemId(), createReqVO.getBomItemId())) { |
| 49 | throw exception(MD_PRODUCT_BOM_CIRCULAR); | 43 | throw exception(MD_PRODUCT_BOM_CIRCULAR); |
| 50 | } | 44 | } |
| @@ -59,20 +53,25 @@ public class MesMdProductBomServiceImpl implements MesMdProductBomService { | @@ -59,20 +53,25 @@ public class MesMdProductBomServiceImpl implements MesMdProductBomService { | ||
| 59 | public void updateProductBom(MesMdProductBomSaveReqVO updateReqVO) { | 53 | public void updateProductBom(MesMdProductBomSaveReqVO updateReqVO) { |
| 60 | // 1.1 校验存在 | 54 | // 1.1 校验存在 |
| 61 | validateProductBomExists(updateReqVO.getId()); | 55 | validateProductBomExists(updateReqVO.getId()); |
| 62 | - // 1.2 校验物料产品存在 | ||
| 63 | - validateItemExists(updateReqVO.getItemId()); | ||
| 64 | - // 1.3 校验BOM物料存在 | ||
| 65 | - validateItemExists(updateReqVO.getBomItemId()); | ||
| 66 | - // 1.4 校验不能自引用 | ||
| 67 | - if (updateReqVO.getItemId().equals(updateReqVO.getBomItemId())) { | ||
| 68 | - throw exception(MD_PRODUCT_BOM_SELF_REFERENCE); | ||
| 69 | - } | 56 | + // 1.2 校验数据 |
| 57 | + validateProductBomSaveData(updateReqVO); | ||
| 70 | 58 | ||
| 71 | // 更新 | 59 | // 更新 |
| 72 | MesMdProductBomDO updateObj = BeanUtils.toBean(updateReqVO, MesMdProductBomDO.class); | 60 | MesMdProductBomDO updateObj = BeanUtils.toBean(updateReqVO, MesMdProductBomDO.class); |
| 73 | productBomMapper.updateById(updateObj); | 61 | productBomMapper.updateById(updateObj); |
| 74 | } | 62 | } |
| 75 | 63 | ||
| 64 | + private void validateProductBomSaveData(MesMdProductBomSaveReqVO reqVO) { | ||
| 65 | + // 校验物料产品存在 | ||
| 66 | + validateItemExists(reqVO.getItemId()); | ||
| 67 | + // 校验BOM物料存在 | ||
| 68 | + validateItemExists(reqVO.getBomItemId()); | ||
| 69 | + // 校验不能自引用 | ||
| 70 | + if (reqVO.getItemId().equals(reqVO.getBomItemId())) { | ||
| 71 | + throw exception(MD_PRODUCT_BOM_SELF_REFERENCE); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 76 | @Override | 75 | @Override |
| 77 | public void deleteProductBom(Long id) { | 76 | public void deleteProductBom(Long id) { |
| 78 | // 校验存在 | 77 | // 校验存在 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdProductSipServiceImpl.java
| @@ -33,12 +33,8 @@ public class MesMdProductSipServiceImpl implements MesMdProductSipService { | @@ -33,12 +33,8 @@ public class MesMdProductSipServiceImpl implements MesMdProductSipService { | ||
| 33 | 33 | ||
| 34 | @Override | 34 | @Override |
| 35 | public Long createProductSip(MesMdProductSipSaveReqVO createReqVO) { | 35 | public Long createProductSip(MesMdProductSipSaveReqVO createReqVO) { |
| 36 | - // 校验排列顺序的唯一性 | ||
| 37 | - validateSortUnique(createReqVO.getItemId(), createReqVO.getSort(), null); | ||
| 38 | - // 校验工序存在 | ||
| 39 | - if (createReqVO.getProcessId() != null) { | ||
| 40 | - processService.validateProcessExists(createReqVO.getProcessId()); | ||
| 41 | - } | 36 | + // 校验数据 |
| 37 | + validateProductSipSaveData(createReqVO, null); | ||
| 42 | 38 | ||
| 43 | // 插入 | 39 | // 插入 |
| 44 | MesMdProductSipDO sip = BeanUtils.toBean(createReqVO, MesMdProductSipDO.class); | 40 | MesMdProductSipDO sip = BeanUtils.toBean(createReqVO, MesMdProductSipDO.class); |
| @@ -50,18 +46,23 @@ public class MesMdProductSipServiceImpl implements MesMdProductSipService { | @@ -50,18 +46,23 @@ public class MesMdProductSipServiceImpl implements MesMdProductSipService { | ||
| 50 | public void updateProductSip(MesMdProductSipSaveReqVO updateReqVO) { | 46 | public void updateProductSip(MesMdProductSipSaveReqVO updateReqVO) { |
| 51 | // 校验存在 | 47 | // 校验存在 |
| 52 | validateProductSipExists(updateReqVO.getId()); | 48 | validateProductSipExists(updateReqVO.getId()); |
| 53 | - // 校验排列顺序的唯一性 | ||
| 54 | - validateSortUnique(updateReqVO.getItemId(), updateReqVO.getSort(), updateReqVO.getId()); | ||
| 55 | - // 校验工序存在 | ||
| 56 | - if (updateReqVO.getProcessId() != null) { | ||
| 57 | - processService.validateProcessExists(updateReqVO.getProcessId()); | ||
| 58 | - } | 49 | + // 校验数据 |
| 50 | + validateProductSipSaveData(updateReqVO, updateReqVO.getId()); | ||
| 59 | 51 | ||
| 60 | // 更新 | 52 | // 更新 |
| 61 | MesMdProductSipDO updateObj = BeanUtils.toBean(updateReqVO, MesMdProductSipDO.class); | 53 | MesMdProductSipDO updateObj = BeanUtils.toBean(updateReqVO, MesMdProductSipDO.class); |
| 62 | productSipMapper.updateById(updateObj); | 54 | productSipMapper.updateById(updateObj); |
| 63 | } | 55 | } |
| 64 | 56 | ||
| 57 | + private void validateProductSipSaveData(MesMdProductSipSaveReqVO reqVO, Long excludeId) { | ||
| 58 | + // 校验排列顺序的唯一性 | ||
| 59 | + validateSortUnique(reqVO.getItemId(), reqVO.getSort(), excludeId); | ||
| 60 | + // 校验工序存在 | ||
| 61 | + if (reqVO.getProcessId() != null) { | ||
| 62 | + processService.validateProcessExists(reqVO.getProcessId()); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 65 | @Override | 66 | @Override |
| 66 | public void deleteProductSip(Long id) { | 67 | public void deleteProductSip(Long id) { |
| 67 | // 校验存在 | 68 | // 校验存在 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdProductSopServiceImpl.java
| @@ -33,12 +33,8 @@ public class MesMdProductSopServiceImpl implements MesMdProductSopService { | @@ -33,12 +33,8 @@ public class MesMdProductSopServiceImpl implements MesMdProductSopService { | ||
| 33 | 33 | ||
| 34 | @Override | 34 | @Override |
| 35 | public Long createProductSop(MesMdProductSopSaveReqVO createReqVO) { | 35 | public Long createProductSop(MesMdProductSopSaveReqVO createReqVO) { |
| 36 | - // 校验排列顺序的唯一性 | ||
| 37 | - validateSortUnique(createReqVO.getItemId(), createReqVO.getSort(), null); | ||
| 38 | - // 校验工序存在 | ||
| 39 | - if (createReqVO.getProcessId() != null) { | ||
| 40 | - processService.validateProcessExists(createReqVO.getProcessId()); | ||
| 41 | - } | 36 | + // 校验数据 |
| 37 | + validateProductSopSaveData(createReqVO, null); | ||
| 42 | 38 | ||
| 43 | // 插入 | 39 | // 插入 |
| 44 | MesMdProductSopDO sop = BeanUtils.toBean(createReqVO, MesMdProductSopDO.class); | 40 | MesMdProductSopDO sop = BeanUtils.toBean(createReqVO, MesMdProductSopDO.class); |
| @@ -50,18 +46,23 @@ public class MesMdProductSopServiceImpl implements MesMdProductSopService { | @@ -50,18 +46,23 @@ public class MesMdProductSopServiceImpl implements MesMdProductSopService { | ||
| 50 | public void updateProductSop(MesMdProductSopSaveReqVO updateReqVO) { | 46 | public void updateProductSop(MesMdProductSopSaveReqVO updateReqVO) { |
| 51 | // 校验存在 | 47 | // 校验存在 |
| 52 | validateProductSopExists(updateReqVO.getId()); | 48 | validateProductSopExists(updateReqVO.getId()); |
| 53 | - // 校验排列顺序的唯一性 | ||
| 54 | - validateSortUnique(updateReqVO.getItemId(), updateReqVO.getSort(), updateReqVO.getId()); | ||
| 55 | - // 校验工序存在 | ||
| 56 | - if (updateReqVO.getProcessId() != null) { | ||
| 57 | - processService.validateProcessExists(updateReqVO.getProcessId()); | ||
| 58 | - } | 49 | + // 校验数据 |
| 50 | + validateProductSopSaveData(updateReqVO, updateReqVO.getId()); | ||
| 59 | 51 | ||
| 60 | // 更新 | 52 | // 更新 |
| 61 | MesMdProductSopDO updateObj = BeanUtils.toBean(updateReqVO, MesMdProductSopDO.class); | 53 | MesMdProductSopDO updateObj = BeanUtils.toBean(updateReqVO, MesMdProductSopDO.class); |
| 62 | productSopMapper.updateById(updateObj); | 54 | productSopMapper.updateById(updateObj); |
| 63 | } | 55 | } |
| 64 | 56 | ||
| 57 | + private void validateProductSopSaveData(MesMdProductSopSaveReqVO reqVO, Long excludeId) { | ||
| 58 | + // 校验排列顺序的唯一性 | ||
| 59 | + validateSortUnique(reqVO.getItemId(), reqVO.getSort(), excludeId); | ||
| 60 | + // 校验工序存在 | ||
| 61 | + if (reqVO.getProcessId() != null) { | ||
| 62 | + processService.validateProcessExists(reqVO.getProcessId()); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 65 | @Override | 66 | @Override |
| 66 | public void deleteProductSop(Long id) { | 67 | public void deleteProductSop(Long id) { |
| 67 | // 校验存在 | 68 | // 校验存在 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcServiceImpl.java
| @@ -86,12 +86,10 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -86,12 +86,10 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 86 | @Override | 86 | @Override |
| 87 | @Transactional(rollbackFor = Exception.class) | 87 | @Transactional(rollbackFor = Exception.class) |
| 88 | public Long createIpqc(MesQcIpqcSaveReqVO createReqVO) { | 88 | public Long createIpqc(MesQcIpqcSaveReqVO createReqVO) { |
| 89 | - // 1.1 校验编号唯一 | ||
| 90 | - validateIpqcCodeUnique(null, createReqVO.getCode()); | ||
| 91 | - // 1.2 校验工单、工位、检测人员存在 | 89 | + // 1.1 校验数据 |
| 90 | + MesMdWorkstationDO workstation = validateIpqcSaveData(createReqVO); | ||
| 91 | + // 1.2 校验工单存在 | ||
| 92 | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); | 92 | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); |
| 93 | - MesMdWorkstationDO workstation = workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); | ||
| 94 | - adminUserApi.validateUser(createReqVO.getInspectorUserId()); | ||
| 95 | // 1.3 根据产品 + 检验类型自动匹配模板 | 93 | // 1.3 根据产品 + 检验类型自动匹配模板 |
| 96 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( | 94 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( |
| 97 | workOrder.getProductId(), MesQcTypeEnum.IPQC.getType()); | 95 | workOrder.getProductId(), MesQcTypeEnum.IPQC.getType()); |
| @@ -118,11 +116,8 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -118,11 +116,8 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 118 | public void updateIpqc(MesQcIpqcSaveReqVO updateReqVO) { | 116 | public void updateIpqc(MesQcIpqcSaveReqVO updateReqVO) { |
| 119 | // 1.1 校验存在 + 草稿状态 | 117 | // 1.1 校验存在 + 草稿状态 |
| 120 | validateIpqcStatusPrepare(updateReqVO.getId()); | 118 | validateIpqcStatusPrepare(updateReqVO.getId()); |
| 121 | - // 1.2 校验编号唯一 | ||
| 122 | - validateIpqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 123 | - // 1.3 校验工位、检测人员存在 | ||
| 124 | - MesMdWorkstationDO workstation = workstationService.validateWorkstationExists(updateReqVO.getWorkstationId()); | ||
| 125 | - adminUserApi.validateUser(updateReqVO.getInspectorUserId()); | 119 | + // 1.2 校验数据 |
| 120 | + MesMdWorkstationDO workstation = validateIpqcSaveData(updateReqVO); | ||
| 126 | 121 | ||
| 127 | // 2. 更新主表 | 122 | // 2. 更新主表 |
| 128 | MesQcIpqcDO existIpqc = validateIpqcExists(updateReqVO.getId()); | 123 | MesQcIpqcDO existIpqc = validateIpqcExists(updateReqVO.getId()); |
| @@ -135,6 +130,15 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -135,6 +130,15 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 135 | ipqcMapper.updateById(updateObj); | 130 | ipqcMapper.updateById(updateObj); |
| 136 | } | 131 | } |
| 137 | 132 | ||
| 133 | + private MesMdWorkstationDO validateIpqcSaveData(MesQcIpqcSaveReqVO reqVO) { | ||
| 134 | + // 校验编号唯一 | ||
| 135 | + validateIpqcCodeUnique(reqVO.getId(), reqVO.getCode()); | ||
| 136 | + // 校验工位、检测人员存在 | ||
| 137 | + MesMdWorkstationDO workstation = workstationService.validateWorkstationExists(reqVO.getWorkstationId()); | ||
| 138 | + adminUserApi.validateUser(reqVO.getInspectorUserId()); | ||
| 139 | + return workstation; | ||
| 140 | + } | ||
| 141 | + | ||
| 138 | @Override | 142 | @Override |
| 139 | @Transactional(rollbackFor = Exception.class) | 143 | @Transactional(rollbackFor = Exception.class) |
| 140 | public void finishIpqc(Long id) { | 144 | public void finishIpqc(Long id) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java
| @@ -69,16 +69,12 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { | @@ -69,16 +69,12 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { | ||
| 69 | @Override | 69 | @Override |
| 70 | @Transactional(rollbackFor = Exception.class) | 70 | @Transactional(rollbackFor = Exception.class) |
| 71 | public Long createIqc(MesQcIqcSaveReqVO createReqVO) { | 71 | public Long createIqc(MesQcIqcSaveReqVO createReqVO) { |
| 72 | - // 1.1 校验编号唯一 | ||
| 73 | - validateIqcCodeUnique(null, createReqVO.getCode()); | ||
| 74 | - // 1.2 校验供应商、物料、检测人员存在 | ||
| 75 | - vendorService.validateVendorExists(createReqVO.getVendorId()); | ||
| 76 | - itemService.validateItemExists(createReqVO.getItemId()); | ||
| 77 | - adminUserApi.validateUser(createReqVO.getInspectorUserId()); | ||
| 78 | - // 1.3 校验来源单据参数,并验证数据存在 | 72 | + // 1.1 校验数据 |
| 73 | + validateIqcSaveData(createReqVO); | ||
| 74 | + // 1.2 校验来源单据参数,并验证数据存在 | ||
| 79 | String sourceDocCode = validateAndGetSourceDocCode( | 75 | String sourceDocCode = validateAndGetSourceDocCode( |
| 80 | createReqVO.getSourceDocType(), createReqVO.getSourceDocId(), createReqVO.getSourceLineId()); | 76 | createReqVO.getSourceDocType(), createReqVO.getSourceDocId(), createReqVO.getSourceLineId()); |
| 81 | - // 1.4 通过 itemId + IQC 类型自动查找模板 | 77 | + // 1.3 通过 itemId + IQC 类型自动查找模板 |
| 82 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( | 78 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( |
| 83 | createReqVO.getItemId(), MesQcTypeEnum.IQC.getType()); | 79 | createReqVO.getItemId(), MesQcTypeEnum.IQC.getType()); |
| 84 | Long templateId = templateItem.getTemplateId(); | 80 | Long templateId = templateItem.getTemplateId(); |
| @@ -100,12 +96,8 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { | @@ -100,12 +96,8 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { | ||
| 100 | public void updateIqc(MesQcIqcSaveReqVO updateReqVO) { | 96 | public void updateIqc(MesQcIqcSaveReqVO updateReqVO) { |
| 101 | // 1.1 校验存在 + 草稿状态 | 97 | // 1.1 校验存在 + 草稿状态 |
| 102 | validateIqcStatusPrepare(updateReqVO.getId()); | 98 | validateIqcStatusPrepare(updateReqVO.getId()); |
| 103 | - // 1.2 校验编号唯一 | ||
| 104 | - validateIqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 105 | - // 1.3 校验供应商、物料、检测人员存在 | ||
| 106 | - vendorService.validateVendorExists(updateReqVO.getVendorId()); | ||
| 107 | - itemService.validateItemExists(updateReqVO.getItemId()); | ||
| 108 | - adminUserApi.validateUser(updateReqVO.getInspectorUserId()); | 99 | + // 1.2 校验数据 |
| 100 | + validateIqcSaveData(updateReqVO); | ||
| 109 | 101 | ||
| 110 | // 2. 更新主表 | 102 | // 2. 更新主表 |
| 111 | MesQcIqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIqcDO.class); | 103 | MesQcIqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIqcDO.class); |
| @@ -116,6 +108,15 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { | @@ -116,6 +108,15 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { | ||
| 116 | iqcMapper.updateById(updateObj); | 108 | iqcMapper.updateById(updateObj); |
| 117 | } | 109 | } |
| 118 | 110 | ||
| 111 | + private void validateIqcSaveData(MesQcIqcSaveReqVO reqVO) { | ||
| 112 | + // 校验编号唯一 | ||
| 113 | + validateIqcCodeUnique(reqVO.getId(), reqVO.getCode()); | ||
| 114 | + // 校验供应商、物料、检测人员存在 | ||
| 115 | + vendorService.validateVendorExists(reqVO.getVendorId()); | ||
| 116 | + itemService.validateItemExists(reqVO.getItemId()); | ||
| 117 | + adminUserApi.validateUser(reqVO.getInspectorUserId()); | ||
| 118 | + } | ||
| 119 | + | ||
| 119 | @Override | 120 | @Override |
| 120 | @Transactional(rollbackFor = Exception.class) | 121 | @Transactional(rollbackFor = Exception.class) |
| 121 | public void finishIqc(Long id) { | 122 | public void finishIqc(Long id) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcServiceImpl.java
| @@ -73,17 +73,12 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | @@ -73,17 +73,12 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | ||
| 73 | @Override | 73 | @Override |
| 74 | @Transactional(rollbackFor = Exception.class) | 74 | @Transactional(rollbackFor = Exception.class) |
| 75 | public Long createOqc(MesQcOqcSaveReqVO createReqVO) { | 75 | public Long createOqc(MesQcOqcSaveReqVO createReqVO) { |
| 76 | - // 1.1 校验编号唯一 | ||
| 77 | - validateOqcCodeUnique(null, createReqVO.getCode()); | ||
| 78 | - // 1.2 校验物料、检测人员存在 | ||
| 79 | - itemService.validateItemExists(createReqVO.getItemId()); | ||
| 80 | - adminUserApi.validateUser(createReqVO.getInspectorUserId()); | ||
| 81 | - // 1.3 校验来源单据参数,并验证数据存在 | 76 | + // 1.1 校验数据 |
| 77 | + validateOqcSaveData(createReqVO); | ||
| 78 | + // 1.2 校验来源单据参数,并验证数据存在 | ||
| 82 | String sourceDocCode = validateAndGetSourceDocCode( | 79 | String sourceDocCode = validateAndGetSourceDocCode( |
| 83 | createReqVO.getSourceDocType(), createReqVO.getSourceLineId()); | 80 | createReqVO.getSourceDocType(), createReqVO.getSourceLineId()); |
| 84 | - // 1.4 校验客户存在 | ||
| 85 | - clientService.validateClientExists(createReqVO.getClientId()); | ||
| 86 | - // 1.5 根据产品 + 检验类型自动匹配模板 | 81 | + // 1.3 根据产品 + 检验类型自动匹配模板 |
| 87 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( | 82 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( |
| 88 | createReqVO.getItemId(), MesQcTypeEnum.OQC.getType()); | 83 | createReqVO.getItemId(), MesQcTypeEnum.OQC.getType()); |
| 89 | Long templateId = templateItem.getTemplateId(); | 84 | Long templateId = templateItem.getTemplateId(); |
| @@ -104,12 +99,8 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | @@ -104,12 +99,8 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | ||
| 104 | public void updateOqc(MesQcOqcSaveReqVO updateReqVO) { | 99 | public void updateOqc(MesQcOqcSaveReqVO updateReqVO) { |
| 105 | // 1.1 校验存在 + 草稿状态 | 100 | // 1.1 校验存在 + 草稿状态 |
| 106 | validateOqcStatusPrepare(updateReqVO.getId()); | 101 | validateOqcStatusPrepare(updateReqVO.getId()); |
| 107 | - // 1.2 校验编号唯一 | ||
| 108 | - validateOqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 109 | - // 1.3 校验客户、物料、检测人员存在 | ||
| 110 | - clientService.validateClientExists(updateReqVO.getClientId()); | ||
| 111 | - itemService.validateItemExists(updateReqVO.getItemId()); | ||
| 112 | - adminUserApi.validateUser(updateReqVO.getInspectorUserId()); | 102 | + // 1.2 校验数据 |
| 103 | + validateOqcSaveData(updateReqVO); | ||
| 113 | 104 | ||
| 114 | // 2. 更新 | 105 | // 2. 更新 |
| 115 | MesQcOqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcOqcDO.class); | 106 | MesQcOqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcOqcDO.class); |
| @@ -119,6 +110,15 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | @@ -119,6 +110,15 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | ||
| 119 | oqcMapper.updateById(updateObj); | 110 | oqcMapper.updateById(updateObj); |
| 120 | } | 111 | } |
| 121 | 112 | ||
| 113 | + private void validateOqcSaveData(MesQcOqcSaveReqVO reqVO) { | ||
| 114 | + // 校验编号唯一 | ||
| 115 | + validateOqcCodeUnique(reqVO.getId(), reqVO.getCode()); | ||
| 116 | + // 校验客户、物料、检测人员存在 | ||
| 117 | + clientService.validateClientExists(reqVO.getClientId()); | ||
| 118 | + itemService.validateItemExists(reqVO.getItemId()); | ||
| 119 | + adminUserApi.validateUser(reqVO.getInspectorUserId()); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | @Override | 122 | @Override |
| 123 | @Transactional(rollbackFor = Exception.class) | 123 | @Transactional(rollbackFor = Exception.class) |
| 124 | public void finishOqc(Long id) { | 124 | public void finishOqc(Long id) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java
| @@ -75,16 +75,13 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | @@ -75,16 +75,13 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | ||
| 75 | @Override | 75 | @Override |
| 76 | @Transactional(rollbackFor = Exception.class) | 76 | @Transactional(rollbackFor = Exception.class) |
| 77 | public Long createRqc(MesQcRqcSaveReqVO createReqVO) { | 77 | public Long createRqc(MesQcRqcSaveReqVO createReqVO) { |
| 78 | - // 1.1 校验编号唯一 | ||
| 79 | - validateRqcCodeUnique(null, createReqVO.getCode()); | ||
| 80 | - // 1.2 校验物料、检测人员存在 | ||
| 81 | - itemService.validateItemExists(createReqVO.getItemId()); | ||
| 82 | - adminUserApi.validateUser(createReqVO.getInspectorUserId()); | ||
| 83 | - // 1.3 根据物料 + 检验类型自动匹配模板 | 78 | + // 1.1 校验数据 |
| 79 | + validateRqcSaveData(createReqVO); | ||
| 80 | + // 1.2 根据物料 + 检验类型自动匹配模板 | ||
| 84 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( | 81 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( |
| 85 | createReqVO.getItemId(), createReqVO.getType()); | 82 | createReqVO.getItemId(), createReqVO.getType()); |
| 86 | Long templateId = templateItem.getTemplateId(); | 83 | Long templateId = templateItem.getTemplateId(); |
| 87 | - // 1.4 获取来源单据编号 | 84 | + // 1.3 获取来源单据编号 |
| 88 | String sourceDocCode = validateAndGetSourceDocCode( | 85 | String sourceDocCode = validateAndGetSourceDocCode( |
| 89 | createReqVO.getSourceDocType(), createReqVO.getSourceDocId()); | 86 | createReqVO.getSourceDocType(), createReqVO.getSourceDocId()); |
| 90 | 87 | ||
| @@ -104,11 +101,8 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | @@ -104,11 +101,8 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | ||
| 104 | public void updateRqc(MesQcRqcSaveReqVO updateReqVO) { | 101 | public void updateRqc(MesQcRqcSaveReqVO updateReqVO) { |
| 105 | // 1.1 校验存在 + 草稿状态 | 102 | // 1.1 校验存在 + 草稿状态 |
| 106 | validateRqcStatusPrepare(updateReqVO.getId()); | 103 | validateRqcStatusPrepare(updateReqVO.getId()); |
| 107 | - // 1.2 校验编号唯一 | ||
| 108 | - validateRqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 109 | - // 1.3 校验物料、检测人员存在 | ||
| 110 | - itemService.validateItemExists(updateReqVO.getItemId()); | ||
| 111 | - adminUserApi.validateUser(updateReqVO.getInspectorUserId()); | 104 | + // 1.2 校验数据 |
| 105 | + validateRqcSaveData(updateReqVO); | ||
| 112 | 106 | ||
| 113 | // 2. 更新 | 107 | // 2. 更新 |
| 114 | MesQcRqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcRqcDO.class); | 108 | MesQcRqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcRqcDO.class); |
| @@ -118,6 +112,14 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | @@ -118,6 +112,14 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | ||
| 118 | rqcMapper.updateById(updateObj); | 112 | rqcMapper.updateById(updateObj); |
| 119 | } | 113 | } |
| 120 | 114 | ||
| 115 | + private void validateRqcSaveData(MesQcRqcSaveReqVO reqVO) { | ||
| 116 | + // 校验编号唯一 | ||
| 117 | + validateRqcCodeUnique(reqVO.getId(), reqVO.getCode()); | ||
| 118 | + // 校验物料、检测人员存在 | ||
| 119 | + itemService.validateItemExists(reqVO.getItemId()); | ||
| 120 | + adminUserApi.validateUser(reqVO.getInspectorUserId()); | ||
| 121 | + } | ||
| 122 | + | ||
| 121 | @Override | 123 | @Override |
| 122 | @Transactional(rollbackFor = Exception.class) | 124 | @Transactional(rollbackFor = Exception.class) |
| 123 | public void finishRqc(Long id) { | 125 | public void finishRqc(Long id) { |