管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-03 105fc752691e15d79715827dc58f22c9a2b87b96
src/main/java/com/lf/server/service/show/DataLibService.java
@@ -1,7 +1,6 @@
package com.lf.server.service.show;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lf.server.entity.all.BaseEntity;
import com.lf.server.entity.ctrl.DownloadReqEntity;
import com.lf.server.entity.data.DownloadEntity;
import com.lf.server.entity.sys.AttachEntity;
@@ -20,7 +19,6 @@
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.util.*;
/**
@@ -165,7 +163,7 @@
        ZipParameters params = Zip4jHelper.getZipParams(true);
        zip.addFolder(new File(gdbPath), params);
        // zip.addFolder(new File(annexPath), params)
        addAnnex(zip, params, annexMap);
        downloadService.addAnnex(zip, params, annexMap);
        String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd()));
        DownloadEntity de = getDownloadEntity(ue, zipFile, dbPwd);
@@ -279,33 +277,6 @@
                    }
                    FileHelper.copyFile(srcFile, destFile);
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }
            }
        }
    }
    /**
     * 添加附件
     */
    public void addAnnex(ZipFile zip, ZipParameters params, Map<String, List<AttachEntity>> annexMap) {
        List<String> files = new ArrayList<>();
        String uploadPath = pathHelper.getConfig().getUploadPath();
        for (String key : annexMap.keySet()) {
            for (AttachEntity ae : annexMap.get(key)) {
                try {
                    File srcFile = new File(uploadPath + File.separator + ae.getPath());
                    if (!srcFile.exists() || srcFile.isDirectory()) {
                        continue;
                    }
                    if (files.contains(srcFile.getPath())) {
                        continue;
                    }
                    files.add(srcFile.getPath());
                    params.setFileNameInZip("annex" + File.separator + key + File.separator + ae.getName());
                    zip.addStream(new FileInputStream(srcFile), params);
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }