燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-08-10 4d1ced71426f31008ce4e4dd47cbed314f330cea
1
已修改2个文件
31 ■■■■ 文件已修改
src/main/java/com/yssh/mapper/XlsReportMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/XlsReportService.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/mapper/XlsReportMapper.java
@@ -22,7 +22,7 @@
    /**
     * 报告是否存在
     */
    int reportExists(@Param("type") String type, @Param("start") String start);
    int reportExists(@Param("type") String type, @Param("name") String name);
    /**
     * 插入报告
src/main/java/com/yssh/service/XlsReportService.java
@@ -5,6 +5,7 @@
import com.yssh.entity.xls.DayExcel;
import com.yssh.entity.xls.MonthExcel;
import com.yssh.entity.xls.WeekExcel;
import com.yssh.entity.xls.XlsReport;
import com.yssh.mapper.XlsReportMapper;
import com.yssh.utils.CalculateUtils;
import com.yssh.utils.DateUtils;
@@ -103,9 +104,32 @@
        String strData = DateUtils.parseDateToStr("month".equals(type) ? DateUtils.YYYYMM : DateUtils.YYYYMMDD, date);
        String target = String.format("%s\\%s.xlsx", getExpPath(type), strData);
        createExcel(source, target, list);
        File f = new File(target);
        if (!f.exists() || f.isDirectory()) {
            createExcel(source, target, list);
        }
        return String.format("%s\\%s.xlsx", type, strData);
    }
    /**
     * 保存结果
     */
    private <T> void saveResult(String type, Date date, List<T> list) throws Exception {
        date = DateUtils.trimTime(date);
        String filePath = createExcel(type, date, list);
        String name = filePath.replace(type + "\\", "");
        int rows = mapper.reportExists(type, name);
        if (rows > 0) return;
        XlsReport xls = new XlsReport();
        xls.setName(name);
        xls.setType(type);
        xls.setPath(filePath);
        xls.setCreateTime(date);
        mapper.insertReport(xls);
    }
    /**
@@ -158,8 +182,7 @@
                list.add(new DayExcel("" + rjz, "" + lj, ljtb + "%", ys, "", "", ""));
            }
            String filePath = createExcel("day", yesterday, list);
            saveResult("day", yesterday, list);
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }