Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
glsx-smart-device-kafka-consumer
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 3fab142b
authored
Mar 23, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]kafka消费数据修改
1 parent
e350e028
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
37 deletions
src/main/java/cn/com/glsx/smart/entity/SmartTemplateParam.java → src/main/java/cn/com/glsx/smart/entity/SmartSceneData.java
src/main/java/cn/com/glsx/smart/mapper/SmartTemplateParamMapper.java → src/main/java/cn/com/glsx/smart/mapper/SmartSceneDataMapper.java
src/main/java/cn/com/glsx/smart/service/OrderIssueService.java
src/main/resources/config/generatorConfig.xml
src/main/resources/mapper/SmartTemplateParamMapper.xml → src/main/resources/mapper/SmartSceneDataMapper.xml
src/main/java/cn/com/glsx/smart/entity/Smart
TemplateParam
.java
→
src/main/java/cn/com/glsx/smart/entity/Smart
SceneData
.java
View file @
3fab142
...
@@ -3,8 +3,8 @@ package cn.com.glsx.smart.entity;
...
@@ -3,8 +3,8 @@ package cn.com.glsx.smart.entity;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
javax.persistence.*
;
import
javax.persistence.*
;
@Table
(
name
=
"smart_
template_param
"
)
@Table
(
name
=
"smart_
scene_data
"
)
public
class
Smart
TemplateParam
implements
Serializable
{
public
class
Smart
SceneData
implements
Serializable
{
/**
/**
* 标识ID
* 标识ID
*/
*/
...
@@ -12,10 +12,10 @@ public class SmartTemplateParam implements Serializable {
...
@@ -12,10 +12,10 @@ public class SmartTemplateParam implements Serializable {
private
Long
id
;
private
Long
id
;
/**
/**
*
模板ID 关联smart_scene_templat
e中id
*
场景ID 关联smart_scen
e中id
*/
*/
@Column
(
name
=
"
templat
e_id"
)
@Column
(
name
=
"
scen
e_id"
)
private
Long
templat
eId
;
private
Long
scen
eId
;
/**
/**
* 类型 1触发条件 2执行内容
* 类型 1触发条件 2执行内容
...
@@ -34,7 +34,7 @@ public class SmartTemplateParam implements Serializable {
...
@@ -34,7 +34,7 @@ public class SmartTemplateParam implements Serializable {
private
String
paramKey
;
private
String
paramKey
;
/**
/**
*
模板
值 数组对象
*
参数
值 数组对象
*/
*/
@Column
(
name
=
"param_value"
)
@Column
(
name
=
"param_value"
)
private
String
paramValue
;
private
String
paramValue
;
...
@@ -60,21 +60,21 @@ public class SmartTemplateParam implements Serializable {
...
@@ -60,21 +60,21 @@ public class SmartTemplateParam implements Serializable {
}
}
/**
/**
* 获取
模板ID 关联smart_scene_templat
e中id
* 获取
场景ID 关联smart_scen
e中id
*
*
* @return
template_id - 模板ID 关联smart_scene_templat
e中id
* @return
scene_id - 场景ID 关联smart_scen
e中id
*/
*/
public
Long
get
Templat
eId
()
{
public
Long
get
Scen
eId
()
{
return
templat
eId
;
return
scen
eId
;
}
}
/**
/**
* 设置
模板ID 关联smart_scene_templat
e中id
* 设置
场景ID 关联smart_scen
e中id
*
*
* @param
templateId 模板ID 关联smart_scene_templat
e中id
* @param
sceneId 场景ID 关联smart_scen
e中id
*/
*/
public
void
set
TemplateId
(
Long
templat
eId
)
{
public
void
set
SceneId
(
Long
scen
eId
)
{
this
.
templateId
=
templat
eId
;
this
.
sceneId
=
scen
eId
;
}
}
/**
/**
...
@@ -132,18 +132,18 @@ public class SmartTemplateParam implements Serializable {
...
@@ -132,18 +132,18 @@ public class SmartTemplateParam implements Serializable {
}
}
/**
/**
* 获取
模板
值 数组对象
* 获取
参数
值 数组对象
*
*
* @return param_value -
模板
值 数组对象
* @return param_value -
参数
值 数组对象
*/
*/
public
String
getParamValue
()
{
public
String
getParamValue
()
{
return
paramValue
;
return
paramValue
;
}
}
/**
/**
* 设置
模板
值 数组对象
* 设置
参数
值 数组对象
*
*
* @param paramValue
模板
值 数组对象
* @param paramValue
参数
值 数组对象
*/
*/
public
void
setParamValue
(
String
paramValue
)
{
public
void
setParamValue
(
String
paramValue
)
{
this
.
paramValue
=
paramValue
==
null
?
null
:
paramValue
.
trim
();
this
.
paramValue
=
paramValue
==
null
?
null
:
paramValue
.
trim
();
...
@@ -156,7 +156,7 @@ public class SmartTemplateParam implements Serializable {
...
@@ -156,7 +156,7 @@ public class SmartTemplateParam implements Serializable {
sb
.
append
(
" ["
);
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
",
templateId="
).
append
(
templat
eId
);
sb
.
append
(
",
sceneId="
).
append
(
scen
eId
);
sb
.
append
(
", type="
).
append
(
type
);
sb
.
append
(
", type="
).
append
(
type
);
sb
.
append
(
", sort="
).
append
(
sort
);
sb
.
append
(
", sort="
).
append
(
sort
);
sb
.
append
(
", paramKey="
).
append
(
paramKey
);
sb
.
append
(
", paramKey="
).
append
(
paramKey
);
...
...
src/main/java/cn/com/glsx/smart/mapper/Smart
TemplateParam
Mapper.java
→
src/main/java/cn/com/glsx/smart/mapper/Smart
SceneData
Mapper.java
View file @
3fab142
package
cn
.
com
.
glsx
.
smart
.
mapper
;
package
cn
.
com
.
glsx
.
smart
.
mapper
;
import
cn.com.glsx.smart.entity.Smart
TemplateParam
;
import
cn.com.glsx.smart.entity.Smart
SceneData
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
public
interface
SmartTemplateParamMapper
extends
CommonBaseMapper
<
SmartTemplateParam
>
{
public
interface
SmartSceneDataMapper
extends
CommonBaseMapper
<
SmartSceneData
>
{
List
<
SmartTemplateParam
>
findByTemplateId
(
@Param
(
"templateId"
)
int
templateId
);
List
<
SmartSceneData
>
findByTemplateId
(
@Param
(
"templateId"
)
int
templateId
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/smart/service/OrderIssueService.java
View file @
3fab142
...
@@ -4,10 +4,9 @@ import cn.com.glsx.smart.commons.Constants;
...
@@ -4,10 +4,9 @@ import cn.com.glsx.smart.commons.Constants;
import
cn.com.glsx.smart.entity.ExecuteTaskVo
;
import
cn.com.glsx.smart.entity.ExecuteTaskVo
;
import
cn.com.glsx.smart.entity.MessageVo
;
import
cn.com.glsx.smart.entity.MessageVo
;
import
cn.com.glsx.smart.entity.ResponseVo
;
import
cn.com.glsx.smart.entity.ResponseVo
;
import
cn.com.glsx.smart.entity.Smart
TemplateParam
;
import
cn.com.glsx.smart.entity.Smart
SceneData
;
import
cn.com.glsx.smart.mapper.Smart
TemplateParam
Mapper
;
import
cn.com.glsx.smart.mapper.Smart
SceneData
Mapper
;
import
cn.com.glsx.smart.utils.HttpUtil
;
import
cn.com.glsx.smart.utils.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -32,11 +31,14 @@ import java.util.stream.Collectors;
...
@@ -32,11 +31,14 @@ import java.util.stream.Collectors;
public
class
OrderIssueService
{
public
class
OrderIssueService
{
@Autowired
@Autowired
private
Smart
TemplateParamMapper
smartTemplateParam
Mapper
;
private
Smart
SceneDataMapper
smartSceneData
Mapper
;
@Value
(
"${orderIssueurl}"
)
@Value
(
"${orderIssueurl}"
)
private
String
orderIssueurl
;
private
String
orderIssueurl
;
@Value
(
"${instructionInfIssue}"
)
private
String
instructionInfIssue
;
/**
/**
* 处理消息
* 处理消息
*
*
...
@@ -48,13 +50,13 @@ public class OrderIssueService {
...
@@ -48,13 +50,13 @@ public class OrderIssueService {
log
.
info
(
"数据异常"
);
log
.
info
(
"数据异常"
);
return
;
return
;
}
}
List
<
Smart
TemplateParam
>
smartTemplateParamList
=
smartTemplateParam
Mapper
.
findByTemplateId
(
Integer
.
parseInt
(
messageVo
.
getScenseId
()));
List
<
Smart
SceneData
>
smartTemplateParamList
=
smartSceneData
Mapper
.
findByTemplateId
(
Integer
.
parseInt
(
messageVo
.
getScenseId
()));
if
(
CollectionUtils
.
isEmpty
(
smartTemplateParamList
))
{
if
(
CollectionUtils
.
isEmpty
(
smartTemplateParamList
))
{
log
.
info
(
"未查到该场景id的条件{}"
,
messageVo
.
getScenseId
());
log
.
info
(
"未查到该场景id的条件{}"
,
messageVo
.
getScenseId
());
return
;
return
;
}
}
// 下发指令
// 下发指令
List
<
Smart
TemplateParam
>
orders
=
smartTemplateParamList
.
stream
().
filter
(
index
->
index
.
getParamKey
().
equals
(
Constants
.
Order_Issue
)).
collect
(
Collectors
.
toList
());
List
<
Smart
SceneData
>
orders
=
smartTemplateParamList
.
stream
().
filter
(
index
->
index
.
getParamKey
().
equals
(
Constants
.
Order_Issue
)).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
log
.
info
(
"未查到该场景id的指令{}"
,
messageVo
.
getScenseId
());
log
.
info
(
"未查到该场景id的指令{}"
,
messageVo
.
getScenseId
());
return
;
return
;
...
@@ -89,7 +91,7 @@ public class OrderIssueService {
...
@@ -89,7 +91,7 @@ public class OrderIssueService {
}
else
{
}
else
{
ordermap
.
put
(
"key"
,
executeTaskVo
.
getOrderCode
());
ordermap
.
put
(
"key"
,
executeTaskVo
.
getOrderCode
());
// 下发红外遥控指令
// 下发红外遥控指令
jsonObject
=
HttpUtil
.
sendPost
(
orderIssueurl
.
replace
(
"{remote_id}"
,
remoteId
).
replace
(
"{infrared_id}"
,
devideId
),
JSONObject
.
toJSONString
(
ordermap
),
new
HashMap
<>());
jsonObject
=
HttpUtil
.
sendPost
(
instructionInfIssue
.
replace
(
"{remote_id}"
,
remoteId
).
replace
(
"{infrared_id}"
,
devideId
),
JSONObject
.
toJSONString
(
ordermap
),
new
HashMap
<>());
}
}
if
(
jsonObject
!=
null
){
if
(
jsonObject
!=
null
){
ResponseVo
responseVo
=
JSONObject
.
toJavaObject
(
jsonObject
,
ResponseVo
.
class
);
ResponseVo
responseVo
=
JSONObject
.
toJavaObject
(
jsonObject
,
ResponseVo
.
class
);
...
@@ -104,7 +106,7 @@ public class OrderIssueService {
...
@@ -104,7 +106,7 @@ public class OrderIssueService {
}
}
});
});
// 推送消息开始 ----- TODO
// 推送消息开始 ----- TODO
List
<
Smart
TemplateParam
>
messageOrders
=
smartTemplateParamList
.
stream
().
filter
(
index
->
index
.
getParamKey
().
equals
(
Constants
.
MESSAGE_NOTI
)).
collect
(
Collectors
.
toList
());
List
<
Smart
SceneData
>
messageOrders
=
smartTemplateParamList
.
stream
().
filter
(
index
->
index
.
getParamKey
().
equals
(
Constants
.
MESSAGE_NOTI
)).
collect
(
Collectors
.
toList
());
// 推送消息结束 -----TODO
// 推送消息结束 -----TODO
}
}
...
...
src/main/resources/config/generatorConfig.xml
View file @
3fab142
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
</javaClientGenerator>
</javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table
tableName=
"smart_
template_param"
domainObjectName=
"SmartTemplateParam
"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
<table
tableName=
"smart_
scene_data"
domainObjectName=
"SmartSceneData
"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
</context>
</context>
</generatorConfiguration>
</generatorConfiguration>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/Smart
TemplateParam
Mapper.xml
→
src/main/resources/mapper/Smart
SceneData
Mapper.xml
View file @
3fab142
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.smart.mapper.Smart
TemplateParam
Mapper"
>
<mapper
namespace=
"cn.com.glsx.smart.mapper.Smart
SceneData
Mapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.smart.entity.Smart
TemplateParam
"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.smart.entity.Smart
SceneData
"
>
<!--
<!--
WARNING - @mbg.generated
WARNING - @mbg.generated
-->
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"
template_id"
jdbcType=
"BIGINT"
property=
"templat
eId"
/>
<result
column=
"
scene_id"
jdbcType=
"BIGINT"
property=
"scen
eId"
/>
<result
column=
"type"
jdbcType=
"TINYINT"
property=
"type"
/>
<result
column=
"type"
jdbcType=
"TINYINT"
property=
"type"
/>
<result
column=
"sort"
jdbcType=
"TINYINT"
property=
"sort"
/>
<result
column=
"sort"
jdbcType=
"TINYINT"
property=
"sort"
/>
<result
column=
"param_key"
jdbcType=
"VARCHAR"
property=
"paramKey"
/>
<result
column=
"param_key"
jdbcType=
"VARCHAR"
property=
"paramKey"
/>
...
@@ -16,11 +16,10 @@
...
@@ -16,11 +16,10 @@
<!--
<!--
WARNING - @mbg.generated
WARNING - @mbg.generated
-->
-->
id,
templat
e_id, `type`, sort, param_key, param_value
id,
scen
e_id, `type`, sort, param_key, param_value
</sql>
</sql>
<select
id=
"findByTemplateId"
resultMap=
"BaseResultMap"
>
<select
id=
"findByTemplateId"
resultMap=
"BaseResultMap"
>
select *
select *
from smart_
template_param where templat
e_id=#{templateId} and type=2
from smart_
scene_data where scen
e_id=#{templateId} and type=2
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
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