管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-31 5fe2473ba0e9f374da27e919fdce09b0915f5e51
1
已修改6个文件
137 ■■■■ 文件已修改
src/main/java/com/lf/server/config/PropertiesConfig.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/FileHelper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/PathHelper.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/MarkService.java 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
说明.txt 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/config/PropertiesConfig.java
@@ -9,8 +9,8 @@
 */
@Configuration
public class PropertiesConfig {
    @Value("${sys.path.import}")
    private String importPath;
    @Value("${sys.path.download}")
    private String downloadPath;
    @Value("${sys.path.export}")
    private String exportPath;
@@ -46,12 +46,12 @@
        this.druidPwd = druidPwd;
    }
    public String getImportPath() {
        return importPath;
    public String getDownloadPath() {
        return downloadPath;
    }
    public void setImportPath(String importPath) {
        this.importPath = importPath;
    public void setDownloadPath(String downloadPath) {
        this.downloadPath = downloadPath;
    }
    public String getExportPath() {
src/main/java/com/lf/server/helper/FileHelper.java
@@ -26,6 +26,20 @@
    private final static Log log = LogFactory.getLog(FileHelper.class);
    /**
     * èŽ·å–æ–‡ä»¶å
     * @param file
     * @return
     */
    public static String getFileName(String file) {
        int idx = file.lastIndexOf(File.separator);
        if (idx > -1) {
            return file.substring(idx + 1);
        }
        return "";
    }
    /**
     * èŽ·å–æ–‡ä»¶æ‰©å±•å
     */
    public static String getExtension(File file) {
src/main/java/com/lf/server/helper/PathHelper.java
@@ -19,7 +19,7 @@
    @Autowired
    private PropertiesConfig config;
    private static int importPath = 1;
    private static int downloadPath = 1;
    private static int exportPath = 1;
@@ -35,8 +35,8 @@
        return config;
    }
    public static int getImportPath() {
        return importPath;
    public static int getDownloadPath() {
        return downloadPath;
    }
    public static int getExportPath() {
@@ -55,7 +55,7 @@
     * åˆå§‹åŒ–
     */
    public void init() {
        importPath = getSubPath(config.getImportPath(), importPath);
        downloadPath = getSubPath(config.getDownloadPath(), downloadPath);
        exportPath = getSubPath(config.getExportPath(), exportPath);
        uploadPath = getSubPath(config.getUploadPath(), uploadPath);
        sharePath = getSubPath(config.getSharePath(), sharePath);
@@ -84,9 +84,9 @@
     * èŽ·å–å¯¼å…¥ç›®å½•
     */
    public String getImportFullPath() {
        importPath = getSubPath(config.getImportPath(), importPath);
        downloadPath = getSubPath(config.getDownloadPath(), downloadPath);
        return config.getImportPath() + File.separator + importPath;
        return config.getDownloadPath() + File.separator + downloadPath;
    }
    /**
src/main/java/com/lf/server/service/show/MarkService.java
@@ -1,12 +1,10 @@
package com.lf.server.service.show;
import com.lf.server.entity.all.HttpStatus;
import com.lf.server.entity.ctrl.MarkJsonEntity;
import com.lf.server.entity.show.MarkEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.GdalHelper;
import com.lf.server.helper.PathHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
import com.lf.server.helper.*;
import com.lf.server.mapper.show.MarkMapper;
import com.lf.server.service.data.UploaderService;
import org.apache.commons.logging.Log;
@@ -15,9 +13,12 @@
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -84,8 +85,9 @@
        return markMapper.updates(list);
    }
    public void downloadShp(UserEntity ue, List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) {
        String path = getShpDir(ue);
    public void downloadShp(UserEntity ue, List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) throws Exception {
        String parent = pathHelper.getTempPath(ue.getId());
        String path = getShpDir(ue, parent);
        List<MarkJsonEntity> points = getMarkByType(list, "POINT");
        if (points.size() > 0) {
@@ -100,11 +102,19 @@
            String polygonFile = GdalHelper.createShp(polygons, path, "POLYGON");
        }
        //
        File[] files = new File(path).listFiles();
        if (files == null || files.length == 0) {
            WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.BAD_REQUEST, "Shp文件生成失败"));
            return;
        }
        String zip = getZip(parent);
        ZipHelper.zip(zip, parent);
        download(res, zip);
    }
    private String getShpDir(UserEntity ue) {
        String path = pathHelper.getTempPath(ue.getId()) + File.separator + WebHelper.getRandomInt(100000, 1000000);
    private String getShpDir(UserEntity ue, String parent) {
        String path = parent + File.separator + WebHelper.getRandomInt(100000, 1000000);
        File file = new File(path);
        if (!file.exists() && !file.isDirectory()) {
@@ -127,4 +137,46 @@
        return rs;
    }
    private String getZip(String parent) {
        String path = parent + File.separator + WebHelper.getRandomInt(100000, 1000000) + ".zip";
        File file = new File(path);
        if (file.exists() && !file.isDirectory()) {
            file.delete();
        }
        return path;
    }
    private void download(HttpServletResponse res, String file) throws Exception {
        String fileName = URLEncoder.encode(FileHelper.getFileName(file), "UTF-8");
        // è®¾ç½®å“åº”头中文件的下载方式为附件方式,以及设置文件名
        res.setHeader("Content-Disposition", "attachment; filename=" + fileName);
        // è®¾ç½®å“åº”头的编码格式为UTF-8
        res.setCharacterEncoding("UTF-8");
        // é€šè¿‡response对象设置响应数据格式(如:"text/plain; charset=utf-8")
        String ext = FileHelper.getExtension(file);
        String mime = FileHelper.getMime(ext);
        res.setContentType(mime);
        // é€šè¿‡response对象,获取到输出流
        ServletOutputStream outputStream = res.getOutputStream();
        // å®šä¹‰è¾“入流,通过输入流读取文件内容
        FileInputStream fileInputStream = new FileInputStream(file);
        int len = 0;
        byte[] bytes = new byte[1024];
        while ((len = fileInputStream.read(bytes)) != -1) {
            // é€šè¿‡è¾“入流读取文件数据,然后通过上述的输出流写回浏览器
            outputStream.write(bytes, 0, len);
            outputStream.flush();
        }
        // å…³é—­èµ„源
        outputStream.close();
        fileInputStream.close();
    }
}
src/main/resources/application.yml
@@ -140,13 +140,13 @@
# ç³»ç»Ÿé…ç½®
sys:
  path:
    # å¯¼å…¥ç›®å½•
    import: D:\LF\import
    # å‡ºå›¾ç›®å½•
    # ä¸‹è½½ç›®å½•(下载文件)
    download: D:\LF\download
    # å‡ºå›¾ç›®å½•(专题图出图)
    export: D:\LF\export
    # ä¸Šä¼ ç›®å½•
    # ä¸Šä¼ ç›®å½•(大数据上传)
    upload: D:\LF\upload
    # å…±äº«ç›®å½•
    # å…±äº«ç›®å½•(数据发布)
    share: D:\LF\share
    # ä¸´æ—¶ç›®å½•
    # ä¸´æ—¶ç›®å½•(临时上传文件)
    temp: D:\LF\temp
˵Ã÷.txt
@@ -24,19 +24,24 @@
23.修改钻孔数据下载工具,更新新增字段的属性
24.身份认证拦截器添加黑白名单检查功能
25.开发自动生成Mybtis Plus代码小工具
26.批量生成基础数据表的实体类和Mapperç±» <
27.
28.
26.批量生成基础数据表的实体类和Mapper类
27.修改所有的批量新增、删除、修改接口
28.开发大文件上传接口(commons-fileupload) <
29.
30.
-----------------------------------------------
.添加批量修改用户密码接口
.修改所有的批量新增、删除、修改接口
.开发大文件上传接口(commons-fileupload)
.修改用户密码接口
.GDAL读取shp后删除上传文件
.对用户、菜单、角色、资源进行授权
.添加查询角色、菜单、资源权限接口
.开发根据实体名称动态查询表的记录数
.开发根据实体名称进行动态分页查询
.开发根据实体名称查询空间表的WKT记录
.开发根据实体名称+字段+值模糊搜索前10条记录
.开发根据名称模糊搜索用户、单位的前10条记录
.开发根据标绘JSON数据生成shp文件并下载
.开发上传shp文件转换为JSON数据接口
----------------------------------------------------------------------------------------------------
java è°ƒç”¨gdal读取gdb数据,linux下java调用gdal: