Commit 5db47cd7 authored by caotao's avatar caotao

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

parent 43025d6f
...@@ -1521,4 +1521,14 @@ public class MonitorFanIdxController extends BaseController { ...@@ -1521,4 +1521,14 @@ public class MonitorFanIdxController extends BaseController {
public ResponseModel<Map<String, String>> getGenPowerInfoForBuDun(@RequestParam(required = false) String areaCode,@RequestParam(required = false) String stationId) { public ResponseModel<Map<String, String>> getGenPowerInfoForBuDun(@RequestParam(required = false) String areaCode,@RequestParam(required = false) String stationId) {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfoForBuDun(areaCode,stationId)); return ResponseHelper.buildResponse(monitoringService.getGenPowerInfoForBuDun(areaCode,stationId));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全国发电详情部盾")
@GetMapping("/getGenPowerInfo")
public ResponseModel<Map<String, Object>> getGenPowerInfo() {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfo());
}
} }
...@@ -13,9 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans; ...@@ -13,9 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*; import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import lombok.Data;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.checkerframework.checker.units.qual.min;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,7 +25,6 @@ import org.typroject.tyboot.component.emq.EmqKeeper; ...@@ -27,7 +25,6 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
...@@ -1266,4 +1263,83 @@ public class MonitoringServiceImpl { ...@@ -1266,4 +1263,83 @@ public class MonitoringServiceImpl {
} }
return returnResult; return returnResult;
} }
public Map<String, Object> getGenPowerInfo() {
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));
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();
returnResult.put("pv_station_count", pvStationList.size());
returnResult.put("fan_station_count", fanStationList.size());
AtomicReference<Double> powerOfDayFD = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> powerOfMonthFD = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> powerOfDayGF = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> powerOfMonthGF = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> planOfFD = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> planOfGF = new AtomicReference<>(new Double(0.00));
fanStationList.forEach(stationBasic -> {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
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, "月发电量")));
planOfFD.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
});
pvStationList.forEach(stationBasic -> {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
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)));
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));
groupByProvince.keySet().forEach(s -> {
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);
});
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());
}
} }
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