Commit af59bb89 authored by caotao's avatar caotao

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

parent ac80a9d2
......@@ -1526,8 +1526,8 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全国发电详情部盾")
@GetMapping("/getGenPowerInfo")
public ResponseModel<Map<String, Object>> getGenPowerInfo() {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfo());
public ResponseModel<Map<String, Object>> getGenPowerInfo(@RequestParam(required = false) String areaCode) {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfo(areaCode));
}
}
......
......@@ -1264,16 +1264,24 @@ public class MonitoringServiceImpl {
return returnResult;
}
public Map<String, Object> getGenPowerInfo() {
public Map<String, Object> getGenPowerInfo(String areaCode) {
List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto();
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));
if (StringUtils.isNotBlank(areaCode)) {
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("area_code",areaCode));
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> pv_interval = new HashMap<>();
HashMap<String, Object> fan_interval = new HashMap<>();
HashMap<String,Double> dayGenCache =new HashMap();
HashMap<String,Double> monthGenCache =new HashMap();
HashMap<String, Double> dayGenCache = new HashMap();
HashMap<String, Double> monthGenCache = new HashMap();
returnResult.put("pv_station_count", pvStationList.size());
returnResult.put("fan_station_count", fanStationList.size());
AtomicReference<Double> powerOfDayFD = new AtomicReference<>(new Double(0.00));
......@@ -1289,8 +1297,8 @@ public class MonitoringServiceImpl {
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
dayGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
planOfFD.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
});
pvStationList.forEach(stationBasic -> {
......@@ -1300,46 +1308,53 @@ public class MonitoringServiceImpl {
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
dayGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthGenCache.put(stationBasic.getStationId(),keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
planOfGF.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
});
returnResult.put("today_pv_power", String.format(CommonConstans.Twodecimalplaces,powerOfDayGF.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_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_fan_quota_schedule", String.format(CommonConstans.Twodecimalplaces,(powerOfMonthFD.get()/planOfFD.get())*100));
returnResult.put("today_pv_power", String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.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_fan_power", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()));
returnResult.put("month_pv_quota_schedule", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthGF.get() / planOfGF.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 -> {
HashMap<String,Object> fan = new HashMap<>();
HashMap<String,Object> pv = new HashMap<>();
HashMap<String, Object> fan = new HashMap<>();
HashMap<String, Object> pv = new HashMap<>();
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> 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());
pv.put("station_count",pvStationIds.size());
fan.put("today_power",getTotalPowerFromCache(fanStationIds,dayGenCache));
pv.put("today_power",getTotalPowerFromCache(pvStationIds,dayGenCache));
fan.put("month_power",getTotalPowerFromCache(fanStationIds,monthGenCache));
pv.put("month_power",getTotalPowerFromCache(pvStationIds,monthGenCache));
pv_interval.put(s,pv);
fan_interval.put(s,fan);
fan.put("station_count", fanStationIds.size());
pv.put("station_count", pvStationIds.size());
fan.put("today_power", getTotalPowerFromCache(fanStationIds, dayGenCache));
pv.put("today_power", getTotalPowerFromCache(pvStationIds, dayGenCache));
fan.put("month_power", getTotalPowerFromCache(fanStationIds, monthGenCache));
pv.put("month_power", getTotalPowerFromCache(pvStationIds, monthGenCache));
pv_interval.put(s, pv);
fan_interval.put(s, fan);
});
returnResult.put("pv_interval",pv_interval);
returnResult.put("fan_interval",fan_interval);
returnResult.put("pv_interval", pv_interval);
returnResult.put("fan_interval", fan_interval);
return returnResult;
}
public Double getPlanGenByStationIdAndMonth(String stationId) {
String[] dates = DateUtil.today().split("-");
return stationPlanMapper.getPlanGenByStationIdAndMonth(stationId, dates[0], String.valueOf(Integer.valueOf(dates[1])));
}
public Double getTotalPowerFromCache(List<String> keys,HashMap<String,Double> cache){
AtomicReference<Double> result = new AtomicReference<>(0.0);
keys.forEach(s->{
result.set(result.get() + cache.get(s));
});
return keepFourdecimalPlaces(result.get());
public Double getTotalPowerFromCache(List<String> keys, HashMap<String, Double> cache) {
AtomicReference<Double> result = new AtomicReference<>(0.0);
keys.forEach(s -> {
result.set(result.get() + cache.get(s));
});
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