import { Processor, ProcessorModule } from "../../src/device"; import { ErrorInfo } from "../../src/device"; /** 模块 检查异常板 * * input 入参 */ export const CheckBlocks: ProcessorModule = { moduleName: "CheckMaterial", moduleVersion: '20250714', config: { minBlockWidth: 0, minBlockThickness: 0, }, setConfig(config) { this.config = { ...this.config, ...config }; }, // 会在处理器自动执行 /** * * @param input 输入数据 * @param next 下一个流程的函数 * @param context 上下文 * @returns */ process(input, next, context) { const { materialList, blockList } = input const self = this; let checkArr = checkBlocks(materialList, blockList) if (checkArr.length > 0) { const _errinfo: ErrorInfo = { moduleName: this.moduleName, moduleVersion: this.moduleVersion, info: { data: checkArr, msg: '该订单内小板有异常' } } this.onError(_errinfo) } function checkBlocks(materialList, blockList): any[] { let allBlocks: any[] = [] for (let pm of materialList) { let bList = blockList.filter(e => e.goodsId == pm.goodsId) for (const pb of bList) { if (pb.width < self.minBlockWidth) { allBlocks.push(pb) } if (pb.thickness < self.minBlockThickness) { allBlocks.push(pb) } } } return allBlocks } return next ? next(input) : input; }, onError(error) { console.error('出错了哦', error); } };