鞍钢鲅鱼圈能源管控系统后端代码
dongyukun
2025-05-20 60ebe311e7e8bec2aca4d46ce1a8018ff871446b
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -99,6 +99,10 @@
    @Autowired
    private PowerMaxdemandDetService powerMaxdemandDetService;
    public static final String VALUE = "value";
    public static final String TIME = "time";
    @GetMapping("/net-factor/list")
    @Operation(summary = "功率因数-电网拓扑")
    public CommonResult<List<PowerNetFactorDTO>> getPowerNetFactorList(@RequestParam Map<String, Object> params) {
@@ -571,47 +575,57 @@
    @GetMapping("/demand/list")
    @Operation(summary = "负荷移植-月最大需量,实测需量,有功功率")
    public CommonResult<List<PowerDemandDTO>> getPowerDemandList(@RequestParam Map<String, Object> params) {
        log.info("负荷移植-月最大需量,实测需量,有功功率");
        List<PowerDemandDTO> result = new ArrayList<>();
        List<PowerDemandEntity> list = powerDemandService.list(params);
        List<PowerDemandDTO> result = ConvertUtils.sourceToTarget(list, PowerDemandDTO.class);
        if (CollectionUtils.isEmpty(result)) {
        if (CollectionUtils.isEmpty(list)) {
            log.info("list.size=" + list.size());
            return success(result);
        }
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        Date start = calendar.getTime();
        Date end = new Date();
        for (PowerDemandDTO dto : result) {
        for (PowerDemandEntity entity : list) {
            PowerDemandDTO demandDTO = new PowerDemandDTO();
            demandDTO.setId(entity.getId());
            demandDTO.setCode(entity.getCode());
            demandDTO.setName(entity.getName());
            List<String> points = new ArrayList<>();
            if (StringUtils.isNotBlank(dto.getCurDemand())) {
                points.add(dto.getCurDemand());
            if (StringUtils.isNotBlank(entity.getCurDemand())) {
                points.add(entity.getCurDemand());
            }
            if (StringUtils.isNotBlank(dto.getActivePower())) {
                points.add(dto.getActivePower());
            if (StringUtils.isNotBlank(entity.getActivePower())) {
                points.add(entity.getActivePower());
            }
            if (!CollectionUtils.isEmpty(points)) {
                Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points);
                if (pointsRealValue.get(dto.getCurDemand()) != null) {
                    dto.setCurDemand(pointsRealValue.get(dto.getCurDemand()).toString());
                if (pointsRealValue.get(entity.getCurDemand()) != null) {
                    demandDTO.setCurDemand(new BigDecimal(pointsRealValue.get(entity.getCurDemand()).toString()));
                }
                if (pointsRealValue.get(dto.getActivePower()) != null) {
                    dto.setActivePower(pointsRealValue.get(dto.getActivePower()).toString());
                if (pointsRealValue.get(entity.getActivePower()) != null) {
                    demandDTO.setActivePower(new BigDecimal(pointsRealValue.get(entity.getActivePower()).toString()));
                }
            }
            if (!StringUtils.isEmpty(dto.getMaxDemand())) {
                Date start = calendar.getTime();
            if (!StringUtils.isEmpty(entity.getMaxDemand())) {
                ApiPointValueQueryDTO apiPointValueQueryDTO = new ApiPointValueQueryDTO();
                apiPointValueQueryDTO.setStart(start);
                apiPointValueQueryDTO.setPointNo(dto.getMaxDemand());
                Map<String, Object> maxValue = dataPointApi.queryPointMaxValue(apiPointValueQueryDTO);
                apiPointValueQueryDTO.setEnd(end);
                apiPointValueQueryDTO.setPointNo(entity.getMaxDemand());
                Map<String, Object> maxValue = dataPointApi.queryPointMaxTimeValue(apiPointValueQueryDTO);
                if (maxValue != null) {
                    dto.setMaxDemand(maxValue.get(dto.getMaxDemand()) == null ? "" : maxValue.get(dto.getMaxDemand()).toString());
                    demandDTO.setMaxDemand(new BigDecimal(maxValue.get(VALUE).toString()));
                    demandDTO.setOccurTime(DateUtils.parse( maxValue.get(TIME).toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
                }
            }
            result.add(demandDTO);
        }
        return success(result);
    }
@@ -702,6 +716,7 @@
        ApiPointValueQueryDTO queryCodeValue = new ApiPointValueQueryDTO();
        queryCodeValue.setStart(startTime);
        queryCodeValue.setEnd(endTime);
        queryCodeValue.setPointNo(entity.getCurDemand());
        List<ApiPointValueDTO> codeValueList = dataPointApi.queryPointHistoryValue(queryCodeValue);
        if (CollectionUtils.isEmpty(codeValueList)) {
            return success(result);