| | |
| | | @Transactional |
| | | public String start(TaskAssignVO startVO){ |
| | | Map<String, Object> vars = new HashMap<>(); |
| | | //this.putDefaultAssignees(vars,startVO.getDrawingNo()); |
| | | |
| | | ProduceDivision div = flowCommonService.putDefaultAssignees(vars,startVO.getDrawingNo(),null); |
| | | vars.put(FlowContants.ASSIGNEE,div.getTeamLeaderId());//第一个用户组长 |
| | | vars.put(FlowContants.TITLE,startVO.getTitle()); |
| | | |
| | | //临时流程标志,明确指定Y,属于临时流程 |
| | | vars.put(FlowContants.IS_TEMP_FLOW,FlowContants.Y.equals(startVO.getIsTempFlow())?FlowContants.Y:FlowContants.N); |
| | | //机床编号 |
| | | vars.put(FlowContants.MACHINE_CODE,startVO.getMachineCode()); |
| | | String workshop = nodeDeptQueryService.getWorkshopNameByMachineCode(startVO.getMachineCode()); |
| | |
| | | identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//设置流程发起人 |
| | | ProcessInstance inst = runtimeService.startProcessInstanceByKey(FlowContants.TRY_PROCESS_KEY,businessKey,vars); |
| | | |
| | | if(curedProgramPackage != null) {//存在已固化程序,复制原来的程序文件。创建节点仍然在编程人员提交以后 |
| | | copyFlowProgramFiles(curedProgramPackage.getProcessInstanceId(),inst.getProcessInstanceId()); |
| | | if(curedProgramPackage != null) {//存在已固化程序,复制原来的程序文件。 |
| | | copyFlowProgramFiles(curedProgramPackage.getId(),inst.getProcessInstanceId()); |
| | | |
| | | curedProgramPackage.setProcessInstanceId(inst.getProcessInstanceId()); |
| | | ncNodeService.updateById(curedProgramPackage); |
| | | } |
| | | |
| | | |
| | | return inst.getProcessInstanceId(); |
| | | } |
| | | |
| | | /** |
| | | * 将默认审批用户放入map中 |
| | | * @param vars 启动流程的变量map |
| | | * @param drawingNo 零组件号 |
| | | */ |
| | | void putDefaultAssignees(Map<String, Object> vars,String drawingNo){ |
| | | ProduceDivision div = produceDivisionService.getByDrawingNoWithQinzhe(drawingNo); |
| | | vars.put(FlowContants.TEAM_LEADER,div.getTeamLeaderId()); |
| | | vars.put(FlowContants.PROGRAMMER,div.getProgrammerId()); |
| | | vars.put(FlowContants.CHECKER,div.getCheckerId()); |
| | | vars.put(FlowContants.SENIOR,div.getSeniorId()); |
| | | |
| | | vars.put(FlowContants.ASSIGNEE,div.getTeamLeaderId());//第一个审批用户:组长 |
| | | } |
| | | |
| | | /** |
| | | * 复制流程程序文件 |
| | | * @param processInstanceId 新启动的流程id |
| | | */ |
| | | private void copyFlowProgramFiles(String oldProcessInstanceId,String processInstanceId) { |
| | | List<FlowProgramFile> fileList = flowProgramFileService.lambdaQuery() |
| | | .eq(FlowProgramFile::getProcessInstanceId,oldProcessInstanceId).list(); |
| | | private void copyFlowProgramFiles(long packageNameNodeId,String processInstanceId) { |
| | | List<Long> fileIds = ncNodeService.getProgramFilesByPackageId(packageNameNodeId).stream().map(NcNode::getFlowProgramFileId).toList(); |
| | | if(!fileIds.isEmpty()) { |
| | | List<FlowProgramFile> fileList = flowProgramFileService.lambdaQuery().in(FlowProgramFile::getId, fileIds).list(); |
| | | |
| | | for (FlowProgramFile file : fileList) { |
| | | FlowProgramFile newFile = new FlowProgramFile(); |
| | | BeanUtils.copyProperties(file, newFile); |
| | | EntityUtil.clearBaseProperties(newFile); |
| | | for (FlowProgramFile file : fileList) { |
| | | FlowProgramFile newFile = new FlowProgramFile(); |
| | | BeanUtils.copyProperties(file, newFile); |
| | | EntityUtil.clearBaseProperties(newFile); |
| | | |
| | | newFile.setProcessInstanceId(processInstanceId); |
| | | newFile.setProcessInstanceId(processInstanceId); |
| | | |
| | | this.flowProgramFileService.save(newFile); |
| | | this.flowProgramFileService.save(newFile); |
| | | } |
| | | } |
| | | } |
| | | |