diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/utils/StringUtils.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/utils/StringUtils.java index 25c2886..22a3350 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -1,11 +1,7 @@ package com.ruoyi.common.utils; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; + import org.springframework.util.AntPathMatcher; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.text.StrFormatter; @@ -681,4 +677,27 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } return sb.toString(); } + + public static String toLowerCaseCamelCase(String input) { + StringBuilder output = new StringBuilder(); + String[] words = input.split("_"); + output.append(words[0]); + for (int i = 1; i < words.length; i++) { + output.append(Character.toUpperCase(words[i].charAt(0))); + output.append(words[i].substring(1).toLowerCase()); + } + return output.toString(); + } + + public static final List> camelCaseMapListKey(List> list) { + List> result = new ArrayList<>(); + for (Map map : list) { + Map lowerCaseMap = new HashMap<>(); + for (String key : map.keySet()) { + lowerCaseMap.put(toLowerCaseCamelCase(key.toLowerCase()), map.get(key)); + } + result.add(lowerCaseMap); + } + return result; + } } \ No newline at end of file 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 9acc17b..ec80d96 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 @@ -12,6 +12,7 @@ import com.ruoyi.project.oil.domain.monitor.ThDevice; import com.ruoyi.project.oil.domain.monitor.ThDeviceReport; import com.ruoyi.project.oil.service.IOilThDeviceService; import com.ruoyi.project.oil.service.ThDeviceReportMonthService; +import com.ruoyi.project.oil.service.impl.OilThDeviceReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -32,6 +33,9 @@ public class OilStatisticsController extends BaseController { @Autowired private ThDeviceReportMonthService thDeviceReportMonthService; + @Autowired + private OilThDeviceReportService oilThDeviceReportService; + @GetMapping(value = "/getDeviceList/{id}") public TableDataInfo getDeviceList(@PathVariable("id") Long id) { startPage(); @@ -77,7 +81,7 @@ public class OilStatisticsController extends BaseController { public AjaxResult reportCenter(Long deptId, String month) { List> resultCurrMonth = oilThDeviceService.selectAllAvgByMonth(deptId, month); // 根据month获取上个月 字符串 month: 2024-09 -> lastMonth: 2024-08;1月份的上个月是12月份 - List> resultLastMonth = oilThDeviceService.selectAllAvgByMonth(deptId, getLastMonth(month)); + List> resultLastMonth = oilThDeviceService.selectAllAvgByMonth(deptId, getPreviousMonth(month)); // 月度报表中的数据 List> result = oilThDeviceService.selectDeptAvgByMonth(deptId, month); // 将所有的数据放入一个map中 @@ -88,7 +92,7 @@ public class OilStatisticsController extends BaseController { return success(resultMap); } - public static String getLastMonth(String month) { + public static String getPreviousMonth(String month) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); if (month.length() == 6) { month = month.substring(0, 5) + "0" + month.substring(5); @@ -98,7 +102,7 @@ public class OilStatisticsController extends BaseController { return lastMonthDate.format(formatter); } - @GetMapping("/getDeviceReportMonthList") + @GetMapping("/monthData/getDeviceReportMonthList") public TableDataInfo getDeviceReportMonthList(Long deptId, String year, String month, int pageNum, int pageSize) { Page page = PageHelper.startPage(pageNum, pageSize); List> result = thDeviceReportMonthService.selectThDeviceReportMonthList(deptId, year, month); @@ -110,8 +114,20 @@ public class OilStatisticsController extends BaseController { return rspData; } - @PostMapping("/updateDeviceReportMonth") + @PostMapping("/monthData/updateDeviceReportMonth") public AjaxResult updateDeviceReportMonth(@RequestBody ThDeviceReportMonth thDeviceReportMonth) { return toAjax(thDeviceReportMonthService.updateThDeviceReportMonth(thDeviceReportMonth)); } + + @GetMapping("/monthData/dataOverview") + public AjaxResult dataOverview(Long deptId, String month) { + List> monthReportDataOverview = oilThDeviceReportService.monthReportDataOverview(deptId, month); + List> preMonthReportDataOverview = oilThDeviceReportService.monthReportDataOverview(deptId, getPreviousMonth(month)); + List> monthReportDataOverviewDeviceDs = oilThDeviceReportService.monthReportDataOverviewDeviceDs(deptId, month); + Map resultMap = new HashMap<>(); + resultMap.put("monthReportDataOverview", monthReportDataOverview); + resultMap.put("preMonthReportDataOverview", preMonthReportDataOverview); + resultMap.put("monthReportDataOverviewDeviceDs", monthReportDataOverviewDeviceDs); + return success(resultMap); + } } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java index 258c0dd..2b64dd8 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java @@ -52,4 +52,16 @@ public interface ThDeviceReportMapper { */ @MapKey("month") List> selectAllAvgByMonth(@Param("deptId") Long deptId, @Param("month") String month); + + /** + * 按月度统计ds, gbz ,dbz的平均值 + */ + @MapKey("month") + List> monthReportDataOverview(@Param("deptId") Long deptId, @Param("month") String month); + + /** + * 按月度统计ds, gbz ,dbz的平均值 + */ + @MapKey("month") + List> monthReportDataOverviewDeviceDs(@Param("deptId") Long deptId, @Param("month") String month); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java new file mode 100644 index 0000000..68d3ec8 --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java @@ -0,0 +1,10 @@ +package com.ruoyi.project.oil.service; + +import java.util.List; +import java.util.Map; + +public interface IOilThDeviceReportService { + List> monthReportDataOverview(Long deptId, String month); + + List> monthReportDataOverviewDeviceDs(Long deptId, String month); +} diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java new file mode 100644 index 0000000..5787db3 --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java @@ -0,0 +1,29 @@ +package com.ruoyi.project.oil.service.impl; + +import com.ruoyi.project.oil.mapper.ThDeviceReportMapper; +import com.ruoyi.project.oil.service.IOilThDeviceReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +import static com.ruoyi.common.utils.StringUtils.camelCaseMapListKey; + +@Service +public class OilThDeviceReportService implements IOilThDeviceReportService { + + @Autowired + private ThDeviceReportMapper thDeviceReportMapper; + + @Override + public List> monthReportDataOverview(Long deptId, String month) { + return camelCaseMapListKey(thDeviceReportMapper.monthReportDataOverview(deptId, month)); + } + + @Override + public List> monthReportDataOverviewDeviceDs(Long deptId, String month) { + return camelCaseMapListKey(thDeviceReportMapper.monthReportDataOverviewDeviceDs(deptId, month)); + } + +} 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 1dae0ed..1a43494 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 @@ -11,6 +11,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static com.ruoyi.common.utils.StringUtils.camelCaseMapListKey; + /** * @author Lenovo * @description 针对表【TH_DEVICE_REPORT_MONTH1(设备月表)】的数据库操作Service实现 @@ -24,35 +26,13 @@ public class ThDeviceReportMonthServiceImpl implements ThDeviceReportMonthServic @Override public List> selectThDeviceReportMonthList(Long deptId, String year, String month) { -// return thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month); - List> result = new ArrayList<>(); - List> list = thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month); - for (Map map : list) { - Map lowerCaseMap = new HashMap<>(); - for (String key : map.keySet()) { - lowerCaseMap.put(toLowerCaseCamelCase(key.toLowerCase()), map.get(key)); - } - result.add(lowerCaseMap); - } - return result; + return camelCaseMapListKey(thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month)); } @Override public int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth) { return thDeviceReportMonthMapper.updateThDeviceReportMonth(thDeviceReportMonth); } - - - public static String toLowerCaseCamelCase(String input) { - StringBuilder output = new StringBuilder(); - String[] words = input.split("_"); - output.append(words[0]); - for (int i = 1; i < words.length; i++) { - output.append(Character.toUpperCase(words[i].charAt(0))); - output.append(words[i].substring(1).toLowerCase()); - } - return output.toString(); - } } diff --git a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml index acedb9a..4b6e7d3 100644 --- a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml @@ -122,4 +122,41 @@ AND TO_CHAR(d.report_time, 'YYYY-MM') = #{month} GROUP BY TO_CHAR(d.report_time, 'YYYY-MM') + + + + + diff --git a/ruoyi-ui/src/api/statistics/monthData.js b/ruoyi-ui/src/api/statistics/monthData.js index 083eba4..8914817 100644 --- a/ruoyi-ui/src/api/statistics/monthData.js +++ b/ruoyi-ui/src/api/statistics/monthData.js @@ -2,7 +2,7 @@ import request from '@/utils/request' export function getDeviceReportMonthList(params) { return request({ - url: '/statistics/getDeviceReportMonthList', + url: '/statistics/monthData/getDeviceReportMonthList', params: params, method: 'get', }) @@ -10,8 +10,16 @@ export function getDeviceReportMonthList(params) { export function updateDeviceReportMonth(params) { return request({ - url: '/statistics/updateDeviceReportMonth', + url: '/statistics/monthData/updateDeviceReportMonth', data: params, method: 'post', }) } + +export function dataOverview(params) { + return request({ + url: '/statistics/monthData/dataOverview', + params: params, + method: 'get', + }) +} diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index 4230ec4..107be4e 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -38,6 +38,7 @@ import VueMeta from 'vue-meta' // 字典数据组件 import DictData from '@/components/DictData' import BaiduMap from 'vue-baidu-map' +import DeptTree from '@/components/DeptTree'; // 全局方法挂载 Vue.prototype.getDicts = getDicts Vue.prototype.getConfigKey = getConfigKey @@ -50,6 +51,7 @@ Vue.prototype.download = download Vue.prototype.handleTree = handleTree // 全局组件挂载 +Vue.component('DeptTree', DeptTree) Vue.component('DictTag', DictTag) Vue.component('Pagination', Pagination) Vue.component('RightToolbar', RightToolbar) diff --git a/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue b/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue index e680b86..1b5ca58 100644 --- a/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue +++ b/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue @@ -27,7 +27,7 @@ > - + @@ -67,7 +67,6 @@