From 197e9b0008e8f2a5dd0e903d8bcccbc550305544 Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期一, 24 三月 2025 16:56:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java | 104 +++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 82 insertions(+), 22 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java index aea343c..b4b3cfa 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java @@ -25,6 +25,7 @@ import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; import com.iailab.module.model.mcs.pre.service.*; import com.iailab.module.model.mcs.pre.vo.MmItemOutputRespVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigSaveReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; @@ -78,6 +79,9 @@ private MmItemResultJsonService mmItemResultJsonService; @Autowired + private StAdjustResultService stAdjustResultService; + + @Autowired private ChartService chartService; @Autowired @@ -113,7 +117,8 @@ @Autowired private StScheduleModelSettingService stScheduleModelSettingService; - + @Autowired + private StAdjustConfigService stAdjustConfigService; private int HOUR_MINS = 60; @Override @@ -194,6 +199,7 @@ Calendar calendar = Calendar.getInstance(); calendar.setTime(predictTime); calendar.add(Calendar.HOUR_OF_DAY, 1); + calendar.add(Calendar.MINUTE, 1); endTime = calendar.getTime(); } @@ -212,7 +218,10 @@ viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime)); viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - viewDto.setCurData(mmItemResultJsonService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, 3)); + viewDto.setCurData(mmItemResultJsonService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); + // 模拟调整曲线 + viewDto.setAdjData(stAdjustResultService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); + List<Double> values = new ArrayList<>(); if (!CollectionUtils.isEmpty(viewDto.getRealData())) { List<Double> hisValues = new ArrayList<>(); @@ -331,6 +340,8 @@ } viewDto.setCumulantPreData(mmItemResultService.getData(out.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); } + // 调整预测值 + viewDto.setAdjData(stAdjustResultService.getData(out.getId(),predictItem.getLastTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); viewMap.put(out.getResultName(), viewDto); } @@ -341,6 +352,7 @@ result.setViewMap(viewMap); return result; } + @Override public PreDataSingleChartRespVO getPreDataSingleChart(PreDataSingleChartReqVO reqVO) { @@ -394,7 +406,9 @@ } else { dataView.setRealData(new ArrayList<>()); } - dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat)); + dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat, 3)); + // 调整预测值 + dataView.setAdjData(stAdjustResultService.getData(outPut.getId(),predictTime,timeFormat)); dataView.setLineType(lineType.getCode()); switch (lineType) { case TN: @@ -407,6 +421,19 @@ default: break; } + + //处理预测累计 + if (outPut.getIscumulant() != null && outPut.getIscumulant() == 1) { + /*if (StringUtils.isNotBlank(outPut.getCumulpoint())) { + dataView.setCumulantRealData(getHisData(outPut.getCumulpoint(), startTime, endTime)); + }*/ + List<Object[]> cumulantPreList = mmItemResultService.getData(outPut.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); + dataView.setCumulantPreData(cumulantPreList); + if (!CollectionUtils.isEmpty(cumulantPreList)) { + dataView.setCumulantPreLast(new BigDecimal(cumulantPreList.get(cumulantPreList.size() - 1)[1].toString()).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + if (!CollectionUtils.isEmpty(dataView.getRealData())) { Object[] rdo = dataView.getRealData().get(dataView.getRealData().size() - 1); dataView.setCurrValue(new BigDecimal(rdo[1].toString())); @@ -424,7 +451,8 @@ String alarmObj = chartParams.get(CommonConstant.ALARM_OBJ); if (StringUtils.isNotBlank(alarmObj)) { - List<AlarmMessageRespDTO> alarmList = ConvertUtils.sourceToTarget(mmPredictAlarmMessageService.getList(alarmObj, predictTime), AlarmMessageRespDTO.class); + String alarmTitle = chartParams.get(CommonConstant.ALARM_TITLE); + List<AlarmMessageRespDTO> alarmList = ConvertUtils.sourceToTarget(mmPredictAlarmMessageService.getList(alarmObj, predictTime, alarmTitle), AlarmMessageRespDTO.class); dataView.setAlarmList(alarmList); if (CollectionUtils.isEmpty(alarmList)) { dataView.setAlarmMessage("暂无预警信息"); @@ -552,7 +580,7 @@ valueDTOS.forEach(item -> { Object[] values = new Object[2]; values[0] = DateUtils.format(item.getT(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); - values[1] = new BigDecimal(item.getV()).setScale(2, BigDecimal.ROUND_HALF_UP); + values[1] = new BigDecimal(item.getV()).setScale(3, BigDecimal.ROUND_HALF_UP); result.add(values); }); return result; @@ -581,7 +609,7 @@ valueDTOS.forEach(item -> { Object[] values = new Object[2]; values[0] = DateUtils.format(item.getT(), timeFormat); - values[1] = new BigDecimal(item.getV()).setScale(2, BigDecimal.ROUND_HALF_UP); + values[1] = new BigDecimal(item.getV()).setScale(3, BigDecimal.ROUND_HALF_UP); result.add(values); }); return result; @@ -708,9 +736,15 @@ result.put(key, BigDecimal.ZERO); } MmItemOutputEntity outPut = mmItemOutputService.getByItemid(predictItem.getId(), itemNo[1], itemNo[2]); - + String outputId = outPut.getId(); + // 判断是否有第五个参数,如果有第5个参数为1,则取累计值 + if (itemNo.length >= 5){ + if (StringUtils.isNotBlank(itemNo[4]) && "1".equals(itemNo[4])){ + outputId = outPut.getId() + CommonDict.CUMULANT_SUFFIX; + } + } Date predictTime = predictItem.getLastTime(); - List<Object[]> curData = mmItemResultJsonService.getData(outPut.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); + List<Object[]> curData = mmItemResultJsonService.getData(outputId, predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); if(CollectionUtils.isEmpty(curData)) { result.put(key, BigDecimal.ZERO); } else { @@ -801,20 +835,46 @@ return true; } - /** - * 计算功率因数 p²/(根号:p²+Q²) - **/ - public Double calculateCos(Double PValue,Double QValue) { - // 绝对值 - PValue = Math.abs(PValue); - QValue = Math.abs(QValue); - //PValue [0,0.001] 直接判断为关闭返回0 - if (PValue >= 0 && PValue <= 0.001) { - return 0.0; - }else { - BigDecimal result = new BigDecimal(PValue).divide(BigDecimal.valueOf(Math.sqrt(Math.pow(PValue, 2) + Math.pow(QValue, 2))), 2, BigDecimal.ROUND_HALF_UP); - return result.doubleValue(); - } + @Override + public Boolean updateAlarmConfig(String alarmObj,String upperLimit,String lowerLimit) { + MmPredictAlarmConfigSaveReqVO reqVO = new MmPredictAlarmConfigSaveReqVO(); + reqVO.setAlarmObj(alarmObj); + reqVO.setUpperLimit(BigDecimal.valueOf(Double.parseDouble(upperLimit))); + reqVO.setLowerLimit(BigDecimal.valueOf(Double.parseDouble(lowerLimit))); + mmPredictAlarmConfigService.updateByAlarmObj(reqVO); + return true; + } + + @Override + public Boolean updateChartParam(ChartDTO chartDTO) { + ChartDTO oldChartDTO = chartService.getChartByChartCode(chartDTO.getChartCode()); + List<ChartParamDTO> chartParams = chartDTO.getChartParams(); + chartParams.forEach(item -> { + item.setChartId(oldChartDTO.getId()); + }); + chartParamService.updateByChartIdAndParamCode(chartParams); + return true; + } + + @Override + public MmItemOutputDTO getItemOutputByItemid(String itemid, String resultstr, String resultIndex) { + return ConvertUtils.sourceToTarget(mmItemOutputService.getByItemid(itemid,resultstr,resultIndex),MmItemOutputDTO.class); + } + + @Override + public List<Object[]> getItemResult(PreItemResultReqVO reqVO) { + + return mmItemResultService.getData(reqVO.getOutputid(),reqVO.getStartTime(),reqVO.getEndTime(),reqVO.getTimeFormat()); + } + + @Override + public PredictItemVO getPredictItemByItemNo(String itemNo) { + return ConvertUtils.sourceToTarget(mmPredictItemService.getItemByItemNo(itemNo),PredictItemVO.class); + } + + @Override + public List<Object[]> getItemResultLastPoint(PreItemResultReqVO reqVO) { + return mmItemResultLastPointService.getData(reqVO.getOutputid(),reqVO.getStartTime(),reqVO.getEndTime(),reqVO.getTimeFormat()); } private Date[] calResultTime(ItemVO predictItem, Date startTimeReq, Date endTimeReq, int lengthLeft, int lengthRight) { -- Gitblit v1.9.3