| | |
| | | // 每天凌晨12点30执行 推送充电用能统计 |
| | | @Scheduled(cron = "0 30 0 * * ?") |
| | | public void superviseNotificationOperationStatsInfo() { |
| | | String port = System.getProperty("server.port"); |
| | | if("5071".equals(port)){ |
| | | StationStatsInfoResult res = new StationStatsInfoResult(); |
| | | int dayOfMonth1 = LocalDateTime.now().getYear(); |
| | | int dayOfMonth2 = LocalDateTime.now().getMonthValue(); |
| | |
| | | res.setStationStatsInfos(stationStatsInfos); |
| | | tcecSuperviseUtil.superviseNotificationOperationStatsInfo(res); |
| | | } |
| | | } |
| | | // 每15分钟执行一次的定时任务 |
| | | @Scheduled(cron = "0 0/15 * * * ?") |
| | | public void supervise_notification_realtime_power_info() { |
| | | String port = System.getProperty("server.port"); |
| | | if("5071".equals(port)){ |
| | | List<Site> data = siteClient.getSiteAll().getData(); |
| | | List<Integer> siteIds = data.stream().map(Site::getId).collect(Collectors.toList()); |
| | | List<Integer> siteIds = data.stream().filter(s->s.getStatus() == 1).map(Site::getId).collect(Collectors.toList()); |
| | | List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData(); |
| | | List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList()); |
| | | List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData(); |
| | |
| | | chargingStatisticeDTO.setEndTime(now); |
| | | List<TChargingOrder> data1 = chargingOrderClient.getChargingStatistics(chargingStatisticeDTO).getData(); |
| | | for (Site datum : data) { |
| | | List<TChargingOrder> collect = data1.stream().filter(e -> e.getSiteId().equals(datum.getId()) |
| | | &&e.getChargingPower()!=null).collect(Collectors.toList()); |
| | | List<TChargingOrder> collect = data1.stream().filter(e -> e.getSiteId().equals(datum.getId()) && e.getChargingPower()!=null).collect(Collectors.toList()); |
| | | SupStationPowerInfo supStationPowerInfo = new SupStationPowerInfo(); |
| | | supStationPowerInfo.setOperatorID("906171535"); |
| | | supStationPowerInfo.setEquipmentOwnerID("906171535"); |
| | | supStationPowerInfo.setStationID(datum.getId().toString()); |
| | | supStationPowerInfo.setStationClassification(1); |
| | | supStationPowerInfo.setDataTime(DateUtils.localDateTimeToString(LocalDateTime.now())); |
| | | BigDecimal divide = collect.stream().map(TChargingOrder::getChargingPower).reduce(BigDecimal::add).get().divide(new BigDecimal(collect.size()).setScale(4, BigDecimal.ROUND_DOWN)); |
| | | BigDecimal divide = collect.stream().map(TChargingOrder::getChargingPower).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(collect.size()).setScale(4, BigDecimal.ROUND_DOWN)); |
| | | supStationPowerInfo.setStationRealTimePower(divide); |
| | | supStationPowerInfo.setEquipmentPowerInfos(buildEquipmentPowerInfo(datum.getId(), tChargingPiles, chargingGunList)); |
| | | stationStatsInfos.add(supStationPowerInfo); |
| | | } |
| | | supStationPowerInfoResult.setSupStationPowerInfos(stationStatsInfos); |
| | | tcecSuperviseUtil.superviseNotificationRealtimePowerInfo(supStationPowerInfoResult); |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 构建桩数据 |