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 b5fcb6fb
authored
Mar 31, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]下发指令代码修改
1 parent
7aa87f54
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
13 deletions
src/main/java/com/glsx/smart/controller/RemoteProductController.java
src/main/java/com/glsx/smart/dao/mapper/SmartProductTypeMapper.java
src/main/java/com/glsx/smart/service/SmartProductTypeService.java
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
src/main/resources/mapper/SmartProductTypeMapper.xml
src/main/java/com/glsx/smart/controller/RemoteProductController.java
View file @
b5fcb6f
...
...
@@ -8,6 +8,7 @@ import com.glsx.plat.common.utils.StringUtils;
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.SmartProductTypeService
;
import
com.glsx.smart.service.SmartUserRelationService
;
import
com.glsx.smart.utils.HttpUtil
;
import
io.swagger.annotations.Api
;
...
...
@@ -34,15 +35,15 @@ public class RemoteProductController {
@Value
(
"${device_remote_url}"
)
private
String
remoteUrl
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
@Autowired
private
SmartProductService
productService
;
@Autowired
private
SmartUserRelationService
userRelationService
;
@Autowired
private
SmartProductTypeService
smartProductTypeService
;
/**
* 用户获取远程产品列表数据
*
...
...
@@ -115,16 +116,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/dao/mapper/SmartProductTypeMapper.java
View file @
b5fcb6f
...
...
@@ -24,4 +24,5 @@ public interface SmartProductTypeMapper extends tk.mybatis.mapper.common.Mapper<
List
<
SmartProductType
>
getListAndCondition
(
List
<
Long
>
list
);
int
findTypeIdByCat
(
int
category_id
);
}
src/main/java/com/glsx/smart/service/SmartProductTypeService.java
View file @
b5fcb6f
...
...
@@ -24,4 +24,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 @
b5fcb6f
package
com
.
glsx
.
smart
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
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
;
...
...
@@ -10,7 +16,9 @@ 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
;
...
...
@@ -24,9 +32,13 @@ import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
public
class
SmartProductTypeServiceImpl
extends
BaseService
implements
SmartProductTypeService
{
@Resource
private
SmartProductTypeMapper
productTypeMapper
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
/**
* 分页获取产品类型列表。
*
...
...
@@ -109,4 +121,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"
);
int
typeId
=
productTypeMapper
.
findTypeIdByCat
(
category_id
);
object
.
put
(
"typeId"
,
typeId
);
newarray
.
add
(
object
);
}
json
.
put
(
"message"
,
newarray
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
JSONObject
.
toJSONString
(
json
);
}
}
src/main/resources/mapper/SmartProductTypeMapper.xml
View file @
b5fcb6f
...
...
@@ -75,4 +75,9 @@
from smart_product_type
where type_name = #{typeName,jdbcType=VARCHAR}
</select>
<select
id=
"findTypeIdByCat"
resultType=
"java.lang.Integer"
>
select id
from smart_product_type
where tuya_category_id =#{category_id}
</select>
</mapper>
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