管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-04-22 cc816055746ae0ffa870734e5a411b2a2aabb96a
src/main/java/com/lf/server/service/show/MarkService.java
@@ -1,5 +1,6 @@
package com.lf.server.service.show;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.ctrl.MarkJsonEntity;
import com.lf.server.entity.data.DownloadEntity;
import com.lf.server.entity.data.MetaEntity;
@@ -89,23 +90,21 @@
     *
     * @param ue   用户实体
     * @param list 标绘JSON实体类集合
     * @param req  请求
     * @param res  响应
     * @return GUID
     * @throws Exception 异常
     */
    public String downloadShp(UserEntity ue, List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) throws Exception {
        String parent = pathHelper.getTempPath();
    public String downloadShp(UserEntity ue, List<MarkJsonEntity> list) throws Exception {
        String path = pathHelper.getTempPath();
        createShapeFiles(ue, list, path);
        String path = createShapeFiles(ue, list, parent);
        File[] files = new File(path).listFiles();
        if (files == null || files.length == 0) {
            return null;
        }
        String zip = getZipPath();
        ZipHelper.zip(zip, parent);
        FileHelper.deleteDir(parent);
        ZipHelper.zip(zip, path);
        FileHelper.deleteDir(path);
        String guid = FileHelper.getFileMd5(zip);
        DownloadEntity entity = downloadService.selectByGuid(guid);
@@ -122,9 +121,7 @@
    /**
     * 创建shp文件
     */
    private String createShapeFiles(UserEntity ue, List<MarkJsonEntity> list, String parent) {
        String path = getShpDir(ue, parent);
    private String createShapeFiles(UserEntity ue, List<MarkJsonEntity> list, String path) {
        List<MarkJsonEntity> points = getMarkByType(list, "POINT");
        if (points.size() > 0) {
            ShpHelper.createShp(points, path, "POINT");
@@ -145,7 +142,7 @@
     * 获取shp目录
     */
    private String getShpDir(UserEntity ue, String parent) {
        String path = parent + File.separator + WebHelper.getRandomInt(100000, 1000000);
        String path = parent + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date());
        File file = new File(path);
        if (!file.exists() && !file.isDirectory()) {
@@ -164,7 +161,7 @@
            if (StringHelper.isEmpty(mark.getWkt())) {
                continue;
            }
            if (mark.getWkt().indexOf(type) > -1) {
            if (mark.getWkt().contains(type)) {
                rs.add(mark);
            }
        }
@@ -192,13 +189,14 @@
    private DownloadEntity getDownloadEntity(UserEntity ue, String file) throws Exception {
        DownloadEntity de = new DownloadEntity();
        de.setName(FileHelper.getFileName(file));
        // 1-Shp文件,2-专题图,3-元数据,4-业务数据,5-管道分析,6-统计报告,7-附件文件,8-瓦片文件
        de.setType(1);
        de.setSizes(FileHelper.sizeToMb(new File(file).length()));
        de.setDepid(ue.getDepid());
        de.setDcount(0);
        // de.setPwd(null)
        de.setUrl(FileHelper.getRelativePath(file));
        de.setDescr("shp文件");
        de.setDescr("Shp文件");
        de.setGuid(FileHelper.getFileMd5(file));
        de.setCreateUser(ue.getId());
        // de.setGeom(null)
@@ -219,7 +217,7 @@
    public List<MarkJsonEntity> readShpForMarks(List<MetaFileEntity> list) {
        String fileName = null;
        for (MetaFileEntity mf : list) {
            if (mf.getName().toLowerCase().contains(".shp")) {
            if (mf.getName().toLowerCase().contains(StaticData.SHP)) {
                fileName = mf.getPath();
                break;
            }