sync数据的bug

This commit is contained in:
Xu Chang 2024-09-15 19:54:08 +08:00
parent e2d78d6083
commit c9a04611c5
3 changed files with 65 additions and 51 deletions

View File

@ -1948,23 +1948,26 @@ export default class TreeStore extends CascadeStore {
default: { default: {
const { e, d, f } = record; const { e, d, f } = record;
assert(d[UpdateAtAttribute], `获取的${e}对象数据没有update时间戳`); assert(d[UpdateAtAttribute], `获取的${e}对象数据没有update时间戳`);
if (!this.store[e]?.[d.id]) { // 只更新满足条件的行的更新时间戳比自己小的BM项目中出现过socket推送的状态先回的情况
this.updateAbjointRow(e, { const cur = this.selectAbjointRow(e, {
id: 'dummy', data: {
action: 'create', id: 1,
data: d, [UpdateAtAttribute]: 1,
}, context, option2); },
this.addToOperationResult(result, e, 'create'); filter: f,
} }, context, {});
else if (this.store[e][d.id].$current?.[UpdateAtAttribute] <= d[UpdateAtAttribute]) { const ids = cur.filter(row => row[UpdateAtAttribute] <= d[UpdateAtAttribute]).map(row => row.id);
this.updateAbjointRow(e, { this.updateAbjointRow(e, {
id: 'dummy', id: 'dummy',
action: 'update', action: 'update',
data: d, data: d,
filter: f, filter: {
}, context, option2); id: {
this.addToOperationResult(result, e, 'update'); $in: ids,
} }
},
}, context, option2);
this.addToOperationResult(result, e, 'update');
break; break;
} }
} }

View File

@ -1950,23 +1950,26 @@ class TreeStore extends CascadeStore_1.CascadeStore {
default: { default: {
const { e, d, f } = record; const { e, d, f } = record;
(0, assert_1.assert)(d[Entity_1.UpdateAtAttribute], `获取的${e}对象数据没有update时间戳`); (0, assert_1.assert)(d[Entity_1.UpdateAtAttribute], `获取的${e}对象数据没有update时间戳`);
if (!this.store[e]?.[d.id]) { // 只更新满足条件的行的更新时间戳比自己小的BM项目中出现过socket推送的状态先回的情况
this.updateAbjointRow(e, { const cur = this.selectAbjointRow(e, {
id: 'dummy', data: {
action: 'create', id: 1,
data: d, [Entity_1.UpdateAtAttribute]: 1,
}, context, option2); },
this.addToOperationResult(result, e, 'create'); filter: f,
} }, context, {});
else if (this.store[e][d.id].$current?.[Entity_1.UpdateAtAttribute] <= d[Entity_1.UpdateAtAttribute]) { const ids = cur.filter(row => row[Entity_1.UpdateAtAttribute] <= d[Entity_1.UpdateAtAttribute]).map(row => row.id);
this.updateAbjointRow(e, { this.updateAbjointRow(e, {
id: 'dummy', id: 'dummy',
action: 'update', action: 'update',
data: d, data: d,
filter: f, filter: {
}, context, option2); id: {
this.addToOperationResult(result, e, 'update'); $in: ids,
} }
},
}, context, option2);
this.addToOperationResult(result, e, 'update');
break; break;
} }
} }

View File

@ -2318,23 +2318,31 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
default: { default: {
const { e, d, f } = record as UpdateOpResult<ED, keyof ED>; const { e, d, f } = record as UpdateOpResult<ED, keyof ED>;
assert(d[UpdateAtAttribute], `获取的${e as string}对象数据没有update时间戳`); assert(d[UpdateAtAttribute], `获取的${e as string}对象数据没有update时间戳`);
if (!this.store[e]?.[d.id!]) {
this.updateAbjointRow(e, { // 只更新满足条件的行的更新时间戳比自己小的BM项目中出现过socket推送的状态先回的情况
id: 'dummy', const cur = this.selectAbjointRow(e, {
action: 'create', data: {
data: d, id: 1,
}, context, option2); [UpdateAtAttribute]: 1,
this.addToOperationResult(result, e, 'create'); },
} filter: f,
else if (this.store[e]![d.id].$current?.[UpdateAtAttribute] <= d[UpdateAtAttribute]) { }, context, {});
this.updateAbjointRow(e, { const ids = cur.filter(
id: 'dummy', row => row[UpdateAtAttribute] <= d[UpdateAtAttribute]
action: 'update', ).map(
data: d, row => row.id!
filter: f, );
}, context, option2); this.updateAbjointRow(e, {
this.addToOperationResult(result, e, 'update'); id: 'dummy',
} action: 'update',
data: d,
filter: {
id: {
$in: ids,
}
},
}, context, option2);
this.addToOperationResult(result, e, 'update');
break; break;
} }
} }