| | |
| | | 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; |
| | |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springblade.mdm.program.service.NodeDeptQueryService; |
| | | import org.springblade.mdm.program.service.ProgramFlowStatusQueryService; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springblade.mdm.utils.EntityUtil; |
| | | import org.springblade.mdm.utils.ProgramFileNameCheckUtil; |
| | |
| | | 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"; |
| | | private final FlowCommonService flowCommonService; |
| | | private final OssTemplate ossTemplate; |
| | | |
| | | |
| | | /** |
| | | * 转派,并记录自己的备注信息 |
| | | * @param nodeId 替换的节点id |
| | | * 准备替换流程需要的数据 |
| | | * @param nodeId 要替换的程序包名节点id |
| | | * @param tempInstanceId 临时流程实例id,用于新的文件 |
| | | * @return 启动数据 |
| | | */ |
| | | /* |
| | | @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); |
| | | } |
| | | } |
| | | |
| | | */ |
| | | |
| | | @Transactional |
| | | public NcNodeVO pre(long nodeId, String tempInstanceId) { |
| | | checkFlowStatus(nodeId); |
| | | |
| | | List<NcNode> fileNodes = nodeService.lambdaQuery() |
| | | .eq(NcNode::getParentId, nodeId) |
| | |
| | | return vo; |
| | | } |
| | | |
| | | void checkFlowStatus(long nodeId) { |
| | | NcNode packageNode = nodeService.getById(nodeId); |
| | | int status = flowStatusQueryService.queryFlowStatus(packageNode.getProcessInstanceId()); |
| | | if (status == 1) { |
| | | throw new ServiceException("程序的流程正在进行中,不能进行替换"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 启动替换流程 |
| | | */ |
| | | @Transactional |
| | | public void start(ReplaceFlowStartVO startVO){ |
| | | |
| | | |
| | | NcNode programPackage = nodeService.getById(startVO.getNodeId()); |
| | | |
| | | Map<String, Object> vars = new HashMap<>(); |
| | | vars.put(FlowContants.ASSIGNEE,startVO.getAssignee());//第一个审批用户 |
| | | 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()); |
| | |
| | | vars.put(FlowContants.PROGRAM_PACKAGE_NAME,programPackage.getName()); |
| | | |
| | | vars.put(FlowContants.PRODUCT_MODEL,programPackage.getProductModel()); |
| | | vars.put(NODE_ID, startVO.getNodeId()); |
| | | vars.put(FlowContants.NODE_ID, startVO.getNodeId()); |
| | | |
| | | vars.put("comment", startVO.getComment()); |
| | | identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//设置流程发起人 |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 上传程序徐文件(编制节点调用) |
| | | * @param uploadVO 上传对象 |
| | | */ |
| | | 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()); |
| | | |
| | |
| | | progFile.setOssName(bfile.getName()); |
| | | progFile.setProcessInstanceId(uploadVO.getProcessInstanceId()); |
| | | progFile.setProgramName(programName); |
| | | progFile.setFileType(uploadVO.getFileType()); |
| | | |
| | | flowProgramFileService.save(progFile); |
| | | |