From b1e37337ac05917ad6989177bc639acc2c065600 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期二, 09 九月 2025 16:14:04 +0800
Subject: [PATCH] 航宇两网交互新增其他文档

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java                 |    1 
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java                |   10 +
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java         |  143 +++++++++++++++
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsPackageStrategy.java              |   37 ++++
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java          |   12 +
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentPackageStrategy.java          |   37 ++++
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionPackageStrategy.java |   37 ++++
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductPackageStrategy.java            |   37 ++++
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java                          |    2 
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java                            |    2 
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java                  |   80 ++++----
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java   |  131 +++++++++++---
 12 files changed, 457 insertions(+), 72 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java
index 9b28811..22c46c3 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java
@@ -12,7 +12,7 @@
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @JsonIgnoreProperties(ignoreUnknown = true)
 public class TransferPackage {
-    public enum DataType { PROCESS, WORKSTEP }
+    public enum DataType {PRODUCT,COMPONENT,PARTS,OPERATION,PROCESS,WORKSTEP}
 
     private final DataType dataType;
     private final DocRelative docRelative;
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java
index 5b8b097..c89c13a 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java
@@ -26,7 +26,7 @@
 
     @Override
     public void onStart(FileAlterationObserver observer) {
-//        log.info("寮�濮嬬洃鍚洰褰�: {}", observer.getDirectory().getAbsolutePath());
+        log.info("寮�濮嬬洃鍚洰褰�: {}", observer.getDirectory().getAbsolutePath());
     }
 
     @Override
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentPackageStrategy.java
new file mode 100644
index 0000000..841a758
--- /dev/null
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentPackageStrategy.java
@@ -0,0 +1,37 @@
+package org.jeecg.modules.dnc.service.impl;
+
+import org.jeecg.modules.dnc.dto.TransferPackage;
+import org.jeecg.modules.dnc.entity.ComponentInfo;
+import org.jeecg.modules.dnc.entity.DocRelative;
+import org.jeecg.modules.dnc.mapper.ComponentInfoMapper;
+import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
+import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
+import org.jeecg.modules.dnc.service.DataPackageStrategy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ComponentPackageStrategy implements DataPackageStrategy {
+    @Autowired
+    private ComponentInfoMapper componentInfoMapper;
+    @Autowired
+    private DeviceTypeMapper deviceTypeMapper;
+    @Autowired
+    private FullHierarchyTraceService traceService;
+    @Autowired
+    private DocRelativeMapper docRelativeMapper;
+
+    @Override
+    public TransferPackage packageData(String relativeId) {
+        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
+        ComponentInfo componentInfo=componentInfoMapper.selectById(docRelative.getAttributionId());
+        if (componentInfo == null) {
+            throw new IllegalArgumentException("瀵瑰簲鐨勯儴浠朵笉瀛樺湪: " + docRelative.getAttributionId());
+        }
+        return TransferPackage.builder()
+                .dataType(TransferPackage.DataType.COMPONENT)
+                .docRelative(docRelative)
+                .traceChain(traceService.traceFromComponent(docRelative))
+                .build();
+    }
+}
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java
index 3ddf601..edd2dc1 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java
@@ -322,7 +322,6 @@
                     }
                     break;
                 case "2":
