Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
glsx-smart-message-channel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8513f502
authored
May 07, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]代码规范
1 parent
ba4ec619
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
20 deletions
src/main/java/cn/com/glsx/consumer/client/SceneClient.java
src/main/java/cn/com/glsx/consumer/client/SmartPlatformClient.java
src/main/java/cn/com/glsx/consumer/service/DeviceService.java
src/main/java/cn/com/glsx/consumer/client/SceneClient.java
View file @
8513f50
...
...
@@ -15,7 +15,7 @@ import java.util.List;
* @author zhouhaibao
* @date 2021/5/6 15:19
*/
@FeignClient
(
name
=
"${
feign.server.name}"
,
url
=
"${
feign.server.url}"
)
@FeignClient
(
name
=
"${
smart.feign.server.name}"
,
url
=
"${smart.
feign.server.url}"
)
public
interface
SceneClient
{
@ResponseBody
...
...
src/main/java/cn/com/glsx/consumer/client/SmartPlatformClient.java
0 → 100644
View file @
8513f50
package
cn
.
com
.
glsx
.
consumer
.
client
;
import
com.glsx.plat.core.web.R
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
* @author zhouhaibao
* @date 2021/5/7 14:07
*/
@FeignClient
(
name
=
"${smartPlatform.feign.server.name}"
,
url
=
"${smartPlatform.feign.server.url}"
)
public
interface
SmartPlatformClient
{
@ResponseBody
@RequestMapping
(
value
=
"/device/devices/{device_id}"
,
method
=
{
RequestMethod
.
GET
})
R
getDeviceName
(
@PathVariable
(
"device_id"
)
String
deviceId
);
}
src/main/java/cn/com/glsx/consumer/service/DeviceService.java
View file @
8513f50
package
cn
.
com
.
glsx
.
consumer
.
service
;
import
cn.com.glsx.consumer.client.SceneClient
;
import
cn.com.glsx.consumer.client.SmartPlatformClient
;
import
cn.com.glsx.consumer.entity.DeviceVo
;
import
cn.com.glsx.consumer.utils.HttpUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
/**
* @author zhouhaibao
...
...
@@ -23,8 +21,8 @@ public class DeviceService {
@Autowired
private
SceneClient
sceneClient
;
@
Value
(
"${getDeviceNameUrl}"
)
private
S
tring
getDeviceNameUrl
;
@
Autowired
private
S
martPlatformClient
smartPlatformClient
;
/**
* 设备绑定
...
...
@@ -47,18 +45,9 @@ public class DeviceService {
}
public
String
getDeviceName
(
String
devId
)
{
String
name
=
""
;
try
{
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
getDeviceNameUrl
.
replace
(
"{device_id}"
,
devId
),
null
,
new
HashMap
<>());
JSONObject
message
=
jsonObject
.
getJSONObject
(
"message"
);
if
(
message
!=
null
){
name
=
message
.
getString
(
"name"
);
}
log
.
info
(
"设备id{}名称查询结果{}"
,
devId
,
name
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"设备id{}名称查询结果{}"
,
devId
,
e
.
getMessage
());
}
return
name
;
R
deviceName
=
smartPlatformClient
.
getDeviceName
(
devId
);
String
message
=
deviceName
.
getMessage
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
);
return
jsonObject
.
getString
(
"name"
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment