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 67032e95
authored
Mar 31, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
车家智能数据服务开发 万能遥控器情况处理--think.wang
2 parents
c5ee3633
dace1fa3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
16 deletions
src/main/java/com/glsx/smart/controller/RemoteProductController.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 @
67032e9
...
...
@@ -12,7 +12,6 @@ import com.glsx.smart.dao.entity.SmartUserRelation;
import
com.glsx.smart.service.SmartProductService
;
import
com.glsx.smart.service.SmartProductTypeService
;
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
;
...
...
@@ -20,9 +19,7 @@ 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.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
/**
...
...
@@ -38,9 +35,6 @@ public class RemoteProductController {
@Value
(
"${device_remote_url}"
)
private
String
remoteUrl
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
@Autowired
private
SmartProductService
productService
;
...
...
@@ -50,6 +44,9 @@ public class RemoteProductController {
@Autowired
private
SmartUserRelationService
userRelationService
;
@Autowired
private
SmartProductTypeService
smartProductTypeService
;
/**
* 用户获取远程产品列表数据
*
...
...
@@ -161,16 +158,7 @@ public class RemoteProductController {
@RequestMapping
(
value
=
"/findRemotes"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"查询红外设备下的遥控器"
)
public
String
findRemotes
(
@RequestParam
String
infrared_id
)
{
return
findRemotesById
(
infrared_id
);
return
smartProductTypeService
.
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/service/SmartProductTypeService.java
View file @
67032e9
...
...
@@ -27,4 +27,6 @@ public interface SmartProductTypeService {
List
<
SmartProductType
>
getListAndContent
(
List
<
Long
>
list
);
List
<
SmartProductType
>
getListAndCondition
(
List
<
Long
>
list
);
String
findRemotesById
(
String
infrared_id
);
}
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
View file @
67032e9
package
com
.
glsx
.
smart
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.smart.dao.entity.SmartProductType
;
import
com.glsx.smart.dao.mapper.SmartProductTypeMapper
;
...
...
@@ -7,12 +10,16 @@ import com.glsx.smart.exception.BusinessException;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.service.BaseService
;
import
com.glsx.smart.service.SmartProductTypeService
;
import
com.glsx.smart.utils.HttpUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
/**
...
...
@@ -25,9 +32,13 @@ import java.util.List;
@Slf4j
@Service
public
class
SmartProductTypeServiceImpl
extends
BaseService
implements
SmartProductTypeService
{
@Resource
private
SmartProductTypeMapper
productTypeMapper
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
/**
* 分页获取产品类型列表。
*
...
...
@@ -114,4 +125,31 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
public
List
<
SmartProductType
>
getListAndCondition
(
List
<
Long
>
list
)
{
return
productTypeMapper
.
getListAndCondition
(
list
);
}
@Override
public
String
findRemotesById
(
String
infrared_id
)
{
String
responseResult
=
null
;
JSONObject
json
=
null
;
try
{
responseResult
=
HttpUtil
.
sendGet
(
findRemotesUrl
.
replace
(
"{infrared_id}"
,
infrared_id
),
null
,
new
HashMap
<>());
json
=
JSON
.
parseObject
(
responseResult
);
if
(
json
.
getInteger
(
"code"
).
equals
(
200
))
{
JSONArray
newArray
=
new
JSONArray
();
JSONArray
array
=
json
.
getJSONArray
(
"message"
);
int
len
=
array
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
JSONObject
object
=
array
.
getJSONObject
(
i
);
JSONObject
val
=
new
JSONObject
();
int
category_id
=
object
.
getInteger
(
"category_id"
);
SmartProductType
productType
=
productTypeMapper
.
getByCategoryId
(
category_id
);
object
.
put
(
"typeId"
,
productType
.
getId
());
newArray
.
add
(
object
);
}
json
.
put
(
"message"
,
newArray
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
JSONObject
.
toJSONString
(
json
);
}
}
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