From 30c549c7e4d63ab3ea5bd0a7cfd69fa89339df33 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 18 九月 2023 19:46:27 +0800
Subject: [PATCH] 增加重试,地址-1

---
 crontask/cron_task.go |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/crontask/cron_task.go b/crontask/cron_task.go
index 968abfc..9938bb4 100644
--- a/crontask/cron_task.go
+++ b/crontask/cron_task.go
@@ -24,7 +24,7 @@
 		totalNumberTimeInterval = 60
 	}
 	s := gocron.NewScheduler(time.UTC)
-	_, err := s.Every(finishNumberTimeInterval).Seconds().StartImmediately().Do(func() {
+	_, err := s.Every(finishNumberTimeInterval).Seconds().Do(func() {
 		plcConfig, code := service.NewDevicePlcService().GetDevicePlc()
 		if code != ecode.OK {
 			return
@@ -33,6 +33,7 @@
 			if addressItem.FieldName == constvar.PlcStartAddressTypeFinishNumber {
 				value, err := service.PlcReadDirect(plcConfig, addressItem.StartAddress, addressItem.Length, addressItem.Type)
 				if err != nil {
+					logx.Infof("plc read finish number err: %v", err)
 					continue
 				}
 				finishNumber := cast.ToInt64(value)
@@ -40,7 +41,7 @@
 					service.PlcCacheSet(addressItem.Position, constvar.PlcCacheKeyFinishNumber, finishNumber)
 					_ = service.NewProgressService().UpdateProgress(addressItem.Position, cast.ToInt64(finishNumber))
 				}
-				logx.Infof("plc read finish number:%v, err:%v", finishNumber, err)
+				logx.Infof("plc read finish number: %v", finishNumber)
 			}
 		}
 
@@ -58,6 +59,7 @@
 			if addressItem.FieldName == constvar.PlcStartAddressTypeTotalNumber {
 				value, err := service.PlcReadDirect(plcConfig, addressItem.StartAddress, addressItem.Length, addressItem.Type)
 				if err != nil {
+					logx.Infof("plc read total number err: %v", err)
 					continue
 				}
 				totalNumber := cast.ToInt64(value)
@@ -65,13 +67,13 @@
 					service.PlcCacheSet(addressItem.Position, constvar.PlcCacheKeyTotalNumber, totalNumber)
 					_ = service.NewProgressService().UpdateProgress(addressItem.Position, cast.ToInt64(totalNumber))
 				}
-				logx.Infof("plc read total number:%v, err:%v", totalNumber, err)
+				logx.Infof("plc read total number: %v", totalNumber)
 			}
 		}
 
 	})
 
-	s.Every(60).Seconds().StartImmediately().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁
+	s.Every(180).Seconds().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁
 	s.StartAsync()
 	return nil
 }

--
Gitblit v1.8.0