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 e20dc7be
authored
May 07, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]代码修改
1 parent
b9ed1f43
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
20 deletions
src/main/java/cn/com/glsx/smart/service/ConditionStrategy.java
src/main/java/cn/com/glsx/smart/service/OrderIssueService.java
src/main/java/cn/com/glsx/smart/service/SceneService.java
src/main/java/cn/com/glsx/smart/service/SmartDeviceStatusService.java
src/main/java/cn/com/glsx/smart/service/ConditionStrategy.java
View file @
e20dc7b
...
@@ -8,9 +8,8 @@ import java.util.List;
...
@@ -8,9 +8,8 @@ import java.util.List;
import
java.util.function.Predicate
;
import
java.util.function.Predicate
;
/**
/**
* @author
fengzhi
* @author
zhouhaibao
* @date 2021/3/9 17:05
* @date 2021/3/9 17:05
* @description 平台统一对外接口
*/
*/
public
interface
ConditionStrategy
{
public
interface
ConditionStrategy
{
...
...
src/main/java/cn/com/glsx/smart/service/OrderIssueService.java
View file @
e20dc7b
...
@@ -7,9 +7,9 @@ import cn.com.glsx.smart.pojo.response.scene.OrderResponse;
...
@@ -7,9 +7,9 @@ import cn.com.glsx.smart.pojo.response.scene.OrderResponse;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -20,7 +20,7 @@ import java.util.List;
...
@@ -20,7 +20,7 @@ import java.util.List;
@Slf4j
@Slf4j
public
class
OrderIssueService
{
public
class
OrderIssueService
{
@
Autowired
@
Resource
private
SceneClient
sceneClient
;
private
SceneClient
sceneClient
;
/**
/**
...
...
src/main/java/cn/com/glsx/smart/service/SceneService.java
View file @
e20dc7b
...
@@ -14,19 +14,14 @@ import cn.com.glsx.smart.mapper.SmartSceneDataMapper;
...
@@ -14,19 +14,14 @@ import cn.com.glsx.smart.mapper.SmartSceneDataMapper;
import
cn.com.glsx.smart.pojo.request.scene.SceneRequest
;
import
cn.com.glsx.smart.pojo.request.scene.SceneRequest
;
import
cn.com.glsx.smart.pojo.response.scene.OrderResponse
;
import
cn.com.glsx.smart.pojo.response.scene.OrderResponse
;
import
cn.com.glsx.smart.utils.DateUtils
;
import
cn.com.glsx.smart.utils.DateUtils
;
import
cn.com.glsx.smart.utils.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
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
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java
.util.HashMap
;
import
java
x.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -37,19 +32,19 @@ import java.util.stream.Collectors;
...
@@ -37,19 +32,19 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
SceneService
{
public
class
SceneService
{
@
Autowired
@
Resource
private
SmartDevideStatusMapper
smartDevideStatusMapper
;
private
SmartDevideStatusMapper
smartDevideStatusMapper
;
@
Autowired
@
Resource
private
SmartSceneDataMapper
smartSceneDataMapper
;
private
SmartSceneDataMapper
smartSceneDataMapper
;
@
Autowired
@
Resource
private
DayInfoMapper
dayInfoMapper
;
private
DayInfoMapper
dayInfoMapper
;
@
Autowired
@
Resource
private
ConditionStrategy
conditionStrategy
;
private
ConditionStrategy
conditionStrategy
;
@
Autowired
@
Resource
private
SceneClient
sceneClient
;
private
SceneClient
sceneClient
;
public
void
triggerScene
(
String
deviceId
,
String
order
){
public
void
triggerScene
(
String
deviceId
,
String
order
){
...
@@ -60,8 +55,7 @@ public class SceneService {
...
@@ -60,8 +55,7 @@ public class SceneService {
return
;
return
;
}
}
smartSceneDataList
.
forEach
(
index
->
{
smartSceneDataList
.
forEach
(
index
->
{
List
<
SmartSceneData
>
list
=
null
;
List
<
SmartSceneData
>
list
;
Integer
executeCycle
=
index
.
getExecuteCycle
();
// 判断场景是否触发
// 判断场景是否触发
if
(
index
.
getConditionRule
().
equals
(
Constants
.
SCENE_CONDITION_ANY
)){
if
(
index
.
getConditionRule
().
equals
(
Constants
.
SCENE_CONDITION_ANY
)){
list
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
order
);
list
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
order
);
...
@@ -69,7 +63,7 @@ public class SceneService {
...
@@ -69,7 +63,7 @@ public class SceneService {
list
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
null
);
list
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
null
);
}
}
// 判断场景条件是否配置了时间并且是全部条件满足执行的
// 判断场景条件是否配置了时间并且是全部条件满足执行的
List
<
SmartSceneData
>
scene_condition_time
=
list
.
stream
().
filter
(
inx
->
inx
.
getParamKey
().
equals
(
"scene_condition_status"
)).
collect
(
Collectors
.
toList
());
List
<
SmartSceneData
>
scene_condition_time
=
list
.
stream
().
filter
(
inx
->
(
"scene_condition_status"
).
equals
(
inx
.
getParamKey
()
)).
collect
(
Collectors
.
toList
());
if
(
list
.
size
()!=
scene_condition_time
.
size
()&&
index
.
getConditionRule
().
equals
(
Constants
.
SCENE_CONDITION_ALL
)){
if
(
list
.
size
()!=
scene_condition_time
.
size
()&&
index
.
getConditionRule
().
equals
(
Constants
.
SCENE_CONDITION_ALL
)){
log
.
info
(
"场景id{}不符合必要条件条件"
,
index
.
getSceneId
());
log
.
info
(
"场景id{}不符合必要条件条件"
,
index
.
getSceneId
());
return
;
return
;
...
@@ -95,7 +89,7 @@ public class SceneService {
...
@@ -95,7 +89,7 @@ public class SceneService {
log
.
info
(
"触发条件的value不存在===id:"
+
condition
.
getId
());
log
.
info
(
"触发条件的value不存在===id:"
+
condition
.
getId
());
return
false
;
return
false
;
}
}
ScenseParamValue
paramValue
=
null
;
ScenseParamValue
paramValue
;
try
{
try
{
paramValue
=
JSON
.
parseObject
(
JSON
.
parse
(
value
).
toString
(),
ScenseParamValue
.
class
);
paramValue
=
JSON
.
parseObject
(
JSON
.
parse
(
value
).
toString
(),
ScenseParamValue
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/cn/com/glsx/smart/service/SmartDeviceStatusService.java
View file @
e20dc7b
package
cn
.
com
.
glsx
.
smart
.
service
;
package
cn
.
com
.
glsx
.
smart
.
service
;
import
cn.com.glsx.smart.commons.Constants
;
import
cn.com.glsx.smart.entity.SmartDevideStatus
;
import
cn.com.glsx.smart.entity.SmartDevideStatus
;
import
cn.com.glsx.smart.mapper.SmartDevideStatusMapper
;
import
cn.com.glsx.smart.mapper.SmartDevideStatusMapper
;
import
cn.com.glsx.smart.vo.Event
;
import
cn.com.glsx.smart.vo.Event
;
...
...
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