
- 添加fast-xml-parser并删除xml-js的依赖关系 - 重构TaskQueue并将ChainQueue重命名为TaskQueue - 改进错误日志记录并添加parseOneTask中缺少applyer对象的错误处理 - 修改parseWxApprovalInfo方法以接受starter参数并将starter属性添加到ChainTaskClass中 - 使用TaskStatus.PASS来检查批准是否通过,并在XML中找到SpNo后将任务添加到队列中。
27 lines
668 B
TypeScript
27 lines
668 B
TypeScript
import { AsyncQueue, createAsyncQueue } from 'common/AsyncQueue'
|
|
import { singleton } from 'decorators/singleton'
|
|
import { BlockChain } from 'chain/BlockChain'
|
|
import logger from 'logger/logger'
|
|
import { TaskSvr } from 'service/task.service'
|
|
|
|
@singleton
|
|
export class TaskQueue {
|
|
private queue: AsyncQueue
|
|
private blockChain: BlockChain
|
|
|
|
constructor() {
|
|
this.queue = createAsyncQueue()
|
|
this.blockChain = new BlockChain()
|
|
}
|
|
|
|
public async addTaskToQueue(spNo: string) {
|
|
this.queue.push(async () => {
|
|
try {
|
|
await new TaskSvr().parseOneTask(spNo)
|
|
} catch (err) {
|
|
logger.error('error add task: ' + err)
|
|
}
|
|
})
|
|
}
|
|
}
|