Commit bb2ebe49c90d3df86681dfcf6d8b840ad9b4bbef

Authored by YunaiV
1 parent dbccfbab

✨ feat(mes): 添加待检任务分页查询功能,支持多来源数据整合

yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/pendinginspect/MesQcPendingInspectController.java
1 package cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect; 1 package cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect;
2 2
  3 +import cn.hutool.core.collection.CollUtil;
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectPageReqVO; 6 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectPageReqVO;
6 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectRespVO; 7 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectRespVO;
  8 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
  10 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.vendor.MesMdVendorDO;
  11 +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
  12 +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
  13 +import cn.iocoder.yudao.module.mes.service.md.vendor.MesMdVendorService;
7 import cn.iocoder.yudao.module.mes.service.qc.pendinginspect.MesQcPendingInspectService; 14 import cn.iocoder.yudao.module.mes.service.qc.pendinginspect.MesQcPendingInspectService;
8 import io.swagger.v3.oas.annotations.Operation; 15 import io.swagger.v3.oas.annotations.Operation;
9 import io.swagger.v3.oas.annotations.tags.Tag; 16 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -15,7 +22,11 @@ import org.springframework.web.bind.annotation.GetMapping; @@ -15,7 +22,11 @@ import org.springframework.web.bind.annotation.GetMapping;
15 import org.springframework.web.bind.annotation.RequestMapping; 22 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RestController; 23 import org.springframework.web.bind.annotation.RestController;
17 24
  25 +import java.util.Map;
  26 +
