| | |
| | | import com.whyc.pojo.db_param.AppParam; |
| | | import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarm; |
| | | import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmParam; |
| | | import com.whyc.pojo.db_station.BattInf; |
| | | import com.whyc.pojo.web_site.AlarmInspection; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | |
| | | private AlmAnalysisParamService almAnalysisParamService; |
| | | @Autowired |
| | | private SubTablePageInfoService subTablePageInfoService; |
| | | @Autowired |
| | | private BattInfService battInfService; |
| | | //获取电源实时告警信息 |
| | | public Response getPwrAlmReal(AlmDto almDto) { |
| | | PageHelper.startPage(almDto.getPageNum(),almDto.getPageSize()); |
| | |
| | | public Response getPwrtAlmAnalyse(AlmAnalyseDto dto) { |
| | | PageHelper .startPage(dto.getPageNum(),dto.getPageSize()); |
| | | List<PwrdevAlarm> list=mapper.getPwrtAlmAnalyse(dto); |
| | | for (PwrdevAlarm pwrAlm:list) { |
| | | pwrAlm.setAlmName(PowerAlarmEnum.getValue(pwrAlm.getAlmId())); |
| | | //查询电源下所有的电池组id |
| | | List<BattInf> binfList = battInfService.getBattgroupIdListByPowerId(pwrAlm.getPowerId()); |
| | | pwrAlm.setBinfList(binfList); |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"电源告警分析"); |
| | | } |
| | | //预警分析管理-电源主属性和分析属性 |
| | | public Response getPwrHisRealInAlm(Integer powerId, String startTime, Integer almId,Integer intervalTime) throws ParseException, InterruptedException { |
| | | //获取告警almId对应的分析配置属性值 |
| | | AlmAnalysisParam almAnalysisParam= almAnalysisParamService.getAnalysisParam(almId); |
| | | List<PwrdevHistorydataId> dataList = new LinkedList<>(); |
| | | Integer cycleTime=0; |
| | | //获取预警分析周期阈值 |
| | | if(intervalTime==null){ |
| | | AppParam appParam = appParamService.getAlarmAnalysisCycle(); |
| | | cycleTime=appParam.getParamValue().intValue(); |
| | | }else{ |
| | | cycleTime=intervalTime; |
| | | } |
| | | Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(startTime,1),cycleTime*(-1)); |
| | | //获取cyscleDate到现在所有的历史实时数据 |
| | | List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date()); |
| | | ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(monthTimeList.size()); |
| | | for (int i = 0; i < monthTimeList.size(); i++) { |
| | | int finalI = i; |
| | | pool.execute(() -> { |
| | | int finalII = finalI; |
| | | PwrdevHistorydataId pwrHis = new PwrdevHistorydataId(); |
| | | pwrHis.setRecordDatetime(monthTimeList.get(finalII).get(0)); |
| | | pwrHis.setRecordDatetime1(monthTimeList.get(finalII).get(1)); |
| | | String table = powerId + "_" + ThreadLocalUtil.format(pwrHis.getRecordDatetime(),2); |
| | | pwrHis.setTableName(table);//表名时间格式部分 |
| | | //判断表是否存在 |
| | | int tableNum = subTablePageInfoService.judgeTable_pwrhis(table); |
| | | List<PwrdevHistorydataId> list = new ArrayList(); |
| | | if (tableNum > 0) { |
| | | list = subTablePageInfoService.getPwrHisRealInAlm(pwrHis); |
| | | } |
| | | dataList.addAll(list); |
| | | latch.countDown(); |
| | | }); |
| | | sleep(200); |
| | | } |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrdevHistorydataId::getRecordDatetime)).collect(Collectors.toList()); |
| | | return new Response().setIII(1,true, dataListSorted,almAnalysisParam,"预警分析管理-电源主属性和分析属性"); |
| | | //查看当前是否存在交流停电告警 |
| | | public Integer judge3100014(Integer powerId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.eq("alm_id",PowerAlarmEnum.ALARM_3100014); |
| | | wrapper.last("limit 1"); |
| | | PwrdevAlarm alm=mapper.selectOne( wrapper); |
| | | return alm!=null?1:0; |
| | | } |
| | | } |