| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.whyc.constant.PwrCapperformanceEnum; |
| | | import com.whyc.dto.Real.CompareDto; |
| | | import com.whyc.dto.Real.PwrHisRealAcInDto; |
| | | import com.whyc.dto.Real.PwrHisRealDcoutInDto; |
| | |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.db_data_history.BattRealdataId; |
| | | import com.whyc.pojo.db_data_history.PwrdevHistorydataId; |
| | | import com.whyc.pojo.db_param.AppParam; |
| | | import com.whyc.pojo.db_param.ApptimeParam; |
| | | import com.whyc.pojo.db_param.PowerPropertyParam; |
| | | import com.whyc.pojo.db_station.PowerInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.lang.reflect.Field; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | |
| | | |
| | | @Autowired |
| | | private PowerInfService powerInfService; |
| | | |
| | | @Autowired |
| | | private AppParamService appParamService; |
| | | |
| | | @Autowired |
| | | private ApptimeParamService apptimeParamService; |
| | | |
| | | @Autowired |
| | | private PowerPropertyParamService propertyParamService; |
| | | |
| | | //系统概览获取半小时交流输入统计 |
| | | public Response getHalfHourPwrHisAcinData(Integer powerId,Integer granularity) { |
| | |
| | | return new Response().setIII(1,datalist.size()>0,datalist,modelCfg,"获取半小时内直流输出统计"); |
| | | } |
| | | //1.2.7优良电源统计上一季度的电源某一属性和参数阈值超过的次数 |
| | | public Map<String,Integer> getPwrQuarter7(Integer powerId, Map<String,Float> paramValue) { |
| | | public Integer getPwrQuarter7(Integer powerId,Integer powerType) throws NoSuchFieldException, IllegalAccessException { |
| | | Map<String,Integer> map=new HashMap<>(); |
| | | map.put("acin1Vola",0); |
| | | map.put("acoutVola",0); |
| | | map.put("dcoutVol",0); |
| | | map.put("dcoutCurr",0); |
| | | List<String> datelist = ActionUtil.getLastQuarterYearMonths(); |
| | | //获取优良电源性能统计在平台上的时间参数设置表 |
| | | ApptimeParam apptimeParam=apptimeParamService.getPwrPerformanceStrartTime(powerId); |
| | | //获取指定时间到当前时间一共多少月的集合 |
| | | List<String> datelist=ActionUtil.getDateListBetweenDates(apptimeParam.getParamValue(), new Date()); |
| | | //获取电源优良判断的标准参数值 |
| | | List<PowerPropertyParam> paramList=propertyParamService.getPwrStandardParam(powerType); |
| | | /*Map<String,Float> paramValues=new HashMap<>(); |
| | | for (PowerPropertyParam param : paramList) { |
| | | paramValues.put(param.getPropertyName()+"_upper", param.getBasisVal()*param.getAlarmLimithUpper()); |
| | | paramValues.put(param.getPropertyName()+"_lower", param.getBasisVal()*param.getAlarmLimitlLower()); |
| | | map.put(param.getPropertyName(), 0); |
| | | }*/ |
| | | for (int i=0;i<datelist.size();i++) { |
| | | String date=datelist.get(i); |
| | | String tableName ="db_data_history.tb_pwrdev_historydata_"+powerId+"_"+date; |
| | |
| | | List<QuarterPwr7Res> datalist=subTablePageInfoService.getPwrQuarter7(tableName); |
| | | // 遍历 dataList 并比较属性值 |
| | | for (QuarterPwr7Res data : datalist) { |
| | | if (data.getAcin1Vola() > paramValue.get("acin1Vola")) { |
| | | map.put("acin1Vola", map.get("acin1Vola") + 1); |
| | | /*if(paramValues.get("acin1_vola_upper")!=null){ |
| | | if ((data.getAcin1Vola() > paramValues.get("acin1_vola_upper"))||(data.getAcin1Vola() < paramValues.get("acin1_vola_lower"))) { |
| | | map.put("acin1_vola", map.get("acin1_vola") + 1); |
| | | } |
| | | } |
| | | if (data.getAcoutVola() > paramValue.get("acoutVola")) { |
| | | map.put("acoutVola", map.get("acoutVola") + 1); |
| | | if(paramValues.get("acout_curra_upper")!=null) { |
| | | if ((data.getAcoutCurra() > paramValues.get("acout_curra_upper")) || (data.getAcoutCurra() < paramValues.get("acout_curra_lower"))) { |
| | | map.put("acout_curra", map.get("acout_curra") + 1); |
| | | } |
| | | } |
| | | if (data.getDcoutVol() > paramValue.get("dcoutVol")) { |
| | | map.put("dcoutVol", map.get("dcoutVol") + 1); |
| | | if(paramValues.get("dcout_vol_upper")!=null) { |
| | | if ((data.getDcoutVol() > paramValues.get("dcout_vol_upper")) || (data.getDcoutVol() < paramValues.get("dcout_vo_lower"))) { |
| | | map.put("dcout_vol", map.get("dcout_vol") + 1); |
| | | } |
| | | } |
| | | if (data.getDcoutCurr() > paramValue.get("dcoutCurr")) { |
| | | map.put("dcoutCurr", map.get("dcoutCurr") + 1); |
| | | if(paramValues.get("dcout_curr_upper")!=null) { |
| | | if ((data.getDcoutCurr() > paramValues.get("dcout_curr_upper")) || (data.getDcoutCurr() < paramValues.get("dcout_curr_lower"))) { |
| | | map.put("dcout_curr", map.get("dcout_curr") + 1); |
| | | } |
| | | }*/ |
| | | for (int j=0;j<paramList.size();j++) { |
| | | PowerPropertyParam param = paramList.get(j); |
| | | String propertyName = ActionUtil.toCamelCase(param.getPropertyName()); |
| | | Field field = QuarterPwr7Res.class.getDeclaredField(propertyName); |
| | | field.setAccessible(true); // 如果字段是私有的,需要设置为可访问 |
| | | Float value = (Float) field.get(data); |
| | | if ((value > (param.getBasisVal()*param.getAlarmLimithUpper()))||(value <(param.getBasisVal()*param.getAlarmLimitlLower()))) { |
| | | map.put(param.getPropertyName(), map.get(param.getPropertyName())==null?0:map.get(param.getPropertyName())+ 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return map; |
| | | //判断优良电源性能 |
| | | int pwrPerformence=judgePwrPerformence(map); |
| | | return pwrPerformence; |
| | | } |
| | | //判断优良电源性能 |
| | | private Integer judgePwrPerformence(Map<String,Integer> map){ |
| | | //获取apps中优良电源判断参数 |
| | | List<AppParam> appParamList=appParamService.getPwrPerformenceParam(); |
| | | Float excellentVal=0f; |
| | | Float commonlyVal=0f; |
| | | Float warningVal=0f; |
| | | for (AppParam appParam : appParamList) { |
| | | if(appParam.getParamNamePsx().equals("power_excellent_val")){ |
| | | excellentVal=appParam.getParamValue(); |
| | | } |
| | | if(appParam.getParamNamePsx().equals("power_commonly_val")){ |
| | | commonlyVal=appParam.getParamValue(); |
| | | } |
| | | if(appParam.getParamNamePsx().equals("power_warning_val")){ |
| | | warningVal=appParam.getParamValue(); |
| | | } |
| | | } |
| | | Integer performance = PwrCapperformanceEnum.PWRSTATE_1.getStateId(); // 初始化为最优等级 |
| | | for (Map.Entry<String, Integer> entry : map.entrySet()) { |
| | | Integer level = evaluateValue(entry.getValue(), excellentVal, commonlyVal, warningVal); |
| | | // 根据等级排序确定当前是否是最差等级 |
| | | if (PwrCapperformanceEnum.PWRSTATE_4.getStateId()==level) { |
| | | performance = PwrCapperformanceEnum.PWRSTATE_4.getStateId(); |
| | | return performance; // 一旦出现差,直接返回 |
| | | } else if (PwrCapperformanceEnum.PWRSTATE_3.getStateId()==level && PwrCapperformanceEnum.PWRSTATE_4.getStateId()!=performance) { |
| | | performance = PwrCapperformanceEnum.PWRSTATE_3.getStateId(); |
| | | } else if (PwrCapperformanceEnum.PWRSTATE_2.getStateId()==level &&(PwrCapperformanceEnum.PWRSTATE_3.getStateId()!=performance||PwrCapperformanceEnum.PWRSTATE_4.getStateId()!=performance)) { |
| | | performance = PwrCapperformanceEnum.PWRSTATE_2.getStateId(); |
| | | } |
| | | } |
| | | return performance; |
| | | } |
| | | // 判断单个值的等级 |
| | | public Integer evaluateValue(Integer value, Float excellentVal, Float commonlyVal, Float warningVal) { |
| | | if (value <= excellentVal) { |
| | | return PwrCapperformanceEnum.PWRSTATE_1.getStateId(); |
| | | } else if (value <= commonlyVal&&value > excellentVal) { |
| | | return PwrCapperformanceEnum.PWRSTATE_2.getStateId(); |
| | | } else if (value <= warningVal&&value > commonlyVal) { |
| | | return PwrCapperformanceEnum.PWRSTATE_3.getStateId(); |
| | | } else { |
| | | return PwrCapperformanceEnum.PWRSTATE_4.getStateId(); |
| | | } |
| | | } |
| | | } |