| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.basesetting.producedivision.entity.ProduceDivision; |
| | | import org.springblade.mdm.basesetting.producedivision.service.ProduceDivisionService; |
| | | import org.springblade.mdm.flow.constants.FlowContants; |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | import org.springblade.mdm.flow.entity.ReplaceProgramFile; |
| | |
| | | private final TaskService taskService; |
| | | private final IdentityService identityService; |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | private final ReplaceProgramFileService replaceProgramFileService; |
| | | private final ProgramFlowStatusQueryService flowStatusQueryService; |
| | | private final NodeDeptQueryService nodeDeptQueryService; |
| | | private OssTemplate ossTemplate; |
| | | public static final String NODE_ID = "nodeId"; |
| | | /** |
| | | * 转派,并记录自己的备注信息 |
| | | * @param nodeId 替换的节点id |
| | | */ |
| | | /* |
| | | @Transactional |
| | | public void prestart(long nodeId,String tempInstanceId) { |
| | | List<NcNode> fileNodes = nodeService.lambdaQuery() |
| | | .eq(NcNode::getParentId, nodeId) |
| | | .eq(NcNode::getIsLastEdition,1) |
| | | .eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_FILE).list(); |
| | | List<Long> fileIds = fileNodes.stream().map(NcNode::getFlowProgramFileId).toList(); |
| | | |
| | | List<FlowProgramFile> programFiles = flowProgramFileService.lambdaQuery() |
| | | .in(FlowProgramFile::getId, fileIds).list(); |
| | | |
| | | |
| | | //将现有文件复制到独立的表中,后续作为审批的文件,审批界面调用的接口也不同,最好单独开发 |
| | | for(FlowProgramFile programFile : programFiles) { |
| | | FlowProgramFile newFile = new FlowProgramFile(); |
| | | BeanUtils.copyProperties(programFile, newFile); |
| | | EntityUtil.clearBaseProperties(newFile); |
| | | newFile.setProcessInstanceId(tempInstanceId); |
| | | flowProgramFileService.save(newFile); |
| | | } |
| | | } |
| | | |
| | | */ |
| | | private final FlowCommonService flowCommonService; |
| | | private final OssTemplate ossTemplate; |
| | | 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<>(); |
| | | vars.put(FlowContants.ASSIGNEE,startVO.getAssignee());//第一个审批用户 |
| | | |
| | | flowCommonService.putFlowVariablesByNode(vars,programPackage); |
| | | flowCommonService.putDefaultAssignees(vars,programPackage.getDrawingNo(),startVO.getAssignee()+""); |
| | | |
| | | vars.put(FlowContants.TITLE,startVO.getTitle()); |
| | | NcNode programPackage = nodeService.getById(startVO.getNodeId()); |
| | | //机床编号 |
| | | 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()+"段"); |
| | | } |
| | | |
| | | }*/ |
| | | |
| | | /** |
| | | * 上传程序徐文件(编制节点调用) |
| | |
| | | */ |
| | | public void uploadReplaceProgramFile(ReplaceUploadVO uploadVO) { |
| | | |
| | | //FlowProgramProperties progProps= flowCommonService.getProgramProperties(uploadVO.getProcessInstanceId()); |
| | | MultipartFile file = uploadVO.getFile(); |
| | | if(file.getSize() == 0){ |
| | | throw new ServiceException("程序文件不可为空文件"); |
| | |
| | | progProps.setDrawingNo(uploadVO.getDrawingNo()); |
| | | progProps.setProcessNo(uploadVO.getProcessNo()); |
| | | progProps.setProcessEdition(uploadVO.getProcessEdition()); |
| | | if(FlowProgramFile.TYPE_PROGRAM.equals(uploadVO.getFileType())) { |
| | | ProgramFileNameCheckUtil.checkFilename(file.getOriginalFilename(),progProps); |
| | | } |
| | | |
| | | ProgramFileNameCheckUtil.checkFilename(file.getOriginalFilename(),progProps); |
| | | |
| | | String programName = NcNodeService.genProgramName(progProps.getDrawingNo(),progProps.getProcessNo()); |
| | | |