| | |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | /** |
| | | * 产品封装 |
| | | * @param docRelative |
| | | * @return |
| | | */ |
| | | public ProcessTraceChain traceFromProduct(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | | traceProductChain(chain, docRelative.getAttributionId()); |
| | | List<ProductMix> productMixList=buildFullTreePath(chain); |
| | | chain.setTreePath(productMixList); |
| | | chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); |
| | | return chain; |
| | | } |
| | | |
| | | /** |
| | | * 部件封装 |
| | | * @param docRelative |
| | | * @return |
| | | */ |
| | | public ProcessTraceChain traceFromComponent(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | | traceComponentChain(chain, docRelative.getAttributionId()); |
| | | List<ProductMix> productMixList=buildFullTreePath(chain); |
| | | chain.setTreePath(productMixList); |
| | | chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); |
| | | return chain; |
| | | } |
| | | |
| | | /** |
| | | * 零件封装 |
| | | * @param docRelative |
| | | * @return |
| | | */ |
| | | public ProcessTraceChain traceFromParts(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | | tracePartsChain(chain, docRelative.getAttributionId()); |
| | | List<ProductMix> productMixList=buildFullTreePath(chain); |
| | | chain.setTreePath(productMixList); |
| | | chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); |
| | | return chain; |
| | | } |
| | | |
| | | /** |
| | | * 工艺规程版本封装 |
| | | * @param docRelative |
| | | * @return |
| | | */ |
| | | public ProcessTraceChain traceFromPsv(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | | traceProcessSpecVersionChain(chain, docRelative.getAttributionId()); |
| | | List<ProductMix> productMixList=buildFullTreePath(chain); |
| | | chain.setTreePath(productMixList); |
| | | chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); |
| | | return chain; |
| | | } |
| | | |
| | | /** |
| | | * 工序封装 |
| | | * @param docRelative |
| | | * @return |
| | | */ |
| | | public ProcessTraceChain traceFromProcess(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | | DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId()); |
| | |
| | | return chain; |
| | | } |
| | | |
| | | /** |
| | | * 工步封装 |
| | | * @param docRelative |
| | | * @return |
| | | */ |
| | | public ProcessTraceChain traceFromWorkStep(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | | DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId()); |
| | |
| | | .ifPresent(doc -> { |
| | | chain.setDocInfo(doc); |
| | | chain.setDocFile(docFileMapper.selectById(doc.getPublishFileId())); |
| | | chain.setCutterList(getCuttersByDocId(doc.getDocId())); |
| | | getLatestGuideCardBatch(doc.getDocId()).ifPresent(chain::setGuideCardBatch); |
| | | }); |
| | | if (Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode()) || |
| | | Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())) { |
| | | chain.setCutterList(getCuttersByDocId(doc.getDocId())); |
| | | getLatestGuideCardBatch(doc.getDocId()).ifPresent(chain::setGuideCardBatch); |
| | | }}); |
| | | return chain; |
| | | } |
| | | |
| | |
| | | Objects.equals(deviceType.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode()); |
| | | } |
| | | |
| | | private void traceProductChain(ProcessTraceChain chain, String productId) { |
| | | ProductInfo product = productMapper.selectById(productId); |
| | | chain.setProduct(product); |
| | | } |
| | | |
| | | private void traceComponentChain(ProcessTraceChain chain, String componentId) { |
| | | chain.setComponentHierarchy(traceComponentHierarchy(componentId)); |
| | | Optional.ofNullable(chain.getComponentHierarchy()) |
| | | .map(ComponentHierarchy::getRootProduct) |
| | | .ifPresent(chain::setProduct); |
| | | } |
| | | |
| | | private void tracePartsChain(ProcessTraceChain chain, String partsId) { |
| | | PartsInfo parts = partsMapper.selectById(partsId); |
| | | chain.setParts(parts); |
| | | if (parts != null) { |
| | | if (parts.getComponentId() != null) { |
| | | chain.setComponentHierarchy(traceComponentHierarchy(parts.getComponentId())); |
| | | Optional.ofNullable(chain.getComponentHierarchy()) |
| | | .map(ComponentHierarchy::getRootProduct) |
| | | .ifPresent(chain::setProduct); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void traceProcessSpecVersionChain(ProcessTraceChain chain, String psvId) { |
| | | ProcessSpecVersion psv = psvMapper.selectById(psvId); |
| | | chain.setProcessSpec(psv); |
| | | if (psv != null) { |
| | | if (psv.getPartsId() != null) { |
| | | PartsInfo parts = partsMapper.selectById(psv.getPartsId()); |
| | | chain.setParts(parts); |
| | | if (parts != null && parts.getComponentId() != null) { |
| | | chain.setComponentHierarchy(traceComponentHierarchy(parts.getComponentId())); |
| | | Optional.ofNullable(chain.getComponentHierarchy()) |
| | | .map(ComponentHierarchy::getRootProduct) |
| | | .ifPresent(chain::setProduct); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void traceProcessChain(ProcessTraceChain chain, String processId) { |
| | | ProcessStream process = processMapper.selectById(processId); |
| | | if (process == null) return; |