管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-30 adcaf3e378b90c8173958233ca6fa1f162a7b71d
1
已修改3个文件
48 ■■■■ 文件已修改
src/main/java/com/lf/server/helper/GdbHelper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/Zip4jHelper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/DataLibService.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/GdbHelper.java
@@ -440,7 +440,7 @@
        SpatialReference sr = new SpatialReference();
        sr.ImportFromEPSG(null == srid ? 4490 : srid);
        return dataSource.CreateLayer(tab, sr, getGeomType(geomType), null);
        return dataSource.CreateLayer(tab.replace(".", "_"), sr, getGeomType(geomType), null);
    }
    /**
src/main/java/com/lf/server/helper/Zip4jHelper.java
@@ -11,6 +11,7 @@
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
@@ -64,6 +65,7 @@
    public static ZipFile createZipFile(String zipFile, String pwd) {
        try {
            ZipFile zip = StringHelper.isEmpty(pwd) ? new ZipFile(zipFile) : new ZipFile(zipFile, pwd.toCharArray());
            // zip.setCharset(Charset.forName("GBK"))
            zip.setCharset(StandardCharsets.UTF_8);
            File f = zip.getFile();
src/main/java/com/lf/server/service/show/DataLibService.java
@@ -20,6 +20,7 @@
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.util.*;
/**
@@ -152,7 +153,6 @@
        String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
        String tempPath = pathHelper.getTempPath(tempName);
        String gdbPath = tempPath + File.separator + "tabs.gdb";
        String annexPath = tempPath + File.separator + "annex";
        File gdbFile = new File(gdbPath);
        if (gdbFile.exists() && gdbFile.isDirectory()) {
@@ -160,17 +160,12 @@
        }
        GdbHelper.createGdb(gdbPath, dataMap);
        File annexFile = new File(annexPath);
        if (!annexFile.exists() || !annexFile.isDirectory()) {
            annexFile.mkdirs();
        }
        createAnnex(annexPath, annexMap);
        String zipFile = pathHelper.getDownloadFullPath() + File.separator + tempName + ".gdb.zip";
        ZipFile zip = Zip4jHelper.createZipFile(zipFile, dr.getPwd());
        ZipParameters params = Zip4jHelper.getZipParams(true);
        zip.addFolder(new File(gdbPath), params);
        zip.addFolder(new File(annexPath), params);
        // zip.addFolder(new File(annexPath), params)
        addAnnex(zip, params, annexMap);
        String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd()));
        DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, dbPwd);
@@ -215,9 +210,9 @@
                }
                if (!annexMap.containsKey(entity)) {
                    annexMap.put(entity, annex);
                    annexMap.put(tab.replace(".", "_"), annex);
                } else {
                    annexMap.get(entity).addAll(annex);
                    annexMap.get(tab.replace(".", "_")).addAll(annex);
                }
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
@@ -256,7 +251,7 @@
    }
    /**
     * 创建附件
     * 创建附件 *
     */
    private void createAnnex(String annexPath, Map<String, List<AttachEntity>> annexMap) {
        if (annexMap.size() == 0) {
@@ -292,6 +287,33 @@
    }
    /**
     * 添加附件
     */
    private 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(key + File.separator + ae.getName());
                    zip.addStream(new FileInputStream(srcFile), params);
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }
            }
        }
    }
    /**
     * 获取下载实体类
     */
    private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) {