管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-11 30272471be13ecb9a1a711a5c037fe27127c9056
1
已修改4个文件
54 ■■■■ 文件已修改
data/db_tab.sql 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/ReportController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/all/StaticData.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/ReportService.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_tab.sql
@@ -770,7 +770,7 @@
comment on table lf.sys_download is '下载记录表';
comment on column lf.sys_download.id is '主键ID';
comment on column lf.sys_download.name is '名称';
comment on column lf.sys_download.type is '类型:1-Shp文件,2-专题图,3-元数据,4-业务数据,5-管道分析';
comment on column lf.sys_download.type is '类型:1-Shp文件,2-专题图,3-元数据,4-业务数据,5-管道分析,6-统计报告';
comment on column lf.sys_download.depid is '单位ID';
comment on column lf.sys_download.sizes is '文件大小:单位MB';
comment on column lf.sys_download.dcount is '下载次数';
src/main/java/com/lf/server/controller/sys/ReportController.java
@@ -185,10 +185,10 @@
    @SysLog()
    @ApiOperation(value = "下载报告")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body")
            @ApiImplicitParam(name = "id", value = "报告ID", dataType = "Integer", paramType = "7")
    })
    @GetMapping(value = "/downloadReport")
    public void downloadReport(Integer id, HttpServletResponse res) {
    public void downloadReport(Integer id, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == id || id < 1) {
                return;
@@ -199,7 +199,9 @@
                return;
            }
            reportService.createReport(re, res);
            UserEntity ue = tokenService.getCurrentUser(req);
            reportService.createReport(ue, re, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
src/main/java/com/lf/server/entity/all/StaticData.java
@@ -55,6 +55,11 @@
    public static final double D1050 = 1050.0;
    /**
     * 字符1
     */
    public final static String S1 = "1";
    /**
     * 等号
     */
    public final static String EQ = "=";
src/main/java/com/lf/server/service/sys/ReportService.java
@@ -1,10 +1,14 @@
package com.lf.server.service.sys;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.ctrl.CountEntity;
import com.lf.server.entity.data.DownloadEntity;
import com.lf.server.entity.sys.AttachEntity;
import com.lf.server.entity.sys.ReportEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.*;
import com.lf.server.mapper.sys.ReportMapper;
import com.lf.server.service.data.DownloadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -28,6 +32,9 @@
    @Autowired
    PathHelper pathHelper;
    @Autowired
    DownloadService downloadService;
    @Override
    public Integer selectCount(String name) {
@@ -101,7 +108,7 @@
    /**
     * 创建报告
     */
    public void createReport(ReportEntity re, HttpServletResponse res) throws Exception {
    public void createReport(UserEntity ue, ReportEntity re, HttpServletResponse res) throws Exception {
        AttachEntity ae = attachService.selectByGuid(re.getGuid());
        if (null == ae) {
            return;
@@ -109,7 +116,7 @@
        String source = pathHelper.getConfig().getUploadPath() + File.separator + ae.getPath();
        String targetName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + FileHelper.getExtension(ae.getName());
        String target = pathHelper.getShareFullPath() + File.separator + targetName;
        String target = pathHelper.getDownloadFullPath() + File.separator + targetName;
        File sourceFile = new File(source);
        if (!sourceFile.exists() || sourceFile.isDirectory()) {
@@ -122,14 +129,18 @@
            return;
        }
        WebHelper.download(target, targetName, res);
        DownloadEntity de = getDownloadEntity(ue, target);
        int rows = downloadService.insert(de);
        if (rows > 0) {
            WebHelper.download(target, targetName, res);
        }
    }
    /**
     * 生成报告
     */
    private void generateReport(String source, String target, ReportEntity re) {
        if ("1".equals(re.getType())) {
        if (StaticData.S1.equals(re.getType())) {
            switch (re.getCode()) {
                case "countOperates ":
                    createCountOperatesWord(source, target);
@@ -202,4 +213,24 @@
        WordHelper.generateWord(source, target, null, addList);
    }
    /**
     * 获取下载实体类
     */
    private DownloadEntity getDownloadEntity(UserEntity ue, String file) {
        DownloadEntity de = new DownloadEntity();
        de.setName(FileHelper.getFileName(file));
        de.setType(6);
        de.setSizes(FileHelper.sizeToMb(new File(file).length()));
        de.setDepid(ue.getDepid());
        de.setDcount(1);
        de.setPwd(null);
        de.setUrl(FileHelper.getRelativePath(file));
        de.setDescr("统计报告");
        de.setGuid(FileHelper.getFileMd5(file));
        de.setCreateUser(ue.getId());
        // de.setGeom(null)
        return de;
    }
}