| | |
| | | import com.whyc.mapper.CommonMapper; |
| | | |
| | | import com.whyc.pojo.db_data_history.BattRealdataId; |
| | | import com.whyc.pojo.db_param.AlmAnalysisParam; |
| | | import com.whyc.pojo.db_param.AppParam; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | |
| | | |
| | | @Autowired |
| | | private BattInfService binfService; |
| | | |
| | | @Autowired |
| | | private AlmAnalysisParamService almAnalysisParamService; |
| | | |
| | | @Autowired |
| | | private AppParamService appParamService; |
| | | |
| | | |
| | | //获取电池组最近一季度的单体数据 |
| | |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList()); |
| | | return new Response().set(1, dataListSorted); |
| | | } |
| | | //电池告警点击具体告警信息查看从告警开始时间到现在的历史实时数据 |
| | | public Response getBattHisRealInAlm(Integer battgroupId, String startTime, Integer almId) throws ParseException, InterruptedException { |
| | | //获取告警almId对应的分析配置属性值 |
| | | AlmAnalysisParam almAnalysisParam= almAnalysisParamService.getAnalysisParam(almId); |
| | | List<RealDateDTO> dataList = new LinkedList<>(); |
| | | //获取预警分析周期阈值 |
| | | AppParam appParam = appParamService.getAlarmAnalysisCycle(); |
| | | Integer cycleTime=appParam.getParamValue().intValue(); |
| | | 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; |
| | | BattRealdataId realdata = new BattRealdataId(); |
| | | realdata.setRecordTime(monthTimeList.get(finalII).get(0)); |
| | | realdata.setRecordTime1(monthTimeList.get(finalII).get(1)); |
| | | String table = battgroupId + "_" + ThreadLocalUtil.format(realdata.getRecordTime(),2); |
| | | realdata.setTableName(table);//表名时间格式部分 |
| | | //判断表是否存在 |
| | | int tableNum = subTablePageInfoService.judgeTable_realdata(table); |
| | | List<RealDateDTO> list = new ArrayList(); |
| | | if (tableNum > 0) { |
| | | list = subTablePageInfoService.getBattHisRealInAlm(realdata); |
| | | } |
| | | dataList.addAll(list); |
| | | latch.countDown(); |
| | | }); |
| | | sleep(200); |
| | | } |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList()); |
| | | return new Response().setIII(1,true, dataListSorted,almAnalysisParam,"电池告警点击具体告警信息查看从告警开始时间到现在的历史实时数据"); |
| | | |
| | | } |
| | | } |