fix: restore archived task progress and runtime gates after restart

This commit is contained in:
abaishu0730 committed 2026-10-19 13:49:33 +08:00
1 parent eb92a4f033
commit cc1ade2261
3 files changed
+102 -8

No files matched your search

+2 -1
View File
@@ -161,7 +161,7 @@ class RuleStore{
if(!grouped.has(order.categoryId))grouped.set(order.categoryId,[]);grouped.get(order.categoryId).push(order);
}
for(const orders of grouped.values()){
if(this.all('execution-tasks').some(task=>task.categoryIds?.includes(orders[0].categoryId)&&['blocked','failed','unknown','capturing','archiving'].includes(task.status)&&inWindow(task.row?.receivedAt,window)))continue;
if(this.all('execution-tasks').some(task=>task.categoryIds?.includes(orders[0].categoryId)&&(['blocked','failed','unknown','capturing','archiving'].includes(task.status)||task.runtimeCheck?.status==='blocked')&&inWindow(task.row?.receivedAt,window)))continue;
const rule=orders[0].ruleSnapshot;if(!rule)continue;
if(this.all('batches').some(b=>b.categoryId===rule.categoryId&&Date.parse(b.cutoff)===Date.parse(cutoff)&&!(b.status==='cancelled'&&b.resolution?.resolution==='retry')))continue;
const published=this.get('rules',rule.id)?.published;
@@ -182,6 +182,7 @@ class RuleStore{
const batch=this.get('batches',id);if(!batch)fail('批次不存在。',404);
if(!(manual&&batch.manual)&&this.get('rules',batch.ruleSnapshot.id)?.published?.status!=='enabled')fail('该类别规则已暂停,批次不能进入发送。',409);
const orders=batch.orderIds.map(oid=>this.get('orders',oid));
if(this.all('execution-tasks').some(task=>batch.orderIds.includes(task.orderId)&&task.runtimeCheck?.status==='blocked'))fail('已归档订单的运行条件复核未通过,批次不能进入发送。',409);
if(orders.some(o=>!o||o.batchId!==id||o.status!=='batched'))fail('批次订单预留已变化。',409);
batch.version=(batch.version||1)+1;batch.status=transition('batch',batch.status,'send');this.put('batches',batch);return batch;
});}