| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import com.mzt.logapi.starter.annotation.LogRecord; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | | import static cn.iocoder.yudao.module.mes.enums.LogRecordConstants.*; |
| | | |
| | | /** |
| | | * MES 出货检验单(OQC) Service 实现类 |
| | |
| | | updateObj.setSourceDocType(null).setSourceDocId(null).setSourceLineId(null); // 不允许修改来源单据 |
| | | updateObj.setTemplateId(null); // 不允许修改模板 |
| | | updateObj.setItemId(null); // 不允许修改物料 |
| | | oqcMapper.updateById(updateObj); |
| | | // 编辑时允许清空客户;完成检验等局部更新仍保留原客户。 |
| | | updateObj.setClientId(null); |
| | | oqcMapper.update(updateObj, new LambdaUpdateWrapper<MesQcOqcDO>() |
| | | .eq(MesQcOqcDO::getId, updateReqVO.getId()) |
| | | .set(MesQcOqcDO::getClientId, updateReqVO.getClientId())); |
| | | } |
| | | |
| | | private void validateOqcSaveData(MesQcOqcSaveReqVO reqVO) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @LogRecord(type = MES_QC_OQC_TYPE, subType = MES_QC_OQC_IMPORT_SUB_TYPE, bizNo = "0", |
| | | success = MES_QC_OQC_IMPORT_SUCCESS) |
| | | public MesQcImportRespVO importOqcList(List<MesQcOqcImportExcelVO> importList) { |
| | | MesQcImportRespVO respVO = MesQcImportRespVO.builder() |
| | | .createList(new ArrayList<>()).failureList(new LinkedHashMap<>()).build(); |
| | | if (CollUtil.isEmpty(importList)) { |
| | | // 空文件也要给日志文案兜底,避免 {{#importSummary}} 取不到值 |
| | | OperateLogUtils.putImportSummary(respVO.getCreateList(), null, respVO.getFailureList()); |
| | | return respVO; |
| | | } |
| | | qcImportHelper.startImport(); |
| | |
| | | respVO.getFailureList().put(label, MesQcImportHelper.resolveImportErrorMessage(ex)); |
| | | } |
| | | } |
| | | // 记录导入结果汇总,供 @LogRecord 的 success 文案引用 |
| | | OperateLogUtils.putImportSummary(respVO.getCreateList(), null, respVO.getFailureList()); |
| | | return respVO; |
| | | } |
| | | |
| | |
| | | reqVO.setName(row.getName().trim()); |
| | | reqVO.setItemId(qcImportHelper.resolveItemId(row.getItemCode())); |
| | | Long clientId = qcImportHelper.resolveClientId(row.getClientName()); |
| | | qcImportHelper.validateClientPermission(clientId, row.getClientName().trim()); |
| | | qcImportHelper.validateClientPermission(clientId, StrUtil.trimToEmpty(row.getClientName())); |
| | | reqVO.setClientId(clientId); |
| | | reqVO.setBatchCode(StrUtil.trimToNull(row.getBatchCode())); |
| | | reqVO.setTemplateId(qcImportHelper.resolveTemplateId(row.getTemplateName())); |