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
e63e4fb8
authored
Nov 28, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fiix:编辑设备写入
parent
5d7de7f2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
16 deletions
server-module/src/main/java/com/makeit/module/controller/device/PlatDeviceController.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-module/src/main/java/com/makeit/module/controller/device/PlatDeviceController.java
View file @
e63e4fb8
...
@@ -93,6 +93,15 @@ public class PlatDeviceController {
...
@@ -93,6 +93,15 @@ public class PlatDeviceController {
return
ApiResponseUtils
.
success
();
return
ApiResponseUtils
.
success
();
}
}
@ApiOperation
(
"编辑设备属性 "
)
@PostMapping
(
"editDeviceProperties1"
)
@AuthIgnore
@TenantIdIgnore
public
ApiResponseEntity
<?>
editDeviceProperties1
(
@RequestBody
PlatDeviceAttrWechatDTO
dto
)
{
platDeviceService
.
editDeviceProperties
(
dto
);
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"编辑设备网络属性 主要写入usrServerInfo信息"
)
@ApiOperation
(
"编辑设备网络属性 主要写入usrServerInfo信息"
)
@PostMapping
(
"editDeviceNetInfo"
)
@PostMapping
(
"editDeviceNetInfo"
)
public
ApiResponseEntity
<?>
editDeviceNetInfo
(
@RequestBody
PlatDeviceNetAttrWechatDTO
dto
)
{
public
ApiResponseEntity
<?>
editDeviceNetInfo
(
@RequestBody
PlatDeviceNetAttrWechatDTO
dto
)
{
...
...
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
e63e4fb8
...
@@ -467,9 +467,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -467,9 +467,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
editDeviceProperties
(
PlatDeviceAttrWechatDTO
dto
)
{
public
void
editDeviceProperties
(
PlatDeviceAttrWechatDTO
dto
)
{
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
String
deviceId
=
dto
.
getDeviceId
();
String
deviceId
=
dto
.
getDeviceId
();
Map
<
String
,
Object
>
map
=
getAttrMap
(
dto
);
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
getPlatDeviceBaseAttrDTO
(
deviceId
);
String
reqJson
=
JSON
.
toJSONString
(
dto
);
Map
<
String
,
Object
>
map
=
getReqMap
(
dto
,
platDeviceBaseAttrDTO
);
log
.
info
(
"写入设备属性请求参数:{}"
,
reqJson
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
if
(
StringUtils
.
isNotEmpty
(
result
))
{
throw
new
RuntimeException
(
"设备写入失败:"
+
result
);
throw
new
RuntimeException
(
"设备写入失败:"
+
result
);
...
@@ -477,7 +479,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -477,7 +479,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
List
<
PlatDeviceOther
>
platDeviceOtherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
List
<
PlatDeviceOther
>
platDeviceOtherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
));
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
));
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
platDeviceOther
.
setAttribute
(
JSON
.
toJSONString
(
map
)
);
platDeviceOther
.
setAttribute
(
reqJson
);
platDeviceOtherService
.
updateById
(
platDeviceOther
);
platDeviceOtherService
.
updateById
(
platDeviceOther
);
}
}
if
(
dto
.
getRadarMount
()
!=
null
)
{
if
(
dto
.
getRadarMount
()
!=
null
)
{
...
@@ -489,6 +491,34 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -489,6 +491,34 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
}
}
}
private
PlatDeviceBaseAttrDTO
getPlatDeviceBaseAttrDTO
(
String
deviceId
)
{
PlatDeviceOther
deviceOther
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
last
(
"limit 1"
));
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
JSON
.
parseObject
(
deviceOther
.
getAttribute
(),
PlatDeviceBaseAttrDTO
.
class
);
return
platDeviceBaseAttrDTO
;
}
private
static
Map
<
String
,
Object
>
getReqMap
(
PlatDeviceBaseAttrDTO
dto
,
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
)
{
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMode
(),
dto
.
getRadarMode
()))
{
map
.
put
(
"radarMode"
,
dto
.
getRadarMode
());
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMount
(),
dto
.
getRadarMount
()))
{
map
.
put
(
"radarMount"
,
dto
.
getRadarMount
());
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDelay
(),
dto
.
getRadarDelay
()))
{
map
.
put
(
"radarDelay"
,
dto
.
getRadarDelay
()
);
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDistance
(),
dto
.
getRadarDistance
()))
{
map
.
put
(
"radarDistance"
,
JSON
.
toJSONString
(
dto
.
getRadarDistance
()));
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarAngle
(),
dto
.
getRadarAngle
()))
{
map
.
put
(
"radarAngle"
,
JSON
.
toJSONString
(
dto
.
getRadarAngle
()));
}
return
map
;
}
@Override
@Override
public
void
editDeviceNetInfo
(
PlatDeviceNetAttrWechatDTO
dto
)
{
public
void
editDeviceNetInfo
(
PlatDeviceNetAttrWechatDTO
dto
)
{
String
deviceId
=
dto
.
getDeviceId
();
String
deviceId
=
dto
.
getDeviceId
();
...
@@ -539,29 +569,27 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -539,29 +569,27 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
batchEditProperties
(
PlatDeviceAttrDTO
dto
)
{
public
void
batchEditProperties
(
PlatDeviceAttrDTO
dto
)
{
if
(
CollectionUtils
.
isEmpty
(
dto
.
getDeviceIdList
()))
{
List
<
String
>
deviceIdList
=
dto
.
getDeviceIdList
();
if
(
CollectionUtils
.
isEmpty
(
deviceIdList
))
{
return
;
return
;
}
}
Map
<
String
,
Object
>
map
=
getAttrMap
(
dto
);
String
reqJson
=
JSON
.
toJSONString
(
dto
);
List
<
String
>
resultList
=
Lists
.
newArrayList
();
for
(
String
deviceId
:
deviceIdList
)
{
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
getPlatDeviceBaseAttrDTO
(
deviceId
);
for
(
String
deviceId
:
dto
.
getDeviceIdList
())
{
Map
<
String
,
Object
>
map
=
getReqMap
(
dto
,
platDeviceBaseAttrDTO
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
if
(
StringUtils
.
isNotEmpty
(
result
))
{
resultList
.
add
(
result
);
throw
new
RuntimeException
(
"修改设备属性失败:"
+
result
);
}
}
List
<
PlatDeviceOther
>
otherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
List
<
PlatDeviceOther
>
otherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
));
.
last
(
"limit 1"
));
for
(
PlatDeviceOther
platDeviceOther
:
otherList
)
{
for
(
PlatDeviceOther
platDeviceOther
:
otherList
)
{
platDeviceOther
.
setAttribute
(
JSON
.
toJSONString
(
map
)
);
platDeviceOther
.
setAttribute
(
reqJson
);
platDeviceOtherService
.
updateById
(
platDeviceOther
);
platDeviceOtherService
.
updateById
(
platDeviceOther
);
}
}
}
if
(
CollectionUtils
.
isNotEmpty
(
resultList
))
{
throw
new
RuntimeException
(
"修改设备属性失败:"
+
resultList
.
get
(
0
));
}
}
}
}
@Override
@Override
...
...
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