lyh
3 天以前 b1e37337ac05917ad6989177bc639acc2c065600
航宇两网交互新增其他文档
已添加4个文件
已修改8个文件
529 ■■■■ 文件已修改
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentPackageStrategy.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsPackageStrategy.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionPackageStrategy.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductPackageStrategy.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java 131 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
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
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();
    }
}
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());
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);
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<>();
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;
    }
}
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();
    }
}
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();
    }
}
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();
    }
}
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
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);
            }
            //涉密网进行NC文件的拷贝
            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();//接下来审批的节点