fix(订单通知): 启动后自动预热运行能力,避免重启阻断发送
- 服务重启会清空 liveTodo/pdfExport/automaticArchive 内存标记,此前需等下一笔订单完成归档才恢复,导致重启后的发送窗口整批被拦截 - 新增 OrderExecutionCoordinator.warmup:启动时读取一次真实待办并执行归档探测,重新点亮三项能力 - application 启动后异步调用,失败只记录日志,不阻塞服务 - 回归:执行集成、执行专测、守护 41 项通过
This commit is contained in:
1 parent
bf3840218d
commit
11a9ff8ca3
2 files changed
+15
-1
No files matched your search
@@ -113,6 +113,7 @@ async function main(options = {}) {
|
||||
health.start();
|
||||
orderExecution.start();
|
||||
orderDispatcher.start();
|
||||
orderExecution.warmup(custodian.principal).then(result=>{if(!result?.started)console.warn('运行能力预热未完成:'+(result?.error||'未知原因'));}).catch(error=>console.warn('运行能力预热失败:'+error.message));
|
||||
if(!options.quiet){
|
||||
console.log('订单通知中心已启动。\nWeb 工作台支持业务日历、异常待办与转交、BPM 连接管理。\n在 Chrome 订单页仍可点击扩展中的“导出当前订单”。');
|
||||
console.log(`首次使用:Chrome 扩展管理 → 开发者模式 → 加载已解压的扩展程序\n选择目录:${installedExtension}\n输出目录:${outputDir}\n本地服务:http://127.0.0.1:${port}`);
|
||||
|
||||
@@ -129,7 +129,20 @@ class OrderExecutionCoordinator{
|
||||
listFieldSamples(input,principal){return require('./field-samples.cjs').listFieldSamples(this,input,principal);}
|
||||
captureFieldSample(input,principal){return require('./field-samples.cjs').captureFieldSample(this,input,principal);}
|
||||
connection(id,principal){const c=this.workspace.getConnection(id);if(!principal?.sessionId||!['admin','operator'].includes(principal?.user?.role)||(principal.user.role!=='admin'&&c.owner!==principal.user.username))fail('仅连接负责人或管理员可以扫描或重试。',403);if(c.status==='disabled')fail('连接已停用。',409);return c;}
|
||||
async refreshCapabilities(rule){
|
||||
async warmup(principal){
|
||||
// Restart clears in-memory runtime capabilities; re-prove them before the next send window.
|
||||
if(this.stopped)return {started:false,error:'服务正在关闭'};
|
||||
let rule=null;
|
||||
try{rule=this.store.all('rules').map(record=>this.store.executionRule(record)).find(item=>item?.status==='enabled'&&item.archiveDirectory)||null;}catch{}
|
||||
let connection=null;
|
||||
try{connection=this.workspace.snapshot().connections.find(item=>item.status==='connected')||null;}catch{}
|
||||
if(connection&&typeof this.provider.scan==='function'){
|
||||
try{await this.provider.scan(connection,principal);}catch(error){this.blockers.push('启动预热待办扫描失败:'+error.message);}
|
||||
}
|
||||
if(!rule)return {started:false,error:'没有已启用且配置归档目录的规则'};
|
||||
try{await this.refreshCapabilities(rule);}catch(error){return {started:false,error:error.message};}
|
||||
return {started:true,ruleId:rule.id,connectionId:connection?.id||null};
|
||||
}async refreshCapabilities(rule){
|
||||
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);}
|
||||
|
||||
Reference in new issue
Block a user