| | |
| | | throw exception(WM_SALES_NOTICE_LINE_EMPTY); |
| | | } |
| | | |
| | | // 2. 全局免审批:直接进入待出库 |
| | | if (bpmProcessInstanceApi.isGlobalAutoApprove()) { |
| | | // 发货通知由仓库确认后直接出库,不再启动审批流程。 |
| | | salesNoticeMapper.updateById(new MesWmSalesNoticeDO() |
| | | .setId(id).setProcessInstanceId("").setStatus(APPROVED.getStatus())); |
| | | reserveSaleOrderOutStatus(notice); |
| | | return; |
| | | } |
| | | |
| | | // 3. 必须选择流程,且分类下存在激活的流程定义 |
| | | if (StrUtil.isBlank(processDefinitionKey)) { |
| | | throw exception(WM_SALES_NOTICE_SUBMIT_PROCESS_KEY_REQUIRED); |
| | | } |
| | | validateSalesNoticeApproveCategoryAndProcessDefinition(); |
| | | ProcessDefinition processDefinition = bpmProcessDefinitionService.getActiveProcessDefinition(processDefinitionKey); |
| | | // 区分「Key 不存在/已停用」与「流程存在但不属于发货审批分类」,分别给出可执行的提示 |
| | | if (processDefinition == null) { |
| | | throw exception(WM_SALES_NOTICE_BPM_PROCESS_KEY_INVALID, processDefinitionKey); |
| | | } |
| | | boolean inDeliveryCategory = bpmProcessDefinitionService |
| | | .getProcessDefinitionInfoListByCategory(SALES_DELIVERY_APPROVE_CATEGORY_CODE).stream() |
| | | .anyMatch(info -> Objects.equals(info.getProcessDefinitionId(), processDefinition.getId())); |
| | | if (!inDeliveryCategory) { |
| | | throw exception(WM_SALES_NOTICE_BPM_PROCESS_DEFINITION_NOT_IN_CATEGORY, |
| | | StrUtil.blankToDefault(processDefinition.getName(), processDefinitionKey)); |
| | | } |
| | | |
| | | // 4. 创建审批流程实例,进入审批中 |
| | | String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() |
| | | .setProcessDefinitionKey(processDefinitionKey).setBusinessKey(String.valueOf(id)) |
| | | .setVariables(Map.of("businessNo", notice.getCode()))); |
| | | salesNoticeMapper.updateById(new MesWmSalesNoticeDO() |
| | | .setId(id).setProcessInstanceId(processInstanceId).setStatus(APPROVING.getStatus())); |
| | | } |
| | | |
| | | @Override |