| | |
| | | import java.util.*; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | |
| | | .setCheckQuantity(createReqVO.getQualifiedQuantity().add(createReqVO.getUnqualifiedQuantity())) |
| | | .setSourceDocCode(sourceDocCode) |
| | | .setStatus(MesQcStatusEnum.DRAFT.getStatus()); |
| | | // 检测人员、检测日期、来料日期未填写时使用默认值,不影响流程 |
| | | if (iqc.getInspectorUserId() == null) { |
| | | iqc.setInspectorUserId(getLoginUserId()); |
| | | } |
| | | if (iqc.getInspectDate() == null) { |
| | | iqc.setInspectDate(LocalDateTime.now()); |
| | | } |
| | | if (iqc.getReceiveDate() == null) { |
| | | iqc.setReceiveDate(LocalDateTime.now()); |
| | | } |
| | | iqcMapper.insert(iqc); |
| | | |
| | | // 3. 从模板指标自动生成检验行 |
| | |
| | | if (reqVO.getItemId() != null) { |
| | | mdmItemApi.getItem(reqVO.getItemId()).getCheckedData(); |
| | | } |
| | | // 校验检测人员存在 |
| | | adminUserApi.validateUser(reqVO.getInspectorUserId()); |
| | | // 校验检测人员存在(非必填,未填写时由创建逻辑默认当前登录人) |
| | | if (reqVO.getInspectorUserId() != null) { |
| | | adminUserApi.validateUser(reqVO.getInspectorUserId()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | return; |
| | | } |
| | | if (ObjectUtil.hasNull(iqc.getSourceLineId(), iqc.getSourceDocId())) { |
| | | throw new IllegalArgumentException( |
| | | "IQC 单[" + iqc.getId() + "] sourceDocType 非空但 sourceLineId 或 sourceDocId 为空"); |
| | | throw exception(QC_IQC_SOURCE_DOC_PARAMS_MISSING); |
| | | } |
| | | |
| | | // 根据不同的来源单据类型,回写不同的单据 |
| | |
| | | outsourceReceiptService.updateOutsourceReceiptWhenIqcFinish(iqc.getSourceDocId(), iqc.getSourceLineId(), |
| | | iqc.getId(), iqc.getQualifiedQuantity(), iqc.getUnqualifiedQuantity()); |
| | | } else { |
| | | throw new IllegalArgumentException( |
| | | "IQC 单[" + iqc.getId() + "] sourceDocType=" + iqc.getSourceDocType() + " 无法识别,无法回写来源单据"); |
| | | throw exception(QC_IQC_SOURCE_DOC_TYPE_UNKNOWN, iqc.getSourceDocType()); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | templateItem = templateItemService.getRequiredTemplateByItemIdAndType( |
| | | line.getItemId(), MesQcTypeEnum.IQC.getType()); |
| | | } catch (Exception e) { |
| | | } catch (cn.iocoder.yudao.framework.common.exception.ServiceException e) { |
| | | if (!java.util.Objects.equals(e.getCode(), QC_NO_TEMPLATE.getCode())) throw e; |
| | | // 获取物料信息,提供更明确的错误提示 |
| | | String itemInfo = getItemInfo(line.getItemId()); |
| | | throw exception(QC_NO_TEMPLATE_FOR_ITEM, itemInfo); |
| | |
| | | Long templateId = templateItem.getTemplateId(); |
| | | |
| | | // 2. 生成检验单编码 |
| | | String code = "IQC" + System.currentTimeMillis(); |
| | | String code = "IQC" + UUID.randomUUID().toString().replace("-", ""); |
| | | |
| | | // 3. 创建 IQC 主表(待检验状态,初始合格数量为 0) |
| | | MesQcIqcDO iqc = new MesQcIqcDO(); |