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 689f918a
authored
Apr 28, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]红外修改
1 parent
c41a05dc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
23 deletions
src/main/java/com/glsx/smart/controller/RemoteProductController.java
src/main/java/com/glsx/smart/dao/entity/SmartUserDevice.java
src/main/java/com/glsx/smart/dao/mapper/SmartUserDeviceMapper.java
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
src/main/resources/mapper/SmartUserDeviceMapper.xml
src/main/java/com/glsx/smart/controller/RemoteProductController.java
View file @
689f918
...
...
@@ -111,7 +111,7 @@ public class RemoteProductController {
* @return 结果
*/
@ResponseBody
@RequestMapping
(
value
=
"/findRemotes"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/findRemotes"
,
method
=
{
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"查询红外设备下的遥控器"
)
public
String
findRemotes
(
@RequestParam
String
infrared_id
)
{
return
productTypeService
.
findRemotesById
(
infrared_id
);
...
...
src/main/java/com/glsx/smart/dao/entity/SmartUserDevice.java
View file @
689f918
...
...
@@ -88,4 +88,7 @@ public class SmartUserDevice {
*/
@Column
(
name
=
"update_time"
)
private
Date
updateTime
;
@Transient
private
String
typeId
;
}
src/main/java/com/glsx/smart/dao/mapper/SmartUserDeviceMapper.java
View file @
689f918
...
...
@@ -19,4 +19,6 @@ public interface SmartUserDeviceMapper extends tk.mybatis.mapper.common.Mapper<S
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
);
int
deleteDevice
(
SmartUserDevice
req
);
List
<
SmartUserDevice
>
findByParentId
(
String
infrared_id
);
}
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
View file @
689f918
...
...
@@ -10,6 +10,7 @@ import com.glsx.smart.dao.entity.SmartProductType;
import
com.glsx.smart.dao.entity.SmartUserDevice
;
import
com.glsx.smart.dao.mapper.SmartProductMapper
;
import
com.glsx.smart.dao.mapper.SmartProductTypeMapper
;
import
com.glsx.smart.dao.mapper.SmartUserDeviceMapper
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.pojo.response.RemoteDeviceResp
;
...
...
@@ -44,6 +45,9 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Resource
private
SmartProductMapper
productMapper
;
@Resource
private
SmartUserDeviceMapper
smartUserDeviceMapper
;
@Value
(
"${findRemotesUrl}"
)
private
String
findRemotesUrl
;
...
...
@@ -136,28 +140,15 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@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
);
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
);
List
<
SmartUserDevice
>
smartUserDeviceList
=
smartUserDeviceMapper
.
findByParentId
(
infrared_id
);
List
<
Map
<
String
,
String
>>
collect
=
smartUserDeviceList
.
stream
().
map
(
index
->
{
Map
<
String
,
String
>
hash
=
new
HashMap
<>();
hash
.
put
(
"remote_name"
,
index
.
getDeviceName
());
hash
.
put
(
"remote_id"
,
index
.
getDeviceId
());
hash
.
put
(
"typeId"
,
index
.
getTypeId
());
return
hash
;
}).
collect
(
Collectors
.
toList
());
return
JSONObject
.
toJSONString
(
collect
);
}
/**
...
...
src/main/resources/mapper/SmartUserDeviceMapper.xml
View file @
689f918
...
...
@@ -15,6 +15,7 @@
<result
column=
"platform_product_id"
jdbcType=
"VARCHAR"
property=
"platformProductId"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"type_id"
jdbcType=
"VARCHAR"
property=
"typeId"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated generated on Fri Apr 23 15:24:29 CST 2021.-->
...
...
@@ -50,6 +51,12 @@
</where>
limit 1
</select>
<select
id=
"findByParentId"
resultMap=
"BaseResultMap"
>
select s1.device_name,s1.device_id,s2.type_id as type_id from smart_user_device s1
left join smart_product s2 on s1.platform_product_id= s2.platform_product_id
where type=2 and
parent_id=#{infrared_id}
</select>
<delete
id=
"deleteDevice"
>
delete from smart_user_device
...
...
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