鞍钢鲅鱼圈能源管控系统后端代码
潘志宝
6 天以前 cd27eb7a49c7cece7767684c90b13bc67f658b45
负荷移植-需量值查询
已修改2个文件
已添加1个文件
119 ■■■■■ 文件已修改
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerDemandQueryDTO.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerDemandQueryRespDTO.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -594,11 +594,12 @@
    }
    @PostMapping("/demand-query/list")
    @Operation(summary = "负荷移植-功率因数查询")
    public CommonResult<List<PowerNetDropdownDTO>> getDemandDropdownList(@RequestBody PowerDemandQueryDTO queryDto) {
        List<PowerNetDropdownDTO> result = new ArrayList<>();
    @Operation(summary = "负荷移植-需量值查询")
    public CommonResult<List<PowerDemandQueryRespDTO>> getDemandDropdownList(@RequestBody PowerDemandQueryDTO queryDto) {
        List<PowerDemandQueryRespDTO> result = new ArrayList<>();
        if (StringUtils.isBlank(queryDto.getCode())) {
            log.info("code isBlank");
            return success(result);
        }
        log.info("code=" + queryDto.getCode());
        if (StringUtils.isBlank(queryDto.getNodeCode())) {
@@ -609,25 +610,42 @@
            log.info("PowerDemandEntity is null");
            return success(result);
        }
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.set(Calendar.SECOND, 0);
        Date startTime = queryDto.getStartTime();
        Date endTime = queryDto.getEndTime();
        if (endTime == null) {
            endTime = calendar.getTime();
        }
        if (startTime == null) {
            calendar.add(Calendar.DAY_OF_YEAR, -1);
            startTime = calendar.getTime();
        }
        Map<String, Object> params0 = new HashMap<>();
        params0.put("groupName", entity.getName());
        List<PowerNetDropdownEntity> list = powerNetDropdownService.list(params0);
        List<String> points = list.stream().map(item -> {
            return item.getCurCos();
        }).collect(Collectors.toList());
        if (queryDto.getCurCos() == null) {
        List<PowerNetDropdownEntity> dropdownList = powerNetDropdownService.list(params0);
        List<String> pointNos = new ArrayList<>();
        for (PowerNetDropdownEntity netDropdown : dropdownList) {
            if (StringUtils.isNotBlank(netDropdown.getExt1())) {
                pointNos.add(netDropdown.getExt1());
            }
        }
        if (StringUtils.isBlank(queryDto.getNodeCode()) || queryDto.getCurDemand() == null) {
            log.info("查询当前值");
            Map<String, Object> pointsRealValue = new HashMap<>();
            if (!CollectionUtils.isEmpty(points)) {
                pointsRealValue = dataPointApi.queryPointsRealValue(points);
            if (!CollectionUtils.isEmpty(pointNos)) {
                pointsRealValue = dataPointApi.queryPointsRealValue(pointNos);
            }
            for (PowerNetDropdownEntity netDropdown : list) {
                PowerNetDropdownDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerNetDropdownDTO.class);
                BigDecimal curCos = BigDecimal.ZERO;
                if (pointsRealValue.get(netDropdown.getCurCos()) != null) {
                    curCos = new BigDecimal(pointsRealValue.get(netDropdown.getCurCos()).toString());
            for (PowerNetDropdownEntity netDropdown : dropdownList) {
                PowerDemandQueryRespDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerDemandQueryRespDTO.class);
                BigDecimal demand = null;
                if (pointsRealValue.get(netDropdown.getExt1()) != null) {
                    demand = new BigDecimal(pointsRealValue.get(netDropdown.getExt1()).toString());
                }
                dto.setCurCos(curCos);
                dto.setCurDemand(demand);
                dto.setDataTime(calendar.getTime());
                result.add(dto);
            }
        } else {
@@ -643,19 +661,7 @@
                return success(result);
            }
            ApiPointsValueQueryDTO valueQueryDTO = new ApiPointsValueQueryDTO();
            valueQueryDTO.setPointNos(points);
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.MILLISECOND, 0);
            calendar.set(Calendar.SECOND, 0);
            Date startTime = queryDto.getStartTime();
            Date endTime = queryDto.getEndTime();
            if (endTime == null) {
                endTime = calendar.getTime();
            }
            if (startTime == null) {
                calendar.add(Calendar.DAY_OF_YEAR, -1);
                startTime = calendar.getTime();
            }
            valueQueryDTO.setPointNos(pointNos);
            valueQueryDTO.setStart(startTime);
            valueQueryDTO.setEnd(endTime);
            Map<String, List<Map<String, Object>>> pointsHisValues = dataPointApi.queryPointsHistoryValue(valueQueryDTO);
@@ -676,17 +682,24 @@
            Collections.reverse(hisValue);
            for (ApiPointValueDTO valueDTO : hisValue) {
                curValue = valueDTO;
                if ((queryDto.getCurCos().doubleValue() - valueDTO.getV()) <= 0.0001) {
                if ((queryDto.getCurDemand().doubleValue() - valueDTO.getV()) <= 0.0001) {
                    break;
                }
            }
            if (curValue == null) {
                log.info("curValue is null");
                for (PowerNetDropdownEntity netDropdown : dropdownList){
                    PowerDemandQueryRespDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerDemandQueryRespDTO.class);
                    if (dto.getNodeCode().equals(nodeCode)) {
                        dto.setCurDemand(queryDto.getCurDemand());
                    }
                    result.add(dto);
                }
                return success(result);
            }
            log.info("curValue=" + curValue);
            for (PowerNetDropdownEntity netDropdown : list) {
                PowerNetDropdownDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerNetDropdownDTO.class);
            for (PowerNetDropdownEntity netDropdown : dropdownList) {
                PowerDemandQueryRespDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerDemandQueryRespDTO.class);
                if (CollectionUtils.isEmpty(pointsHisValues.get(netDropdown.getCurCos()))) {
                    continue;
@@ -696,7 +709,8 @@
                    pointValueMap.put(item.get("time").toString(), DecimalUtil.toBigDecimal(item.get("value")));
                });
                dto.setCurCos(pointValueMap.get(DateUtils.format(curValue.getT(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)));
                dto.setCurDemand(pointValueMap.get(DateUtils.format(curValue.getT(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)));
                dto.setDataTime(curValue.getT());
                result.add(dto);
            }
        }
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerDemandQueryDTO.java
@@ -23,11 +23,8 @@
    @Schema(description = "节点编码")
    private String nodeCode;
    @Schema(description = "节点名称")
    private String nodeName;
    @Schema(description = "当前功率因数")
    private BigDecimal curCos;
    @Schema(description = "当前需量")
    private BigDecimal curDemand;
    @Schema(description = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerDemandQueryRespDTO.java
对比新文件
@@ -0,0 +1,32 @@
package com.iailab.module.ansteel.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * 需量查询结果
 *
 * @author PanZhibao
 * @Description
 * @createTime 2025年05月07日
 */
@Data
public class PowerDemandQueryRespDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @Schema(description = "节点编码")
    private String nodeCode;
    @Schema(description = "节点名称")
    private String nodeName;
    @Schema(description = "当前需量")
    private BigDecimal curDemand;
    @Schema(description = "数据时间")
    private Date dataTime;
}