From 290f2a28f42ef340db651901fa513c6beae8d899 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 21 九月 2023 11:34:21 +0800
Subject: [PATCH] 待机逻辑更改,超过配置的时间数据不变认为待机

---
 api/v1/plc.go |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/api/v1/plc.go b/api/v1/plc.go
index 6a6392f..47cf4bc 100644
--- a/api/v1/plc.go
+++ b/api/v1/plc.go
@@ -1,6 +1,7 @@
 package v1
 
 import (
+	"apsClient/conf"
 	"apsClient/constvar"
 	"apsClient/model/request"
 	"apsClient/model/response"
@@ -12,6 +13,7 @@
 	"apsClient/service"
 	"github.com/gin-gonic/gin"
 	"github.com/spf13/cast"
+	"time"
 )
 
 type PlcApi struct{}
@@ -38,10 +40,11 @@
 	plcStatus := 1 //鏂紑杩炴帴
 	isConnect := service.PlcIsConnect()
 	if isConnect {
-		if resp.FinishNumber > 0 { //鐢熶骇
+		lastUpdateTime := service.FinishUpdateTimeGet(params.Position)
+		if time.Now().Unix()-cast.ToInt64(lastUpdateTime) < conf.Conf.PLC.StandbyTime { //鐢熶骇
 			plcStatus = 2
-		} else { //寰呮満
-			plcStatus = 3
+		} else {
+			plcStatus = 3 //寰呮満
 		}
 	}
 	resp.PlcStatus = plcStatus

--
Gitblit v1.8.0