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
6d364455
authored
Nov 03, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
398f1437
54708acf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
12 deletions
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/FallAlarm.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-service/src/main/java/com/makeit/utils/DayDurationUtil.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/FallAlarm.java
View file @
6d364455
...
@@ -99,15 +99,16 @@ public class FallAlarm implements IAlarm {
...
@@ -99,15 +99,16 @@ public class FallAlarm implements IAlarm {
private
void
recordDuration
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
private
void
recordDuration
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatAlarmConfig
config
=
alarmConfigCacheUtil
.
get
(
platDevice
.
getOrgId
(),
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BEHAVIOR
.
getValue
());
PlatAlarmConfig
config
=
alarmConfigCacheUtil
.
get
(
platDevice
.
getOrgId
(),
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BEHAVIOR
.
getValue
());
if
(
config
==
null
||
StringUtils
.
isBlank
(
config
.
getRuleConfig
()))
{
log
.
error
(
"行为告警配置未配置,告警配置id:"
+
config
.
getId
());
return
;
}
String
ruleConfigStr
=
config
.
getRuleConfig
();
String
ruleConfigStr
=
config
.
getRuleConfig
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
if
(
StringUtils
.
isBlank
(
ruleConfigStr
))
{
log
.
error
(
"行为告警配置未配置,告警配置id:"
+
config
.
getId
());
return
;
}
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
person
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
String
person
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
PlatAlarmConfigBehaviorDTOVO
ruleConfig
=
JsonUtil
.
toObj
(
ruleConfigStr
,
PlatAlarmConfigBehaviorDTOVO
.
class
);
PlatAlarmConfigBehaviorDTOVO
ruleConfig
=
JsonUtil
.
toObj
(
ruleConfigStr
,
PlatAlarmConfigBehaviorDTOVO
.
class
);
...
@@ -155,7 +156,9 @@ public class FallAlarm implements IAlarm {
...
@@ -155,7 +156,9 @@ public class FallAlarm implements IAlarm {
if
(
duration1
!=
0
)
{
if
(
duration1
!=
0
)
{
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BEHAVIOR_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BEHAVIOR_ID
+
deviceId
,
alarmRedisDTO
);
notice
(
platAlarmCheckDTO
);
PlatAlarmCheckDTO
platAlarmCheckDTO_behavior
=
BeanDtoVoUtils
.
convert
(
platAlarmCheckDTO
,
PlatAlarmCheckDTO
.
class
);
platAlarmCheckDTO_behavior
.
setPlatAlarmConfig
(
config
);
notice
(
platAlarmCheckDTO_behavior
);
}
else
{
}
else
{
return
;
return
;
}
}
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
6d364455
...
@@ -686,6 +686,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -686,6 +686,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
}
platRoomService
.
save
(
platRoom
);
platRoomService
.
save
(
platRoom
);
//已有房间的空间不允许再创建下级
lastSpaceIds
.
add
(
platRoom
.
getSpaceId
());
platBedService
.
add
(
platRoom
);
platBedService
.
add
(
platRoom
);
}
}
}
}
...
...
server-service/src/main/java/com/makeit/utils/DayDurationUtil.java
View file @
6d364455
...
@@ -40,8 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
...
@@ -40,8 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
return
;
return
;
}
}
Map
<
String
,
List
<
PlatDayDurationRecord
>>
deviceIdMap
=
platDayDurationRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatDayDurationRecord:
:
getDeviceId
));
Map
<
String
,
List
<
PlatDayDurationRecord
>>
deviceIdMap
=
platDayDurationRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatDayDurationRecord:
:
getDeviceId
));
//七天
都得有
数据
//七天
内 至少有三条
数据
deviceIdMap
.
entrySet
().
stream
().
filter
(
vo
->
vo
.
getValue
().
size
()>=
7
).
map
(
vo
->
{
deviceIdMap
.
entrySet
().
stream
().
filter
(
vo
->
vo
.
getValue
().
size
()>=
3
).
map
(
vo
->
{
List
<
PlatDayDurationRecord
>
value
=
vo
.
getValue
();
List
<
PlatDayDurationRecord
>
value
=
vo
.
getValue
();
int
size
=
value
.
size
();
int
size
=
value
.
size
();
int
mid
=
size
/
2
;
int
mid
=
size
/
2
;
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
6d364455
...
@@ -171,17 +171,19 @@ public class PushCallback implements MqttCallback {
...
@@ -171,17 +171,19 @@ public class PushCallback implements MqttCallback {
}
}
@Transactional
@Transactional
@TenantIdIgnore
public
void
updateDeviceStatus
(
String
messageType
,
String
deviceId
,
String
iot_tenantId
)
{
public
void
updateDeviceStatus
(
String
messageType
,
String
deviceId
,
String
iot_tenantId
)
{
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
DeviceState
.
offline
.
getValue
(),
DeviceState
.
online
.
getValue
())){
try
{
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
DeviceState
.
offline
.
getValue
(),
DeviceState
.
online
.
getValue
()))
{
platDeviceService
.
update
(
new
UpdateWrapper
<
PlatDevice
>().
lambda
()
platDeviceService
.
update
(
new
UpdateWrapper
<
PlatDevice
>().
lambda
()
.
set
(
PlatDevice:
:
getStatus
,
messageType
.
toLowerCase
())
.
set
(
PlatDevice:
:
getStatus
,
messageType
.
toLowerCase
())
.
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
));
.
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
));
LambdaQueryWrapper
<
PlatDevice
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
PlatDevice
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
deviceLambdaQueryWrapper
.
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
);
deviceLambdaQueryWrapper
.
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
);
List
<
PlatDevice
>
deviceList
=
platDeviceService
.
list
(
deviceLambdaQueryWrapper
);
List
<
PlatDevice
>
deviceList
=
platDeviceService
.
list
(
deviceLambdaQueryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
deviceList
))
{
if
(
CollectionUtils
.
isEmpty
(
deviceList
))
{
return
;
return
;
}
}
for
(
PlatDevice
platDevice
:
deviceList
)
{
for
(
PlatDevice
platDevice
:
deviceList
)
{
...
@@ -189,6 +191,9 @@ public class PushCallback implements MqttCallback {
...
@@ -189,6 +191,9 @@ public class PushCallback implements MqttCallback {
}
}
deviceCacheUtil
.
putAll
(
deviceList
);
deviceCacheUtil
.
putAll
(
deviceList
);
}
}
}
catch
(
Exception
e
){
logger
.
error
(
"更新设备状态:"
,
e
);
}
}
}
...
...
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