Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
glsx-smart-message-channel
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 469d69a7
authored
Apr 13, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]pulsar消费服务
1 parent
43903701
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
src/main/java/cn/com/glsx/consumer/service/TuyaConmsumerService.java
src/main/java/cn/com/glsx/consumer/service/TuyaConmsumerService.java
View file @
469d69a
...
@@ -70,23 +70,23 @@ public class TuyaConmsumerService {
...
@@ -70,23 +70,23 @@ public class TuyaConmsumerService {
});
});
// 判断该设备是否在用户场景里面
// 判断该设备是否在用户场景里面
List
<
SmartSceneData
>
smartSceneDataList
=
smartSceneDataMapper
.
findSceneDataByDeviceId
(
list
.
get
(
0
).
getDeviceId
());
List
<
SmartSceneData
>
smartSceneDataList
=
smartSceneDataMapper
.
findSceneDataByDeviceId
(
list
.
get
(
0
).
getDeviceId
());
if
(
CollectionUtils
.
isEmpty
(
smartSceneDataList
))
{
if
(
CollectionUtils
.
isEmpty
(
smartSceneDataList
))
{
log
.
info
(
"未查到用户场景,设备id{}"
,
list
.
get
(
0
).
getDeviceId
());
log
.
info
(
"未查到用户场景,设备id{}"
,
list
.
get
(
0
).
getDeviceId
());
return
;
return
;
}
}
smartSceneDataList
.
forEach
(
index
->
{
smartSceneDataList
.
forEach
(
index
->
{
Integer
executeCycle
=
index
.
getExecuteCycle
();
Integer
executeCycle
=
index
.
getExecuteCycle
();
// 判断场景是否触发
// 判断场景是否触发
List
<
SmartSceneData
>
sceneDataList
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
());
List
<
SmartSceneData
>
sceneDataList
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
());
// 判断场景条件是否配置了时间并且是全部条件满足执行的
// 判断场景条件是否配置了时间并且是全部条件满足执行的
List
<
SmartSceneData
>
scene_condition_time
=
sceneDataList
.
stream
().
filter
(
inx
->
inx
.
getParamKey
().
equals
(
"scene_condition_status"
)).
collect
(
Collectors
.
toList
());
List
<
SmartSceneData
>
scene_condition_time
=
sceneDataList
.
stream
().
filter
(
inx
->
inx
.
getParamKey
().
equals
(
"scene_condition_status"
)).
collect
(
Collectors
.
toList
());
if
(
list
.
size
()!=
scene_condition_time
.
size
()&&
index
.
getConditionRule
().
equals
(
"2"
))
{
if
(
list
.
size
()
!=
scene_condition_time
.
size
()
&&
index
.
getConditionRule
().
equals
(
"2"
))
{
log
.
info
(
"场景id{}不符合必要条件条件"
,
index
.
getSceneId
());
log
.
info
(
"场景id{}不符合必要条件条件"
,
index
.
getSceneId
());
return
;
return
;
}
}
boolean
isTrigger
=
conditionStrategy
.
isTrigger
(
sceneDataList
,
executeCycle
,
boolean
isTrigger
=
conditionStrategy
.
isTrigger
(
sceneDataList
,
executeCycle
,
(
SmartSceneData
condition
)
->
getTriggerResult
(
condition
));
(
SmartSceneData
condition
)
->
getTriggerResult
(
condition
));
log
.
info
(
"场景id{}---{}触发条件"
,
index
.
getSceneId
(),
isTrigger
?
"符合"
:
"不符合"
);
log
.
info
(
"场景id{}---{}触发条件"
,
index
.
getSceneId
(),
isTrigger
?
"符合"
:
"不符合"
);
if
(
isTrigger
)
{
if
(
isTrigger
)
{
// 下发场景
// 下发场景
Map
<
String
,
String
>
requestMap
=
new
HashMap
<>();
Map
<
String
,
String
>
requestMap
=
new
HashMap
<>();
...
@@ -138,7 +138,7 @@ public class TuyaConmsumerService {
...
@@ -138,7 +138,7 @@ public class TuyaConmsumerService {
//触发条件判断
//触发条件判断
private
boolean
getTriggerResult
(
SmartSceneData
condition
)
{
private
boolean
getTriggerResult
(
SmartSceneData
condition
)
{
if
(
condition
.
getExecuteCycle
()
!=
1
&&
!
getExecuteCycle
().
equals
(
condition
.
getExecuteCycle
()))
{
if
(
condition
.
getExecuteCycle
()
!=
1
&&
!
getExecuteCycle
().
equals
(
condition
.
getExecuteCycle
()))
{
log
.
info
(
"当前时间不是触发周期:"
+
condition
.
getId
());
log
.
info
(
"当前时间不是触发周期:"
+
condition
.
getId
());
return
false
;
return
false
;
}
}
...
@@ -165,8 +165,13 @@ public class TuyaConmsumerService {
...
@@ -165,8 +165,13 @@ public class TuyaConmsumerService {
if
(
smartDevideStatus
==
null
)
{
if
(
smartDevideStatus
==
null
)
{
return
false
;
return
false
;
}
}
String
Value
=
null
;
//触发状态值,如果value没有值,则取ordervalue
//触发状态值,如果value没有值,则取ordervalue
String
Value
=
paramValue
.
getValue
();
if
(
deviceOrderCode
.
equals
(
"va_temperature"
)
||
deviceOrderCode
.
equals
(
"va_humidity"
))
{
Value
=
Integer
.
parseInt
(
paramValue
.
getValue
())
*
10
+
""
;
}
else
{
Value
=
paramValue
.
getValue
();
}
if
(
StringUtils
.
isEmpty
(
Value
))
{
if
(
StringUtils
.
isEmpty
(
Value
))
{
Value
=
paramValue
.
getOrderVal
();
Value
=
paramValue
.
getOrderVal
();
if
(
StringUtils
.
isEmpty
(
Value
))
{
if
(
StringUtils
.
isEmpty
(
Value
))
{
...
@@ -175,6 +180,6 @@ public class TuyaConmsumerService {
...
@@ -175,6 +180,6 @@ public class TuyaConmsumerService {
}
}
}
}
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
return
ELogic
.
getValueByCode
(
logic
,
Value
,
smartDevideStatus
.
getDeviceOrderValue
()
==
null
?
""
:
smartDevideStatus
.
getDeviceOrderValue
());
return
ELogic
.
getValueByCode
(
logic
,
Value
,
smartDevideStatus
.
getDeviceOrderValue
()
==
null
?
""
:
smartDevideStatus
.
getDeviceOrderValue
());
}
}
}
}
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