管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-11 30272471be13ecb9a1a711a5c037fe27127c9056
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;
    }
}