|
...
|
...
|
@@ -12,6 +12,7 @@ |
|
12
|
12
|
import { StructJSON } from '/@/api/device/model/modelOfMatterModel';
|
|
13
|
13
|
import { HistoryData } from '/@/api/alarm/position/model';
|
|
14
|
14
|
import { useJsonParse } from '/@/hooks/business/useJsonParse';
|
|
|
15
|
+ import { isObject, isString } from '/@/utils/is';
|
|
15
|
16
|
|
|
16
|
17
|
const emit = defineEmits(['register', 'ok']);
|
|
17
|
18
|
|
|
...
|
...
|
@@ -28,6 +29,14 @@ |
|
28
|
29
|
|
|
29
|
30
|
const getPositionRecord = computed<DataSource>(() => unref(dataSourceRef).at(0) as DataSource);
|
|
30
|
31
|
|
|
|
32
|
+ const getPositionIdentifier = computed(() => {
|
|
|
33
|
+ const { latitudeIdentifier, longitudeIdentifier } = unref(getPositionRecord);
|
|
|
34
|
+ return {
|
|
|
35
|
+ latitudeIdentifier,
|
|
|
36
|
+ longitudeIdentifier,
|
|
|
37
|
+ };
|
|
|
38
|
+ });
|
|
|
39
|
+
|
|
31
|
40
|
const { getDeviceProfileTslByIdWithIdentifier } = useDeviceProfileQueryContext();
|
|
32
|
41
|
|
|
33
|
42
|
const handleSetForm = async () => {
|
|
...
|
...
|
@@ -55,7 +64,7 @@ |
|
55
|
64
|
);
|
|
56
|
65
|
return {
|
|
57
|
66
|
label: `${detail.functionName} / ${structIdentifierDetail?.functionName}`,
|
|
58
|
|
- value: identifier,
|
|
|
67
|
+ value: `${identifier} / ${structIdentifierDetail?.identifier}`,
|
|
59
|
68
|
};
|
|
60
|
69
|
}
|
|
61
|
70
|
|
|
...
|
...
|
@@ -101,17 +110,15 @@ |
|
101
|
110
|
});
|
|
102
|
111
|
|
|
103
|
112
|
const getPositionDataSource = async (res: HistoryData) => {
|
|
104
|
|
- const keys = Object.keys(res);
|
|
105
|
113
|
const track: Record<'lng' | 'lat', number>[] = [];
|
|
106
|
|
-
|
|
107
|
114
|
const {
|
|
108
|
115
|
latitudeIdentifier = [],
|
|
109
|
116
|
longitudeIdentifier = [],
|
|
110
|
117
|
deviceProfileId,
|
|
111
|
118
|
} = unref(getPositionRecord);
|
|
112
|
119
|
|
|
113
|
|
- const [latIdentifier] = latitudeIdentifier || [];
|
|
114
|
|
- const [lngIdentifier] = longitudeIdentifier || [];
|
|
|
120
|
+ const [latIdentifier, structLatIdentifier] = latitudeIdentifier || [];
|
|
|
121
|
+ const [lngIdentifier, structLngIdentifier] = longitudeIdentifier || [];
|
|
115
|
122
|
|
|
116
|
123
|
if (!latIdentifier || !lngIdentifier) return track;
|
|
117
|
124
|
|
|
...
|
...
|
@@ -133,27 +140,34 @@ |
|
133
|
140
|
const { identifier } = detail || {};
|
|
134
|
141
|
|
|
135
|
142
|
if (detail?.specs?.dataType.type === DataTypeEnum.STRUCT) {
|
|
136
|
|
- const [, structIdentifier] = position;
|
|
137
|
143
|
res[identifier].forEach((temp) => {
|
|
138
|
|
- const structJSON = useJsonParse(temp.value).value;
|
|
139
|
|
- temp.value = structJSON?.[structIdentifier];
|
|
|
144
|
+ if (isString(temp.value)) {
|
|
|
145
|
+ temp.value = useJsonParse(temp.value).value;
|
|
|
146
|
+ }
|
|
140
|
147
|
});
|
|
141
|
148
|
}
|
|
142
|
149
|
}
|
|
143
|
150
|
|
|
144
|
151
|
for (const ts of timespanList) {
|
|
145
|
|
- const list: { ts: number; value: number }[] = [];
|
|
146
|
|
- for (const key of keys) {
|
|
147
|
|
- const record = res[key].find((item) => ts === item.ts);
|
|
148
|
|
- list.push(record as any);
|
|
149
|
|
- }
|
|
|
152
|
+ const latRecord = res[latIdentifier].find((item) => ts === item.ts);
|
|
|
153
|
+ const lngRecord = res[lngIdentifier].find((item) => ts === item.ts);
|
|
|
154
|
+
|
|
|
155
|
+ if (!latRecord || !lngRecord) continue;
|
|
|
156
|
+
|
|
|
157
|
+ const positionRecord = { lat: 0, lng: 0 };
|
|
|
158
|
+
|
|
|
159
|
+ positionRecord.lat =
|
|
|
160
|
+ structLatIdentifier && isObject(latRecord.value)
|
|
|
161
|
+ ? Reflect.get(latRecord.value as unknown as object, structLatIdentifier)
|
|
|
162
|
+ : latRecord.value;
|
|
|
163
|
+
|
|
|
164
|
+ positionRecord.lng =
|
|
|
165
|
+ structLngIdentifier && isObject(lngRecord.value)
|
|
|
166
|
+ ? Reflect.get(latRecord.value as unknown as object, structLngIdentifier)
|
|
|
167
|
+ : lngRecord.value;
|
|
150
|
168
|
|
|
151
|
|
- if (list.length === 2 && list.every(Boolean)) {
|
|
152
|
|
- let lng = list.at(0)?.value;
|
|
153
|
|
- let lat = list.at(1)?.value;
|
|
154
|
|
- if (lng && lat) {
|
|
155
|
|
- track.push({ lng: Number(lng), lat: Number(lat) });
|
|
156
|
|
- }
|
|
|
169
|
+ if (positionRecord.lat && positionRecord.lng) {
|
|
|
170
|
+ track.push({ lng: Number(positionRecord.lng), lat: Number(positionRecord.lat) });
|
|
157
|
171
|
}
|
|
158
|
172
|
}
|
|
159
|
173
|
|
|
...
|
...
|
@@ -171,7 +185,9 @@ |
|
171
|
185
|
|
|
172
|
186
|
const res = await getDeviceHistoryInfo({
|
|
173
|
187
|
...value,
|
|
174
|
|
- [SchemaFiled.KEYS]: value[SchemaFiled.KEYS].join(','),
|
|
|
188
|
+ [SchemaFiled.KEYS]: `${unref(getPositionIdentifier).latitudeIdentifier?.at(0)},${unref(
|
|
|
189
|
+ getPositionIdentifier
|
|
|
190
|
+ ).longitudeIdentifier?.at(0)}`,
|
|
175
|
191
|
});
|
|
176
|
192
|
|
|
177
|
193
|
const track = await getPositionDataSource(res);
|
...
|
...
|
|