| | |
| | | private final NodeDeptQueryService nodeDeptQueryService; |
| | | private final FlowCommonService flowCommonService; |
| | | private final OssTemplate ossTemplate; |
| | | public static final String NODE_ID = "nodeId"; |
| | | |
| | | private final MachineService machineService; |
| | | |
| | | /** |
| | | * 准备替换流程需要的数据 |
| | |
| | | */ |
| | | @Transactional |
| | | public void start(ReplaceFlowStartVO startVO){ |
| | | |
| | | |
| | | flowProgramFileService.checkProgramFiles(startVO.getTempInstanceId(),true); |
| | | NcNode programPackage = nodeService.getById(startVO.getNodeId()); |
| | | |
| | | Map<String, Object> vars = new HashMap<>(); |
| | | |
| | | flowCommonService.putFlowVariablesByNode(vars,programPackage); |
| | | flowCommonService.putDefaultAssignees(vars,programPackage.getDrawingNo(),startVO.getAssignee()+""); |
| | | |
| | | vars.put(FlowContants.TITLE,startVO.getTitle()); |
| | | |
| | | //机床编号 |
| | | vars.put(FlowContants.MACHINE_CODE,programPackage.getMachineCode()); |
| | | //Machine machine = machineService.getByCode(programPackge.getMachineCode()); |
| | | //机床型号 |
| | | //if(machine != null) { |
| | | //vars.put(FlowContants.MACHINE_MODE, programPackge.getMachineMode()); |
| | | //} |
| | | vars.put(FlowContants.PROCESS_NO,programPackage.getProcessNo()); |
| | | vars.put(FlowContants.PROCESS_NAME,programPackage.getProcessName()); |
| | | vars.put(FlowContants.PROCESS_EDITION,programPackage.getProcessEdition()); |
| | | vars.put(FlowContants.CRAFT_EDITION,programPackage.getCraftEdition()); |
| | | |
| | | vars.put(FlowContants.DRAWING_NO,programPackage.getDrawingNo()); |
| | | vars.put(FlowContants.DRAWING_NO_EDITION,programPackage.getDrawingNoEdition()); |
| | | |
| | | vars.put(FlowContants.PROGRAM_PACKAGE_NAME,programPackage.getName()); |
| | | |
| | | vars.put(FlowContants.PRODUCT_MODEL,programPackage.getProductModel()); |
| | | vars.put(NODE_ID, startVO.getNodeId()); |
| | | |
| | | vars.put("comment", startVO.getComment()); |
| | | vars.put(FlowContants.MY_PROCESS_NAME,"替换流程"); |
| | | identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//设置流程发起人 |
| | | ProcessInstance inst = runtimeService.startProcessInstanceByKey(FlowContants.REPLACE_PROCESS_KEY,startVO.getNodeId()+"",vars); |
| | | //replaceProgramFileService.lambdaUpdate().eq(ReplaceProgramFile::getTempId,startVO.getTempId()).set(ReplaceProgramFile::getProcessInstanceId,inst.getProcessInstanceId()); |
| | | //更新节点的流程id,避免重复发起流程 |
| | | programPackage.setProcessInstanceId(inst.getId()); |
| | | this.nodeService.updateById(programPackage); |
| | | |
| | | /* |
| | | Task startTask = taskService.createTaskQuery() |
| | | .processInstanceId(inst.getId()) |
| | | .singleResult(); |
| | | |
| | | // 添加评论 |
| | | taskService.addComment(startTask.getId(), inst.getProcessInstanceId(),startVO.getComment()); |
| | | */ |
| | | flowProgramFileService.lambdaUpdate() |
| | | .eq(FlowProgramFile::getProcessInstanceId,startVO.getTempInstanceId()) |
| | | .set(FlowProgramFile::getProcessInstanceId,inst.getProcessInstanceId()).update(); |
| | | |
| | | } |
| | | /* |
| | | public void checkProgramFiles(String processInstanceId,boolean isPass) { |
| | | List<FlowProgramFile> flowPrograms = this.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId, processInstanceId).orderByAsc(FlowProgramFile::getCreateTime).list(); |
| | | List<FlowProgramFile> purePrograms = flowPrograms.stream().filter(FlowProgramFile::isProgram).toList(); |
| | | if(isPass && purePrograms.isEmpty()){ |
| | | throw new ServiceException("请上传程序文件"); |
| | | } |
| | | int totalSeg = 0; |
| | | |
| | | if(!purePrograms.isEmpty()){ |
| | | FlowProgramFile progFile = purePrograms.get(0); |
| | | totalSeg = ProgramFileNameCheckUtil.getProgramSegCount(progFile.getName()); |
| | | } |
| | | |
| | | if(totalSeg != purePrograms.size()){ |
| | | throw new ServiceException("应上传"+totalSeg+"段程序,实际上传"+flowPrograms.size()+"段"); |
| | | } |
| | | |
| | | }*/ |
| | | |
| | | /** |
| | | * 上传程序徐文件(编制节点调用) |