From ee76588e80b26aadbac5547abb13d4b0bc45ce42 Mon Sep 17 00:00:00 2001 From: godLei6 <603785348@qq.com> Date: Tue, 19 Sep 2023 10:23:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Daction=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/event/deviceMsgEvent/thing.go | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/disvr/internal/event/deviceMsgEvent/thing.go b/src/disvr/internal/event/deviceMsgEvent/thing.go index 6fbaef7c9..8ab6ab62e 100644 --- a/src/disvr/internal/event/deviceMsgEvent/thing.go +++ b/src/disvr/internal/event/deviceMsgEvent/thing.go @@ -293,6 +293,17 @@ func (l *ThingLogic) HandleAction(msg *deviceMsg.PublishMsg) (respMsg *deviceMsg if err != nil { return nil, err } + utils.GoNewCtx(l.ctx, func(ctx context.Context) { + l.Infof("DeviceThingActionReport.Action device:%v,reqType:%v,req:%v", core, reqType, l.dreq) + //应用事件通知-设备物模型事件上报通知 ↓↓↓ + err := l.svcCtx.PubApp.DeviceThingActionReport(ctx, application.ActionReport{ + Device: core, Timestamp: timeStamp.UnixMilli(), ReqType: reqType, ClientToken: l.dreq.ClientToken, + ActionID: l.dreq.ActionID, Params: l.dreq.Params, Dir: schema.ActionDirUp, Code: l.dreq.Code, Status: l.dreq.Status, + }) + if err != nil { + logx.WithContext(ctx).Errorf("%s.DeviceThingActionReport.Action req:%v,err:%v", utils.FuncName(), utils.Fmt(l.dreq), err) + } + }) case deviceMsg.ActionReply: //云端请求设备的回复 reqType = deviceMsg.RespMsg var resp msgThing.Resp @@ -312,18 +323,20 @@ func (l *ThingLogic) HandleAction(msg *deviceMsg.PublishMsg) (respMsg *deviceMsg if err != nil { return nil, err } - } - utils.GoNewCtx(l.ctx, func(ctx context.Context) { - l.Infof("DeviceThingActionReport device:%v,reqType:%v,req:%v", core, reqType, l.dreq) - //应用事件通知-设备物模型事件上报通知 ↓↓↓ - err := l.svcCtx.PubApp.DeviceThingActionReport(ctx, application.ActionReport{ - Device: core, Timestamp: timeStamp.UnixMilli(), ReqType: reqType, ClientToken: l.dreq.ClientToken, - ActionID: l.dreq.ActionID, Params: l.dreq.Params, Dir: schema.ActionDirUp, Code: l.dreq.Code, Status: l.dreq.Status, + utils.GoNewCtx(l.ctx, func(ctx context.Context) { + l.Infof("DeviceThingActionReport.ActionReply device:%v,reqType:%v,req:%v", core, reqType, l.dreq) + param := resp.Data.(map[string]any) + //应用事件通知-设备物模型事件上报通知 ↓↓↓ + err := l.svcCtx.PubApp.DeviceThingActionReport(ctx, application.ActionReport{ + Device: core, Timestamp: timeStamp.UnixMilli(), ReqType: reqType, ClientToken: resp.ClientToken, + ActionID: resp.ActionID, Params: param, Dir: schema.ActionDirUp, Code: resp.Code, Status: resp.Status, + }) + if err != nil { + logx.WithContext(ctx).Errorf("%s.DeviceThingActionReport req:%v,err:%v", utils.FuncName(), utils.Fmt(l.dreq), err) + } }) - if err != nil { - logx.WithContext(ctx).Errorf("%s.DeviceThingActionReport req:%v,err:%v", utils.FuncName(), utils.Fmt(l.dreq), err) - } - }) + } + return nil, nil }