From 9f411c3b0c21ba8fb0a532a5a93a52873ddba7d6 Mon Sep 17 00:00:00 2001 From: LokerL Date: Wed, 18 Sep 2024 13:36:16 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=AF=B9=E6=AF=94=E5=88=86?= =?UTF-8?q?=E6=9E=90=E5=8A=9F=E8=83=BD=E5=89=8D=E5=90=8E=E7=AB=AF=EF=BC=9B?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E9=97=A8=E6=95=B0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OilStatisticsController.java | 11 ++ .../oil/mapper/ThDeviceReportMonthMapper.java | 3 + .../service/ThDeviceReportMonthService.java | 2 + .../impl/ThDeviceReportMonthServiceImpl.java | 11 ++ .../mybatis/oil/ThDeviceReportMonthMapper.xml | 19 ++ ruoyi-ui/src/api/statistics/comparison.js | 8 + ruoyi-ui/src/components/BaseChart/index.vue | 23 +-- ruoyi-ui/src/components/DeptTree/index.vue | 59 ++++--- .../views/dataStatistics/comparison/index.vue | 163 +++++++++--------- 9 files changed, 175 insertions(+), 124 deletions(-) diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java index 44efe2d..fea820f 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java @@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -58,6 +59,16 @@ public class OilStatisticsController extends BaseController { return getDataTable(result); } + @GetMapping("/getAvgDsByDeptIdsAndDate") + public AjaxResult getAvgDsByDeptIdsAndDate(@RequestParam("ids") List ids, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) { + Map resultMap = new HashMap<>(); + for (Long id : ids) { + List> result = thDeviceReportMonthService.selectAvgDsByDeptIdAndDate(id, startDate, endDate); + resultMap.put(id, result); + } + return success(resultMap); + } + @GetMapping("/getDeviceAvgByMonth") public TableDataInfo getDeviceAvgByMonth(Long deptId, String startMonth, String endMonth, int pageNum, int pageSize) { diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java index 18ba25a..046c8d6 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java @@ -25,6 +25,9 @@ public interface ThDeviceReportMonthMapper { * 更新 */ int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth); + + @MapKey("dept_id") + List> selectAvgDsByDeptIdAndDate(@Param("deptId") Long deptId, @Param("startYear") int startYear, @Param("startMonth") int startMonth, @Param("endYear") int endYear, @Param("endMonth") int endMonth); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java index 991a009..e95b6a8 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java @@ -21,4 +21,6 @@ public interface ThDeviceReportMonthService { * 更新 */ int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth); + + List> selectAvgDsByDeptIdAndDate(Long deptId, String startTime, String endTime); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java index 1a43494..2f5b5f3 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java @@ -33,6 +33,17 @@ public class ThDeviceReportMonthServiceImpl implements ThDeviceReportMonthServic public int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth) { return thDeviceReportMonthMapper.updateThDeviceReportMonth(thDeviceReportMonth); } + + @Override + public List> selectAvgDsByDeptIdAndDate(Long deptId, String startDate, String endDate) { + // startDate:开始日期 2024-07, 拆分出startYear和startMonth,并转为int + int startYear = Integer.parseInt(startDate.split("-")[0]); + int startMonth = Integer.parseInt(startDate.split("-")[1]); + // endDate:结束日期 2024-08, 拆分出endYear和endMonth + int endYear = Integer.parseInt(endDate.split("-")[0]); + int endMonth = Integer.parseInt(endDate.split("-")[1]); + return camelCaseMapListKey(thDeviceReportMonthMapper.selectAvgDsByDeptIdAndDate(deptId, startYear, startMonth, endYear, endMonth)); + } } diff --git a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml index bbc2981..6c53624 100644 --- a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml @@ -55,4 +55,23 @@ where id = #{id} + + + diff --git a/ruoyi-ui/src/api/statistics/comparison.js b/ruoyi-ui/src/api/statistics/comparison.js index 09781fd..ae88fec 100644 --- a/ruoyi-ui/src/api/statistics/comparison.js +++ b/ruoyi-ui/src/api/statistics/comparison.js @@ -7,3 +7,11 @@ export function getAvgDsByMonth(params) { method: 'get', }) } + +export function getAvgDsByDeptIdsAndDate(params) { + return request({ + url: '/statistics/getAvgDsByDeptIdsAndDate', + params: params, + method: 'get', + }) +} diff --git a/ruoyi-ui/src/components/BaseChart/index.vue b/ruoyi-ui/src/components/BaseChart/index.vue index 140135b..8f5e397 100644 --- a/ruoyi-ui/src/components/BaseChart/index.vue +++ b/ruoyi-ui/src/components/BaseChart/index.vue @@ -9,26 +9,7 @@