Commit a1a35aa530551cf9b5e5a508022a561c41120e01

Authored by YunaiV
1 parent 521c5380

✨ feat(qc): 新增计量单位引用统计功能

yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ipqc/MesQcIpqcLineMapper.java
... ... @@ -32,4 +32,8 @@ public interface MesQcIpqcLineMapper extends BaseMapperX<MesQcIpqcLineDO> {
32 32 .eq(MesQcIpqcLineDO::getIpqcId, ipqcId));
33 33 }
34 34  
  35 + default Long selectCountByUnitMeasureId(Long unitMeasureId) {
  36 + return selectCount(MesQcIpqcLineDO::getUnitMeasureId, unitMeasureId);
  37 + }
  38 +
35 39 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/iqc/MesQcIqcLineMapper.java
... ... @@ -32,4 +32,8 @@ public interface MesQcIqcLineMapper extends BaseMapperX<MesQcIqcLineDO> {
32 32 .eq(MesQcIqcLineDO::getIqcId, iqcId));
33 33 }
34 34  
  35 + default Long selectCountByUnitMeasureId(Long unitMeasureId) {
  36 + return selectCount(MesQcIqcLineDO::getUnitMeasureId, unitMeasureId);
  37 + }
  38 +
35 39 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/oqc/MesQcOqcLineMapper.java
... ... @@ -32,4 +32,8 @@ public interface MesQcOqcLineMapper extends BaseMapperX<MesQcOqcLineDO> {
32 32 .eq(MesQcOqcLineDO::getOqcId, oqcId));
33 33 }
34 34  
  35 + default Long selectCountByUnitMeasureId(Long unitMeasureId) {
  36 + return selectCount(MesQcOqcLineDO::getUnitMeasureId, unitMeasureId);
  37 + }
  38 +
35 39 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/rqc/MesQcRqcLineMapper.java
... ... @@ -32,4 +32,8 @@ public interface MesQcRqcLineMapper extends BaseMapperX<MesQcRqcLineDO> {
32 32 .eq(MesQcRqcLineDO::getRqcId, rqcId));
33 33 }
34 34  
  35 + default Long selectCountByUnitMeasureId(Long unitMeasureId) {
  36 + return selectCount(MesQcRqcLineDO::getUnitMeasureId, unitMeasureId);
  37 + }
  38 +
