From 3817b0e527eadc47d7fe32cd5d73278b3d867b58 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 09 十一月 2023 14:21:45 +0800 Subject: [PATCH] 按是否需求设置工艺参数的配置决定是否下发工艺参数 --- api/v1/task.go | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-) diff --git a/api/v1/task.go b/api/v1/task.go index 439a8d7..60f6b8d 100644 --- a/api/v1/task.go +++ b/api/v1/task.go @@ -271,22 +271,32 @@ ctx.Ok() return } - processModel, err := taskService.GetProcessParams(procedure, order) - if err != nil || processModel == nil || processModel.ParamsMap == nil { - ctx.FailWithMsg(ecode.ParamsErr, "鏈幏鍙栧埌宸ヨ壓鍙傛暟锛岃鍦ㄥ伐鑹烘ā鍨嬪簱涓笂浼狅紒") - return - } + plcConfig, code := service.NewDevicePlcService().GetDevicePlc() if code != ecode.OK || plcConfig.ID == 0 { ctx.FailWithMsg(ecode.NeedConfirmedErr, "璇峰厛閰嶇疆PLC") return } plcConfig.MaxTryTimes = 2 - err = SendParams(processModel.ParamsMap, plcConfig) + + device, err := service.GetCurrentDevice() if err != nil { - ctx.FailWithMsg(ecode.NeedConfirmedErr, "PLC璇锋眰澶辫触锛岃妫�鏌LC閰嶇疆锛�") + ctx.FailWithMsg(ecode.DBErr, err.Error()) return } + if device.NeedSetProcessParams { + processModel, err := taskService.GetProcessParams(procedure, order) + if err != nil || processModel == nil || processModel.ParamsMap == nil { + ctx.FailWithMsg(ecode.ParamsErr, "鏈幏鍙栧埌宸ヨ壓鍙傛暟锛岃鍦ㄥ伐鑹烘ā鍨嬪簱涓笂浼狅紒") + return + } + err = SendParams(processModel.ParamsMap, plcConfig) + if err != nil { + ctx.FailWithMsg(ecode.NeedConfirmedErr, "PLC璇锋眰澶辫触锛岃妫�鏌LC閰嶇疆锛�") + return + } + } + plcConfig.CurrentTryTimes = 0 err = service.PlcWrite(plcConfig, constvar.PlcStartAddressTypeTotalNumber, procedure.Channel, order.Amount.IntPart()) if err != nil { -- Gitblit v1.8.0