From 662676ff9fcd6eebf3fca89486979b7f85c35b59 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 23:06:13 +0800
Subject: [PATCH] 移除导入自动补值并仅使用文件中的测量值

---
 tests/test-console-data-import.test.mjs    |   16 ++++++++++++++--
 src/utils/consoleDataImport.ts             |    5 -----
 tests/test-console-data-import-browser.mjs |    8 ++++++++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/utils/consoleDataImport.ts b/src/utils/consoleDataImport.ts
index 76f7158..d025c36 100644
--- a/src/utils/consoleDataImport.ts
+++ b/src/utils/consoleDataImport.ts
@@ -80,11 +80,6 @@
         const duration = /^(\d+):([0-5]\d):([0-5]\d)(?:\.(\d{1,3}))?$/.exec(value.trim())
         value = duration ? Number(duration[1]) * 3600 + Number(duration[2]) * 60 + Number(duration[3]) + Number((duration[4] || '').padEnd(3, '0')) / 1000 : NaN
       }
-      if (party && ['temperature', 'positivePotential', 'negativePotential'].includes(field) && (value === undefined || value === '')) {
-        // 开发测试值只在甲方实时表缺值时补齐,按记录序号确定以保持重复导入幂等。
-        const offset = Number(raw['记录序号']) % 10
-        value = field === 'temperature' ? 25 + offset / 10 : field === 'positivePotential' ? (1500 + offset) / 1000 : (-100 - offset) / 1000
-      }
       const text = String(value ?? '').trim()
       const fail = (reason: string) => errors.push(`第${sourceRow}行,列「${header}」:${reason}`)
       if (['recordNo', 'batteryNo', 'stepName'].includes(field)) {
diff --git a/tests/test-console-data-import-browser.mjs b/tests/test-console-data-import-browser.mjs
index dc49e57..0c17c18 100644
--- a/tests/test-console-data-import-browser.mjs
+++ b/tests/test-console-data-import-browser.mjs
@@ -66,6 +66,14 @@
     const imported = JSON.parse(calls.at(-1).changesSummary)
     assert.equal(imported[0].batteryNo, 'BAT-1')
     if (process.env.PARTY_EXCEL) assert.equal(imported.length, { REALTIME: 7605, STEP: 129, CYCLE: 33 }[type])
+    if (process.env.PARTY_EXCEL && type === 'REALTIME') {
+      const source = XLSX.readFile(process.env.PARTY_EXCEL).Sheets.record
+      const fields = ['temperature', 'positivePotential', 'negativePotential']
+      for (let row = 0; row < imported.length; row++) {
+        assert.deepEqual(fields.map(field => imported[row][field]), fields.map((_, column) =>
+          source[XLSX.utils.encode_cell({ r: row + 1, c: column + 10 })]?.v ?? null))
+      }
+    }
   }
   await page.goto(`${origin}/test-list/1/console/data/import?dataType=REALTIME`)
   await page.locator('input[type=file]').setInputFiles(standardFile('REALTIME', true))
diff --git a/tests/test-console-data-import.test.mjs b/tests/test-console-data-import.test.mjs
index 34c14ce..a248392 100644
--- a/tests/test-console-data-import.test.mjs
+++ b/tests/test-console-data-import.test.mjs
@@ -28,11 +28,23 @@
   assert.equal(rows[1].data.capacity, 8.5122)
   assert.equal(rows[1].data.energy, 9.7178)
   for (const field of ['temperature', 'positivePotential', 'negativePotential']) {
-    assert.equal(typeof rows[0].data[field], 'number')
-    assert.equal(rows[0].data[field], parseConsoleImport(partyWorkbook(), 'REALTIME', ['BAT-1'], 'BAT-1')[0].data[field])
+    assert.equal(rows[0].data[field], null)
   }
 })
 
+test('采集器三项测量只读取 Excel 已有值,缺列或空格不生成数值', () => {
+  const workbook = partyWorkbook()
+  XLSX.utils.sheet_add_aoa(workbook.Sheets.record, [
+    ['温度(℃)', '正电位(V)', '负电位(V)'],
+    [32.75, 1.8234, -0.2045],
+    ['', '', ''],
+  ], { origin: 'K1' })
+  const rows = parseConsoleImport(workbook, 'REALTIME', ['BAT-1'])
+  assert.deepEqual(rows[0].errors, [])
+  assert.deepEqual(['temperature', 'positivePotential', 'negativePotential'].map(field => rows[0].data[field]), [32.75, 1.8234, -0.2045])
+  assert.deepEqual(['temperature', 'positivePotential', 'negativePotential'].map(field => rows[1].data[field]), [null, null, null])
+})
+
 test('标准模板兼容文本、毫秒时间戳和 Excel 日期系统,并拒绝非法日期', () => {
   const make = (time, date1904 = false) => {
     const workbook = XLSX.utils.book_new()

--
Gitblit v1.7.1