Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
45877eeb
Commit
45877eeb
authored
Aug 30, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
针对错误数据导致地图数据加载失败问题进行修复
parent
5b582b00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
149 additions
and
119 deletions
+149
-119
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+149
-119
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
45877eeb
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
cn.hutool.extra.pinyin.PinyinUtil
;
import
cn.hutool.extra.pinyin.PinyinUtil
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic
;
...
@@ -54,15 +55,15 @@ public class CommonServiceImpl {
...
@@ -54,15 +55,15 @@ public class CommonServiceImpl {
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
redisTemplate
;
@Autowired
@Autowired
private
StationBasicMapper
stationBasicMapper
;
private
StationBasicMapper
stationBasicMapper
;
/**
/**
* 带参数 求平均值
* 带参数 求平均值
*
*/
* */
public
Double
getavg
(
List
<
QueryDto
>
queryDto
,
String
keyavg
,
Class
clas
)
{
public
Double
getavg
(
List
<
QueryDto
>
queryDto
,
String
keyavg
,
Class
clas
){
Double
value
=
null
;
Double
value
=
null
;
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
for
(
QueryDto
dto
:
queryDto
)
{
for
(
QueryDto
dto
:
queryDto
)
{
queryBuilder
.
must
(
QueryBuilders
.
termQuery
(
dto
.
getKey
(),
dto
.
getValue
()));
queryBuilder
.
must
(
QueryBuilders
.
termQuery
(
dto
.
getKey
(),
dto
.
getValue
()));
}
}
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
keyavg
);
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
keyavg
);
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
()
...
@@ -71,33 +72,33 @@ public class CommonServiceImpl {
...
@@ -71,33 +72,33 @@ public class CommonServiceImpl {
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
build
();
.
build
();
query
.
setTrackTotalHits
(
true
);
query
.
setTrackTotalHits
(
true
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
clas
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
clas
);
if
(
search
.
hasAggregations
())
{
if
(
search
.
hasAggregations
())
{
Aggregations
aggregations
=
search
.
getAggregations
();
Aggregations
aggregations
=
search
.
getAggregations
();
if
(
Objects
.
nonNull
(
aggregations
))
{
if
(
Objects
.
nonNull
(
aggregations
))
{
Avg
avg
=
aggregations
.
get
(
"buyCountAvg"
);
Avg
avg
=
aggregations
.
get
(
"buyCountAvg"
);
value
=
avg
.
getValue
();
value
=
avg
.
getValue
();
}
}
}
}
return
value
;
return
value
;
}
}
/*
/*
*分组平均值
*分组平均值
**/
**/
public
List
<?
extends
Terms
.
Bucket
>
getgroupavg
(
Map
<
String
,
List
<
String
>>
value
,
String
keyavg
,
String
groupKey
,
Class
clas
)
{
public
List
<?
extends
Terms
.
Bucket
>
getgroupavg
(
Map
<
String
,
List
<
String
>>
value
,
String
keyavg
,
String
groupKey
,
Class
clas
)
{
List
<?
extends
Terms
.
Bucket
>
listdata
=
null
;
List
<?
extends
Terms
.
Bucket
>
listdata
=
null
;
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
for
(
String
key:
value
.
keySet
())
{
for
(
String
key
:
value
.
keySet
())
{
List
<
String
>
va
=
value
.
get
(
key
);
List
<
String
>
va
=
value
.
get
(
key
);
queryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
key
,
va
));
queryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
key
,
va
));
}
}
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"groupKey"
).
field
(
groupKey
);
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"groupKey"
).
field
(
groupKey
);
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
keyavg
);
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
keyavg
);
tb1
.
subAggregation
(
buyCountAvg
);
// 通过typeId字段分组统计总数
tb1
.
subAggregation
(
buyCountAvg
);
// 通过typeId字段分组统计总数
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
queryBuilder
)
.
withQuery
(
queryBuilder
)
.
addAggregation
(
tb1
)
.
addAggregation
(
tb1
)
...
@@ -108,8 +109,8 @@ public class CommonServiceImpl {
...
@@ -108,8 +109,8 @@ public class CommonServiceImpl {
if
(
search
.
hasAggregations
())
{
if
(
search
.
hasAggregations
())
{
Aggregations
aggregations
=
search
.
getAggregations
();
Aggregations
aggregations
=
search
.
getAggregations
();
if
(
Objects
.
nonNull
(
aggregations
))
{
if
(
Objects
.
nonNull
(
aggregations
))
{
List
<
Aggregation
>
list
=
aggregations
.
asList
();
List
<
Aggregation
>
list
=
aggregations
.
asList
();
listdata
=
list
!=
null
&&!
list
.
isEmpty
()?((
ParsedStringTerms
)
list
.
get
(
0
)).
getBuckets
():
null
;
listdata
=
list
!=
null
&&
!
list
.
isEmpty
()
?
((
ParsedStringTerms
)
list
.
get
(
0
)).
getBuckets
()
:
null
;
}
}
}
}
...
@@ -120,17 +121,17 @@ public class CommonServiceImpl {
...
@@ -120,17 +121,17 @@ public class CommonServiceImpl {
*分组求和
*分组求和
**/
**/
public
List
<?
extends
Terms
.
Bucket
>
getgroupsum
(
Map
<
String
,
List
<
String
>>
value
,
String
keyavg
,
String
groupKey
,
Class
clas
)
{
public
List
<?
extends
Terms
.
Bucket
>
getgroupsum
(
Map
<
String
,
List
<
String
>>
value
,
String
keyavg
,
String
groupKey
,
Class
clas
)
{
List
<?
extends
Terms
.
Bucket
>
listdata
=
null
;
List
<?
extends
Terms
.
Bucket
>
listdata
=
null
;
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
for
(
String
key:
value
.
keySet
())
{
for
(
String
key
:
value
.
keySet
())
{
List
<
String
>
va
=
value
.
get
(
key
);
List
<
String
>
va
=
value
.
get
(
key
);
queryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
key
,
va
));
queryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
key
,
va
));
}
}
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"groupKey"
).
field
(
groupKey
);
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"groupKey"
).
field
(
groupKey
);
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
keyavg
);
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
keyavg
);
tb1
.
subAggregation
(
buyCountSum
);
// 通过typeId字段分组统计总数
tb1
.
subAggregation
(
buyCountSum
);
// 通过typeId字段分组统计总数
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
queryBuilder
)
.
withQuery
(
queryBuilder
)
.
addAggregation
(
tb1
)
.
addAggregation
(
tb1
)
...
@@ -141,8 +142,8 @@ public class CommonServiceImpl {
...
@@ -141,8 +142,8 @@ public class CommonServiceImpl {
if
(
search
.
hasAggregations
())
{
if
(
search
.
hasAggregations
())
{
Aggregations
aggregations
=
search
.
getAggregations
();
Aggregations
aggregations
=
search
.
getAggregations
();
if
(
Objects
.
nonNull
(
aggregations
))
{
if
(
Objects
.
nonNull
(
aggregations
))
{
List
<
Aggregation
>
list
=
aggregations
.
asList
();
List
<
Aggregation
>
list
=
aggregations
.
asList
();
listdata
=
list
!=
null
&&!
list
.
isEmpty
()?((
ParsedStringTerms
)
list
.
get
(
0
)).
getBuckets
():
null
;
listdata
=
list
!=
null
&&
!
list
.
isEmpty
()
?
((
ParsedStringTerms
)
list
.
get
(
0
)).
getBuckets
()
:
null
;
}
}
}
}
...
@@ -150,14 +151,13 @@ public class CommonServiceImpl {
...
@@ -150,14 +151,13 @@ public class CommonServiceImpl {
}
}
/**
/**
* 带参数 求和
* 带参数 求和
*
*/
* */
public
Double
getsum
(
List
<
QueryDto
>
queryDto
,
String
keysum
,
Class
clas
)
{
public
Double
getsum
(
List
<
QueryDto
>
queryDto
,
String
keysum
,
Class
clas
){
Double
value
=
null
;
Double
value
=
null
;
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
for
(
QueryDto
dto
:
queryDto
)
{
for
(
QueryDto
dto
:
queryDto
)
{
queryBuilder
.
must
(
QueryBuilders
.
termQuery
(
dto
.
getKey
(),
dto
.
getValue
()));
queryBuilder
.
must
(
QueryBuilders
.
termQuery
(
dto
.
getKey
(),
dto
.
getValue
()));
}
}
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
keysum
);
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
keysum
);
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
()
...
@@ -166,132 +166,160 @@ public class CommonServiceImpl {
...
@@ -166,132 +166,160 @@ public class CommonServiceImpl {
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
build
();
.
build
();
query
.
setTrackTotalHits
(
true
);
query
.
setTrackTotalHits
(
true
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
clas
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
clas
);
if
(
search
.
hasAggregations
())
{
if
(
search
.
hasAggregations
())
{
Aggregations
aggregations
=
search
.
getAggregations
();
Aggregations
aggregations
=
search
.
getAggregations
();
if
(
Objects
.
nonNull
(
aggregations
))
{
if
(
Objects
.
nonNull
(
aggregations
))
{
Sum
sum
=
aggregations
.
get
(
"buyCountSum"
);
Sum
sum
=
aggregations
.
get
(
"buyCountSum"
);
value
=
sum
.
getValue
();
value
=
sum
.
getValue
();
}
}
}
}
return
value
;
return
value
;
}
}
public
Integer
getCount
(
List
<
QueryDto
>
queryDto
,
String
keysum
,
Class
clas
)
{
public
Integer
getCount
(
List
<
QueryDto
>
queryDto
,
String
keysum
,
Class
clas
)
{
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
for
(
QueryDto
dto
:
queryDto
)
{
for
(
QueryDto
dto
:
queryDto
)
{
queryBuilder
.
must
(
QueryBuilders
.
matchPhraseQuery
(
dto
.
getKey
(),
dto
.
getValue
()));
queryBuilder
.
must
(
QueryBuilders
.
matchPhraseQuery
(
dto
.
getKey
(),
dto
.
getValue
()));
}
}
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
queryBuilder
)
.
withQuery
(
queryBuilder
)
.
withPageable
(
PageRequest
.
of
(
0
,
10000
))
.
withPageable
(
PageRequest
.
of
(
0
,
10000
))
.
build
();
.
build
();
query
.
setTrackTotalHits
(
true
);
query
.
setTrackTotalHits
(
true
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
clas
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
clas
);
return
search
.
getSearchHits
().
size
();
return
search
.
getSearchHits
().
size
();
}
}
/**
/**
* @deprecated 获取指标值总和
* @param gatewayId 网关id 用于拼接sql语句
* @param gatewayId 网关id 用于拼接sql语句
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和
* @return 指标值总和
* @deprecated 获取指标值总和
*/
*/
public
Double
getTotalByIndicatior
(
String
gatewayId
,
String
indicator
){
public
Double
getTotalByIndicatior
(
String
gatewayId
,
String
indicator
)
{
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
Double
totalvalue
=
0.0
;
Double
totalvalue
=
0.00
;
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
try
{
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
}
catch
(
Exception
e
)
{
return
totalvalue
;
}
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
}
}
public
Double
getTotalByIndicatiorAndParams
(
String
gatewayId
,
String
indicator
,
String
querySql
){
public
Double
getTotalByIndicatiorAndParams
(
String
gatewayId
,
String
indicator
,
String
querySql
)
{
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
Double
totalvalue
=
0.0
;
Double
totalvalue
=
0.00
;
if
(
null
!=
querySql
){
try
{
sql
=
sql
+
" "
+
querySql
;
if
(
null
!=
querySql
)
{
sql
=
sql
+
" "
+
querySql
;
}
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
}
catch
(
Exception
e
)
{
return
totalvalue
;
}
}
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
}
}
public
Double
getNumByIndicatior
(
String
gatewayId
,
String
indicator
){
public
Double
getNumByIndicatior
(
String
gatewayId
,
String
indicator
)
{
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName=~/"
+
indicator
+
"$/"
;
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName=~/"
+
indicator
+
"$/"
;
Double
totalvalue
=
0.0
;
Double
totalvalue
=
0.00
;
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
try
{
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
}
catch
(
Exception
e
)
{
return
totalvalue
;
}
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
}
}
/**
/**
* @deprecated 获取指标值平均值
* @param gatewayId 网关id 用于拼接sql语句
* @param gatewayId 网关id 用于拼接sql语句
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和
* @return 指标值总和
* @deprecated 获取指标值平均值
*/
*/
public
Double
getAvgvalueByIndicatior
(
String
gatewayId
,
String
indicator
){
public
Double
getAvgvalueByIndicatior
(
String
gatewayId
,
String
indicator
)
{
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
Double
avageValue
=
0.0
;
Double
avageValue
=
0.00
;
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
try
{
avageValue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
average
().
getAsDouble
();
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
avageValue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
average
().
getAsDouble
();
}
catch
(
Exception
e
)
{
return
avageValue
;
}
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
}
}
public
Double
getTotalByIndicatior
(
List
<
Map
<
String
,
Object
>>
mapList
,
String
indicator
){
Double
totalvalue
=
0.0
;
public
Double
getTotalByIndicatior
(
List
<
Map
<
String
,
Object
>>
mapList
,
String
indicator
)
{
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
stringObjectMap
.
get
(
"equipmentIndexName"
).
toString
().
contains
(
indicator
)&&!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
Double
totalvalue
=
0.0000
;
return
Double
.
valueOf
(
String
.
format
(
"%.4f"
,
totalvalue
));
try
{
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
stringObjectMap
.
get
(
"equipmentIndexName"
).
toString
().
contains
(
indicator
)
&&
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
}
catch
(
Exception
e
){
return
totalvalue
;
}
return
Double
.
valueOf
(
String
.
format
(
"%.4f"
,
totalvalue
));
}
}
/**
/**
* @deprecated 获取指标值平均值
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和
* @return 指标值总和
* @deprecated 获取指标值平均值
*/
*/
public
Double
getAvgvalueByIndicatior
(
List
<
Map
<
String
,
Object
>>
mapList
,
String
indicator
){
public
Double
getAvgvalueByIndicatior
(
List
<
Map
<
String
,
Object
>>
mapList
,
String
indicator
)
{
Double
avageValue
=
0.0
;
Double
avageValue
=
0.00
;
avageValue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
stringObjectMap
.
get
(
"equipmentIndexName"
).
toString
().
contains
(
indicator
)&&!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
try
{
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
avageValue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
stringObjectMap
.
get
(
"equipmentIndexName"
).
toString
().
contains
(
indicator
)
&&
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
}
catch
(
Exception
exception
){
return
avageValue
;
}
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
}
}
public
Double
getStationCapactityByStationWerks
(
String
WERKS
){
return
sjglZsjZsbtzMapper
.
getStationCapactityByStationWerks
(
WERKS
);
public
Double
getStationCapactityByStationWerks
(
String
WERKS
)
{
return
sjglZsjZsbtzMapper
.
getStationCapactityByStationWerks
(
WERKS
);
}
}
public
Page
<
SocialContributionDto
>
getSocialContributionDtoList
(
Double
totalSocialContribution
){
Page
<
SocialContributionDto
>
socialContributionDtoPage
=
new
Page
<
SocialContributionDto
>();
public
Page
<
SocialContributionDto
>
getSocialContributionDtoList
(
Double
totalSocialContribution
)
{
List
<
SocialContributionDto
>
socialContributionDtoList
=
new
ArrayList
<>();
Page
<
SocialContributionDto
>
socialContributionDtoPage
=
new
Page
<
SocialContributionDto
>();
List
<
SocialContributionDto
>
socialContributionDtoList
=
new
ArrayList
<>();
//获取所有网关id不为空的数据
//获取所有网关id不为空的数据
//二氧化碳贡献数
SocialContributionDto
co2
=
new
SocialContributionDto
();
//二氧化碳贡献数
//标准煤贡献度
SocialContributionDto
co2
=
new
SocialContributionDto
();
SocialContributionDto
coal
=
new
SocialContributionDto
();
//标准煤贡献度
//碳粉尘计算公式
SocialContributionDto
coal
=
new
SocialContributionDto
();
SocialContributionDto
toner
=
new
SocialContributionDto
();
//碳粉尘计算公式
//二氧化硫贡献度
SocialContributionDto
toner
=
new
SocialContributionDto
();
SocialContributionDto
so2
=
new
SocialContributionDto
();
//二氧化硫贡献度
/** 社会贡献原始计算公式,后边的数据已经经过处理
SocialContributionDto
so2
=
new
SocialContributionDto
();
发电量完成率=(月/年)发电量/(月/年)发电量指标
/** 社会贡献原始计算公式,后边的数据已经经过处理
小时数完成率=(月/年)可利用小时/(月/年)可利用小时数指标
发电量完成率=(月/年)发电量/(月/年)发电量指标
可利用小时(h)=(日/月/年)发电量(万kW·h)/装机容量(万kW)
小时数完成率=(月/年)可利用小时/(月/年)可利用小时数指标
二氧化碳减排量(万t)=发电量(万kW·h)*0.79
可利用小时(h)=(日/月/年)发电量(万kW·h)/装机容量(万kW)
节约标准煤(万t)=发电量(万kW·h)*0.29
二氧化碳减排量(万t)=发电量(万kW·h)*0.79
炭粉尘减排量(t)=发电量(万kW·h)*0.30
节约标准煤(万t)=发电量(万kW·h)*0.29
二氧化硫减排量(t)=发电量(万kW·h)*1.51
炭粉尘减排量(t)=发电量(万kW·h)*0.30
氮氧化物减排量(t)=发电量(万kW·h)*1.69
二氧化硫减排量(t)=发电量(万kW·h)*1.51
*/
氮氧化物减排量(t)=发电量(万kW·h)*1.69
*/
co2
.
setUnit
(
"二氧化碳减排量(万t)"
);
co2
.
setUnit
(
"二氧化碳减排量(万t)"
);
co2
.
setTitle
(
String
.
format
(
"%.2f"
,
totalSocialContribution
*
CommonConstans
.
carbonDioxide
));
co2
.
setTitle
(
String
.
format
(
"%.2f"
,
totalSocialContribution
*
CommonConstans
.
carbonDioxide
));
socialContributionDtoList
.
add
(
co2
);
socialContributionDtoList
.
add
(
co2
);
coal
.
setUnit
(
"节约标准煤(万t)"
);
coal
.
setUnit
(
"节约标准煤(万t)"
);
coal
.
setTitle
(
String
.
format
(
"%.2f"
,(
totalSocialContribution
*
CommonConstans
.
standardCoal
)));
coal
.
setTitle
(
String
.
format
(
"%.2f"
,
(
totalSocialContribution
*
CommonConstans
.
standardCoal
)));
socialContributionDtoList
.
add
(
coal
);
socialContributionDtoList
.
add
(
coal
);
toner
.
setUnit
(
"碳粉尘减排量(万t)"
);
toner
.
setUnit
(
"碳粉尘减排量(万t)"
);
toner
.
setTitle
(
String
.
format
(
"%.2f"
,
(
totalSocialContribution
*
CommonConstans
.
toner
*
CommonConstans
.
tToWT
)));
toner
.
setTitle
(
String
.
format
(
"%.2f"
,
(
totalSocialContribution
*
CommonConstans
.
toner
*
CommonConstans
.
tToWT
)));
socialContributionDtoList
.
add
(
toner
);
socialContributionDtoList
.
add
(
toner
);
so2
.
setUnit
(
"二氧化硫减排量(万t)"
);
so2
.
setUnit
(
"二氧化硫减排量(万t)"
);
so2
.
setTitle
(
String
.
format
(
"%.2f"
,
(
totalSocialContribution
*
CommonConstans
.
sulfurDioxide
*
CommonConstans
.
tToWT
)));
so2
.
setTitle
(
String
.
format
(
"%.2f"
,
(
totalSocialContribution
*
CommonConstans
.
sulfurDioxide
*
CommonConstans
.
tToWT
)));
socialContributionDtoList
.
add
(
so2
);
socialContributionDtoList
.
add
(
so2
);
socialContributionDtoPage
.
setRecords
(
socialContributionDtoList
);
socialContributionDtoPage
.
setRecords
(
socialContributionDtoList
);
socialContributionDtoPage
.
setTotal
(
100
);
socialContributionDtoPage
.
setTotal
(
100
);
...
@@ -299,23 +327,25 @@ public class CommonServiceImpl {
...
@@ -299,23 +327,25 @@ public class CommonServiceImpl {
return
socialContributionDtoPage
;
return
socialContributionDtoPage
;
}
}
public
List
<
StationCacheInfoDto
>
getListStationCacheInfoDto
()
{
public
List
<
StationCacheInfoDto
>
getListStationCacheInfoDto
()
{
List
<
StationCacheInfoDto
>
stationCacheInfoDtoList
=
redisTemplate
.
opsForList
().
range
(
"station_info_cache"
,
0
,
-
1
);
List
<
StationCacheInfoDto
>
stationCacheInfoDtoList
=
redisTemplate
.
opsForList
().
range
(
"station_info_cache"
,
0
,
-
1
);
if
(
ObjectUtils
.
isEmpty
(
stationCacheInfoDtoList
))
{
if
(
ObjectUtils
.
isEmpty
(
stationCacheInfoDtoList
))
{
try
{
try
{
stationCacheDataInit
.
run
();
stationCacheDataInit
.
run
();
stationCacheInfoDtoList
=
redisTemplate
.
opsForList
().
range
(
"station_info_cache"
,
0
,
-
1
);
stationCacheInfoDtoList
=
redisTemplate
.
opsForList
().
range
(
"station_info_cache"
,
0
,
-
1
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
return
stationCacheInfoDtoList
;
return
stationCacheInfoDtoList
;
}
}
public
StationCacheInfoDto
getStationCacheInfoDtoByStationId
(
String
stationId
){
public
StationCacheInfoDto
getStationCacheInfoDtoByStationId
(
String
stationId
)
{
return
getListStationCacheInfoDto
().
stream
().
filter
(
stationCacheInfoDto
->
stationCacheInfoDto
.
getStationId
().
equals
(
stationId
)).
collect
(
Collectors
.
toList
()).
get
(
0
);
return
getListStationCacheInfoDto
().
stream
().
filter
(
stationCacheInfoDto
->
stationCacheInfoDto
.
getStationId
().
equals
(
stationId
)).
collect
(
Collectors
.
toList
()).
get
(
0
);
}
}
public
String
getFanDevicePrefix
(
String
stationid
){
StationBasic
stationBasic
=
stationBasicMapper
.
selectById
(
stationid
);
public
String
getFanDevicePrefix
(
String
stationid
)
{
return
PinyinUtil
.
getFirstLetter
(
stationBasic
.
getStationName
().
split
(
"风"
)[
0
],
""
).
toUpperCase
(
Locale
.
ROOT
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectById
(
stationid
);
return
PinyinUtil
.
getFirstLetter
(
stationBasic
.
getStationName
().
split
(
"风"
)[
0
],
""
).
toUpperCase
(
Locale
.
ROOT
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment