npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mes-cli-otd-flex

v3.0.0

Published

MES CLI tool for AI-MES backend API

Downloads

477

Readme

MES CLI 工具

一个用于查询 MES 系统信息的命令行工具。

功能特性

  • 查询车间列表
  • 查询产线列表
  • 查询线体生产排程工单
  • 查询工单详情
  • 查询工单WIP信息
  • 支持多环境配置(开发/生产)
  • 支持自定义服务器地址配置
  • 支持表格和 JSON 两种输出格式
  • 灵活的筛选条件

环境要求

  • Node.js >= 14.x

打包

# 进入项目目录
cd mes-cli

# 安装依赖
npm install

# 打包成 tarball
npm pack

打包后会生成类似 mes-cli-版本号.tgz 的文件。

安装

方法一:使用打包文件安装

# 安装本地打包文件
npm install -g ./mes-cli-版本号.tgz

方法二:开发模式安装

# 进入项目目录
cd mes-cli

# 全局链接
npm link

方法三:从 npm 仓库安装(如已发布)

npm install -g mes-cli

命令结构

mes [options] <command> [command-options]

全局选项

| 选项 | 说明 | 默认值 | |------|------|--------| | --env <env> | 环境选择:dev 或 prod | prod | | --api-url <url> | 自定义 API URL(优先级最高) | - | | -V, --version | 显示版本号 | - | | -h, --help | 显示帮助信息 | - |

命令列表

config - 配置管理

mes config <subcommand>

config set - 设置服务器地址

mes config set <url>

设置默认的 API 服务器地址,配置文件保存在用户主目录下的 .mesrc 文件中。

config get - 查看当前配置

mes config get

显示当前配置的服务器地址和更新时间。

config reset - 重置配置

mes config reset

删除配置文件,恢复默认设置。

query workshop - 查询车间列表

mes query workshop [options]

| 选项 | 说明 | |------|------| | --plantKeyword <keyword> | 工厂代码或名称筛选 | | --workShopKeyword <keyword> | 车间代码或名称筛选 | | --json | 输出 JSON 格式 |

query line - 查询产线列表

mes query line [options]

| 选项 | 说明 | |------|------| | --workShopKeyword <keyword> | 车间代码或名称筛选 | | --lineKeyword <keyword> | 线体ID或名称筛选 | | --lineIdList <ids> | 线体ID列表(逗号分隔) | | --json | 输出 JSON 格式 |

query line-scheduling-wo - 查询线体生产排程工单

mes query line-scheduling-wo [options]

| 选项 | 说明 | |------|------| | --workShopKeyword <keyword> | 车间代码或名称筛选 | | --lineKeyword <keyword> | 线体ID或名称筛选 | | --lineIdList <ids> | 线体ID列表(逗号分隔) | | --includeClosed | 包含已关闭工单 | | --json | 输出 JSON 格式 |

query wo detail - 查询工单详情

mes query wo detail [options]

| 选项 | 说明 | |------|------| | --workOrderNo <no> | 工单编号(可多次使用) | | --workOrderNoList <nos> | 工单编号列表(逗号分隔,需用引号包裹) | | --json | 输出 JSON 格式 |

query wo wip - 查询工单WIP信息

mes query wo wip [options]

| 选项 | 说明 | |------|------| | --workOrderNo <no> | 工单编号 | | --json | 输出 JSON 格式 |

使用示例

# 安装后设置服务器地址
mes config set http://customer-server:8080

# 查看当前配置
mes config get

# 查询车间列表
mes query workshop

# 查询车间列表(带筛选条件)
mes query workshop --workShopKeyword=车间

# 查询产线列表
mes query line

# 查询指定车间的产线
mes query line --workShopKeyword=WS01

# 查询线体生产排程工单
mes query line-scheduling-wo

# 查询线体生产排程工单(包含已关闭)
mes query line-scheduling-wo --includeClosed

# 查询工单详情
mes query wo detail --workOrderNo=WO20260414001

# 查询多个工单详情
mes query wo detail --workOrderNo=WO001 --workOrderNo=WO002
mes query wo detail --workOrderNoList="WO001,WO002,WO003"

# 查询工单WIP信息
mes query wo wip --workOrderNo=WO20260414001

# 使用开发环境(临时覆盖配置)
mes --env dev query workshop

# 使用自定义API地址(临时覆盖配置)
mes --api-url http://custom-server:8080 query workshop

# JSON 格式输出
mes query workshop --json

服务器地址优先级

当多个配置方式同时存在时,优先级从高到低为:

  1. 命令行参数 --api-url
  2. 环境变量 MES_API_URL
  3. 配置文件(通过 mes config set 设置)
  4. 命令行参数 --env(dev/prod)
  5. 默认生产环境地址

环境配置

方式一:配置文件(推荐)

# 设置服务器地址
mes config set http://customer-server:8080

# 后续所有命令都会使用该地址
mes query workshop

方式二:命令行参数

# 临时使用指定地址
mes --api-url http://customer-server:8080 query workshop

# 使用预设环境
mes --env dev query workshop
mes --env prod query workshop

方式三:环境变量

# Linux/Mac
export MES_API_URL=http://customer-server:8080

# Windows PowerShell
$env:MES_API_URL = "http://customer-server:8080"

mes query workshop

环境地址

| 环境 | API 地址 | |------|----------| | dev | http://localhost:5011 | | prod | http://flex.otdmes.com.cn:60064 |

输出格式

表格格式(默认)

workshop 命令输出

=== Work Shop List ===
WS01      | 装配车间
WS02      | 焊接车间

line 命令输出

=== Line List ===
L001      | SMT-01         | SMT       | WS01      | MO123
L002      | SMT-02         | SMT       | WS01      | MO456

wo wip 命令输出

=== Work Order WIP Information ===
Result: OK (200)
P001           | WIP:100
P002           | WIP:50

wo detail 命令输出

=== Work Order Information ===
Result: OK (200)
WO20260414001   | PRD001         | Qty:1000   | Output:800     | Complete:80.00%

JSON 格式

{
  "result": "OK",
  "resultCode": "200",
  "resultMsg": "",
  "list": [...]
}

配置文件位置

配置文件保存在用户主目录下:

  • Linux/Mac: ~/.mesrc
  • Windows: %USERPROFILE%\.mesrc

配置文件格式:

{
  "apiUrl": "http://customer-server:8080",
  "updatedAt": "2026-04-14T10:30:00.000Z"
}

卸载

npm uninstall -g mes-cli

完全卸载

如果需要完全清理所有相关文件(包括配置文件),可以执行以下命令:

# 卸载 CLI 工具
npm uninstall -g mes-cli

# Linux/Mac - 删除配置文件
rm ~/.mesrc

# Windows PowerShell - 删除配置文件
Remove-Item $env:USERPROFILE\.mesrc

卸载后验证

# 验证是否已卸载
mes --version
# 输出: 'mes' 不是内部或外部命令,也不是可运行的程序或批处理文件。

技术栈

  • Node.js
  • Commander.js - CLI 框架
  • Axios - HTTP 客户端

开发

# 安装依赖
npm install

# 运行
node index.js query workshop

# 开发模式链接
npm link

许可证

ISC