Commit 244570548406c6a5a0934bc2b2c29b5665b9152f
1 parent
b7a78283
fix: socket receive message the previous data is lost
Showing
2 changed files
with
12 additions
and
3 deletions
@@ -144,9 +144,11 @@ | @@ -144,9 +144,11 @@ | ||
144 | 144 | ||
145 | if (!hasDeviceAttr()) return; | 145 | if (!hasDeviceAttr()) return; |
146 | 146 | ||
147 | + const keys = props.attr ? props.attr : unref(deviceAttrs).join(); | ||
148 | + | ||
147 | const res = await getDeviceHistoryInfo({ | 149 | const res = await getDeviceHistoryInfo({ |
148 | entityId: props.deviceDetail.tbDeviceId, | 150 | entityId: props.deviceDetail.tbDeviceId, |
149 | - keys: unref(deviceAttrs).join(), | 151 | + keys, |
150 | startTs: Date.now() - 1 * 24 * 60 * 60 * 1000, | 152 | startTs: Date.now() - 1 * 24 * 60 * 60 * 1000, |
151 | endTs: Date.now(), | 153 | endTs: Date.now(), |
152 | agg: AggregateDataEnum.NONE, | 154 | agg: AggregateDataEnum.NONE, |
@@ -42,6 +42,7 @@ | @@ -42,6 +42,7 @@ | ||
42 | attr: undefined as string | undefined, | 42 | attr: undefined as string | undefined, |
43 | originData: [] as DataSource[], | 43 | originData: [] as DataSource[], |
44 | dataSource: [] as DataSource[], | 44 | dataSource: [] as DataSource[], |
45 | + message: {} as ReceiveMessage['data'], | ||
45 | sendValue: { | 46 | sendValue: { |
46 | tsSubCmds: [ | 47 | tsSubCmds: [ |
47 | { | 48 | { |
@@ -123,8 +124,14 @@ | @@ -123,8 +124,14 @@ | ||
123 | if (value) { | 124 | if (value) { |
124 | const { data } = value; | 125 | const { data } = value; |
125 | const keys = Object.keys(data); | 126 | const keys = Object.keys(data); |
126 | - socketInfo.originData = socketInfo.dataSource = keys.map((key) => { | ||
127 | - const [time, value] = data[key].at(0) || []; | 127 | + keys.forEach((key) => { |
128 | + socketInfo.message[key] = value.data[key]; | ||
129 | + }); | ||
130 | + | ||
131 | + const allKeys = Object.keys(socketInfo.message); | ||
132 | + | ||
133 | + socketInfo.originData = socketInfo.dataSource = allKeys.map((key) => { | ||
134 | + const [time, value] = socketInfo.message[key].at(0) || []; | ||
128 | return { key, value, time }; | 135 | return { key, value, time }; |
129 | }); | 136 | }); |
130 | 137 |