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 dc304367
authored
Apr 22, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]pulsar消费服务
1 parent
fced48a0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
93 deletions
pom.xml
src/main/java/cn/com/glsx/consumer/redis/RedisService.java
src/main/java/cn/com/glsx/consumer/service/DeviceEventService.java
src/main/java/cn/com/glsx/consumer/service/InfoService.java
pom.xml
View file @
dc30436
...
@@ -90,11 +90,6 @@
...
@@ -90,11 +90,6 @@
<artifactId>
mapper
</artifactId>
<artifactId>
mapper
</artifactId>
<version>
3.4.1
</version>
<version>
3.4.1
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-redis
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
<executions>
<executions>
<execution>
<execution>
...
...
src/main/java/cn/com/glsx/consumer/redis/RedisService.java
deleted
100644 → 0
View file @
fced48a
package
cn
.
com
.
glsx
.
consumer
.
redis
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.data.redis.core.HashOperations
;
import
org.springframework.data.redis.core.ListOperations
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.SetOperations
;
import
org.springframework.data.redis.core.ValueOperations
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
*
* redis 操作工具类
*/
@Component
public
class
RedisService
{
@Resource
(
name
=
"redisTemplate"
)
protected
RedisTemplate
<
Object
,
Object
>
redisTemplate
;
protected
Log
logger
=
LogFactory
.
getLog
(
getClass
());
public
void
set
(
String
key
,
Object
value
)
{
ValueOperations
valueOperations
=
redisTemplate
.
opsForValue
();
valueOperations
.
set
(
key
,
value
);
}
public
Object
get
(
String
key
)
{
return
redisTemplate
.
opsForValue
().
get
(
key
);
}
public
void
setList
(
String
key
,
List
<?>
value
)
{
ListOperations
listOperations
=
redisTemplate
.
opsForList
();
listOperations
.
leftPush
(
key
,
value
);
}
public
void
setOutTime
(
String
key
,
Object
value
,
long
timeout
,
TimeUnit
unit
)
{
ValueOperations
valueOperations
=
redisTemplate
.
opsForValue
();
valueOperations
.
set
(
key
,
value
,
timeout
,
unit
);
}
public
Object
getList
(
String
key
)
{
return
redisTemplate
.
opsForList
().
leftPop
(
key
);
}
public
void
setSet
(
String
key
,
Set
<?>
value
)
{
SetOperations
setOperations
=
redisTemplate
.
opsForSet
();
setOperations
.
add
(
key
,
value
);
}
public
Object
getSet
(
String
key
)
{
return
redisTemplate
.
opsForSet
().
members
(
key
);
}
public
void
setHash
(
String
key
,
Map
<
String
,
?>
value
)
{
HashOperations
hashOperations
=
redisTemplate
.
opsForHash
();
hashOperations
.
putAll
(
key
,
value
);
}
public
Object
getHash
(
String
key
)
{
return
redisTemplate
.
opsForHash
().
entries
(
key
);
}
public
void
delete
(
String
key
)
{
redisTemplate
.
delete
(
key
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/consumer/service/DeviceEventService.java
View file @
dc30436
...
@@ -44,16 +44,16 @@ public class DeviceEventService {
...
@@ -44,16 +44,16 @@ public class DeviceEventService {
String
event
=
index
.
getEvent
();
String
event
=
index
.
getEvent
();
switch
(
event
)
{
switch
(
event
)
{
case
"GW_BIND"
:
case
"GW_BIND"
:
devBind
(
index
);
//
devBind(index);
break
;
break
;
case
"SUB_DEV_BIND"
:
case
"SUB_DEV_BIND"
:
devBind
(
index
);
//
devBind(index);
break
;
break
;
case
"GW_UN_BIND"
:
case
"GW_UN_BIND"
:
devUnBind
(
index
);
//
devUnBind(index);
break
;
break
;
case
"SUB_DEV_UN_BIND"
:
case
"SUB_DEV_UN_BIND"
:
devUnBind
(
index
);
//
devUnBind(index);
break
;
break
;
default
:
default
:
break
;
break
;
...
...
src/main/java/cn/com/glsx/consumer/service/InfoService.java
View file @
dc30436
...
@@ -12,7 +12,6 @@ import cn.com.glsx.consumer.entity.SmartSceneData;
...
@@ -12,7 +12,6 @@ import cn.com.glsx.consumer.entity.SmartSceneData;
import
cn.com.glsx.consumer.mapper.DayInfoMapper
;
import
cn.com.glsx.consumer.mapper.DayInfoMapper
;
import
cn.com.glsx.consumer.mapper.SmartDevideStatusMapper
;
import
cn.com.glsx.consumer.mapper.SmartDevideStatusMapper
;
import
cn.com.glsx.consumer.mapper.SmartSceneDataMapper
;
import
cn.com.glsx.consumer.mapper.SmartSceneDataMapper
;
import
cn.com.glsx.consumer.redis.RedisService
;
import
cn.com.glsx.consumer.utils.DateUtils
;
import
cn.com.glsx.consumer.utils.DateUtils
;
import
cn.com.glsx.consumer.utils.HttpUtil
;
import
cn.com.glsx.consumer.utils.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -55,8 +54,8 @@ public class InfoService {
...
@@ -55,8 +54,8 @@ public class InfoService {
@Value
(
"${issueOrderUrl}"
)
@Value
(
"${issueOrderUrl}"
)
private
String
issueOrderUrl
;
private
String
issueOrderUrl
;
@Autowired
/*
@Autowired
private
RedisService
redisService
;
private RedisService redisService;
*/
/**
/**
* 处理消息
* 处理消息
...
@@ -100,7 +99,7 @@ public class InfoService {
...
@@ -100,7 +99,7 @@ public class InfoService {
boolean
isTrigger
=
conditionStrategy
.
isTrigger
(
scene_condition_time
,
index
.
getConditionRule
(),
boolean
isTrigger
=
conditionStrategy
.
isTrigger
(
scene_condition_time
,
index
.
getConditionRule
(),
(
SmartSceneData
condition
)
->
getTriggerResult
(
condition
));
(
SmartSceneData
condition
)
->
getTriggerResult
(
condition
));
// 温度控制
// 温度控制
Object
o
=
redisService
.
get
(
key
);
/*
Object o = redisService.get(key);
if(isTrigger&&!in.getFlag()){
if(isTrigger&&!in.getFlag()){
if(o==null){
if(o==null){
redisService.setOutTime(key,key,1, TimeUnit.DAYS);
redisService.setOutTime(key,key,1, TimeUnit.DAYS);
...
@@ -112,7 +111,7 @@ public class InfoService {
...
@@ -112,7 +111,7 @@ public class InfoService {
// 重新触发的话
// 重新触发的话
if(!isTrigger&&!in.getFlag()){
if(!isTrigger&&!in.getFlag()){
redisService.delete(key);
redisService.delete(key);
}
}
*/
log
.
info
(
"场景id{}---{}触发条件"
,
index
.
getSceneId
(),
isTrigger
?
"符合"
:
"不符合"
);
log
.
info
(
"场景id{}---{}触发条件"
,
index
.
getSceneId
(),
isTrigger
?
"符合"
:
"不符合"
);
if
(
isTrigger
)
{
if
(
isTrigger
)
{
// 下发场景
// 下发场景
...
...
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