| | |
| | | import org.springblade.mdm.flow.service.FlowProgramFileService; |
| | | import org.springblade.mdm.flow.service.FlowProgramProperties; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.utils.EntityUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | public NcNode createNodeTreeToMachine(FlowProgramProperties programProperties) { |
| | | NcNode root; |
| | | if(programProperties.getProcessDefinitionKey().equals(FlowContants.TRY_PROCESS_KEY)){ |
| | | if(Func.isEmpty(programProperties.getDeviation())){ |
| | | //试切 |
| | | if(Func.isEmpty(programProperties.getDeviation()) || |
| | | (FlowContants.Y.equals(programProperties.getHasCuredProgram()) && FlowContants.N.equals(programProperties.getCureProgramUseable()))){ |
| | | //普通试切,或者有固化不可用,建立试切节点 |
| | | //试切根节点 |
| | | root = rootNodeByName(TRY_NAME); |
| | | if (root == null) { |
| | | root = createTryNode(); |
| | |
| | | /** |
| | | * 根据流程信息,自动创建各个节点,包括程序节点 |
| | | * @param programProperties 程序属性 |
| | | * @return 程序包节点实例 |
| | | */ |
| | | @Transactional |
| | | public void createNodeTreeWithProgram(FlowProgramProperties programProperties) { |
| | | public NcNode createNodeTreeWithProgram(FlowProgramProperties programProperties) { |
| | | //,int rootNodeCatgory = 1:试切,2固化,3偏离 |
| | | NcNode programPkdNode = createTreeToPackage(programProperties); |
| | | //删除之前创建过的程序文件节点(因为重复在编制节点审批),避免重复数据 |
| | | //this.ncNodeService.lambdaUpdate().eq(NcNode::getParentId, programPkdNode.getId()).remove(); |
| | | ncNodeService.deleteSubNodes(programPkdNode.getId()); |
| | | |
| | | List<FlowProgramFile> programFiles = flowProgramFileService.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId, programProperties.getProcessInstanceId()).list(); |
| | | for (FlowProgramFile programFile : programFiles) { |
| | | createProgramFileNode(programFile, programPkdNode, programProperties);//所有文件包括程序和其他,都需要建立节点 |
| | | //if(programFile.isProgram()) { |
| | | |
| | | //} |
| | | } |
| | | createOtherNode(programFiles); |
| | | |
| | | return programPkdNode; |
| | | } |
| | | void createOtherNode(List<FlowProgramFile> programFiles){ |
| | | //111mqita 节点 |
| | | } |
| | | |
| | | /** |
| | | * 建立程序文件节点 |
| | | * @param programFile 流程文件 |
| | |
| | | //此处应避免重复创建 |
| | | |
| | | NcNode node = new NcNode(); |
| | | BeanUtils.copyProperties(programPkdNode, node); |
| | | EntityUtil.clearBaseProperties(node); |
| | | |
| | | node.setNodeType(NcNode.TYPE_PROGRAM_FILE); |
| | | node.setName(programFile.getName());//文件名, |
| | | |
| | | node.setIsLastEdition(1); |
| | | /* |
| | | node.setDrawingNo(programPkdNode.getDrawingNo()); |
| | | node.setDrawingNoEdition(programProperties.getDrawingNoEdition()); |
| | | node.setCraftEdition(programProperties.getCraftEdition()); |
| | |
| | | node.setProcessEdition(programProperties.getProcessEdition()); |
| | | node.setMachineCode(programProperties.getMachineCode()); |
| | | node.setProductModel(programProperties.getProductModel()); |
| | | |
| | | */ |
| | | node.setFlowProgramFileId(programFile.getId()); |
| | | node.setVersionNumber(1); |
| | | node.setParentId(programPkdNode.getId()); |
| | | node.setParentIds(programPkdNode.getParentIds()+","+programPkdNode.getId()); |
| | | /* |
| | | if("program".equals(programFile.getFileType())){ |
| | | |
| | | }else{ |
| | | //其他文件,和程序包名同级并列 |
| | | |
| | | }*/ |
| | | |
| | | ncNodeService.save(node); |
| | | } |
| | |
| | | //程序包节点和程序文件节点数据 |
| | | if(NcNode.TYPE_PROGRAM_PACKAGE.equals(nodeType) || NcNode.TYPE_PROGRAM_FILE.equals(nodeType)){ |
| | | |
| | | String programNo = programSeqService.generageProgramNo(); |
| | | ncNode.setProgramNo(programNo); |
| | | ncNode.setProcessInstanceId(programProperties.getProcessInstanceId()); |
| | | ncNode.setDrawingNo(programProperties.getDrawingNo()); |
| | | ncNode.setDrawingNoEdition(programProperties.getDrawingNoEdition()); |
| | |
| | | ncNode.setProductModel(programProperties.getProductModel()); |
| | | |
| | | ncNode.setDeviation(programProperties.getDeviation()); |
| | | |
| | | if(NcNode.TYPE_PROGRAM_PACKAGE.equals(nodeType)) {//程序包节点,分配程序编号 |
| | | String programNo = programSeqService.generageProgramNo(); |
| | | ncNode.setProgramNo(programNo); |
| | | } |
| | | } |
| | | |
| | | ncNode.setIsLastEdition(1); |