| | |
| | | package org.jeecg.modules.dnc.service.support; |
| | | |
| | | import org.jeecg.modules.dnc.entity.PartsInfo; |
| | | import org.jeecg.modules.dnc.entity.ProductInfo; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.response.CommonGenericTree; |
| | | import org.jeecg.modules.dnc.entity.ComponentInfo; |
| | | import org.jeecg.modules.dnc.dto.ComponentExt; |
| | |
| | | |
| | | public class ProductTreeWrapper { |
| | | |
| | | public static List<CommonGenericTree> loadTree(List<ProductInfo> productInfoList, List<ComponentExt> componentInfoList, List<PartsInfo> partsInfoList) { |
| | | public static List<CommonGenericTree> loadTree(List<ProductInfo> productInfoList, List<ComponentExt> componentInfoList, |
| | | List<PartsInfo> partsInfoList,List<ProcessSpecVersion> processSpecVersionList, |
| | | List<ProcessStream> processStreams, List<WorkStep> workStepList) { |
| | | List<CommonGenericTree> tree = new ArrayList<CommonGenericTree>();// TreeNode集合,存放所有树对象。 |
| | | Map<String, CommonGenericTree> productMap = new HashMap<>(); |
| | | Map<String, CommonGenericTree> componentMap = new HashMap<>(); |
| | | Map<String, CommonGenericTree> partsMap = new HashMap<>(); |
| | | Map<String, CommonGenericTree> pvsMap = new HashMap<>(); |
| | | Map<String, CommonGenericTree> processMap = new HashMap<>(); |
| | | CommonGenericTree<ProductInfo> node; |
| | | CommonGenericTree<ComponentInfo> componentNode; |
| | | CommonGenericTree<PartsInfo> partsNode; |
| | | CommonGenericTree<ProcessSpecVersion> pvsNode; |
| | | CommonGenericTree<ProcessStream> processNode; |
| | | CommonGenericTree<WorkStep> workStepNode; |
| | | for(ProductInfo productInfo : productInfoList) { |
| | | node = new CommonGenericTree(); |
| | | node.setId(productInfo.getProductId()); |
| | |
| | | partsNode.setParentId(componentNode.getId()); |
| | | componentNode.addChildren(partsNode); |
| | | } |
| | | partsMap.put(parts.getPartsId(), partsNode); |
| | | } |
| | | |
| | | //工艺规程版本存在零件下 |
| | | for(ProcessSpecVersion processSpecVersion : processSpecVersionList) { |
| | | pvsNode = new CommonGenericTree(); |
| | | pvsNode.setId(processSpecVersion.getId()); |
| | | pvsNode.setLabel("[" + processSpecVersion.getProcessSpecVersionCode()+ "]" + processSpecVersion.getProcessSpecVersionName()); |
| | | pvsNode.setParentId(null); |
| | | pvsNode.setIconClass(""); |
| | | pvsNode.setType(4); |
| | | pvsNode.setRField(processSpecVersion.getPartsId()); |
| | | pvsNode.setEntity(processSpecVersion); |
| | | if(partsMap.containsKey(pvsNode.getRField())) { |
| | | partsNode = partsMap.get(pvsNode.getRField()); |
| | | pvsNode.setParentId(partsNode.getId()); |
| | | partsNode.addChildren(pvsNode); |
| | | } |
| | | pvsMap.put(processSpecVersion.getId(),pvsNode); |
| | | } |
| | | |
| | | //工序存在部件或者工艺规程版本下 |
| | | for(ProcessStream processStream : processStreams) { |
| | | processNode = new CommonGenericTree(); |
| | | processNode.setId(processStream.getProcessId()); |
| | | processNode.setLabel("[" + processStream.getProcessCode()+ "]" + processStream.getProcessName()); |
| | | processNode.setParentId(null); |
| | | processNode.setIconClass(""); |
| | | processNode.setType(5); |
| | | if (StrUtil.isEmpty(processStream.getPsvId())) { |
| | | //没有partsId,部件下的工序 |
| | | processNode.setRField(processStream.getComponentId()); |
| | | processNode.setEntity(processStream); |
| | | if(componentMap.containsKey(processNode.getRField())) { |
| | | componentNode = componentMap.get(processNode.getRField()); |
| | | processNode.setParentId(componentNode.getId()); |
| | | componentNode.addChildren(processNode); |
| | | } |
| | | }else { |
| | | //有psvId,零件下的工序 |
| | | processNode.setRField(processStream.getPsvId()); |
| | | processNode.setEntity(processStream); |
| | | if(pvsMap.containsKey(processNode.getRField())) { |
| | | pvsNode = pvsMap.get(processNode.getRField()); |
| | | processNode.setParentId(pvsNode.getId()); |
| | | pvsNode.addChildren(processNode); |
| | | } |
| | | } |
| | | processMap.put(processStream.getProcessId(),processNode); |
| | | } |
| | | |
| | | //工步存在工序下 |
| | | for (WorkStep workStep : workStepList) { |
| | | workStepNode = new CommonGenericTree(); |
| | | workStepNode.setId(workStep.getId()); |
| | | workStepNode.setLabel("[" + workStep.getStepCode() + "]" + workStep.getStepName()); |
| | | workStepNode.setParentId(null); |
| | | workStepNode.setIconClass(""); |
| | | workStepNode.setType(6); |
| | | workStepNode.setRField(workStep.getProcessId()); |
| | | workStepNode.setEntity(workStep); |
| | | if (processMap.containsKey(workStepNode.getRField())) { |
| | | processNode = processMap.get(workStepNode.getRField()); |
| | | workStepNode.setParentId(processNode.getId()); |
| | | processNode.addChildren(workStepNode); |
| | | } |
| | | } |
| | | |
| | | return tree; |
| | | } |
| | | |