-
                     if (StrUtil.isNotEmpty(item.getUserId())){
                         ComponentPermission componentPermission = new ComponentPermission();
                         componentPermission.setComponentId(item.getBusinessId());
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java
index 46cfe99..d75c9ea 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java
@@ -18,7 +18,15 @@
     public DataPackageService(List<DataPackageStrategy> strategyList) {
         strategies = new EnumMap<>(TransferPackage.DataType.class);
         strategyList.forEach(strategy -> {
-            if (strategy instanceof ProcessPackageStrategy) {
+            if (strategy instanceof ProductPackageStrategy) {
+                strategies.put(TransferPackage.DataType.PRODUCT, strategy);
+            } else if (strategy instanceof ComponentPackageStrategy) {
+                strategies.put(TransferPackage.DataType.COMPONENT, strategy);
+            } else if (strategy instanceof PartsPackageStrategy) {
+                strategies.put(TransferPackage.DataType.PARTS, strategy);
+            } else if (strategy instanceof ProcessSpecVersionPackageStrategy) {
+                strategies.put(TransferPackage.DataType.OPERATION, strategy);
+            } else if (strategy instanceof ProcessPackageStrategy) {
                 strategies.put(TransferPackage.DataType.PROCESS, strategy);
             } else if (strategy instanceof WorkStepPackageStrategy) {
                 strategies.put(TransferPackage.DataType.WORKSTEP, strategy);
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java
index 85e3df8..27cce40 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java
@@ -3,6 +3,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import liquibase.pro.packaged.S;
 import org.apache.commons.lang3.StringUtils;
+import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
 import org.jeecg.modules.dnc.dto.ComponentHierarchy;
 import org.jeecg.modules.dnc.dto.TransferPackage;
 import org.jeecg.modules.dnc.entity.*;
@@ -27,6 +28,7 @@
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -36,6 +38,7 @@
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 @Service
 public class FileFerryService {
@@ -51,7 +54,7 @@
     @Value("${jeecg.path.upload}")
     private String upLoadPath;
 
-    @Autowired
+    @Resource
     private MdcEquipmentMapper mdcEquipmentMapper;
 
     @Autowired
@@ -94,8 +97,6 @@
             throw new RuntimeException("鏂囦欢鍐欏叆澶辫触", e);
         }
     }
-
-
 
     public TransferPackage importData(String filePath) {
         try {
@@ -142,18 +143,28 @@
             long number = Long.parseLong(numericPart);
             number--;  // 鑾峰彇鍓嶄竴涓簭鍒楀彿
 
-            // 淇濇寔鐩稿悓浣嶆暟鏍煎紡
-            String newNumeric = String.format("%0" + numericPart.length() + "d", number);
-            String ncFileName = prefix + newNumeric + "_" + equipmentId+".NC";
-            String ncFilePath = path.getParent().resolve(ncFileName).toString();
-
             // 6. 鑾峰彇鏂囦欢澶嶅埗鐩爣璺緞
+            DocRelative docRelative=pkg.getDocRelative();
             DocFile docFile = pkg.getTraceChain().getDocFile();
             DocInfo docInfo = pkg.getTraceChain().getDocInfo();
             if (docFile == null) {
                 throw new IllegalStateException("浼犺緭鍖呬腑缂哄皯鏂囨。鏂囦欢淇℃伅");
             }
 
+            // 淇濇寔鐩稿悓浣嶆暟鏍煎紡
+            String newNumeric = String.format("%0" + numericPart.length() + "d", number);
+            String ncFileName = "";
+            if (Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode()) ||
+                    Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())) {
+                //NC鏂囦欢鐨勬嫹璐�
+                ncFileName = prefix + newNumeric + "_" + equipmentId+".NC";
+            }else {
+                //鍏朵粬鏂囨。鐨勬嫹璐�
+                ncFileName = prefix + newNumeric + "_" + equipmentId+"."+docFile.getFileSuffix();
+                docInfo.setDocDispatchStatus(3);
+                pkg.getTraceChain().setDocInfo(docInfo);
+            }
+            String ncFilePath = path.getParent().resolve(ncFileName).toString();
             // 鏋勫缓鐩爣璺緞
             String targetDirectory = fileHomePath + docFile.getFilePath();
             String targetPath = Paths.get(targetDirectory, docFile.getFileEncodeName()).toString();
@@ -183,12 +194,12 @@
                     DocClassification classification = classificationService.getByCode("send");
                     if(classification == null)
                         ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
-                    DocRelative docRelative = new DocRelative();
-                    docRelative.setDocId(docInfo.getDocId());
-                    docRelative.setClassificationId(classification.getClassificationId());
-                    docRelative.setAttributionType(7);
-                    docRelative.setAttributionId(mdcEquipment.getId());
-                    docRelativeService.save(docRelative);
+                    DocRelative newDocRelative = new DocRelative();
+                    newDocRelative.setDocId(docInfo.getDocId());
+                    newDocRelative.setClassificationId(classification.getClassificationId());
+                    newDocRelative.setAttributionType(7);
+                    newDocRelative.setAttributionId(mdcEquipment.getId());
+                    docRelativeService.save(newDocRelative);
                 }
                 String sendPath = StringUtils.join(strings.toArray(), "/");
                 boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(), sendPath + "/" + mdcEquipment.getEquipmentId(),
@@ -203,37 +214,35 @@
             } else {
                 throw new RuntimeException("鏂囦欢浼犺緭璺緞鑾峰彇澶辫触");
             }
-
-            // 璁$畻鍚庝竴涓枃浠跺悕
-            long nextNumber = Long.parseLong(numericPart);
-            nextNumber++;
-
             //鑾峰彇搴忓垪鍖栫殑绋嬪簭纭琛ㄦ暟鎹�
             GuideCardBatch guideCardBatch=pkg.getTraceChain().getGuideCardBatch();
+            if (guideCardBatch!=null){
+                // 璁$畻鍚庝竴涓枃浠跺悕
+                long nextNumber = Long.parseLong(numericPart);
+                nextNumber++;
+                //鑾峰彇鏂囦欢璺緞
+                String pictureUrl=guideCardBatch.getPicture();
 
-            //鑾峰彇鏂囦欢璺緞
-            String pictureUrl=guideCardBatch.getPicture();
+                // 淇濇寔鐩稿悓浣嶆暟鏍煎紡
+                String nextNumeric = String.format("%0" + numericPart.length() + "d", nextNumber);
+                String nextFileName = prefix + nextNumeric + "_" + equipmentId+"."+pictureUrl.split("\\.")[1];
+                String nextFilePath = path.getParent().resolve(nextFileName).toString();
 
-            // 淇濇寔鐩稿悓浣嶆暟鏍煎紡
-            String nextNumeric = String.format("%0" + numericPart.length() + "d", nextNumber);
-            String nextFileName = prefix + nextNumeric + "_" + equipmentId+"."+pictureUrl.split("\\.")[1];
-            String nextFilePath = path.getParent().resolve(nextFileName).toString();
+                //鎷兼帴鐜版湁璺緞
+                String picturePtah=upLoadPath+"/"+pictureUrl;
 
-            //鎷兼帴鐜版湁璺緞
-            String picturePtah=upLoadPath+"/"+pictureUrl;
-
-            // 9. 澶嶅埗鏂囦欢骞堕噸鍛藉悕
-            logger.info("澶嶅埗鏂囦欢: {} 鈫� {}", nextFilePath,picturePtah);
-            Path PicSource= Paths.get(nextFilePath);
-            Files.copy(PicSource, Paths.get(picturePtah), StandardCopyOption.REPLACE_EXISTING);
+                // 9. 澶嶅埗鏂囦欢骞堕噸鍛藉悕
+                logger.info("澶嶅埗鏂囦欢: {} 鈫� {}", nextFilePath,picturePtah);
+                Path PicSource= Paths.get(nextFilePath);
+                Files.copy(PicSource, Paths.get(picturePtah), StandardCopyOption.REPLACE_EXISTING);
+                Files.delete(PicSource);
+            }
 
             // 鍒犻櫎鏂囦欢
             logger.info("鍒犻櫎涓存椂鏂囦欢: {}", ncFilePath);
             Files.delete(source);
             Files.delete(path);
-            Files.delete(PicSource);
-
-            return JsonUtils.fromJson(json, TransferPackage.class);
+            return pkg;
 
         } catch (NumberFormatException e) {
             throw new RuntimeException("鏂囦欢鍚嶄腑鐨勬暟瀛楁牸寮忔棤鏁�: " + e.getMessage(), e);
@@ -251,7 +260,6 @@
                 pkg.getTraceChain().getComponentHierarchy().getComponents().size() < 4) {
             return;
         }
-
         ComponentHierarchy hierarchy = pkg.getTraceChain().getComponentHierarchy();
         List<ComponentInfo> compressed = new ArrayList<>();
 
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java
index 1180bdf..7304fdc 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java
@@ -6,6 +6,7 @@
 import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.dnc.mapper.*;
 import org.jeecg.modules.dnc.service.IPermissionStreamNewService;
+import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.service.IMdcProductionService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +47,74 @@
     private CutterMapper cutterMapper;
     @Autowired
     private GuideCardBatchMapper guideCardBatchMapper;
+    @Autowired
+    private IPermissionStreamNewService permissionStreamNewService;
+    @Autowired
+    private ISysUserService sysUserService;
+    @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());
@@ -60,9 +128,15 @@
         completeChainWithProductInfo(chain);
         List<ProductMix> productMixList=buildFullTreePath(chain);
         chain.setTreePath(productMixList);
+        chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList));
         return chain;
     }
 
