@steedos-labs/plugin-workflow 3.0.96 → 3.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1676,8 +1676,23 @@ UUFlowManager.workflow_engine = async function (approve_from_client, current_use
|
|
|
1676
1676
|
const t8 = Date.now();
|
|
1677
1677
|
// Update instance
|
|
1678
1678
|
const t8_1 = Date.now();
|
|
1679
|
+
// 当步骤发生流转时,current_step_name 的变更必须经由 objectql 写入,
|
|
1680
|
+
// 以触发 instances 的 afterUpdate(uuflowManager.triggerRecordInstanceQueue),
|
|
1681
|
+
// 否则 instance_record_queue 不会生成同步记录。
|
|
1682
|
+
// 这里先把 current_step_name 从原子 raw 写入中剥离(保留 $push traces 等原子性),
|
|
1683
|
+
// raw 写入后 DB 仍保留旧的 current_step_name,再由 objectql 单独应用新步骤名,
|
|
1684
|
+
// 使 afterUpdate 检测到 current_step_name 变化并触发同步。
|
|
1685
|
+
const nextStepNameForQueue = updateObj.$set ? updateObj.$set.current_step_name : undefined;
|
|
1686
|
+
const prevStepNameForQueue = updatedInstance.current_step_name;
|
|
1687
|
+
const stepNameChangedForQueue = nextStepNameForQueue !== undefined && nextStepNameForQueue !== prevStepNameForQueue;
|
|
1688
|
+
if (stepNameChangedForQueue) {
|
|
1689
|
+
delete updateObj.$set.current_step_name;
|
|
1690
|
+
}
|
|
1679
1691
|
const instancesCollection = await getCollection('instances');
|
|
1680
1692
|
await instancesCollection.updateOne({ _id: instance_id }, updateObj);
|
|
1693
|
+
if (stepNameChangedForQueue) {
|
|
1694
|
+
await getObject('instances').update(instance_id, { current_step_name: nextStepNameForQueue });
|
|
1695
|
+
}
|
|
1681
1696
|
console.log(`[workflow/engine] [workflow_engine] second updateOne took ${Date.now() - t8_1}ms`);
|
|
1682
1697
|
|
|
1683
1698
|
// Insert new instance tasks if needed
|