From 9c489617b002e71859597097c9d1d2f1b9fc0e56 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期二, 23 十二月 2025 17:05:57 +0800
Subject: [PATCH] 完善modbus协议写入方法

---
 mes-web/src/views/plcTest/components/MultiDeviceTest/TaskOrchestration.vue |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/mes-web/src/views/plcTest/components/MultiDeviceTest/TaskOrchestration.vue b/mes-web/src/views/plcTest/components/MultiDeviceTest/TaskOrchestration.vue
index 5f2b44e..a06745f 100644
--- a/mes-web/src/views/plcTest/components/MultiDeviceTest/TaskOrchestration.vue
+++ b/mes-web/src/views/plcTest/components/MultiDeviceTest/TaskOrchestration.vue
@@ -531,10 +531,10 @@
       headerStr === 'w' || headerStr === '瀹藉害') {
       headerMap.width = index
     }
-    // 楂樺害
-    else if (headerStr.includes('楂�') || headerStr.includes('height') ||
-      headerStr === 'h' || headerStr === '楂樺害') {
-      headerMap.height = index
+    // 闀垮害
+    else if (headerStr.includes('闀�') || headerStr.includes('length') ||
+      headerStr === 'l' || headerStr === '闀垮害') {
+      headerMap.length = index
     }
     // 鍘氬害
     else if (headerStr.includes('鍘�') || headerStr.includes('thickness') ||
@@ -570,14 +570,15 @@
 
   // 濡傛灉娌℃湁鎵惧埌琛ㄥご锛屽皾璇曚娇鐢ㄧ涓�琛屼綔涓鸿〃澶达紙绱㈠紩鏂瑰紡锛�
   if (Object.keys(headerMap).length === 0 && jsonData.length > 1) {
-    // 榛樿鏍煎紡锛氱幓鐠僆D, 瀹�, 楂�, 鍘�, 鏁伴噺锛堟寜鍒楅『搴忥級
+    // 榛樿鏍煎紡锛氱幓鐠僆D, 瀹�, 闀�, 鍘�, 鏁伴噺锛堟寜鍒楅『搴忥級
     headerMap.glassId = 0
     headerMap.width = 1
-    headerMap.height = 2
+    headerMap.length = 2
     headerMap.thickness = 3
     headerMap.quantity = 4
   }
 
+  const padTwoZero = (num) => num.toString().padStart(2, '0')
   // 瑙f瀽鏁版嵁琛�
   const result = []
   for (let i = 1; i < jsonData.length; i++) {
@@ -586,7 +587,7 @@
 
     const glassId = row[headerMap.glassId] ? String(row[headerMap.glassId]).trim() : ''
     const width = row[headerMap.width] ? String(row[headerMap.width]).trim() : ''
-    const height = row[headerMap.height] ? String(row[headerMap.height]).trim() : ''
+    const length = row[headerMap.length] ? String(row[headerMap.length]).trim() : ''
     const thickness = row[headerMap.thickness] ? String(row[headerMap.thickness]).trim() : ''
     const quantity = row[headerMap.quantity] ? String(row[headerMap.quantity]).trim() : ''
     const filmsId = row[headerMap.filmsId] ? String(row[headerMap.filmsId]).trim() : ''
@@ -595,7 +596,7 @@
     const customerName = row[headerMap.customerName] ? String(row[headerMap.customerName]).trim() : ''
 
     // 璺宠繃绌鸿
-    if (!glassId && !width && !height && !thickness && !quantity) {
+    if (!glassId && !width && !length && !thickness && !quantity) {
       continue
     }
 
@@ -616,12 +617,12 @@
     const qty = parseInt(quantity) || 1
     for (let j = 0; j < qty; j++) {
       // 濡傛灉鏁伴噺澶т簬1锛屼负姣忔潯璁板綍鐢熸垚鍞竴鐨勭幓鐠僆D锛堣拷鍔犲簭鍙凤級
-      const finalGlassId = qty > 1 ? `${glassId}${j + 1}` : glassId
+      const finalGlassId = qty > 1 ? `${glassId}${padTwoZero(j + 1)}` : glassId
 
       result.push({
         glassId: finalGlassId,
         width: parseNumber(width),
-        height: parseNumber(height),
+        length: parseNumber(length),
         thickness: parseNumber(thickness),
         quantity: '1', // 姣忔潯璁板綍鏁伴噺涓�1
         filmsId: filmsId,

--
Gitblit v1.8.0