|
@@ -1,25 +1,20 @@
|
|
-/*
|
|
|
|
- * 文 件 名: EnergyConsumptionController
|
|
|
|
- * 版 权: 华设设计集团股份有限公司
|
|
|
|
- * 描 述: <描述>
|
|
|
|
- * 修 改 人: lvwenbin
|
|
|
|
- * 修改时间: 2025/8/26
|
|
|
|
- * 跟踪单号: <跟踪单号>
|
|
|
|
- * 修改单号: <修改单号>
|
|
|
|
- * 修改内容: <修改内容>
|
|
|
|
- */
|
|
|
|
package com.ruoyi.ems.controller;
|
|
package com.ruoyi.ems.controller;
|
|
|
|
|
|
import com.huashe.common.domain.AjaxResult;
|
|
import com.huashe.common.domain.AjaxResult;
|
|
|
|
+import com.huashe.common.utils.ListUtils;
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
import com.ruoyi.common.log.enums.BusinessType;
|
|
import com.ruoyi.common.log.enums.BusinessType;
|
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
|
-import com.ruoyi.ems.model.EnergyConsumptionVO;
|
|
|
|
|
|
+import com.ruoyi.ems.model.ElecConsumptionVO;
|
|
|
|
+import com.ruoyi.ems.model.ElecConsumptionExportVO;
|
|
|
|
+import com.ruoyi.ems.model.WaterConsumptionVO;
|
|
|
|
+import com.ruoyi.ems.model.WaterConsumptionExportVO;
|
|
import com.ruoyi.ems.model.QueryMeter;
|
|
import com.ruoyi.ems.model.QueryMeter;
|
|
-import com.ruoyi.ems.service.IEnergyConsumptionService;
|
|
|
|
|
|
+import com.ruoyi.ems.service.IElecConsumptionService;
|
|
|
|
+import com.ruoyi.ems.service.IWaterConsumptionService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
@@ -34,7 +29,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 用能统计分析Controller
|
|
|
|
|
|
+ * 用能统计分析Controller - 重构版本
|
|
*
|
|
*
|
|
* @author ruoyi
|
|
* @author ruoyi
|
|
* @date 2024-12-20
|
|
* @date 2024-12-20
|
|
@@ -45,204 +40,296 @@ import java.util.List;
|
|
public class EnergyConsumptionController extends BaseController {
|
|
public class EnergyConsumptionController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private IEnergyConsumptionService energyConsumptionService;
|
|
|
|
|
|
+ private IElecConsumptionService elecConsumptionService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWaterConsumptionService waterConsumptionService;
|
|
|
|
|
|
- // ==================== 区域用能统计 ====================
|
|
|
|
|
|
+ // ==================== 区域用电统计 ====================
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询区域用能统计列表
|
|
|
|
|
|
+ * 查询区域用电统计列表
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:list")
|
|
@RequiresPermissions("ems:consumption:list")
|
|
- @GetMapping("/area/list")
|
|
|
|
- @ApiOperation("查询区域用能统计列表")
|
|
|
|
- public TableDataInfo getAreaConsumptionList(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- // 参数校验和默认值设置
|
|
|
|
- if (queryMeter == null) {
|
|
|
|
- queryMeter = new QueryMeter();
|
|
|
|
- }
|
|
|
|
|
|
+ @GetMapping("/area/elec/list")
|
|
|
|
+ @ApiOperation("查询区域用电统计列表")
|
|
|
|
+ public TableDataInfo getAreaElecConsumptionList(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(1);
|
|
|
|
|
|
- // 设置默认时间维度
|
|
|
|
- if (StringUtils.isBlank(queryMeter.getTimeDimension())) {
|
|
|
|
- queryMeter.setTimeDimension("month");
|
|
|
|
- }
|
|
|
|
|
|
+ List<ElecConsumptionVO> list = elecConsumptionService.selectAreaElecConsumptionList(queryMeter);
|
|
|
|
+ int total = list.size();
|
|
|
|
+ list = ListUtils.subList(list, (queryMeter.getPageNum() - 1) * queryMeter.getPageSize(),
|
|
|
|
+ queryMeter.getPageNum() * queryMeter.getPageSize() - 1);
|
|
|
|
|
|
- // 设置对象类型
|
|
|
|
- queryMeter.setObjType(1);
|
|
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
+ rspData.setCode(200);
|
|
|
|
+ rspData.setRows(list);
|
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
|
+ rspData.setTotal(total);
|
|
|
|
|
|
- startPage();
|
|
|
|
- List<EnergyConsumptionVO> list = energyConsumptionService.selectAreaConsumptionList(queryMeter);
|
|
|
|
- return getDataTable(list);
|
|
|
|
|
|
+ return rspData;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询区域用能统计汇总
|
|
|
|
|
|
+ * 查询区域用电统计汇总
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:list")
|
|
@RequiresPermissions("ems:consumption:list")
|
|
- @GetMapping("/area/summary")
|
|
|
|
- @ApiOperation("查询区域用能统计汇总")
|
|
|
|
- public AjaxResult getAreaConsumptionSummary(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- if (queryMeter == null) {
|
|
|
|
- queryMeter = new QueryMeter();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @GetMapping("/area/elec/summary")
|
|
|
|
+ @ApiOperation("查询区域用电统计汇总")
|
|
|
|
+ public AjaxResult getAreaElecConsumptionSummary(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
queryMeter.setObjType(1);
|
|
queryMeter.setObjType(1);
|
|
- EnergyConsumptionVO summary = energyConsumptionService.selectAreaConsumptionSummary(queryMeter);
|
|
|
|
|
|
+
|
|
|
|
+ ElecConsumptionVO summary = elecConsumptionService.selectAreaElecConsumptionSummary(queryMeter);
|
|
return success(summary);
|
|
return success(summary);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导出区域用能统计数据
|
|
|
|
|
|
+ * 导出区域用电统计数据
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:export")
|
|
@RequiresPermissions("ems:consumption:export")
|
|
- @Log(title = "区域用能统计", businessType = BusinessType.EXPORT)
|
|
|
|
- @PostMapping("/area/export")
|
|
|
|
- @ApiOperation("导出区域用能统计数据")
|
|
|
|
- public void exportAreaConsumption(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- if (queryMeter == null) {
|
|
|
|
- queryMeter = new QueryMeter();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtils.isBlank(queryMeter.getTimeDimension())) {
|
|
|
|
- queryMeter.setTimeDimension("month");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @Log(title = "区域用电统计", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/area/elec/export")
|
|
|
|
+ @ApiOperation("导出区域用电统计数据")
|
|
|
|
+ public void exportAreaElecConsumption(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
queryMeter.setObjType(1);
|
|
queryMeter.setObjType(1);
|
|
- List<EnergyConsumptionVO> list = energyConsumptionService.exportAreaConsumptionList(queryMeter);
|
|
|
|
|
|
|
|
- ExcelUtil<EnergyConsumptionVO> util = new ExcelUtil<>(EnergyConsumptionVO.class);
|
|
|
|
- String fileName = String.format("区域用能统计_%s_%s.xlsx",
|
|
|
|
- queryMeter.getTimeDimension(),
|
|
|
|
|
|
+ List<ElecConsumptionVO> list = elecConsumptionService.exportAreaElecConsumptionList(queryMeter);
|
|
|
|
+ // 转换为导出VO
|
|
|
|
+ List<ElecConsumptionExportVO> exportList = elecConsumptionService.convertToElecExportVOList(list,
|
|
|
|
+ queryMeter.getTimeDimension());
|
|
|
|
+
|
|
|
|
+ ExcelUtil<ElecConsumptionExportVO> util = new ExcelUtil<>(ElecConsumptionExportVO.class);
|
|
|
|
+ String fileName = String.format("区域用电统计_%s_%s.xlsx", queryMeter.getTimeDimension(),
|
|
System.currentTimeMillis());
|
|
System.currentTimeMillis());
|
|
- util.exportExcel(response, list, fileName);
|
|
|
|
|
|
+ util.exportExcel(response, exportList, fileName);
|
|
}
|
|
}
|
|
|
|
|
|
- // ==================== 设施用能统计 ====================
|
|
|
|
|
|
+ // ==================== 设施用电统计 ====================
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询设施用能统计列表
|
|
|
|
|
|
+ * 查询设施用电统计列表
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:list")
|
|
@RequiresPermissions("ems:consumption:list")
|
|
- @GetMapping("/facs/list")
|
|
|
|
- @ApiOperation("查询设施用能统计列表")
|
|
|
|
- public TableDataInfo getFacsConsumptionList(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- // 参数校验和默认值设置
|
|
|
|
- if (queryMeter == null) {
|
|
|
|
- queryMeter = new QueryMeter();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 设置默认时间维度
|
|
|
|
- if (StringUtils.isBlank(queryMeter.getTimeDimension())) {
|
|
|
|
- queryMeter.setTimeDimension("month");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 设置默认设施分类
|
|
|
|
|
|
+ @GetMapping("/facs/elec/list")
|
|
|
|
+ @ApiOperation("查询设施用电统计列表")
|
|
|
|
+ public TableDataInfo getFacsElecConsumptionList(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(2);
|
|
if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
queryMeter.setFacsCategory("Z");
|
|
queryMeter.setFacsCategory("Z");
|
|
}
|
|
}
|
|
|
|
|
|
- // 设置对象类型
|
|
|
|
- queryMeter.setObjType(2);
|
|
|
|
|
|
+ List<ElecConsumptionVO> list = elecConsumptionService.selectFacsElecConsumptionList(queryMeter);
|
|
|
|
+ int total = list.size();
|
|
|
|
+ list = ListUtils.subList(list, (queryMeter.getPageNum() - 1) * queryMeter.getPageSize(),
|
|
|
|
+ queryMeter.getPageNum() * queryMeter.getPageSize() - 1);
|
|
|
|
+
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
+ rspData.setCode(200);
|
|
|
|
+ rspData.setRows(list);
|
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
|
+ rspData.setTotal(total);
|
|
|
|
|
|
- startPage();
|
|
|
|
- List<EnergyConsumptionVO> list = energyConsumptionService.selectFacsConsumptionList(queryMeter);
|
|
|
|
- return getDataTable(list);
|
|
|
|
|
|
+ return rspData;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询设施用能统计汇总
|
|
|
|
|
|
+ * 查询设施用电统计汇总
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:list")
|
|
@RequiresPermissions("ems:consumption:list")
|
|
- @GetMapping("/facs/summary")
|
|
|
|
- @ApiOperation("查询设施用能统计汇总")
|
|
|
|
- public AjaxResult getFacsConsumptionSummary(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- if (queryMeter == null) {
|
|
|
|
- queryMeter = new QueryMeter();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @GetMapping("/facs/elec/summary")
|
|
|
|
+ @ApiOperation("查询设施用电统计汇总")
|
|
|
|
+ public AjaxResult getFacsElecConsumptionSummary(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(2);
|
|
if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
queryMeter.setFacsCategory("Z");
|
|
queryMeter.setFacsCategory("Z");
|
|
}
|
|
}
|
|
|
|
|
|
- queryMeter.setObjType(2);
|
|
|
|
- EnergyConsumptionVO summary = energyConsumptionService.selectFacsConsumptionSummary(queryMeter);
|
|
|
|
|
|
+ ElecConsumptionVO summary = elecConsumptionService.selectFacsElecConsumptionSummary(queryMeter);
|
|
return success(summary);
|
|
return success(summary);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导出设施用能统计数据
|
|
|
|
|
|
+ * 导出设施用电统计数据
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:export")
|
|
@RequiresPermissions("ems:consumption:export")
|
|
- @Log(title = "设施用能统计", businessType = BusinessType.EXPORT)
|
|
|
|
- @PostMapping("/facs/export")
|
|
|
|
- @ApiOperation("导出设施用能统计数据")
|
|
|
|
- public void exportFacsConsumption(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- if (queryMeter == null) {
|
|
|
|
- queryMeter = new QueryMeter();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtils.isBlank(queryMeter.getTimeDimension())) {
|
|
|
|
- queryMeter.setTimeDimension("month");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @Log(title = "设施用电统计", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/facs/elec/export")
|
|
|
|
+ @ApiOperation("导出设施用电统计数据")
|
|
|
|
+ public void exportFacsElecConsumption(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(2);
|
|
if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
queryMeter.setFacsCategory("Z");
|
|
queryMeter.setFacsCategory("Z");
|
|
}
|
|
}
|
|
|
|
|
|
- queryMeter.setObjType(2);
|
|
|
|
- List<EnergyConsumptionVO> list = energyConsumptionService.exportFacsConsumptionList(queryMeter);
|
|
|
|
|
|
+ List<ElecConsumptionVO> list = elecConsumptionService.exportFacsElecConsumptionList(queryMeter);
|
|
|
|
+ // 转换为导出VO
|
|
|
|
+ List<ElecConsumptionExportVO> exportList = elecConsumptionService.convertToElecExportVOList(list,
|
|
|
|
+ queryMeter.getTimeDimension());
|
|
|
|
|
|
- ExcelUtil<EnergyConsumptionVO> util = new ExcelUtil<>(EnergyConsumptionVO.class);
|
|
|
|
- String fileName = String.format("设施用能统计_%s_%s.xlsx",
|
|
|
|
- queryMeter.getTimeDimension(),
|
|
|
|
|
|
+ ExcelUtil<ElecConsumptionExportVO> util = new ExcelUtil<>(ElecConsumptionExportVO.class);
|
|
|
|
+ String fileName = String.format("设施用电统计_%s_%s.xlsx", queryMeter.getTimeDimension(),
|
|
System.currentTimeMillis());
|
|
System.currentTimeMillis());
|
|
- util.exportExcel(response, list, fileName);
|
|
|
|
|
|
+ util.exportExcel(response, exportList, fileName);
|
|
}
|
|
}
|
|
|
|
|
|
- // ==================== 兼容性接口 ====================
|
|
|
|
|
|
+ // ==================== 区域用水统计 ====================
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询区域用能数据 (兼容旧接口)
|
|
|
|
|
|
+ * 查询区域用水统计列表
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:list")
|
|
@RequiresPermissions("ems:consumption:list")
|
|
- @GetMapping("/hour/listAreaMeter")
|
|
|
|
- @ApiOperation("查询区域用能数据(兼容接口)")
|
|
|
|
- @Deprecated
|
|
|
|
- public TableDataInfo listAreaMeter(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- return getAreaConsumptionList(queryMeter);
|
|
|
|
|
|
+ @GetMapping("/area/water/list")
|
|
|
|
+ @ApiOperation("查询区域用水统计列表")
|
|
|
|
+ public TableDataInfo getAreaWaterConsumptionList(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(1);
|
|
|
|
+
|
|
|
|
+ List<WaterConsumptionVO> list = waterConsumptionService.selectAreaWaterConsumptionList(queryMeter);
|
|
|
|
+ int total = list.size();
|
|
|
|
+ list = ListUtils.subList(list, (queryMeter.getPageNum() - 1) * queryMeter.getPageSize(),
|
|
|
|
+ queryMeter.getPageNum() * queryMeter.getPageSize() - 1);
|
|
|
|
+
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
+ rspData.setCode(200);
|
|
|
|
+ rspData.setRows(list);
|
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
|
+ rspData.setTotal(total);
|
|
|
|
+
|
|
|
|
+ return rspData;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询设施用能数据 (兼容旧接口)
|
|
|
|
|
|
+ * 查询区域用水统计汇总
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:list")
|
|
@RequiresPermissions("ems:consumption:list")
|
|
- @GetMapping("/hour/listFacsMeter")
|
|
|
|
- @ApiOperation("查询设施用能数据(兼容接口)")
|
|
|
|
- @Deprecated
|
|
|
|
- public TableDataInfo listFacsMeter(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- return getFacsConsumptionList(queryMeter);
|
|
|
|
|
|
+ @GetMapping("/area/water/summary")
|
|
|
|
+ @ApiOperation("查询区域用水统计汇总")
|
|
|
|
+ public AjaxResult getAreaWaterConsumptionSummary(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(1);
|
|
|
|
+
|
|
|
|
+ WaterConsumptionVO summary = waterConsumptionService.selectAreaWaterConsumptionSummary(queryMeter);
|
|
|
|
+ return success(summary);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导出区域用能数据 (兼容旧接口)
|
|
|
|
|
|
+ * 导出区域用水统计数据
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:export")
|
|
@RequiresPermissions("ems:consumption:export")
|
|
- @Log(title = "区域用能统计", businessType = BusinessType.EXPORT)
|
|
|
|
- @PostMapping("/exportAreaMeter")
|
|
|
|
- @ApiOperation("导出区域用能数据(兼容接口)")
|
|
|
|
- @Deprecated
|
|
|
|
- public void exportAreaMeter(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- exportAreaConsumption(response, queryMeter);
|
|
|
|
|
|
+ @Log(title = "区域用水统计", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/area/water/export")
|
|
|
|
+ @ApiOperation("导出区域用水统计数据")
|
|
|
|
+ public void exportAreaWaterConsumption(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(1);
|
|
|
|
+
|
|
|
|
+ List<WaterConsumptionVO> list = waterConsumptionService.exportAreaWaterConsumptionList(queryMeter);
|
|
|
|
+ // 转换为导出VO
|
|
|
|
+ List<WaterConsumptionExportVO> exportList = waterConsumptionService.convertToWaterExportVOList(list,
|
|
|
|
+ queryMeter.getTimeDimension());
|
|
|
|
+
|
|
|
|
+ ExcelUtil<WaterConsumptionExportVO> util = new ExcelUtil<>(WaterConsumptionExportVO.class);
|
|
|
|
+ String fileName = String.format("区域用水统计_%s_%s.xlsx", queryMeter.getTimeDimension(),
|
|
|
|
+ System.currentTimeMillis());
|
|
|
|
+ util.exportExcel(response, exportList, fileName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // ==================== 设施用水统计 ====================
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询设施用水统计列表
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("ems:consumption:list")
|
|
|
|
+ @GetMapping("/facs/water/list")
|
|
|
|
+ @ApiOperation("查询设施用水统计列表")
|
|
|
|
+ public TableDataInfo getFacsWaterConsumptionList(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(2);
|
|
|
|
+ if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
|
|
+ queryMeter.setFacsCategory("Z");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WaterConsumptionVO> list = waterConsumptionService.selectFacsWaterConsumptionList(queryMeter);
|
|
|
|
+
|
|
|
|
+ int total = list.size();
|
|
|
|
+ list = ListUtils.subList(list, (queryMeter.getPageNum() - 1) * queryMeter.getPageSize(),
|
|
|
|
+ queryMeter.getPageNum() * queryMeter.getPageSize() - 1);
|
|
|
|
+
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
+ rspData.setCode(200);
|
|
|
|
+ rspData.setRows(list);
|
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
|
+ rspData.setTotal(total);
|
|
|
|
+
|
|
|
|
+ return rspData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询设施用水统计汇总
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("ems:consumption:list")
|
|
|
|
+ @GetMapping("/facs/water/summary")
|
|
|
|
+ @ApiOperation("查询设施用水统计汇总")
|
|
|
|
+ public AjaxResult getFacsWaterConsumptionSummary(@ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(2);
|
|
|
|
+ if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
|
|
+ queryMeter.setFacsCategory("Z");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WaterConsumptionVO summary = waterConsumptionService.selectFacsWaterConsumptionSummary(queryMeter);
|
|
|
|
+ return success(summary);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导出设施用能数据 (兼容旧接口)
|
|
|
|
|
|
+ * 导出设施用水统计数据
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:consumption:export")
|
|
@RequiresPermissions("ems:consumption:export")
|
|
- @Log(title = "设施用能统计", businessType = BusinessType.EXPORT)
|
|
|
|
- @PostMapping("/exportFacsMeter")
|
|
|
|
- @ApiOperation("导出设施用能数据(兼容接口)")
|
|
|
|
- @Deprecated
|
|
|
|
- public void exportFacsMeter(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
- exportFacsConsumption(response, queryMeter);
|
|
|
|
|
|
+ @Log(title = "设施用水统计", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/facs/water/export")
|
|
|
|
+ @ApiOperation("导出设施用水统计数据")
|
|
|
|
+ public void exportFacsWaterConsumption(HttpServletResponse response, @ApiParam("查询参数") QueryMeter queryMeter) {
|
|
|
|
+ validateAndSetDefaults(queryMeter);
|
|
|
|
+ queryMeter.setObjType(2);
|
|
|
|
+ if (StringUtils.isBlank(queryMeter.getFacsCategory())) {
|
|
|
|
+ queryMeter.setFacsCategory("Z");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WaterConsumptionVO> list = waterConsumptionService.exportFacsWaterConsumptionList(queryMeter);
|
|
|
|
+ // 转换为导出VO
|
|
|
|
+ List<WaterConsumptionExportVO> exportList = waterConsumptionService.convertToWaterExportVOList(list,
|
|
|
|
+ queryMeter.getTimeDimension());
|
|
|
|
+
|
|
|
|
+ ExcelUtil<WaterConsumptionExportVO> util = new ExcelUtil<>(WaterConsumptionExportVO.class);
|
|
|
|
+ String fileName = String.format("设施用水统计_%s_%s.xlsx", queryMeter.getTimeDimension(),
|
|
|
|
+ System.currentTimeMillis());
|
|
|
|
+ util.exportExcel(response, exportList, fileName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // ==================== 参数校验方法 ====================
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验并设置默认参数
|
|
|
|
+ */
|
|
|
|
+ private void validateAndSetDefaults(QueryMeter queryMeter) {
|
|
|
|
+ if (queryMeter == null) {
|
|
|
|
+ throw new IllegalArgumentException("查询参数不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 设置默认时间维度
|
|
|
|
+ if (StringUtils.isBlank(queryMeter.getTimeDimension())) {
|
|
|
|
+ queryMeter.setTimeDimension("month");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 设置默认排序
|
|
|
|
+ if (StringUtils.isBlank(queryMeter.getOrderFlag())) {
|
|
|
|
+ queryMeter.setOrderFlag("desc");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|