Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
f96f6a97
Commit
f96f6a97
authored
May 30, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改平台编码
parent
229f8acb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
15 deletions
+66
-15
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+41
-12
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+25
-3
No files found.
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
f96f6a97
...
...
@@ -271,29 +271,27 @@ public class DeviceApiController {
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
}
else
{
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatform
Id
()))
{
throw
new
AppException
(
"当前平台
Id
为空!"
);
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatform
Code
()))
{
throw
new
AppException
(
"当前平台
编码
为空!"
);
}
PlatformEntity
platformEntity
=
platformService
.
get
(
req
.
getPlatformId
(
));
PlatformEntity
platformEntity
=
platformService
.
selectOne
(
new
PlatformQuery
().
platformSn
(
req
.
getPlatformCode
()
));
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
"
当前设备未配置所属系统平
!"
);
throw
new
AppException
(
"
所属系统平台不存在
!"
);
}
if
(
ObjectUtils
.
isEmpty
(
req
.
getP
roductId
()))
{
throw
new
AppException
(
"当前产品
Id
为空!"
);
if
(
ObjectUtils
.
isEmpty
(
req
.
getP
latformCode
()))
{
throw
new
AppException
(
"当前产品
Code
为空!"
);
}
ProductEntity
productEntity
=
productService
.
get
(
req
.
getProductId
(
));
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
req
.
getProductCode
()
));
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
"
当前设备未配置所属产品,
"
);
throw
new
AppException
(
"
所属产品编码不存在
"
);
}
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
deviceEntity
.
setDeviceName
(
req
.
getDeviceName
());
deviceEntity
.
setDeviceCode
(
req
.
getDeviceCode
());
deviceEntity
.
setDeviceMac
(
req
.
getDevice
Mac
());
deviceEntity
.
setDeviceMac
(
req
.
getDevice
Code
());
deviceEntity
.
setSiteCode
(
req
.
getSiteCode
());
deviceEntity
.
setSiteName
(
req
.
getSiteName
());
deviceEntity
.
setIp
(
req
.
getIp
());
deviceEntity
.
setPort
(
req
.
getPort
());
deviceEntity
.
setPlatformId
(
platformEntity
.
getId
());
deviceEntity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
deviceEntity
.
setProductId
(
productEntity
.
getId
());
...
...
@@ -347,8 +345,39 @@ public class DeviceApiController {
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
info
(
"响应【激活设备】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
/**
* 删除设备
*
* @param req
* @return
*/
@PostMapping
(
"deviceDel"
)
@ApiUserAuth
public
String
deviceDel
(
@RequestBody
DeviceReq
req
)
{
log
.
info
(
"【删除设备】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"当前设备不存在!"
);
}
deviceService
.
remove
(
deviceEntity
.
getId
(),
null
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
info
(
"响应【
激活设备
设备】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
log
.
info
(
"响应【
删除
设备】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
f96f6a97
...
...
@@ -112,7 +112,6 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
}
/**
* 下发信息
*/
...
...
@@ -142,7 +141,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"content"
,
content
);
ApiResp
<
String
>
sendDeviceMessageResp
=
this
.
service
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
obj
),
null
);
ApiResp
<
String
>
sendDeviceMessageResp
=
this
.
service
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
obj
),
null
);
log
.
info
(
String
.
format
(
"sendMsgResp:%s"
,
JSON
.
toJSONString
(
sendDeviceMessageResp
)));
if
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
()
!=
sendDeviceMessageResp
.
getCode
())
{
throw
new
AppException
(
"下发消息失败!"
);
...
...
@@ -150,7 +149,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
// Thread.sleep(50);
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
}
else
{
}
else
{
throw
new
AppException
(
"设备不存在!deviceId:"
+
deviceId
);
}
...
...
@@ -166,4 +165,27 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
return
jsonObject
.
toJSONString
();
}
/**
* 设备激活
*/
@PostMapping
(
value
=
"active"
)
public
String
deviceActive
(
@RequestParam
(
value
=
"deviceCode"
)
String
deviceCode
)
{
JSONObject
jsonObject
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
this
.
getModuleDesc
()
+
"下发设备消息"
;
try
{
this
.
service
.
active
(
deviceCode
,
getContext
());
this
.
init
(
request
,
response
,
null
,
model
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
model
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
}
catch
(
Exception
e
)
{
log
.
error
(
"设备激活消息"
,
e
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
jsonObject
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
}
return
jsonObject
.
toJSONString
();
}
}
\ No newline at end of file
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