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 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
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