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
0ebd05c3
authored
Nov 06, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:长者月报问题
parent
8cdf2ef8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
44 deletions
db/上线后sql/update.sql
server-module/src/main/java/com/makeit/module/controller/elder/PlatElderSleepController.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderReportMonthServiceImpl.java
db/上线后sql/update.sql
View file @
0ebd05c3
ALTER
TABLE
`plat_device_other`
ALTER
TABLE
`plat_device_other`
...
@@ -4,4 +4,14 @@ ADD COLUMN `secure_key` varchar(255) COMMENT '密钥key' AFTER `secure_id`;
...
@@ -4,4 +4,14 @@ ADD COLUMN `secure_key` varchar(255) COMMENT '密钥key' AFTER `secure_id`;
ALTER
TABLE
`plat_alarm_record`
ALTER
TABLE
`plat_alarm_record`
ADD
COLUMN
`misinformation_flag`
char
(
1
)
DEFAULT
0
COMMENT
'是否误报 1 误报 0 没有误报'
AFTER
`read_flag`
;
ADD
COLUMN
`misinformation_flag`
char
(
1
)
DEFAULT
0
COMMENT
'是否误报 1 误报 0 没有误报'
AFTER
`read_flag`
;
\ No newline at end of file
ALTER
TABLE
`plat_elder_report_month`
MODIFY
COLUMN
`sleep_result`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
COMMENT
'睡眠结果'
AFTER
`day`
,
MODIFY
COLUMN
`heart_rate`
int
(
11
)
COMMENT
'心率'
AFTER
`sleep_result`
,
MODIFY
COLUMN
`respiratory_rate`
int
(
11
)
COMMENT
'呼吸率'
AFTER
`heart_rate`
,
MODIFY
COLUMN
`fail_count`
int
(
11
)
COMMENT
'跌倒次数'
AFTER
`respiratory_rate`
,
MODIFY
COLUMN
`heart_exception_count`
int
(
11
)
COMMENT
'心率异常次数'
AFTER
`fail_count`
,
MODIFY
COLUMN
`respiratory_exception_count`
int
(
11
)
COMMENT
'呼吸异常次数'
AFTER
`heart_exception_count`
,
MODIFY
COLUMN
`behavior_exception_count`
int
(
11
)
COMMENT
'行为异常次数'
AFTER
`respiratory_exception_count`
;
\ No newline at end of file
server-module/src/main/java/com/makeit/module/controller/elder/PlatElderSleepController.java
View file @
0ebd05c3
...
@@ -7,6 +7,7 @@ import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
...
@@ -7,6 +7,7 @@ import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.elder.PlatElderReportMonthService
;
import
com.makeit.service.platform.elder.PlatElderSleepService
;
import
com.makeit.service.platform.elder.PlatElderSleepService
;
import
com.makeit.task.IotSyncTask
;
import
com.makeit.task.IotSyncTask
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -36,6 +37,9 @@ public class PlatElderSleepController {
...
@@ -36,6 +37,9 @@ public class PlatElderSleepController {
private
PlatElderSleepService
platElderSleepService
;
private
PlatElderSleepService
platElderSleepService
;
@Autowired
@Autowired
private
PlatDeviceService
platDeviceService
;
private
PlatDeviceService
platDeviceService
;
@Autowired
private
PlatElderReportMonthService
platElderReportMonthService
;
@ApiOperation
(
"测试"
)
@ApiOperation
(
"测试"
)
@PostMapping
(
"test"
)
@PostMapping
(
"test"
)
@AuthIgnore
@AuthIgnore
...
@@ -54,6 +58,13 @@ public class PlatElderSleepController {
...
@@ -54,6 +58,13 @@ public class PlatElderSleepController {
return
ApiResponseUtils
.
success
();
return
ApiResponseUtils
.
success
();
}
}
@ApiOperation
(
"测试"
)
@PostMapping
(
"test2"
)
@AuthIgnore
public
ApiResponseEntity
<
Void
>
reportMonthJob
()
{
platElderReportMonthService
.
reportMonthJob
();
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"编辑设备属性"
)
@ApiOperation
(
"编辑设备属性"
)
@PostMapping
(
"editDeviceProperties"
)
@PostMapping
(
"editDeviceProperties"
)
...
...
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderReportMonthServiceImpl.java
View file @
0ebd05c3
...
@@ -9,6 +9,7 @@ import com.makeit.entity.platform.elder.PlatElder;
...
@@ -9,6 +9,7 @@ import com.makeit.entity.platform.elder.PlatElder;
import
com.makeit.entity.platform.elder.PlatElderReportMonth
;
import
com.makeit.entity.platform.elder.PlatElderReportMonth
;
import
com.makeit.entity.platform.elder.PlatElderSleepAnalysis
;
import
com.makeit.entity.platform.elder.PlatElderSleepAnalysis
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.mapper.platform.elder.PlatElderReportMonthMapper
;
import
com.makeit.mapper.platform.elder.PlatElderReportMonthMapper
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe
;
import
com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe
;
...
@@ -140,8 +141,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
...
@@ -140,8 +141,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
}
}
@Override
@Override
@TenantIdIgnore
public
void
reportMonthJob
()
{
public
void
reportMonthJob
()
{
LocalDate
nowDate
=
LocalDate
.
now
();
LocalDate
nowDate
=
LocalDate
.
now
()
.
minusDays
(
6
)
;
LocalDate
yesDate
=
nowDate
.
minusDays
(
1
);
LocalDate
yesDate
=
nowDate
.
minusDays
(
1
);
LocalDateTime
yesStart
=
LocalDateTimeUtils
.
getDayStart
(
yesDate
);
LocalDateTime
yesStart
=
LocalDateTimeUtils
.
getDayStart
(
yesDate
);
...
@@ -151,59 +153,56 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
...
@@ -151,59 +153,56 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
List
<
PlatElderReportMonth
>
reportMonthList
=
new
ArrayList
<>(
10
);
List
<
PlatElderReportMonth
>
reportMonthList
=
new
ArrayList
<>(
10
);
platTenantService
.
executeTenantList
(()
->
{
List
<
PlatElder
>
elderList
=
platElderService
.
list
(
new
QueryWrapper
<
PlatElder
>().
lambda
()
List
<
PlatElder
>
elderList
=
platElderService
.
list
(
new
QueryWrapper
<
PlatElder
>().
lambda
()
.
isNotNull
(
PlatElder:
:
getBedId
));
.
isNotNull
(
PlatElder:
:
getBedId
));
List
<
PlatElderSleepAnalysis
>
sleepAnalysesList
=
platElderSleepAnalysisService
.
list
(
new
QueryWrapper
<
PlatElderSleepAnalysis
>().
lambda
()
List
<
PlatElderSleepAnalysis
>
sleepAnalysesList
=
platElderSleepAnalysisService
.
list
(
new
QueryWrapper
<
PlatElderSleepAnalysis
>().
lambda
()
.
in
(
PlatElderSleepAnalysis:
:
getElderId
,
StreamUtil
.
mapId
(
elderList
,
PlatElder:
:
getId
))
.
in
(
PlatElderSleepAnalysis:
:
getElderId
,
StreamUtil
.
mapId
(
elderList
,
PlatElder:
:
getId
))
.
eq
(
PlatElderSleepAnalysis:
:
getHappenDate
,
dateTimeFormatter
.
format
(
yesDate
))
.
eq
(
PlatElderSleepAnalysis:
:
getHappenDate
,
dateTimeFormatter
.
format
(
yesDate
))
);
);
Map
<
String
,
PlatElderSleepAnalysis
>
sleepAnalysisMap
=
StreamUtil
.
toMap
(
sleepAnalysesList
,
PlatElderSleepAnalysis:
:
getElderId
);
List
<
PlatAlarmRecord
>
recordList
=
platAlarmRecordService
.
list
(
new
QueryWrapper
<
PlatAlarmRecord
>().
lambda
()
.
in
(
PlatAlarmRecord:
:
getElderIds
,
StreamUtil
.
mapId
(
elderList
,
PlatElder:
:
getId
)));
Map
<
String
,
List
<
PlatAlarmRecord
>>
recordMap
=
StreamUtil
.
groupBy
(
recordList
,
PlatAlarmRecord:
:
getElderIds
);
elderList
.
forEach
(
e
->
{
PlatElderReportMonth
reportMonth
=
new
PlatElderReportMonth
();
reportMonth
.
setElderId
(
e
.
getBedId
());
reportMonth
.
setDay
(
yesDate
);
MapUtil
.
setIfPresent
(
sleepAnalysisMap
,
e
.
getId
(),
sa
->
{
reportMonth
.
setSleepResult
(
sa
.
getSleepResult
());
});
PlatDevice
platDevice
=
platElderRealTimeService
.
getBreathDevice
(
e
.
getId
(),
null
);
Map
<
String
,
PlatElderSleepAnalysis
>
sleepAnalysisMap
=
StreamUtil
.
toMap
(
sleepAnalysesList
,
PlatElderSleepAnalysis:
:
getElderId
);
List
<
DeviceInfoContentBreathe
>
breatheList
=
iotProductDeviceService
.
getDeviceLogByTimeRangeBreathe
(
platDevice
.
getOriDeviceId
(),
2
*
24
*
3600
,
yesStart
,
yesEnd
);
List
<
PlatAlarmRecord
>
recordList
=
platAlarmRecordService
.
list
(
new
QueryWrapper
<
PlatAlarmRecord
>().
lambda
()
.
in
(
PlatAlarmRecord:
:
getElderIds
,
StreamUtil
.
mapId
(
elderList
,
PlatElder:
:
getId
)));
if
(
CollectionUtils
.
isNotEmpty
(
breatheList
))
{
Map
<
String
,
List
<
PlatAlarmRecord
>>
recordMap
=
StreamUtil
.
groupBy
(
recordList
,
PlatAlarmRecord:
:
getElderIds
);
reportMonth
.
setBreatheDeviceId
(
platDevice
.
getId
());
for
(
PlatElder
e
:
elderList
)
{
reportMonth
.
setBreatheOriDeviceId
(
platDevice
.
getOriDeviceId
());
PlatElderReportMonth
reportMonth
=
new
PlatElderReportMonth
();
reportMonth
.
setElderId
(
e
.
getId
());
reportMonth
.
setDay
(
yesDate
);
reportMonth
.
setHeartRate
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getHr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
MapUtil
.
setIfPresent
(
sleepAnalysisMap
,
e
.
getId
(),
sa
->
{
reportMonth
.
setRespiratoryRate
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getBr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()
));
reportMonth
.
setSleepResult
(
sa
.
getSleepResult
(
));
}
});
List
<
PlatAlarmRecord
>
rList
=
Optional
.
ofNullable
(
recordMap
.
get
(
e
.
getId
())).
orElse
(
new
ArrayList
<>(
10
));
PlatDevice
platDevice
=
platElderRealTimeService
.
getBreathDevice
(
e
.
getId
(),
null
);
if
(
platDevice
==
null
)
{
continue
;
}
reportMonth
.
setFailCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
FALL
.
getValue
().
equals
(
i
.
getAlarmType
())));
List
<
DeviceInfoContentBreathe
>
breatheList
=
iotProductDeviceService
.
getDeviceLogByTimeRangeBreathe
(
platDevice
.
getOriDeviceId
(),
2
*
24
*
3600
,
yesStart
,
yesEnd
);
reportMonth
.
setHeartExceptionCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
HEART
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonth
.
setRespiratoryExceptionCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BREATHE
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonth
.
setBehaviorExceptionCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BEHAVIOR
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonthList
.
add
(
reportMonth
);
if
(
CollectionUtils
.
isNotEmpty
(
breatheList
))
{
});
reportMonth
.
setBreatheDeviceId
(
platDevice
.
getId
());
reportMonth
.
setBreatheOriDeviceId
(
platDevice
.
getOriDeviceId
());
saveBatch
(
reportMonthList
);
reportMonth
.
setHeartRate
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getHr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
reportMonth
.
setRespiratoryRate
((
int
)
(
StreamUtil
.
reduce
(
breatheList
,
i
->
(
long
)
i
.
getProperties
().
getBr
(),
0L
,
Long:
:
sum
)
/
breatheList
.
size
()));
}
List
<
PlatAlarmRecord
>
rList
=
Optional
.
ofNullable
(
recordMap
.
get
(
e
.
getId
())).
orElse
(
new
ArrayList
<>(
10
));
});
reportMonth
.
setFailCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
FALL
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonth
.
setHeartExceptionCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
HEART
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonth
.
setRespiratoryExceptionCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BREATHE
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonth
.
setBehaviorExceptionCount
((
int
)
StreamUtil
.
count
(
rList
,
i
->
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BEHAVIOR
.
getValue
().
equals
(
i
.
getAlarmType
())));
reportMonth
.
setTenantId
(
e
.
getTenantId
());
reportMonthList
.
add
(
reportMonth
);
}
saveBatch
(
reportMonthList
);
}
}
}
}
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