|
@@ -119,7 +119,7 @@ function normalizeAsset(identity, source) {
|
|
|
const attributes = source.attributes && typeof source.attributes === 'object' ? source.attributes : {}
|
|
const attributes = source.attributes && typeof source.attributes === 'object' ? source.attributes : {}
|
|
|
const displayCode = text(source.code)
|
|
const displayCode = text(source.code)
|
|
|
const name = text(source.name || source.facilityName || source.resourceName || source.title) || (emergency ? '应急对象名称未提供' : '设施名称未提供')
|
|
const name = text(source.name || source.facilityName || source.resourceName || source.title) || (emergency ? '应急对象名称未提供' : '设施名称未提供')
|
|
|
- // 状态是码值时翻成中文(0 正常 / 1 维护中 / 2 异常);后端若直接给人话则原样用。
|
|
|
|
|
|
|
+ // 状态是码值时翻成中文(设施:0 正常 / 1 异常;后端若直接给人话则原样用)。
|
|
|
const statusRaw = source.status ?? source.state ?? source.statusName ?? source.stateName
|
|
const statusRaw = source.status ?? source.state ?? source.statusName ?? source.stateName
|
|
|
const status = (category === 'PROTECTION_TARGET' ? riskLevelText(statusRaw) : emergency ? undefinedEnumText(statusRaw) : facilityStatusText(statusRaw)) || '状态未发布'
|
|
const status = (category === 'PROTECTION_TARGET' ? riskLevelText(statusRaw) : emergency ? undefinedEnumText(statusRaw) : facilityStatusText(statusRaw)) || '状态未发布'
|
|
|
const location = text(source.address || source.location || source.position)
|
|
const location = text(source.address || source.location || source.position)
|
|
@@ -267,7 +267,7 @@ function deviceStatusText(item) {
|
|
|
* 但认不出的值也不能编一个中文,所以统一走 `codedText()`:命中词表回「中文」,
|
|
* 但认不出的值也不能编一个中文,所以统一走 `codedText()`:命中词表回「中文」,
|
|
|
* 未命中回「码」本身(与 CODE_TEXT 的立场一致)。
|
|
* 未命中回「码」本身(与 CODE_TEXT 的立场一致)。
|
|
|
*/
|
|
*/
|
|
|
-const FACILITY_STATUS_TEXT = { '0': '正常', '1': '维护中', '2': '异常' }
|
|
|
|
|
|
|
+const FACILITY_STATUS_TEXT = { '0': '正常', '1': '异常' }
|
|
|
const NETWORK_TYPE_TEXT = { '0': '燃气管网', '1': '排水管网', '2': '供水管网' }
|
|
const NETWORK_TYPE_TEXT = { '0': '燃气管网', '1': '排水管网', '2': '供水管网' }
|
|
|
const NETWORK_LEVEL_TEXT = { '0': '污水', '1': '雨水' }
|
|
const NETWORK_LEVEL_TEXT = { '0': '污水', '1': '雨水' }
|
|
|
/** 排水工程设施类型(0 闸门 / 1 调蓄设施 / 2 泵站):同样是码值,一并直译。 */
|
|
/** 排水工程设施类型(0 闸门 / 1 调蓄设施 / 2 泵站):同样是码值,一并直译。 */
|
|
@@ -289,11 +289,14 @@ const FACILITY_CATEGORY_TEXT = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 码 → 显示值;命中词表用中文,未登记机器码显示未知;已发布中文保留。 */
|
|
/** 码 → 显示值;命中词表用中文,未登记机器码显示未知;已发布中文保留。 */
|
|
|
-function codedText(value, dictionary, withCode = false) {
|
|
|
|
|
|
|
+function codedText(value, dictionary, withCode = false, unknownWithCode = false) {
|
|
|
const code = value === null || value === undefined ? '' : String(value).trim()
|
|
const code = value === null || value === undefined ? '' : String(value).trim()
|
|
|
if (!code) return ''
|
|
if (!code) return ''
|
|
|
const label = dictionary && Object.hasOwn(dictionary, code) ? dictionary[code] : ''
|
|
const label = dictionary && Object.hasOwn(dictionary, code) ? dictionary[code] : ''
|
|
|
- if (!label) return /\p{Script=Han}/u.test(code) && !/\p{Script=Latin}/u.test(code) ? code : '未知'
|
|
|
|
|
|
|
+ if (!label) {
|
|
|
|
|
+ const shown = /\p{Script=Han}/u.test(code) && !/\p{Script=Latin}/u.test(code) ? code : '未知'
|
|
|
|
|
+ return unknownWithCode && shown === '未知' ? `未知(${code})` : shown
|
|
|
|
|
+ }
|
|
|
return withCode ? `${label}(${code})` : label
|
|
return withCode ? `${label}(${code})` : label
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -302,9 +305,9 @@ export function facilityCategoryText(category) {
|
|
|
return codedText(category, FACILITY_CATEGORY_TEXT)
|
|
return codedText(category, FACILITY_CATEGORY_TEXT)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 设施状态(0 正常 / 1 维护中 / 2 异常)→ 中文;空值如实空。 */
|
|
|
|
|
|
|
+/** 设施状态(0 正常 / 1 异常)→ 中文;未知码保留原值并如实标注,不猜旧字典语义。 */
|
|
|
export function facilityStatusText(status) {
|
|
export function facilityStatusText(status) {
|
|
|
- return codedText(status, FACILITY_STATUS_TEXT)
|
|
|
|
|
|
|
+ return codedText(status, FACILITY_STATUS_TEXT, false, true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|