From f838162ed0ee7f2832924c2399eddd461760135a Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 13 十月 2023 21:47:54 +0800 Subject: [PATCH] plc地址和工艺参数不再单独拉取,只serf主启动时拉取 --- api/v1/task.go | 53 ++++++----------------------------------------------- 1 files changed, 6 insertions(+), 47 deletions(-) diff --git a/api/v1/task.go b/api/v1/task.go index 5604993..96a0b1a 100644 --- a/api/v1/task.go +++ b/api/v1/task.go @@ -4,21 +4,17 @@ "apsClient/conf" "apsClient/constvar" "apsClient/model" - "apsClient/model/common" "apsClient/model/request" "apsClient/model/response" - "apsClient/nsq" "apsClient/pkg/contextx" - "apsClient/pkg/convertx" "apsClient/pkg/ecode" "apsClient/pkg/logx" - "apsClient/pkg/safe" "apsClient/service" "apsClient/service/plc_address" "errors" - "fmt" "github.com/gin-gonic/gin" - "gorm.io/gorm" + "github.com/jinzhu/gorm" + "github.com/spf13/cast" "sort" "sync" "time" @@ -144,7 +140,7 @@ ctx.Fail(ecode.ParamsErr) return } - id := convertx.Atoi(idx) + id := cast.ToUint(idx) procedure, code := service.NewTaskService().GetProcedureById(id) if code != ecode.OK { ctx.Fail(code) @@ -179,15 +175,6 @@ }) } - safe.Go(func() { - caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicGetPlcAddress, conf.Conf.NsqConf.NodeId), fmt.Sprintf(constvar.NsqTopicSendPlcAddress, conf.Conf.NsqConf.NodeId)) - var addressResult common.ResponsePlcAddress - err := caller.Call(common.RequestPlcAddress{DeviceId: conf.Conf.System.DeviceId}, &addressResult, time.Second*3) - if err != nil { - logx.Infof("get plc address err: %v", err.Error()) - } - }) - resp := response.ProcessParamsResponse{ Number: processModel.Number, Params: processParamsArr, @@ -212,7 +199,7 @@ ctx.Fail(ecode.ParamsErr) return } - id := convertx.Atoi(idx) + id := cast.ToUint(idx) procedure, code := service.NewTaskService().GetProcedureById(id) if code != ecode.OK { ctx.Fail(code) @@ -231,20 +218,6 @@ logx.Errorf("UpdateProcedureStatus err: %v", err.Error()) ctx.Fail(ecode.UnknownErr) return - } - - msg := &common.MsgTaskStatusUpdate{ - WorkOrderId: procedure.WorkOrderID, - ProcedureID: procedure.ProceduresInfo.ProcedureID, - DeviceId: procedure.ProceduresInfo.DeviceID, - IsProcessing: false, - IsFinish: true, - } - - caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicTaskProcedureStatusUpdate, conf.Conf.NsqConf.NodeId), "") - err = caller.Send(msg) - if err != nil { - logx.Errorf("send task status update msg error:%v", err.Error()) } service.TaskFlagUnset(procedure.Channel) @@ -308,7 +281,7 @@ return } plcConfig, code := service.NewDevicePlcService().GetDevicePlc() - if code != ecode.OK || plcConfig.Id == 0 { + if code != ecode.OK || plcConfig.ID == 0 { ctx.FailWithMsg(ecode.NeedConfirmedErr, "璇峰厛閰嶇疆PLC") return } @@ -331,20 +304,6 @@ if err != nil { ctx.FailWithMsg(ecode.NeedConfirmedErr, "PLC璇锋眰澶辫触锛岃妫�鏌LC閰嶇疆") return - } - - msg := &common.MsgTaskStatusUpdate{ - WorkOrderId: procedure.WorkOrderID, - ProcedureID: procedure.ProceduresInfo.ProcedureID, - DeviceId: procedure.ProceduresInfo.DeviceID, - IsProcessing: true, - IsFinish: false, - } - - caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicTaskProcedureStatusUpdate, conf.Conf.NsqConf.NodeId), "") - err = caller.Send(msg) - if err != nil { - logx.Errorf("send task status update msg error:%v", err.Error()) } service.TaskFlagSet(procedure.Channel) ctx.Ok() @@ -388,7 +347,7 @@ } plcConfig, code := service.NewDevicePlcService().GetDevicePlc() - if code != ecode.OK || plcConfig.Id == 0 { + if code != ecode.OK || plcConfig.ID == 0 { ctx.FailWithMsg(ecode.NeedConfirmedErr, "璇峰厛閰嶇疆PLC") return } -- Gitblit v1.8.0