管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-03 05b7f36c1fdb1dae4fd2131f63e10f72f85ee42c
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.*;
/**
@@ -130,7 +128,7 @@
        }
        for (String id : ids) {
            if (StringHelper.isEmpty(id)) {
            if (StringHelper.isEmpty(id) || "00".equals(id)) {
                continue;
            }
            if (!rs.contains(id)) {
@@ -165,13 +163,13 @@
        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 downloadEntity = getDownloadEntity(ue, zipFile, dbPwd);
        int rows = downloadMapper.insert(downloadEntity);
        DownloadEntity de = getDownloadEntity(ue, zipFile, dbPwd);
        int rows = downloadMapper.insert(de);
        return rows > 0 ? downloadEntity.getGuid() : null;
        return rows > 0 ? de.getGuid() : null;
    }
    /**
@@ -186,34 +184,7 @@
                }
                QueryWrapper wrapper = createQueryWrapper(baseMapper, dr);
                List list = baseMapper.selectList(wrapper);
                if (null == list || list.size() == 0) {
                    continue;
                }
                if (!dataMap.containsKey(entity)) {
                    dataMap.put(entity, list);
                } else {
                    dataMap.get(entity).addAll(list);
                }
                if (wrapper.isEmptyOfWhere()) {
                    wrapper.apply("1 = 1");
                }
                if ("bborehole".equals(entity)) {
                    wrapper.last("limit 100");
                }
                String tab = BaseQueryService.getTabName(baseMapper);
                List<AttachEntity> annex = baseMapper.selectAnnex(tab, wrapper);
                if (null == annex || annex.isEmpty()) {
                    continue;
                }
                if (!annexMap.containsKey(entity)) {
                    annexMap.put(tab.replace(".", "_"), annex);
                } else {
                    annexMap.get(tab.replace(".", "_")).addAll(annex);
                }
                downloadService.addData(entity, baseMapper, wrapper, dataMap, annexMap);
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
            }
@@ -279,33 +250,6 @@
                    }
                    FileHelper.copyFile(srcFile, destFile);
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }
            }
        }
    }
    /**
     * 添加附件
     */
    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("annex" + File.separator + key + File.separator + ae.getName());
                    zip.addStream(new FileInputStream(srcFile), params);
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }