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 a6a686c9
authored
Apr 12, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
车家智能数据服务 远程设备条件处理优化--think.wang
1 parent
ac15dc6d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
16 deletions
src/main/java/com/glsx/smart/controller/RemoteProductController.java
src/main/java/com/glsx/smart/pojo/response/RemoteDeviceResp.java
src/main/java/com/glsx/smart/service/SmartProductTypeService.java
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
src/main/java/com/glsx/smart/controller/RemoteProductController.java
View file @
a6a686c
...
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.glsx.plat.common.utils.HttpUtils
;
import
com.glsx.plat.common.utils.HttpUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.pojo.response.RemoteDeviceResp
;
import
com.glsx.smart.service.SmartProductService
;
import
com.glsx.smart.service.SmartProductService
;
import
com.glsx.smart.service.SmartProductTypeService
;
import
com.glsx.smart.service.SmartProductTypeService
;
import
com.glsx.smart.service.SmartUserRelationService
;
import
com.glsx.smart.service.SmartUserRelationService
;
...
@@ -16,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -16,6 +17,9 @@ 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.util.ArrayList
;
import
java.util.List
;
/**
/**
* 远程产品服务controller
* 远程产品服务controller
* 暂时只有涂鸦
* 暂时只有涂鸦
...
@@ -48,7 +52,7 @@ public class RemoteProductController {
...
@@ -48,7 +52,7 @@ 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
List
<
RemoteDeviceResp
>
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
);
...
@@ -59,7 +63,8 @@ public class RemoteProductController {
...
@@ -59,7 +63,8 @@ public class RemoteProductController {
return
this
.
getRemoteDevice
(
user
.
getThirdId
(),
status
);
return
this
.
getRemoteDevice
(
user
.
getThirdId
(),
status
);
}
}
private
JSONArray
getRemoteDevice
(
String
thirdId
,
Byte
status
)
{
private
List
<
RemoteDeviceResp
>
getRemoteDevice
(
String
thirdId
,
Byte
status
)
{
List
<
RemoteDeviceResp
>
deviceRespList
=
new
ArrayList
<>();
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
());
...
@@ -71,7 +76,7 @@ public class RemoteProductController {
...
@@ -71,7 +76,7 @@ public class RemoteProductController {
if
(
json
.
getInteger
(
"code"
).
equals
(
200
))
{
if
(
json
.
getInteger
(
"code"
).
equals
(
200
))
{
JSONArray
array
=
json
.
getJSONArray
(
"message"
);
JSONArray
array
=
json
.
getJSONArray
(
"message"
);
if
(
array
==
null
||
array
.
size
()
<=
0
){
if
(
array
==
null
||
array
.
size
()
<=
0
){
return
array
;
return
deviceRespList
;
}
}
return
productTypeService
.
remoteDeviceHandler
(
array
,
status
);
return
productTypeService
.
remoteDeviceHandler
(
array
,
status
);
}
}
...
@@ -79,7 +84,7 @@ public class RemoteProductController {
...
@@ -79,7 +84,7 @@ public class RemoteProductController {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"获取用户设备列表数据失败:{}"
,
e
);
log
.
error
(
"获取用户设备列表数据失败:{}"
,
e
);
}
}
return
new
JSONArray
()
;
return
deviceRespList
;
}
}
/**
/**
...
...
src/main/java/com/glsx/smart/pojo/response/RemoteDeviceResp.java
0 → 100644
View file @
a6a686c
package
com
.
glsx
.
smart
.
pojo
.
response
;
import
lombok.Data
;
/**
* @author think.wang
* @version 1.0.0
* @Title RemoteDeviceResp
* @Package com.glsx.smart.pojo.response
* @Description 远程设备返回数据
* @date 2021/4/12
*/
@Data
public
class
RemoteDeviceResp
{
private
String
productId
;
//产品id
private
String
uuid
;
//设备id
private
String
productName
;
//产品名称
private
String
iconUrl
;
//产品图片url
private
boolean
flag
;
//是否万能遥控器 true是 false否
}
src/main/java/com/glsx/smart/service/SmartProductTypeService.java
View file @
a6a686c
...
@@ -3,6 +3,7 @@ package com.glsx.smart.service;
...
@@ -3,6 +3,7 @@ package com.glsx.smart.service;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.smart.dao.entity.SmartProductType
;
import
com.glsx.smart.dao.entity.SmartProductType
;
import
com.glsx.smart.pojo.response.RemoteDeviceResp
;
import
java.util.List
;
import
java.util.List
;
...
@@ -31,6 +32,6 @@ public interface SmartProductTypeService {
...
@@ -31,6 +32,6 @@ public interface SmartProductTypeService {
String
findRemotesById
(
String
infrared_id
);
String
findRemotesById
(
String
infrared_id
);
JSONArray
remoteDeviceHandler
(
JSONArray
array
,
Byte
status
);
List
<
RemoteDeviceResp
>
remoteDeviceHandler
(
JSONArray
array
,
Byte
status
);
}
}
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
View file @
a6a686c
...
@@ -11,6 +11,7 @@ import com.glsx.smart.dao.mapper.SmartProductMapper;
...
@@ -11,6 +11,7 @@ import com.glsx.smart.dao.mapper.SmartProductMapper;
import
com.glsx.smart.dao.mapper.SmartProductTypeMapper
;
import
com.glsx.smart.dao.mapper.SmartProductTypeMapper
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.pojo.response.RemoteDeviceResp
;
import
com.glsx.smart.service.BaseService
;
import
com.glsx.smart.service.BaseService
;
import
com.glsx.smart.service.SmartProductTypeService
;
import
com.glsx.smart.service.SmartProductTypeService
;
import
com.glsx.smart.utils.HttpUtil
;
import
com.glsx.smart.utils.HttpUtil
;
...
@@ -165,8 +166,8 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -165,8 +166,8 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
* @return
* @return
*/
*/
@Override
@Override
public
JSONArray
remoteDeviceHandler
(
JSONArray
array
,
Byte
status
)
{
public
List
<
RemoteDeviceResp
>
remoteDeviceHandler
(
JSONArray
array
,
Byte
status
)
{
JSONArray
arrayList
=
new
JSONArray
();
List
<
RemoteDeviceResp
>
deviceRespList
=
new
ArrayList
<>
();
//获取平台产品id列表
//获取平台产品id列表
int
len
=
array
.
size
();
int
len
=
array
.
size
();
List
<
String
>
prodIdList
=
new
ArrayList
<>(
len
);
List
<
String
>
prodIdList
=
new
ArrayList
<>(
len
);
...
@@ -175,7 +176,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -175,7 +176,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
}
}
List
<
SmartProduct
>
productList
=
productMapper
.
getByPlatProductIdList
(
prodIdList
);
List
<
SmartProduct
>
productList
=
productMapper
.
getByPlatProductIdList
(
prodIdList
);
if
(
CollectionUtils
.
isEmpty
(
productList
)){
if
(
CollectionUtils
.
isEmpty
(
productList
)){
return
array
List
;
return
deviceResp
List
;
}
}
//获取设备类型列表
//获取设备类型列表
List
<
SmartProductType
>
list
;
List
<
SmartProductType
>
list
;
...
@@ -205,17 +206,17 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -205,17 +206,17 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
}
}
SmartProductType
productType
=
typeMap
.
get
(
product
.
getTypeId
());
SmartProductType
productType
=
typeMap
.
get
(
product
.
getTypeId
());
if
(
productType
!=
null
){
if
(
productType
!=
null
){
JSONObject
val
=
new
JSONObject
();
RemoteDeviceResp
resp
=
new
RemoteDeviceResp
();
val
.
put
(
"productId"
,
productId
);
resp
.
setProductId
(
productId
);
val
.
put
(
"uuid"
,
object
.
getString
(
"id"
));
resp
.
setUuid
(
object
.
getString
(
"id"
));
val
.
put
(
"productName"
,
object
.
getString
(
"product_name"
));
resp
.
setProductName
(
object
.
getString
(
"product_name"
));
val
.
put
(
"iconUrl"
,
product
.
getIconUrl
());
resp
.
setIconUrl
(
product
.
getIconUrl
());
boolean
flag
=
productType
.
getTypeName
().
contains
(
Constants
.
DEFAULT_DEVICE
)
?
true
:
false
;
boolean
flag
=
productType
.
getTypeName
().
contains
(
Constants
.
DEFAULT_DEVICE
)
?
true
:
false
;
val
.
put
(
"flag"
,
flag
);
resp
.
setFlag
(
flag
);
arrayList
.
add
(
val
);
deviceRespList
.
add
(
resp
);
}
}
}
}
return
array
List
;
return
deviceResp
List
;
}
}
/**
/**
...
...
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