| | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | import org.springblade.mdm.flow.service.FlowCommonService; |
| | | 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.program.mapper.NcNodeMapper; |
| | | import org.springblade.mdm.program.vo.NcNodeQueryVO; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * 程序节点 |
| | | * 程序节点自动创建服务,在 试切流程 程序编制 节点 审核通过后调用 |
| | | * |
| | | * @author yangys |
| | | */ |
| | |
| | | private final NcNodeService ncNodeService; |
| | | private final FlowCommonService flowCommonService; |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | |
| | | private final ProgramSeqService programSeqService; |
| | | public static final String SHIQIE_NAME = "试切"; |
| | | public static final String GUHUA_NAME = "固化"; |
| | | public static final String PIANLI_NAME = "偏离"; |
| | |
| | | * 根据流程信息,自动创建各个节点 |
| | | * @param processInstanceId |
| | | */ |
| | | @Transactional |
| | | public void createNodeTree(String processInstanceId) { |
| | | FlowProgramProperties programProperties = flowCommonService.getProgramProperties(processInstanceId); |
| | | |
| | |
| | | private void createProgramFileNode(FlowProgramFile programFile, NcNode programPkdNode, FlowProgramProperties programProperties) { |
| | | NcNode node = new NcNode(); |
| | | node.setNodeType(NcNode.TYPE_PROGRAM_FILE); |
| | | node.setName(programFile.getProgramName()); |
| | | 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.setCraftEdition(programProperties.getCraftEdition()); |
| | | node.setProcessName(programProperties.getProcessName()); |
| | | node.setProcessNo(programProperties.getProcessNo()); |
| | | node.setMachineCode(programProperties.getMachineCode()); |
| | | node.setProductModel(programProperties.getProductModel()); |
| | | node.setFlowProgramFileId(programFile.getId()); |
| | | |
| | | ncNodeService.save(node); |
| | | } |
| | | |
| | |
| | | |
| | | //创建产品型号节点 |
| | | //NcNode productModelNode = createProductModelNode(programProperties.getProductModel(), root); |
| | | NcNode productModelNode = createNodeIfNotExists(programProperties.getProductModel(),NcNode.TYPE_PRODUCT_MODEL, root); |
| | | NcNode productModelNode = createNodeIfNotExists(programProperties.getProductModel(),NcNode.TYPE_PRODUCT_MODEL, root,programProperties); |
| | | //零组件号节点 |
| | | NcNode drawingNoNode = createNodeIfNotExists(programProperties.getDrawingNo(),NcNode.TYPE_DRAWING_NO, productModelNode); |
| | | NcNode drawingNoNode = createNodeIfNotExists(programProperties.getDrawingNo(),NcNode.TYPE_DRAWING_NO, productModelNode,programProperties); |
| | | //工艺版次节点 |
| | | NcNode craftEditionNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_CRAFT_EDITION, drawingNoNode); |
| | | NcNode craftEditionNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_CRAFT_EDITION, drawingNoNode,programProperties); |
| | | //工序号节 |
| | | NcNode processNoNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_PROCESS_NO, craftEditionNode); |
| | | NcNode processNoNode = createNodeIfNotExists(programProperties.getProcessNo(),NcNode.TYPE_PROCESS_NO, craftEditionNode,programProperties); |
| | | //工序版次节点 |
| | | NcNode processEditionNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_PROCESS_EDITION, processNoNode); |
| | | NcNode processEditionNode = createNodeIfNotExists(programProperties.getProcessEdition(),NcNode.TYPE_PROCESS_EDITION, processNoNode,programProperties); |
| | | //加工机床节点 |
| | | NcNode machineCodeNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_MACHINE_CODE, processEditionNode); |
| | | NcNode machineCodeNode = createNodeIfNotExists(programProperties.getMachineCode(),NcNode.TYPE_MACHINE_CODE, processEditionNode,programProperties); |
| | | //程序包名节点 |
| | | NcNode programPkgNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_PROGRAM_PACKAGE, machineCodeNode); |
| | | |
| | | return programPkgNode; |
| | | //程序文件节点,多个文件需要循环创建 |
| | | |
| | | String programPkgName = programProperties.getDrawingNo()+"-"+programProperties.getProcessNo();//零件号加工序号 |
| | | return createNodeIfNotExists(programPkgName ,NcNode.TYPE_PROGRAM_PACKAGE, machineCodeNode,programProperties); |
| | | } |
| | | /* |
| | | NcNode createProductModelNode(String name,NcNode parentNode){ |
| | | NcNode ncNode = new NcNode(); |
| | | ncNode.setName(name); |
| | | ncNode.setParentId(parentNode.getId()); |
| | | ncNode.setParentIds(parentNode.getParentIds()+","+parentNode.getId()); |
| | | ncNode.setNodeType("15"); |
| | | ncNodeService.save(ncNode); |
| | | |
| | | return ncNode; |
| | | } |
| | | |
| | | */ |
| | | |
| | | /** |
| | | * 不存在则创建节点 |
| | | * @param name 节点名称 |
| | | * @param nodeType 节点类型 |
| | | * @param parentNode 父节点 |
| | | * @param programProperties 流程程序属性 |
| | | * @return |
| | | */ |
| | | NcNode createNodeIfNotExists(String name,String nodeType,NcNode parentNode){ |
| | | NcNode createNodeIfNotExists(String name,String nodeType,NcNode parentNode,FlowProgramProperties programProperties) { |
| | | Optional<NcNode> nodeOpt = this.ncNodeService.lambdaQuery().eq(NcNode::getName,name).eq(NcNode::getNodeType,nodeType).eq(NcNode::getParentId,parentNode.getId()).oneOpt(); |
| | | if(nodeOpt.isPresent()){ |
| | | return nodeOpt.get(); |
| | |
| | | ncNode.setParentId(parentNode.getId()); |
| | | ncNode.setParentIds(parentNode.getParentIds() + "," + parentNode.getId()); |
| | | ncNode.setNodeType(nodeType); |
| | | |
| | | |
| | | //程序包节点和程序文件节点数据 |
| | | 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.setCraftEdition(programProperties.getCraftEdition()); |
| | | ncNode.setProcessNo(programProperties.getProcessNo()); |
| | | ncNode.setProcessEdition(programProperties.getProcessEdition()); |
| | | ncNode.setProcessName(programProperties.getProcessName()); |
| | | ncNode.setMachineCode(programProperties.getMachineCode()); |
| | | ncNode.setProductModel(programProperties.getProductModel()); |
| | | |
| | | |
| | | } |
| | | |
| | | ncNode.setIsLastEdition(1); |
| | | |
| | | ncNodeService.save(ncNode); |
| | | |
| | | return ncNode; |