Commit af59bb89 authored by caotao's avatar caotao

1、给部盾提供接口发电量详情接口

parent ac80a9d2
...@@ -1526,8 +1526,8 @@ public class MonitorFanIdxController extends BaseController { ...@@ -1526,8 +1526,8 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全国发电详情部盾") @ApiOperation(value = "全国发电详情部盾")
@GetMapping("/getGenPowerInfo") @GetMapping("/getGenPowerInfo")
public ResponseModel<Map<String, Object>> getGenPowerInfo() { public ResponseModel<Map<String, Object>> getGenPowerInfo(@RequestParam(required = false) String areaCode) {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfo()); return ResponseHelper.buildResponse(monitoringService.getGenPowerInfo(areaCode));
} }
} }
......
...@@ -1264,16 +1264,24 @@ public class MonitoringServiceImpl { ...@@ -1264,16 +1264,24 @@ public class MonitoringServiceImpl {
return returnResult; return returnResult;
} }
public Map<String, Object> getGenPowerInfo() { public Map<String, Object> getGenPowerInfo(String areaCode) {
List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto(); List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto();
List<StationCacheInfoDto> fanStationList= stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()); if (StringUtils.isNotBlank(areaCode)) {
List<StationCacheInfoDto> pvStationList= stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()); MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("area_code",areaCode));
Map<String,List<StationCacheInfoDto>> groupByProvince = stationCacheInfoDtos.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getBelongProvince)); List<StationCacheInfoDto> filterData = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getAreaCode().equals(areaCode)).collect(Collectors.toList());
stationCacheInfoDtos = filterData.size() > 0 ? filterData : stationCacheInfoDtos;
if(!ObjectUtils.isEmpty(mapRegion)){
stationCacheInfoDtos =filterData;
}
}
List<StationCacheInfoDto> fanStationList = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList());
List<StationCacheInfoDto> pvStationList = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList());
Map<String, List<StationCacheInfoDto>> groupByProvince = stationCacheInfoDtos.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getBelongProvince));
HashMap<String, Object> returnResult = new HashMap<>(); HashMap<String, Object> returnResult = new HashMap<>();
HashMap<String, Object> pv_interval = new HashMap<>(); HashMap<String, Object> pv_interval = new HashMap<>();
HashMap<String, Object> fan_interval = new HashMap<>(); HashMap<String, Object> fan_interval = new HashMap<>();
HashMap<String,Double> dayGenCache =new HashMap(); HashMap<String, Double> dayGenCache = new HashMap();
HashMap<String,Double> monthGenCache =new HashMap(); HashMap<String, Double> monthGenCache = new HashMap();
returnResult.put("pv_station_count", pvStationList.size()); returnResult.put("pv_station_count", pvStationList.size());
returnResult.put("fan_station_count", fanStationList.size()); returnResult.put("fan_station_count", fanStationList.size());
AtomicReference<Double> powerOfDayFD = new AtomicReference<>(new Double(0.00)); AtomicReference<Double> powerOfDayFD = new AtomicReference<>(new Double(0.00));
...@@ -1289,8 +1297,8 @@ public class MonitoringServiceImpl { ...@@ -1289,8 +1297,8 @@ public class MonitoringServiceImpl {
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"))); powerOfDayFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"))); powerOfMonthFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
dayGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"))); dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"))); monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
planOfFD.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId())); planOfFD.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
}); });
pvStationList.forEach(stationBasic -> { pvStationList.forEach(stationBasic -> {
...@@ -1300,46 +1308,53 @@ public class MonitoringServiceImpl { ...@@ -1300,46 +1308,53 @@ public class MonitoringServiceImpl {
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)); powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)); powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
dayGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay))); dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth))); monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
planOfGF.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId())); planOfGF.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
}); });
returnResult.put("today_pv_power", String.format(CommonConstans.Twodecimalplaces,powerOfDayGF.get())); returnResult.put("today_pv_power", String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get()));
returnResult.put("today_fan_power", String.format(CommonConstans.Twodecimalplaces,powerOfDayFD.get())); returnResult.put("today_fan_power", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()));
returnResult.put("month_pv_power", String.format(CommonConstans.Twodecimalplaces,powerOfMonthGF.get())); returnResult.put("month_pv_power", String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get()));
returnResult.put("month_fan_power", String.format(CommonConstans.Twodecimalplaces,powerOfMonthFD.get())); returnResult.put("month_fan_power", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()));
returnResult.put("month_pv_quota_schedule", String.format(CommonConstans.Twodecimalplaces,(powerOfMonthGF.get()/planOfGF.get())*100)); returnResult.put("month_pv_quota_schedule", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthGF.get() / planOfGF.get()) * 100));
returnResult.put("month_fan_quota_schedule", String.format(CommonConstans.Twodecimalplaces,(powerOfMonthFD.get()/planOfFD.get())*100)); if(returnResult.get("month_pv_quota_schedule").toString().equals("NaN")){
returnResult.put("month_pv_quota_schedule",0.00f);
}
returnResult.put("month_fan_quota_schedule", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthFD.get() / planOfFD.get()) * 100));
if(returnResult.get("month_fan_quota_schedule").toString().equals("NaN")){
returnResult.put("month_fan_quota_schedule",0.00f);
}
groupByProvince.keySet().forEach(s -> { groupByProvince.keySet().forEach(s -> {
HashMap<String,Object> fan = new HashMap<>(); HashMap<String, Object> fan = new HashMap<>();
HashMap<String,Object> pv = new HashMap<>(); HashMap<String, Object> pv = new HashMap<>();
List<StationCacheInfoDto> list = groupByProvince.get(s); List<StationCacheInfoDto> list = groupByProvince.get(s);
List<String> fanStationIds = list.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()).stream().map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList()); List<String> fanStationIds = list.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()).stream().map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList());
List<String> pvStationIds = list.stream().filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()).stream().map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList()); List<String> pvStationIds = list.stream().filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()).stream().map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList());
fan.put("station_count",fanStationIds.size()); fan.put("station_count", fanStationIds.size());
pv.put("station_count",pvStationIds.size()); pv.put("station_count", pvStationIds.size());
fan.put("today_power",getTotalPowerFromCache(fanStationIds,dayGenCache)); fan.put("today_power", getTotalPowerFromCache(fanStationIds, dayGenCache));
pv.put("today_power",getTotalPowerFromCache(pvStationIds,dayGenCache)); pv.put("today_power", getTotalPowerFromCache(pvStationIds, dayGenCache));
fan.put("month_power",getTotalPowerFromCache(fanStationIds,monthGenCache)); fan.put("month_power", getTotalPowerFromCache(fanStationIds, monthGenCache));
pv.put("month_power",getTotalPowerFromCache(pvStationIds,monthGenCache)); pv.put("month_power", getTotalPowerFromCache(pvStationIds, monthGenCache));
pv_interval.put(s,pv); pv_interval.put(s, pv);
fan_interval.put(s,fan); fan_interval.put(s, fan);
}); });
returnResult.put("pv_interval",pv_interval); returnResult.put("pv_interval", pv_interval);
returnResult.put("fan_interval",fan_interval); returnResult.put("fan_interval", fan_interval);
return returnResult; return returnResult;
} }
public Double getPlanGenByStationIdAndMonth(String stationId) { public Double getPlanGenByStationIdAndMonth(String stationId) {
String[] dates = DateUtil.today().split("-"); String[] dates = DateUtil.today().split("-");
return stationPlanMapper.getPlanGenByStationIdAndMonth(stationId, dates[0], String.valueOf(Integer.valueOf(dates[1]))); return stationPlanMapper.getPlanGenByStationIdAndMonth(stationId, dates[0], String.valueOf(Integer.valueOf(dates[1])));
} }
public Double getTotalPowerFromCache(List<String> keys,HashMap<String,Double> cache){ public Double getTotalPowerFromCache(List<String> keys, HashMap<String, Double> cache) {
AtomicReference<Double> result = new AtomicReference<>(0.0); AtomicReference<Double> result = new AtomicReference<>(0.0);
keys.forEach(s->{ keys.forEach(s -> {
result.set(result.get() + cache.get(s)); result.set(result.get() + cache.get(s));
}); });
return keepFourdecimalPlaces(result.get()); return keepFourdecimalPlaces(result.get());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment