78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
|
import { Processor, ProcessorModule } from "../../src/device";
|
||
|
|
||
|
import { ErrorInfo } from "../../src/device";
|
||
|
|
||
|
/** 模块 检查是否 板材尺寸大于机台尺寸
|
||
|
*
|
||
|
* input 入参
|
||
|
|
||
|
*/
|
||
|
|
||
|
/** 检查是否 板材尺寸大于机台尺寸 */
|
||
|
export const CheckMaterial: ProcessorModule<any, any> = {
|
||
|
moduleName: "CheckMaterial",
|
||
|
moduleVersion: '20250714',
|
||
|
config: {
|
||
|
boardWidth: 0,
|
||
|
boardLength: 0,
|
||
|
placeStyle:1,
|
||
|
},
|
||
|
setConfig(config) {
|
||
|
this.config = { ...this.config, ...config };
|
||
|
},
|
||
|
|
||
|
// 会在处理器自动执行
|
||
|
/**
|
||
|
*
|
||
|
* @param input 输入数据
|
||
|
* @param next 下一个流程的函数
|
||
|
* @param context 上下文
|
||
|
* @returns
|
||
|
*/
|
||
|
|
||
|
process(input, next, context) {
|
||
|
const { materialList } = input
|
||
|
const self = this;
|
||
|
let checkArr = checkMetrial(materialList)
|
||
|
if (checkArr.length > 0) {
|
||
|
const _errinfo: ErrorInfo = {
|
||
|
moduleName: this.moduleName,
|
||
|
moduleVersion: this.moduleVersion,
|
||
|
info: {
|
||
|
data: checkArr,
|
||
|
msg: '该订单内大板有异常'
|
||
|
}
|
||
|
}
|
||
|
this.onError(_errinfo)
|
||
|
}
|
||
|
|
||
|
function checkMetrial(materialList): any[] {
|
||
|
|
||
|
let errPMs: any = []
|
||
|
|
||
|
if (self.placeStyle !== 1) {
|
||
|
for (let pm of materialList) {
|
||
|
if (pm.orgWidth > self.boardWidth || pm.orgLength > self.boardLength) {
|
||
|
// console.log('板材尺寸大于机台尺寸', PlaceStore.sysConfig)
|
||
|
errPMs.push(pm)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return errPMs
|
||
|
}
|
||
|
|
||
|
return next ? next(input) : input;
|
||
|
},
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
onError(error) {
|
||
|
|
||
|
console.error('出错了哦', error);
|
||
|
|
||
|
}
|
||
|
};
|
||
|
|