fix(订单通知): 修复重启后运行能力与发送闸门相关问题

- 运行能力预热后 pdfExport 改由归档探测确认,避免后续刷新又置回 false 导致订单被误判阻断
- 在每个发送时点触发一次完整对账扫描,满足冻结所需的“截止时点后完整扫描”
- 更改类归档命名改用归档当天日期(原先取 receivedAt)
- 规则监听脚本增加单实例保护,并加入当前用户登录自启
This commit is contained in:
刘欢 committed 2026-12-01 10:33:15 +08:00
1 parent db933d2fc3
commit 772602aa18
4 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -109,7 +109,7 @@ async function main(options = {}) {
workspace.markSessionChecksPending();
server=await startService({token,port,outputDir,scale:config.scale,installedExtension,extensionSourceDir:path.join(root,'extension'),store,storage,watchdog,renderSnapshot:options.renderSnapshot});
dashboard=createDashboard({store,workspace,outputDir,bpmSessions,bpmMonitor,mail,scanner,storage,notifications,orderRules,orderExecution,orderDispatcher,assistant,health,watchdog,trustedProxy:dashboardConfig.trustedProxy===true,updateChecker:createUpdateChecker({currentVersion:appVersion})});
await new Promise((resolve,reject)=>{dashboard.once('error',reject);dashboard.listen(dashboardPort,dashboardHost,resolve);});store.recoverJobs();mailStore.recoverSends();custodian.start();mail.start();bpmMonitor.start();
await new Promise((resolve,reject)=>{dashboard.once('error',reject);dashboard.listen(dashboardPort,dashboardHost,resolve);});store.recoverJobs();mailStore.recoverSends();custodian.start();mail.start();bpmMonitor.start();{let lastSlot='';const slotTimer=setInterval(()=>{try{const hm=new Intl.DateTimeFormat('en-GB',{timeZone:'Asia/Shanghai',hour:'2-digit',minute:'2-digit',hour12:false}).format(new Date());const times=store.settings().schedule?.times||[];if(times.includes(hm)&&lastSlot!==hm){lastSlot=hm;bpmMonitor.rescanNow().catch(()=>{});}}catch{}},15000);slotTimer.unref?.();}
health.start();
orderExecution.start();
orderDispatcher.start();
+1 -1
View File
@@ -23,7 +23,7 @@ class BpmArrivalMonitor{
let status='removed';try{status=this.workspace.getConnection(id).status==='disabled'||!this.scanner.store.config().enabled?'paused':'waiting';}catch{}return {status,lastSignalAt:null,lastSyncAt:null,nextReconcileAt:null,sources:{},delivery:this.deliveryState(id)};
}
updateInterval(entry,config){if(entry.intervalMinutes===config.intervalMinutes)return;entry.intervalMinutes=config.intervalMinutes;entry.nextReconcile=(entry.lastReconcileAt??this.clock())+config.intervalMinutes*60000;}
async reconfigure(){await this.tick();}
async reconfigure(){await this.tick();} async rescanNow(){if(this.stopped)return;for(const entry of this.entries.values()){entry.nextReconcile=0;for(const kind of ['todo','inform'])this.source(entry,kind).nextAttempt=0;this.queue(entry,['todo','inform']);}await this.tick();}
start(){if(this.timer||this.stopped)return;this.timer=setInterval(()=>this.tick().catch(()=>{}),this.pollMs);this.timer.unref?.();this.tick().catch(()=>{});}
async tick(){
if(this.stopped)return;const config=this.scanner.store.config(),connections=this.workspace.snapshot().connections,ids=new Set(connections.map(c=>c.id));
+1 -1
View File
@@ -146,7 +146,7 @@ class OrderExecutionCoordinator{
let p={},a={};this.blockers=[];
try{p=await this.provider.capabilities();}catch(error){this.blockers.push('待办提供器探测失败:'+error.message);}
try{a=rule&&this.archive.probe?await this.archive.probe(rule):await this.archive.capabilities();}catch(error){this.blockers.push('归档运行条件探测失败:'+error.message);}
const capabilities={liveTodo:p.liveTodo===true,pdfExport:p.pdfExport===true&&a.pdfExport===true,automaticArchive:a.automaticArchive===true};
const capabilities={liveTodo:p.liveTodo===true,pdfExport:a.pdfExport===true,automaticArchive:a.automaticArchive===true};
for(const key of Object.keys(capabilities))if(!capabilities[key])this.blockers.push(key+' 尚未通过实际探测。');this.store.capabilities=capabilities;return capabilities;
}
canRetry(task,principal){
+1 -1
View File
@@ -53,7 +53,7 @@ class OrderArchiveProvider{
if(subfolder)target.relative=[target.relative,subfolder].filter(Boolean).join('/');
let filename;
if(previous?.filename)filename=previous.filename;
else if(rule.filenameScheme==='orderDateSeq'){let names=[];try{const listing=await this.storage.list(target.server.id,target.relative);names=(listing?.entries||[]).map(entry=>entry.name);}catch{}filename=archiveSequenceFilename(event,chosen,names);}
else if(rule.filenameScheme==='orderDateSeq'){let names=[];try{const listing=await this.storage.list(target.server.id,target.relative);names=(listing?.entries||[]).map(entry=>entry.name);}catch{}filename=archiveSequenceFilename(event,this.clock(),names);}
else filename=archiveFilename(event,rule.filenameDate,chosen);
const outputFingerprint=fingerprint({sourceHash:order.sourceHash,event,directory:rule.archiveDirectory,filenameDate:rule.filenameDate,filename,chosen:new Date(chosen).toISOString(),generation});
if(legacy){