Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
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 c33297e4
authored
Mar 30, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]下发指令代码修改
1 parent
484d1786
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
14 deletions
src/main/java/com/glsx/smart/controller/RemoteProductController.java
src/main/java/com/glsx/smart/controller/SceneController.java
src/main/java/com/glsx/smart/utils/HttpUtil.java
src/main/java/com/glsx/smart/controller/RemoteProductController.java
View file @
c33297e
...
@@ -9,27 +9,34 @@ import com.glsx.smart.dao.entity.SmartProduct;
...
@@ -9,27 +9,34 @@ import com.glsx.smart.dao.entity.SmartProduct;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.service.SmartProductService
;
import
com.glsx.smart.service.SmartProductService
;
import
com.glsx.smart.service.SmartUserRelationService
;
import
com.glsx.smart.service.SmartUserRelationService
;
import
com.glsx.smart.utils.HttpUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
/**
/**
*
* 远程产品服务controller
* 远程产品服务controller
* 暂时只有涂鸦
* 暂时只有涂鸦
*
*/
*/
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/remoteProduct"
)
@RequestMapping
(
"/remoteProduct"
)
@Api
(
value
=
"设备管理"
,
tags
=
{
"设备管理"
})
public
class
RemoteProductController
{
public
class
RemoteProductController
{
@Value
(
"${device_remote_url}"
)
@Value
(
"${device_remote_url}"
)
private
String
remoteUrl
;
private
String
remoteUrl
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
@Autowired
@Autowired
private
SmartProductService
productService
;
private
SmartProductService
productService
;
...
@@ -44,17 +51,17 @@ public class RemoteProductController {
...
@@ -44,17 +51,17 @@ public class RemoteProductController {
@ResponseBody
@ResponseBody
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
JSONArray
getList
(
@RequestBody
SmartUserRelation
request
)
{
public
JSONArray
getList
(
@RequestBody
SmartUserRelation
request
)
{
log
.
info
(
"用户参数:{}"
,
request
);
log
.
info
(
"用户参数:{}"
,
request
);
request
.
setUserId
(
91712228L
);
request
.
setUserId
(
91712228L
);
SmartUserRelation
user
=
userRelationService
.
getSingle
(
request
);
SmartUserRelation
user
=
userRelationService
.
getSingle
(
request
);
return
this
.
getRemoteDevice
(
user
.
getThirdId
());
return
this
.
getRemoteDevice
(
user
.
getThirdId
());
}
}
private
JSONArray
getRemoteDevice
(
String
thirdId
){
private
JSONArray
getRemoteDevice
(
String
thirdId
)
{
StringBuffer
url
=
new
StringBuffer
(
remoteUrl
);
StringBuffer
url
=
new
StringBuffer
(
remoteUrl
);
url
.
append
(
"/device/"
).
append
(
thirdId
).
append
(
"/devices"
);
url
.
append
(
"/device/"
).
append
(
thirdId
).
append
(
"/devices"
);
log
.
info
(
"请求远程设备列表接口地址:{}"
,
url
.
toString
());
log
.
info
(
"请求远程设备列表接口地址:{}"
,
url
.
toString
());
try
{
try
{
String
result
=
HttpUtils
.
get
(
url
.
toString
());
String
result
=
HttpUtils
.
get
(
url
.
toString
());
log
.
info
(
"获取用户设备列表数据返回结果:{}"
,
result
);
log
.
info
(
"获取用户设备列表数据返回结果:{}"
,
result
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
if
(
StringUtils
.
isNotEmpty
(
result
))
{
...
@@ -76,7 +83,7 @@ public class RemoteProductController {
...
@@ -76,7 +83,7 @@ public class RemoteProductController {
return
list
;
return
list
;
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"获取用户设备列表数据失败:{}"
,
e
);
log
.
error
(
"获取用户设备列表数据失败:{}"
,
e
);
}
}
return
null
;
return
null
;
...
@@ -84,17 +91,40 @@ public class RemoteProductController {
...
@@ -84,17 +91,40 @@ public class RemoteProductController {
/**
/**
* 通过平台产品id获取产品图片
* 通过平台产品id获取产品图片
*
* @param productId
* @param productId
* @return
* @return
*/
*/
private
String
getProductIcon
(
String
productId
){
private
String
getProductIcon
(
String
productId
)
{
SmartProduct
req
=
new
SmartProduct
();
SmartProduct
req
=
new
SmartProduct
();
req
.
setPlatformProductId
(
productId
);
req
.
setPlatformProductId
(
productId
);
List
<
SmartProduct
>
list
=
productService
.
getListByCondition
(
req
);
List
<
SmartProduct
>
list
=
productService
.
getListByCondition
(
req
);
if
(!
list
.
isEmpty
())
{
if
(!
list
.
isEmpty
())
{
return
list
.
get
(
0
).
getIconUrl
();
return
list
.
get
(
0
).
getIconUrl
();
}
}
return
null
;
return
null
;
}
}
/**
* 查询红外设备下的遥控器
*
* @return 结果
*/
@ResponseBody
@RequestMapping
(
value
=
"/findRemotes"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"查询红外设备下的遥控器"
)
public
String
findRemotes
(
@RequestParam
String
infrared_id
)
{
return
findRemotesById
(
infrared_id
);
}
private
String
findRemotesById
(
String
infrared_id
)
{
String
responseResult
=
null
;
try
{
responseResult
=
HttpUtil
.
sendGet
(
findRemotesUrl
.
replace
(
"{infrared_id}"
,
infrared_id
),
null
,
new
HashMap
<>());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
responseResult
;
}
}
}
src/main/java/com/glsx/smart/controller/SceneController.java
View file @
c33297e
...
@@ -77,4 +77,5 @@ public class SceneController {
...
@@ -77,4 +77,5 @@ public class SceneController {
public
List
<
OrderResponse
>
issueOrder
(
@RequestBody
SmartScene
scene
)
{
public
List
<
OrderResponse
>
issueOrder
(
@RequestBody
SmartScene
scene
)
{
return
sceneService
.
issueOrder
(
scene
);
return
sceneService
.
issueOrder
(
scene
);
}
}
}
}
src/main/java/com/glsx/smart/utils/HttpUtil.java
View file @
c33297e
...
@@ -394,12 +394,9 @@ public class HttpUtil {
...
@@ -394,12 +394,9 @@ public class HttpUtil {
* @return
* @return
* @throws IOException
* @throws IOException
*/
*/
public
static
JSONObject
sendGet
(
String
url
,
Map
<
String
,
String
>
params
,
Map
<
String
,
String
>
headerParams
)
throws
IOException
{
public
static
String
sendGet
(
String
url
,
Map
<
String
,
String
>
params
,
Map
<
String
,
String
>
headerParams
)
throws
IOException
{
String
retData
=
getData
(
url
,
params
,
Consts
.
UTF_8
,
headerParams
);
String
retData
=
getData
(
url
,
params
,
Consts
.
UTF_8
,
headerParams
);
if
(
StringUtils
.
isNotBlank
(
retData
))
{
return
retData
;
return
JSONObject
.
parseObject
(
retData
);
}
return
new
JSONObject
();
}
}
/**
/**
...
...
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