管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-12 4d8dd71b7d13fa41132c46831090c6282af502cb
src/main/java/com/lf/server/service/show/MarkService.java
@@ -2,6 +2,7 @@
import com.lf.server.entity.ctrl.MarkJsonEntity;
import com.lf.server.entity.data.DownloadEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.show.MarkEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.*;
@@ -14,6 +15,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@@ -121,15 +123,15 @@
        List<MarkJsonEntity> points = getMarkByType(list, "POINT");
        if (points.size() > 0) {
            String pointFile = GdalHelper.createShp(points, path, "POINT");
            String pointFile = ShpHelper.createShp(points, path, "POINT");
        }
        List<MarkJsonEntity> lines = getMarkByType(list, "LINESTRING");
        if (lines.size() > 0) {
            String lineFile = GdalHelper.createShp(lines, path, "LINESTRING");
            String lineFile = ShpHelper.createShp(lines, path, "LINESTRING");
        }
        List<MarkJsonEntity> polygons = getMarkByType(list, "POLYGON");
        if (polygons.size() > 0) {
            String polygonFile = GdalHelper.createShp(polygons, path, "POLYGON");
            String polygonFile = ShpHelper.createShp(polygons, path, "POLYGON");
        }
        return path;
@@ -161,7 +163,7 @@
    }
    private String getZip() {
        String path = pathHelper.getDownloadFullPath() + File.separator + WebHelper.getRandomInt(100000, 1000000) + ".zip";
        String path = pathHelper.getDownloadFullPath() + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip";
        File file = new File(path);
        if (file.exists() && !file.isDirectory()) {
@@ -179,7 +181,7 @@
        de.setDcount(0);
        // de.setPwd(null)
        de.setUrl(FileHelper.getRelativePath(file));
        de.setDescr("下载ShapeFile文件");
        de.setDescr("ShapeFile文件");
        de.setGuid(FileHelper.getFileMd5(file));
        de.setCreateUser(ue.getId());
        // de.setGeom(null)
@@ -196,4 +198,28 @@
    public String getDownloadFilePath(DownloadEntity de) {
        return pathHelper.getConfig().getDownloadPath() + File.separator + de.getUrl();
    }
    /**
     * 读取ShapeFile文件获取Mark实体类
     *
     * @param list ShapeFile文件列表
     * @return Mark实体类集合
     */
    public List<MarkJsonEntity> readShpForMarks(List<MetaFileEntity> list) {
        String fileName = null;
        for (MetaFileEntity mf : list) {
            if (mf.getName().toLowerCase().indexOf(".shp") > -1) {
                fileName = mf.getPath();
                break;
            }
        }
        if (StringHelper.isEmpty(fileName)) {
            return null;
        }
        List<MarkJsonEntity> mjeList = ShpHelper.readShpForMarks(fileName);
        FileHelper.deleteFiles(list);
        return mjeList;
    }
}