| | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.flow.constants.FlowContants; |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | import org.springblade.mdm.flow.service.FlowCommonService; |
| | |
| | | private final ProgramSeqService programSeqService; |
| | | public static final String TRY_NAME = "试切"; |
| | | public static final String CURE_NAME = "固化"; |
| | | public static final String PIANLI_NAME = "偏离"; |
| | | public static final String DEVIATION_NAME = "偏离"; |
| | | |
| | | /** |
| | | * 创建树到机床级别 |
| | |
| | | */ |
| | | @Transactional |
| | | public NcNode createNodeTreeToMachine(FlowProgramProperties programProperties) { |
| | | |
| | | NcNode root; |
| | | if(programProperties.getProcessDefinitionKey().equals(FlowContants.TRY_PROCESS_KEY)){ |
| | | //试切 |
| | | root = rootNodeByName(TRY_NAME); |
| | | if(root == null){ |
| | | root = createTryNode(); |
| | | if(Func.isEmpty(programProperties.getDeviation())){ |
| | | //试切 |
| | | root = rootNodeByName(TRY_NAME); |
| | | if (root == null) { |
| | | root = createTryNode(); |
| | | } |
| | | }else{ |
| | | //有偏离 |
| | | root = rootNodeByName(DEVIATION_NAME); |
| | | if(root == null){ |
| | | root = createDeviationNode(); |
| | | } |
| | | } |
| | | }else if(programProperties.getProcessDefinitionKey().equals(FlowContants.CURE_PROCESS_KEY)){ |
| | | root = rootNodeByName(CURE_NAME); |
| | |
| | | root = createCureNode(); |
| | | } |
| | | }else{ |
| | | root = rootNodeByName(PIANLI_NAME); |
| | | if(root == null){ |
| | | root = createPianliNode(); |
| | | } |
| | | throw new ServiceException("流程定义不在范围内"); |
| | | } |
| | | |
| | | NcNode lastNode = null; |
| | | //创建产品型号节点 |
| | | NcNode productModelNode = createNodeIfNotExists(programProperties.getProductModel(),NcNode.TYPE_PRODUCT_MODEL, root,programProperties); |
| | | //零组件号节点 |
| | | NcNode drawingNoNode = createNodeIfNotExists(programProperties.getDrawingNo(),NcNode.TYPE_DRAWING_NO, productModelNode,programProperties); |
| | | //工艺版次节点 |
| | | NcNode craftEditionNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_CRAFT_EDITION, drawingNoNode,programProperties); |
| | | //NcNode craftEditionNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_CRAFT_EDITION, drawingNoNode,programProperties); |
| | | //工序号节 |
| | | NcNode processNoNode = createNodeIfNotExists(programProperties.getProcessNo(),NcNode.TYPE_PROCESS_NO, craftEditionNode,programProperties); |
| | | NcNode processNoNode = createNodeIfNotExists(programProperties.getProcessNo(),NcNode.TYPE_PROCESS_NO, drawingNoNode,programProperties); |
| | | //工序版次节点 |
| | | NcNode processEditionNode = createNodeIfNotExists(programProperties.getProcessEdition(),NcNode.TYPE_PROCESS_EDITION, processNoNode,programProperties); |
| | | //加工机床节点 |
| | |
| | | |
| | | List<FlowProgramFile> programFiles = flowProgramFileService.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId, programProperties.getProcessInstanceId()).list(); |
| | | for (FlowProgramFile programFile : programFiles) { |
| | | createProgramFileNode(programFile, programPkdNode, programProperties); |
| | | createProgramFileNode(programFile, programPkdNode, programProperties);//所有文件包括程序和其他,都需要建立节点 |
| | | //if(programFile.isProgram()) { |
| | | |
| | | //} |
| | | } |
| | | |
| | | createOtherNode(programFiles); |
| | | } |
| | | |
| | | void createOtherNode(List<FlowProgramFile> programFiles){ |
| | | //111mqita 节点 |
| | | } |
| | | /** |
| | | * 建立程序文件节点 |
| | | * @param programFile 流程文件 |
| | |
| | | NcNode node = new NcNode(); |
| | | node.setNodeType(NcNode.TYPE_PROGRAM_FILE); |
| | | node.setName(programFile.getName());//文件名, |
| | | node.setParentId(programPkdNode.getId()); |
| | | node.setParentIds(programPkdNode.getParentIds()+","+programPkdNode.getId()); |
| | | |
| | | node.setIsLastEdition(1); |
| | | node.setDrawingNo(programPkdNode.getDrawingNo()); |
| | | node.setDrawingNoEdition(programProperties.getDrawingNoEdition()); |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | public NcNode createTreeToPackage(FlowProgramProperties programProperties) { |
| | | NcNode machineCodeNode = createNodeTreeToMachine(programProperties); |
| | | NcNode processEditionNode = this.ncNodeService.getById(machineCodeNode.getParentId()); |
| | | //获取工序版次下其他机床名,存在则删除 |
| | | ncNodeService.lambdaUpdate().eq(NcNode::getNodeType,NcNode.TYPE_MACHINE_CODE) |
| | | .eq(NcNode::getParentId,processEditionNode.getId()).eq(NcNode::getIsLastEdition,1) |
| | | .ne(NcNode::getName,machineCodeNode.getName()).remove(); |
| | | |
| | | //保持加工机床是最新下发任务的机床,不是新建一个机床节点,插叙工序版次下是否有其他的机床(零件号一致,工序号,工序版次一致) |
| | | //获取 |
| | | //加工机床和程序包名在同一级节点,同在工序版次下级 |
| | | String programPkgName = NcNodeService.genProgramName(programProperties.getDrawingNo(),programProperties.getProcessNo()); |
| | | return createNodeIfNotExists(programPkgName ,NcNode.TYPE_PROGRAM_PACKAGE, machineCodeNode,programProperties); |
| | | return createNodeIfNotExists(programPkgName ,NcNode.TYPE_PROGRAM_PACKAGE, processEditionNode,programProperties); |
| | | |
| | | } |
| | | |
| | |
| | | * @param nodeType 节点类型 |
| | | * @param parentNode 父节点 |
| | | * @param programProperties 流程程序属性 |
| | | * @return |
| | | * @return 创建或已存在的节点或 |
| | | */ |
| | | NcNode createNodeIfNotExists(String name,String nodeType,NcNode parentNode,FlowProgramProperties programProperties) { |
| | | Optional<NcNode> nodeOpt = this.ncNodeService.lambdaQuery().eq(NcNode::getName,name).eq(NcNode::getNodeType,nodeType) |
| | |
| | | ncNode.setProcessName(programProperties.getProcessName()); |
| | | ncNode.setMachineCode(programProperties.getMachineCode()); |
| | | ncNode.setProductModel(programProperties.getProductModel()); |
| | | //ncNode.setMachineMode(programProperties.getMachineMode()); |
| | | |
| | | ncNode.setDeviation(programProperties.getDeviation()); |
| | | } |
| | | |
| | | ncNode.setIsLastEdition(1); |
| | |
| | | return ncNode; |
| | | } |
| | | |
| | | NcNode createPianliNode() { |
| | | NcNode createDeviationNode() { |
| | | NcNode ncNode = new NcNode(); |
| | | ncNode.setId(3L); |
| | | ncNode.setName(PIANLI_NAME); |
| | | ncNode.setName(DEVIATION_NAME); |
| | | ncNode.setParentId(0L); |
| | | ncNode.setParentIds("0"); |
| | | ncNode.setNodeType("10"); |