Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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",
|
"name": "cut-abstractions",
|
||||||
"version": "0.1.1",
|
"version": "0.1.4",
|
||||||
"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/**/*"
|
".": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
38
src/base.ts
38
src/base.ts
@ -1,15 +1,29 @@
|
|||||||
export class ConfigBase {
|
import { ConfigBase } from "./models/config";
|
||||||
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> {
|
||||||
export interface FileInfo extends FileOptions {
|
public readonly name: string = '';
|
||||||
name: string,
|
public readonly version: string = '1.0.0';
|
||||||
content: string | Blob | Uint8Array,
|
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 {
|
import { ProcessorBase } from "./base";
|
||||||
public readonly name: string = '';
|
import { ConfigBase } from "./models/config";
|
||||||
public readonly version: string = '1.0.0';
|
import { FileInfo } from "./models/file";
|
||||||
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": ["samples","tests"],
|
"exclude": ["node_modules","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