| | |
| | | import com.iailab.module.ansteel.api.vo.PowerCapacitorHisPageReqVO; |
| | | import com.iailab.module.ansteel.api.vo.PowerMaxDemandMainPageReqVO; |
| | | import com.iailab.module.ansteel.common.constant.CommonConstant; |
| | | import com.iailab.module.ansteel.common.enums.ProcessConfDataTypeEnum; |
| | | import com.iailab.module.ansteel.common.enums.TransferTypeEnum; |
| | | import com.iailab.module.ansteel.common.utils.DecimalUtil; |
| | | import com.iailab.module.ansteel.common.utils.PowerUtil; |
| | |
| | | } |
| | | |
| | | @PostMapping("/factor-control/list") |
| | | @Operation(summary = "功率因数管控") |
| | | @Operation(summary = "功率因数调整结果查询") |
| | | public CommonResult<List<PowerFactorControlDTO>> powerFactorControlList(@RequestBody PowerFactorReqVO powerFactorReqVO) { |
| | | List<PowerFactorControlDTO> result = new ArrayList<>(); |
| | | Map<String, Object> chartMap = new HashMap<>(); |
| | | List<ChartParamDTO> chartList = mcsApi.getChartParamList(CommonConstant.POWER_CODE); |
| | | chartList.forEach(item -> { |
| | |
| | | dto.setScheduleCode("AnsteelOffPowerAC"); |
| | | Map<String, String> dynamicSettings = new HashMap<>(); |
| | | dynamicSettings.put("option_param", JSONArray.toJSONString(contentListNew.stream().toArray(Integer[]::new))); |
| | | dynamicSettings.put("cos_param", JSONArray.toJSONString(powerFactorReqVO.getAdjustValueList().stream().toArray(String[]::new))); |
| | | List<String> cosParam = new ArrayList<>(); |
| | | cosParam.add(powerFactorReqVO.getAdjustValueCcpp().toString()); |
| | | cosParam.add(powerFactorReqVO.getAdjustValue135().toString()); |
| | | cosParam.add(powerFactorReqVO.getAdjustValueTrt().toString()); |
| | | dynamicSettings.put("cos_param", JSONArray.toJSONString(cosParam)); |
| | | dto.setDynamicSettings(dynamicSettings); |
| | | |
| | | log.info("调度方案开始执行," + JSONObject.toJSONString(dto)); |
| | | MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
| | | log.info("调度方案执行完成," + mdkScheduleRespDTO); |
| | | // MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
| | | //log.info("调度方案执行完成," + mdkScheduleRespDTO); |
| | | |
| | | String statusCode = mdkScheduleRespDTO.getStatusCode(); |
| | | /*String statusCode = mdkScheduleRespDTO.getStatusCode(); |
| | | if (!CommonConstant.MDK_STATUS_100.equals(statusCode)) { |
| | | log.info("statusCode=" + statusCode); |
| | | return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), "工序异常,无计算结果"); |
| | | } |
| | | |
| | | Map<String, Object> data = mdkScheduleRespDTO.getResult(); |
| | | List<String> adjustCosList = Arrays.asList(data.get("adjust_cos").toString().split(","));//管控结果 |
| | | Map<String, Object> data = mdkScheduleRespDTO.getResult();*/ |
| | | // 调整后的功率因数 |
| | | // List<String> adjustCosList = Arrays.asList(data.get("adjust_cos").toString().split(",")); |
| | | String fakeData = "[0.39,0.98,0.98,0 91,1.0,0.93,0.86,0.89,0.98,0.9,0.97,0.89,0.84,0.91]"; |
| | | List<BigDecimal> adjustCosList = JSONArray.parseArray(fakeData, BigDecimal.class); |
| | | |
| | | PowerFactorControlDTO powerFactorControlDTO = new PowerFactorControlDTO(); |
| | | List<PowerFactorControlDTO> result = new ArrayList<>(); |
| | | List<PowerFactorControlDTO> list = powerFactorControlService.list(powerFactorControlDTO); |
| | | // 无功管控结果 |
| | | BigDecimal back_wugong_buchang = new BigDecimal(36.92); |
| | | adjustCosList.add(back_wugong_buchang); |
| | | |
| | | Map<Integer, BigDecimal> adjustCosMap = new HashMap<>(); |
| | | for (int i = 1; i <= adjustCosList.size(); i++) { |
| | | adjustCosMap.put(i, adjustCosList.get(i)); |
| | | } |
| | | |
| | | List<PowerFactorControlEntity> list = powerFactorControlService.list(); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | log.info("list is empty"); |
| | | return success(result); |
| | | } |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | | PowerFactorControlDTO controlDTO = list.get(i); |
| | | for (int i = 1; i <= list.size(); i++) { |
| | | PowerFactorControlEntity entity = list.get(i); |
| | | PowerFactorControlDTO controlDTO = new PowerFactorControlDTO(); |
| | | controlDTO.setName(entity.getName()); |
| | | controlDTO.setSort(entity.getSort()); |
| | | try { |
| | | PredictLastValueReqVO reqVO = new PredictLastValueReqVO(); |
| | | reqVO.setPredictTime(calendar.getTime()); |
| | | List<String[]> itemNos = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(controlDTO.getPredResult())) { |
| | | itemNos.add(controlDTO.getPredResult().split(",")); |
| | | // 预测结果 |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(entity.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> params1 = new ArrayList<>(); |
| | | params1.add(entity.getPredResult()); |
| | | Map<String, Object> pointValues = dataPointApi.queryPointsRealValue(params1); |
| | | if (!CollectionUtils.isEmpty(pointValues)) { |
| | | controlDTO.setPredResult(DecimalUtil.toBigDecimal(pointValues.get(entity.getPredResult()))); |
| | | } |
| | | break; |
| | | case PREDICTVALUE: |
| | | PredictLastValueReqVO reqVO = new PredictLastValueReqVO(); |
| | | calendar.set(calendar.HOUR_OF_DAY, 0); |
| | | reqVO.setPredictTime(calendar.getTime()); |
| | | List<String[]> itemNos = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(entity.getPredResult())) { |
| | | itemNos.add(entity.getPredResult().split(",")); |
| | | } |
| | | reqVO.setItemNos(itemNos); |
| | | Map<String, BigDecimal> preValues = mcsApi.getPredictValueByTime(reqVO); |
| | | if (preValues.get(entity.getPredResult()) != null) { |
| | | controlDTO.setPredResult(new BigDecimal(preValues.get(entity.getPredResult()).toString())); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (!CollectionUtils.isEmpty(itemNos)) { |
| | | reqVO.setItemNos(itemNos); |
| | | log.info("reqVO=" + JSONObject.toJSONString(reqVO)); |
| | | Map<String, BigDecimal> preValues = mcsApi.getPredictValueByTime(reqVO); |
| | | if (!ObjectUtils.isEmpty(preValues.get(controlDTO.getPredResult()))) { |
| | | controlDTO.setPredResult(preValues.get(controlDTO.getPredResult()).toString()); |
| | | } |
| | | } |
| | | controlDTO.setAdjustCos(adjustCosList.get(i)); |
| | | |
| | | // 管控结果 |
| | | if (adjustCosMap.containsKey(entity.getCosIndex())) { |
| | | controlDTO.setAdjustCos(adjustCosMap.get(entity.getCosIndex())); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.info(controlDTO.getName() + "获取预测值异常," + ex.getMessage()); |
| | | ex.printStackTrace(); |
| | | } |
| | | result.add(controlDTO); |
| | | } |
| | | |
| | | List<String> points = new ArrayList<>(); |
| | | points.add(pointNo); |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | |
| | | PowerFactorControlDTO controlDTO = new PowerFactorControlDTO(); |
| | | controlDTO.setName("望铁关口最大无功倒送量"); |
| | | controlDTO.setPredResult(pointsRealValue.get(pointNo).toString()); |
| | | controlDTO.setAdjustCos(data.get("back_wugong_buchang").toString()); |
| | | controlDTO.setSort(list.size() + 1); |
| | | result.add(controlDTO); |
| | | log.info("result===" + JSONObject.toJSONString(result)); |
| | | return success(result); |
| | | } |