| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessMapper; |
| | | import cn.iocoder.yudao.module.mes.service.pro.route.MesProRouteProcessService; |
| | | import cn.iocoder.yudao.module.mes.service.pd.processparamtemplate.MesPdProcessParamTemplateService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Resource |
| | | private MesProProcessMapper processMapper; |
| | | |
| | | @Resource |
| | | private MesPdProcessParamTemplateService paramTemplateService; |
| | | |
| | | @Resource |
| | | private MesProProcessContentService processContentService; |
| | |
| | | validateProcessCodeUnique(saveReqVO.getId(), saveReqVO.getCode()); |
| | | // 2. 校验名称唯一 |
| | | validateProcessNameUnique(saveReqVO.getId(), saveReqVO.getName()); |
| | | validateParamConfiguration(saveReqVO); |
| | | } |
| | | |
| | | private void validateParamConfiguration(MesProProcessSaveReqVO req) { |
| | | // 兼容未发送新字段的旧客户端:更新时保留已有配置。 |
| | | if (req.getParamCollectMode() == null) { |
| | | if (req.getId() == null) req.setParamCollectMode(0); |
| | | else { |
| | | MesProProcessDO current = processMapper.selectById(req.getId()); |
| | | if (current != null) { |
| | | req.setParamCollectMode(current.getParamCollectMode() == null ? 0 : current.getParamCollectMode()); |
| | | req.setParamTemplateId(current.getParamTemplateId()); |
| | | } |
| | | } |
| | | } |
| | | Integer mode = req.getParamCollectMode(); |
| | | if (mode == null || mode < 0 || mode > 2) throw exception(PRO_PROCESS_PARAM_CONFIG_INVALID); |
| | | if (mode != 0) { |
| | | if (req.getParamTemplateId() == null) throw exception(PRO_PROCESS_PARAM_TEMPLATE_REQUIRED); |
| | | paramTemplateService.validateProcessParamTemplateExists(req.getParamTemplateId()); |
| | | if (CollUtil.isEmpty(paramTemplateService.getProcessParamTemplateDetailListByTemplateId(req.getParamTemplateId()))) { |
| | | throw exception(PRO_WORK_ORDER_PARAM_RECORD_TEMPLATE_NO_DETAIL); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |