| | |
| | | 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_param.PowerheartParam; |
| | | import com.whyc.pojo.db_station.PowerInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class PwrdevHistorydataIdService { |
| | |
| | | @Autowired |
| | | private PowerPropertyParamService propertyParamService; |
| | | |
| | | //系统概览获取半小时交流输入统计 |
| | | public Response getHalfHourPwrHisAcinData(Integer powerId,Integer granularity) { |
| | | @Autowired |
| | | private PowerheartParamService heartService; |
| | | |
| | | //系统概览前N笔交流输入统计 |
| | | public Response getPwrHisAcinData100(Integer powerId) { |
| | | String dateTime = ActionUtil.sdfwithOutday.format(new Date()); |
| | | //获取前半个小时数据 |
| | | //获取前笔数*时间间隔 |
| | | PowerheartParam heartParam=heartService.getHeartParamByPowerId(powerId); |
| | | Integer interverCount=100*10;//默认值 |
| | | Integer granularity=10;//默认值 |
| | | if(heartParam!=null){ |
| | | interverCount=heartParam.getAcinInterverCfg()*heartParam.getAcinCountCfg(); |
| | | granularity=heartParam.getAcinInterverCfg(); |
| | | } |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 计算半小时前的时间点 |
| | | LocalDateTime halfHourAgo = now.minusMinutes(30); |
| | | // 计算笔数*时间间隔的时间点 |
| | | LocalDateTime halfHourAgo = now.minusMinutes(interverCount); |
| | | // 格式化输出 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String halfHourAgoTime=halfHourAgo.format(formatter); |
| | |
| | | return new Response().setII(1,datalist.size()>0,datalist,"获取半小时内交流输入统计"); |
| | | |
| | | } |
| | | //系统概览获取半小时直流输出统计 |
| | | public Response getHalfHourPwrHisDcoutData(Integer powerId,Integer granularity) { |
| | | //系统概览获取前N笔直流输出统计 |
| | | public Response getHalfHourPwrHisDcoutData(Integer powerId) { |
| | | String dateTime = ActionUtil.sdfwithOutday.format(new Date()); |
| | | //获取前笔数*时间间隔 |
| | | PowerheartParam heartParam=heartService.getHeartParamByPowerId(powerId); |
| | | Integer interverCount=100*10;//默认值 |
| | | Integer granularity=10;//默认值 |
| | | if(heartParam!=null){ |
| | | interverCount=heartParam.getAcinInterverCfg()*heartParam.getAcinCountCfg(); |
| | | granularity=heartParam.getAcinInterverCfg(); |
| | | } |
| | | //获取前半个小时数据 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 计算半小时前的时间点 |
| | | LocalDateTime halfHourAgo = now.minusMinutes(30); |
| | | LocalDateTime halfHourAgo = now.minusMinutes(interverCount); |
| | | // 格式化输出 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String halfHourAgoTime=halfHourAgo.format(formatter); |
| | |
| | | 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); |
| | | }*/ |
| | | List<String> propertyNameList = paramList.stream() |
| | | .map(param -> param.getPropertyName()) |
| | | .collect(Collectors.toList()); |
| | | for (int i=0;i<datelist.size();i++) { |
| | | String date=datelist.get(i); |
| | | String tableName ="db_data_history.tb_pwrdev_historydata_"+powerId+"_"+date; |
| | |
| | | if(existTableName == null){ |
| | | continue; |
| | | } |
| | | List<QuarterPwr7Res> datalist=subTablePageInfoService.getPwrQuarter7(tableName); |
| | | List<PwrdevHistorydataId> datalist=subTablePageInfoService.getPwrQuarter7(tableName,propertyNameList); |
| | | // 遍历 dataList 并比较属性值 |
| | | for (QuarterPwr7Res data : datalist) { |
| | | /*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(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(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(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 (PwrdevHistorydataId data : datalist) { |
| | | 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 field = PwrdevHistorydataId.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); |
| | | int limitNum=map.get(param.getPropertyName())==null?0:map.get(param.getPropertyName()); |
| | | map.put(param.getPropertyName(), limitNum+1); |
| | | } |
| | | } |
| | | } |