From 426a1311e3f0fe682f49b4203a0a72e668ca6be5 Mon Sep 17 00:00:00 2001 From: LokerL Date: Fri, 27 Sep 2024 12:57:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=B9=B4=E5=BA=A6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=89=8D=E5=90=8E=E7=AB=AF=EF=BC=9B=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OilStatisticsController.java | 19 +- .../oil/mapper/ThDeviceReportMonthMapper.java | 3 + .../service/ThDeviceReportMonthService.java | 2 + .../impl/ThDeviceReportMonthServiceImpl.java | 5 + .../mybatis/oil/ThDeviceReportMonthMapper.xml | 24 +++ ruoyi-ui/src/api/statistics/yearData.js | 17 ++ ruoyi-ui/src/layout/components/Navbar.vue | 8 - ruoyi-ui/src/utils/excel.js | 26 ++- .../views/dataStatistics/yearData/index.vue | 198 ++++++++++++++++++ 9 files changed, 289 insertions(+), 13 deletions(-) create mode 100644 ruoyi-ui/src/api/statistics/yearData.js 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 fea820f..11d3801 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,7 +19,6 @@ 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; @@ -175,4 +174,22 @@ public class OilStatisticsController extends BaseController { List> dailyReportDataOverview = oilThDeviceReportService.dailyReportDataOverview(day); return success(dailyReportDataOverview); } + + @GetMapping("/yearData/getDeviceReportYearList") + public TableDataInfo getDeviceReportYearList(Long deptId, String year, int pageNum, int pageSize) { + Page page = PageHelper.startPage(pageNum, pageSize); + List> result = thDeviceReportMonthService.selectThDeviceReportYearList(deptId, year); + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setRows(result); + rspData.setMsg("查询成功"); + rspData.setTotal(page.getTotal()); + return rspData; + } + + @GetMapping("/yearData/getDeviceReportYearListAll") + public AjaxResult getDeviceReportYearList(Long deptId, String year) { + List> result = thDeviceReportMonthService.selectThDeviceReportYearList(deptId, year); + return success(result); + } } 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 046c8d6..0ee46c0 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 @@ -28,6 +28,9 @@ public interface ThDeviceReportMonthMapper { @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); + + @MapKey("deptId") + List> selectThDeviceReportYearList(Long deptId, String year); } 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 e95b6a8..3952105 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 @@ -23,4 +23,6 @@ public interface ThDeviceReportMonthService { int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth); List> selectAvgDsByDeptIdAndDate(Long deptId, String startTime, String endTime); + + List> selectThDeviceReportYearList(Long deptId, String year); } 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 2f5b5f3..b897fff 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 @@ -44,6 +44,11 @@ public class ThDeviceReportMonthServiceImpl implements ThDeviceReportMonthServic int endMonth = Integer.parseInt(endDate.split("-")[1]); return camelCaseMapListKey(thDeviceReportMonthMapper.selectAvgDsByDeptIdAndDate(deptId, startYear, startMonth, endYear, endMonth)); } + + @Override + public List> selectThDeviceReportYearList(Long deptId, String year) { + return camelCaseMapListKey(thDeviceReportMonthMapper.selectThDeviceReportYearList(deptId, year)); + } } 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 6c53624..6fcf0f6 100644 --- a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml @@ -45,6 +45,30 @@ + + - - - - - - - - diff --git a/ruoyi-ui/src/utils/excel.js b/ruoyi-ui/src/utils/excel.js index 2cef1b5..afa3ab3 100644 --- a/ruoyi-ui/src/utils/excel.js +++ b/ruoyi-ui/src/utils/excel.js @@ -1,8 +1,7 @@ import * as XLSX from "xlsx"; - -export function exportExcel(dom, fileName="导出文件") { - const xlsxParam = { raw: true };//转换成excel时,使用原始的格式 +export function exportExcel(dom, fileName = "导出文件") { + const xlsxParam = { raw: true }; //转换成excel时,使用原始的格式 let table; if (!dom) { return; @@ -16,5 +15,24 @@ export function exportExcel(dom, fileName="导出文件") { let wb = XLSX.utils.table_to_book(table, xlsxParam); // 生成excel - XLSX.writeFile(wb, `${fileName.endsWith(".xlsx") ? fileName : fileName + ".xlsx"}`); + XLSX.writeFile( + wb, + `${fileName.endsWith(".xlsx") ? fileName : fileName + ".xlsx"}` + ); +} +export function dataToExcel({data, fileName = "导出文件", sheetName = "SheetJS", wsCallback=null}) { + const wb = XLSX.utils.book_new(); + // 创建一个新的工作表 + const ws_name = sheetName; + const ws_data = data; + const ws = XLSX.utils.aoa_to_sheet(ws_data); + + if (wsCallback) { + wsCallback(ws); + } + + // 将工作表添加到工作簿中 + XLSX.utils.book_append_sheet(wb, ws, ws_name); + + XLSX.writeFile(wb, `${fileName}.xlsx`); } diff --git a/ruoyi-ui/src/views/dataStatistics/yearData/index.vue b/ruoyi-ui/src/views/dataStatistics/yearData/index.vue index e69de29..3d69624 100644 --- a/ruoyi-ui/src/views/dataStatistics/yearData/index.vue +++ b/ruoyi-ui/src/views/dataStatistics/yearData/index.vue @@ -0,0 +1,198 @@ + + + + +