From 48b69b857ae860050a790be63b317e15be49f1b1 Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期二, 13 五月 2025 16:57:41 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java |   81 ++++++++++++++++++++++++++++++++++------
 1 files changed, 69 insertions(+), 12 deletions(-)

diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
index 795f7da..bdcf1d2 100644
--- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
+++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -3,6 +3,7 @@
 import cn.hutool.core.util.NumberUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.iailab.framework.common.exception.ErrorCode;
 import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants;
 import com.iailab.framework.common.pojo.CommonResult;
 import com.iailab.framework.common.pojo.PageResult;
@@ -38,6 +39,7 @@
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.iailab.framework.common.pojo.CommonResult.error;
 import static com.iailab.framework.common.pojo.CommonResult.success;
 
 /**
@@ -93,6 +95,7 @@
 
     @Autowired
     private PowerMaxdemandMainService powerMaxDemandMainService;
+
     @Autowired
     private PowerMaxdemandDetService powerMaxdemandDetService;
 
@@ -431,8 +434,51 @@
     @GetMapping("/capacitor-status/list")
     @Operation(summary = "功率因数-电容器投退状态")
     public CommonResult<List<PowerCapacitorStatusDTO>> getPowerCapacitorStatusList(@RequestParam Map<String, Object> params) {
+        List<PowerCapacitorStatusDTO> result = new ArrayList<>();
         List<PowerCapacitorStatusEntity> list = powerCapacitorStatusService.list(params);
-        return success(ConvertUtils.sourceToTarget(list, PowerCapacitorStatusDTO.class));
+        for (PowerCapacitorStatusEntity entity : list) {
+            PowerCapacitorStatusDTO dto = new PowerCapacitorStatusDTO();
+            dto.setId(entity.getId());
+            dto.setName(entity.getName());
+            dto.setRemark(entity.getRemark());
+            dto.setMainCount(DecimalUtil.toBigDecimal(entity.getMainCount()).intValue());
+            dto.setChildCount(DecimalUtil.toBigDecimal(entity.getChildCount()).intValue());
+            int onCount = 0;
+            Map<String, Object> params1 = new HashMap<>();
+            params1.put("statusId", entity.getId());
+            List<PowerCapacitorDetEntity> detList = powerCapacitorDetService.list(params1);
+            if (CollectionUtils.isEmpty(detList)) {
+                dto.setOnCount(onCount);
+                continue;
+            }
+            List<String> points = new ArrayList<>();
+            Map<String, Object> pointsRealValue = new HashMap<>();
+            for (PowerCapacitorDetEntity det : detList) {
+                if (StringUtils.isNotBlank(det.getPointNo())) {
+                    points.add(det.getPointNo());
+                }
+            }
+            if (!CollectionUtils.isEmpty(points)) {
+                pointsRealValue = dataPointApi.queryPointsRealValue(points);
+            }
+            for (PowerCapacitorDetEntity det : detList) {
+                if (StringUtils.isBlank(det.getId())) {
+                    continue;
+                }
+                Object obj = pointsRealValue.get(det.getPointNo());
+                if (obj == null) {
+                    continue;
+                }
+                BigDecimal pv = new BigDecimal(obj.toString());
+                if (pv.compareTo(BigDecimal.ZERO) <= 0) {
+                    continue;
+                }
+                onCount ++;
+            }
+            dto.setOnCount(onCount);
+            result.add(dto);
+        }
+        return success(result);
     }
 
     @GetMapping("/capacitor-det/list")
@@ -440,10 +486,13 @@
     public CommonResult<List<PowerCapacitorDetDTO>> getPowerCapacitorDetList(@RequestParam Map<String, Object> params) {
         List<PowerCapacitorDetEntity> list = powerCapacitorDetService.list(params);
         log.info("list.size=" + list.size());
-        List<String> points = list.stream().map(item -> {
-            return item.getPointNo();
-        }).collect(Collectors.toList());
+        List<String> points = new ArrayList<>();
         Map<String, Object> pointsRealValue = new HashMap<>();
+        for (PowerCapacitorDetEntity det : list) {
+            if (StringUtils.isNotBlank(det.getPointNo())) {
+                points.add(det.getPointNo());
+            }
+        }
         if (!CollectionUtils.isEmpty(points)) {
             pointsRealValue = dataPointApi.queryPointsRealValue(points);
         }
@@ -802,7 +851,7 @@
         apiPointValueQueryDTO.setEnd(new Date());
         List<ApiPointValueDTO> monthChartData = dataPointApi.queryPointHistoryValue(apiPointValueQueryDTO);
         List<Double> monthValues = new ArrayList<>();
-        if (CollectionUtils.isEmpty(monthChartData)) {
+        if (!CollectionUtils.isEmpty(monthChartData)) {
             monthValues = monthChartData.stream().map(item -> item.getV()).collect(Collectors.toList());
             result.setMax(monthValues.stream().max(Double::compareTo).get());
             result.setMin(monthValues.stream().min(Double::compareTo).get());
@@ -1107,15 +1156,12 @@
     @PostMapping("/power-maxdemand/page")
     @Operation(summary = "负荷移植-最大需量发生记录分页")
     public CommonResult<PageResult<PowerMaxDemandMainDTO>> getPowerMaxDemandMainPage(@RequestBody PowerMaxDemandMainPageReqVO reqVO) {
+        if (StringUtils.isBlank(reqVO.getCode())) {
+            log.info("code is blank");
+            return error(GlobalErrorCodeConstants.BAD_REQUEST);
+        }
         PageResult<PowerMaxdemandMainEntity> page = powerMaxDemandMainService.page(reqVO);
         PageResult<PowerMaxDemandMainDTO> result = BeanUtils.toBean(page, PowerMaxDemandMainDTO.class);
-        /*List<String> parentIds = result.getList()
-                .stream()
-                .map(PowerMaxDemandMainDTO::getId)
-                .collect(Collectors.toList());
-        List<PowerMaxdemandDetEntity> children = powerMaxdemandDetService.selectListByRelIds(parentIds);
-        Map<String, List<PowerMaxdemandDetEntity>> childrenMap = children.stream()
-                .collect(Collectors.groupingBy(PowerMaxdemandDetEntity::getRelId));*/
         result.getList().forEach(dto0 -> {
             List<PowerMaxdemandDetEntity> detList0 = powerMaxdemandDetService.selectListByRelId(dto0.getId(), dto0.getOccurTime());
             dto0.setChildren(ConvertUtils.sourceToTarget(detList0, PowerMaxdemandDetDTO.class));
@@ -1128,4 +1174,15 @@
         });
         return success(result);
     }
+
+    @PostMapping("/power-maxdemand/det-list")
+    @Operation(summary = "负荷移植-最大需量发生记录详情")
+    public CommonResult<List<PowerMaxdemandDetDTO>> getPowerMaxDemandDetList(@RequestParam Map<String, Object> params) {
+        String relId = (String) params.get("relId");
+        if (StringUtils.isBlank(relId)) {
+            return error(GlobalErrorCodeConstants.BAD_REQUEST);
+        }
+        List<PowerMaxdemandDetEntity> list = powerMaxdemandDetService.selectListByRelId(relId);
+        return success(ConvertUtils.sourceToTarget(list, PowerMaxdemandDetDTO.class));
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3