From c7cc3d90df2a412063188e5cdf025de6cd5bfcd9 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 10 八月 2023 17:38:50 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/service/XlsReportService.java |   51 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/yssh/service/XlsReportService.java b/src/main/java/com/yssh/service/XlsReportService.java
index 7cc8355..eb649d1 100644
--- a/src/main/java/com/yssh/service/XlsReportService.java
+++ b/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);
         }
     }
 
     /**
-     * 鍒涘缓鏈堟姤
+     * 鍒涘缓鏈堟姤锛歯ew 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);

--
Gitblit v1.9.3