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
179470b5
Commit
179470b5
authored
Feb 19, 2024
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复如果es数据为空接口报错问题
parent
dd1cb3d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+9
-3
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
179470b5
...
@@ -97,7 +97,9 @@ public class CommonServiceImpl {
...
@@ -97,7 +97,9 @@ public class CommonServiceImpl {
public
Double
getAvagerByEquipmentIndxName
(
List
<
ESEquipments
>
equipments
,
String
indexName
)
{
public
Double
getAvagerByEquipmentIndxName
(
List
<
ESEquipments
>
equipments
,
String
indexName
)
{
Double
result
=
0.00
;
Double
result
=
0.00
;
result
=
equipments
.
stream
().
filter
(
esEquipments
->
esEquipments
.
getEquipmentIndexName
().
equals
(
indexName
)).
filter
(
esEquipments
->
esEquipments
.
getValueF
()
!=
null
).
mapToDouble
(
ESEquipments:
:
getValueF
).
average
().
getAsDouble
();
if
(!
ObjectUtils
.
isEmpty
(
equipments
))
{
result
=
equipments
.
stream
().
filter
(
esEquipments
->
esEquipments
.
getEquipmentIndexName
().
equals
(
indexName
)).
filter
(
esEquipments
->
esEquipments
.
getValueF
()
!=
null
).
mapToDouble
(
ESEquipments:
:
getValueF
).
average
().
getAsDouble
();
}
return
result
;
return
result
;
}
}
...
@@ -128,7 +130,9 @@ public class CommonServiceImpl {
...
@@ -128,7 +130,9 @@ public class CommonServiceImpl {
// }
// }
public
Double
getTotalByIndicatior
(
List
<
Map
<
String
,
Object
>>
mapList
,
String
indicator
)
{
public
Double
getTotalByIndicatior
(
List
<
Map
<
String
,
Object
>>
mapList
,
String
indicator
)
{
Double
totalvalue
=
0.0
;
Double
totalvalue
=
0.0
;
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
();
if
(!
ObjectUtils
.
isEmpty
(
mapList
))
{
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
();
}
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
}
}
...
@@ -139,7 +143,9 @@ public class CommonServiceImpl {
...
@@ -139,7 +143,9 @@ public class CommonServiceImpl {
*/
*/
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.0
;
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
();
if
(!
ObjectUtils
.
isEmpty
(
mapList
))
{
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
();
}
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
}
}
...
...
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