baoshiwei
2025-04-19 5d36e1f987ef21e44ded2e8a1d06c28094ec1e76
zhitan-admin/src/main/java/com/zhitan/web/controller/keyequipment/MonthlyKeyEquipmentController.java
@@ -1,7 +1,6 @@
package com.zhitan.web.controller.keyequipment;
import com.github.pagehelper.PageInfo;
import com.zhitan.common.core.controller.BaseController;
import com.zhitan.common.core.domain.AjaxResult;
import com.zhitan.keyequipment.domain.MonthlyKeyEquipment;
@@ -42,8 +41,7 @@
    @GetMapping("/list")
    @ApiOperation(value = "重点设备能耗统计(月)列表")
    public AjaxResult list(DataItem dataItem) {
        try {
    public AjaxResult list(DataItem dataItem) throws ParseException {
            List<MonthlyKeyEquipment> dataList=new ArrayList<>();
            Map tableColumn =new HashMap<>();//表数据
@@ -75,26 +73,17 @@
            reportList.setTablehead(table);
            List<ModelNode> nodeId = modelNodeService.getModelNodeByModelCode(dataItem.getIndexCode());
            if(CollectionUtils.isEmpty(nodeId)){
                return AjaxResult.success(reportList);
            return success(new ArrayList<>());
            }
            List<EnergyIndex> energyList = modelNodeService.getSettingIndex(nodeId.get(0).getNodeId());
            if(CollectionUtils.isEmpty(energyList)){
                return AjaxResult.success(reportList);
            return success(new ArrayList<>());
            }
            List<String> indexIds = energyList.stream().map(EnergyIndex::getIndexId).collect(Collectors.toList());
            startPage();
            List<MonthlyKeyEquipment> list = monthlyKeyEquipmentService.getMonthlyKeyEquipmentList(indexIds, dataList,dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getEnergyType());
            int count=Integer.valueOf(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length()-2));
            list.forEach(monthlyReport -> monthlyReport.setCount(count));
            reportList.setTabledata(list);
            reportList.setTotal(new PageInfo(list).getTotal());
            return AjaxResult.success(reportList);
        } catch (Exception ex) {
            logger.error("获取出错!", ex);
            return AjaxResult.error("获取出错!");
        }
        return success(list);
    }
    @GetMapping("/listChart")
@@ -110,6 +99,7 @@
        List<MonthlyKeyEquipment> list = monthlyKeyEquipmentService.getListChart(dataItem.getIndexId(),dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getEnergyType());
        return AjaxResult.success(list);
    }
    public static String getLastDayOfMonth(String yearMonth) {
        int year = Integer.parseInt(yearMonth.split("-")[0]);  //年
        int month = Integer.parseInt(yearMonth.split("-")[1]); //月