已添加14个文件
已修改8个文件
1600 ■■■■■ 文件已修改
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/constant/DncPassLogPassType.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/DataPackageStrategy.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java 213 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessPackageStrategy.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepPackageStrategy.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java 252 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java 316 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/constant/DncPassLogPassType.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,39 @@
package org.jeecg.modules.dnc.constant;
public enum DncPassLogPassType {
    //NC文件
    DOCUMENT("01", "nc文件"),
    //nc文件
    NCFILE("02", "NC文件"),
    //产品结构树
    PRODUCTSTRUCTURE("03", "产品结构树"),
    //程序加工确认表
    PROGRAMPROCESSING("04", "程序加工确认表");
    private String code;
    private String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    DncPassLogPassType() {
    }
    DncPassLogPassType(String code, String name) {
        this.code = code;
        this.name = name;
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java
@@ -38,6 +38,18 @@
    }
    /**
     * èŽ·å–å…¨éƒ¨äº§å“æ ‘ï¼ˆåŒ…æ‹¬è®¾å¤‡ç±»ä¸Žnc文件)
     * @return
     */
    @AutoLog(value = "获取全部产品树")
    @ApiOperation(value = "获取全部产品树", notes = "获取全部产品树")
    @GetMapping(value = "/getAllTree")
    public Result<?> getAllTree() {
        List<ProductMix> productMixList = iProductMixService.getProductMixTree();
        return Result.OK(productMixList);
    }
    /**
     * èŽ·å–å…·ä½“å±‚çº§å®žä½“
     * @param id,type
     * @return
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java
@@ -6,5 +6,22 @@
import org.jeecg.modules.dnc.entity.ProductMix;
public interface ProductMixMapper extends BaseMapper<ProductMix> {
    @Select("SELECT * FROM nc_product_mix WHERE id = #{productId} AND tree_type = 1")
    ProductMix findByProductId(@Param("productId") String productId);
    @Select("SELECT * FROM nc_product_mix WHERE id = #{componentId} AND tree_type = 2")
    ProductMix findByComponentId(@Param("componentId") String componentId);
    @Select("SELECT * FROM nc_product_mix WHERE id = #{partsId} AND tree_type = 3")
    ProductMix findByPartsId(@Param("partsId") String partsId);
    @Select("SELECT * FROM nc_product_mix WHERE id = #{operationId} AND tree_type = 4")
    ProductMix findByOperationId(@Param("operationId") String operationId);
    @Select("SELECT * FROM nc_product_mix WHERE id = #{processId} AND tree_type = 5")
    ProductMix findByProcessId(@Param("operationId") String processId);
    @Select("SELECT * FROM nc_product_mix WHERE id = #{worksiteId} AND tree_type = 6")
    ProductMix findByWorksiteId(@Param("operationId") String worksiteId);
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/DataPackageStrategy.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package org.jeecg.modules.dnc.service;
import org.jeecg.modules.dnc.dto.TransferPackage;
// æ•°æ®å°è£…策略接口
public interface DataPackageStrategy {
    /**
     * å°è£…业务数据为传输包
     * @param id ä¸šåŠ¡å®žä½“ID(工序ID或工步ID)
     * @return å°è£…好的传输包
     */
    TransferPackage packageData(String id);
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java
@@ -12,6 +12,23 @@
    //获取封装产品结构树
    public List<ProductMix> getTree();
    //模拟生成产品结构树
    /**
     * æŸ¥è¯¢å¯¹åº”id的所有父级(权限分配使用)
     * @param id
     * @return
     */
    List<ProductMix> getParentList(String id);
    /**
     * æŸ¥è¯¢å¯¹åº”id的所有子节点(权限分配使用)
     * @param id
     * @return
     */
    List<ProductMix> getChildrenList(String id);
    /**
     * æŸ¥è¯¢äº§å“ç»“构树(包括设备类与nc文件)
     * @return
     */
    List<ProductMix> getProductMixTree();
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java
@@ -8,6 +8,7 @@
import org.jeecg.modules.dnc.entity.*;
import org.jeecg.modules.dnc.mapper.*;
import org.jeecg.modules.dnc.service.*;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysUserService;
import org.slf4j.Logger;
@@ -295,9 +296,9 @@
                    }
                }
                if (permissionStreamNew.getDepartId() != null) {
                    String id=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()).getId();
                    if (id!=null){
                        permissionStreamNew.setDepartId(id);
                    MdcProduction mdcProduction=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId());
                    if (mdcProduction!=null){
                        permissionStreamNew.setDepartId(mdcProduction.getId());
                    }
                }
                permissionStreamNewMapper.insert(permissionStreamNew);
