Compare commits
	
		
			10 Commits
		
	
	
		
			0.1
			...
			d9a3368185
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					d9a3368185 | ||
| 
						 | 
					2105c4b656 | ||
| 
						 | 
					1adee71c7a | ||
| 
						 | 
					92b49c7035 | ||
| 
						 | 
					fd68920e01 | ||
| 
						 | 
					1954f8d612 | ||
| 
						 | 
					4473a9af41 | ||
| 
						 | 
					d73c260fb8 | ||
| 
						 | 
					79c3284ced | ||
| 
						 | 
					c43224ed4a | 
							
								
								
									
										25
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								README.md
									
									
									
									
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
## 生产接口协议 
 | 
			
		||||
本项目使用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,11 +1,13 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cut-abstractions",
 | 
			
		||||
  "version": "0.1.1",
 | 
			
		||||
  "version": "0.1.5",
 | 
			
		||||
  "description": "",
 | 
			
		||||
  "main": "index.ts",
 | 
			
		||||
  "files": ["dist/**/*"],
 | 
			
		||||
  "main":"./dist/index.js",
 | 
			
		||||
  "module": "./dist/index.js",
 | 
			
		||||
  "types": "./dist/index.d.js",
 | 
			
		||||
  "exports": {
 | 
			
		||||
    ".": "./dist/**/*"
 | 
			
		||||
    ".": "./dist/index.js"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "tsc",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								src/base.ts
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								src/base.ts
									
									
									
									
									
								
							@@ -1,15 +1,29 @@
 | 
			
		||||
export class ConfigBase {
 | 
			
		||||
    name: string = '';
 | 
			
		||||
    version:string = '1.0.0';
 | 
			
		||||
    enable:boolean = true;
 | 
			
		||||
    [key: string]: any;
 | 
			
		||||
import { ConfigBase } from "./models/config";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 加工处理器上下文
 | 
			
		||||
 */
 | 
			
		||||
export abstract class ProcessorContext<TInput,TOutput,TConfig extends ConfigBase>{
 | 
			
		||||
    /**
 | 
			
		||||
     * 输入数据
 | 
			
		||||
     */
 | 
			
		||||
    public input?:TInput;
 | 
			
		||||
    /**
 | 
			
		||||
     * 合并配置文件与临时输入参
 | 
			
		||||
     */
 | 
			
		||||
    public params?:TConfig;
 | 
			
		||||
    /**
 | 
			
		||||
     * 输出数据
 | 
			
		||||
     */
 | 
			
		||||
    public output?:TOutput;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface FileOptions {
 | 
			
		||||
    encode?: string;
 | 
			
		||||
    addBOM?: boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface FileInfo extends FileOptions {
 | 
			
		||||
    name: string,
 | 
			
		||||
    content: string | Blob | Uint8Array,
 | 
			
		||||
/**
 | 
			
		||||
 * 处理器基类
 | 
			
		||||
 */
 | 
			
		||||
export abstract class ProcessorBase<TInput,TOutput,TConfig extends ConfigBase> {
 | 
			
		||||
    public abstract get name():string;
 | 
			
		||||
    public abstract get version(): string;
 | 
			
		||||
    public abstract exec(context:ProcessorContext<TInput,TOutput,TConfig>):Promise<void>|void
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								src/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
export * from './base';
 | 
			
		||||
export * from './parsers';
 | 
			
		||||
export * from './models/config';
 | 
			
		||||
export * from './models/file';
 | 
			
		||||
							
								
								
									
										28
									
								
								src/models/config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/models/config.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 配置基类,下划线开头的变量不会被序列化
 | 
			
		||||
 */
 | 
			
		||||
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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								src/models/file.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/models/file.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
export interface FileOptions {
 | 
			
		||||
    encode?: string;
 | 
			
		||||
    addBOM?: boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface FileInfo extends FileOptions {
 | 
			
		||||
    name: string,
 | 
			
		||||
    content: string | Blob | Uint8Array,
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,48 @@
 | 
			
		||||
export abstract class ProcessorBase {
 | 
			
		||||
    public readonly name: string = '';
 | 
			
		||||
    public readonly version: string = '1.0.0';
 | 
			
		||||
    public abstract exec(...args: any[]): any
 | 
			
		||||
import { ProcessorBase } from "./base";
 | 
			
		||||
import { ConfigBase } from "./models/config";
 | 
			
		||||
import { FileInfo } from "./models/file";
 | 
			
		||||
 | 
			
		||||
// 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"],
 | 
			
		||||
  "exclude": ["samples","tests"],
 | 
			
		||||
  "exclude": ["node_modules","samples","tests"],
 | 
			
		||||
  "compilerOptions": {
 | 
			
		||||
    /* Visit https://aka.ms/tsconfig to read more about this file */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user