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
7ace2a21
authored
Dec 20, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:bug fix
parent
e289d4a1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
13 deletions
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
View file @
7ace2a21
...
@@ -57,6 +57,9 @@ public class OffBedAlarm implements IAlarm {
...
@@ -57,6 +57,9 @@ public class OffBedAlarm implements IAlarm {
log
.
error
(
"离床告警心率设备未关联长者,设备plat_id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
log
.
error
(
"离床告警心率设备未关联长者,设备plat_id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
return
;
return
;
}
}
if
(!
platDevice
.
getId
().
equals
(
"1732609639364812805"
)){
return
;
}
PlatAlarmConfig
config
=
alarmConfigCacheUtil
.
get
(
platDevice
.
getOrgId
(),
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
OFF_BED
.
getValue
());
PlatAlarmConfig
config
=
alarmConfigCacheUtil
.
get
(
platDevice
.
getOrgId
(),
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
OFF_BED
.
getValue
());
offBedCheckAlarm
(
config
,
platAlarmCheckDTO
,
platDevice
);
offBedCheckAlarm
(
config
,
platAlarmCheckDTO
,
platDevice
);
...
@@ -214,7 +217,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -214,7 +217,7 @@ public class OffBedAlarm implements IAlarm {
log
.
info
(
"deviceId:{},uncross_config:{},第一次离床时间:{}"
,
deviceId
,
config
.
getRuleConfig
(),
longToTime
(
alarmRedisDTO
.
getStartLong
()));
log
.
info
(
"deviceId:{},uncross_config:{},第一次离床时间:{}"
,
deviceId
,
config
.
getRuleConfig
(),
longToTime
(
alarmRedisDTO
.
getStartLong
()));
Integer
duration
=
ruleConfig
.
getDuration
();
Integer
duration
=
ruleConfig
.
getDuration
();
LocalTime
startTime
=
ruleConfig
.
getOffBedStart
();
LocalTime
startTime
=
ruleConfig
.
getOffBedStart
();
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
//
LocalDateTime startLocalDteTime = LocalDateTime.of(LocalDate.now(), startTime);
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
// LocalDateTime endLocalDteTime = LocalDateTime.of(LocalDate.now(), endTime);
// LocalDateTime endLocalDteTime = LocalDateTime.of(LocalDate.now(), endTime);
...
@@ -239,13 +242,14 @@ public class OffBedAlarm implements IAlarm {
...
@@ -239,13 +242,14 @@ public class OffBedAlarm implements IAlarm {
}
}
LocalDateTime
now
=
currentTime
();
LocalDateTime
now
=
currentTime
();
LocalTime
localTime
=
LocalTime
.
now
().
plusHours
(
9
);
LocalTime
localTime
=
LocalTime
.
now
().
plusHours
(
8
);
if
(!
isInTime
&&
localTime
.
isAfter
(
startTime
)
&&
localTime
.
isBefore
(
endTime
))
{
if
(!
isInTime
&&
localTime
.
isAfter
(
startTime
)
&&
localTime
.
isBefore
(
endTime
))
{
long
mills
=
Duration
.
between
(
startLocalDteTime
,
now
).
toMillis
()
/
1000
;
LocalDateTime
dateTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
long
mills
=
Duration
.
between
(
dateTime
,
now
).
toMillis
()
/
1000
;
boolean
noInOverTime
=
mills
>=
duration
*
60
;
boolean
noInOverTime
=
mills
>=
duration
*
60
;
if
(
noInOverTime
)
{
if
(
noInOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{}
"
,
deviceId
,
config
.
getRuleConfig
()
);
log
.
info
(
"deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{}
,date:{},mills:{}"
,
deviceId
,
config
.
getRuleConfig
(),
dateTime
,
mills
);
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
}
else
{
}
else
{
...
@@ -326,7 +330,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -326,7 +330,7 @@ public class OffBedAlarm implements IAlarm {
}
}
private
static
LocalDateTime
currentTime
()
{
private
static
LocalDateTime
currentTime
()
{
return
LocalDateTime
.
now
().
plusHours
(
9
);
return
LocalDateTime
.
now
().
plusHours
(
8
);
// return LocalDateTime.now();
// return LocalDateTime.now();
}
}
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
View file @
7ace2a21
...
@@ -123,7 +123,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
...
@@ -123,7 +123,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
Boolean
isUnWechatRead
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
Boolean
isUnWechatRead
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
.
anyMatch
(
a
->
CommonEnum
.
NO
.
getValue
().
equals
(
a
.
getWechatReadFlag
()));
.
anyMatch
(
a
->
CommonEnum
.
NO
.
getValue
().
equals
(
a
.
getWechatReadFlag
()));
Boolean
statusFlag
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
Boolean
statusFlag
=
CollUtil
.
isNotEmpty
(
list
)
&&
list
.
stream
()
.
anyMatch
(
a
->
CommonEnum
.
NO
.
getValue
().
equals
(
a
.
get
Status
()));
.
anyMatch
(
a
->
CommonEnum
.
NO
.
getValue
().
equals
(
a
.
get
ReadFlag
()));
Page
<
PlatAlarmRecord
>
page
=
page
(
mpPage
,
lambdaQueryWrapper
);
Page
<
PlatAlarmRecord
>
page
=
page
(
mpPage
,
lambdaQueryWrapper
);
List
<
PlatAlarmRecord
>
records
=
page
.
getRecords
();
List
<
PlatAlarmRecord
>
records
=
page
.
getRecords
();
List
<
PlatAlarmRecordVO
>
dtos
=
BeanDtoVoUtils
.
listVo
(
records
,
PlatAlarmRecordVO
.
class
);
List
<
PlatAlarmRecordVO
>
dtos
=
BeanDtoVoUtils
.
listVo
(
records
,
PlatAlarmRecordVO
.
class
);
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
7ace2a21
...
@@ -43,6 +43,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
...
@@ -43,6 +43,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.BiConsumer
;
import
java.util.function.BiConsumer
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
...
@@ -68,6 +69,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -68,6 +69,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private
PlatElderService
platElderService
;
private
PlatElderService
platElderService
;
private
void
check
(
PlatSpaceAddDTO
dto
)
{
private
void
check
(
PlatSpaceAddDTO
dto
)
{
if
(
StrUtil
.
isNotBlank
(
dto
.
getParentPath
())
&&
dto
.
getParentPath
().
split
(
","
).
length
>=
4
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
}
LambdaQueryWrapper
<
PlatSpace
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
PlatSpace
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
PlatSpace:
:
getName
,
dto
.
getName
());
queryWrapper
.
eq
(
PlatSpace:
:
getName
,
dto
.
getName
());
queryWrapper
.
ne
(
StringUtil
.
isNotEmpty
(
dto
.
getId
()),
PlatSpace:
:
getId
,
dto
.
getId
());
queryWrapper
.
ne
(
StringUtil
.
isNotEmpty
(
dto
.
getId
()),
PlatSpace:
:
getId
,
dto
.
getId
());
...
@@ -149,7 +155,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -149,7 +155,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT
);
}
}
// todo 编辑后层级大于4,不允许编辑 脏数据太多,待校验
// todo 编辑后层级大于4,不允许编辑 脏数据太多,待校验
//
checkAndUpdateSonSpace(space);
checkAndUpdateSonSpace
(
space
);
this
.
updateById
(
space
);
this
.
updateById
(
space
);
List
<
String
>
lastSpaceIds
=
recursionLastSpaceIds
(
space
.
getId
(),
new
ArrayList
<>());
List
<
String
>
lastSpaceIds
=
recursionLastSpaceIds
(
space
.
getId
(),
new
ArrayList
<>());
if
(
CollUtil
.
isEmpty
(
lastSpaceIds
))
{
if
(
CollUtil
.
isEmpty
(
lastSpaceIds
))
{
...
@@ -228,17 +234,19 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -228,17 +234,19 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
.
apply
(
StringUtils
.
isNotBlank
(
spaceId
),
"find_in_set('"
+
spaceId
+
"',parent_path)"
));
.
apply
(
StringUtils
.
isNotBlank
(
spaceId
),
"find_in_set('"
+
spaceId
+
"',parent_path)"
));
int
sonLevel
=
0
;
int
sonLevel
=
0
;
if
(
CollUtil
.
isNotEmpty
(
platSpaceList
))
{
if
(
CollUtil
.
isNotEmpty
(
platSpaceList
))
{
final
int
[]
maxLength
=
{
1
}
;
AtomicInteger
maxLength
=
new
AtomicInteger
(
1
)
;
platSpaceList
.
forEach
(
s
->
{
platSpaceList
.
forEach
(
s
->
{
if
(
StrUtil
.
isBlank
(
s
.
getParentPath
()))
{
if
(
StrUtil
.
isBlank
(
s
.
getParentPath
()))
{
return
;
return
;
}
}
String
[]
parentSpaceIds
=
s
.
getParentPath
().
split
(
","
);
List
<
String
>
parentSpaceIds
=
Lists
.
newArrayList
(
s
.
getParentPath
().
split
(
","
));
if
(
parentSpaceIds
.
length
>
maxLength
[
0
])
{
parentSpaceIds
.
remove
(
space
.
getId
());
maxLength
[
0
]
=
parentSpaceIds
.
length
;
if
(
parentSpaceIds
.
size
()
>
maxLength
.
get
())
{
maxLength
.
set
(
parentSpaceIds
.
size
());
}
}
maxLength
.
set
(
parentSpaceIds
.
size
());
});
});
sonLevel
=
maxLength
[
0
]
;
sonLevel
=
maxLength
.
get
()
;
}
}
if
(
level
+
sonLevel
>
3
)
{
if
(
level
+
sonLevel
>
3
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
...
@@ -843,7 +851,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -843,7 +851,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
}
List
<
PlatSpace
>
list
=
this
.
list
(
queryWrapper
);
List
<
PlatSpace
>
list
=
this
.
list
(
queryWrapper
);
list
=
list
.
stream
()
list
=
list
.
stream
()
.
filter
(
s
->
(
StringUtil
.
isNotEmpty
(
s
.
getParentPath
())
&&
s
.
getParentPath
().
split
(
","
).
length
<
3
)
.
filter
(
s
->
(
StringUtil
.
isNotEmpty
(
s
.
getParentPath
())
&&
s
.
getParentPath
().
split
(
","
).
length
<
=
3
)
||
StringUtil
.
isEmpty
(
s
.
getParentPath
()))
||
StringUtil
.
isEmpty
(
s
.
getParentPath
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
//父级
//父级
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
7ace2a21
package
com
.
makeit
.
mqtt
;
package
com
.
makeit
.
mqtt
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.google.common.collect.Lists
;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
...
@@ -13,6 +15,7 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
...
@@ -13,6 +15,7 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import
com.makeit.external.strategy.OpenApiBaseStrategy
;
import
com.makeit.external.strategy.OpenApiBaseStrategy
;
import
com.makeit.external.strategy.OpenApiBaseStrategyFactory
;
import
com.makeit.external.strategy.OpenApiBaseStrategyFactory
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.enums.redis.RedisConst
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.module.iot.enums.DeviceState
;
import
com.makeit.module.iot.enums.DeviceState
;
import
com.makeit.module.iot.vo.DeviceInfo
;
import
com.makeit.module.iot.vo.DeviceInfo
;
...
@@ -267,6 +270,7 @@ public class PushCallback implements MqttCallback {
...
@@ -267,6 +270,7 @@ public class PushCallback implements MqttCallback {
List
<
PlatAlarmConfig
>
configList
=
alarmConfigService
.
listOfBed
(
orgIds
);
List
<
PlatAlarmConfig
>
configList
=
alarmConfigService
.
listOfBed
(
orgIds
);
Map
<
String
,
PlatAlarmConfig
>
configMap
=
StreamUtil
.
toMap
(
configList
,
PlatAlarmConfig:
:
getOrgId
);
Map
<
String
,
PlatAlarmConfig
>
configMap
=
StreamUtil
.
toMap
(
configList
,
PlatAlarmConfig:
:
getOrgId
);
String
alarmType
=
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
OFF_BED
.
getValue
();
String
alarmType
=
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
OFF_BED
.
getValue
();
List
<
String
>
type
=
Lists
.
newArrayList
(
"OFFLINE"
,
"DISCONNECT"
);
platDeviceList
.
forEach
(
device
->
{
platDeviceList
.
forEach
(
device
->
{
for
(
IAlarm
alarm
:
alarmList
)
{
for
(
IAlarm
alarm
:
alarmList
)
{
if
(
alarm
.
support
(
alarmType
))
{
if
(
alarm
.
support
(
alarmType
))
{
...
@@ -285,6 +289,9 @@ public class PushCallback implements MqttCallback {
...
@@ -285,6 +289,9 @@ public class PushCallback implements MqttCallback {
platAlarmCheckDTO
.
setProperties
(
properties
);
platAlarmCheckDTO
.
setProperties
(
properties
);
//设备状态
//设备状态
platAlarmCheckDTO
.
setMessageType
(
messageType
);
platAlarmCheckDTO
.
setMessageType
(
messageType
);
if
(
StrUtil
.
isBlank
(
messageType
)
||
type
.
contains
(
messageType
))
{
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
device
.
getId
());
}
alarm
.
checkConfig
(
platAlarmCheckDTO
);
alarm
.
checkConfig
(
platAlarmCheckDTO
);
}
}
}
}
...
...
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