鞍钢鲅鱼圈能源管控系统后端代码
liriming
昨天 8f89dd21f2efffac1da33a00d0b60319c34f06cb
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -95,6 +95,7 @@
    @Autowired
    private PowerMaxdemandMainService powerMaxDemandMainService;
    @Autowired
    private PowerMaxdemandDetService powerMaxdemandDetService;
@@ -433,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")
@@ -442,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);
        }
@@ -804,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());
@@ -1127,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));
    }
}