Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f7064691
authored
Sep 26, 2023
by
杨伟程
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
日睡眠图表
parent
43c81ecb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
7 deletions
server-common/src/main/java/com/makeit/utils/data/convert/MathUtil.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderDayReportWeekServiceImpl.java
server-common/src/main/java/com/makeit/utils/data/convert/MathUtil.java
View file @
f7064691
...
@@ -5,13 +5,56 @@ import java.math.RoundingMode;
...
@@ -5,13 +5,56 @@ import java.math.RoundingMode;
public
class
MathUtil
{
public
class
MathUtil
{
public
static
BigDecimal
divideZero
(
BigDecimal
a
,
BigDecimal
b
,
int
scale
,
RoundingMode
roundingMode
)
{
public
static
int
divideZero
(
int
a
,
int
b
)
{
if
(
b
==
0
)
{
return
0
;
}
return
a
/
b
;
}
public
static
long
divideZero
(
long
a
,
long
b
)
{
if
(
b
==
0
)
{
return
0
;
}
return
a
/
b
;
}
public
static
Integer
divideNull
(
int
a
,
int
b
)
{
if
(
b
==
0
)
{
return
null
;
}
return
a
/
b
;
}
public
static
Long
divideNull
(
long
a
,
long
b
)
{
if
(
b
==
0
)
{
return
null
;
}
return
a
/
b
;
}
public
static
BigDecimal
divideNull
(
BigDecimal
a
,
BigDecimal
b
,
int
scale
,
RoundingMode
roundingMode
)
{
if
(
b
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
null
;
}
return
a
.
divide
(
b
,
scale
,
roundingMode
);
}
public
static
BigDecimal
decimalDivideZero
(
BigDecimal
a
,
BigDecimal
b
,
int
scale
,
RoundingMode
roundingMode
)
{
if
(
b
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
if
(
b
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
BigDecimal
.
ZERO
;
return
BigDecimal
.
ZERO
;
}
}
return
a
.
divide
(
b
,
scale
,
roundingMode
);
return
a
.
divide
(
b
,
scale
,
roundingMode
);
}
}
public
static
BigDecimal
decimalDivideNull
(
BigDecimal
a
,
BigDecimal
b
,
int
scale
,
RoundingMode
roundingMode
)
{
if
(
b
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
null
;
}
return
a
.
divide
(
b
,
scale
,
roundingMode
);
}
public
static
BigDecimal
min
(
BigDecimal
a
,
BigDecimal
b
)
{
public
static
BigDecimal
min
(
BigDecimal
a
,
BigDecimal
b
)
{
BigDecimal
min
=
a
;
BigDecimal
min
=
a
;
...
@@ -41,11 +84,12 @@ public class MathUtil {
...
@@ -41,11 +84,12 @@ public class MathUtil {
return
Math
.
min
(
Math
.
min
(
a
,
b
),
c
);
return
Math
.
min
(
Math
.
min
(
a
,
b
),
c
);
}
}
public
static
Long
orZero
(
Long
a
){
public
static
Long
orZero
(
Long
a
)
{
return
a
==
null
?
0L
:
a
;
return
a
==
null
?
0L
:
a
;
}
}
public
static
Integer
orZero
(
Integer
a
){
return
a
==
null
?
0
:
a
;
public
static
Integer
orZero
(
Integer
a
)
{
return
a
==
null
?
0
:
a
;
}
}
}
}
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderDayReportWeekServiceImpl.java
View file @
f7064691
...
@@ -491,10 +491,17 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
...
@@ -491,10 +491,17 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
platElderBreatheDayStat
.
setHeartRateMax
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getHr
()).
max
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setHeartRateMax
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getHr
()).
max
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setHeartRateMin
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getHr
()).
min
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setHeartRateMin
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getHr
()).
min
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setHeartRateAvg
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getHr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
if
(
CollectionUtils
.
isNotEmpty
(
breatheList
))
{
platElderBreatheDayStat
.
setHeartRateAvg
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getHr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
}
platElderBreatheDayStat
.
setRespiratoryRateMax
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getBr
()).
max
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setRespiratoryRateMax
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getBr
()).
max
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setRespiratoryRateMin
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getBr
()).
min
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setRespiratoryRateMin
(
breatheList
.
stream
().
map
(
i
->
i
.
getProperties
().
getBr
()).
min
(
Integer:
:
compareTo
).
orElse
(
null
));
platElderBreatheDayStat
.
setRespiratoryRateAvg
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getBr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
if
(
CollectionUtils
.
isNotEmpty
(
breatheList
))
{
platElderBreatheDayStat
.
setRespiratoryRateAvg
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getBr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
}
breatheDayStatList
.
add
(
platElderBreatheDayStat
);
breatheDayStatList
.
add
(
platElderBreatheDayStat
);
}
}
...
...
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