| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- export function warningValue(source, ...keys) {
- for (const key of keys) {
- const value = source?.[key]
- if (value !== undefined && value !== null && value !== '') return value
- }
- return ''
- }
- export function warningIdOf(source) {
- return warningValue(source, 'warningId', 'warning_id', 'id')
- }
- export function normalizeWarningBasic(source = {}, references = {}) {
- const warningType = warningValue(source, 'warningType', 'warning_type')
- const warningLevel = warningValue(source, 'warningLevel', 'warning_level')
- return {
- ...source,
- warningId: warningIdOf(source),
- warningNo: warningValue(source, 'warningNo', 'warning_no'),
- warningName: warningValue(source, 'warningName', 'warning_name'),
- warningType,
- warningTypeText: warningValue(source, 'warningTypeText', 'warningTypeName', 'warning_type_name')
- || references.typeLabels?.[warningType]
- || warningType,
- warningLevel,
- warningLevelText: warningValue(source, 'warningLevelText', 'warningLevelName', 'warning_level_name')
- || references.levelLabels?.[warningLevel]
- || warningLevel,
- warningSpecial: warningValue(source, 'warningSpecial', 'warning_special'),
- warningContent: warningValue(source, 'warningContent', 'warning_content'),
- ownershipUnit: warningValue(source, 'ownershipUnit', 'ownership_unit'),
- deviceName: warningValue(source, 'deviceName', 'device_name'),
- deviceCode: warningValue(source, 'deviceCode', 'device_code'),
- location: warningValue(source, 'location', 'deviceLocation', 'device_location'),
- publisher: warningValue(source, 'publisher'),
- publisherName: warningValue(source, 'publisherName', 'publisher_name'),
- handler: warningValue(source, 'handler'),
- handlerName: warningValue(source, 'handlerName', 'handler_name'),
- reviewer: warningValue(source, 'reviewer'),
- reviewerName: warningValue(source, 'reviewerName', 'reviewer_name'),
- publishTime: warningValue(source, 'publishTime', 'publish_time'),
- updateTime: warningValue(source, 'updateTime', 'update_time'),
- remark: warningValue(source, 'remark'),
- status: warningValue(source, 'status'),
- itemId: warningValue(source, 'itemId', 'item_id'),
- itemSnapshot: warningValue(source, 'itemSnapshot', 'item_snapshot'),
- disposalDeadline: warningValue(source, 'disposalDeadline', 'disposal_deadline'),
- stageDeadline: warningValue(source, 'stageDeadline', 'stage_deadline')
- }
- }
- export function normalizeWarningAlarm(source = {}) {
- return {
- ...source,
- alarmId: warningValue(source, 'alarmId', 'alarm_id', 'id'),
- alarmNo: warningValue(source, 'alarmNo', 'alarm_no', 'warningCode', 'warning_code'),
- alarmContent: warningValue(source, 'alarmContent', 'alarm_content'),
- alarmType: warningValue(source, 'alarmTypeText', 'alarmType', 'alarm_type', 'warningTypeName', 'warning_type_name', 'warningType', 'warning_type'),
- deviceName: warningValue(source, 'deviceName', 'device_name', 'equipmentName', 'equipment_name'),
- deviceCode: warningValue(source, 'deviceCode', 'device_code', 'equipmentCode', 'equipment_code'),
- thresholdValue: warningValue(source, 'thresholdValue', 'threshold_value', 'warningValue', 'warning_value'),
- actualValue: warningValue(source, 'actualValue', 'actual_value'),
- createTime: warningValue(source, 'createTime', 'create_time', 'alarmTime', 'alarm_time')
- }
- }
- export function normalizeWarningDetail(source = {}, references = {}) {
- const basicSource = source.basicInfo || source.basic_info || source
- return {
- ...source,
- basicInfo: normalizeWarningBasic(basicSource, references),
- alarmList: (source.alarmList || source.alarm_list || []).map(normalizeWarningAlarm),
- disposalHistory: source.disposalHistory || source.disposal_history || source.disposalList || source.disposal_list || [],
- attachmentList: source.attachmentList || source.attachment_list || [],
- supervisionList: source.supervisionList || source.supervision_list || [],
- electronicArchive: source.electronicArchive || source.electronic_archive || null
- }
- }
|