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 @@