From e77e66d681cd2676675d194211f171744e23b479 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 14 九月 2023 19:05:54 +0800 Subject: [PATCH] 从云端获取plc配置和plc地址 --- api/v1/plc.go | 31 +++++-------------------------- 1 files changed, 5 insertions(+), 26 deletions(-) diff --git a/api/v1/plc.go b/api/v1/plc.go index 254845f..7fdf89d 100644 --- a/api/v1/plc.go +++ b/api/v1/plc.go @@ -2,10 +2,10 @@ import ( "apsClient/constvar" + "apsClient/model/request" "apsClient/model/response" _ "apsClient/model/response" "apsClient/pkg/contextx" - "apsClient/pkg/ecode" "apsClient/service" "github.com/gin-gonic/gin" "github.com/spf13/cast" @@ -17,10 +17,12 @@ // @Tags 鐢熶骇鏁伴噺 // @Summary 鑾峰彇鐢熶骇杩涘害 // @Produce application/json +// @Param object body request.SendProcessParams true "鏌ヨ鍙傛暟" // @Success 200 {object} contextx.Response{data=response.ProductProgress} "鎴愬姛" -// @Router /v1/plc/productProgress [get] +// @Router /v1/plc/productProgress [post] func (slf *PlcApi) GetProductProgress(c *gin.Context) { - ctx, ok := contextx.NewContext(c, nil) + var params request.GetProductProgress + ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } @@ -41,29 +43,6 @@ func (slf *PlcApi) SetProductNumber(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { - return - } - - taskData, code := service.NewTaskService().GetTask() - if code != ecode.OK { - ctx.Fail(code) - return - } - - if taskData.Order == nil { - ctx.FailWithMsg(ecode.UnknownErr, "褰撳墠娌℃湁寰呯敓浜у伐鍗�") - return - } - - plcConfig, code := service.NewDevicePlcService().GetDevicePlc() - if code != ecode.OK { - ctx.FailWithMsg(ecode.UnknownErr, "璇峰厛閰嶇疆PLC") - return - } - - err := service.PlcWrite(plcConfig, constvar.PlcStartAddressTypeTotalNumber, taskData.Order.Amount.IntPart()) - if err != nil { - ctx.FailWithMsg(ecode.UnknownErr, "璁剧疆澶辫触锛岃妫�鏌lc閰嶇疆") return } ctx.Ok() -- Gitblit v1.8.0