nayota-show-sdk 1.3.72 → 1.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -360,6 +360,28 @@ function normalizeLegacyPropLine(source = {}, prop = {}, row = {}) {
|
|
|
360
360
|
return null
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
+
function normalizeLegacyNumber(value) {
|
|
364
|
+
if (value === undefined || value === null || value === '') {
|
|
365
|
+
return null
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const raw = normalizeLegacyCurrentValue(value)
|
|
369
|
+
const num = Number(raw)
|
|
370
|
+
return Number.isFinite(num) ? num : null
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function getLegacyStatusCounts(props = []) {
|
|
374
|
+
const statusProps = props.filter(prop => prop && prop.isStatus)
|
|
375
|
+
return {
|
|
376
|
+
total: statusProps.length,
|
|
377
|
+
open: statusProps.filter(prop =>
|
|
378
|
+
normalizeLegacyNumber(prop.rawValue) === 1 ||
|
|
379
|
+
normalizeLegacyNumber(prop.value) === 1 ||
|
|
380
|
+
normalizeLegacyNumber(prop.prop?.value) === 1
|
|
381
|
+
).length
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
363
385
|
function normalizeLegacyEasyListProp(source = {}, row = {}) {
|
|
364
386
|
const prop = withLegacyId(source.prop || {})
|
|
365
387
|
const propId = source.propId || source.devicePropertyId || prop._id || source._id || source.id
|
|
@@ -426,10 +448,18 @@ function normalizeLegacyEasyListRow(item = {}) {
|
|
|
426
448
|
const props = Array.isArray(row.props)
|
|
427
449
|
? row.props.map(prop => normalizeLegacyEasyListProp(prop, row))
|
|
428
450
|
: []
|
|
451
|
+
const statusCounts = getLegacyStatusCounts(props)
|
|
429
452
|
|
|
430
453
|
return removeUndefinedFields({
|
|
431
454
|
...row,
|
|
432
455
|
props,
|
|
456
|
+
status: row.status
|
|
457
|
+
? {
|
|
458
|
+
...row.status,
|
|
459
|
+
total: row.status.total ?? statusCounts.total,
|
|
460
|
+
open: row.status.open ?? statusCounts.open
|
|
461
|
+
}
|
|
462
|
+
: undefined,
|
|
433
463
|
lineTime: row.lineTime || props.find(prop => prop.isImport && prop.valueAt)?.valueAt || row.updatedAt || null
|
|
434
464
|
})
|
|
435
465
|
}
|
|
@@ -140,6 +140,11 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
140
140
|
id: 'twin-1',
|
|
141
141
|
name: '会议室空调',
|
|
142
142
|
line: false,
|
|
143
|
+
status: {
|
|
144
|
+
value: 1,
|
|
145
|
+
label: '制热',
|
|
146
|
+
valueStr: '制热'
|
|
147
|
+
},
|
|
143
148
|
props: [
|
|
144
149
|
{
|
|
145
150
|
id: 'twin-prop-mode',
|
|
@@ -182,6 +187,13 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
182
187
|
const electricProp = row.props[1]
|
|
183
188
|
|
|
184
189
|
expect(row._id).toBe('twin-1')
|
|
190
|
+
expect(row.status).toEqual({
|
|
191
|
+
value: 1,
|
|
192
|
+
label: '制热',
|
|
193
|
+
valueStr: '制热',
|
|
194
|
+
total: 1,
|
|
195
|
+
open: 1
|
|
196
|
+
})
|
|
185
197
|
expect(modeProp).toEqual(
|
|
186
198
|
expect.objectContaining({
|
|
187
199
|
_id: 'twin-prop-mode',
|