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 652bf369
authored
Mar 30, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' of 192.168.3.233:open-source/chejia-smart-service into dev
2 parents
48116e61
c33297e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
29 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/resources/mapper/SmartSysCodeMapper.xml
src/main/java/com/glsx/smart/controller/RemoteProductController.java
View file @
652bf36
...
...
@@ -9,27 +9,34 @@ import com.glsx.smart.dao.entity.SmartProduct;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.service.SmartProductService
;
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
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
/**
*
* 远程产品服务controller
* 暂时只有涂鸦
*
*/
@Slf4j
@RestController
@RequestMapping
(
"/remoteProduct"
)
@Api
(
value
=
"设备管理"
,
tags
=
{
"设备管理"
})
public
class
RemoteProductController
{
@Value
(
"${device_remote_url}"
)
private
String
remoteUrl
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
@Autowired
private
SmartProductService
productService
;
...
...
@@ -44,17 +51,17 @@ public class RemoteProductController {
@ResponseBody
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
JSONArray
getList
(
@RequestBody
SmartUserRelation
request
)
{
log
.
info
(
"用户参数:{}"
,
request
);
log
.
info
(
"用户参数:{}"
,
request
);
request
.
setUserId
(
91712228L
);
SmartUserRelation
user
=
userRelationService
.
getSingle
(
request
);
return
this
.
getRemoteDevice
(
user
.
getThirdId
());
}
private
JSONArray
getRemoteDevice
(
String
thirdId
){
private
JSONArray
getRemoteDevice
(
String
thirdId
)
{
StringBuffer
url
=
new
StringBuffer
(
remoteUrl
);
url
.
append
(
"/device/"
).
append
(
thirdId
).
append
(
"/devices"
);
log
.
info
(
"请求远程设备列表接口地址:{}"
,
url
.
toString
());
try
{
try
{
String
result
=
HttpUtils
.
get
(
url
.
toString
());
log
.
info
(
"获取用户设备列表数据返回结果:{}"
,
result
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
...
...
@@ -76,7 +83,7 @@ public class RemoteProductController {
return
list
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"获取用户设备列表数据失败:{}"
,
e
);
}
return
null
;
...
...
@@ -84,17 +91,40 @@ public class RemoteProductController {
/**
* 通过平台产品id获取产品图片
*
* @param productId
* @return
*/
private
String
getProductIcon
(
String
productId
){
private
String
getProductIcon
(
String
productId
)
{
SmartProduct
req
=
new
SmartProduct
();
req
.
setPlatformProductId
(
productId
);
List
<
SmartProduct
>
list
=
productService
.
getListByCondition
(
req
);
if
(!
list
.
isEmpty
())
{
return
list
.
get
(
0
).
getIconUrl
();
if
(!
list
.
isEmpty
())
{
return
list
.
get
(
0
).
getIconUrl
();
}
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 @
652bf36
...
...
@@ -77,4 +77,5 @@ public class SceneController {
public
List
<
OrderResponse
>
issueOrder
(
@RequestBody
SmartScene
scene
)
{
return
sceneService
.
issueOrder
(
scene
);
}
}
src/main/java/com/glsx/smart/utils/HttpUtil.java
View file @
652bf36
...
...
@@ -394,12 +394,9 @@ public class HttpUtil {
* @return
* @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
);
if
(
StringUtils
.
isNotBlank
(
retData
))
{
return
JSONObject
.
parseObject
(
retData
);
}
return
new
JSONObject
();
return
retData
;
}
/**
...
...
src/main/resources/mapper/SmartSysCodeMapper.xml
View file @
652bf36
...
...
@@ -20,22 +20,9 @@
<result
column=
"update_by"
jdbcType=
"BIGINT"
property=
"updateBy"
/>
</resultMap>
<resultMap
id=
"TreeResultMap"
type=
"com.glsx.smart.dao.entity.SmartSysCode"
>
<!--@mbg.generated--
>
<resultMap
id=
"TreeResultMap"
type=
"com.glsx.smart.dao.entity.SmartSysCode"
extends=
"BaseResultMap"
>
<!--@Table smart_sys_code-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"dict_type"
jdbcType=
"VARCHAR"
property=
"dictType"
/>
<result
column=
"dict_key"
jdbcType=
"VARCHAR"
property=
"dictKey"
/>
<result
column=
"dict_value"
jdbcType=
"VARCHAR"
property=
"dictValue"
/>
<result
column=
"parent_key"
jdbcType=
"VARCHAR"
property=
"parentKey"
/>
<result
column=
"sort"
jdbcType=
"TINYINT"
property=
"sort"
/>
<result
column=
"status"
jdbcType=
"TINYINT"
property=
"status"
/>
<result
column=
"level"
jdbcType=
"TINYINT"
property=
"level"
/>
<result
column=
"remark"
jdbcType=
"VARCHAR"
property=
"remark"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"create_by"
jdbcType=
"BIGINT"
property=
"createBy"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"update_by"
jdbcType=
"BIGINT"
property=
"updateBy"
/>
<collection
property=
"subCodeList"
select=
"getTree"
column=
"{parentKey=dict_key}"
/>
</resultMap>
...
...
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