鞍钢鲅鱼圈能源管控系统后端代码
潘志宝
2 天以前 7b576876e69f7bd6dffca135e1576264820fffbb
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.iailab.module.ansteel.api.controller.admin;
 
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.util.date.DateUtils;
import com.iailab.module.ansteel.api.dto.GasLdgCulRespDTO;
import com.iailab.module.ansteel.api.dto.PreDataViewSimpleDTO;
import com.iailab.module.ansteel.gas.service.GasPredConfService;
import com.iailab.module.ansteel.page.service.PageParamService;
import com.iailab.module.model.api.mcs.McsApi;
import com.iailab.module.model.api.mcs.dto.PreDataJsonReqVO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * 煤气接口
 *
 * @author DongYukun
 * @Description
 * @createTime 2025年05月07日
 */
@Slf4j
@RestController
@RequestMapping("/ansteel/api/gas")
public class GasController {
 
    @Autowired
    private GasPredConfService gasPredConfService;
 
    @Autowired
    private PageParamService pageParamService;
 
    @Autowired
    private McsApi mcsApi;
 
    @GetMapping("/pred-conf/list")
    @Operation(summary = "煤气预测配置")
    public CommonResult<List<PreDataViewSimpleDTO>> getGasPredConfList(@RequestParam Map<String, Object> params) {
        return CommonResult.success(gasPredConfService.list(params));
    }
 
    @GetMapping("/pred-conf/list")
    @Operation(summary = "获取转炉煤气回收消耗总量")
    public CommonResult<GasLdgCulRespDTO> getGasLdgCul(@RequestParam Map<String, Object> params) {
        GasLdgCulRespDTO result = new GasLdgCulRespDTO();
        String type = (String) params.get("type");
        String predictTime = (String) params.get("predictTime");
        if (StringUtils.isBlank(type) || StringUtils.isBlank(predictTime)) {
            return CommonResult.success(result);
        }
        PreDataJsonReqVO reqVO = new PreDataJsonReqVO();
        reqVO.setPredictTime(DateUtils.parse(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
        List<String> outputIdList = new ArrayList<>();
        String xhOut = pageParamService.getValue("iLDG_XH_" + type);
        if (StringUtils.isNotBlank(xhOut)) {
            outputIdList.add(xhOut);
        }
        String hsOut = pageParamService.getValue("iLDG_HS_" + type);
        if (StringUtils.isNotBlank(hsOut)) {
            outputIdList.add(hsOut);
        }
        reqVO.setOutputIdList(outputIdList);
        if (CollectionUtils.isEmpty(outputIdList)) {
            return CommonResult.success(result);
        }
        log.info("getPreDataCur,reqVO={}", reqVO);
        Map<String, List<Object[]>> preData = mcsApi.getPreDataCur(reqVO);
        if (CollectionUtils.isEmpty(preData)) {
            return CommonResult.success(result);
        }
        if (preData.containsKey(xhOut)) {
            List<Object[]> data = preData.get(xhOut);
            double total = 0.0;
            for (int i = 0; i < data.size(); i++) {
                Object[] obj = data.get(i);
                total = total + new BigDecimal(obj[1].toString()).doubleValue();
            }
            result.setXh(new BigDecimal(total).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
        }
        if (preData.containsKey(hsOut)) {
            List<Object[]> data = preData.get(hsOut);
            double total = 0.0;
            for (int i = 0; i < data.size(); i++) {
                Object[] obj = data.get(i);
                total = total + new BigDecimal(obj[1].toString()).doubleValue();
            }
            result.setHs(new BigDecimal(total).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
        }
 
        return CommonResult.success(result);
    }
}