| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; |
| | | import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; |
| | | import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; |
| | | import com.iailab.module.model.api.mdk.MdkApi; |
| | |
| | | saveScheduleSuggest("润忠调整建议", runAdvice, scheduleObj, scheduleTime); |
| | | }*/ |
| | | |
| | | logger.info("adviceValues=" + entry.getValue().getResult().get("adviceValues")); |
| | | List<BigDecimal> adviceValues = new ArrayList<>(); |
| | | JSONArray ja0 = JSONArray.parseArray(entry.getValue().getResult().get("adviceValues").toString()); |
| | | JSONArray ja1 = ja0.getJSONArray(0); |
| | | for(int i = 0; i < ja1.size(); i++) { |
| | | adviceValues.add(new BigDecimal(ja1.get(i).toString())); |
| | | } |
| | | logger.info("adviceValues=" + JSONArray.toJSONString(adviceValues)); |
| | | BigDecimal adviceValues = new BigDecimal(entry.getValue().getResult().get("adviceValues").toString()); |
| | | logger.info("各制氧机组建议 adviceValues=" + adviceValues); |
| | | |
| | | |
| | | String advice = entry.getValue().getResult().get("advice").toString(); |
| | | if(!advice.contains("压力正常")){ |
| | | saveScheduleSuggest("各制氧机组建议", advice, scheduleObj, scheduleTime, adviceValues.get(0), scheduleScheme.getAdjustRate()); |
| | | if(adviceValues.compareTo(BigDecimal.ZERO) != 0){ |
| | | saveScheduleSuggest("各制氧机组建议", advice, scheduleObj, scheduleTime, adviceValues, scheduleScheme.getAdjustRate()); |
| | | } |
| | | |
| | | } else if (entry.getKey().equals(CODE01)) { |
| | | StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE05); |
| | | StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE01); |
| | | String scheduleObj = scheduleScheme.getScheduleObj(); |
| | | |
| | | BigDecimal adviceValues = new BigDecimal(entry.getValue().getResult().get("adviceValues").toString()); |
| | | logger.info("氮气预警 adviceValues=" + adviceValues); |
| | | |
| | | String advice = entry.getValue().getResult().get("advice").toString(); |
| | | if(!"压力正常".equals(advice)){ |
| | | saveScheduleSuggest("氮气预警", advice, scheduleObj, scheduleTime); |
| | | if(adviceValues.compareTo(BigDecimal.ZERO) != 0){ |
| | | saveAlarmMessage("氮气预警", advice, scheduleObj, scheduleTime,adviceValues,scheduleScheme.getAdjustRate()); |
| | | } |
| | | } |
| | | } |
| | |
| | | suggest.setSort(0); |
| | | mcsApi.createScheduleSuggest(suggest); |
| | | } |
| | | private void saveAlarmMessage(String title, String content, String scheduleObj, Date scheduleTime, BigDecimal adjustValue, int adjustRate) { |
| | | if (StringUtils.isBlank(content)) { |
| | | logger.info(title + "预警值为空,不产生预警"); |
| | | return; |
| | | } |
| | | if (adjustValue == null || adjustValue.doubleValue() == 0) { |
| | | logger.info(title + "预警值为空,不产生预警"); |
| | | return; |
| | | } |
| | | if (gasAdjustMode.containsKey(title) && gasAdjustMode.get(title).equals(adjustValue.compareTo(BigDecimal.ZERO)) && |
| | | gasLastSugTime.containsKey(title) && (scheduleTime.getTime() - gasLastSugTime.get(title).getTime() <= Integer.valueOf(adjustRate).longValue() * 60 * 1000)) { |
| | | logger.info("预警在有效期内"); |
| | | return; |
| | | } |
| | | gasAdjustMode.put(title, adjustValue.compareTo(BigDecimal.ZERO)); |
| | | gasLastSugTime.put(title, scheduleTime); |
| | | |
| | | AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); |
| | | alarm.setTitle(title); |
| | | alarm.setContent(content); |
| | | alarm.setAlarmObj(scheduleObj); |
| | | alarm.setAlarmType(adjustValue.compareTo(BigDecimal.ZERO) > 0 ? "超上限" : "超下限"); |
| | | alarm.setAlarmTime(scheduleTime); |
| | | mcsApi.createAlarmMessage(alarm); |
| | | } |
| | | } |