|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.ems.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.huashe.common.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
|
@@ -9,10 +10,13 @@ import com.ruoyi.common.log.enums.BusinessType;
|
|
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
|
|
import com.ruoyi.ems.domain.ElecMeter;
|
|
|
import com.ruoyi.ems.domain.ElecMeterH;
|
|
|
+import com.ruoyi.ems.domain.EmsObjAttrValue;
|
|
|
+import com.ruoyi.ems.domain.FacsCategory;
|
|
|
import com.ruoyi.ems.model.QueryMeter;
|
|
|
import com.ruoyi.ems.service.IBoundaryObjService;
|
|
|
import com.ruoyi.ems.service.IElecMeterHService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -24,7 +28,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 用电计量-小时Controller
|
|
@@ -55,6 +64,55 @@ public class ElecMeterHController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 查询设施用能统计数据
|
|
|
+ *
|
|
|
+ * @param queryMeter 查询条件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/staByTime")
|
|
|
+ public AjaxResult staByTime(QueryMeter queryMeter) {
|
|
|
+ List<ElecMeter> list = elecMeterHService.staByTime(queryMeter);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ Map<String, ElecMeter> map = list.stream()
|
|
|
+ .collect(Collectors.toMap(ElecMeter::getObjName, Function.identity()));
|
|
|
+ BigDecimal quantity = BigDecimal.ZERO;
|
|
|
+ BigDecimal useCost = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ ElecMeter lowElec = map.computeIfAbsent("lowElec", k -> new ElecMeter("-1", "lowElec", 0.0, 0.0));
|
|
|
+ ElecMeter normalElec = map.computeIfAbsent("normalElec", k -> new ElecMeter("0", "normalElec", 0.0, 0.0));
|
|
|
+ ElecMeter highElec = map.computeIfAbsent("highElec", k -> new ElecMeter("1", "highElec", 0.0, 0.0));
|
|
|
+ ElecMeter peakElec = map.computeIfAbsent("peakElec", k -> new ElecMeter("-1", "peakElec", 0.0, 0.0));
|
|
|
+
|
|
|
+ quantity = quantity.add(new BigDecimal(String.valueOf(lowElec.getQuantity())));
|
|
|
+ useCost = useCost.add(new BigDecimal(String.valueOf(lowElec.getUseCost())));
|
|
|
+ quantity = quantity.add(new BigDecimal(String.valueOf(normalElec.getQuantity())));
|
|
|
+ useCost = useCost.add(new BigDecimal(String.valueOf(normalElec.getUseCost())));
|
|
|
+ quantity = quantity.add(new BigDecimal(String.valueOf(highElec.getQuantity())));
|
|
|
+ useCost = useCost.add(new BigDecimal(String.valueOf(highElec.getUseCost())));
|
|
|
+ quantity = quantity.add(new BigDecimal(String.valueOf(peakElec.getQuantity())));
|
|
|
+ useCost = useCost.add(new BigDecimal(String.valueOf(peakElec.getUseCost())));
|
|
|
+
|
|
|
+ jsonObject.put("total", new ElecMeter("total", "total", quantity.doubleValue(), useCost.doubleValue()));
|
|
|
+ jsonObject.put("lowElec", lowElec);
|
|
|
+ jsonObject.put("normalElec", normalElec);
|
|
|
+ jsonObject.put("highElec", highElec);
|
|
|
+ jsonObject.put("peakElec", peakElec);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ jsonObject.put("total", new ElecMeter("total", "total", 0.0, 0.0));
|
|
|
+ jsonObject.put("lowElec", new ElecMeter("-1", "lowElec", 0.0, 0.0));
|
|
|
+ jsonObject.put("normalElec", new ElecMeter("0", "normalElec", 0.0, 0.0));
|
|
|
+ jsonObject.put("highElec", new ElecMeter("1", "highElec", 0.0, 0.0));
|
|
|
+ jsonObject.put("peakElec", new ElecMeter("2", "peakElec", 0.0, 0.0));
|
|
|
+ }
|
|
|
+
|
|
|
+ return success(jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询设施用能统计数据
|
|
|
+ *
|
|
|
* @param queryMeter 查询条件
|
|
|
* @return
|
|
|
*/
|
|
@@ -66,6 +124,7 @@ public class ElecMeterHController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 查询设施用能统计数据
|
|
|
+ *
|
|
|
* @param queryMeter 查询条件
|
|
|
* @return
|
|
|
*/
|