18 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 27 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  28 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  29 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
19 30
20 @Tag(name = "管理后台 - MES 待检任务") 31 @Tag(name = "管理后台 - MES 待检任务")
21 @RestController 32 @RestController
@@ -25,13 +36,49 @@ public class MesQcPendingInspectController { @@ -25,13 +36,49 @@ public class MesQcPendingInspectController {
25 36
26 @Resource 37 @Resource
27 private MesQcPendingInspectService pendingInspectService; 38 private MesQcPendingInspectService pendingInspectService;
  39 + @Resource
  40 + private MesMdItemService itemService;
  41 + @Resource
  42 + private MesMdUnitMeasureService unitMeasureService;
  43 + @Resource
  44 + private MesMdVendorService vendorService;
28 45
29 @GetMapping("/page") 46 @GetMapping("/page")
30 @Operation(summary = "获得待检任务分页") 47 @Operation(summary = "获得待检任务分页")
31 @PreAuthorize("@ss.hasPermission('mes:qc-pending-inspect:query')") 48 @PreAuthorize("@ss.hasPermission('mes:qc-pending-inspect:query')")
32 public CommonResult<PageResult<MesQcPendingInspectRespVO>> getPendingInspectPage( 49 public CommonResult<PageResult<MesQcPendingInspectRespVO>> getPendingInspectPage(
33 @Valid MesQcPendingInspectPageReqVO pageReqVO) { 50 @Valid MesQcPendingInspectPageReqVO pageReqVO) {
34 - return success(pendingInspectService.getPendingInspectPage(pageReqVO)); 51 + PageResult<MesQcPendingInspectRespVO> pageResult = pendingInspectService.getPendingInspectPage(pageReqVO);
  52 + // 拼接 VO:物料、供应商、计量单位
  53 + buildPendingInspectRespVOList(pageResult.getList());
  54 + return success(pageResult);
  55 + }
  56 +
  57 + // ==================== 拼接 VO ====================
  58 +
  59 + private void buildPendingInspectRespVOList(java.util.List<MesQcPendingInspectRespVO> list) {
  60 + if (CollUtil.isEmpty(list)) {
  61 + return;
  62 + }
  63 + // 批量查询物料
  64 + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(
  65 + convertSet(list, MesQcPendingInspectRespVO::getItemId));
  66 + // 批量查询计量单位(通过物料的 unitMeasureId)
  67 + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
  68 + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId));
  69 + // 批量查询供应商
  70 + Map<Long, MesMdVendorDO> vendorMap = vendorService.getVendorMap(
  71 + convertSet(list, MesQcPendingInspectRespVO::getVendorId));
  72 + // 拼装
  73 + list.forEach(vo -> {
  74 + findAndThen(itemMap, vo.getItemId(), item -> {
  75 + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification());
  76 + findAndThen(unitMeasureMap, item.getUnitMeasureId(),
  77 + unit -> vo.setUnitName(unit.getName()));
  78 + });
  79 + findAndThen(vendorMap, vo.getVendorId(),
  80 + vendor -> vo.setVendorName(vendor.getName()));
  81 + });
35 } 82 }
36 83
37 } 84 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/pendinginspect/vo/MesQcPendingInspectRespVO.java
@@ -25,9 +25,6 @@ public class MesQcPendingInspectRespVO { @@ -25,9 +25,6 @@ public class MesQcPendingInspectRespVO {
25 @Schema(description = "检验类型(MesQcTypeEnum)", example = "1") 25 @Schema(description = "检验类型(MesQcTypeEnum)", example = "1")
26 private Integer qcType; 26 private Integer qcType;
27 27
28 - @Schema(description = "检验类型名称", example = "来料检验")  
29 - private String qcTypeName;  
30 -  
31 // ========== 物料 ========== 28 // ========== 物料 ==========
32 29
33 @Schema(description = "物料 ID", example = "10") 30 @Schema(description = "物料 ID", example = "10")
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/pendinginspect/MesQcPendingInspectMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.qc.pendinginspect;
  2 +
  3 +import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectRespVO;
  4 +import com.baomidou.mybatisplus.core.metadata.IPage;
  5 +import org.apache.ibatis.annotations.Mapper;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
  8 +/**
  9 + * MES 待检任务 Mapper
  10 + *
  11 + * 使用 UNION ALL SQL 从多个来源表(到货通知单、外协入库单等)查询待检行
  12 + */
  13 +@Mapper
  14 +public interface MesQcPendingInspectMapper {
  15 +
  16 + IPage<MesQcPendingInspectRespVO> selectQcPendingPage(IPage<MesQcPendingInspectRespVO> page,
  17 + @Param("sourceDocCode") String sourceDocCode,
  18 + @Param("qcType") Integer qcType,
  19 + @Param("itemId") Long itemId);
  20 +
  21 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcServiceImpl.java
@@ -153,6 +153,9 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { @@ -153,6 +153,9 @@ public class MesQcIqcServiceImpl implements MesQcIqcService {
153 } else if (Objects.equals(iqc.getSourceDocType(), MesBizTypeConstants.WM_OUTSOURCE_RECPT)) { 153 } else if (Objects.equals(iqc.getSourceDocType(), MesBizTypeConstants.WM_OUTSOURCE_RECPT)) {
154 outsourceReceiptService.approveOutsourceReceiptWhenIqcComplete(iqc.getSourceDocId(), iqc.getSourceLineId(), 154 outsourceReceiptService.approveOutsourceReceiptWhenIqcComplete(iqc.getSourceDocId(), iqc.getSourceLineId(),
155 iqc.getId(), iqc.getQualifiedQuantity(), iqc.getUnqualifiedQuantity()); 155 iqc.getId(), iqc.getQualifiedQuantity(), iqc.getUnqualifiedQuantity());
  156 + } else {
  157 + throw new IllegalArgumentException(
  158 + "IQC 单[" + iqc.getId() + "] sourceDocType=" + iqc.getSourceDocType() + " 无法识别,无法回写来源单据");
156 } 159 }
157 } 160 }
158 161
@@ -220,6 +223,8 @@ public class MesQcIqcServiceImpl implements MesQcIqcService { @@ -220,6 +223,8 @@ public class MesQcIqcServiceImpl implements MesQcIqcService {
220 // 根据来源单据类型,校验数据存在且匹配 223 // 根据来源单据类型,校验数据存在且匹配
221 if (Objects.equals(sourceDocType, MesBizTypeConstants.WM_ARRIVAL_NOTICE)) { 224 if (Objects.equals(sourceDocType, MesBizTypeConstants.WM_ARRIVAL_NOTICE)) {
222 arrivalNoticeService.validateArrivalNoticeAndLineExists(sourceDocId, sourceLineId); 225 arrivalNoticeService.validateArrivalNoticeAndLineExists(sourceDocId, sourceLineId);
  226 + } else if (Objects.equals(sourceDocType, MesBizTypeConstants.WM_OUTSOURCE_RECPT)) {
  227 + outsourceReceiptService.validateOutsourceReceiptAndLineExists(sourceDocId, sourceLineId);
223 } 228 }
224 } 229 }
225 230
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/pendinginspect/MesQcPendingInspectServiceImpl.java
1 package cn.iocoder.yudao.module.mes.service.qc.pendinginspect; 1 package cn.iocoder.yudao.module.mes.service.qc.pendinginspect;
2 2
3 -import cn.hutool.core.collection.CollUtil;  
4 -import cn.hutool.core.util.StrUtil;  
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
6 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectPageReqVO; 5 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectPageReqVO;
7 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectRespVO; 6 import cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectRespVO;
8 -import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;  
9 -import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;  
10 -import cn.iocoder.yudao.module.mes.dal.dataobject.md.vendor.MesMdVendorDO;  
11 -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;  
12 -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeLineDO;  
13 -import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeLineMapper;  
14 -import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeMapper;  
15 -import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;  
16 -import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;  
17 -import cn.iocoder.yudao.module.mes.enums.wm.MesWmArrivalNoticeStatusEnum;  
18 -import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;  
19 -import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;  
20 -import cn.iocoder.yudao.module.mes.service.md.vendor.MesMdVendorService; 7 +import cn.iocoder.yudao.module.mes.dal.mysql.qc.pendinginspect.MesQcPendingInspectMapper;
  8 +import com.baomidou.mybatisplus.core.metadata.IPage;
21 import jakarta.annotation.Resource; 9 import jakarta.annotation.Resource;
22 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
23 import org.springframework.validation.annotation.Validated; 11 import org.springframework.validation.annotation.Validated;
24 12
25 -import java.util.*;  
26 -import java.util.stream.Collectors;  
27 -  
28 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;  
29 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;  
30 -  
31 /** 13 /**
32 * MES 待检任务 Service 实现类 14 * MES 待检任务 Service 实现类
  15 + *
  16 + * 使用 UNION ALL SQL 从多个来源表查询待检行,对齐 KTG 的 QcPendingInspectMapper.xml 实现
33 */ 17 */
34 @Service 18 @Service
35 @Validated 19 @Validated
36 public class MesQcPendingInspectServiceImpl implements MesQcPendingInspectService { 20 public class MesQcPendingInspectServiceImpl implements MesQcPendingInspectService {
37 21
38 @Resource 22 @Resource
39 - private MesWmArrivalNoticeMapper arrivalNoticeMapper;  
40 - @Resource  
41 - private MesWmArrivalNoticeLineMapper arrivalNoticeLineMapper;  
42 - @Resource  
43 - private MesMdItemService itemService;  
44 - @Resource  
45 - private MesMdVendorService vendorService;  
46 - @Resource  
47 - private MesMdUnitMeasureService unitMeasureService; 23 + private MesQcPendingInspectMapper pendingInspectMapper;
48 24
49 - // 【下面的 todo 先晚点改】  
50 - // TODO @AI:是否可以在 mapper 里查询(union 汇总)然后关联数据的读取,尽量放在 controller;  
51 - // TODO @AI:另外,如果使用 mapper 操作,尽量使用 mybatis plus 或者 mybatis plus join,减少 mapper xml;  
52 @Override 25 @Override
53 public PageResult<MesQcPendingInspectRespVO> getPendingInspectPage(MesQcPendingInspectPageReqVO pageReqVO) { 26 public PageResult<MesQcPendingInspectRespVO> getPendingInspectPage(MesQcPendingInspectPageReqVO pageReqVO) {
54 - List<MesQcPendingInspectRespVO> allItems = new ArrayList<>();  
55 -  
56 - // 1. IQC 来源:到货通知单  
57 - if (pageReqVO.getQcType() == null || Objects.equals(pageReqVO.getQcType(), MesQcTypeEnum.IQC.getType())) {  
58 - allItems.addAll(queryIqcPendingFromArrivalNotice(pageReqVO));  
59 - }  
60 - // TODO 2. IPQC 来源(生产工单,WM 模块未实现)  
61 - // TODO 3. OQC 来源(销售出库单,WM 模块未实现)  
62 - // TODO 4. RQC 来源(退货单,WM 模块未实现)  
63 -  
64 - // 5. 按 recordTime 降序排序  
65 - allItems.sort(Comparator.comparing(MesQcPendingInspectRespVO::getRecordTime,  
66 - Comparator.nullsLast(Comparator.reverseOrder())));  
67 -  
68 - // 6. 内存分页  
69 - int total = allItems.size();  
70 - int fromIndex = (pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize();  
71 - if (fromIndex >= total) {  
72 - return new PageResult<>(Collections.emptyList(), (long) total);  
73 - }  
74 - int toIndex = Math.min(fromIndex + pageReqVO.getPageSize(), total);  
75 - return new PageResult<>(allItems.subList(fromIndex, toIndex), (long) total); 27 + // 分页查询
  28 + IPage<MesQcPendingInspectRespVO> page = MyBatisUtils.buildPage(pageReqVO);
  29 + pendingInspectMapper.selectQcPendingPage(page,
  30 + pageReqVO.getSourceDocCode(), pageReqVO.getQcType(), pageReqVO.getItemId());
  31 + // 返回结果
  32 + return new PageResult<>(page.getRecords(), page.getTotal());
76 } 33 }
77 34
78 - // ==================== IQC 来源:到货通知单 ====================  
79 -  
80 - private List<MesQcPendingInspectRespVO> queryIqcPendingFromArrivalNotice(MesQcPendingInspectPageReqVO pageReqVO) {  
81 - // 1. 查询状态为"待质检"的到货通知单  
82 - List<MesWmArrivalNoticeDO> notices = arrivalNoticeMapper.selectListByStatus(  
83 - MesWmArrivalNoticeStatusEnum.PENDING_QC.getStatus());  
84 - if (CollUtil.isEmpty(notices)) {  
85 - return Collections.emptyList();  
86 - }  
87 - // 1.1 按 sourceDocCode 模糊过滤  
88 - if (StrUtil.isNotBlank(pageReqVO.getSourceDocCode())) {  
89 - notices = notices.stream()  
90 - .filter(n -> n.getCode().contains(pageReqVO.getSourceDocCode()))  
91 - .collect(Collectors.toList());  
92 - }  
93 - if (CollUtil.isEmpty(notices)) {  
94 - return Collections.emptyList();  
95 - }  
96 - Map<Long, MesWmArrivalNoticeDO> noticeMap = convertMap(notices, MesWmArrivalNoticeDO::getId);  
97 -  
98 - // 2. 查询需要 IQC 但尚未创建检验单的行  
99 - List<MesWmArrivalNoticeLineDO> lines = arrivalNoticeLineMapper.selectListByIqcPending(  
100 - new ArrayList<>(noticeMap.keySet()));  
101 - if (CollUtil.isEmpty(lines)) {  
102 - return Collections.emptyList();  
103 - }  
104 -  
105 - // 3. 批量查询物料  
106 - Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(convertSet(lines, MesWmArrivalNoticeLineDO::getItemId));  
107 - // 3.1 按 itemId 精确过滤  
108 - if (pageReqVO.getItemId() != null) {  
109 - lines = lines.stream()  
110 - .filter(line -> pageReqVO.getItemId().equals(line.getItemId()))  
111 - .collect(Collectors.toList());  
112 - }  
113 - if (CollUtil.isEmpty(lines)) {  
114 - return Collections.emptyList();  
115 - }  
116 -  
117 - // 4. 批量查询供应商  
118 - Map<Long, MesMdVendorDO> vendorMap = vendorService.getVendorMap(  
119 - convertSet(notices, MesWmArrivalNoticeDO::getVendorId));  
120 - // 5. 批量查询计量单位  
121 - Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(  
122 - convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId));  
123 -  
124 - // 6. 组装 VO  
125 - List<MesQcPendingInspectRespVO> result = new ArrayList<>(lines.size());  
126 - for (MesWmArrivalNoticeLineDO line : lines) {  
127 - MesWmArrivalNoticeDO notice = noticeMap.get(line.getNoticeId());  
128 - if (notice == null) {  
129 - continue;  
130 - }  
131 - MesQcPendingInspectRespVO vo = new MesQcPendingInspectRespVO();  
132 - vo.setSourceDocId(notice.getId());  
133 - vo.setSourceDocType(MesBizTypeConstants.WM_ARRIVAL_NOTICE);  
134 - vo.setSourceDocCode(notice.getCode());  
135 - vo.setSourceLineId(line.getId());  
136 - vo.setQcType(MesQcTypeEnum.IQC.getType());  
137 - vo.setQcTypeName(MesQcTypeEnum.IQC.getName());  
138 - vo.setItemId(line.getItemId());  
139 - vo.setQuantityToCheck(line.getArrivalQuantity());  
140 - vo.setVendorId(notice.getVendorId());  
141 - vo.setRecordTime(notice.getArrivalDate());  
142 - // 物料信息  
143 - MesMdItemDO item = itemMap.get(line.getItemId());  
144 - if (item != null) {  
145 - vo.setItemCode(item.getCode());  
146 - vo.setItemName(item.getName());  
147 - vo.setSpecification(item.getSpecification());  
148 - MesMdUnitMeasureDO unit = unitMeasureMap.get(item.getUnitMeasureId());  
149 - if (unit != null) {  
150 - vo.setUnitName(unit.getName());  
151 - }  
152 - }  
153 - // 供应商信息  
154 - MesMdVendorDO vendor = vendorMap.get(notice.getVendorId());  
155 - if (vendor != null) {  
156 - vo.setVendorName(vendor.getName());  
157 - }  
158 - result.add(vo);  
159 - }  
160 - return result;  
161 - }  
162 } 35 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/outsourcereceipt/MesWmOutsourceReceiptService.java
@@ -91,4 +91,12 @@ public interface MesWmOutsourceReceiptService { @@ -91,4 +91,12 @@ public interface MesWmOutsourceReceiptService {
91 void approveOutsourceReceiptWhenIqcComplete(Long receiptId, Long lineId, Long iqcId, 91 void approveOutsourceReceiptWhenIqcComplete(Long receiptId, Long lineId, Long iqcId,
92 BigDecimal qualifiedQuantity, BigDecimal unqualifiedQuantity); 92 BigDecimal qualifiedQuantity, BigDecimal unqualifiedQuantity);
93 93
  94 + /**
  95 + * 校验外协入库单和行存在
  96 + *
  97 + * @param receiptId 入库单编号
  98 + * @param lineId 行编号
  99 + */
  100 + void validateOutsourceReceiptAndLineExists(Long receiptId, Long lineId);
  101 +
94 } 102 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/outsourcereceipt/MesWmOutsourceReceiptServiceImpl.java
@@ -250,6 +250,20 @@ public class MesWmOutsourceReceiptServiceImpl implements MesWmOutsourceReceiptSe @@ -250,6 +250,20 @@ public class MesWmOutsourceReceiptServiceImpl implements MesWmOutsourceReceiptSe
250 return receipt; 250 return receipt;
251 } 251 }
252 252
  253 + @Override
  254 + public void validateOutsourceReceiptAndLineExists(Long receiptId, Long lineId) {
  255 + // 1. 校验入库单存在
  256 + validateOutsourceReceiptExists(receiptId);
  257 + // 2. 校验行存在且属于该入库单
  258 + MesWmOutsourceReceiptLineDO line = outsourceReceiptLineService.getOutsourceReceiptLine(lineId);
  259 + if (line == null) {
  260 + throw exception(WM_OUTSOURCE_RECEIPT_LINE_NOT_EXISTS);
  261 + }
  262 + if (ObjUtil.notEqual(receiptId, line.getReceiptId())) {
  263 + throw exception(WM_OUTSOURCE_RECEIPT_LINE_NOT_EXISTS);
  264 + }
  265 + }
  266 +
253 /** 267 /**
254 * 校验外协入库单存在且为草稿状态 268 * 校验外协入库单存在且为草稿状态
255 */ 269 */
yudao-module-mes/src/main/resources/mapper/qc/pendinginspect/MesQcPendingInspectMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.mes.dal.mysql.qc.pendinginspect.MesQcPendingInspectMapper">
  4 +
  5 + <!--
  6 + 待检任务查询(UNION ALL 多来源),目前已实现的来源:
  7 + 1. 到货通知单(IQC):状态=待质检(2),行的 iqc_check_flag=1 且 iqc_id IS NULL
  8 + 2. 外协入库单(IQC/OIQC):状态=待检验(1),行的 iqc_check=1 且 iqc_id IS NULL
  9 +
  10 + TODO IPQC/OQC/RQC 来源待对应模块就绪后补充
  11 + -->
  12 + <select id="selectQcPendingPage" resultType="cn.iocoder.yudao.module.mes.controller.admin.qc.pendinginspect.vo.MesQcPendingInspectRespVO">
  13 + SELECT * FROM (
  14 + <!-- 1. IQC 来源:到货通知单 -->
  15 + SELECT
  16 + n.id AS sourceDocId,
  17 + ${@cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants@WM_ARRIVAL_NOTICE} AS sourceDocType,
  18 + n.code AS sourceDocCode,
  19 + l.id AS sourceLineId,
  20 + n.arrival_date AS recordTime,
  21 + ${@cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum@IQC.type} AS qcType,
  22 + l.item_id AS itemId,
  23 + l.arrival_quantity AS quantityToCheck,
  24 + n.vendor_id AS vendorId
  25 + FROM mes_wm_arrival_notice n
  26 + JOIN mes_wm_arrival_notice_line l ON n.id = l.notice_id
  27 + WHERE n.status = ${@cn.iocoder.yudao.module.mes.enums.wm.MesWmArrivalNoticeStatusEnum@PENDING_QC.status}
  28 + AND l.iqc_check_flag = 1
  29 + AND l.iqc_id IS NULL
  30 + AND n.deleted = 0
  31 + AND l.deleted = 0
  32 +
  33 + UNION ALL
  34 +
  35 + <!-- 2. IQC 来源:外协入库单 -->
  36 + SELECT
  37 + r.id AS sourceDocId,
  38 + ${@cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants@WM_OUTSOURCE_RECPT} AS sourceDocType,
  39 + r.code AS sourceDocCode,
  40 + rl.id AS sourceLineId,
  41 + r.receipt_date AS recordTime,
  42 + ${@cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum@IQC.type} AS qcType,
  43 + rl.item_id AS itemId,
  44 + rl.quantity AS quantityToCheck,
  45 + r.vendor_id AS vendorId
  46 + FROM mes_wm_outsource_receipt r
  47 + JOIN mes_wm_outsource_receipt_line rl ON r.id = rl.receipt_id
  48 + WHERE r.status = ${@cn.iocoder.yudao.module.mes.enums.wm.MesWmOutsourceReceiptStatusEnum@CONFIRMED.status}
  49 + AND rl.iqc_check = 1
  50 + AND rl.iqc_id IS NULL
  51 + AND r.deleted = 0
  52 + AND rl.deleted = 0
  53 + ) t
  54 + <where>
  55 + <if test="sourceDocCode != null and sourceDocCode != ''">
  56 + AND t.sourceDocCode LIKE CONCAT('%', #{sourceDocCode}, '%')
  57 + </if>
  58 + <if test="qcType != null">
  59 + AND t.qcType = #{qcType}
  60 + </if>
  61 + <if test="itemId != null">
  62 + AND t.itemId = #{itemId}
  63 + </if>
  64 + </where>
  65 + ORDER BY t.recordTime DESC
  66 + </select>
  67 +
  68 +</mapper>