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
dbe84faf
authored
Dec 13, 2023
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: iot设备属性同步
parent
15decda0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
dbe84faf
...
@@ -912,6 +912,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -912,6 +912,7 @@ 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
receiveIotProperties
(
String
deviceId
,
JSONObject
iotProperties
)
{
PlatDeviceOther
deviceOther
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
PlatDeviceOther
deviceOther
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
...
@@ -926,26 +927,26 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -926,26 +927,26 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
platDeviceBaseAttrDTO
=
new
PlatDeviceBaseAttrDTO
();
platDeviceBaseAttrDTO
=
new
PlatDeviceBaseAttrDTO
();
}
}
PlatDeviceBaseAttrDTO
iotAttr
=
iotProperties
.
toJavaObject
(
PlatDeviceBaseAttrDTO
.
class
);
PlatDeviceBaseAttrDTO
iotAttr
=
iotProperties
.
toJavaObject
(
PlatDeviceBaseAttrDTO
.
class
);
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMode
(),
iotAttr
.
getRadarMode
()))
{
if
(
iotAttr
.
getRadarMode
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMode
(),
iotAttr
.
getRadarMode
()))
{
platDeviceBaseAttrDTO
.
setRadarMode
(
iotAttr
.
getRadarMode
());
platDeviceBaseAttrDTO
.
setRadarMode
(
iotAttr
.
getRadarMode
());
}
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMount
(),
iotAttr
.
getRadarMount
()))
{
if
(
iotAttr
.
getRadarMount
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMount
(),
iotAttr
.
getRadarMount
()))
{
platDeviceBaseAttrDTO
.
setRadarMount
(
iotAttr
.
getRadarMount
());
platDeviceBaseAttrDTO
.
setRadarMount
(
iotAttr
.
getRadarMount
());
}
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarHight
(),
iotAttr
.
getRadarHight
()))
{
if
(
iotAttr
.
getRadarHight
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarHight
(),
iotAttr
.
getRadarHight
()))
{
platDeviceBaseAttrDTO
.
setRadarHight
(
iotAttr
.
getRadarHight
());
platDeviceBaseAttrDTO
.
setRadarHight
(
iotAttr
.
getRadarHight
());
}
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDelay
(),
iotAttr
.
getRadarDelay
()))
{
if
(
iotAttr
.
getRadarDelay
()
!=
null
&&
!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDelay
(),
iotAttr
.
getRadarDelay
()))
{
platDeviceBaseAttrDTO
.
setRadarDelay
(
iotAttr
.
getRadarDelay
());
platDeviceBaseAttrDTO
.
setRadarDelay
(
iotAttr
.
getRadarDelay
());
}
}
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarDistance
=
platDeviceBaseAttrDTO
.
getRadarDistance
();
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarDistance
=
platDeviceBaseAttrDTO
.
getRadarDistance
();
if
(!
Objects
.
equals
(
radarDistance
,
iotAttr
.
getRadarDistance
()))
{
if
(
iotAttr
.
getRadarDistance
()
!=
null
&&
!
Objects
.
equals
(
radarDistance
,
iotAttr
.
getRadarDistance
()))
{
if
(
radarDistance
!=
null
&&
radarDistance
.
getMax
()
!=
null
&&
radarDistance
.
getMin
()
!=
null
)
{
if
(
radarDistance
!=
null
&&
radarDistance
.
getMax
()
!=
null
&&
radarDistance
.
getMin
()
!=
null
)
{
platDeviceBaseAttrDTO
.
setRadarDistance
(
iotAttr
.
getRadarDistance
());
platDeviceBaseAttrDTO
.
setRadarDistance
(
iotAttr
.
getRadarDistance
());
}
}
}
}
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarAngle
=
platDeviceBaseAttrDTO
.
getRadarAngle
();
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarAngle
=
platDeviceBaseAttrDTO
.
getRadarAngle
();
if
(!
Objects
.
equals
(
radarAngle
,
iotAttr
.
getRadarAngle
()))
{
if
(
iotAttr
.
getRadarAngle
()
!=
null
&&
!
Objects
.
equals
(
radarAngle
,
iotAttr
.
getRadarAngle
()))
{
if
(
radarAngle
!=
null
&&
radarAngle
.
getMax
()
!=
null
&&
radarAngle
.
getMin
()
!=
null
)
{
if
(
radarAngle
!=
null
&&
radarAngle
.
getMax
()
!=
null
&&
radarAngle
.
getMin
()
!=
null
)
{
platDeviceBaseAttrDTO
.
setRadarAngle
(
iotAttr
.
getRadarAngle
());
platDeviceBaseAttrDTO
.
setRadarAngle
(
iotAttr
.
getRadarAngle
());
}
}
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
dbe84faf
...
@@ -36,6 +36,7 @@ import javax.annotation.Resource;
...
@@ -36,6 +36,7 @@ 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
;
...
@@ -118,8 +119,6 @@ public class PushCallback implements MqttCallback {
...
@@ -118,8 +119,6 @@ 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
())
||
WRITE_PROPERTY_REPLY
.
equals
(
device
.
getMessageType
())))
{
return
;
return
;
...
@@ -135,8 +134,10 @@ public class PushCallback implements MqttCallback {
...
@@ -135,8 +134,10 @@ public class PushCallback implements MqttCallback {
if
(
properties
==
null
)
{
if
(
properties
==
null
)
{
return
;
return
;
}
}
CompletableFuture
.
runAsync
(()
->
{
platDeviceService
.
receiveIotProperties
(
device
.
getDeviceId
(),
properties
);
platDeviceService
.
receiveIotProperties
(
device
.
getDeviceId
(),
properties
);
RedisUtil
.
delete
(
key
);
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