【fix】子设备上报方式修复

This commit is contained in:
XM-GO
2023-09-28 10:38:02 +08:00
parent 0dc58c0d18
commit 0b568d16e1
13 changed files with 378 additions and 64 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/PandaXGO/PandaKit/biz"
"log"
"pandax/apps/device/entity"
"pandax/apps/device/services"
ruleEntity "pandax/apps/rule/entity"
@@ -67,6 +68,7 @@ func (s *HookService) handleOne(msg *netbase.DeviceEventInfo) {
global.Log.Error("规则链执行失败", errs)
}
// 保存设备影子
log.Println(ruleMessage.Msg, msg.Type, msg.DeviceAuth)
if msg.Type != message.RpcRequestMes {
SetDeviceShadow(msg.DeviceAuth, ruleMessage.Msg, msg.Type)
}
@@ -106,7 +108,7 @@ func getRuleChain(etoken *tool.DeviceAuth) *ruleEntity.RuleDataJson {
}
}()
key := etoken.ProductId
get, err := global.Cache.ComputeIfAbsent(key, func(k any) (any, error) {
get, err := global.ProductCache.ComputeIfAbsent(key, func(k any) (any, error) {
one := services.ProductModelDao.FindOne(k.(string))
rule := ruleService.RuleChainModelDao.FindOne(one.RuleChainId)
return rule.RuleDataJson, nil