35 39 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
... ... @@ -27,6 +27,7 @@ public interface ErrorCodeConstants {
27 27 ErrorCode MD_UNIT_MEASURE_HAS_SECONDARY = new ErrorCode(1_040_101_003, "该主单位下存在辅单位,无法删除");
28 28 ErrorCode MD_UNIT_MEASURE_HAS_TASK_ISSUE = new ErrorCode(1_040_101_004, "该计量单位已被生产投料引用,无法删除");
29 29 ErrorCode MD_UNIT_MEASURE_HAS_QC_TEMPLATE_INDICATOR = new ErrorCode(1_040_101_005, "该计量单位已被质检方案指标项引用,无法删除");
  30 + ErrorCode MD_UNIT_MEASURE_HAS_QC_LINE = new ErrorCode(1_040_101_006, "该计量单位已被质检单据行引用,无法删除");
30 31  
31 32 // ========== MES 基础数据-物料(1-040-102-000) ==========
32 33 ErrorCode MD_ITEM_NOT_EXISTS = new ErrorCode(1_040_102_000, "物料不存在");
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/unitmeasure/MesMdUnitMeasureServiceImpl.java
... ... @@ -9,6 +9,10 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasur
9 9 import cn.iocoder.yudao.module.mes.dal.mysql.md.unitmeasure.MesMdUnitMeasureMapper;
10 10 import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
11 11 import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskIssueService;
  12 +import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcLineService;
  13 +import cn.iocoder.yudao.module.mes.service.qc.iqc.MesQcIqcLineService;
  14 +import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcLineService;
  15 +import cn.iocoder.yudao.module.mes.service.qc.rqc.MesQcRqcLineService;
12 16 import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateIndicatorService;
13 17 import org.springframework.context.annotation.Lazy;
14 18 import jakarta.annotation.Resource;
... ... @@ -43,6 +47,18 @@ public class MesMdUnitMeasureServiceImpl implements MesMdUnitMeasureService {
43 47 @Resource
44 48 @Lazy
45 49 private MesQcTemplateIndicatorService templateIndicatorService;
  50 + @Resource
  51 + @Lazy
  52 + private MesQcIqcLineService iqcLineService;
  53 + @Resource
  54 + @Lazy
  55 + private MesQcOqcLineService oqcLineService;
  56 + @Resource
  57 + @Lazy
  58 + private MesQcIpqcLineService ipqcLineService;
  59 + @Resource
  60 + @Lazy
  61 + private MesQcRqcLineService rqcLineService;
46 62  
47 63 @Override
48 64 public Long createUnitMeasure(MesMdUnitMeasureSaveReqVO createReqVO) {
... ... @@ -87,6 +103,13 @@ public class MesMdUnitMeasureServiceImpl implements MesMdUnitMeasureService {
87 103 if (templateIndicatorService.getTemplateIndicatorCountByUnitMeasureId(id) > 0) {
88 104 throw exception(MD_UNIT_MEASURE_HAS_QC_TEMPLATE_INDICATOR);
89 105 }
  106 + // 校验是否被质检单据行引用(IQC/OQC/IPQC/RQC)
  107 + if (iqcLineService.getIqcLineCountByUnitMeasureId(id) > 0
  108 + || oqcLineService.getOqcLineCountByUnitMeasureId(id) > 0
  109 + || ipqcLineService.getIpqcLineCountByUnitMeasureId(id) > 0
  110 + || rqcLineService.getRqcLineCountByUnitMeasureId(id) > 0) {
  111 + throw exception(MD_UNIT_MEASURE_HAS_QC_LINE);
  112 + }
90 113  
91 114 // 删除
92 115 unitMeasureMapper.deleteById(id);
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcLineService.java
... ... @@ -69,4 +69,12 @@ public interface MesQcIpqcLineService {
69 69 */
70 70 void deleteListByIpqcId(Long ipqcId);
71 71  
  72 + /**
  73 + * 统计使用指定计量单位的过程检验行数量
  74 + *
  75 + * @param unitMeasureId 计量单位编号
  76 + * @return 引用数量
  77 + */
  78 + Long getIpqcLineCountByUnitMeasureId(Long unitMeasureId);
  79 +
72 80 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcLineServiceImpl.java
... ... @@ -127,4 +127,9 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService {
127 127 ipqcLineMapper.deleteByIpqcId(ipqcId);
128 128 }
129 129  
  130 + @Override
  131 + public Long getIpqcLineCountByUnitMeasureId(Long unitMeasureId) {
  132 + return ipqcLineMapper.selectCountByUnitMeasureId(unitMeasureId);
  133 + }
  134 +
130 135 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcLineService.java
... ... @@ -70,4 +70,12 @@ public interface MesQcIqcLineService {
70 70 */
71 71 void deleteListByIqcId(Long iqcId);
72 72  
  73 + /**
  74 + * 统计使用指定计量单位的来料检验行数量
  75 + *
  76 + * @param unitMeasureId 计量单位编号
  77 + * @return 引用数量
  78 + */
  79 + Long getIqcLineCountByUnitMeasureId(Long unitMeasureId);
  80 +
73 81 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcLineServiceImpl.java
... ... @@ -127,4 +127,9 @@ public class MesQcIqcLineServiceImpl implements MesQcIqcLineService {
127 127 iqcLineMapper.deleteByIqcId(iqcId);
128 128 }
129 129  
  130 + @Override
  131 + public Long getIqcLineCountByUnitMeasureId(Long unitMeasureId) {
  132 + return iqcLineMapper.selectCountByUnitMeasureId(unitMeasureId);
  133 + }
  134 +
130 135 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcLineService.java
... ... @@ -69,4 +69,12 @@ public interface MesQcOqcLineService {
69 69 */
70 70 void recalculateLineDefectStats(Long oqcId, List<MesQcDefectRecordDO> records);
71 71  
  72 + /**
  73 + * 统计使用指定计量单位的出货检验行数量
  74 + *
  75 + * @param unitMeasureId 计量单位编号
  76 + * @return 引用数量
  77 + */
  78 + Long getOqcLineCountByUnitMeasureId(Long unitMeasureId);
  79 +
72 80 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcLineServiceImpl.java
... ... @@ -125,4 +125,9 @@ public class MesQcOqcLineServiceImpl implements MesQcOqcLineService {
125 125 oqcLineMapper.deleteByOqcId(oqcId);
126 126 }
127 127  
  128 + @Override
  129 + public Long getOqcLineCountByUnitMeasureId(Long unitMeasureId) {
  130 + return oqcLineMapper.selectCountByUnitMeasureId(unitMeasureId);
  131 + }
  132 +
128 133 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcLineService.java
... ... @@ -69,4 +69,12 @@ public interface MesQcRqcLineService {
69 69 */
70 70 void deleteByRqcId(Long rqcId);
71 71  
  72 + /**
  73 + * 统计使用指定计量单位的退货检验行数量
  74 + *
  75 + * @param unitMeasureId 计量单位编号
  76 + * @return 引用数量
  77 + */
  78 + Long getRqcLineCountByUnitMeasureId(Long unitMeasureId);
  79 +
72 80 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcLineServiceImpl.java
... ... @@ -125,4 +125,9 @@ public class MesQcRqcLineServiceImpl implements MesQcRqcLineService {
125 125 rqcLineMapper.deleteByRqcId(rqcId);
126 126 }
127 127  
  128 + @Override
  129 + public Long getRqcLineCountByUnitMeasureId(Long unitMeasureId) {
  130 + return rqcLineMapper.selectCountByUnitMeasureId(unitMeasureId);
  131 + }
  132 +
128 133 }
... ...