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