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
aad41a52
authored
Feb 01, 2024
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:中度睡眠计算
parent
bb3ec1af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
23 deletions
server-service/src/main/java/com/makeit/service/platform/elder/impl/DeviceLogServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderSleepServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/DeviceLogServiceImpl.java
View file @
aad41a52
...
@@ -112,7 +112,8 @@ public class DeviceLogServiceImpl implements DeviceLogService {
...
@@ -112,7 +112,8 @@ public class DeviceLogServiceImpl implements DeviceLogService {
public
static
List
<
String
>
getDayMinute
(
Integer
month
,
Integer
day
)
{
public
static
List
<
String
>
getDayMinute
(
Integer
month
,
Integer
day
)
{
List
<
String
>
list
=
Lists
.
newArrayList
();
List
<
String
>
list
=
Lists
.
newArrayList
();
LocalDateTime
now
=
LocalDateTime
.
of
(
2024
,
month
,
day
-
1
,
8
,
0
);
LocalDateTime
of1
=
LocalDateTime
.
of
(
2024
,
month
,
day
,
8
,
0
);
LocalDateTime
now
=
of1
.
plusDays
(-
1
);
for
(
int
i
=
0
;
i
<
24
;
i
++)
{
for
(
int
i
=
0
;
i
<
24
;
i
++)
{
int
hour
=
now
.
getHour
();
int
hour
=
now
.
getHour
();
for
(
int
j
=
0
;
j
<
60
;
j
++)
{
for
(
int
j
=
0
;
j
<
60
;
j
++)
{
...
...
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderSleepServiceImpl.java
View file @
aad41a52
...
@@ -501,9 +501,12 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
...
@@ -501,9 +501,12 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
*/
*/
private
void
middleSleep
(
TreeMap
<
String
,
TreeMap
<
String
,
AnalysisVO
>>
sleepTypeMap
,
SaasSleepAnalysisModel
analysisModel
,
private
void
middleSleep
(
TreeMap
<
String
,
TreeMap
<
String
,
AnalysisVO
>>
sleepTypeMap
,
SaasSleepAnalysisModel
analysisModel
,
List
<
SleepTimeAnalysisVO
>
sleepTimeAnalysisVOList
)
{
List
<
SleepTimeAnalysisVO
>
sleepTimeAnalysisVOList
)
{
//3次
int
sleepModerateActionThreshold
=
Integer
.
parseInt
(
analysisModel
.
getSleepModerateActionThreshold
());
int
sleepModerateActionThreshold
=
Integer
.
parseInt
(
analysisModel
.
getSleepModerateActionThreshold
());
// 10minute
int
sleepModerateActionTimeBegin
=
Integer
.
parseInt
(
analysisModel
.
getSleepModerateActionTimeBegin
());
int
sleepModerateActionTimeBegin
=
Integer
.
parseInt
(
analysisModel
.
getSleepModerateActionTimeBegin
());
int
sleepMidMinute
=
0
;
int
sleepMidMinute
=
0
;
int
size
=
0
;
String
startSleepMidTime
=
null
;
String
startSleepMidTime
=
null
;
boolean
isMiddleSleep
=
false
;
boolean
isMiddleSleep
=
false
;
...
@@ -512,43 +515,42 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
...
@@ -512,43 +515,42 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
String
key
=
entry
.
getKey
();
String
key
=
entry
.
getKey
();
for
(
Map
.
Entry
<
String
,
AnalysisVO
>
voEntry
:
sleepMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
AnalysisVO
>
voEntry
:
sleepMap
.
entrySet
())
{
AnalysisVO
analysisVO
=
voEntry
.
getValue
();
AnalysisVO
analysisVO
=
voEntry
.
getValue
();
boolean
condition
=
analysisVO
.
getActionCount
()
<
sleepModerateActionThreshold
&&
analysisVO
.
getTurnedCount
()
<
sleepModerateActionThreshold
;
String
key1
=
voEntry
.
getKey
();
Integer
actionCount
=
analysisVO
.
getActionCount
();
Integer
turnedCount
=
analysisVO
.
getTurnedCount
();
boolean
isAction
=
actionCount
>
sleepModerateActionThreshold
;
boolean
isTurned
=
turnedCount
>
sleepModerateActionThreshold
;
SleepTimeAnalysisVO
sleepTimeAnalysisVO
=
new
SleepTimeAnalysisVO
();
SleepTimeAnalysisVO
sleepTimeAnalysisVO
=
new
SleepTimeAnalysisVO
();
if
(
condition
)
{
size
++;
if
(
StringUtils
.
isEmpty
(
startSleepMidTime
))
{
long
between
=
0
;
startSleepMidTime
=
voEntry
.
getKey
();
if
(
startSleepMidTime
!=
null
)
{
between
=
Duration
.
between
(
LocalDateTime
.
parse
(
startSleepMidTime
,
DEFAULT_FORMATTER
),
LocalDateTime
.
parse
(
key1
,
DEFAULT_FORMATTER
)).
toMinutes
();
}
}
long
between
=
Duration
.
between
(
LocalDateTime
.
parse
(
startSleepMidTime
,
DEFAULT_FORMATTER
),
if
(!
isAction
&&
!
isTurned
)
{
LocalDateTime
.
parse
(
voEntry
.
getKey
(),
DEFAULT_FORMATTER
)).
toMinutes
();
if
(
StringUtils
.
isEmpty
(
startSleepMidTime
))
{
if
(
between
==
sleepMidMinute
){
startSleepMidTime
=
key1
;
sleepMidMinute
++;
}
else
{
if
(
isMiddleSleep
){
sleepTimeAnalysisVO
.
setEndTime
(
voEntry
.
getKey
());
}
}
sleepMidMinute
+=
actionCount
;
sleepMidMinute
+=
turnedCount
;
}
else
{
sleepMidMinute
=
0
;
sleepMidMinute
=
0
;
startSleepMidTime
=
null
;
startSleepMidTime
=
null
;
}
continue
;
continue
;
}
}
String
endTime
=
sleepTimeAnalysisVO
.
getEndTime
();
if
(
StringUtils
.
isEmpty
(
startSleepMidTime
)
&&
sleepMidMinute
==
0
)
{
if
(
StringUtils
.
isEmpty
(
startSleepMidTime
)
&&
sleepMidMinute
==
0
)
{
continue
;
continue
;
}
}
if
(
sleepMidMinute
>
sleepModerateActionTimeBegin
&&
!
isMiddleSleep
)
{
boolean
condition
=
sleepMidMinute
>=
sleepModerateActionThreshold
&&
between
>
sleepModerateActionTimeBegin
;
if
(
condition
||
size
==
sleepMap
.
size
()
-
1
)
{
sleepTimeAnalysisVO
.
setStartTime
(
startSleepMidTime
);
sleepTimeAnalysisVO
.
setStartTime
(
startSleepMidTime
);
sleepTimeAnalysisVO
.
setEndTime
(
voEntry
.
getKey
()
);
sleepTimeAnalysisVO
.
setEndTime
(
key1
);
sleepTimeAnalysisVO
.
setType
(
SleepTypeEnum
.
SLEEP_MODERATE
.
getCode
());
sleepTimeAnalysisVO
.
setType
(
SleepTypeEnum
.
SLEEP_MODERATE
.
getCode
());
sleepTimeAnalysisVO
.
setBelongToSleepTime
(
key
);
sleepTimeAnalysisVO
.
setBelongToSleepTime
(
key
);
sleepTimeAnalysisVOList
.
add
(
sleepTimeAnalysisVO
);
sleepTimeAnalysisVOList
.
add
(
sleepTimeAnalysisVO
);
isMiddleSleep
=
true
;
}
if
(
isMiddleSleep
&&
StrUtil
.
isNotBlank
(
endTime
))
{
startSleepMidTime
=
null
;
startSleepMidTime
=
null
;
sleepMidMinute
=
0
;
sleepMidMinute
=
0
;
isMiddleSleep
=
false
;
}
}
}
}
}
}
}
}
...
@@ -896,7 +898,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
...
@@ -896,7 +898,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
}
}
String
tenantId
=
elder
.
getTenantId
();
String
tenantId
=
elder
.
getTenantId
();
// dayHourRangeList = Lists.newArrayList("2024-01-30 09:45:00~2024-01-30 09:45:1
0");
dayHourRangeList
=
Lists
.
newArrayList
(
"2024-01-29 23:38:00~2024-01-30 01:53:0
0"
);
for
(
String
hourRange
:
dayHourRangeList
)
{
for
(
String
hourRange
:
dayHourRangeList
)
{
String
[]
hourRangeArray
=
hourRange
.
split
(
"~"
);
String
[]
hourRangeArray
=
hourRange
.
split
(
"~"
);
List
<
DeviceOperationLogEntity
>
deviceOperationLogEntities
=
productDeviceService
.
getDeviceLogByTimeRange
(
platDevice
.
getOriDeviceId
(),
"reportProperty"
,
5000
,
hourRangeArray
[
0
],
hourRangeArray
[
1
]);
List
<
DeviceOperationLogEntity
>
deviceOperationLogEntities
=
productDeviceService
.
getDeviceLogByTimeRange
(
platDevice
.
getOriDeviceId
(),
"reportProperty"
,
5000
,
hourRangeArray
[
0
],
hourRangeArray
[
1
]);
...
@@ -912,7 +914,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
...
@@ -912,7 +914,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
return
deviceInfoContentBreathe
;
return
deviceInfoContentBreathe
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
DeviceInfoContentBreathe
>>
minuteMap
=
StreamUtil
.
groupBy
(
deviceInfoContentBreatheList
,
DeviceInfoContentBreathe:
:
getReportTime
);
Map
<
String
,
List
<
DeviceInfoContentBreathe
>>
minuteMap
=
StreamUtil
.
groupBy
(
deviceInfoContentBreatheList
,
DeviceInfoContentBreathe:
:
getReportTime
);
deviceLogService
.
save
(
deviceOperationLogEntities
);
//
deviceLogService.save(deviceOperationLogEntities);
deviceOperationLogEntities
.
clear
();
deviceOperationLogEntities
.
clear
();
TreeMap
<
String
,
AnalysisVO
>
statisticsMap
=
getPerMinuteData
(
minuteMap
,
analysisModel
);
TreeMap
<
String
,
AnalysisVO
>
statisticsMap
=
getPerMinuteData
(
minuteMap
,
analysisModel
);
if
(
CollUtil
.
isNotEmpty
(
statisticsMap
))
{
if
(
CollUtil
.
isNotEmpty
(
statisticsMap
))
{
...
...
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