@@ -449,6 +450,7 @@
    private void saveGuideCardBatch(GuideCardBatch guideCardBatch) {
        if (guideCardBatchMapper.selectById(guideCardBatch.getId()) == null) {
            guideCardBatch.setFlowStatus("1");
            guideCardBatchMapper.insert(guideCardBatch);
            logger.debug("刀片批次已保存: {}", guideCardBatch.getId());
        } else {
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package org.jeecg.modules.dnc.service.impl;
import org.jeecg.modules.dnc.dto.TransferPackage;
import org.jeecg.modules.dnc.service.DataPackageStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@Service
public class DataPackageService {
    private final Map<TransferPackage.DataType, DataPackageStrategy> strategies;
    @Autowired
    public DataPackageService(List<DataPackageStrategy> strategyList) {
        strategies = new EnumMap<>(TransferPackage.DataType.class);
        strategyList.forEach(strategy -> {
            if (strategy instanceof ProcessPackageStrategy) {
                strategies.put(TransferPackage.DataType.PROCESS, strategy);
            } else if (strategy instanceof WorkStepPackageStrategy) {
                strategies.put(TransferPackage.DataType.WORKSTEP, strategy);
            }
        });
    }
    public TransferPackage packageData(TransferPackage.DataType type, String id) {
        DataPackageStrategy strategy = strategies.get(type);
        if (strategy == null) {
            throw new IllegalArgumentException("不支持的数据类型: " + type);
        }
        return strategy.packageData(id);
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java
@@ -62,6 +62,36 @@
    @Autowired
    private IDocRelativeService docRelativeService;
    @Autowired
    private DataPackageService dataPackageService;
    public String exportData(TransferPackage.DataType type, String id,String fileName) {
        // 1. èŽ·å–å°è£…æ•°æ®
        TransferPackage transferPackage = dataPackageService.packageData(type, id);
        // 2. åŽ‹ç¼©å±‚çº§ç»“æž„
        compressHierarchy(transferPackage);
        // 3. JSON序列化
        String json = JsonUtils.toJson(transferPackage);
//        // 4. åŽ‹ç¼©åŠ å¯†
//        byte[] compressed = CompressionUtils.gzipCompress(json.getBytes(StandardCharsets.UTF_8));
//        byte[] encrypted = securityService.encrypt(compressed);
        //暂时不加密
        byte[] compressed = json.getBytes(StandardCharsets.UTF_8);
        // 5. ç”Ÿæˆæ–‡ä»¶
        Path filePath = Paths.get(ferryPath,fileName);
        try {
            Files.createDirectories(filePath.getParent());
            Files.write(filePath, compressed);
            return filePath.toString();
        } catch (IOException e) {
            throw new RuntimeException("文件写入失败", e);
        }
    }
    public TransferPackage importData(String filePath) {
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,213 @@
package org.jeecg.modules.dnc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
import org.jeecg.modules.dnc.dto.ComponentHierarchy;
import org.jeecg.modules.dnc.dto.ProcessTraceChain;
import org.jeecg.modules.dnc.entity.*;
import org.jeecg.modules.dnc.mapper.*;
import org.jeecg.modules.dnc.service.IPermissionStreamNewService;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
public class FullHierarchyTraceService {
    @Autowired
    private ProductMixMapper productMixMapper;
    @Autowired
    private ProductInfoMapper productMapper;
    @Autowired
    private ComponentInfoMapper componentMapper;
    @Autowired
    private PartsInfoMapper partsMapper;
    @Autowired
    private ProcessSpecVersionMapper psvMapper;
    @Autowired
    private ProcessStreamMapper processMapper;
    @Autowired
    private WorkStepMapper workStepMapper;
    @Autowired
    private DeviceTypeMapper deviceTypeMapper;
    @Autowired
    private DeviceManagementMapper deviceManagementMapper;
    @Autowired
    private DocInfoMapper docInfoMapper;
    @Autowired
    private DocFileMapper docFileMapper;
    @Autowired
    private CutterMapper cutterMapper;
    @Autowired
    private GuideCardBatchMapper guideCardBatchMapper;
    public ProcessTraceChain traceFromProcess(DocRelative docRelative) {
        ProcessTraceChain chain = initChainWithDocInfo(docRelative);
        DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId());
        chain.setDeviceType(deviceType);
        if (isProcessType(deviceType)) {
            chain.setDeviceManagement(deviceManagementMapper.selectById(deviceType.getDeviceManagementId()));
            traceProcessChain(chain, deviceType.getAttributionId());
        }
        completeChainWithProductInfo(chain);
        List<ProductMix> productMixList=buildFullTreePath(chain);
        chain.setTreePath(productMixList);
        return chain;
    }
    public ProcessTraceChain traceFromWorkStep(DocRelative docRelative) {
        ProcessTraceChain chain = initChainWithDocInfo(docRelative);
        DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId());
        chain.setDeviceType(deviceType);
        if (isWorkSiteType(deviceType)) {
            chain.setDeviceManagement(deviceManagementMapper.selectById(deviceType.getDeviceManagementId()));
            traceWorkStepChain(chain, deviceType.getAttributionId());
        }
        completeChainWithProductInfo(chain);
        List<ProductMix> productMixList=buildFullTreePath(chain);
        chain.setTreePath(productMixList);
        return chain;
    }
    private ProcessTraceChain initChainWithDocInfo(DocRelative docRelative) {
        ProcessTraceChain chain = ProcessTraceChain.builder().docRelative(docRelative).build();
        Optional.ofNullable(docInfoMapper.selectById(docRelative.getDocId()))
                .ifPresent(doc -> {
                    chain.setDocInfo(doc);
                    chain.setDocFile(docFileMapper.selectById(doc.getPublishFileId()));
                    chain.setCutterList(getCuttersByDocId(doc.getDocId()));
                    getLatestGuideCardBatch(doc.getDocId()).ifPresent(chain::setGuideCardBatch);
                });
        return chain;
    }
    private List<Cutter> getCuttersByDocId(String docId) {
        return cutterMapper.selectList(new QueryWrapper<Cutter>().eq("doc_id", docId));
    }
    private Optional<GuideCardBatch> getLatestGuideCardBatch(String docId) {
        List<GuideCardBatch> batches = guideCardBatchMapper.selectList(
                new QueryWrapper<GuideCardBatch>()
                        .eq("doc_id", docId)
                        .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)"));
        return CollectionUtils.isEmpty(batches) ? Optional.empty() : Optional.of(batches.get(0));
    }
    private boolean isProcessType(DeviceType deviceType) {
        return deviceType != null &&
                Objects.equals(deviceType.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode());
    }
    private boolean isWorkSiteType(DeviceType deviceType) {
        return deviceType != null &&
                Objects.equals(deviceType.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode());
    }
    private void traceProcessChain(ProcessTraceChain chain, String processId) {
        ProcessStream process = processMapper.selectById(processId);
        if (process == null) return;
        chain.setProcess(process);
        if (process.getPsvId() != null) {
            ProcessSpecVersion psv = psvMapper.selectById(process.getPsvId());
            chain.setProcessSpec(psv);
            if (psv != null && psv.getPartsId() != null) {
                PartsInfo parts = partsMapper.selectById(psv.getPartsId());
                chain.setParts(parts);
                if (parts != null && parts.getComponentId() != null) {
                    chain.setComponentHierarchy(traceComponentHierarchy(parts.getComponentId()));
                }
            }
        } else if (process.getComponentId() != null) {
            chain.setComponentHierarchy(traceComponentHierarchy(process.getComponentId()));
        }
    }
    private void traceWorkStepChain(ProcessTraceChain chain, String workStepId) {
        WorkStep workStep = workStepMapper.selectById(workStepId);
        if (workStep == null) return;
        chain.setWorkStep(workStep);
        traceProcessChain(chain, workStep.getProcessId());
    }
    private ComponentHierarchy traceComponentHierarchy(String componentId) {
        ComponentHierarchy hierarchy = new ComponentHierarchy();
        ComponentInfo current = componentMapper.selectById(componentId);
        while (current != null) {
            hierarchy.addComponentToTop(current);
            if (current.getParentId() == null || current.getParentId().isEmpty()) {
                Optional.ofNullable(current.getProductId())
                        .map(productMapper::selectById)
                        .ifPresent(hierarchy::setRootProduct);
                break;
            }
            current = componentMapper.selectById(current.getParentId());
        }
        return hierarchy;
    }
    private void completeChainWithProductInfo(ProcessTraceChain chain) {
        Optional.ofNullable(chain.getComponentHierarchy())
                .map(ComponentHierarchy::getComponents)
                .filter(components -> !components.isEmpty())
                .map(components -> components.get(0))
                .map(ComponentInfo::getProductId)
                .map(productMapper::selectById)
                .ifPresent(chain::setProduct);
    }
    private List<ProductMix> buildFullTreePath(ProcessTraceChain chain) {
        List<ProductMix> path = new ArrayList<>();
        Optional.ofNullable(chain.getProduct())
                .map(ProductInfo::getProductId)
                .map(productMixMapper::findByProductId)
                .ifPresent(path::add);
        Optional.ofNullable(chain.getComponentHierarchy())
                .map(ComponentHierarchy::getComponentsFromTop)
                .ifPresent(components -> components.stream()
                        .map(ComponentInfo::getComponentId)
                        .map(productMixMapper::findByComponentId)
                        .filter(Objects::nonNull)
                        .forEach(path::add));
        Optional.ofNullable(chain.getParts())
                .map(PartsInfo::getPartsId)
                .map(productMixMapper::findByPartsId)
                .ifPresent(path::add);
        Optional.ofNullable(chain.getProcessSpec())
                .map(ProcessSpecVersion::getId)
                .map(productMixMapper::findByOperationId)
                .ifPresent(path::add);
        Optional.ofNullable(chain.getProcess())
                .map(ProcessStream::getProcessId)
                .map(productMixMapper::findByProcessId)
                .ifPresent(path::add);
        Optional.ofNullable(chain.getWorkStep())
                .map(WorkStep::getId)
                .map(productMixMapper::findByWorksiteId)
                .ifPresent(path::add);
        return path;
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessPackageStrategy.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
package org.jeecg.modules.dnc.service.impl;
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
import org.jeecg.modules.dnc.dto.TransferPackage;
import org.jeecg.modules.dnc.entity.DeviceType;
import org.jeecg.modules.dnc.entity.DocRelative;
import org.jeecg.modules.dnc.entity.ProcessStream;
import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
import org.jeecg.modules.dnc.mapper.ProcessStreamMapper;
import org.jeecg.modules.dnc.service.DataPackageStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProcessPackageStrategy implements DataPackageStrategy {
    @Autowired
    private ProcessStreamMapper processMapper;
    @Autowired
    private DeviceTypeMapper deviceTypeMapper;
    @Autowired
    private FullHierarchyTraceService traceService;
    @Autowired
    private DocRelativeMapper docRelativeMapper;
    @Override
    public TransferPackage packageData(String relativeId) {
        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
        DeviceType deviceType=deviceTypeMapper.selectById(docRelative.getAttributionId());
        if (deviceType!=null&&deviceType.getAttributionType().equals(DocAttributionTypeEnum.PROCESS.getCode())) {
            ProcessStream process = processMapper.selectById(deviceType.getAttributionId());
            if (process == null) {
                throw new IllegalArgumentException("设备类对应的工序不存在: " + deviceType.getDeviceManagementId());
            }
        }
        return TransferPackage.builder()
                .dataType(TransferPackage.DataType.PROCESS)
                .docRelative(docRelative)
                .traceChain(traceService.traceFromProcess(docRelative))
                .build();
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java
@@ -1,17 +1,19 @@
package org.jeecg.modules.dnc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.entity.ProductMix;
import org.jeecg.modules.dnc.entity.*;
import org.jeecg.modules.dnc.mapper.ProductMixMapper;
import org.jeecg.modules.dnc.service.IPermissionStreamNewService;
import org.jeecg.modules.dnc.service.IProductMixService;
import org.jeecg.modules.dnc.service.*;
import org.jeecg.modules.dnc.utils.TreeBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ProductMixServiceImpl extends ServiceImpl<ProductMixMapper, ProductMix> implements IProductMixService {
@@ -19,6 +21,21 @@
    @Autowired
    private IPermissionStreamNewService permissionStreamNewService;
    @Autowired
    @Lazy
    private IDeviceTypeService deviceTypeService;
    @Autowired
    @Lazy
    private IDeviceManagementService deviceManagementService;
    @Autowired
    @Lazy
    private IDocInfoService docInfoService;
    @Autowired
    @Lazy
    private IDocRelativeService docRelativeService;
    /**
     * é»˜è®¤ç»“构树查询
     * @return
@@ -48,4 +65,135 @@
        result.sort(Comparator.comparing(ProductMix::getCreateTime, Comparator.nullsLast(Date::compareTo)));
        return result;
    }
    @Override
    public List<ProductMix> getParentList(String id) {
        List<ProductMix> parentList = new ArrayList<>();
        // 1. æ ¹æ®ID查询当前节点
        ProductMix current = this.getById(id);
        if (current == null) {
            return parentList; // èŠ‚ç‚¹ä¸å­˜åœ¨æ—¶è¿”å›žç©ºåˆ—è¡¨
        }
        // 2. ä»Žå½“前节点开始向上查找父节点
        Long parentId = current.getParentId();
        while ( parentId != 0L) {
            ProductMix parent = this.getById(parentId.toString());
            if (parent == null) {
                break;
            }
            parentList.add(parent);
            parentId = parent.getParentId();
        }
        return parentList;
    }
    @Override
    public List<ProductMix> getChildrenList(String id) {
        List<ProductMix> childrenList = new ArrayList<>();
        ProductMix current = this.getById(id);
        if (current == null) {
            return childrenList;
        }
        // ä½¿ç”¨é˜Ÿåˆ—进行BFS
        Queue<ProductMix> queue = new LinkedList<>();
        queue.add(current); // åŠ å…¥å½“å‰èŠ‚ç‚¹ä½œä¸ºèµ·ç‚¹
        // è®°å½•已访问节点的ID,避免循环引用
        Set<String> visited = new HashSet<>();
        visited.add(id); // èµ·å§‹èŠ‚ç‚¹å·²è®¿é—®
        while (!queue.isEmpty()) {
            ProductMix node = queue.poll();
            // è·³è¿‡èµ·å§‹èŠ‚ç‚¹ï¼ˆå³ä¼ å…¥çš„èŠ‚ç‚¹ï¼‰ï¼Œä¸åŠ å…¥ç»“æžœåˆ—è¡¨
            if (!node.getId().toString().equals(id)) {
                childrenList.add(node);
            }
            // æŸ¥è¯¢å½“前节点的直接子节点
            List<ProductMix> directChildren = this.lambdaQuery().eq(ProductMix::getParentId, node.getId()).list();
            if (directChildren != null && !directChildren.isEmpty()) {
                for (ProductMix child : directChildren) {
                    String childId = child.getId().toString();
                    // å¦‚果该子节点还未访问过
                    if (!visited.contains(childId)) {
                        visited.add(childId);
                        queue.add(child);
                    }
                    // å¦åˆ™å¿½ç•¥ï¼Œé¿å…å¾ªçŽ¯å¼•ç”¨å¯¼è‡´çš„æ­»å¾ªçŽ¯
                }
            }
        }
        return childrenList;
    }
    /**
     * æŸ¥è¯¢äº§å“ç»“构树(包括设备类与nc文件)
     * @return
     */
    @Override
    public List<ProductMix> getProductMixTree() {
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<ProductMix> rawData = new ArrayList<>();
        if (loginUser.getUsername().equals("admin")) {
            //不需要权限过滤
            rawData = permissionStreamNewService.loadProductMixAll(loginUser.getId());
        } else {
            //需要权限过滤
            String productIds = loginUser.getProductionIds();
            if (productIds != null && !productIds.isEmpty()) {
                List<String> productIdList = Arrays.asList(productIds.split(","));
                rawData = permissionStreamNewService.loadProductMix(loginUser.getId(), productIdList);
            }
        }
        List<Long> ids = rawData.stream()
                .filter(p -> p.getType() != null)
                .filter(productMix -> productMix.getType() == 5 || productMix.getType() == 6)
                .map(ProductMix::getId)
                .collect(Collectors.toList());
        if (ids.isEmpty()) {
            return rawData;
        }
        //过滤设备类关联信息
        List<DeviceType> deviceTypeList = deviceTypeService.list(new QueryWrapper<DeviceType>()
                .in("attribution_id", ids));
        List<ProductMix> productMixList = new ArrayList<>();
        deviceTypeList.forEach(item->{
            ProductMix productMix = new ProductMix();
            productMix.setId(Long.parseLong(item.getId()));
            productMix.setParentId(Long.parseLong(item.getAttributionId()));
            DeviceManagement deviceManagement=deviceManagementService.getById(item.getDeviceManagementId());
            productMix.setTreeCode(deviceManagement.getDeviceManagementCode());
            productMix.setTreeName(deviceManagement.getDeviceManagementName());
            productMix.setType(7);
            productMixList.add(productMix);
        });
        rawData.addAll(productMixList);
        //过滤文档关联信息
        List<String> deviceTypeIds = deviceTypeList.stream().map(DeviceType::getId).collect(Collectors.toList());
        List<DocRelative> relativeList = docRelativeService.list(new QueryWrapper<DocRelative>()
                .in("attribution_id", deviceTypeIds));
        List<ProductMix> docList = new ArrayList<>();
        relativeList.forEach(item->{
            ProductMix productMix = new ProductMix();
            productMix.setId(Long.parseLong(item.getId()));
            productMix.setParentId(Long.parseLong(item.getAttributionId()));
            DocInfo docInfo = docInfoService.getById(item.getDocId());
            productMix.setTreeCode(docInfo.getDocSuffix());
            productMix.setTreeName(docInfo.getDocName());
            productMix.setType(99);
            docList.add(productMix);
        });
        rawData.addAll(docList);
        TreeBuilder builder = new TreeBuilder();
        TreeBuilder.CleanResult cleanResult = builder.preprocessData(rawData);
        List<ProductMix> sorted = builder.topologicalSort(
                cleanResult.getValidNodes(),
                cleanResult.getNodeMap()
        );
        List<ProductMix> result =builder.assembleTree(sorted, cleanResult.getNodeMap());
        result.sort(Comparator.comparing(ProductMix::getCreateTime, Comparator.nullsLast(Date::compareTo)));
        return result;
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepPackageStrategy.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,43 @@
package org.jeecg.modules.dnc.service.impl;
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
import org.jeecg.modules.dnc.dto.TransferPackage;
import org.jeecg.modules.dnc.entity.DeviceType;
import org.jeecg.modules.dnc.entity.DocRelative;
import org.jeecg.modules.dnc.entity.WorkStep;
import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
import org.jeecg.modules.dnc.mapper.WorkStepMapper;
import org.jeecg.modules.dnc.service.DataPackageStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class WorkStepPackageStrategy implements DataPackageStrategy {
    @Autowired
    private WorkStepMapper workStepMapper;
    @Autowired
    private FullHierarchyTraceService traceService;
    @Autowired
    private DeviceTypeMapper deviceTypeMapper;
    @Autowired
    private DocRelativeMapper docRelativeMapper;
    @Override
    public TransferPackage packageData(String relativeId) {
        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
        DeviceType deviceType=deviceTypeMapper.selectById(docRelative.getAttributionId());
        if (deviceType!=null&&deviceType.getAttributionType().equals(DocAttributionTypeEnum.WORKSITE.getCode())) {
            WorkStep workStep = workStepMapper.selectById(deviceType.getAttributionId());
            if (workStep == null) {
                throw new IllegalArgumentException("设备类对应的工步不存在: " + deviceType.getDeviceManagementId());
            }
        }
        return TransferPackage.builder()
                .dataType(TransferPackage.DataType.WORKSTEP)
                .docRelative(docRelative)
                .traceChain(traceService.traceFromWorkStep(docRelative))
                .build();
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
package org.jeecg.modules.dncFlow.adapter;
import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream;
import org.jeecg.modules.dncFlow.service.StreamTarget;
public class AssignEquipmentFileStreamAdapter implements StreamTarget {
    private final AssignEquipmentFileStream file;
    public AssignEquipmentFileStreamAdapter(AssignEquipmentFileStream file) {
        this.file = file;
    }
    @Override
    public void setProductId(String productId) {
        file.setProductId(productId);
    }
    @Override
    public void setComponentId(String componentId) {
        file.setComponentId(componentId);
    }
    @Override
    public void setPartsId(String partsId) {
        file.setPartsId(partsId);
    }
    @Override
    public void setProcessId(String processId) {
        file.setProcessId(processId);
    }
    @Override
    public void setPsvId(String psvId) {
        file.setPsvId(psvId);
    }
    @Override
    public void setStepId(String stepId) {
        file.setStepId(stepId);
    }
    @Override
    public void setDeviceTypeId(String deviceTypeId) {
        file.setDeviceTypeId(deviceTypeId);
    }
    @Override
    public String getAttributionId() {
        return file.getAttributionId();
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,252 @@
package org.jeecg.modules.dncFlow.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.dnc.entity.DeviceManagement;
import org.jeecg.modules.dnc.entity.DeviceType;
import org.jeecg.modules.dnc.entity.DocInfo;
import org.jeecg.modules.dnc.entity.DocRelative;
import org.jeecg.modules.dnc.service.IDeviceManagementService;
import org.jeecg.modules.dnc.service.IDeviceTypeService;
import org.jeecg.modules.dnc.service.IDocInfoService;
import org.jeecg.modules.dnc.service.IDocRelativeService;
import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream;
import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
 /**
 * @Description: DNC-设备结构树指派产品结构树
 * @Author: jeecg-boot
 * @Date:   2025-06-17
 * @Version: V1.0
 */
@Api(tags="DNC-设备结构树指派产品结构树")
@RestController
@RequestMapping("/dncFlow/assignEquipmentFileStream")
@Slf4j
public class AssignEquipmentFileStreamController extends JeecgController<AssignEquipmentFileStream, IAssignEquipmentFileStreamService> {
    @Autowired
    private IAssignEquipmentFileStreamService assignEquipmentFileStreamService;
    @Autowired
    private IDeviceTypeService deviceTypeService;
    @Autowired
    private IDeviceManagementService deviceManagementService;
    @Autowired
    private IDocRelativeService docRelativeService;
    @Autowired
    private IDocInfoService docInfoService;
    /**
     * åˆ†é¡µåˆ—表查询
     *
     * @param assignEquipmentFileStream
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "DNC-设备结构树指派产品结构树-分页列表查询")
    @ApiOperation(value="DNC-设备结构树指派产品结构树-分页列表查询", notes="DNC-设备结构树指派产品结构树-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<AssignEquipmentFileStream>> queryPageList(AssignEquipmentFileStream assignEquipmentFileStream,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<AssignEquipmentFileStream> queryWrapper = QueryGenerator.initQueryWrapper(assignEquipmentFileStream, req.getParameterMap());
        Page<AssignEquipmentFileStream> page = new Page<AssignEquipmentFileStream>(pageNo, pageSize);
        IPage<AssignEquipmentFileStream> pageList = assignEquipmentFileStreamService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
     /**
      * æµç¨‹å¯åЍ,保存对应的数据
      * @param assignEquipmentFileStream
      * @return
      */
     @AutoLog(value = "DNC-设备结构树指派产品结构树-流程启动,保存对应的数据")
     @ApiOperation(value="DNC-设备结构树指派产品结构树-流程启动,保存对应的数据", notes="DNC-设备结构树指派产品结构树-流程启动,保存对应的数据")
     @PostMapping(value = "savaFlow")
     public Result<?> saveAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream){
         return assignEquipmentFileStreamService.saveAssignEquipmentFileStream(assignEquipmentFileStream);
     }
     /**
      * æµç¨‹èŠ‚ç‚¹å®¡æ ¸
      * @param assignEquipmentFileStreamVo
      * @return
      */
     @AutoLog(value = "DNC-设备结构树指派产品结构树-流程节点审核")
     @ApiOperation(value="DNC-设备结构树指派产品结构树-流程节点审核", notes="DNC-设备结构树指派产品结构树-流程节点审核")
     @PostMapping(value = "audit")
     public Result<?> auditAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){
         return assignEquipmentFileStreamService.auditAssignEquipmentFileStream(assignEquipmentFileStreamVo);
     }
    /**
     *   æ·»åŠ 
     *
     * @param assignEquipmentFileStream
     * @return
     */
    @AutoLog(value = "DNC-设备结构树指派产品结构树-添加")
    @ApiOperation(value="DNC-设备结构树指派产品结构树-添加", notes="DNC-设备结构树指派产品结构树-添加")
    //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) {
        assignEquipmentFileStreamService.save(assignEquipmentFileStream);
        return Result.OK("添加成功!");
    }
     /**
      * æŸ¥è¯¢å®¡ç­¾åŸºæœ¬ä¿¡æ¯
      * @param id
      * @return
      */
     @ApiOperation(value = "查询审签基本信息", notes = "查询审签基本信息")
     @GetMapping(value = "/selectVoById")
     public Result<?> selectVoById(@RequestParam(name="id") String id){
         List<AssignEquipmentFileStream> list = assignEquipmentFileStreamService.list(new QueryWrapper<AssignEquipmentFileStream>().eq("id", id));
         if (!list.isEmpty()){
             list.forEach(item->{
                 DeviceType deviceType = deviceTypeService.getById(item.getDeviceTypeId());
                 if (deviceType!=null){
                     DeviceManagement deviceManagement = deviceManagementService.getById(deviceType.getDeviceManagementId());
                     if (deviceManagement!=null){
                         item.setDeviceTypeName(deviceManagement.getDeviceManagementName());
                     }
                 }
                 DocRelative docRelative=docRelativeService.getById(item.getDocId());
                 if (docRelative!=null){
                     DocInfo docInfo = docInfoService.getById(docRelative.getDocId());
                     item.setDocName(docInfo.getDocName());
                 }
             });
             return Result.OK(list);
         }
         return Result.error("未找到对应数据");
     }
    /**
     *  ç¼–辑
     *
     * @param assignEquipmentFileStream
     * @return
     */
    @AutoLog(value = "DNC-设备结构树指派产品结构树-编辑")
    @ApiOperation(value="DNC-设备结构树指派产品结构树-编辑", notes="DNC-设备结构树指派产品结构树-编辑")
    //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) {
        assignEquipmentFileStreamService.updateById(assignEquipmentFileStream);
        return Result.OK("编辑成功!");
    }
    /**
     *   é€šè¿‡id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "DNC-设备结构树指派产品结构树-通过id删除")
    @ApiOperation(value="DNC-设备结构树指派产品结构树-通过id删除", notes="DNC-设备结构树指派产品结构树-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        assignEquipmentFileStreamService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     *  æ‰¹é‡åˆ é™¤
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "DNC-设备结构树指派产品结构树-批量删除")
    @ApiOperation(value="DNC-设备结构树指派产品结构树-批量删除", notes="DNC-设备结构树指派产品结构树-批量删除")
    //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.assignEquipmentFileStreamService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
    /**
     * é€šè¿‡id查询
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "DNC-设备结构树指派产品结构树-通过id查询")
    @ApiOperation(value="DNC-设备结构树指派产品结构树-通过id查询", notes="DNC-设备结构树指派产品结构树-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<AssignEquipmentFileStream> queryById(@RequestParam(name="id",required=true) String id) {
        AssignEquipmentFileStream assignEquipmentFileStream = assignEquipmentFileStreamService.getById(id);
        if(assignEquipmentFileStream==null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(assignEquipmentFileStream);
    }
    /**
    * å¯¼å‡ºexcel
    *
    * @param request
    * @param assignEquipmentFileStream
    */
    //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, AssignEquipmentFileStream assignEquipmentFileStream) {
        return super.exportXls(request, assignEquipmentFileStream, AssignEquipmentFileStream.class, "DNC-设备结构树指派产品结构树");
    }
    /**
      * é€šè¿‡excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    //@RequiresPermissions("nc_assign_equipment_file_stream:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, AssignEquipmentFileStream.class);
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,133 @@
package org.jeecg.modules.dncFlow.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
 * @Description:
 * @Author: jeecg-boot
 * @Date:   2025-06-17
 * @Version: V1.0
 */
@Data
@TableName("nc_assign_equipment_file_stream")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="nc_assign_equipment_file_stream对象", description="DNC-设备结构树指派产品结构树")
public class AssignEquipmentFileStream implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**设备ID*/
    @Excel(name = "设备ID", width = 15)
    @ApiModelProperty(value = "设备ID")
    @Dict(dictTable = "mdc_equipment", dicCode = "id", dicText = "equipment_id")
    private String equipmentId;
    /**设备文档ID*/
    @Excel(name = "设备文档ID", width = 15)
    @ApiModelProperty(value = "设备文档ID")
    @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name")
    private String equipmentDocId;
    /**设备文件ID*/
    @Excel(name = "设备文件ID", width = 15)
    @ApiModelProperty(value = "设备文件ID")
    private String equipmentFileId;
    /**产品ID*/
    @Excel(name = "产品ID", width = 15)
    @ApiModelProperty(value = "产品ID")
    @Dict(dictTable = "nc_product_info", dicCode = "product_id", dicText = "product_name")
    private String productId;
    /**部件ID*/
    @Excel(name = "部件ID", width = 15)
    @ApiModelProperty(value = "部件ID")
    @Dict(dictTable = "nc_component_info", dicCode = "component_id", dicText = "component_name")
    private String componentId;
    /**零件ID*/
    @Excel(name = "零件ID", width = 15)
    @ApiModelProperty(value = "零件ID")
    @Dict(dictTable = "nc_parts_info", dicCode = "parts_id", dicText = "parts_name")
    private String partsId;
    /**工艺规程版本ID*/
    @Excel(name = "工艺规程版本ID", width = 15)
    @ApiModelProperty(value = "工艺规程版本ID")
    @Dict(dictTable = "nc_process_spec_version", dicCode = "id", dicText = "process_spec_version_name")
    private String psvId;
    /**工序ID*/
    @Excel(name = "工序ID", width = 15)
    @ApiModelProperty(value = "工序ID")
    @Dict(dictTable = "nc_process_stream", dicCode = "process_id", dicText = "process_name")
    private String processId;
    /**工步ID*/
    @Excel(name = "工步ID", width = 15)
    @ApiModelProperty(value = "工步ID")
    @Dict(dictTable = "nc_work_step", dicCode = "id", dicText = "step_name")
    private String stepId;
    /**设备类ID*/
    @Excel(name = "设备类ID", width = 15)
    @ApiModelProperty(value = "设备类ID")
    private String deviceTypeId;
    /**产品文档id*/
    @Excel(name = "产品文档id", width = 15)
    @ApiModelProperty(value = "产品文档id")
    @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name")
    private String docId;
    /**指派原因*/
    @Excel(name = "指派原因", width = 15)
    @ApiModelProperty(value = "指派原因")
    private String applyReason;
    /**审核类型*/
    @Excel(name = "审核类型", width = 15)
    @ApiModelProperty(value = "审核类型")
    private String auditType;
    /**审核意见*/
    @Excel(name = "审核意见", width = 15)
    @ApiModelProperty(value = "审核意见")
    private String auditReason;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    private Date createTime;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**更新日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新日期")
    private Date updateTime;
    /**所属部门*/
    @ApiModelProperty(value = "所属部门")
    private String sysOrgCode;
    /**设备类名称*/
    private transient String deviceTypeName;
    /**产品文件名称*/
    private transient String docName;
    /**所属id*/
    private transient String attributionId;
    /**所属type*/
    private transient String attributionType;
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package org.jeecg.modules.dncFlow.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * @Description: DNC-设备结构树指派产品结构树
 * @Author: jeecg-boot
 * @Date:   2025-06-17
 * @Version: V1.0
 */
public interface AssignEquipmentFileStreamMapper extends BaseMapper<AssignEquipmentFileStream> {
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper">
</mapper>
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
package org.jeecg.modules.dncFlow.service;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo;
/**
 * @Description: DNC-设备结构树指派产品结构树
 * @Author: jeecg-boot
 * @Date:   2025-06-17
 * @Version: V1.0
 */
public interface IAssignEquipmentFileStreamService extends IService<AssignEquipmentFileStream> {
    /**
     * æµç¨‹å¯åЍ,保存对应的数据
     * @param assignEquipmentFileStream
     * @return
     */
    Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream);
    /**
     * æµç¨‹èŠ‚ç‚¹å®¡æ ¸
     * @param assignEquipmentFileStreamVo
     * @return
     */
    Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo);
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,316 @@
package org.jeecg.modules.dncFlow.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.constant.DncPassLogPassType;
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
import org.jeecg.modules.dnc.dto.TransferPackage;
import org.jeecg.modules.dnc.entity.*;
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.response.ActivitiCode;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.DocumentCode;
import org.jeecg.modules.dnc.response.UcenterCode;
import org.jeecg.modules.dnc.service.*;
import org.jeecg.modules.dnc.service.impl.FileFerryService;
import org.jeecg.modules.dnc.utils.ValidateUtil;
import org.jeecg.modules.dnc.utils.date.DateUtil;
import org.jeecg.modules.dnc.utils.file.FileUtilS;
import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum;
import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream;
import org.jeecg.modules.dncFlow.entity.DispatchFile;
import org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper;
import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService;
import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo;
import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
/**
 * @Description: DNC-设备结构树指派产品结构树
 * @Author: jeecg-boot
 * @Date:   2025-06-17
 * @Version: V1.0
 */
@Service("IAssignEquipmentFileStreamService")
public class AssignEquipmentFileStreamServiceImpl extends ServiceImpl<AssignEquipmentFileStreamMapper, AssignEquipmentFileStream> implements IAssignEquipmentFileStreamService , FlowCallBackServiceI {
    @Autowired
    private IDocInfoService docInfoService;
    @Autowired
    private IDocFileService docFileService;
    @Autowired
    private IMdcEquipmentService mdcEquipmentService;
    @Autowired
    private IGuideCardBatchService iGuideCardBatchService;
    @Resource
    private FlowCommonService flowCommonService;
    @Resource
    private IFlowDefinitionService flowDefinitionService;
    @Autowired
    private IFlowTaskService flowTaskService;
    @Autowired
    private TaskService taskService;
    @Autowired
    private IFlowMyBusinessService flowMyBusinessService;
    @Autowired
    private IDocRelativeService docRelativeService;
    @Autowired
    private IDeviceTypeService deviceTypeService;
    @Autowired
    private PermissionService permissionService;
    /**
     * æµç¨‹å¯åЍ,保存对应的数据
     * @param assignEquipmentFileStream
     * @return
     */
    @Override
    public Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream){
        //参数校验
        checkParam(assignEquipmentFileStream);
        //获取设备
        MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId());
        if(equipment==null){
            return Result.error("未发现该设备");
        }
        //获取设备文档信息
        DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId());
        if(docInfo==null){
            return Result.error("未发现该设备对应文档");
        }
        //获取设备文件信息
        DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId());
        if(docFile==null){
            return Result.error("未发现该设备对应文件");
        }
        //获取产品文档信息
        DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId());
        //获取对应设备类
        DeviceType deviceType = deviceTypeService.getById(docRelative.getAttributionId());
        if(deviceType!=null){
            assignEquipmentFileStream.setDeviceTypeId(deviceType.getId());
            assignEquipmentFileStream.setAttributionId(deviceType.getAttributionId());
            assignEquipmentFileStream.setAttributionType(deviceType.getAttributionType().toString());
            PermissionStreamNew permissionStreamNew=permissionService.getPermissionStreams(assignEquipmentFileStream);
            if(permissionStreamNew==null){
                return Result.error("用户无权操作此任务");
            }
        }
        DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId());
        if(productDocInfo==null){
            return Result.error("未发现该产品结构树对应文档");
        }
        //获取产品文档信息对应最新程序加工确认表
        List<GuideCardBatch> batches = iGuideCardBatchService.list(
                new QueryWrapper<GuideCardBatch>()
                        .eq("doc_id", productDocInfo.getDocId())
                        .eq("flow_status", GuideCardBatchEnum.COMPLETE.getCode())
                        .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)"));
        if(CollectionUtils.isEmpty(batches)){
            return Result.error("该文档对应的程序加工确认表审批未通过,不能进行升版");
        }
        this.save(assignEquipmentFileStream);
        System.out.println("设备结构树指派产品结构树:" + assignEquipmentFileStream.getId());
        flowCommonService.initActBusiness("设备结构树指派产品结构树:"+docInfo.getDocName()+"->"+productDocInfo.getDocName(),
                assignEquipmentFileStream.getId(), "IAssignEquipmentFileStreamService", "nc_assign_equipment_file_stream", null);
        Map<String, Object> variables = new HashMap<>();
        variables.put("dataId", assignEquipmentFileStream.getId());
        variables.put("organization", assignEquipmentFileStream.getApplyReason());
        variables.put("comment", assignEquipmentFileStream.getApplyReason());
        variables.put("proofreading",true);
        Result result= flowDefinitionService.startProcessInstanceByKey("nc_assign_equipment_file_stream", variables);
        if (!result.isSuccess()) {
            super.removeById(assignEquipmentFileStream.getId());
        }
        return result;
    }
    /**
     * æµç¨‹èŠ‚ç‚¹å®¡æ ¸
     * @param assignEquipmentFileStreamVo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        try {
            // å‚数校验
            if (!ValidateUtil.validateString(assignEquipmentFileStreamVo.getTaskId()) || !ValidateUtil.validateString(assignEquipmentFileStreamVo.getDataId())) {
                return Result.error(CommonCode.INVALID_PARAM.toString());
            }
            String userId = user.getId();
            assignEquipmentFileStreamVo.setAssignee(user.getUsername());
            if (!ValidateUtil.validateString(userId)) {
                return Result.error(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST.toString());
            }
            // æ•°æ®æŸ¥è¯¢
            AssignEquipmentFileStream assignEquipmentFileStream = this.getById(assignEquipmentFileStreamVo.getDataId());
            if (assignEquipmentFileStream == null) {
                return Result.error(CommonCode.INVALID_PARAM.toString());
            }
            //获取设备
            MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId());
            if(equipment==null){
                return Result.error("未发现该设备");
            }
            //获取设备文档信息
            DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId());
            if(docInfo==null){
                return Result.error("未发现该设备对应文档");
            }
            //获取设备文件信息
            DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId());
            if(docFile==null){
                return Result.error("未发现该设备对应文件");
            }
            //获取产品文档信息
            DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId());
            DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId());
            if(productDocInfo==null){
                return Result.error("未发现该产品结构树对应文档");
            }
            //获取设备
            MdcEquipment mdcEquipment =mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId());
            if (mdcEquipment==null){
                return Result.error("未发现该设备");
            }
            // 2. æŸ¥è¯¢æµç¨‹ä¸šåŠ¡è®°å½•ï¼ˆå¤„ç†ç©ºç»“æžœï¼‰
            List<FlowMyBusiness> businessList = flowMyBusinessService.list(
                    new QueryWrapper<FlowMyBusiness>()
                            .eq("process_instance_id", assignEquipmentFileStreamVo.getInstanceId())
            );
            if (businessList.isEmpty()) {
                return Result.error("流程记录不存在");
            }
            FlowMyBusiness flowMyBusiness = businessList.get(0);
            // 3. æ ¡éªŒç”¨æˆ·æ˜¯å¦ä¸ºå€™é€‰å¤„理人
            List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class);
            if (todoUsers == null || !todoUsers.contains(user.getUsername())) {
                return Result.error("用户无权操作此任务");
            }
            // 4. è®¤é¢†ä»»åŠ¡ï¼ˆå¤„ç†å·²è¢«è®¤é¢†çš„æƒ…å†µï¼‰
            String taskId = flowMyBusiness.getTaskId();
            Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
            if (task == null) {
                return Result.error("任务不存在或已完成");
            }
            if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) {
                return Result.error("任务已被他人认领");
            }
            taskService.claim(taskId, user.getUsername());
            // è®¾ç½®æµç¨‹å˜é‡
            Map<String, Object> values = new HashMap<>();
            values.put("dataId", assignEquipmentFileStream.getId());
            values.put("assignee", userId);
            values.put("comment", assignEquipmentFileStreamVo.getComment());
            values.put("organization", assignEquipmentFileStreamVo.getComment());
            assignEquipmentFileStreamVo.setValues(values);
            // å®Œæˆæµç¨‹ä»»åŠ¡
            Result result = flowTaskService.complete(assignEquipmentFileStreamVo);
            if (result.isSuccess()) {
                this.updateById(assignEquipmentFileStream);
                if (assignEquipmentFileStreamVo.getAuditType().equals("1")) {
                    //1.产品结构树nc文件进行升版
                    DocFile productDocFile = new DocFile();
                    productDocFile.setDocId(productDocInfo.getDocId());
                    productDocFile.setFileName(docFile.getFileName());
                    productDocFile.setFileEncodeName(docFile.getFileEncodeName());
                    productDocFile.setFilePath(docFile.getFilePath());
                    productDocFile.setFileSize(docFile.getFileSize());
                    productDocFile.setFileSuffix(docFile.getFileSuffix());
                    docFileService.addDocFile(productDocFile);
                    productDocInfo.setPublishVersion(productDocFile.getDocVersion());
                    productDocInfo.setPublishFileId(productDocFile.getFileId());
                    docInfoService.updateById(productDocInfo);
                }
            } else {
                return result;
            }
            return Result.OK("操作成功");
        }  catch (Exception e) {
            try {
                TransactionStatus transactionStatus = TransactionAspectSupport.currentTransactionStatus();
                if (!transactionStatus.isCompleted()) {
                    transactionStatus.setRollbackOnly();
                }
            } catch (NoTransactionException ex) {
                // å¿½ç•¥æ— äº‹åŠ¡çš„å¼‚å¸¸
            }
            log.error("审核失败", e);
            return Result.error("操作失败:" + e.getMessage());
        }
    }
    //传参验证
    public boolean checkParam(AssignEquipmentFileStream assignEquipmentFileStream) {
        if (assignEquipmentFileStream == null) {
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        }
        if (!ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getDocId())
                || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentFileId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentDocId())) {
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        }
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if (!ValidateUtil.validateString(userId)) {
            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
        }
        return true;
    }
    @Override
    public void afterFlowHandle(FlowMyBusiness business) {
        business.getTaskNameId();//接下来审批的节点
        business.getValues();//前端传进来的参数
        business.getActStatus();
    }
    @Override
    public Object getBusinessDataById(String dataId) {
        return this.getById(dataId);
    }
    @Override
    public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) {
        return null;
    }
    @Override
    public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
        //业务是否干预流程,业务干预,流程干预,指定人员进行处理
        return null;
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java
@@ -13,16 +13,21 @@
import org.flowable.task.api.Task;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.entity.DocInfo;
import org.jeecg.modules.dnc.entity.PermissionStreamNew;
import org.jeecg.modules.dnc.constant.DncPassLogPassType;
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
import org.jeecg.modules.dnc.dto.TransferPackage;
import org.jeecg.modules.dnc.entity.*;
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.mapper.DocInfoMapper;
import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
import org.jeecg.modules.dnc.response.ActivitiCode;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.UcenterCode;
import org.jeecg.modules.dnc.service.IDocInfoService;
import org.jeecg.modules.dnc.service.*;
import org.jeecg.modules.dnc.service.impl.FileFerryService;
import org.jeecg.modules.dnc.utils.ValidateUtil;
import org.jeecg.modules.dnc.utils.date.DateUtil;
import org.jeecg.modules.dnc.utils.file.FileUtilS;
import org.jeecg.modules.dncFlow.entity.DispatchFile;
import org.jeecg.modules.dncFlow.mapper.DispatchFileMapper;
import org.jeecg.modules.dncFlow.service.IDispatchFileService;
@@ -35,14 +40,23 @@
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.flowable.service.IHisWorkTaskService;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
/**
@@ -68,13 +82,29 @@
    @Autowired
    private IFlowMyBusinessService flowMyBusinessService;
    @Autowired
    private DocInfoMapper docInfoMapper;
    @Autowired
    private ISysUserRoleService sysUserRoleService;
    @Autowired
    private PermissionService permissionService;
    @Autowired
    private IHisWorkTaskService hisWorkTaskService;
    @Autowired
    private IDeviceTypeService deviceTypeService;
    @Autowired
    private IDeviceManagementService deviceManagementService;
    @Autowired
    private IDncPassLogService dncPassLogService;
    @Autowired
    private IDocFileService docFileService;
    @Autowired
    private IDocRelativeService docRelativeService;
    @Autowired
    @Lazy
    private FileFerryService ferryService;
    @Value("${deploy.secretFolder}")
    private String secretFolder;    //工控网传输nc文件夹
    @Value("${fileHomePath}")
    private String fileHomePath;
    /**
     * æµç¨‹å¯åЍ,保存对应的数据
     * @param dispatchFile
@@ -380,9 +410,13 @@
    @Override
    public Result<?> submitProccess(DispatchFile dispatchFile) {
        checkParam(dispatchFile);
        super.save(dispatchFile);
        //获取文件信息
        DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId());
        PermissionStreamNew permissionStreams = getPermissionStreams(dispatchFile);
        if (permissionStreams==null){
            return Result.error("用户没有权限");
        }
        super.save(dispatchFile);
        flowCommonService.initActBusiness(docInfo.getDocName()+"."+docInfo.getDocSuffix()+"文件进行定型",
                dispatchFile.getId(), "IDispatchFileService", "process_rf27duhy", null);
        Map<String, Object> variables = new HashMap<>();
@@ -417,7 +451,7 @@
        return values;
    }
    private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) {
    private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) throws IOException {
        if (StrUtil.isNotBlank(dispatchFileFlowTaskVo.getProofreadStatus())) {
            switch (dispatchFileFlowTaskVo.getProofreadStatus()) {
                case "1":
@@ -448,9 +482,95 @@
        if (dispatchFileFlowTaskVo.getStereotype() != null && dispatchFileFlowTaskVo.getStereotype()) {
            dispatchFile.setCurrentNode("5");
            docInfo.setDocDispatchStatus(5);
            //定型通过
            DeviceType deviceType=deviceTypeService.getById(dispatchFile.getDeviceTypeId());
            DeviceManagement deviceManagement=deviceManagementService.getById(deviceType.getDeviceManagementId());
            DocFile docFile=docFileService.getById(dispatchFile.getFileId());
            DocRelative docRelative=docRelativeService.getOne(new QueryWrapper<DocRelative>().eq("doc_id",docInfo.getDocId())
                    .eq("attribution_id",dispatchFile.getAttributionId()).eq("attribution_type",dispatchFile.getAttributionType()));
            handleFileProcessing(docFile,deviceManagement,secretFolder);
            handleProductTree(docInfo,docRelative,deviceManagement);
        }
    }
    //封装处理文件
    private void handleFileProcessing(DocFile docFile, DeviceManagement deviceManagement, String secretFolder) throws IOException {
        if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) {
            DncPassLog passInfoTxt = new DncPassLog();
            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(DncPassLogPassType.NCFILE.getCode());
            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);
            // 4. æ‰§è¡Œæ–‡ä»¶æ“ä½œ,后缀为NC
            Path source = Paths.get(fileHomePath+docFile.getFilePath(), docFile.getFileEncodeName());
            String destFileName = "10A" + DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc + "_" + deviceManagement.getDeviceManagementCode()+".NC";
            Path destination = Paths.get(secretFolder, destFileName);
            Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
        }
    }
    /**
     * å¤„理对应产品结构树、nc文件、刀具列表、程序加工确认表封装
     * @param docInfo
     */
    private void handleProductTree(DocInfo docInfo, DocRelative docRelative, DeviceManagement deviceManagement) {
        /*查询最后一条记录*/
        //休眠 500毫秒
        DncPassLog passInfoTxt = new DncPassLog();
        Date dateFirst = DateUtil.getNow();
        passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
        DncPassLog dncPassLog  = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
        int fileTxt = 0, fileNc =0;
        if (dncPassLog !=null) {
            fileTxt = dncPassLog.getSequenceNumber() + 1;
        } else {
            fileTxt =  1;
        }
        String sequence = String.format("%06d",fileTxt);
        passInfoTxt.setSequenceNumber(fileTxt);
        passInfoTxt.setCreateTime(dateFirst);
        passInfoTxt.setSequenceOrder(sequence);
        System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME));
        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+"_"+deviceManagement.getDeviceManagementCode()+".ferry");
            System.out.println("工序数据已导出: " + filePath);
        }else {
            //工步对应设备类
            String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry");
            System.out.println("工步数据已导出: " + filePath);
        }
    }
    //传参验证
    public boolean checkParam(DispatchFile dispatchFile) {
        if (dispatchFile == null) {
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java
@@ -7,8 +7,10 @@
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.response.ActivitiCode;
import org.jeecg.modules.dnc.service.IDeviceTypeService;
import org.jeecg.modules.dncFlow.adapter.AssignEquipmentFileStreamAdapter;
import org.jeecg.modules.dncFlow.adapter.AssignFileStreamAdapter;
import org.jeecg.modules.dncFlow.adapter.DispatchFileAdapter;
import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream;
import org.jeecg.modules.dncFlow.entity.AssignFileStream;
import org.jeecg.modules.dncFlow.entity.DispatchFile;
import org.jeecg.modules.dncFlow.handler.*;
@@ -51,6 +53,10 @@
        return processInternal(new AssignFileStreamAdapter(stream), stream.getAttributionType());
    }
    public PermissionStreamNew getPermissionStreams(AssignEquipmentFileStream stream) {
        return processInternal(new AssignEquipmentFileStreamAdapter(stream), stream.getAttributionType());
    }
    private PermissionStreamNew processInternal(StreamTarget target, String attributionType) {
        LoginUser user = getCurrentUser();
        String resolvedId = resolveAttributionId(target.getAttributionId());
lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package org.jeecg.modules.dncFlow.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.modules.flowable.domain.vo.FlowTaskVo;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
 * @Description: DNC-设备结构树指派产品结构树
 * @Author: jeecg-boot
 * @Date:   2025-06-17
 * @Version: V1.0
 */
@Data
@ApiModel(value="设备结构树指派产品结构树--请求参数")
public class AssignEquipmentFileStreamVo extends FlowTaskVo {
    /**
     * taskIds
     */
    private String taskIds;
    /**审核类型*/
    @Excel(name = "审核类型", width = 15)
    @ApiModelProperty(value = "审核类型")
    private String auditType;
}