Compare commits
No commits in common. "main" and "0.1" have entirely different histories.
25
README.md
25
README.md
@ -1,25 +0,0 @@
|
|||||||
## 生产接口协议
|
|
||||||
本项目使用typescript编写,IDE推荐使用vscode。
|
|
||||||
|
|
||||||
### 术语表
|
|
||||||
| 中文 | CAD | MES | IMES | 备注 |
|
|
||||||
| --- | --- | --- | --- | --- |
|
|
||||||
| 房名 | RoomName | roomName | roomName | |
|
|
||||||
| 柜名 | CabinetName | boxName | bodyName | |
|
|
||||||
| 小板名 | BoardName | blockName | blockName | |
|
|
||||||
| 材质 | Material | material | material | |
|
|
||||||
| 大板名 | 无 | boardName | goodsName | |
|
|
||||||
| 余料 | 无 | scrap | remain | |
|
|
||||||
| 排单 | 无 | planOrder |planOrder | |
|
|
||||||
|
|
||||||
|
|
||||||
### 编译与发布
|
|
||||||
更新 package.json 版本号
|
|
||||||
```shell
|
|
||||||
pnpm clean
|
|
||||||
pnpm build
|
|
||||||
pnpm release
|
|
||||||
```
|
|
||||||
|
|
||||||
### 开发建议
|
|
||||||
MES与IMES存在不少命名上的差异,可以考虑 接口类型独立, 参数与配置单独创建类型
|
|
@ -1,13 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "cut-abstractions",
|
"name": "cut-abstractions",
|
||||||
"version": "0.1.4",
|
"version": "0.1.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"main": "index.ts",
|
||||||
"files": ["dist/**/*"],
|
"files": ["dist/**/*"],
|
||||||
"main":"./dist/index.js",
|
|
||||||
"module": "./dist/index.js",
|
|
||||||
"types": "./dist/index.d.js",
|
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/index.js"
|
".": "./dist/**/*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
38
src/base.ts
38
src/base.ts
@ -1,29 +1,15 @@
|
|||||||
import { ConfigBase } from "./models/config";
|
export class ConfigBase {
|
||||||
|
name: string = '';
|
||||||
|
version:string = '1.0.0';
|
||||||
/**
|
enable:boolean = true;
|
||||||
* 加工处理器上下文
|
[key: string]: any;
|
||||||
*/
|
|
||||||
export abstract class ProcessorContext<TInput,TOutput,TConfig extends ConfigBase>{
|
|
||||||
/**
|
|
||||||
* 输入数据
|
|
||||||
*/
|
|
||||||
public Input?:TInput;
|
|
||||||
/**
|
|
||||||
* 合并配置文件与临时输入参
|
|
||||||
*/
|
|
||||||
public params?:TConfig;
|
|
||||||
/**
|
|
||||||
* 输出数据
|
|
||||||
*/
|
|
||||||
public Ouput?:TOutput;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export interface FileOptions {
|
||||||
* 处理器基类
|
encode?: string;
|
||||||
*/
|
addBOM?: boolean;
|
||||||
export abstract class ProcessorBase<TInput,TOutput,TConfig extends ConfigBase> {
|
}
|
||||||
public readonly name: string = '';
|
export interface FileInfo extends FileOptions {
|
||||||
public readonly version: string = '1.0.0';
|
name: string,
|
||||||
public abstract exec(context:ProcessorContext<TInput,TOutput,TConfig>):Promise<void>|void
|
content: string | Blob | Uint8Array,
|
||||||
}
|
}
|
@ -1,4 +0,0 @@
|
|||||||
export * from './base';
|
|
||||||
export * from './parsers';
|
|
||||||
export * from './models/config';
|
|
||||||
export * from './models/file';
|
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* 配置基类,下划线开头的变量不会被序列化
|
|
||||||
*/
|
|
||||||
export class ConfigBase {
|
|
||||||
name: string = '';
|
|
||||||
version:string = '1.0.0';
|
|
||||||
[key: string]: any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加载反序列化数据
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
load(data:Record<string,unknown>){
|
|
||||||
for (const key of Object.getOwnPropertyNames(this).filter(i=>i[0]!=='_')) {
|
|
||||||
if(data[key]!=undefined){
|
|
||||||
this[key] = data[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 序列化json方法
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
toJson(){
|
|
||||||
return JSON.stringify(this,(k,v)=>k[0]=='_'?undefined:v);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
export interface FileOptions {
|
|
||||||
encode?: string;
|
|
||||||
addBOM?: boolean;
|
|
||||||
}
|
|
||||||
export interface FileInfo extends FileOptions {
|
|
||||||
name: string,
|
|
||||||
content: string | Blob | Uint8Array,
|
|
||||||
}
|
|
@ -1,48 +1,7 @@
|
|||||||
import { ProcessorBase } from "./base";
|
export abstract class ProcessorBase {
|
||||||
import { ConfigBase } from "./models/config";
|
public readonly name: string = '';
|
||||||
import { FileInfo } from "./models/file";
|
public readonly version: string = '1.0.0';
|
||||||
|
public abstract exec(...args: any[]): any
|
||||||
// todo: 类型参数待补完
|
|
||||||
|
|
||||||
export class BlockInfo{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class BlockProcessorConfig extends ConfigBase{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户板材数据过滤与转换
|
|
||||||
*/
|
|
||||||
export abstract class BlockProcessor extends ProcessorBase<BlockInfo[],BlockInfo[],BlockProcessorConfig>{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class LayoutInput {
|
|
||||||
|
|
||||||
}
|
|
||||||
export class LayoutOutput{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class LyaoutProcessorConfig extends ConfigBase{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class LayoutProcessor extends ProcessorBase<LayoutInput,LayoutOutput,LyaoutProcessorConfig>{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ExporterInput{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ExporterProcessorConfig extends ConfigBase{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class ExporterProcessor extends ProcessorBase<ExporterInput,FileInfo,ExporterProcessorConfig>{
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules","samples","tests"],
|
"exclude": ["samples","tests"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user