From 9e2fbcdc62bc4b45519715c8243446a11ee011cf Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 20 十二月 2023 17:26:27 +0800
Subject: [PATCH] goborrow rtu地址-1

---
 crontask/cron_task.go |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/crontask/cron_task.go b/crontask/cron_task.go
index 2bd87c3..da24026 100644
--- a/crontask/cron_task.go
+++ b/crontask/cron_task.go
@@ -38,15 +38,15 @@
 		}
 		for _, addressItem := range plcConfig.Details {
 			if addressItem.FieldName == constvar.PlcStartAddressTypeFinishNumber {
-				value, err := service.PlcReadDirect(plcConfig, addressItem.StartAddress, addressItem.Length, addressItem.Type)
+				value, err := service.PlcReadDirect(plcConfig, addressItem)
 				if err != nil {
 					logx.Infof("plc read finish number err: %v", err)
 					continue
 				}
-				finishNumber := cast.ToInt64(value)
+				finishNumber := cast.ToInt(value)
 				if finishNumber != 0 {
 					service.PlcCacheSet(conf.Conf.CurrentDeviceID, addressItem.Channel, constvar.PlcCacheKeyFinishNumber, finishNumber)
-					_ = service.NewProgressService().UpdateProgress(conf.Conf.CurrentDeviceID, addressItem.Channel, cast.ToInt64(finishNumber))
+					_ = service.NewProgressService().UpdateProgress(conf.Conf.CurrentDeviceID, addressItem.Channel, finishNumber)
 				}
 				logx.Infof("plc read finish number: %v", finishNumber)
 			}
@@ -64,7 +64,7 @@
 		}
 		for _, addressItem := range plcConfig.Details {
 			if addressItem.FieldName == constvar.PlcStartAddressTypeTotalNumber {
-				value, err := service.PlcReadDirect(plcConfig, addressItem.StartAddress, addressItem.Length, addressItem.Type)
+				value, err := service.PlcReadDirect(plcConfig, addressItem)
 				if err != nil {
 					logx.Infof("plc read total number err: %v", err)
 					continue
@@ -80,7 +80,7 @@
 	})
 
 	if isMaster {
-		s.Every(60).Seconds().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁
+		s.Every(20).Seconds().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁
 		s.Every(30).Seconds().Do(SyncTaskStatus)         //鍚屾浠诲姟鐘舵��
 		s.Every(10).Seconds().Do(CheckNsqConn)           //鏌ヨnsq杩炴帴
 		s.Every(30).Seconds().Do(ReportData)             //涓婃姤鏁版嵁
@@ -116,11 +116,15 @@
 	syncOkIds := make([]uint, 0, len(records))
 	for _, record := range records {
 		msg := &common.MsgTaskStatusUpdate{
-			WorkOrderId:  record.WorkOrderId,
-			ProcedureID:  record.ProcedureID,
-			DeviceId:     record.DeviceId,
-			IsProcessing: record.IsProcessing,
-			IsFinish:     record.IsFinish,
+			WorkOrderId:        record.WorkOrderId,
+			ProcedureID:        record.ProcedureID,
+			DeviceId:           record.DeviceId,
+			IsProcessing:       record.IsProcessing,
+			IsFinish:           record.IsFinish,
+			FinishAmount:       record.FinishedQuantity,
+			ProductProcedureID: record.ProductProcedureID,
+			StartTs:            record.StartTs,
+			FinishTs:           record.FinishTs,
 		}
 		caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicTaskProcedureStatusUpdate, conf.Conf.NsqConf.NodeId), "")
 		err = caller.Send(msg)
@@ -131,7 +135,7 @@
 		syncOkIds = append(syncOkIds, record.ID)
 	}
 	if len(syncOkIds) > 0 {
-		err = service.NewTaskService().RemoveTaskStatusSync(syncOkIds)
+		err = service.NewTaskService().FinishTaskStatusSync(syncOkIds)
 		if err != nil {
 			logx.Errorf("sync task status delete sync ok records error:%v", err)
 		}

--
Gitblit v1.8.0