Commit 4b32b581 authored by chenzhao's avatar chenzhao

监盘接口 字段替换 非空验证

parent 8df1dbcb
......@@ -40,7 +40,7 @@ public class ESEquipments {
@Field(type = FieldType.Text)
private String value;
@Field(type = FieldType.Float, index = false)
private Float valueF;
private Float valueF ;
@Field(type = FieldType.Text)
private String valueLabel;
@Field(type = FieldType.Text , index = false)
......
......@@ -172,7 +172,7 @@ public class DemoController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化influxdb-风电、光伏、升压站")
@GetMapping("/test4")
@GetMapping("doc/test4")
public ResponseModel<Integer> demoTest3() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801435891929089","1669524885619085313","1668801570352926721","1669525017559306241"};
......@@ -360,7 +360,7 @@ public class DemoController extends BaseController {
public ResponseModel<Object> demoTest8() {
QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "有功功率");
SumAggregationBuilder buyCountSum = AggregationBuilders.sum("buyCountSum").field("valueDouble");
SumAggregationBuilder buyCountSum = AggregationBuilders.sum("buyCountSum").field("valueF");
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.addAggregation(buyCountSum)
......@@ -377,7 +377,7 @@ public class DemoController extends BaseController {
public ResponseModel<Object> demoTest9() {
QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "有功功率");
AvgAggregationBuilder buyCountAvg = AggregationBuilders.avg("buyCountAvg").field("valueDouble");
AvgAggregationBuilder buyCountAvg = AggregationBuilders.avg("buyCountAvg").field("valueF");
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.addAggregation(buyCountAvg)
......@@ -402,7 +402,7 @@ public class DemoController extends BaseController {
// 如果只对一个字段进行分组写一个就好
TermsAggregationBuilder tb1 = AggregationBuilders.terms("group_gatewayId").field("gatewayId.keyword");//gatewayId 是分组字段名,group_gatewayId是查询结果的别名
// TermsAggregationBuilder tb2 = AggregationBuilders.terms("group_equipmentNumber").field("equipmentNumber.keyword");//equipmentNumber 是分组字段名,group_equipmentNumber是查询结果的别名
SumAggregationBuilder sb = AggregationBuilders.sum("sum_valueDouble").field("valueDouble");//valueDouble是求和字段名称,sun_valueDouble是结果别名
SumAggregationBuilder sb = AggregationBuilders.sum("sum_valueDouble").field("valueF");//valueF是求和字段名称,sun_valueDouble是结果别名
// 注意顺序,决定先通过谁分组
tb1.subAggregation(sb); // 通过typeId字段分组统计总数
......@@ -432,8 +432,8 @@ public class DemoController extends BaseController {
QueryDto ff2=new QueryDto("equipmentIndexName.keyword","有功功率");
queryDto.add(ff1);
queryDto.add(ff2);
Double avg= commonServiceImpl.getavg(queryDto,"valueDouble",ESEquipments.class);
Double sum= commonServiceImpl.getsum(queryDto,"valueDouble",ESEquipments.class);
Double avg= commonServiceImpl.getavg(queryDto,"valueF",ESEquipments.class);
Double sum= commonServiceImpl.getsum(queryDto,"valueF",ESEquipments.class);
Map<String,Double> map=new HashMap();
map.put("1668801435891929089_avg",avg);
......@@ -466,7 +466,7 @@ public class DemoController extends BaseController {
// value1.add("1668801435891929089");
// map.put("gatewayId.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupavg(map,"valueDouble" ,"equipmentIndexName.keyword",ESEquipments.class);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupavg(map,"valueF" ,"equipmentIndexName.keyword",ESEquipments.class);
Map<String,Object> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
......@@ -498,7 +498,7 @@ public class DemoController extends BaseController {
value1.add("1668801435891929089");
map.put("gatewayId.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"equipmentIndexName.keyword",ESEquipments.class);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueF" ,"equipmentIndexName.keyword",ESEquipments.class);
Map<String,Object> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
......@@ -556,7 +556,7 @@ public class DemoController extends BaseController {
@GetMapping("/test17")
public ResponseModel<Integer> demoTest17() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801435891929089","1669524885619085313","1668801570352926721","1669525017559306241"};
String [] strings = {"1668801570352926721","1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
......@@ -568,6 +568,8 @@ public class DemoController extends BaseController {
// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏
QueryWrapper.eq("gateway", strings[i]);
QueryWrapper.eq("front_module","电量表计");
QueryWrapper.eq("system_type","模拟量");
long DATE = new Date().getTime();
System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper);
......@@ -575,29 +577,26 @@ public class DemoController extends BaseController {
List<ESEquipments> listit =new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) {
Map<String, String> tag = new HashMap<>();
Map<String, Object> maps2 = new HashMap<>();
tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway());
maps2.put("address", monitorFanIndicator.getIndexAddress());
maps2.put("dataType", monitorFanIndicator.getDataType());
maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
maps2.put("gatewayId", monitorFanIndicator.getGateway());
maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
maps2.put("createdTime", "2023-07-05 18:30:26");
maps2.put("unit", monitorFanIndicator.getUnit());
maps2.put("value", "");
maps2.put("traceId", "");
maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
maps2.put("frontModule", monitorFanIndicator.getFrontModule());
maps2.put("systemType", monitorFanIndicator.getSystemType());
maps2.put("pictureName", monitorFanIndicator.getPictureName());
// maps2.put("address", monitorFanIndicator.getIndexAddress());
// maps2.put("dataType", monitorFanIndicator.getDataType());
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
// maps2.put("gatewayId", monitorFanIndicator.getGateway());
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
// maps2.put("createdTime", "2023-07-05 18:30:26");
// maps2.put("unit", monitorFanIndicator.getUnit());
// maps2.put("value", "");
// maps2.put("traceId", "");
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
maps2.put("frontModule","模拟量");
// maps2.put("systemType", monitorFanIndicator.getSystemType());
// maps2.put("pictureName", monitorFanIndicator.getPictureName());
//升压站的字段显示名称
maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2,1688558007051L, TimeUnit.MILLISECONDS);
}
}
......
......@@ -643,7 +643,7 @@ public class MonitorFanIdxController extends BaseController {
data3.put("title",columnMap.get("月发电量").toString());
objects.add(data3);
Map<String, Object> data4 = new HashMap<>();
data4.put("title",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射"));
data4.put("title",String.format("%.2f",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射")));
objects.add(data4);
Map<String, Object> data5 = new HashMap<>();
data5.put("title",columnMap.get("年发电量").toString());
......@@ -652,10 +652,10 @@ public class MonitorFanIdxController extends BaseController {
data6.put("title", columnMap.get("有功功率").toString()) ;
objects.add(data6);
Map<String, Object> data7 = new HashMap<>();
data7.put("title",columnMap.get("日照时数").toString());
data7.put("title",String.format("%.2f",((Double.parseDouble(columnMap.get("日发电量").toString())/10)/ (Double.parseDouble(columnMap.get("装机容量").toString())))));
objects.add(data7);
Map<String, Object> data8 = new HashMap<>();
data8.put("title",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射累计"));
data8.put("title",String.format("%.2f",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射累计")));
objects.add(data8);
Map<String, Object> data9 = new HashMap<>();
data9.put("title","0.00%");//综合效率
......
......@@ -247,7 +247,7 @@ public class CommonServiceImpl {
} catch (Exception e) {
return totalvalue;
}
return Double.valueOf(String.format("%.2f", totalvalue));
return Double.valueOf(String.format("%.2f", totalvalue*CommonConstans.pvGenPoweActor));
}
public Double getTotalByIndicatiorAndParams(String gatewayId, String indicator, String querySql) {
......@@ -573,13 +573,13 @@ public class CommonServiceImpl {
}
public Double getAvagerByEquipmentIndxName(List<ESEquipments> equipments, String indexName) {
Double result = 0.00;
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).mapToDouble(ESEquipments::getValueF).average().getAsDouble();
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF()!= null).mapToDouble(ESEquipments::getValueF).average().getAsDouble();
return result;
}
public Double getSumByEquipmentIndxName(List<ESEquipments> equipments, String indexName) {
Double result = 0.00;
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).mapToDouble(ESEquipments::getValueF).sum();
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF()!= null).mapToDouble(ESEquipments::getValueF).sum();
return result;
}
......
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