|
|
@@ -183,11 +183,41 @@ const send = (message: BaseToPreviewMessage) => {
|
|
|
return post(message);
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * 子应用只识别不带后缀的设备类型组(windrect / fanlocal / gate / window ...)。
|
|
|
+ * 后端链接里常带业务子类型(如 windrect_ds_two、fanlocal_hx),直接透传会让子应用去错误的图层里找。
|
|
|
+ * 这里统一归一到子应用认识的类型组;人员/车辆类型保持原样,由子应用转去人员定位系统。
|
|
|
+ */
|
|
|
+const DEVICE_TYPE_PREFIXES = ['fanlocal', 'fanmain', 'windrect', 'gate', 'window', 'modelsensor', 'speedStation', 'obfurage', 'sys'];
|
|
|
+
|
|
|
+export const normalizeDeviceType = (deviceType?: string | null): string => {
|
|
|
+ const raw = (deviceType || '').trim();
|
|
|
+ if (!raw) return '';
|
|
|
+ if (/^(location|vehicle|cheliang)/i.test(raw)) return raw;
|
|
|
+
|
|
|
+ const lower = raw.toLowerCase();
|
|
|
+ const exact = DEVICE_TYPE_PREFIXES.find((prefix) => prefix.toLowerCase() === lower);
|
|
|
+ if (exact) return exact;
|
|
|
+
|
|
|
+ const matched = DEVICE_TYPE_PREFIXES.find((prefix) => lower.startsWith(`${prefix.toLowerCase()}_`));
|
|
|
+ return matched || raw;
|
|
|
+};
|
|
|
+
|
|
|
/** 定位巷道:{ model_id, tunid, deviceType } */
|
|
|
export const locateTunnel = (payload: LocateTunnelPayload) => send({ from: SOURCE_BASE, type: 'locate-tunnel', payload });
|
|
|
|
|
|
/** 定位设备:{ model_id, deviceType, locationId } */
|
|
|
-export const locateDevice = (payload: LocateDevicePayload) => send({ from: SOURCE_BASE, type: 'locate-device', payload });
|
|
|
+export const locateDevice = (payload: LocateDevicePayload) =>
|
|
|
+ send({
|
|
|
+ from: SOURCE_BASE,
|
|
|
+ type: 'locate-device',
|
|
|
+ payload: { ...payload, deviceType: normalizeDeviceType(payload.deviceType) },
|
|
|
+ });
|
|
|
|
|
|
/** 定位设备报表(按安装位置名称):{ model_id, deviceType, locationName } */
|
|
|
-export const locateDeviceReport = (payload: LocateDeviceReportPayload) => send({ from: SOURCE_BASE, type: 'locate-device-report', payload });
|
|
|
+export const locateDeviceReport = (payload: LocateDeviceReportPayload) =>
|
|
|
+ send({
|
|
|
+ from: SOURCE_BASE,
|
|
|
+ type: 'locate-device-report',
|
|
|
+ payload: { ...payload, deviceType: normalizeDeviceType(payload.deviceType) },
|
|
|
+ });
|