From 0d3d5a03d100614e0216249ec5ebbbbef8ff174c Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 16 九月 2023 19:13:54 +0800 Subject: [PATCH] fix --- api/v1/plc.go | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/api/v1/plc.go b/api/v1/plc.go index 7fdf89d..5f3b279 100644 --- a/api/v1/plc.go +++ b/api/v1/plc.go @@ -6,6 +6,7 @@ "apsClient/model/response" _ "apsClient/model/response" "apsClient/pkg/contextx" + "apsClient/pkg/plc/apacheplc4x" "apsClient/service" "github.com/gin-gonic/gin" "github.com/spf13/cast" @@ -26,11 +27,23 @@ if !ok { return } - finishNumber, _ := service.PlcCacheGet(constvar.PlcCacheKeyFinishNumber) - totalNumber, _ := service.PlcCacheGet(constvar.PlcCacheKeyTotalNumber) + finishNumber, _ := service.PlcCacheGet(params.Position, constvar.PlcCacheKeyFinishNumber) + totalNumber, _ := service.PlcCacheGet(params.Position, constvar.PlcCacheKeyTotalNumber) resp := new(response.ProductProgress) resp.FinishNumber = cast.ToInt(finishNumber) resp.TotalNumber = cast.ToInt(totalNumber) + + plcStatus := 1 //鏂紑杩炴帴 + isConnect := apacheplc4x.IsConnect() + if isConnect { + if resp.FinishNumber > 0 { //鐢熶骇 + plcStatus = 2 + } else { //寰呮満 + plcStatus = 3 + } + } + resp.PlcStatus = plcStatus + ctx.OkWithDetailed(resp) } -- Gitblit v1.8.0