+    /**
+     * 宸ユ灏佽
+     * @param docRelative
+     * @return
+     */
     public ProcessTraceChain traceFromWorkStep(DocRelative docRelative) {
         ProcessTraceChain chain = initChainWithDocInfo(docRelative);
         DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId());
@@ -76,6 +150,7 @@
         completeChainWithProductInfo(chain);
         List<ProductMix> productMixList=buildFullTreePath(chain);
         chain.setTreePath(productMixList);
+        chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList));
         return chain;
     }
 
@@ -85,9 +160,11 @@
                 .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;
     }
 
@@ -111,6 +188,48 @@
     private boolean isWorkSiteType(DeviceType deviceType) {
         return deviceType != null &&
                 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) {
@@ -210,4 +329,22 @@
         return path;
     }
 
+    private List<PermissionStreamNew> buildFullTreePathPermission(List<ProductMix> productMixList) {
+        List<Long> ids=productMixList.stream().map(ProductMix::getId).collect(Collectors.toList());
+        List<PermissionStreamNew> path = permissionStreamNewService
+                .list(new QueryWrapper<PermissionStreamNew>().in("business_id",ids)
+                        .eq("delete_flag",0));
+        path.forEach(item->{
+            if (item.getDepartId()!=null){
+                MdcProduction mdcProduction=mdcProductionService.getById(item.getDepartId());
+                if(mdcProduction!=null){
+                    item.setDepartId(item.getDepartId());
+                }
+            }
+            if (item.getUserId()!=null){
+                item.setUserId(sysUserService.getById(item.getUserId()).getUsername());
+            }
+        });
+        return path;
+    }
 }
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsPackageStrategy.java
new file mode 100644
index 0000000..05a2304
--- /dev/null
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsPackageStrategy.java
@@ -0,0 +1,37 @@
+package org.jeecg.modules.dnc.service.impl;
+
+import org.jeecg.modules.dnc.dto.TransferPackage;
+import org.jeecg.modules.dnc.entity.DocRelative;
+import org.jeecg.modules.dnc.entity.PartsInfo;
+import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
+import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
+import org.jeecg.modules.dnc.mapper.PartsInfoMapper;
+import org.jeecg.modules.dnc.service.DataPackageStrategy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class PartsPackageStrategy implements DataPackageStrategy {
+    @Autowired
+    private PartsInfoMapper partsInfoMapper;
+    @Autowired
+    private DeviceTypeMapper deviceTypeMapper;
+    @Autowired
+    private FullHierarchyTraceService traceService;
+    @Autowired
+    private DocRelativeMapper docRelativeMapper;
+
+    @Override
+    public TransferPackage packageData(String relativeId) {
+        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
+        PartsInfo partsInfo=partsInfoMapper.selectById(docRelative.getAttributionId());
+        if (partsInfo == null) {
+            throw new IllegalArgumentException("瀵瑰簲鐨勯浂浠朵笉瀛樺湪: " + docRelative.getAttributionId());
+        }
+        return TransferPackage.builder()
+                .dataType(TransferPackage.DataType.PARTS)
+                .docRelative(docRelative)
+                .traceChain(traceService.traceFromParts(docRelative))
+                .build();
+    }
+}
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionPackageStrategy.java
new file mode 100644
index 0000000..36b35e3
--- /dev/null
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionPackageStrategy.java
@@ -0,0 +1,37 @@
+package org.jeecg.modules.dnc.service.impl;
+
+import org.jeecg.modules.dnc.dto.TransferPackage;
+import org.jeecg.modules.dnc.entity.DocRelative;
+import org.jeecg.modules.dnc.entity.ProcessSpecVersion;
+import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
+import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
+import org.jeecg.modules.dnc.mapper.ProcessSpecVersionMapper;
+import org.jeecg.modules.dnc.service.DataPackageStrategy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ProcessSpecVersionPackageStrategy implements DataPackageStrategy {
+    @Autowired
+    private ProcessSpecVersionMapper processSpecVersionMapper;
+    @Autowired
+    private DeviceTypeMapper deviceTypeMapper;
+    @Autowired
+    private FullHierarchyTraceService traceService;
+    @Autowired
+    private DocRelativeMapper docRelativeMapper;
+
+    @Override
+    public TransferPackage packageData(String relativeId) {
+        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
+        ProcessSpecVersion processSpecVersion=processSpecVersionMapper.selectById(docRelative.getAttributionId());
+        if (processSpecVersion == null) {
+            throw new IllegalArgumentException("瀵瑰簲鐨勫伐鑹鸿绋嬬増鏈笉瀛樺湪: " + docRelative.getAttributionId());
+        }
+        return TransferPackage.builder()
+                .dataType(TransferPackage.DataType.PROCESS)
+                .docRelative(docRelative)
+                .traceChain(traceService.traceFromPsv(docRelative))
+                .build();
+    }
+}
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductPackageStrategy.java
new file mode 100644
index 0000000..3e169f8
--- /dev/null
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductPackageStrategy.java
@@ -0,0 +1,37 @@
+package org.jeecg.modules.dnc.service.impl;
+
+import org.jeecg.modules.dnc.dto.TransferPackage;
+import org.jeecg.modules.dnc.entity.DocRelative;
+import org.jeecg.modules.dnc.entity.ProductInfo;
+import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
+import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
+import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
+import org.jeecg.modules.dnc.service.DataPackageStrategy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ProductPackageStrategy implements DataPackageStrategy {
+    @Autowired
+    private ProductInfoMapper productInfoMapper;
+    @Autowired
+    private DeviceTypeMapper deviceTypeMapper;
+    @Autowired
+    private FullHierarchyTraceService traceService;
+    @Autowired
+    private DocRelativeMapper docRelativeMapper;
+
+    @Override
+    public TransferPackage packageData(String relativeId) {
+        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
+        ProductInfo productInfo=productInfoMapper.selectById(docRelative.getAttributionId());
+        if (productInfo == null) {
+            throw new IllegalArgumentException("瀵瑰簲鐨勪骇鍝佷笉瀛樺湪: " + docRelative.getAttributionId());
+        }
+        return TransferPackage.builder()
+                .dataType(TransferPackage.DataType.PRODUCT)
+                .docRelative(docRelative)
+                .traceChain(traceService.traceFromProduct(docRelative))
+                .build();
+    }
+}
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java
index 5770843..dde92ae 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java
@@ -82,6 +82,18 @@
 	 }
 
 	 /**
+	  * 鍏朵粬鏂囨。鎵嬪姩鍙戣捣娴佺▼
+	  * @param dispatchFile
+	  * @return
+	  */
+	 @AutoLog(value = "nc绋嬪簭涓庣數瀛愬浘鐗堢娲�-鍏朵粬鏂囨。鎵嬪姩鍙戣捣娴佺▼")
+	 @ApiOperation(value="nc绋嬪簭涓庣數瀛愬浘鐗堢娲�-鍏朵粬鏂囨。鎵嬪姩鍙戣捣娴佺▼", notes="nc绋嬪簭涓庣數瀛愬浘鐗堢娲�-鍏朵粬鏂囨。鎵嬪姩鍙戣捣娴佺▼")
+	 @PostMapping(value = "/startDispatchFile")
+	 public Result<?> startDispatchFile(@RequestBody DispatchFile dispatchFile){
+		 return dispatchFileService.saveDispatchFile(dispatchFile);
+	 }
+
+	 /**
 	  * 閲嶆柊鍚姩
 	  * @param dispatchFileFlowTaskVo
 	  * @return
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
index 1b89f6f..2fb9d31 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
@@ -346,8 +346,11 @@
             DocFile docFile = docFileService.getById(en.getFileId());
             if(docFile == null)
                 ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
-            //淇敼鍘熸湁鐘舵��
-            docInfo.setDocDispatchStatus(4);
+            //淇敼NC鐘舵��
+            if (Objects.equals(en.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode().toString()) ||
+                    Objects.equals(en.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode().toString())) {
+                docInfo.setDocDispatchStatus(4);
+            }
             docInfoService.updateById(docInfo);
             DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(en.getDocId(),7, en.getDeviceId());
             if(deviceDoc != null) {
@@ -378,19 +381,17 @@
             }
             if(!b)
                 ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR);
-            if (mdcEquipment != null) {
-                List<String> strings =  iMdcProductionService.findListParentTreeAll(mdcEquipment.getId());
-                if (strings != null && !strings.isEmpty()) {
-                    String path = StringUtils.join(strings.toArray(), "/");
-                    boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(),path + "/"+ mdcEquipment.getEquipmentId(),
-                            docFile.getFileEncodeName(),
+            List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId());
+            if (strings != null && !strings.isEmpty()) {
+                String path = StringUtils.join(strings.toArray(), "/");
+                boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(),path + "/"+ mdcEquipment.getEquipmentId(),
+                        docFile.getFileEncodeName(),
+                        docFile.getFileName(),docFile.getFileSuffix());
+                if (!copyFileNc) {
+                    ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
+                } else {
+                    FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(),
                             docFile.getFileName(),docFile.getFileSuffix());
-                    if (!copyFileNc) {
-                        ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
-                    } else {
-                        FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(),
-                                docFile.getFileName(),docFile.getFileSuffix());
-                    }
                 }
             }
             List<DocRelative> docRelativeList=docRelativeService.
@@ -401,13 +402,15 @@
             if (docRelativeList.isEmpty()){
                 ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR);
             }
-            //娑夊瘑缃戣繘琛孨C鏂囦欢鐨勬嫹璐�
-            handleFileTransfer(mdcEquipment, docFile);
-            //NC鏂囦欢鐨勬嫹璐�
-//            handleFileProcessing(docFile, mdcEquipment, secretFolder);
-            //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐�
-//            handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId());
-            return synchronizedFlagService.updateFlag(1);
+            DocRelative docRelative=docRelativeList.get(0);
+            if (!Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode()) ||
+                    !Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())) {
+                //鍏朵粬鏂囦欢鐨勬嫹璐�
+                handleFileOtherProcessing(docFile, mdcEquipment, secretFolder);
+                //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐�
+                handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId());
+            }
+            return true;
         }else if(up.getStatus() == 3) {
             //鎷掔粷鎿嶄綔 浠�涔堜篃涓嶅仛
             return true;
@@ -687,16 +690,86 @@
         passInfoTxt.setPassType(DncPassLogPassType.PRODUCTSTRUCTURE.getCode());
         dncPassLogService.save(passInfoTxt);
         String fileName="10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY);
-        if (Objects.equals(docInfo.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode())){
-            //宸ュ簭瀵瑰簲璁惧绫�
-            String filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
-            System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath);
-        }else {
-            //宸ユ瀵瑰簲璁惧绫�
-            String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
-            System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath);
+        String filePath="";
+        switch (docInfo.getAttributionType()){
+            case 1:
+                //浜у搧瀵瑰簲鍏朵粬鏂囨。
+                filePath = ferryService.exportData(TransferPackage.DataType.PRODUCT, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
+                System.out.println("浜у搧鏁版嵁宸插鍑�: " + filePath);
+                break;
+            case 2:
+                //閮ㄤ欢瀵瑰簲鍏朵粬鏂囨。
+                filePath = ferryService.exportData(TransferPackage.DataType.COMPONENT, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
+                System.out.println("閮ㄤ欢鏁版嵁宸插鍑�: " + filePath);
+                break;
+            case 3:
+                //闆朵欢瀵瑰簲鍏朵粬鏂囨。
+                filePath = ferryService.exportData(TransferPackage.DataType.PARTS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
+                System.out.println("闆朵欢鏁版嵁宸插鍑�: " + filePath);
+                break;
+            case 4:
+                //宸ヨ壓鐗堟湰瀵瑰簲鍏朵粬鏂囨。
+                filePath = ferryService.exportData(TransferPackage.DataType.OPERATION, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
+                System.out.println("宸ヨ壓鐗堟湰鏁版嵁宸插鍑�: " + filePath);
+                break;
+            case 5:
+                //宸ュ簭瀵瑰簲璁惧绫�
+                filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
+                System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath);
+                break;
+            case 6:
+                //宸ユ瀵瑰簲璁惧绫�
+                filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry");
+                System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath);
+                break;
+            default:
+                break;
         }
     }
+
+    //灏佽澶勭悊鍏朵粬鏂囦欢
+    private void handleFileOtherProcessing(DocFile docFile, MdcEquipment mdcEquipment, String secretFolder) {
+        if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) {
+            List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId());
+            if (strings != null && !strings.isEmpty()) {
+                DncPassLog passInfoTxt = new DncPassLog();
+                String path = StringUtils.join(strings.toArray(), "/");
+                Date dateFirst = DateUtil.getNow();
+                passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
+                /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/
+                //浼戠湢 500姣
+                DncPassLog dncPassLog  = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
+                int fileNc =0;
+                if (dncPassLog !=null) {
+                    fileNc = dncPassLog.getSequenceNumber() + 1;
+                } else {
+                    fileNc =  1;
+                }
+                //澶勭悊鏂囦欢鍚嶇О  鏂囦欢璺緞
+                String sequenceNc = String.format("%06d",fileNc);
+                DncPassLog passInfoNc = new DncPassLog();
+                passInfoNc.setSequenceNumber(fileNc);
+                passInfoNc.setSequenceOrder(sequenceNc);
+                passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
+                passInfoNc.setPassType("02");
+                passInfoNc.setPassName(docFile.getFileName());
+                try {
+                    Thread.sleep(1000);
+                    Date date = new Date();
+                    passInfoNc.setCreateTime(date);
+                    System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME));
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                dncPassLogService.save(passInfoNc);
+                FileUtilS.copyFileUpName(path + "/" + mdcEquipment.getEquipmentId() + "/send/" +
+                                docFile.getFileName(),
+                        secretFolder +"/"+"10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc+"_"+mdcEquipment.getEquipmentId(),
+                        docFile.getFileSuffix(), docFile.getFileSuffix());
+            }
+        }
+    }
+
     @Override
     public void afterFlowHandle(FlowMyBusiness business) {
         business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣

--
Gitblit v1.9.3