| | |
| | | package com.iailab.module.ansteel.api.controller.admin; |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.ansteel.api.dto.PowerNetFactorDTO; |
| | | 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.entity.GasPredConfEntity; |
| | | import com.iailab.module.ansteel.gas.service.GasPredConfService; |
| | | import com.iailab.module.ansteel.power.entity.PowerNetFactorEntity; |
| | | 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; |
| | | |
| | |
| | | @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); |
| | | } |
| | | } |