燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-08-10 c7cc3d90df2a412063188e5cdf025de6cd5bfcd9
1
已修改2个文件
82 ■■■■■ 文件已修改
src/main/java/com/yssh/config/InitConfig.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/XlsReportService.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/config/InitConfig.java
@@ -19,7 +19,7 @@
@Component
public class InitConfig implements ApplicationRunner {
    //protected final Log logger = LogFactory.getLog(this.getClass());
    // protected final Log logger = LogFactory.getLog(this.getClass())
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
@@ -53,18 +53,25 @@
    private void test() {
        //task.corpReserveDataSync();
        //warningAnalyseService.warningOperationStorage(calendar.getTime());
        //warningAnalyseService.warningOperationStorage(cal.getTime());
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.MONTH, 6);
        cal.set(Calendar.DAY_OF_MONTH, 25);
        cal.set(Calendar.HOUR_OF_DAY, 14);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        /*Calendar cal1 = Calendar.getInstance();
        cal1.set(Calendar.MONTH, 6);
        cal1.set(Calendar.DAY_OF_MONTH, 25);
        cal1.set(Calendar.HOUR_OF_DAY, 14);
        cal1.set(Calendar.MINUTE, 0);
        cal1.set(Calendar.SECOND, 0);
        cal1.set(Calendar.MILLISECOND, 0);
        xlsReportService.createDayReport(cal1.getTime());*/
        xlsReportService.createDayReport(cal.getTime());
        // xlsReportService.createWeekReport();
        // xlsReportService.createMonthReport();
        Calendar cal2 = Calendar.getInstance();
        cal2.set(Calendar.MONTH, 6);
        cal2.set(Calendar.DAY_OF_MONTH, 31);
        xlsReportService.createWeekReport(cal2.getTime());
        /*Calendar cal3 = Calendar.getInstance();
        cal3.set(Calendar.MONTH, 7);
        cal3.set(Calendar.DAY_OF_MONTH, 1);
        xlsReportService.createMonthReport(cal3.getTime());*/
    }
}
src/main/java/com/yssh/service/XlsReportService.java
@@ -55,15 +55,6 @@
    private double bjz;
    /**
     * Excel是否已存在
     */
    private boolean xlsExists(String type, String name) {
        int rows = mapper.reportExists(type, name);
        return rows > 0;
    }
    /**
     * 获取导出路径
     */
    private String getExpPath(String type) {
@@ -172,10 +163,10 @@
            List<DayExcel> list = new ArrayList<>();
            for (int i = 1; i < 47; i++) {
                String name = "AI-" + (i < 10 ? "0" : "") + i;
                double rjz = mapper.selectDayAvg(yyyymmdd + "%", name);
                double lj = mapper.selectAccumulate(yearStart, end, name);
                double lastLj = mapper.selectYearAccumulate(lastYear + "%", name);
                double ljtb = CalculateUtils.round2((lj - lastLj) / lastLj * 100);
                double rjz = mapper.selectDayAvg(yyyymmdd + "%", name); // 日均值
                double lj = mapper.selectAccumulate(yearStart, end, name); // 累计
                double lastLj = mapper.selectYearAccumulate(lastYear + "%", name); // 去年累计
                double ljtb = CalculateUtils.round2((lj - lastLj) / lastLj * 100); // 累计同比
                MonitorPointPosition point = commonService.select3dCheckPointByName(name);
                String id = point.getId().substring(0, point.getId().lastIndexOf("_") + 1) + "0";
                // List<SuYuan700> suList = mapper.selectSuYuanByTime(id, yyyy_mm_dd + " 00:00:00", yyyy_mm_dd + " 23:00:00");
@@ -197,20 +188,45 @@
        try {
            Date mon = DateUtils.getAPeriodOfTime(date, -7, Calendar.DATE);
            Date sun = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE);
            Date lastMon = DateUtils.getAPeriodOfTime(date, -14, Calendar.DATE);
            Date lastSun = DateUtils.getAPeriodOfTime(date, -8, Calendar.DATE);
            Date lastYearMon = DateUtils.getAPeriodOfTime(mon, -1, Calendar.YEAR);
            Date lastYearSun = DateUtils.getAPeriodOfTime(sun, -1, Calendar.YEAR);
            Integer intMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, mon) + "00"); // 2023072400
            Integer intSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, sun) + "23"); // 2023073023
            Integer intLastMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastMon) + "00"); // 2023071700
            Integer intLastSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastSun) + "23"); // 2023072323
            Integer intLastYearMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastYearMon) + "00"); // 2022071700
            Integer intLastYearSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastYearSun) + "23"); // 2022072323
            String yyyy = DateUtils.parseDateToStr(DateUtils.YYYY, sun); // 2023
            Integer yearStart = Integer.parseInt(yyyy + "010100"); // 2023010100
            String lastYear = DateUtils.parseDateToStr(DateUtils.YYYY, DateUtils.lastYear(sun)); // 2022
            List<WeekExcel> list = new ArrayList<>();
            for (int i = 1; i < 47; i++) {
                String name = "AI-" + (i < 10 ? "0" : "") + i;
                double sz = mapper.selectAccumulate(intMon, intSun, name); // 上周
                double ssz = mapper.selectAccumulate(intLastMon, intLastSun, name); // 上上周
                double zhb = CalculateUtils.round2((sz - ssz) / ssz * 100); // 周环比
                double qntq = mapper.selectAccumulate(intLastYearMon, intLastYearSun, name); // 去年同期
                double ztb = CalculateUtils.round2((sz - qntq) / qntq * 100); // 周同比
                double lj = mapper.selectAccumulate(yearStart, intSun, name); // 累计
                double lastLj = mapper.selectYearAccumulate(lastYear + "%", name); // 去年累计
                double ljtb = CalculateUtils.round2((lj - lastLj) / lastLj * 100); // 累计同比
                MonitorPointPosition point = commonService.select3dCheckPointByName(name);
                String id = point.getId().substring(0, point.getId().lastIndexOf("_") + 1) + "0";
                List<SuYuan700> suList = mapper.selectSuYuanByStartAndEnd(id, name, yjz, intMon, intSun);
                String ys = getYs(suList);
                list.add(new WeekExcel("" + sz, zhb + "%", "", ztb + "%", "", "" + lj, "" + ljtb, "", ys, "", "", ""));
            }
            //String filePath = createExcel("week", end, list);
            saveResult("week", sun, list);
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }
    }
    /**
     * 创建月报
     * 创建月报:new MonthExcel("AI-" + (i < 10 ? "0" : "") + i, "yhb", "ytq", "ytb", "yhb2", "lj", "ljtb", "qyn", "ys", "fs", "fx", "°c");
     */
    public void createMonthReport(Date date) {
        try {
@@ -220,8 +236,7 @@
            List<MonthExcel> list = new ArrayList<>();
            for (int i = 1; i < 47; i++) {
                MonthExcel day = new MonthExcel("AI-" + (i < 10 ? "0" : "") + i, "yhb", "ytq", "ytb", "yhb2", "lj", "ljtb", "qyn", "ys", "fs", "fx", "°c");
                list.add(day);
                //
            }
            String filePath = createExcel("month", end, list);