管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-11 d43fe8e4c939edf7810681aad17fa1deeef1b0b6
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;
@@ -11,7 +10,7 @@
import com.lf.server.mapper.all.GeomBaseMapper;
import com.lf.server.mapper.data.DownloadMapper;
import com.lf.server.service.all.BaseQueryService;
import com.lf.server.service.data.DownloadService;
import com.lf.server.service.data.MetaService;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.model.ZipParameters;
import org.apache.commons.logging.Log;
@@ -32,10 +31,10 @@
    PathHelper pathHelper;
    @Autowired
    DownloadMapper downloadMapper;
    MetaService metaService;
    @Autowired
    DownloadService downloadService;
    DownloadMapper downloadMapper;
    @Autowired
    BaseQueryService baseQueryService;
@@ -152,7 +151,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,23 +158,18 @@
        }
        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)
        metaService.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;
    }
    /**
@@ -191,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 ("bborehole".equals(entity)) {
                    continue;
                }
                if (wrapper.isEmptyOfWhere()) {
                    wrapper.apply("1 = 1");
                }
                String tab = BaseQueryService.getTabName(baseMapper);
                List<AttachEntity> annex = baseMapper.selectAnnex(tab, wrapper);
                if (null == annex || annex.isEmpty()) {
                    continue;
                }
                if (!annexMap.containsKey(entity)) {
                    annexMap.put(entity, annex);
                } else {
                    annexMap.get(entity).addAll(annex);
                }
                metaService.addData(entity, baseMapper, wrapper, dataMap, annexMap);
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
            }
@@ -256,7 +222,7 @@
    }
    /**
     * 创建附件
     * 创建附件 *
     */
    private void createAnnex(String annexPath, Map<String, List<AttachEntity>> annexMap) {
        if (annexMap.size() == 0) {