Commit 5ba13828 authored by tangwei's avatar tangwei

修改区域统计

parent ac24e315
...@@ -29,6 +29,7 @@ import java.text.DecimalFormat; ...@@ -29,6 +29,7 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -113,13 +114,13 @@ public class LargeScreenImpl { ...@@ -113,13 +114,13 @@ public class LargeScreenImpl {
ParsedSum parsedSum = (ParsedSum) agg; ParsedSum parsedSum = (ParsedSum) agg;
switch (bucket.getKeyAsString()) { switch (bucket.getKeyAsString()) {
case RSD: case RSD:
mapdta.put("RSD", Double.valueOf(format2.format(parsedSum.getValue()))); mapdta.put("RSD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActor* CommonConstans.pvGenPoweActorDay)));
break; break;
case YFD: case YFD:
mapdta.put("YFD", Double.valueOf(format2.format(parsedSum.getValue()))); mapdta.put("YFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
break; break;
case NFD: case NFD:
mapdta.put("NFD", Double.valueOf(format2.format(parsedSum.getValue()))); mapdta.put("NFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
break; break;
default: default:
break; break;
...@@ -162,8 +163,8 @@ public class LargeScreenImpl { ...@@ -162,8 +163,8 @@ public class LargeScreenImpl {
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto(); List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode)); Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
for (String s : belongAreaList.keySet()) { for (String s : belongAreaList.keySet()) {
List<String> ids = belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList()); //List<String> ids = belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
getqy(ids,s); getqy(belongAreaList.get(s),s);
} }
} }
...@@ -173,7 +174,7 @@ public class LargeScreenImpl { ...@@ -173,7 +174,7 @@ public class LargeScreenImpl {
/** /**
* 区域 * 区域
**/ **/
public Map<String, Double> getqy(List<String> gatewayId,String s) { public Map<String, Double> getqy(List<StationCacheInfoDto> gatewayId,String s) {
Map<String, Double> mapdta = new HashMap<>(); Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d); mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d); mapdta.put("ZFS", 0d);
...@@ -185,12 +186,14 @@ public class LargeScreenImpl { ...@@ -185,12 +186,14 @@ public class LargeScreenImpl {
mapdta.put("NJHWC", 0d); mapdta.put("NJHWC", 0d);
//平均数 //平均数
List<String> value = new ArrayList<>(); List<String> value = new ArrayList<>();
List<String> ids = gatewayId.stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
value.add(SS); value.add(SS);
value.add(ZFS); value.add(ZFS);
value.add(ZFSLJ); value.add(ZFSLJ);
Map<String, List<String>> map = new HashMap<>(); Map<String, List<String>> map = new HashMap<>();
map.put("equipmentIndexName.keyword", value); map.put("equipmentIndexName.keyword", value);
map.put("gatewayId.keyword", gatewayId); map.put("gatewayId.keyword", ids);
List<? extends Terms.Bucket> lidate = commonServiceImpl.getgroupavg(map, "valueF", "equipmentIndexName.keyword", ESEquipments.class); List<? extends Terms.Bucket> lidate = commonServiceImpl.getgroupavg(map, "valueF", "equipmentIndexName.keyword", ESEquipments.class);
DecimalFormat format2 = new DecimalFormat("#.0000"); DecimalFormat format2 = new DecimalFormat("#.0000");
...@@ -216,33 +219,70 @@ public class LargeScreenImpl { ...@@ -216,33 +219,70 @@ public class LargeScreenImpl {
} }
} }
//总和
value.clear();
value.add(RSD);
value.add(YFD);
value.add(NFD);
List<? extends Terms.Bucket> lidatesum = commonServiceImpl.getgroupsum(map, "valueF", "equipmentIndexName.keyword", ESEquipments.class);
for (Terms.Bucket bucket : lidatesum) { //日发电量
Aggregations aggregation = bucket.getAggregations(); AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
List<Aggregation> listdata = Objects.nonNull(aggregation) ? aggregation.asList() : null; //月发电量
for (Aggregation agg : listdata) { AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
ParsedSum parsedSum = (ParsedSum) agg; //年发电量
switch (bucket.getKeyAsString()) { AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
case RSD: for (StationCacheInfoDto stationBasic : gatewayId) {
mapdta.put("RSD", Double.valueOf(format2.format(parsedSum.getValue())));
break; if ("FDZ".equals(stationBasic.getStationType())) {
case YFD: Map<String, List<String>> queryCondtion = new HashMap<>();
mapdta.put("YFD", Double.valueOf(format2.format(parsedSum.getValue()))); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
break; queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
case NFD: List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
mapdta.put("NFD", Double.valueOf(format2.format(parsedSum.getValue()))); dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
break; monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
default: annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
break; } else {
} Map<String, List<String>> queryCondtion = new HashMap<>();
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, shouldQueryCondtion);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActornew));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActornew));
} }
} }
mapdta.put("RSD", dailyPower.get());
mapdta.put("YFD", monthlyPower.get());
mapdta.put("NFD", annualPower.get());
// //总和
// value.clear();
// value.add(RSD);
// value.add(YFD);
// value.add(NFD);
// List<? extends Terms.Bucket> lidatesum = commonServiceImpl.getgroupsum(map, "valueF", "equipmentIndexName.keyword", ESEquipments.class);
//
// for (Terms.Bucket bucket : lidatesum) {
// Aggregations aggregation = bucket.getAggregations();
// List<Aggregation> listdata = Objects.nonNull(aggregation) ? aggregation.asList() : null;
// for (Aggregation agg : listdata) {
// ParsedSum parsedSum = (ParsedSum) agg;
// switch (bucket.getKeyAsString()) {
// case RSD:
// mapdta.put("RSD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActor* CommonConstans.pvGenPoweActorDay)));
// break;
// case YFD:
// mapdta.put("YFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
// break;
// case NFD:
// mapdta.put("NFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
// break;
// default:
// break;
// }
// }
// }
//计算月完成百分比 //计算月完成百分比
//当前月份 获取 //当前月份 获取
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
...@@ -274,7 +314,9 @@ public class LargeScreenImpl { ...@@ -274,7 +314,9 @@ public class LargeScreenImpl {
} }
public Double keepFourdecimalPlaces(Double param) {
return Double.valueOf(String.format("%.4f", param));
}
//全国发电趋势 //全国发电趋势
@Scheduled(cron = "0/10 * * * * ? ") @Scheduled(cron = "0/10 * * * * ? ")
......
...@@ -58,6 +58,8 @@ public class MonitorFanIdxController extends BaseController { ...@@ -58,6 +58,8 @@ public class MonitorFanIdxController extends BaseController {
@Autowired @Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
StationBasicMapper stationBasicMapper; StationBasicMapper stationBasicMapper;
@Autowired @Autowired
...@@ -210,18 +212,30 @@ public class MonitorFanIdxController extends BaseController { ...@@ -210,18 +212,30 @@ public class MonitorFanIdxController extends BaseController {
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId(); String gatewayId = stationBasic.getFanGatewayId();
String[] columnList = new String[]{"日发电量", "月发电量", "年发电量"}; // String[] columnList = new String[]{"日发电量", "月发电量", "年发电量"};
String[] columnLists = new String[]{"30秒平均风速"}; // String[] columnLists = new String[]{"30秒平均风速"};
Map<String, Object> columnMap = new HashMap<>(); Map<String, Object> columnMap = new HashMap<>();
for (String column : columnList) { // for (String column : columnList) {
Double result = commonService.getTotalByIndicatior(gatewayId, column); // Double result = commonService.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f", result)); // columnMap.put(column, String.format("%.2f", result));
} // }
for (String column : columnLists) { // for (String column : columnLists) {
Double result = commonService.getAvgvalueByIndicatior(gatewayId, column); // Double result = commonService.getAvgvalueByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f", result)); // columnMap.put(column, String.format("%.2f", result));
} // }
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速", "日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put( "日发电量",String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "日发电量")));
columnMap.put( "月发电量",String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "月发电量")));
columnMap.put( "年发电量",String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "年发电量")));
columnMap.put( "30秒平均风速",String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速")));
Map<String, List<String>> queryCondtion1 = new HashMap<>(); Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值")); queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
...@@ -615,6 +629,11 @@ public class MonitorFanIdxController extends BaseController { ...@@ -615,6 +629,11 @@ public class MonitorFanIdxController extends BaseController {
columnMap.put(column, result); columnMap.put(column, result);
} }
} }
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
......
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