鞍钢鲅鱼圈能源管控系统后端代码
liriming
5 天以前 c79bc0566e67eabd4715d854a2306e2451983e7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.iailab.module.ansteel.plant.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.module.ansteel.plant.dao.PlantChartConfDao;
import com.iailab.module.ansteel.plant.entity.PlantChartConfEntity;
import com.iailab.module.ansteel.plant.service.PlantChartConfService;
import com.iailab.module.ansteel.plant.vo.PlantChartDataVO;
import com.iailab.module.data.api.point.DataPointApi;
import com.iailab.module.data.api.point.dto.ApiPointsValueQueryDTO;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * @description:
 * @author: lirm
 * @date: 2025/6/20 13:59
 **/
@Slf4j
@Service
public class PlantChartConfServiceImpl implements PlantChartConfService {
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    @Resource
    private PlantChartConfDao plantChartConfDao;
    @Resource
    private DataPointApi dataPointApi;
 
    @Override
    public PlantChartDataVO getPlantChartData(Map tMap) {
        PlantChartDataVO result = new PlantChartDataVO();
        if(ObjectUtils.isEmpty(tMap.get("indType")) || ObjectUtils.isEmpty(tMap.get("indCode"))){
            logger.info("输入参数为空");
            return result;
        }
        QueryWrapper<PlantChartConfEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("ind_type",tMap.get("indType"));
        queryWrapper.eq("indCode",tMap.get("indCode"));
        List<PlantChartConfEntity> plantChartConfList = plantChartConfDao.selectList(queryWrapper);
        if (CollectionUtils.isEmpty(plantChartConfList)) {
            log.info("plantChartConfList is null");
            return result;
        }
        PlantChartConfEntity plantChartConfEntity = plantChartConfList.get(0);
        // 筛选DATAPOINT一次性查询出全部
        List<String> pointNos = Stream.of(plantChartConfEntity.getIndAvg(),plantChartConfEntity.getIndTheory(),plantChartConfEntity.getIndOptimal(),plantChartConfEntity.getIndReal()).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(pointNos)) {
            ApiPointsValueQueryDTO queryDTO = new ApiPointsValueQueryDTO();
            queryDTO.setPointNos(pointNos);
            Map<String, List<Map<String, Object>>>  pointsHisValues = dataPointApi.queryPointsHistoryValue(queryDTO);
            if (CollectionUtils.isEmpty(pointsHisValues)) {
                log.info("pointsHisValues is null");
                return result;
            }
            result.setIndCode(plantChartConfEntity.getIndCode());
            result.setIndName(plantChartConfEntity.getIndName());
            result.setIndAvgHisList(pointsHisValues.get(plantChartConfEntity.getIndAvg()));
            result.setIndTheoryHisList(pointsHisValues.get(plantChartConfEntity.getIndTheory()));
            result.setIndOptimalHisList(pointsHisValues.get(plantChartConfEntity.getIndOptimal()));
            result.setIndRealHisList(pointsHisValues.get(plantChartConfEntity.getIndReal()));
            result.setIndPowerHisList(pointsHisValues.get(plantChartConfEntity.getIndPower()));
        }
        return result;
    }
}