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
3909acb0
authored
Dec 13, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
e5c3e16d
f551a574
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
60 deletions
server-module/src/main/java/com/makeit/module/controller/children/alarm/PlatAlarmRecordChildrenController.java
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceBaseAttrDTO.java
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-module/src/main/java/com/makeit/module/controller/children/alarm/PlatAlarmRecordChildrenController.java
View file @
3909acb0
...
@@ -40,7 +40,7 @@ public class PlatAlarmRecordChildrenController {
...
@@ -40,7 +40,7 @@ public class PlatAlarmRecordChildrenController {
PageVO
<
PlatAlarmRecordVO
>
result
=
platAlarmRecordService
.
childrenPage
(
dto
);
PageVO
<
PlatAlarmRecordVO
>
result
=
platAlarmRecordService
.
childrenPage
(
dto
);
Map
<
String
,
Object
>
resMap
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
resMap
=
Maps
.
newHashMap
();
boolean
b
=
result
.
getList
().
stream
().
anyMatch
(
p
->
StringUtils
.
equals
(
CommonEnum
.
NO
.
getValue
(),
p
.
getWechatReadFlag
()));
boolean
b
=
result
.
getList
().
stream
().
anyMatch
(
p
->
StringUtils
.
equals
(
CommonEnum
.
NO
.
getValue
(),
p
.
getWechatReadFlag
()));
resMap
.
put
(
"
wechatRead
Flag"
,
b
);
resMap
.
put
(
"
todo
Flag"
,
b
);
resMap
.
put
(
"page"
,
result
);
resMap
.
put
(
"page"
,
result
);
return
ApiResponseUtils
.
success
(
resMap
);
return
ApiResponseUtils
.
success
(
resMap
);
}
}
...
...
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceBaseAttrDTO.java
View file @
3909acb0
...
@@ -42,6 +42,10 @@ public class PlatDeviceBaseAttrDTO {
...
@@ -42,6 +42,10 @@ public class PlatDeviceBaseAttrDTO {
private
DeviceAttrRange
radarAngle
;
private
DeviceAttrRange
radarAngle
;
@ApiModelProperty
(
value
=
"雷达检测延迟时间 单位S ,范围:0-32768"
)
@ApiModelProperty
(
value
=
"雷达检测延迟时间 单位S ,范围:0-32768"
)
private
Integer
radarDelay
;
private
Integer
radarDelay
;
@ApiModelProperty
(
value
=
"雷达安装场景 0:客厅;1:卧室;2:卫生间"
)
private
Integer
radarSence
;
@ApiModelProperty
(
value
=
"雷达灵敏度 0:灵敏;1:标准;2:鲁棒"
)
private
Integer
radarSPL
;
@Data
@Data
...
...
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
View file @
3909acb0
package
com
.
makeit
.
service
.
platform
.
device
;
package
com
.
makeit
.
service
.
platform
.
device
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.dto.BaseIdDTO
;
...
@@ -94,5 +93,5 @@ public interface PlatDeviceService extends IService<PlatDevice> {
...
@@ -94,5 +93,5 @@ public interface PlatDeviceService extends IService<PlatDevice> {
void
devicePushLog
(
MultipartFile
multipartFile
,
String
deviceId
)
throws
IOException
;
void
devicePushLog
(
MultipartFile
multipartFile
,
String
deviceId
)
throws
IOException
;
void
receiveIotProperties
(
String
deviceId
,
JSONObject
iotProperties
);
void
syncIotProperties
(
String
deviceId
);
}
}
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
3909acb0
...
@@ -69,6 +69,7 @@ import com.makeit.shengwang.agora.service.ShengwangService;
...
@@ -69,6 +69,7 @@ import com.makeit.shengwang.agora.service.ShengwangService;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.JsonUtil
;
import
com.makeit.utils.data.convert.PageUtil
;
import
com.makeit.utils.data.convert.PageUtil
;
import
com.makeit.utils.data.convert.StreamUtil
;
import
com.makeit.utils.data.convert.StreamUtil
;
import
com.makeit.utils.old.StringUtils
;
import
com.makeit.utils.old.StringUtils
;
...
@@ -380,6 +381,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -380,6 +381,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
BeanUtils
.
copyProperties
(
dto
,
platDeviceOther
,
"id"
);
BeanUtils
.
copyProperties
(
dto
,
platDeviceOther
,
"id"
);
platDeviceOther
.
setDeviceId
(
id
);
platDeviceOther
.
setDeviceId
(
id
);
platDeviceOther
.
setAttribute
(
JSON
.
toJSONString
(
getDeviceBaseAttrDTO
(
db
.
getOriDeviceId
())));
platDeviceOther
.
setOriDeviceId
(
db
.
getOriDeviceId
());
platDeviceOther
.
setOriDeviceId
(
db
.
getOriDeviceId
());
platDeviceOtherService
.
saveOrUpdate
(
platDeviceOther
);
platDeviceOtherService
.
saveOrUpdate
(
platDeviceOther
);
}
}
...
@@ -931,45 +933,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -931,45 +933,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
}
@Override
@Override
@TenantIdIgnore
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
receiveIotProperties
(
String
deviceId
,
JSONObject
iotProperties
)
{
public
void
syncIotProperties
(
String
deviceId
)
{
PlatDeviceOther
deviceOther
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
getDeviceBaseAttrDTO
(
deviceId
);
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
last
(
"limit 1"
));
if
(
deviceOther
==
null
)
{
log
.
warn
(
"iot修改属性回复,设备其他信息不存在,设备id:{}"
,
deviceId
);
return
;
}
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
JSON
.
parseObject
(
deviceOther
.
getAttribute
(),
PlatDeviceBaseAttrDTO
.
class
);
if
(
platDeviceBaseAttrDTO
==
null
)
{
platDeviceBaseAttrDTO
=
new
PlatDeviceBaseAttrDTO
();
}
PlatDeviceBaseAttrDTO
iotAttr
=
iotProperties
.
toJavaObject
(
PlatDeviceBaseAttrDTO
.
class
);
if
(
iotAttr
.
getRadarMode
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMode
(),
iotAttr
.
getRadarMode
()))
{
platDeviceBaseAttrDTO
.
setRadarMode
(
iotAttr
.
getRadarMode
());
}
if
(
iotAttr
.
getRadarMount
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMount
(),
iotAttr
.
getRadarMount
()))
{
platDeviceBaseAttrDTO
.
setRadarMount
(
iotAttr
.
getRadarMount
());
}
if
(
iotAttr
.
getRadarHight
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarHight
(),
iotAttr
.
getRadarHight
()))
{
platDeviceBaseAttrDTO
.
setRadarHight
(
iotAttr
.
getRadarHight
());
}
if
(
iotAttr
.
getRadarDelay
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDelay
(),
iotAttr
.
getRadarDelay
()))
{
platDeviceBaseAttrDTO
.
setRadarDelay
(
iotAttr
.
getRadarDelay
());
}
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarDistance
=
platDeviceBaseAttrDTO
.
getRadarDistance
();
if
(
iotAttr
.
getRadarDistance
()
!=
null
&&
!
Objects
.
equals
(
radarDistance
,
iotAttr
.
getRadarDistance
()))
{
if
(
radarDistance
!=
null
&&
radarDistance
.
getMax
()
!=
null
&&
radarDistance
.
getMin
()
!=
null
)
{
platDeviceBaseAttrDTO
.
setRadarDistance
(
iotAttr
.
getRadarDistance
());
}
}
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarAngle
=
platDeviceBaseAttrDTO
.
getRadarAngle
();
if
(
iotAttr
.
getRadarAngle
()
!=
null
&&
!
Objects
.
equals
(
radarAngle
,
iotAttr
.
getRadarAngle
()))
{
if
(
radarAngle
!=
null
&&
radarAngle
.
getMax
()
!=
null
&&
radarAngle
.
getMin
()
!=
null
)
{
platDeviceBaseAttrDTO
.
setRadarAngle
(
iotAttr
.
getRadarAngle
());
}
}
String
attr
=
JSON
.
toJSONString
(
platDeviceBaseAttrDTO
);
String
attr
=
JSON
.
toJSONString
(
platDeviceBaseAttrDTO
);
platDeviceOtherService
.
update
(
new
UpdateWrapper
<
PlatDeviceOther
>().
lambda
()
platDeviceOtherService
.
update
(
new
UpdateWrapper
<
PlatDeviceOther
>().
lambda
()
.
set
(
PlatDeviceOther:
:
getAttribute
,
attr
)
.
set
(
PlatDeviceOther:
:
getAttribute
,
attr
)
...
@@ -983,4 +949,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -983,4 +949,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
}
}
}
private
PlatDeviceBaseAttrDTO
getDeviceBaseAttrDTO
(
String
deviceId
)
{
String
propertiesName
=
"radarMount,radarMode,radarHight,radarDistance,radarAngle,radarDelay,radarSence,radarSPL"
;
PlatDeviceAttrWechatDTO
dto
=
new
PlatDeviceAttrWechatDTO
();
dto
.
setDeviceId
(
deviceId
);
dto
.
setReadProperties
(
propertiesName
);
List
<
DeviceProperties
>
data
=
this
.
readDeviceProperties
(
dto
);
Map
<
String
,
Object
>
attrMap
=
data
.
stream
().
filter
(
p
->
!
Objects
.
isNull
(
p
.
getValue
())).
collect
(
Collectors
.
toMap
(
DeviceProperties:
:
getProperty
,
DeviceProperties:
:
getValue
));
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
JsonUtil
.
mapToBean
(
attrMap
,
PlatDeviceBaseAttrDTO
.
class
);
return
platDeviceBaseAttrDTO
;
}
}
}
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
3909acb0
...
@@ -18,7 +18,6 @@ import com.makeit.service.platform.device.PlatDeviceService;
...
@@ -18,7 +18,6 @@ import com.makeit.service.platform.device.PlatDeviceService;
import
com.makeit.service.saas.SaasSleepAnalysisModelService
;
import
com.makeit.service.saas.SaasSleepAnalysisModelService
;
import
com.makeit.utils.AlarmConfigCacheUtil
;
import
com.makeit.utils.AlarmConfigCacheUtil
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.redis.RedisUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.eclipse.paho.client.mqttv3.IMqttDeliveryToken
;
import
org.eclipse.paho.client.mqttv3.IMqttDeliveryToken
;
import
org.eclipse.paho.client.mqttv3.MqttCallback
;
import
org.eclipse.paho.client.mqttv3.MqttCallback
;
...
@@ -36,7 +35,6 @@ import javax.annotation.Resource;
...
@@ -36,7 +35,6 @@ import javax.annotation.Resource;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -119,26 +117,13 @@ public class PushCallback implements MqttCallback {
...
@@ -119,26 +117,13 @@ public class PushCallback implements MqttCallback {
* IOT端设备属性修改后同步
* IOT端设备属性修改后同步
* @param device
* @param device
*/
*/
@TenantIdIgnore
@Async
public
void
syncProperties
(
DeviceInfo
device
)
{
public
void
syncProperties
(
DeviceInfo
device
)
{
if
(!
(
WRITE_PROPERTY
.
equals
(
device
.
getMessageType
())
||
WRITE_PROPERTY_REPLY
.
equals
(
device
.
getMessageType
()
)))
{
if
(!
WRITE_PROPERTY
.
equals
(
device
.
getMessageType
(
)))
{
return
;
return
;
}
}
// 记录修改的属性
platDeviceService
.
syncIotProperties
(
device
.
getDeviceId
());
String
key
=
DEVICE_WRITE_PROPERTY_KEY
+
device
.
getDeviceId
();
if
(
WRITE_PROPERTY
.
equals
(
device
.
getMessageType
()))
{
RedisUtil
.
set
(
key
,
device
.
getProperties
(),
10
,
TimeUnit
.
SECONDS
);
}
// 收到修改属性回复
if
(
WRITE_PROPERTY_REPLY
.
equals
(
device
.
getMessageType
()))
{
JSONObject
properties
=
RedisUtil
.
get
(
key
);
if
(
properties
==
null
)
{
return
;
}
CompletableFuture
.
runAsync
(()
->
{
platDeviceService
.
receiveIotProperties
(
device
.
getDeviceId
(),
properties
);
RedisUtil
.
delete
(
key
);
});
}
}
}
/**
/**
...
...
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