鞍钢鲅鱼圈能源管控系统后端代码
liriming
4 天以前 00762deb0cb1350c83bb2c5f5f68ca1919ddb45e
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
package com.iailab.module.ansteel.plant.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.module.ansteel.plant.dao.PlantIndexConfDao;
import com.iailab.module.ansteel.plant.entity.PlantIndexConfEntity;
import com.iailab.module.ansteel.plant.service.PlantIndexConfService;
import com.iailab.module.ansteel.plant.vo.PlantIndexDataVO;
import com.iailab.module.data.api.point.DataPointApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * @description:
 * @author: dzd
 * @date: 2025/6/16 13:57
 **/
@Slf4j
@Service
public class PlantIndexConfServiceImpl implements PlantIndexConfService {
 
    @Resource
    private PlantIndexConfDao plantIndexConfDao;
    @Resource
    private DataPointApi dataPointApi;
 
    private final BigDecimal badValue = new BigDecimal(-2);
 
    @Override
    public List<PlantIndexDataVO> getPlantIndexData(String businessType) {
        QueryWrapper<PlantIndexConfEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("business_type",businessType);
        List<PlantIndexConfEntity> PlantIndexConfList = plantIndexConfDao.selectList(queryWrapper);
        // 筛选DATAPOINT一次性查询出全部
        List<String> pointNos = PlantIndexConfList.stream().flatMap(e -> Stream.of(e.getIndAvg(),e.getIndTheory(),e.getIndOptimal(),e.getIndReal(),e.getIndDeviationValue(),e.getIndDeviationRate(),e.getIndPrevious())).collect(Collectors.toList());
        Map<String, Object> pointValues = new HashMap<>();
        if (!CollectionUtils.isEmpty(pointNos)) {
            pointValues = dataPointApi.queryPointsRealValue(pointNos);
        }
        List<PlantIndexDataVO> result = new ArrayList<>(PlantIndexConfList.size());
        for (PlantIndexConfEntity PlantIndexConf : PlantIndexConfList) {
            PlantIndexDataVO plantData = new PlantIndexDataVO();
            plantData.setType(PlantIndexConf.getIndType());
            plantData.setCode(PlantIndexConf.getIndCode());
            plantData.setName(PlantIndexConf.getIndName());
            plantData.setUnit(PlantIndexConf.getIndUnit());
            plantData.setSort(PlantIndexConf.getSort());
 
            plantData.setIndAvg(pointValues.containsKey(PlantIndexConf.getIndAvg()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndAvg()).toString()) : badValue);
            plantData.setIndTheory(pointValues.containsKey(PlantIndexConf.getIndTheory()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndTheory()).toString()) : badValue);
            plantData.setIndOptimal(pointValues.containsKey(PlantIndexConf.getIndOptimal()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndOptimal()).toString()) : badValue);
            plantData.setIndReal(pointValues.containsKey(PlantIndexConf.getIndReal()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndReal()).toString()) : badValue);
            plantData.setIndDeviationValue(pointValues.containsKey(PlantIndexConf.getIndDeviationValue()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndDeviationValue()).toString()) : badValue);
            plantData.setIndDeviationRate(pointValues.containsKey(PlantIndexConf.getIndDeviationRate()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndDeviationRate()).toString()) : badValue);
            plantData.setIndPrevious(pointValues.containsKey(PlantIndexConf.getIndPrevious()) ? new BigDecimal(pointValues.get(PlantIndexConf.getIndPrevious()).toString()) : badValue);
 
            result.add(plantData);
        }
        return result;
    }
}