Merge remote-tracking branch 'origin/dev_business' into dev_business
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcQualityExportVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcLineDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.ipqc.MesQcIpqcLineMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| | | import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService; |
| | | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | private MesMdItemService itemService; |
| | | @Resource |
| | | private MesMdUnitMeasureService unitMeasureService; |
| | | @Resource |
| | | private MesQcIndicatorResultService indicatorResultService; |
| | | @Resource |
| | | private MesQcIndicatorService indicatorService; |
| | | @Resource |
| | | private MesQcIpqcLineMapper ipqcLineMapper; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | HttpServletResponse response) throws IOException { |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | | List<MesQcIpqcDO> list = ipqcService.getIpqcPage(pageReqVO).getList(); |
| | | List<MesQcIpqcRespVO> voList = buildIpqcRespVOList(list); |
| | | ExcelUtils.write(response, "è¿ç¨æ£éªå.xls", "æ°æ®", MesQcIpqcRespVO.class, voList); |
| | | List<MesQcQualityExportVO> exportList = buildIpqcQualityExportList(list); |
| | | ExcelUtils.write(response, "è¿ç¨æ£éªå.xls", "æ°æ®", MesQcQualityExportVO.class, exportList); |
| | | } |
| | | |
| | | // ==================== æ¼æ¥ VO ==================== |
| | |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcIpqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢æ£éªé¡¹ææ |
| | | Map<Long, String> indicatorSummaryMap = buildIndicatorSummaryMap(list); |
| | | // æ¼è£
VO |
| | | return BeanUtils.toBean(list, MesQcIpqcRespVO.class, vo -> { |
| | | findAndThen(workOrderMap, vo.getWorkOrderId(), workOrder -> vo |
| | |
| | | }); |
| | | findAndThen(userMap, vo.getInspectorUserId(), |
| | | user -> vo.setInspectorNickname(user.getNickname())); |
| | | vo.setIndicatorResultSummary(indicatorSummaryMap.getOrDefault(vo.getId(), "")); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºæ¯ä¸ªæ£éªåçæ£éªé¡¹ææ æ±æ»å符串ï¼qcType = IPQCï¼ |
| | | */ |
| | | private Map<Long, String> buildIndicatorSummaryMap(List<MesQcIpqcDO> list) { |
| | | Map<Long, String> indicatorSummaryMap = new HashMap<>(); |
| | | Set<Long> qcIds = convertSet(list, MesQcIpqcDO::getId); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return indicatorSummaryMap; |
| | | } |
| | | // æ QC ID æ¹éæ¥è¯¢æ£éªç»æ |
| | | List<MesQcIndicatorResultDO> indicatorResults = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), MesBizTypeConstants.QC_IPQC); |
| | | if (CollUtil.isEmpty(indicatorResults)) { |
| | | return indicatorSummaryMap; |
| | | } |
| | | // æ QC ID åç»ç»æ |
| | | Map<Long, List<MesQcIndicatorResultDO>> resultMap = indicatorResults.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDO::getQcId)); |
| | | // æ¹éæ¥è¯¢æ£éªç»ææç» |
| | | Set<Long> resultIds = convertSet(indicatorResults, MesQcIndicatorResultDO::getId); |
| | | List<MesQcIndicatorResultDetailDO> indicatorDetails = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultIds)); |
| | | // æç»æ ID åç»æç» |
| | | Map<Long, List<MesQcIndicatorResultDetailDO>> detailMapByResultId = indicatorDetails.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDetailDO::getResultId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Set<Long> indicatorIds = convertSet(indicatorDetails, MesQcIndicatorResultDetailDO::getIndicatorId); |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap(indicatorIds); |
| | | |
| | | // æå»ºæ¯ä¸ª QC çææ æ±æ»å符串 |
| | | resultMap.forEach((qcId, results) -> { |
| | | List<String> indicatorSummaries = new ArrayList<>(); |
| | | for (MesQcIndicatorResultDO result : results) { |
| | | List<MesQcIndicatorResultDetailDO> details = detailMapByResultId.getOrDefault(result.getId(), Collections.emptyList()); |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | // éè¿ indicatorId å
³èææ åç§°ï¼æ¥ä¸å°ååé为 "ææ " |
| | | String indicatorName = "ææ "; |
| | | MesQcIndicatorDO indicator = indicatorMap.get(detail.getIndicatorId()); |
| | | if (indicator != null && StrUtil.isNotBlank(indicator.getName())) { |
| | | indicatorName = indicator.getName(); |
| | | } |
| | | String value = detail.getValue(); |
| | | String remark = detail.getRemark(); |
| | | // æ ¼å¼å为 "ææ åç§°:å¼" æ "ææ åç§°:å¼(夿³¨)" |
| | | String indicatorStr = indicatorName + ":" + value; |
| | | if (StrUtil.isNotBlank(remark)) { |
| | | indicatorStr += "(" + remark + ")"; |
| | | } |
| | | indicatorSummaries.add(indicatorStr); |
| | | } |
| | | } |
| | | indicatorSummaryMap.put(qcId, String.join(", ", indicatorSummaries)); |
| | | }); |
| | | return indicatorSummaryMap; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå¯¼åºè¡ï¼ä¸åä¸è¡ï¼æ£éªææ / å¤å®ä¾æ®åèªè¡æç»å¹¶æ¼æ¥ |
| | | */ |
| | | private List<MesQcQualityExportVO> buildIpqcQualityExportList(List<MesQcIpqcDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcIpqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢ç©æ |
| | | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( |
| | | convertSet(list, MesQcIpqcDO::getItemId)); |
| | | // æ¹éæ¥è¯¢è¡æç» |
| | | List<MesQcIpqcLineDO> lines = ipqcLineMapper.selectListByIpqcIds(convertSet(list, MesQcIpqcDO::getId)); |
| | | Map<Long, List<MesQcIpqcLineDO>> lineMap = lines.stream() |
| | | .collect(Collectors.groupingBy(MesQcIpqcLineDO::getIpqcId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = CollUtil.isEmpty(lines) ? Collections.emptyMap() |
| | | : indicatorService.getIndicatorMap(convertSet(lines, MesQcIpqcLineDO::getIndicatorId)); |
| | | // æ¹éæ¥è¯¢å®æµå¼ï¼æ£éªå ID -> {ææ ID -> 宿µå¼} |
| | | Map<Long, Map<Long, String>> measureMap = buildMeasureValueMap( |
| | | convertSet(list, MesQcIpqcDO::getId), MesBizTypeConstants.QC_IPQC); |
| | | // ç»è£
导åºè¡ |
| | | List<MesQcQualityExportVO> exportList = new ArrayList<>(list.size()); |
| | | for (MesQcIpqcDO ipqc : list) { |
| | | MesQcQualityExportVO vo = new MesQcQualityExportVO(); |
| | | vo.setDocName(ipqc.getName()); |
| | | MesMdItemDO item = itemMap.get(ipqc.getItemId()); |
| | | vo.setItemName(item != null ? item.getName() : ""); |
| | | // IPQC æ æ¹æ¬¡å·åæ®µï¼æç¨æ¥æºåæ®ç¼å·ï¼ä¸è¬ä¸ºç产工åå·ï¼ä½ä¸ºæ¹å· |
| | | vo.setBatchNo(ipqc.getSourceDocCode()); |
| | | vo.setInspectDate(MesQcQualityExportVO.formatDateTime(ipqc.getInspectDate())); |
| | | List<String> indicatorNames = new ArrayList<>(); |
| | | List<String> judgementSegments = new ArrayList<>(); |
| | | for (MesQcIpqcLineDO line : lineMap.getOrDefault(ipqc.getId(), Collections.emptyList())) { |
| | | MesQcIndicatorDO indicator = indicatorMap.get(line.getIndicatorId()); |
| | | String name = indicator != null && StrUtil.isNotBlank(indicator.getName()) |
| | | ? indicator.getName() : ""; |
| | | String range = MesQcQualityExportVO.buildRangeText( |
| | | line.getStandardValue(), line.getMinThreshold(), line.getMaxThreshold()); |
| | | if (StrUtil.isNotBlank(name)) { |
| | | String measuredValue = measureMap |
| | | .getOrDefault(ipqc.getId(), Collections.emptyMap()) |
| | | .get(line.getIndicatorId()); |
| | | indicatorNames.add(StrUtil.isNotBlank(measuredValue) ? name + ":" + measuredValue : name); |
| | | if (StrUtil.isNotBlank(range)) { |
| | | judgementSegments.add(name + range); |
| | | } |
| | | } |
| | | } |
| | | vo.setIndicatorNames(String.join("ã", indicatorNames)); |
| | | vo.setJudgementBasis(String.join("ï¼", judgementSegments)); |
| | | vo.setCheckResultText(getCheckResultLabel(ipqc.getCheckResult())); |
| | | findAndThen(userMap, ipqc.getInspectorUserId(), |
| | | user -> vo.setInspectorName(user.getNickname())); |
| | | // ææ å®¡æ ¸äººæ°æ®æ¥æºï¼å¯¼åºç©ºå |
| | | vo.setAuditorName(""); |
| | | vo.setRemark(ipqc.getRemark()); |
| | | exportList.add(vo); |
| | | } |
| | | return exportList; |
| | | } |
| | | |
| | | /** |
| | | * æå»º æ£éªå ID -> {ææ ID -> 宿µå¼} æ å°ï¼å®æµå¼åèªæ£éªç»ææç»è¡¨ |
| | | */ |
| | | private Map<Long, Map<Long, String>> buildMeasureValueMap(Set<Long> qcIds, int qcType) { |
| | | Map<Long, Map<Long, String>> measureMap = new HashMap<>(); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return measureMap; |
| | | } |
| | | List<MesQcIndicatorResultDO> results = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), qcType); |
| | | if (CollUtil.isEmpty(results)) { |
| | | return measureMap; |
| | | } |
| | | Map<Long, Long> resultQcMap = results.stream() |
| | | .collect(Collectors.toMap(MesQcIndicatorResultDO::getId, MesQcIndicatorResultDO::getQcId)); |
| | | List<MesQcIndicatorResultDetailDO> details = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultQcMap.keySet())); |
| | | if (CollUtil.isEmpty(details)) { |
| | | return measureMap; |
| | | } |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | Long qcId = resultQcMap.get(detail.getResultId()); |
| | | if (qcId == null) { |
| | | continue; |
| | | } |
| | | measureMap.computeIfAbsent(qcId, k -> new HashMap<>()) |
| | | .put(detail.getIndicatorId(), detail.getValue()); |
| | | } |
| | | return measureMap; |
| | | } |
| | | |
| | | private String getCheckResultLabel(Integer checkResult) { |
| | | if (checkResult == null) { |
| | | return ""; |
| | | } |
| | | return DictFrameworkUtils.parseDictDataLabel( |
| | | DictTypeConstants.MES_QC_CHECK_RESULT, String.valueOf(checkResult)); |
| | | } |
| | | |
| | | } |
| | |
| | | @Schema(description = "æ£æµäººåç¨æ· ID", example = "1") |
| | | private Long inspectorUserId; |
| | | |
| | | @Schema(description = "æ£æµæ¥æ") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] inspectDate; |
| | | |
| | | } |
| | |
| | | @DictFormat(DictTypeConstants.MES_QC_CHECK_RESULT) |
| | | private Integer checkResult; |
| | | |
| | | // ========== æ£éªé¡¹ææ ========== |
| | | |
| | | @Schema(description = "æ£éªé¡¹ææ æ±æ»", example = "å¤è§:è¯å¥½(OK), 尺寸:100.00mm(OK)") |
| | | @ExcelProperty("æ£éªé¡¹ææ ") |
| | | private String indicatorResultSummary; |
| | | |
| | | @Schema(description = "æ£æµæ¥æ") |
| | | @ExcelProperty("æ£æµæ¥æ") |
| | | private LocalDateTime inspectDate; |
| | |
| | | @Schema(description = "产åç©æ ID", example = "50") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "è´¨æ£æ¹æ¡ ID", example = "5") |
| | | private Long templateId; |
| | | |
| | | // ========== æ°é ========== |
| | | |
| | | @Schema(description = "æ£æµæ°é", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.iqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.iqc.vo.MesQcIqcPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.iqc.vo.MesQcIqcRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.iqc.vo.MesQcIqcSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcQualityExportVO; |
| | | import cn.iocoder.yudao.module.srm.api.supplier.SrmSupplierApi; |
| | | import cn.iocoder.yudao.module.srm.api.supplier.dto.SrmSupplierRespDTO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcLineDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.iqc.MesQcIqcLineMapper; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.iqc.MesQcIqcService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | @Resource |
| | | private SrmSupplierApi srmSupplierApi; |
| | | @Resource |
| | | private MesQcIndicatorResultService indicatorResultService; |
| | | @Resource |
| | | private MesQcIndicatorService indicatorService; |
| | | @Resource |
| | | private MesMdItemService itemService; |
| | | @Resource |
| | | private MesMdUnitMeasureService unitMeasureService; |
| | | @Resource |
| | | private MesQcIqcLineMapper iqcLineMapper; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | HttpServletResponse response) throws IOException { |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | | List<MesQcIqcDO> list = iqcService.getIqcPage(pageReqVO).getList(); |
| | | List<MesQcIqcRespVO> voList = buildIqcRespVOList(list); |
| | | ExcelUtils.write(response, "æ¥ææ£éªå.xls", "æ°æ®", MesQcIqcRespVO.class, voList); |
| | | List<MesQcQualityExportVO> exportList = buildIqcQualityExportList(list); |
| | | ExcelUtils.write(response, "æ¥ææ£éªå.xls", "æ°æ®", MesQcQualityExportVO.class, exportList); |
| | | } |
| | | |
| | | // ==================== æ¼æ¥ VO ==================== |
| | |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcIqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢æ£éªé¡¹ææ |
| | | Set<Long> qcIds = convertSet(list, MesQcIqcDO::getId); |
| | | Map<Long, List<MesQcIndicatorResultDO>> indicatorResultMap = new HashMap<>(); |
| | | if (CollUtil.isNotEmpty(qcIds)) { |
| | | // æQC IDæ¹éæ¥è¯¢æ£éªç»æï¼IQCç±»åï¼ |
| | | List<MesQcIndicatorResultDO> indicatorResults = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), MesBizTypeConstants.QC_IQC); |
| | | indicatorResults.forEach(result -> { |
| | | indicatorResultMap.computeIfAbsent(result.getQcId(), k -> new ArrayList<>()).add(result); |
| | | }); |
| | | } |
| | | // æ¹éæ¥è¯¢æ£éªç»ææç»å¹¶æå»ºææ æ å° |
| | | Map<Long, String> indicatorSummaryMap = new HashMap<>(); |
| | | if (CollUtil.isNotEmpty(indicatorResultMap)) { |
| | | Set<Long> resultIds = new HashSet<>(); |
| | | indicatorResultMap.values().forEach(results -> { |
| | | results.forEach(result -> resultIds.add(result.getId())); |
| | | }); |
| | | if (CollUtil.isNotEmpty(resultIds)) { |
| | | // æ¹éæ¥è¯¢æ£éªç»ææç» |
| | | List<MesQcIndicatorResultDetailDO> indicatorDetails = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultIds)); |
| | | // æç»æIDåç»æç» |
| | | Map<Long, List<MesQcIndicatorResultDetailDO>> detailMapByResultId = indicatorDetails.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDetailDO::getResultId)); |
| | | |
| | | // æ¹éæ¥è¯¢æ£æµææ ï¼indicatorId -> indicatorï¼ |
| | | Set<Long> indicatorIds = convertSet(indicatorDetails, MesQcIndicatorResultDetailDO::getIndicatorId); |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap(indicatorIds); |
| | | |
| | | // æå»ºæ¯ä¸ªQCçææ æ±æ»å符串 |
| | | indicatorResultMap.forEach((qcId, results) -> { |
| | | List<String> indicatorSummaries = new ArrayList<>(); |
| | | for (MesQcIndicatorResultDO result : results) { |
| | | List<MesQcIndicatorResultDetailDO> details = detailMapByResultId.getOrDefault(result.getId(), Collections.emptyList()); |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | // éè¿ indicatorId å
³èææ åç§°ï¼æ¥ä¸å°ååé为 "ææ " |
| | | String indicatorName = "ææ "; |
| | | MesQcIndicatorDO indicator = indicatorMap.get(detail.getIndicatorId()); |
| | | if (indicator != null && StrUtil.isNotBlank(indicator.getName())) { |
| | | indicatorName = indicator.getName(); |
| | | } |
| | | String value = detail.getValue(); |
| | | String remark = detail.getRemark(); |
| | | // æ ¼å¼å为 "ææ åç§°:å¼" æ "ææ åç§°:å¼(夿³¨)" |
| | | String indicatorStr = indicatorName + ":" + value; |
| | | if (StrUtil.isNotBlank(remark)) { |
| | | indicatorStr += "(" + remark + ")"; |
| | | } |
| | | indicatorSummaries.add(indicatorStr); |
| | | } |
| | | } |
| | | // ç¨éå·è¿æ¥å¤ä¸ªææ |
| | | indicatorSummaryMap.put(qcId, String.join(", ", indicatorSummaries)); |
| | | }); |
| | | } |
| | | } |
| | | // æ¼è£
VO |
| | | return BeanUtils.toBean(list, MesQcIqcRespVO.class, vo -> { |
| | | findAndThen(vendorMap, vo.getVendorId(), |
| | |
| | | }); |
| | | findAndThen(userMap, vo.getInspectorUserId(), |
| | | user -> vo.setInspectorNickname(user.getNickname())); |
| | | // 设置æ£éªé¡¹ææ æ±æ» |
| | | vo.setIndicatorResultSummary(indicatorSummaryMap.getOrDefault(vo.getId(), "")); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå¯¼åºè¡ï¼ä¸åä¸è¡ï¼æ£éªææ / å¤å®ä¾æ®åèªè¡æç»å¹¶æ¼æ¥ |
| | | */ |
| | | private List<MesQcQualityExportVO> buildIqcQualityExportList(List<MesQcIqcDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcIqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢ç©æ |
| | | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( |
| | | convertSet(list, MesQcIqcDO::getItemId)); |
| | | // æ¹éæ¥è¯¢è¡æç» |
| | | List<MesQcIqcLineDO> lines = iqcLineMapper.selectListByIqcIds(convertSet(list, MesQcIqcDO::getId)); |
| | | Map<Long, List<MesQcIqcLineDO>> lineMap = lines.stream() |
| | | .collect(Collectors.groupingBy(MesQcIqcLineDO::getIqcId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = CollUtil.isEmpty(lines) ? Collections.emptyMap() |
| | | : indicatorService.getIndicatorMap(convertSet(lines, MesQcIqcLineDO::getIndicatorId)); |
| | | // æ¹éæ¥è¯¢å®æµå¼ï¼æ£éªå ID -> {ææ ID -> 宿µå¼} |
| | | Map<Long, Map<Long, String>> measureMap = buildMeasureValueMap( |
| | | convertSet(list, MesQcIqcDO::getId), MesBizTypeConstants.QC_IQC); |
| | | // ç»è£
导åºè¡ |
| | | List<MesQcQualityExportVO> exportList = new ArrayList<>(list.size()); |
| | | for (MesQcIqcDO iqc : list) { |
| | | MesQcQualityExportVO vo = new MesQcQualityExportVO(); |
| | | vo.setDocName(iqc.getName()); |
| | | MesMdItemDO item = itemMap.get(iqc.getItemId()); |
| | | vo.setItemName(item != null ? item.getName() : ""); |
| | | vo.setBatchNo(iqc.getVendorBatch()); |
| | | vo.setInspectDate(MesQcQualityExportVO.formatDateTime(iqc.getInspectDate())); |
| | | List<String> indicatorNames = new ArrayList<>(); |
| | | List<String> judgementSegments = new ArrayList<>(); |
| | | for (MesQcIqcLineDO line : lineMap.getOrDefault(iqc.getId(), Collections.emptyList())) { |
| | | MesQcIndicatorDO indicator = indicatorMap.get(line.getIndicatorId()); |
| | | String name = indicator != null && StrUtil.isNotBlank(indicator.getName()) |
| | | ? indicator.getName() : ""; |
| | | String range = MesQcQualityExportVO.buildRangeText( |
| | | line.getStandardValue(), line.getMinThreshold(), line.getMaxThreshold()); |
| | | if (StrUtil.isNotBlank(name)) { |
| | | String measuredValue = measureMap |
| | | .getOrDefault(iqc.getId(), Collections.emptyMap()) |
| | | .get(line.getIndicatorId()); |
| | | indicatorNames.add(StrUtil.isNotBlank(measuredValue) ? name + ":" + measuredValue : name); |
| | | if (StrUtil.isNotBlank(range)) { |
| | | judgementSegments.add(name + range); |
| | | } |
| | | } |
| | | } |
| | | vo.setIndicatorNames(String.join("ã", indicatorNames)); |
| | | vo.setJudgementBasis(String.join("ï¼", judgementSegments)); |
| | | vo.setCheckResultText(getCheckResultLabel(iqc.getCheckResult())); |
| | | findAndThen(userMap, iqc.getInspectorUserId(), |
| | | user -> vo.setInspectorName(user.getNickname())); |
| | | // ææ å®¡æ ¸äººæ°æ®æ¥æºï¼å¯¼åºç©ºå |
| | | vo.setAuditorName(""); |
| | | vo.setRemark(iqc.getRemark()); |
| | | exportList.add(vo); |
| | | } |
| | | return exportList; |
| | | } |
| | | |
| | | /** |
| | | * æå»º æ£éªå ID -> {ææ ID -> 宿µå¼} æ å°ï¼å®æµå¼åèªæ£éªç»ææç»è¡¨ |
| | | */ |
| | | private Map<Long, Map<Long, String>> buildMeasureValueMap(Set<Long> qcIds, int qcType) { |
| | | Map<Long, Map<Long, String>> measureMap = new HashMap<>(); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return measureMap; |
| | | } |
| | | List<MesQcIndicatorResultDO> results = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), qcType); |
| | | if (CollUtil.isEmpty(results)) { |
| | | return measureMap; |
| | | } |
| | | Map<Long, Long> resultQcMap = results.stream() |
| | | .collect(Collectors.toMap(MesQcIndicatorResultDO::getId, MesQcIndicatorResultDO::getQcId)); |
| | | List<MesQcIndicatorResultDetailDO> details = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultQcMap.keySet())); |
| | | if (CollUtil.isEmpty(details)) { |
| | | return measureMap; |
| | | } |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | Long qcId = resultQcMap.get(detail.getResultId()); |
| | | if (qcId == null) { |
| | | continue; |
| | | } |
| | | measureMap.computeIfAbsent(qcId, k -> new HashMap<>()) |
| | | .put(detail.getIndicatorId(), detail.getValue()); |
| | | } |
| | | return measureMap; |
| | | } |
| | | |
| | | private String getCheckResultLabel(Integer checkResult) { |
| | | if (checkResult == null) { |
| | | return ""; |
| | | } |
| | | return DictFrameworkUtils.parseDictDataLabel( |
| | | DictTypeConstants.MES_QC_CHECK_RESULT, String.valueOf(checkResult)); |
| | | } |
| | | |
| | | } |
| | |
| | | @DictFormat(DictTypeConstants.MES_QC_CHECK_RESULT) |
| | | private Integer checkResult; |
| | | |
| | | // ========== æ£éªé¡¹ææ ========== |
| | | |
| | | @Schema(description = "æ£éªé¡¹ææ æ±æ»", example = "å¤è§:è¯å¥½(OK), 尺寸:100.00mm(OK)") |
| | | @ExcelProperty("æ£éªé¡¹ææ ") |
| | | private String indicatorResultSummary; |
| | | |
| | | @Schema(description = "æ¥ææ¥æ") |
| | | @ExcelProperty("æ¥ææ¥æ") |
| | | private LocalDateTime receiveDate; |
| | |
| | | @NotNull(message = "产åç©æä¸è½ä¸ºç©º") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "è´¨æ£æ¹æ¡ ID", example = "5") |
| | | private Long templateId; |
| | | |
| | | // ========== æ°é ========== |
| | | |
| | | @Schema(description = "æ¬æ¬¡æ¥æ¶æ°é", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcQualityExportVO; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcLineDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcLineMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | private MesMdItemService itemService; |
| | | @Resource |
| | | private MesMdUnitMeasureService unitMeasureService; |
| | | @Resource |
| | | private MesQcIndicatorResultService indicatorResultService; |
| | | @Resource |
| | | private MesQcIndicatorService indicatorService; |
| | | @Resource |
| | | private MesQcOqcLineMapper oqcLineMapper; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | HttpServletResponse response) throws IOException { |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | | List<MesQcOqcDO> list = oqcService.getOqcPage(pageReqVO).getList(); |
| | | List<MesQcOqcRespVO> voList = buildOqcRespVOList(list); |
| | | ExcelUtils.write(response, "åºè´§æ£éªå.xls", "æ°æ®", MesQcOqcRespVO.class, voList); |
| | | List<MesQcQualityExportVO> exportList = buildOqcQualityExportList(list); |
| | | ExcelUtils.write(response, "åºè´§æ£éªå.xls", "æ°æ®", MesQcQualityExportVO.class, exportList); |
| | | } |
| | | |
| | | // ==================== æ¼æ¥ VO ==================== |
| | |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcOqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢æ£éªé¡¹ææ |
| | | Map<Long, String> indicatorSummaryMap = buildIndicatorSummaryMap(list); |
| | | // æ¼è£
VO |
| | | return BeanUtils.toBean(list, MesQcOqcRespVO.class, vo -> { |
| | | findAndThen(clientMap, vo.getClientId(), |
| | |
| | | }); |
| | | findAndThen(userMap, vo.getInspectorUserId(), |
| | | user -> vo.setInspectorNickname(user.getNickname())); |
| | | vo.setIndicatorResultSummary(indicatorSummaryMap.getOrDefault(vo.getId(), "")); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå¯¼åºè¡ï¼ä¸åä¸è¡ï¼æ£éªææ / å¤å®ä¾æ®åèªè¡æç»å¹¶æ¼æ¥ |
| | | */ |
| | | private List<MesQcQualityExportVO> buildOqcQualityExportList(List<MesQcOqcDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcOqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢ç©æ |
| | | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( |
| | | convertSet(list, MesQcOqcDO::getItemId)); |
| | | // æ¹éæ¥è¯¢è¡æç» |
| | | List<MesQcOqcLineDO> lines = oqcLineMapper.selectListByOqcIds(convertSet(list, MesQcOqcDO::getId)); |
| | | Map<Long, List<MesQcOqcLineDO>> lineMap = lines.stream() |
| | | .collect(Collectors.groupingBy(MesQcOqcLineDO::getOqcId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = CollUtil.isEmpty(lines) ? Collections.emptyMap() |
| | | : indicatorService.getIndicatorMap(convertSet(lines, MesQcOqcLineDO::getIndicatorId)); |
| | | // æ¹éæ¥è¯¢å®æµå¼ï¼æ£éªå ID -> {ææ ID -> 宿µå¼} |
| | | Map<Long, Map<Long, String>> measureMap = buildMeasureValueMap( |
| | | convertSet(list, MesQcOqcDO::getId), MesBizTypeConstants.QC_OQC); |
| | | // ç»è£
导åºè¡ |
| | | List<MesQcQualityExportVO> exportList = new ArrayList<>(list.size()); |
| | | for (MesQcOqcDO oqc : list) { |
| | | MesQcQualityExportVO vo = new MesQcQualityExportVO(); |
| | | vo.setDocName(oqc.getName()); |
| | | MesMdItemDO item = itemMap.get(oqc.getItemId()); |
| | | vo.setItemName(item != null ? item.getName() : ""); |
| | | vo.setBatchNo(oqc.getBatchCode()); |
| | | vo.setInspectDate(MesQcQualityExportVO.formatDateTime(oqc.getInspectDate())); |
| | | List<String> indicatorNames = new ArrayList<>(); |
| | | List<String> judgementSegments = new ArrayList<>(); |
| | | for (MesQcOqcLineDO line : lineMap.getOrDefault(oqc.getId(), Collections.emptyList())) { |
| | | MesQcIndicatorDO indicator = indicatorMap.get(line.getIndicatorId()); |
| | | String name = indicator != null && StrUtil.isNotBlank(indicator.getName()) |
| | | ? indicator.getName() : ""; |
| | | String range = MesQcQualityExportVO.buildRangeText( |
| | | line.getStandardValue(), line.getMinThreshold(), line.getMaxThreshold()); |
| | | if (StrUtil.isNotBlank(name)) { |
| | | String measuredValue = measureMap |
| | | .getOrDefault(oqc.getId(), Collections.emptyMap()) |
| | | .get(line.getIndicatorId()); |
| | | indicatorNames.add(StrUtil.isNotBlank(measuredValue) ? name + ":" + measuredValue : name); |
| | | if (StrUtil.isNotBlank(range)) { |
| | | judgementSegments.add(name + range); |
| | | } |
| | | } |
| | | } |
| | | vo.setIndicatorNames(String.join("ã", indicatorNames)); |
| | | vo.setJudgementBasis(String.join("ï¼", judgementSegments)); |
| | | vo.setCheckResultText(getCheckResultLabel(oqc.getCheckResult())); |
| | | findAndThen(userMap, oqc.getInspectorUserId(), |
| | | user -> vo.setInspectorName(user.getNickname())); |
| | | // ææ å®¡æ ¸äººæ°æ®æ¥æºï¼å¯¼åºç©ºå |
| | | vo.setAuditorName(""); |
| | | vo.setRemark(oqc.getRemark()); |
| | | exportList.add(vo); |
| | | } |
| | | return exportList; |
| | | } |
| | | |
| | | /** |
| | | * æå»º æ£éªå ID -> {ææ ID -> 宿µå¼} æ å°ï¼å®æµå¼åèªæ£éªç»ææç»è¡¨ |
| | | */ |
| | | private Map<Long, Map<Long, String>> buildMeasureValueMap(Set<Long> qcIds, int qcType) { |
| | | Map<Long, Map<Long, String>> measureMap = new HashMap<>(); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return measureMap; |
| | | } |
| | | List<MesQcIndicatorResultDO> results = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), qcType); |
| | | if (CollUtil.isEmpty(results)) { |
| | | return measureMap; |
| | | } |
| | | Map<Long, Long> resultQcMap = results.stream() |
| | | .collect(Collectors.toMap(MesQcIndicatorResultDO::getId, MesQcIndicatorResultDO::getQcId)); |
| | | List<MesQcIndicatorResultDetailDO> details = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultQcMap.keySet())); |
| | | if (CollUtil.isEmpty(details)) { |
| | | return measureMap; |
| | | } |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | Long qcId = resultQcMap.get(detail.getResultId()); |
| | | if (qcId == null) { |
| | | continue; |
| | | } |
| | | measureMap.computeIfAbsent(qcId, k -> new HashMap<>()) |
| | | .put(detail.getIndicatorId(), detail.getValue()); |
| | | } |
| | | return measureMap; |
| | | } |
| | | |
| | | private String getCheckResultLabel(Integer checkResult) { |
| | | if (checkResult == null) { |
| | | return ""; |
| | | } |
| | | return DictFrameworkUtils.parseDictDataLabel( |
| | | DictTypeConstants.MES_QC_CHECK_RESULT, String.valueOf(checkResult)); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºæ¯ä¸ªæ£éªåçæ£éªé¡¹ææ æ±æ»å符串ï¼qcType = OQCï¼ |
| | | */ |
| | | private Map<Long, String> buildIndicatorSummaryMap(List<MesQcOqcDO> list) { |
| | | Map<Long, String> indicatorSummaryMap = new HashMap<>(); |
| | | Set<Long> qcIds = convertSet(list, MesQcOqcDO::getId); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return indicatorSummaryMap; |
| | | } |
| | | // æ QC ID æ¹éæ¥è¯¢æ£éªç»æ |
| | | List<MesQcIndicatorResultDO> indicatorResults = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), MesBizTypeConstants.QC_OQC); |
| | | if (CollUtil.isEmpty(indicatorResults)) { |
| | | return indicatorSummaryMap; |
| | | } |
| | | // æ QC ID åç»ç»æ |
| | | Map<Long, List<MesQcIndicatorResultDO>> resultMap = indicatorResults.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDO::getQcId)); |
| | | // æ¹éæ¥è¯¢æ£éªç»ææç» |
| | | Set<Long> resultIds = convertSet(indicatorResults, MesQcIndicatorResultDO::getId); |
| | | List<MesQcIndicatorResultDetailDO> indicatorDetails = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultIds)); |
| | | // æç»æ ID åç»æç» |
| | | Map<Long, List<MesQcIndicatorResultDetailDO>> detailMapByResultId = indicatorDetails.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDetailDO::getResultId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Set<Long> indicatorIds = convertSet(indicatorDetails, MesQcIndicatorResultDetailDO::getIndicatorId); |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap(indicatorIds); |
| | | |
| | | // æå»ºæ¯ä¸ª QC çææ æ±æ»å符串 |
| | | resultMap.forEach((qcId, results) -> { |
| | | List<String> indicatorSummaries = new ArrayList<>(); |
| | | for (MesQcIndicatorResultDO result : results) { |
| | | List<MesQcIndicatorResultDetailDO> details = detailMapByResultId.getOrDefault(result.getId(), Collections.emptyList()); |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | // éè¿ indicatorId å
³èææ åç§°ï¼æ¥ä¸å°ååé为 "ææ " |
| | | String indicatorName = "ææ "; |
| | | MesQcIndicatorDO indicator = indicatorMap.get(detail.getIndicatorId()); |
| | | if (indicator != null && StrUtil.isNotBlank(indicator.getName())) { |
| | | indicatorName = indicator.getName(); |
| | | } |
| | | String value = detail.getValue(); |
| | | String remark = detail.getRemark(); |
| | | // æ ¼å¼å为 "ææ åç§°:å¼" æ "ææ åç§°:å¼(夿³¨)" |
| | | String indicatorStr = indicatorName + ":" + value; |
| | | if (StrUtil.isNotBlank(remark)) { |
| | | indicatorStr += "(" + remark + ")"; |
| | | } |
| | | indicatorSummaries.add(indicatorStr); |
| | | } |
| | | } |
| | | indicatorSummaryMap.put(qcId, String.join(", ", indicatorSummaries)); |
| | | }); |
| | | return indicatorSummaryMap; |
| | | } |
| | | |
| | | } |
| | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | |
| | | @Schema(description = "管çåå° - MES åºè´§æ£éªåå页 Request VO") |
| | | @Data |
| | |
| | | @Schema(description = "æ£æµç»æ", example = "1") |
| | | private Integer checkResult; |
| | | |
| | | @Schema(description = "æ£æµæ¥æ") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] inspectDate; |
| | | |
| | | } |
| | |
| | | @DictFormat(DictTypeConstants.MES_QC_CHECK_RESULT) |
| | | private Integer checkResult; |
| | | |
| | | // ========== æ£éªé¡¹ææ ========== |
| | | |
| | | @Schema(description = "æ£éªé¡¹ææ æ±æ»", example = "å¤è§:è¯å¥½(OK), 尺寸:100.00mm(OK)") |
| | | @ExcelProperty("æ£éªé¡¹ææ ") |
| | | private String indicatorResultSummary; |
| | | |
| | | @Schema(description = "åºè´§æ¥æ") |
| | | @ExcelProperty("åºè´§æ¥æ") |
| | | private LocalDateTime outDate; |
| | |
| | | @NotNull(message = "产åç©æä¸è½ä¸ºç©º") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "è´¨æ£æ¹æ¡ ID", example = "5") |
| | | private Long templateId; |
| | | |
| | | // ========== æ°é ========== |
| | | |
| | | @Schema(description = "æ¬æ¬¡åºè´§æ°é", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.rqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcQualityExportVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcLineDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc.MesQcRqcLineMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.rqc.MesQcRqcService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | private MesMdItemService itemService; |
| | | @Resource |
| | | private MesMdUnitMeasureService unitMeasureService; |
| | | @Resource |
| | | private MesQcIndicatorResultService indicatorResultService; |
| | | @Resource |
| | | private MesQcIndicatorService indicatorService; |
| | | @Resource |
| | | private MesQcRqcLineMapper rqcLineMapper; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | HttpServletResponse response) throws IOException { |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | | List<MesQcRqcDO> list = rqcService.getRqcPage(pageReqVO).getList(); |
| | | List<MesQcRqcRespVO> voList = buildRqcRespVOList(list); |
| | | ExcelUtils.write(response, "éè´§æ£éªå.xls", "æ°æ®", MesQcRqcRespVO.class, voList); |
| | | List<MesQcQualityExportVO> exportList = buildRqcQualityExportList(list); |
| | | ExcelUtils.write(response, "éè´§æ£éªå.xls", "æ°æ®", MesQcQualityExportVO.class, exportList); |
| | | } |
| | | |
| | | // ==================== æ¼æ¥ VO ==================== |
| | |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcRqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢æ£éªé¡¹ææ |
| | | Map<Long, String> indicatorSummaryMap = buildIndicatorSummaryMap(list); |
| | | // æ¼è£
VO |
| | | return BeanUtils.toBean(list, MesQcRqcRespVO.class, vo -> { |
| | | findAndThen(itemMap, vo.getItemId(), item -> { |
| | |
| | | }); |
| | | findAndThen(userMap, vo.getInspectorUserId(), |
| | | user -> vo.setInspectorNickname(user.getNickname())); |
| | | vo.setIndicatorResultSummary(indicatorSummaryMap.getOrDefault(vo.getId(), "")); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºæ¯ä¸ªæ£éªåçæ£éªé¡¹ææ æ±æ»å符串ï¼qcType = RQCï¼ |
| | | */ |
| | | private Map<Long, String> buildIndicatorSummaryMap(List<MesQcRqcDO> list) { |
| | | Map<Long, String> indicatorSummaryMap = new HashMap<>(); |
| | | Set<Long> qcIds = convertSet(list, MesQcRqcDO::getId); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return indicatorSummaryMap; |
| | | } |
| | | // æ QC ID æ¹éæ¥è¯¢æ£éªç»æ |
| | | List<MesQcIndicatorResultDO> indicatorResults = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), MesBizTypeConstants.QC_RQC); |
| | | if (CollUtil.isEmpty(indicatorResults)) { |
| | | return indicatorSummaryMap; |
| | | } |
| | | // æ QC ID åç»ç»æ |
| | | Map<Long, List<MesQcIndicatorResultDO>> resultMap = indicatorResults.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDO::getQcId)); |
| | | // æ¹éæ¥è¯¢æ£éªç»ææç» |
| | | Set<Long> resultIds = convertSet(indicatorResults, MesQcIndicatorResultDO::getId); |
| | | List<MesQcIndicatorResultDetailDO> indicatorDetails = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultIds)); |
| | | // æç»æ ID åç»æç» |
| | | Map<Long, List<MesQcIndicatorResultDetailDO>> detailMapByResultId = indicatorDetails.stream() |
| | | .collect(Collectors.groupingBy(MesQcIndicatorResultDetailDO::getResultId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Set<Long> indicatorIds = convertSet(indicatorDetails, MesQcIndicatorResultDetailDO::getIndicatorId); |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap(indicatorIds); |
| | | |
| | | // æå»ºæ¯ä¸ª QC çææ æ±æ»å符串 |
| | | resultMap.forEach((qcId, results) -> { |
| | | List<String> indicatorSummaries = new ArrayList<>(); |
| | | for (MesQcIndicatorResultDO result : results) { |
| | | List<MesQcIndicatorResultDetailDO> details = detailMapByResultId.getOrDefault(result.getId(), Collections.emptyList()); |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | // éè¿ indicatorId å
³èææ åç§°ï¼æ¥ä¸å°ååé为 "ææ " |
| | | String indicatorName = "ææ "; |
| | | MesQcIndicatorDO indicator = indicatorMap.get(detail.getIndicatorId()); |
| | | if (indicator != null && StrUtil.isNotBlank(indicator.getName())) { |
| | | indicatorName = indicator.getName(); |
| | | } |
| | | String value = detail.getValue(); |
| | | String remark = detail.getRemark(); |
| | | // æ ¼å¼å为 "ææ åç§°:å¼" æ "ææ åç§°:å¼(夿³¨)" |
| | | String indicatorStr = indicatorName + ":" + value; |
| | | if (StrUtil.isNotBlank(remark)) { |
| | | indicatorStr += "(" + remark + ")"; |
| | | } |
| | | indicatorSummaries.add(indicatorStr); |
| | | } |
| | | } |
| | | indicatorSummaryMap.put(qcId, String.join(", ", indicatorSummaries)); |
| | | }); |
| | | return indicatorSummaryMap; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå¯¼åºè¡ï¼ä¸åä¸è¡ï¼æ£éªææ / å¤å®ä¾æ®åèªè¡æç»å¹¶æ¼æ¥ |
| | | */ |
| | | private List<MesQcQualityExportVO> buildRqcQualityExportList(List<MesQcRqcDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¹éæ¥è¯¢æ£æµäººå |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcRqcDO::getInspectorUserId)); |
| | | // æ¹éæ¥è¯¢ç©æ |
| | | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( |
| | | convertSet(list, MesQcRqcDO::getItemId)); |
| | | // æ¹éæ¥è¯¢è¡æç» |
| | | List<MesQcRqcLineDO> lines = rqcLineMapper.selectListByRqcIds(convertSet(list, MesQcRqcDO::getId)); |
| | | Map<Long, List<MesQcRqcLineDO>> lineMap = lines.stream() |
| | | .collect(Collectors.groupingBy(MesQcRqcLineDO::getRqcId)); |
| | | // æ¹éæ¥è¯¢æ£æµææ |
| | | Map<Long, MesQcIndicatorDO> indicatorMap = CollUtil.isEmpty(lines) ? Collections.emptyMap() |
| | | : indicatorService.getIndicatorMap(convertSet(lines, MesQcRqcLineDO::getIndicatorId)); |
| | | // æ¹éæ¥è¯¢å®æµå¼ï¼æ£éªå ID -> {ææ ID -> 宿µå¼} |
| | | Map<Long, Map<Long, String>> measureMap = buildMeasureValueMap( |
| | | convertSet(list, MesQcRqcDO::getId), MesBizTypeConstants.QC_RQC); |
| | | // ç»è£
导åºè¡ |
| | | List<MesQcQualityExportVO> exportList = new ArrayList<>(list.size()); |
| | | for (MesQcRqcDO rqc : list) { |
| | | MesQcQualityExportVO vo = new MesQcQualityExportVO(); |
| | | vo.setDocName(rqc.getName()); |
| | | MesMdItemDO item = itemMap.get(rqc.getItemId()); |
| | | vo.setItemName(item != null ? item.getName() : ""); |
| | | vo.setBatchNo(rqc.getBatchCode()); |
| | | vo.setInspectDate(MesQcQualityExportVO.formatDateTime(rqc.getInspectDate())); |
| | | List<String> indicatorNames = new ArrayList<>(); |
| | | List<String> judgementSegments = new ArrayList<>(); |
| | | for (MesQcRqcLineDO line : lineMap.getOrDefault(rqc.getId(), Collections.emptyList())) { |
| | | MesQcIndicatorDO indicator = indicatorMap.get(line.getIndicatorId()); |
| | | String name = indicator != null && StrUtil.isNotBlank(indicator.getName()) |
| | | ? indicator.getName() : ""; |
| | | String range = MesQcQualityExportVO.buildRangeText( |
| | | line.getStandardValue(), line.getMinThreshold(), line.getMaxThreshold()); |
| | | if (StrUtil.isNotBlank(name)) { |
| | | String measuredValue = measureMap |
| | | .getOrDefault(rqc.getId(), Collections.emptyMap()) |
| | | .get(line.getIndicatorId()); |
| | | indicatorNames.add(StrUtil.isNotBlank(measuredValue) ? name + ":" + measuredValue : name); |
| | | if (StrUtil.isNotBlank(range)) { |
| | | judgementSegments.add(name + range); |
| | | } |
| | | } |
| | | } |
| | | vo.setIndicatorNames(String.join("ã", indicatorNames)); |
| | | vo.setJudgementBasis(String.join("ï¼", judgementSegments)); |
| | | vo.setCheckResultText(getCheckResultLabel(rqc.getCheckResult())); |
| | | findAndThen(userMap, rqc.getInspectorUserId(), |
| | | user -> vo.setInspectorName(user.getNickname())); |
| | | // ææ å®¡æ ¸äººæ°æ®æ¥æºï¼å¯¼åºç©ºå |
| | | vo.setAuditorName(""); |
| | | vo.setRemark(rqc.getRemark()); |
| | | exportList.add(vo); |
| | | } |
| | | return exportList; |
| | | } |
| | | |
| | | /** |
| | | * æå»º æ£éªå ID -> {ææ ID -> 宿µå¼} æ å°ï¼å®æµå¼åèªæ£éªç»ææç»è¡¨ |
| | | */ |
| | | private Map<Long, Map<Long, String>> buildMeasureValueMap(Set<Long> qcIds, int qcType) { |
| | | Map<Long, Map<Long, String>> measureMap = new HashMap<>(); |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return measureMap; |
| | | } |
| | | List<MesQcIndicatorResultDO> results = indicatorResultService.getIndicatorResultListByQcIdsAndType( |
| | | new ArrayList<>(qcIds), qcType); |
| | | if (CollUtil.isEmpty(results)) { |
| | | return measureMap; |
| | | } |
| | | Map<Long, Long> resultQcMap = results.stream() |
| | | .collect(Collectors.toMap(MesQcIndicatorResultDO::getId, MesQcIndicatorResultDO::getQcId)); |
| | | List<MesQcIndicatorResultDetailDO> details = indicatorResultService.getIndicatorResultDetailListByResultIds( |
| | | new ArrayList<>(resultQcMap.keySet())); |
| | | if (CollUtil.isEmpty(details)) { |
| | | return measureMap; |
| | | } |
| | | for (MesQcIndicatorResultDetailDO detail : details) { |
| | | Long qcId = resultQcMap.get(detail.getResultId()); |
| | | if (qcId == null) { |
| | | continue; |
| | | } |
| | | measureMap.computeIfAbsent(qcId, k -> new HashMap<>()) |
| | | .put(detail.getIndicatorId(), detail.getValue()); |
| | | } |
| | | return measureMap; |
| | | } |
| | | |
| | | private String getCheckResultLabel(Integer checkResult) { |
| | | if (checkResult == null) { |
| | | return ""; |
| | | } |
| | | return DictFrameworkUtils.parseDictDataLabel( |
| | | DictTypeConstants.MES_QC_CHECK_RESULT, String.valueOf(checkResult)); |
| | | } |
| | | |
| | | } |
| | |
| | | @Schema(description = "æ£æµäººåç¨æ· ID", example = "1") |
| | | private Long inspectorUserId; |
| | | |
| | | @Schema(description = "æ£æµæ¥æ") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] inspectDate; |
| | | |
| | | } |
| | |
| | | @DictFormat(DictTypeConstants.MES_QC_CHECK_RESULT) |
| | | private Integer checkResult; |
| | | |
| | | // ========== æ£éªé¡¹ææ ========== |
| | | |
| | | @Schema(description = "æ£éªé¡¹ææ æ±æ»", example = "å¤è§:è¯å¥½(OK), 尺寸:100.00mm(OK)") |
| | | @ExcelProperty("æ£éªé¡¹ææ ") |
| | | private String indicatorResultSummary; |
| | | |
| | | @Schema(description = "æ£æµæ¥æ") |
| | | @ExcelProperty("æ£æµæ¥æ") |
| | | private LocalDateTime inspectDate; |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.template; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemOptionRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.mdm.MesMdmItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; |
| | | import cn.iocoder.yudao.module.mes.service.mdm.MesMdmItemService; |
| | | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateItemService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | |
| | | @Resource |
| | | private MesQcTemplateItemService templateItemService; |
| | | @Resource |
| | | private MesQcTemplateService templateService; |
| | | @Resource |
| | | private MesMdmItemService mdmItemService; |
| | | @Resource |
| | |
| | | return success(new PageResult<>(buildItemRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | | } |
| | | |
| | | @GetMapping("/list-by-item-and-type") |
| | | @Operation(summary = "æ ¹æ®ç©ææå·¥å/ä»»å¡åæ£æµç§ç±»è·åå¯ç¨è´¨æ£æ¹æ¡") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| | | public CommonResult<List<MesQcTemplateItemOptionRespVO>> getTemplateItemOptionList( |
| | | @RequestParam(value = "qcType", required = false) Integer qcType, |
| | | @RequestParam(value = "itemId", required = false) Long itemId, |
| | | @RequestParam(value = "workOrderId", required = false) Long workOrderId, |
| | | @RequestParam(value = "taskId", required = false) Long taskId) { |
| | | List<MesQcTemplateItemDO> list = templateItemService.getTemplateItemList( |
| | | itemId, qcType, workOrderId, taskId); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | Map<Long, MesQcTemplateDO> templateMap = templateService.getTemplateMap( |
| | | convertSet(list, MesQcTemplateItemDO::getTemplateId)); |
| | | List<MesQcTemplateItemOptionRespVO> result = BeanUtils.toBean(list, |
| | | MesQcTemplateItemOptionRespVO.class, vo -> { |
| | | MesQcTemplateDO template = templateMap.get(vo.getTemplateId()); |
| | | if (template != null) { |
| | | vo.setTemplateCode(template.getCode()).setTemplateName(template.getName()); |
| | | } |
| | | }); |
| | | return success(result); |
| | | } |
| | | |
| | | // ==================== æ¼æ¥ VO ==================== |
| | | |
| | | private List<MesQcTemplateItemRespVO> buildItemRespVOList(List<MesQcTemplateItemDO> list) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Schema(description = "管çåå° - MES è´¨æ£æ¹æ¡-产åå
³è é项 Response VO") |
| | | @Data |
| | | public class MesQcTemplateItemOptionRespVO { |
| | | |
| | | @Schema(description = "产åå
³èç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | private Long id; |
| | | |
| | | @Schema(description = "è´¨æ£æ¹æ¡ ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long templateId; |
| | | |
| | | @Schema(description = "è´¨æ£æ¹æ¡ç¼å·", example = "QC_CAR_001") |
| | | private String templateCode; |
| | | |
| | | @Schema(description = "è´¨æ£æ¹æ¡åç§°", example = "汽车æ´è½¦è´¨æ£æ¹æ¡") |
| | | private String templateName; |
| | | |
| | | @Schema(description = "æä½æ£æµæ°", example = "5") |
| | | private Integer quantityCheck; |
| | | |
| | | @Schema(description = "æå¤§ä¸åæ ¼æ°", example = "0") |
| | | private Integer quantityUnqualified; |
| | | |
| | | @Schema(description = "æå¤§è´å½ç¼ºé·çï¼%ï¼", example = "0") |
| | | private BigDecimal criticalRate; |
| | | |
| | | @Schema(description = "æå¤§ä¸¥é缺é·çï¼%ï¼", example = "0") |
| | | private BigDecimal majorRate; |
| | | |
| | | @Schema(description = "æå¤§è½»å¾®ç¼ºé·çï¼%ï¼", example = "100") |
| | | private BigDecimal minorRate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.vo; |
| | | |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | * MES è´¨æ£æ£éªåå¯¼åº Excel VOï¼IQC/IPQC/OQC/RQC å
±ç¨ï¼ |
| | | * |
| | | * <p>导åºåï¼æ£éªååç§° / ç©æåç§° / æ¹å· / æ£æµæ¥æ / æ£éªææ / å¤å®ä¾æ® / æ£éªç»æ / æ£éªäºº / å®¡æ ¸äºº / 夿³¨ã |
| | | * æ£éªææ ãå¤å®ä¾æ®åèªæ£éªåè¡æç»ï¼å®¡æ ¸äººææ æ°æ®æ¥æºï¼å¯¼åºä¸ºç©ºåã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Data |
| | | public class MesQcQualityExportVO { |
| | | |
| | | @ExcelProperty("æ£éªååç§°") |
| | | private String docName; |
| | | |
| | | @ExcelProperty("ç©æåç§°") |
| | | private String itemName; |
| | | |
| | | @ExcelProperty("æ¹å·") |
| | | private String batchNo; |
| | | |
| | | @ExcelProperty("æ£æµæ¥æ") |
| | | private String inspectDate; |
| | | |
| | | @ExcelProperty("æ£éªææ ") |
| | | private String indicatorNames; |
| | | |
| | | @ExcelProperty("å¤å®ä¾æ®") |
| | | private String judgementBasis; |
| | | |
| | | @ExcelProperty("æ£éªç»æ") |
| | | private String checkResultText; |
| | | |
| | | @ExcelProperty("æ£éªäºº") |
| | | private String inspectorName; |
| | | |
| | | @ExcelProperty("å®¡æ ¸äºº") |
| | | private String auditorName; |
| | | |
| | | @ExcelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * æ ¼å¼åæ£æµæ¥æï¼ä»
æ¥æï¼ï¼null è¿å空串 |
| | | */ |
| | | public static String formatDateTime(LocalDateTime dateTime) { |
| | | if (dateTime == null) { |
| | | return ""; |
| | | } |
| | | return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | |
| | | /** |
| | | * 廿æ°å¼å°¾é¨æ æä¹ç 0ï¼å¦ 35.000000 -> 35ã2.500000 -> 2.5 |
| | | */ |
| | | public static String formatDecimal(BigDecimal value) { |
| | | if (value == null) { |
| | | return ""; |
| | | } |
| | | return value.stripTrailingZeros().toPlainString(); |
| | | } |
| | | |
| | | /** |
| | | * ç»è£
åä¸ªæ£æµé¡¹çå¤å®ä¾æ®ææ¬ï¼ |
| | | * ä¸ä¸éåæ -> "ä¸é~ä¸é"ï¼ä»
æä¸é -> "â¤ä¸é"ï¼ä»
æä¸é -> "â¥ä¸é"ï¼ |
| | | * åæ ä½ç»äºæ åå¼ -> "æ åå¼ æ åå¼"ï¼å¦åè¿å空串ã |
| | | */ |
| | | public static String buildRangeText(BigDecimal standardValue, BigDecimal minThreshold, BigDecimal maxThreshold) { |
| | | if (maxThreshold != null && minThreshold != null) { |
| | | return formatDecimal(minThreshold) + "~" + formatDecimal(maxThreshold); |
| | | } |
| | | if (maxThreshold != null) { |
| | | return "â¤" + formatDecimal(maxThreshold); |
| | | } |
| | | if (minThreshold != null) { |
| | | return "â¥" + formatDecimal(minThreshold); |
| | | } |
| | | if (standardValue != null) { |
| | | return "æ åå¼ " + formatDecimal(standardValue); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | } |
| | |
| | | return selectList(MesQcIndicatorResultDetailDO::getResultId, resultId); |
| | | } |
| | | |
| | | default List<MesQcIndicatorResultDetailDO> selectListByResultIds(List<Long> resultIds) { |
| | | return selectList(MesQcIndicatorResultDetailDO::getResultId, resultIds); |
| | | } |
| | | |
| | | default void deleteByResultId(Long resultId) { |
| | | delete(new LambdaQueryWrapperX<MesQcIndicatorResultDetailDO>() |
| | | .eq(MesQcIndicatorResultDetailDO::getResultId, resultId)); |
| | |
| | | .eq(MesQcIndicatorResultDO::getQcType, qcType)); |
| | | } |
| | | |
| | | default List<MesQcIndicatorResultDO> selectListByQcIdsAndType(List<Long> qcIds, Integer qcType) { |
| | | return selectList(new LambdaQueryWrapperX<MesQcIndicatorResultDO>() |
| | | .in(MesQcIndicatorResultDO::getQcId, qcIds) |
| | | .eq(MesQcIndicatorResultDO::getQcType, qcType)); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcLineDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return selectList(MesQcIpqcLineDO::getIpqcId, ipqcId); |
| | | } |
| | | |
| | | default List<MesQcIpqcLineDO> selectListByIpqcIds(Collection<Long> ipqcIds) { |
| | | return selectList(new LambdaQueryWrapperX<MesQcIpqcLineDO>() |
| | | .in(MesQcIpqcLineDO::getIpqcId, ipqcIds) |
| | | .orderByAsc(MesQcIpqcLineDO::getId)); |
| | | } |
| | | |
| | | default void deleteByIpqcId(Long ipqcId) { |
| | | delete(new LambdaQueryWrapperX<MesQcIpqcLineDO>() |
| | | .eq(MesQcIpqcLineDO::getIpqcId, ipqcId)); |
| | |
| | | .eqIfPresent(MesQcIpqcDO::getCheckResult, reqVO.getCheckResult()) |
| | | .eqIfPresent(MesQcIpqcDO::getStatus, reqVO.getStatus()) |
| | | .eqIfPresent(MesQcIpqcDO::getInspectorUserId, reqVO.getInspectorUserId()) |
| | | .betweenIfPresent(MesQcIpqcDO::getInspectDate, reqVO.getInspectDate()) |
| | | .orderByDesc(MesQcIpqcDO::getId)); |
| | | } |
| | | |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcLineDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return selectList(MesQcIqcLineDO::getIqcId, iqcId); |
| | | } |
| | | |
| | | default List<MesQcIqcLineDO> selectListByIqcIds(Collection<Long> iqcIds) { |
| | | return selectList(new LambdaQueryWrapperX<MesQcIqcLineDO>() |
| | | .in(MesQcIqcLineDO::getIqcId, iqcIds) |
| | | .orderByAsc(MesQcIqcLineDO::getId)); |
| | | } |
| | | |
| | | default void deleteByIqcId(Long iqcId) { |
| | | delete(new LambdaQueryWrapperX<MesQcIqcLineDO>() |
| | | .eq(MesQcIqcLineDO::getIqcId, iqcId)); |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcLineDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return selectList(MesQcOqcLineDO::getOqcId, oqcId); |
| | | } |
| | | |
| | | default List<MesQcOqcLineDO> selectListByOqcIds(Collection<Long> oqcIds) { |
| | | return selectList(new LambdaQueryWrapperX<MesQcOqcLineDO>() |
| | | .in(MesQcOqcLineDO::getOqcId, oqcIds) |
| | | .orderByAsc(MesQcOqcLineDO::getId)); |
| | | } |
| | | |
| | | default void deleteByOqcId(Long oqcId) { |
| | | delete(new LambdaQueryWrapperX<MesQcOqcLineDO>() |
| | | .eq(MesQcOqcLineDO::getOqcId, oqcId)); |
| | |
| | | .likeIfPresent(MesQcOqcDO::getBatchCode, reqVO.getBatchCode()) |
| | | .eqIfPresent(MesQcOqcDO::getItemId, reqVO.getItemId()) |
| | | .eqIfPresent(MesQcOqcDO::getCheckResult, reqVO.getCheckResult()) |
| | | .betweenIfPresent(MesQcOqcDO::getInspectDate, reqVO.getInspectDate()) |
| | | .orderByDesc(MesQcOqcDO::getId)); |
| | | } |
| | | |
| | |
| | | .likeIfPresent(MesQcOqcDO::getBatchCode, reqVO.getBatchCode()) |
| | | .eqIfPresent(MesQcOqcDO::getItemId, reqVO.getItemId()) |
| | | .eqIfPresent(MesQcOqcDO::getCheckResult, reqVO.getCheckResult()) |
| | | .betweenIfPresent(MesQcOqcDO::getInspectDate, reqVO.getInspectDate()) |
| | | .orderByDesc(MesQcOqcDO::getId); |
| | | if (permittedClientIds != null) { |
| | | if (CollUtil.isEmpty(permittedClientIds)) { |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcLineDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return selectList(MesQcRqcLineDO::getRqcId, rqcId); |
| | | } |
| | | |
| | | default List<MesQcRqcLineDO> selectListByRqcIds(Collection<Long> rqcIds) { |
| | | return selectList(new LambdaQueryWrapperX<MesQcRqcLineDO>() |
| | | .in(MesQcRqcLineDO::getRqcId, rqcIds) |
| | | .orderByAsc(MesQcRqcLineDO::getId)); |
| | | } |
| | | |
| | | default void deleteByRqcId(Long rqcId) { |
| | | delete(new LambdaQueryWrapperX<MesQcRqcLineDO>() |
| | | .eq(MesQcRqcLineDO::getRqcId, rqcId)); |
| | |
| | | .eqIfPresent(MesQcRqcDO::getCheckResult, reqVO.getCheckResult()) |
| | | .eqIfPresent(MesQcRqcDO::getStatus, reqVO.getStatus()) |
| | | .eqIfPresent(MesQcRqcDO::getInspectorUserId, reqVO.getInspectorUserId()) |
| | | .betweenIfPresent(MesQcRqcDO::getInspectDate, reqVO.getInspectDate()) |
| | | .orderByDesc(MesQcRqcDO::getId)); |
| | | } |
| | | |
| | |
| | | List<MesQcIndicatorResultDetailDO> getDetailListByResultId(Long resultId); |
| | | |
| | | /** |
| | | * æ ¹æ®æ£éªç»æ ID å表æ¹éè·åæç»å表 |
| | | * |
| | | * @param resultIds æ£éªç»æ ID å表 |
| | | * @return æç»å表 |
| | | */ |
| | | List<MesQcIndicatorResultDetailDO> getDetailListByResultIds(List<Long> resultIds); |
| | | |
| | | /** |
| | | * æ ¹æ®æ£éªç»æ ID å 餿ææç» |
| | | * |
| | | * @param resultId æ£éªç»æ ID |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<MesQcIndicatorResultDetailDO> getDetailListByResultIds(List<Long> resultIds) { |
| | | return detailMapper.selectListByResultIds(resultIds); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteDetailByResultId(Long resultId) { |
| | | detailMapper.delete(new LambdaQueryWrapperX<MesQcIndicatorResultDetailDO>() |
| | | .eq(MesQcIndicatorResultDetailDO::getResultId, resultId)); |
| | |
| | | List<MesQcIndicatorResultDetailDO> getIndicatorResultDetailListByResultId(Long resultId); |
| | | |
| | | /** |
| | | * è·åæå®è´¨æ£åä¸çæ£éªç»æå表 |
| | | * |
| | | * @param qcId è´¨æ£å ID |
| | | * @param qcType è´¨æ£ç±»å |
| | | * @return ç»æå表 |
| | | */ |
| | | List<MesQcIndicatorResultDO> getIndicatorResultListByQcIdAndType(Long qcId, Integer qcType); |
| | | |
| | | /** |
| | | * è·åæå®è´¨æ£åä¸çæ£éªç»ææ°é |
| | | * |
| | | * @param qcId è´¨æ£å ID |
| | |
| | | Long getIndicatorResultCountByQcIdAndType(Long qcId, Integer qcType); |
| | | |
| | | /** |
| | | * æ ¹æ®è´¨æ£åIDå表åç±»åæ¹éè·åæ£éªç»æ |
| | | * |
| | | * @param qcIds è´¨æ£å ID å表 |
| | | * @param qcType è´¨æ£ç±»å |
| | | * @return æ£éªç»æå表 |
| | | */ |
| | | List<MesQcIndicatorResultDO> getIndicatorResultListByQcIdsAndType(List<Long> qcIds, Integer qcType); |
| | | |
| | | /** |
| | | * æ ¹æ®ç»æIDå表æ¹éè·åæ£éªç»ææç» |
| | | * |
| | | * @param resultIds ç»æIDå表 |
| | | * @return æ£éªç»ææç»å表 |
| | | */ |
| | | List<MesQcIndicatorResultDetailDO> getIndicatorResultDetailListByResultIds(List<Long> resultIds); |
| | | |
| | | /** |
| | | * æ ¡éªæå®è´¨æ£åä¸è³å°åå¨ä¸æ¡æ£éªç»æ |
| | | * |
| | | * @param qcId è´¨æ£å ID |
| | |
| | | return resultMapper.selectCountByQcIdAndType(qcId, qcType); |
| | | } |
| | | |
| | | /** |
| | | * è·åæå®è´¨æ£åä¸çæ£éªç»æå表 |
| | | * |
| | | * @param qcId è´¨æ£å ID |
| | | * @param qcType è´¨æ£ç±»å |
| | | * @return ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<MesQcIndicatorResultDO> getIndicatorResultListByQcIdAndType(Long qcId, Integer qcType) { |
| | | return resultMapper.selectListByQcIdAndType(qcId, qcType); |
| | | } |
| | | |
| | | @Override |
| | | public List<MesQcIndicatorResultDO> getIndicatorResultListByQcIdsAndType(List<Long> qcIds, Integer qcType) { |
| | | if (CollUtil.isEmpty(qcIds)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return resultMapper.selectListByQcIdsAndType(qcIds, qcType); |
| | | } |
| | | |
| | | @Override |
| | | public List<MesQcIndicatorResultDetailDO> getIndicatorResultDetailListByResultIds(List<Long> resultIds) { |
| | | if (CollUtil.isEmpty(resultIds)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return resultDetailService.getDetailListByResultIds(resultIds); |
| | | } |
| | | |
| | | @Override |
| | | public void validateIndicatorResultExistsByQcIdAndType(Long qcId, Integer qcType) { |
| | | Long resultCount = getIndicatorResultCountByQcIdAndType(qcId, qcType); |
| | |
| | | package cn.iocoder.yudao.module.mes.service.qc.ipqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | |
| | | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); |
| | | // 1.3 ç¡®å®æ£éªç©æï¼æä»»å¡æ¶åä»»å¡çç©æï¼æ 任塿¶åå·¥åç产å |
| | | Long itemId = (ctx.task() != null) ? ctx.task().getItemId() : workOrder.getProductId(); |
| | | // 1.4 æ ¹æ®ç©æ + æ£éªç±»åèªå¨å¹é
æ¨¡æ¿ |
| | | MesQcTemplateItemDO templateItem = templateItemService.getRequiredTemplateByItemIdAndType( |
| | | itemId, MesQcTypeEnum.IPQC.getType()); |
| | | // 1.4 æ ¹æ®ç©æ + IPQC ç±»åæ¥æ¾å¯ç¨è´¨æ£æ¹æ¡ï¼æ¯æå端æ¾å¼æå®ï¼ |
| | | List<MesQcTemplateItemDO> templateItems = templateItemService.getTemplateItemList( |
| | | itemId, MesQcTypeEnum.IPQC.getType(), null, null); |
| | | if (CollUtil.isEmpty(templateItems)) { |
| | | throw exception(QC_NO_TEMPLATE); |
| | | } |
| | | MesQcTemplateItemDO templateItem = templateItems.get(0); |
| | | if (createReqVO.getTemplateId() != null) { |
| | | templateItem = templateItems.stream() |
| | | .filter(available -> Objects.equals(available.getTemplateId(), createReqVO.getTemplateId())) |
| | | .findFirst().orElse(null); |
| | | if (templateItem == null) { |
| | | throw exception(QC_NO_TEMPLATE); // æå®äºæ¹æ¡ä½ä¸å¨å¹é
å表ä¸ï¼æç» |
| | | } |
| | | } |
| | | Long templateId = templateItem.getTemplateId(); |
| | | // 1.5 è·åæ¥æºåæ®ç¼å· |
| | | String sourceDocCode = validateAndGetSourceDocCode( |
| | |
| | | // 1.2 æ ¡éªæ¥æºåæ®åæ°ï¼å¹¶éªè¯æ°æ®åå¨ |
| | | String sourceDocCode = validateAndGetSourceDocCode( |
| | | createReqVO.getSourceDocType(), createReqVO.getSourceDocId(), createReqVO.getSourceLineId()); |
| | | // 1.3 éè¿ itemId + IQC ç±»åèªå¨æ¥æ¾æ¨¡æ¿ |
| | | MesQcTemplateItemDO templateItem = templateItemService.getRequiredTemplateByItemIdAndType( |
| | | createReqVO.getItemId(), MesQcTypeEnum.IQC.getType()); |
| | | // 1.3 æ ¹æ®äº§å + IQC ç±»åæ¥æ¾å¯ç¨è´¨æ£æ¹æ¡ï¼æ¯æå端æ¾å¼æå®ï¼ |
| | | List<MesQcTemplateItemDO> templateItems = templateItemService.getTemplateItemList( |
| | | createReqVO.getItemId(), MesQcTypeEnum.IQC.getType(), null, null); |
| | | if (CollUtil.isEmpty(templateItems)) { |
| | | throw exception(QC_NO_TEMPLATE); |
| | | } |
| | | MesQcTemplateItemDO templateItem = templateItems.get(0); |
| | | if (createReqVO.getTemplateId() != null) { |
| | | templateItem = templateItems.stream() |
| | | .filter(item -> Objects.equals(item.getTemplateId(), createReqVO.getTemplateId())) |
| | | .findFirst().orElse(null); |
| | | if (templateItem == null) { |
| | | throw exception(QC_NO_TEMPLATE); // æå®äºæ¹æ¡ä½ä¸å¨å¹é
å表ä¸ï¼æç» |
| | | } |
| | | } |
| | | Long templateId = templateItem.getTemplateId(); |
| | | |
| | | // 2. æå
¥ä¸»è¡¨ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.qc.oqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | |
| | | // 1.2 æ ¡éªæ¥æºåæ®åæ°ï¼å¹¶éªè¯æ°æ®åå¨ |
| | | String sourceDocCode = validateAndGetSourceDocCode( |
| | | createReqVO.getSourceDocType(), createReqVO.getSourceLineId()); |
| | | // 1.3 æ ¹æ®äº§å + æ£éªç±»åèªå¨å¹é
æ¨¡æ¿ |
| | | MesQcTemplateItemDO templateItem = templateItemService.getRequiredTemplateByItemIdAndType( |
| | | createReqVO.getItemId(), MesQcTypeEnum.OQC.getType()); |
| | | // 1.3 æ ¹æ®äº§å + OQC ç±»åæ¥æ¾å¯ç¨è´¨æ£æ¹æ¡ï¼æ¯æå端æ¾å¼æå®ï¼ |
| | | List<MesQcTemplateItemDO> templateItems = templateItemService.getTemplateItemList( |
| | | createReqVO.getItemId(), MesQcTypeEnum.OQC.getType(), null, null); |
| | | if (CollUtil.isEmpty(templateItems)) { |
| | | throw exception(QC_NO_TEMPLATE); |
| | | } |
| | | MesQcTemplateItemDO templateItem = templateItems.get(0); |
| | | if (createReqVO.getTemplateId() != null) { |
| | | templateItem = templateItems.stream() |
| | | .filter(available -> Objects.equals(available.getTemplateId(), createReqVO.getTemplateId())) |
| | | .findFirst().orElse(null); |
| | | if (templateItem == null) { |
| | | throw exception(QC_NO_TEMPLATE); // æå®äºæ¹æ¡ä½ä¸å¨å¹é
å表ä¸ï¼æç» |
| | | } |
| | | } |
| | | Long templateId = templateItem.getTemplateId(); |
| | | |
| | | // 2. æå
¥ä¸»è¡¨ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.qc.rqc; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | |
| | | public Long createRqc(MesQcRqcSaveReqVO createReqVO) { |
| | | // 1.1 æ ¡éªæ°æ® |
| | | validateRqcSaveData(createReqVO); |
| | | // 1.2 æ ¹æ®ç©æ + æ£éªç±»åèªå¨å¹é
æ¨¡æ¿ |
| | | MesQcTemplateItemDO templateItem = templateItemService.getRequiredTemplateByItemIdAndType( |
| | | createReqVO.getItemId(), createReqVO.getType()); |
| | | // 1.2 æ ¹æ®ç©æ + RQC æ£æµç§ç±»æ¥æ¾å¯ç¨è´¨æ£æ¹æ¡ï¼æ¯æå端æ¾å¼æå®ï¼ |
| | | List<MesQcTemplateItemDO> templateItems = templateItemService.getTemplateItemList( |
| | | createReqVO.getItemId(), MesQcTypeEnum.RQC.getType(), null, null); |
| | | if (CollUtil.isEmpty(templateItems)) { |
| | | throw exception(QC_NO_TEMPLATE); |
| | | } |
| | | MesQcTemplateItemDO templateItem = templateItems.get(0); |
| | | if (createReqVO.getTemplateId() != null) { |
| | | templateItem = templateItems.stream() |
| | | .filter(available -> Objects.equals(available.getTemplateId(), createReqVO.getTemplateId())) |
| | | .findFirst().orElse(null); |
| | | if (templateItem == null) { |
| | | throw exception(QC_NO_TEMPLATE); // æå®äºæ¹æ¡ä½ä¸å¨å¹é
å表ä¸ï¼æç» |
| | | } |
| | | } |
| | | Long templateId = templateItem.getTemplateId(); |
| | | // 1.3 è·åæ¥æºåæ®ç¼å· |
| | | String sourceDocCode = validateAndGetSourceDocCode( |
| | |
| | | import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; |
| | | import jakarta.validation.Valid; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * MES è´¨æ£æ¹æ¡-产åå
³è Service æ¥å£ |
| | | * |
| | |
| | | */ |
| | | MesQcTemplateItemDO getRequiredTemplateByItemIdAndType(Long itemId, Integer qcType); |
| | | |
| | | /** |
| | | * æ ¹æ®äº§åç©æï¼æå·¥å/ä»»å¡ï¼å QC ç±»åï¼è·åææå¯ç¨çè´¨æ£æ¹æ¡äº§åå
³èå表 |
| | | * |
| | | * @param itemId 产åç©æ IDï¼mes_md_item.idï¼ï¼ä¸ workOrderId/taskId è³å°å
¶ä¸ |
| | | * @param qcType æ£æµç§ç±»ï¼æä¸¾ {@link MesQcTypeEnum}ï¼ |
| | | * @param workOrderId ç产工å IDï¼å¯éï¼IPQC åºæ¯ç¨äºè§£æäº§åç©æï¼ |
| | | * @param taskId çäº§ä»»å¡ IDï¼å¯éï¼ä¼å
ç¨äºè§£æäº§åç©æï¼ |
| | | * @return å¹é
ç产åå
³èå表ï¼ä¿æå顺åºï¼ï¼æ å¹é
è¿å空å表 |
| | | */ |
| | | List<MesQcTemplateItemDO> getTemplateItemList(Long itemId, Integer qcType, Long workOrderId, Long taskId); |
| | | |
| | | } |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateItemMapper; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskService; |
| | | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | |
| | | private MesQcTemplateService templateService; |
| | | @Resource |
| | | private MesMdItemService mesMdItemService; |
| | | @Resource |
| | | @Lazy |
| | | private MesProTaskService proTaskService; |
| | | @Resource |
| | | @Lazy |
| | | private MesProWorkOrderService proWorkOrderService; |
| | | |
| | | @Override |
| | | public Long createTemplateItem(MesQcTemplateItemSaveReqVO createReqVO) { |
| | |
| | | |
| | | @Override |
| | | public MesQcTemplateItemDO getRequiredTemplateByItemIdAndType(Long itemId, Integer qcType) { |
| | | // 1. æ¥åº itemId å
³èçææ templateItem |
| | | MesMdItemDO item1 = mesMdItemService.getItem(itemId); |
| | | List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(item1.getMdmItemId()); |
| | | List<MesQcTemplateItemDO> templateItems = getTemplateItemList(itemId, qcType, null, null); |
| | | if (CollUtil.isEmpty(templateItems)) { |
| | | throw exception(QC_NO_TEMPLATE); |
| | | } |
| | | // 2. çé types å
å« qcType ä¸ç¶æä¸ºå¼å¯çæ¨¡æ¿ |
| | | return templateItems.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public List<MesQcTemplateItemDO> getTemplateItemList(Long itemId, Integer qcType, Long workOrderId, Long taskId) { |
| | | // 1. è§£æçå®äº§åç©æ IDï¼ä»»å¡ä¼å
ï¼å
¶æ¬¡å·¥åï¼æåç´æ¥ç¨å
¥å |
| | | Long resolvedItemId = itemId; |
| | | if (taskId != null) { |
| | | resolvedItemId = proTaskService.validateTaskExists(taskId).getItemId(); |
| | | } else if (workOrderId != null) { |
| | | resolvedItemId = proWorkOrderService.validateWorkOrderExists(workOrderId).getProductId(); |
| | | } |
| | | if (resolvedItemId == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // 2. mes_md_item.id 转 mdm_item.idï¼äº§åå
³è表åçæ¯ mdm ç©æï¼ |
| | | MesMdItemDO item = mesMdItemService.getItem(resolvedItemId); |
| | | if (item == null || item.getMdmItemId() == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // 3. æ¥åºè¯¥ç©æå
³èçææäº§åå
³è |
| | | List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(item.getMdmItemId()); |
| | | if (CollUtil.isEmpty(templateItems)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // 4. è¿æ»¤ï¼æ¹æ¡å¯ç¨ä¸æ£æµç§ç±»å
å« qcTypeï¼è¿åå
¨é¨å¹é
项 |
| | | List<MesQcTemplateDO> templates = templateService.getTemplateList( |
| | | convertSet(templateItems, MesQcTemplateItemDO::getTemplateId)); |
| | | MesQcTemplateDO matchedTemplate = findFirst(templates, |
| | | t -> CommonStatusEnum.isEnable(t.getStatus()) && CollUtil.contains(t.getTypes(), qcType)); |
| | | if (matchedTemplate == null) { |
| | | throw exception(QC_NO_TEMPLATE); |
| | | } |
| | | // 3. è¿å对åºç templateItem |
| | | return findFirst(templateItems, |
| | | item -> Objects.equals(item.getTemplateId(), matchedTemplate.getId())); |
| | | Set<Long> matchedTemplateIds = templates.stream() |
| | | .filter(t -> CommonStatusEnum.isEnable(t.getStatus()) |
| | | && CollUtil.contains(t.getTypes(), qcType)) |
| | | .map(MesQcTemplateDO::getId) |
| | | .collect(Collectors.toSet()); |
| | | return templateItems.stream() |
| | | .filter(t -> matchedTemplateIds.contains(t.getTemplateId())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | } |