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 a79556b5
authored
Apr 23, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]pulsar消费服务
1 parent
f6a297f4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
190 additions
and
78 deletions
pom.xml
src/main/java/cn/com/glsx/consumer/common/Contants.java
src/main/java/cn/com/glsx/consumer/comsumers/TuyaComsumer.java
src/main/java/cn/com/glsx/consumer/entity/DeviceEvent.java
src/main/java/cn/com/glsx/consumer/entity/DeviceEventDetail.java
src/main/java/cn/com/glsx/consumer/entity/DeviceVo.java
src/main/java/cn/com/glsx/consumer/service/DeviceEventService.java
src/main/java/cn/com/glsx/consumer/service/DeviceService.java
src/main/java/cn/com/glsx/consumer/service/InfoService.java
pom.xml
View file @
a79556b
...
@@ -66,6 +66,11 @@
...
@@ -66,6 +66,11 @@
<artifactId>
rest-admin-mybatis
</artifactId>
<artifactId>
rest-admin-mybatis
</artifactId>
<version>
1.1.0-SNAPSHOT
</version>
<version>
1.1.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-redis
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
src/main/java/cn/com/glsx/consumer/common/Contants.java
View file @
a79556b
...
@@ -7,6 +7,7 @@ package cn.com.glsx.consumer.common;
...
@@ -7,6 +7,7 @@ package cn.com.glsx.consumer.common;
public
class
Contants
{
public
class
Contants
{
public
static
final
int
STATUS_APPEAR
=
4
;
public
static
final
int
STATUS_APPEAR
=
4
;
public
static
final
int
event_APPEAR
=
20
;
public
static
final
int
SCENE_CONDITION_ALL
=
2
;
public
static
final
int
SCENE_CONDITION_ALL
=
2
;
public
static
final
int
SCENE_CONDITION_ANY
=
1
;
public
static
final
int
SCENE_CONDITION_ANY
=
1
;
public
static
final
String
MSG_TYPE_RESOURCE
=
"resource"
;
public
static
final
String
MSG_TYPE_RESOURCE
=
"resource"
;
...
...
src/main/java/cn/com/glsx/consumer/comsumers/TuyaComsumer.java
View file @
a79556b
...
@@ -53,6 +53,10 @@ public class TuyaComsumer implements CommandLineRunner {
...
@@ -53,6 +53,10 @@ public class TuyaComsumer implements CommandLineRunner {
String
data
=
AESBase64Utils
.
decrypt
(
vo
.
getData
(),
accessKey
.
substring
(
8
,
24
));
String
data
=
AESBase64Utils
.
decrypt
(
vo
.
getData
(),
accessKey
.
substring
(
8
,
24
));
log
.
info
(
"the real message data:"
+
data
);
log
.
info
(
"the real message data:"
+
data
);
infoService
.
processMessage
(
data
);
infoService
.
processMessage
(
data
);
}
else
if
(
protocol
.
equals
(
Contants
.
event_APPEAR
)){
String
data
=
AESBase64Utils
.
decrypt
(
vo
.
getData
(),
accessKey
.
substring
(
8
,
24
));
log
.
info
(
"the real message data:"
+
data
);
infoService
.
processEeventMessage
(
data
);
}
}
}
}
);
);
...
...
src/main/java/cn/com/glsx/consumer/entity/DeviceEvent.java
0 → 100644
View file @
a79556b
package
cn
.
com
.
glsx
.
consumer
.
entity
;
import
lombok.Data
;
/**
* @author zhouhaibao
* @date 2021/4/23 11:34
*/
@Data
public
class
DeviceEvent
{
private
String
devId
;
private
String
productKey
;
private
String
bizCode
;
private
DeviceEventDetail
bizData
;
}
src/main/java/cn/com/glsx/consumer/entity/DeviceEventDetail.java
0 → 100644
View file @
a79556b
package
cn
.
com
.
glsx
.
consumer
.
entity
;
import
lombok.Data
;
/**
* @author zhouhaibao
* @date 2021/4/23 11:35
*/
@Data
public
class
DeviceEventDetail
{
private
String
devId
;
private
String
uuid
;
private
String
uid
;
private
String
token
;
private
String
name
;
}
src/main/java/cn/com/glsx/consumer/entity/DeviceVo.java
0 → 100644
View file @
a79556b
package
cn
.
com
.
glsx
.
consumer
.
entity
;
import
lombok.Data
;
/**
* @author zhouhaibao
* @date 2021/4/23 11:43
*/
@Data
public
class
DeviceVo
{
private
String
deviceId
;
private
String
productId
;
private
String
resource
;
private
String
uid
;
private
String
time
;
private
String
parentId
;
private
String
deviceName
;
}
src/main/java/cn/com/glsx/consumer/service/DeviceEventService.java
View file @
a79556b
...
@@ -4,11 +4,13 @@ import cn.com.glsx.consumer.entity.AqaraEvent;
...
@@ -4,11 +4,13 @@ import cn.com.glsx.consumer.entity.AqaraEvent;
import
cn.com.glsx.consumer.entity.AqaraEventDetail
;
import
cn.com.glsx.consumer.entity.AqaraEventDetail
;
import
cn.com.glsx.consumer.entity.DeviceStatus
;
import
cn.com.glsx.consumer.entity.DeviceStatus
;
import
cn.com.glsx.consumer.entity.DeviceStatusDetail
;
import
cn.com.glsx.consumer.entity.DeviceStatusDetail
;
import
cn.com.glsx.consumer.entity.DeviceVo
;
import
cn.com.glsx.consumer.utils.HttpUtil
;
import
cn.com.glsx.consumer.utils.HttpUtil
;
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
;
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
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -26,11 +28,8 @@ public class DeviceEventService {
...
@@ -26,11 +28,8 @@ public class DeviceEventService {
@Autowired
@Autowired
private
InfoService
infoService
;
private
InfoService
infoService
;
//@Value("${addUserDevUrl}")
@Autowired
private
String
addUserDevUrl
;
private
DeviceService
deviceService
;
//@Value("${deleteUserDevUrl}")
private
String
deleteUserDevUrl
;
/**
/**
* 处理事件消息
* 处理事件消息
...
@@ -42,54 +41,24 @@ public class DeviceEventService {
...
@@ -42,54 +41,24 @@ public class DeviceEventService {
if
(
CollectionUtils
.
isNotEmpty
(
data
))
{
if
(
CollectionUtils
.
isNotEmpty
(
data
))
{
data
.
forEach
(
index
->
{
data
.
forEach
(
index
->
{
String
event
=
index
.
getEvent
();
String
event
=
index
.
getEvent
();
switch
(
event
)
{
if
(
event
.
equals
(
"GW_BIND"
)||
event
.
equals
(
"SUB_DEV_BIND"
)){
case
"GW_BIND"
:
deviceService
.
devBind
(
convertVo
(
index
));
//devBind(index);
}
else
if
(
event
.
equals
(
"GW_UN_BIND"
)||
event
.
equals
(
"SUB_DEV_UN_BIND"
)){
break
;
deviceService
.
devUnBind
(
convertVo
(
index
));
case
"SUB_DEV_BIND"
:
//devBind(index);
break
;
case
"GW_UN_BIND"
:
//devUnBind(index);
break
;
case
"SUB_DEV_UN_BIND"
:
//devUnBind(index);
break
;
default
:
break
;
}
}
});
});
}
}
}
}
/**
private
DeviceVo
convertVo
(
AqaraEventDetail
index
)
{
* 设备绑定
DeviceVo
deviceVo
=
new
DeviceVo
();
*
deviceVo
.
setDeviceId
(
index
.
getDid
());
* @param index 入参
deviceVo
.
setParentId
(
index
.
getParentId
());
*/
deviceVo
.
setResource
(
"access_platform_aqara"
);
private
void
devBind
(
AqaraEventDetail
index
)
{
deviceVo
.
setProductId
(
index
.
getModel
());
try
{
deviceVo
.
setUid
(
index
.
getOpenId
());
String
responseBody
=
HttpUtil
.
sendPost
(
addUserDevUrl
,
JSONObject
.
toJSONString
(
index
),
new
HashMap
<>());
deviceVo
.
setDeviceName
(
index
.
getName
());
log
.
info
(
"设备id{}保存结果{}"
,
index
.
getDid
(),
responseBody
);
return
deviceVo
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"设备id{}保存异常,{}"
,
index
.
getDid
(),
e
);
}
}
/**
* 设备解绑
*
* @param index 入参
*/
private
void
devUnBind
(
AqaraEventDetail
index
)
{
try
{
String
responseBody
=
HttpUtil
.
sendPost
(
deleteUserDevUrl
,
JSONObject
.
toJSONString
(
index
),
new
HashMap
<>());
log
.
info
(
"设备id{}删除结果{}"
,
index
.
getDid
(),
responseBody
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"设备id{}删除异常,{}"
,
index
.
getDid
(),
e
);
}
}
}
...
...
src/main/java/cn/com/glsx/consumer/service/DeviceService.java
0 → 100644
View file @
a79556b
package
cn
.
com
.
glsx
.
consumer
.
service
;
import
cn.com.glsx.consumer.entity.DeviceVo
;
import
cn.com.glsx.consumer.utils.HttpUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
/**
* @author zhouhaibao
* @date 2021/4/23 11:18
*/
@Service
@Slf4j
public
class
DeviceService
{
@Value
(
"${addUserDevUrl}"
)
private
String
addUserDevUrl
;
@Value
(
"${deleteUserDevUrl}"
)
private
String
deleteUserDevUrl
;
/**
* 设备绑定
*
* @param deviceVo 入参
*/
public
void
devBind
(
DeviceVo
deviceVo
)
{
try
{
String
responseBody
=
HttpUtil
.
sendPost
(
addUserDevUrl
,
JSONObject
.
toJSONString
(
deviceVo
),
new
HashMap
<>());
log
.
info
(
"设备id{}保存更新结果{}"
,
deviceVo
.
getDeviceId
(),
responseBody
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"设备id{}保存更新异常,{}"
,
deviceVo
.
getDeviceId
(),
e
);
}
}
/**
* 设备解绑
*
* @param deviceVo 入参
*/
public
void
devUnBind
(
DeviceVo
deviceVo
)
{
try
{
String
responseBody
=
HttpUtil
.
sendPost
(
deleteUserDevUrl
,
JSONObject
.
toJSONString
(
deviceVo
),
new
HashMap
<>());
log
.
info
(
"设备id{}删除结果{}"
,
deviceVo
.
getDeviceId
(),
responseBody
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"设备id{}删除异常,{}"
,
deviceVo
.
getDeviceId
(),
e
);
}
}
}
src/main/java/cn/com/glsx/consumer/service/InfoService.java
View file @
a79556b
...
@@ -4,8 +4,11 @@ import cn.com.glsx.consumer.common.Contants;
...
@@ -4,8 +4,11 @@ import cn.com.glsx.consumer.common.Contants;
import
cn.com.glsx.consumer.common.EDay
;
import
cn.com.glsx.consumer.common.EDay
;
import
cn.com.glsx.consumer.common.ELogic
;
import
cn.com.glsx.consumer.common.ELogic
;
import
cn.com.glsx.consumer.entity.DayInfo
;
import
cn.com.glsx.consumer.entity.DayInfo
;
import
cn.com.glsx.consumer.entity.DeviceEvent
;
import
cn.com.glsx.consumer.entity.DeviceEventDetail
;
import
cn.com.glsx.consumer.entity.DeviceStatus
;
import
cn.com.glsx.consumer.entity.DeviceStatus
;
import
cn.com.glsx.consumer.entity.DeviceStatusDetail
;
import
cn.com.glsx.consumer.entity.DeviceStatusDetail
;
import
cn.com.glsx.consumer.entity.DeviceVo
;
import
cn.com.glsx.consumer.entity.ScenseParamValue
;
import
cn.com.glsx.consumer.entity.ScenseParamValue
;
import
cn.com.glsx.consumer.entity.SmartDevideStatus
;
import
cn.com.glsx.consumer.entity.SmartDevideStatus
;
import
cn.com.glsx.consumer.entity.SmartSceneData
;
import
cn.com.glsx.consumer.entity.SmartSceneData
;
...
@@ -19,9 +22,11 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -19,9 +22,11 @@ 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.apache.ibatis.annotations.Case
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
sun.misc.Cache
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -54,8 +59,8 @@ public class InfoService {
...
@@ -54,8 +59,8 @@ public class InfoService {
@Value
(
"${issueOrderUrl}"
)
@Value
(
"${issueOrderUrl}"
)
private
String
issueOrderUrl
;
private
String
issueOrderUrl
;
/*
@Autowired
@Autowired
private
RedisService redisService;*/
private
DeviceService
deviceService
;
/**
/**
* 处理消息
* 处理消息
...
@@ -73,22 +78,22 @@ public class InfoService {
...
@@ -73,22 +78,22 @@ public class InfoService {
smartDevideStatusMapper
.
updateByPrimaryKeySelective
(
index
);
smartDevideStatusMapper
.
updateByPrimaryKeySelective
(
index
);
}
}
});
});
list
.
forEach
(
in
->
{
list
.
forEach
(
in
->
{
// 判断该设备是否在用户场景里面
// 判断该设备是否在用户场景里面
List
<
SmartSceneData
>
smartSceneDataList
=
smartSceneDataMapper
.
findSceneDataByDeviceId
(
in
.
getDeviceId
(),
in
.
getDeviceOrderCode
());
List
<
SmartSceneData
>
smartSceneDataList
=
smartSceneDataMapper
.
findSceneDataByDeviceId
(
in
.
getDeviceId
(),
in
.
getDeviceOrderCode
());
if
(
CollectionUtils
.
isEmpty
(
smartSceneDataList
))
{
if
(
CollectionUtils
.
isEmpty
(
smartSceneDataList
))
{
log
.
info
(
"未查到用户场景,设备id{}"
,
in
.
getDeviceId
());
log
.
info
(
"未查到用户场景,设备id{}"
,
in
.
getDeviceId
());
return
;
return
;
}
}
smartSceneDataList
.
forEach
(
index
->
{
smartSceneDataList
.
forEach
(
index
->
{
String
key
=
index
.
getSceneId
()+
"_"
+
Contants
.
SCENE_STATUS
;
String
key
=
index
.
getSceneId
()
+
"_"
+
Contants
.
SCENE_STATUS
;
List
<
SmartSceneData
>
sceneDataList
=
null
;
List
<
SmartSceneData
>
sceneDataList
=
null
;
Integer
executeCycle
=
index
.
getExecuteCycle
();
Integer
executeCycle
=
index
.
getExecuteCycle
();
// 判断场景是否触发
// 判断场景是否触发
if
(
index
.
getConditionRule
().
equals
(
"1"
))
{
if
(
index
.
getConditionRule
().
equals
(
"1"
))
{
sceneDataList
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
in
.
getDeviceOrderCode
());
sceneDataList
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
in
.
getDeviceOrderCode
());
}
else
{
}
else
{
sceneDataList
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
null
);
sceneDataList
=
smartSceneDataMapper
.
findBySceneId
(
index
.
getSceneId
(),
null
);
}
}
// 判断场景条件是否配置了时间并且是全部条件满足执行的
// 判断场景条件是否配置了时间并且是全部条件满足执行的
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
());
...
@@ -99,19 +104,6 @@ public class InfoService {
...
@@ -99,19 +104,6 @@ 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);
if(isTrigger&&!in.getFlag()){
if(o==null){
redisService.setOutTime(key,key,1, TimeUnit.DAYS);
}else{
log.info("场景id{}温湿度已经触发过一次",index.getSceneId());
return;
}
}
// 重新触发的话
if(!isTrigger&&!in.getFlag()){
redisService.delete(key);
}*/
log
.
info
(
"场景id{}---{}触发条件"
,
index
.
getSceneId
(),
isTrigger
?
"符合"
:
"不符合"
);
log
.
info
(
"场景id{}---{}触发条件"
,
index
.
getSceneId
(),
isTrigger
?
"符合"
:
"不符合"
);
if
(
isTrigger
)
{
if
(
isTrigger
)
{
// 下发场景
// 下发场景
...
@@ -138,11 +130,11 @@ public class InfoService {
...
@@ -138,11 +130,11 @@ public class InfoService {
status
.
forEach
(
index
->
{
status
.
forEach
(
index
->
{
// 温度特殊处理
// 温度特殊处理
SmartDevideStatus
smartDevideStatus
=
smartDevideStatusMapper
.
findDevStatusByIdAndCode
(
deviceStatus
.
getDevId
(),
index
.
getCode
());
SmartDevideStatus
smartDevideStatus
=
smartDevideStatusMapper
.
findDevStatusByIdAndCode
(
deviceStatus
.
getDevId
(),
index
.
getCode
());
if
(
smartDevideStatus
!=
null
)
{
if
(
smartDevideStatus
!=
null
)
{
String
code
=
index
.
getCode
();
String
code
=
index
.
getCode
();
String
deviceOrderValue
=
smartDevideStatus
.
getDeviceOrderValue
();
String
deviceOrderValue
=
smartDevideStatus
.
getDeviceOrderValue
();
if
(
code
.
equals
(
"va_temperature"
)
||
code
.
equals
(
"va_humidity"
))
{
if
(
code
.
equals
(
"va_temperature"
)
||
code
.
equals
(
"va_humidity"
))
{
if
(
deviceOrderValue
.
substring
(
0
,
deviceOrderValue
.
length
()-
1
).
equals
(
index
.
getValue
().
substring
(
0
,
deviceOrderValue
.
length
()-
1
)))
{
if
(
deviceOrderValue
.
substring
(
0
,
deviceOrderValue
.
length
()
-
1
).
equals
(
index
.
getValue
().
substring
(
0
,
deviceOrderValue
.
length
()
-
1
)))
{
log
.
info
(
"温湿度误差在0.1之内,不用触发场景"
);
log
.
info
(
"温湿度误差在0.1之内,不用触发场景"
);
smartDevideStatus
.
setFlag
(
false
);
smartDevideStatus
.
setFlag
(
false
);
}
}
...
@@ -193,7 +185,7 @@ public class InfoService {
...
@@ -193,7 +185,7 @@ public class InfoService {
log
.
info
(
"JSON解析异常:ScenseParamValue===="
+
e
.
getMessage
()
+
"===conditionId:"
+
condition
.
getId
());
log
.
info
(
"JSON解析异常:ScenseParamValue===="
+
e
.
getMessage
()
+
"===conditionId:"
+
condition
.
getId
());
return
false
;
return
false
;
}
}
log
.
info
(
"JSON转化后参数{}"
,
paramValue
);
log
.
info
(
"JSON转化后参数{}"
,
paramValue
);
//参数一,设备id
//参数一,设备id
String
deviceId
=
paramValue
.
getSelect
();
String
deviceId
=
paramValue
.
getSelect
();
//参数二,设备指令
//参数二,设备指令
...
@@ -208,8 +200,8 @@ public class InfoService {
...
@@ -208,8 +200,8 @@ public class InfoService {
String
Value
=
null
;
String
Value
=
null
;
//触发状态值,如果value没有值,则取ordervalue
//触发状态值,如果value没有值,则取ordervalue
if
(
deviceOrderCode
.
equals
(
"va_temperature"
)
||
deviceOrderCode
.
equals
(
"va_humidity"
))
{
if
(
deviceOrderCode
.
equals
(
"va_temperature"
)
||
deviceOrderCode
.
equals
(
"va_humidity"
))
{
if
(
StringUtils
.
isNotBlank
(
paramValue
.
getValue
()))
{
if
(
StringUtils
.
isNotBlank
(
paramValue
.
getValue
()))
{
log
.
info
(
"温湿度值为{}"
,
paramValue
.
getValue
());
log
.
info
(
"温湿度值为{}"
,
paramValue
.
getValue
());
Value
=
Integer
.
parseInt
(
paramValue
.
getValue
())
*
10
+
""
;
Value
=
Integer
.
parseInt
(
paramValue
.
getValue
())
*
10
+
""
;
}
}
// 处理特殊温度时候情况
// 处理特殊温度时候情况
...
@@ -225,7 +217,41 @@ public class InfoService {
...
@@ -225,7 +217,41 @@ public class InfoService {
}
}
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
boolean
valueByCode
=
ELogic
.
getValueByCode
(
logic
,
Value
,
smartDevideStatus
.
getDeviceOrderValue
()
==
null
?
""
:
smartDevideStatus
.
getDeviceOrderValue
());
boolean
valueByCode
=
ELogic
.
getValueByCode
(
logic
,
Value
,
smartDevideStatus
.
getDeviceOrderValue
()
==
null
?
""
:
smartDevideStatus
.
getDeviceOrderValue
());
log
.
info
(
"deviceOrderCode为{}的判断是{}"
,
deviceOrderCode
,
valueByCode
);
log
.
info
(
"deviceOrderCode为{}的判断是{}"
,
deviceOrderCode
,
valueByCode
);
return
valueByCode
;
return
valueByCode
;
}
}
/**
* 事件消息
*
* @param data
*/
public
void
processEeventMessage
(
String
data
)
{
DeviceEvent
deviceEvent
=
JSONObject
.
parseObject
(
data
,
DeviceEvent
.
class
);
String
bizCode
=
deviceEvent
.
getBizCode
();
switch
(
bizCode
)
{
case
"nameUpdate"
:
deviceService
.
devBind
(
convervo
(
deviceEvent
));
break
;
case
"bindUser"
:
deviceService
.
devBind
(
convervo
(
deviceEvent
));
break
;
case
"delete"
:
deviceService
.
devUnBind
(
convervo
(
deviceEvent
));
break
;
default
:
break
;
}
}
private
DeviceVo
convervo
(
DeviceEvent
deviceEvent
)
{
DeviceVo
deviceVo
=
new
DeviceVo
();
DeviceEventDetail
bizData
=
deviceEvent
.
getBizData
();
deviceVo
.
setDeviceName
(
bizData
.
getName
());
deviceVo
.
setUid
(
bizData
.
getUid
());
deviceVo
.
setProductId
(
deviceEvent
.
getProductKey
());
deviceVo
.
setResource
(
"access_platform_tuya"
);
deviceVo
.
setDeviceId
(
bizData
.
getDevId
());
return
deviceVo
;
}
}
}
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