feat:提交

This commit is contained in:
2025-07-30 17:59:40 +08:00
commit 60f31b9299
16 changed files with 1995 additions and 0 deletions

8
src/index.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* @package @mes-processors/libs
* @author LX
* @description 工作流处理器类库,在这个文件中使用导出时,不要在路径中使用'@',否则模块无法加载
*/
// CutOrder
export * from "./processors/cutOrder/CutOrder";

2
src/modules/README.md Normal file
View File

@@ -0,0 +1,2 @@
### react-layout
矩形优化算法(陈总新优化)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
import { ProcessorBase, ProcessorContext, CutOrderInput, CutorderOutput, CutorderConfig } from "cut-abstractions";
import { KLSC, YH_bang } from "../../modules/cutOrder/KLSCclass";
/**
* 开料顺序 --新算法
*/
export class CutOrderProc extends ProcessorBase<CutOrderInput, CutorderOutput, CutorderConfig> {
get name(): string {
return 'imes-cutOrder';
}
get version(): string {
return '1.0.0';
}
exec(context: ProcessorContext<CutOrderInput, CutorderOutput, CutorderConfig>): Promise<void> | void {
return new Promise(async (resolve, reject) => {
try {
/** 验证入参 */
let check = this.checkInput(context?.input)
if (check.isOk == false) {
reject(check.msg)
return
} else {
let bangs: YH_bang[] = []
let blocks = new Array()
let length = context.input?.blocks.length || 0
let beginId = 0;
let dt = context.input?.gap || 6;
let k = context.input?.boardWidth || 0;
let g = context.input?.boardHeight || 0;
for (let i = 0; i < length; i++) {
let block = context.input?.blocks[i];
let bangid = i + 1;
let x = block?.x;
let y = block?.y;
let pbg = block?.length;
let pbk = block?.width;
blocks[bangid] = block;
if (x == undefined) {
reject(`block ${block?.id} x is undefined`)
return
} else if (y == undefined) {
reject(`block ${block?.id} y is undefined`)
return
}
else if (pbg == undefined) {
reject(`block ${block?.id} pbg is undefined`)
return
} else if (pbk == undefined) {
reject(`block ${block?.id} pbk is undefined`)
return
}
bangs.push({
bangid,
line: 0,
pbg,
pbk,
x,
y,
ishb: false,
hb: [],
isbig: false,
isqg: false,
isgr: false,
gr: [],
grid: -1
});
}
let xdsc = new KLSC(bangs, k, g, dt, 0, 0, 1);
let rt = xdsc.SCid;
if (rt.length < length) {
reject('开料顺序算法异常,计算结果与板件数不匹配。')
return
};
for (let i = 0; i < rt.length; i++) {
let bid = rt[i];
beginId++;
blocks[bid].cutOrder = beginId;
}
context.output = {
blocks
}
}
resolve()
} catch (error) {
reject(error);
}
});
}
private checkInput(input?: CutOrderInput) {
let info: any = {
isOk: true,
msg: ''
}
if (input == undefined) {
info.isOk = false
info.msg = 'context.input is undefind'
} else if (input.blocks == undefined) {
info.isOk = false
info.msg = 'context.input.blocks is undefind'
} else if (input.gap == undefined) {
info.isOk = false
info.msg = 'context.input.gap is undefind'
} else if (input.boardWidth == undefined) {
info.isOk = false
info.msg = 'context.input.boardWidth is undefind'
} else if (input.boardHeight == undefined) {
info.isOk = false
info.msg = 'context.input.boardHeight is undefind'
}
return info
}
}

View File

@@ -0,0 +1,61 @@
import { test } from 'vitest'
import { CutOrderProc } from './CutOrder';
import { CutorderConfig, CutOrderInput, CutorderInputBlock } from 'cut-abstractions';
test('cutOrderTest', async () => {
let cutOrderProc = new CutOrderProc()
let params: CutorderConfig = new CutorderConfig()
let blocks: CutorderInputBlock[] = [
{
id: 25030882560,
length: 598,
width: 398,
x: 3.005,
y: 4,
},
{
id: 25030882561,
length: 598,
width: 398,
x: 3.005,
y: 610,
},
{
id: 25030882562,
length: 598,
width: 398,
x: 3.005,
y: 1216,
},
{
id: 25030882563,
length: 598,
width: 398,
x: 3.005,
y: 1821.005,
},
{
id: 25030882564,
length: 598,
width: 398,
x: 407.015,
y: 3.005,
},
]
let input: CutOrderInput = {
boardWidth: 1220,
boardHeight: 2440,
gap: 6,
blocks
}
const context = {
input,
params
}
await cutOrderProc.exec(context)
// 将在context的output中显示结果
console.log(context);
})

View File

1
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />