2026-08-28 15:06:01 +08:00
|
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
2026-10-14 17:24:59 +08:00
|
|
|
|
"bj_power_workstation/internal/tightening"
|
|
|
|
|
|
|
2026-08-28 15:06:01 +08:00
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// AuthConfig JWT 登录鉴权配置
|
|
|
|
|
|
// go-zero conf 仅识别 json 标签(yaml/toml 统一转为 JSON 后按此映射)
|
|
|
|
|
|
type AuthConfig struct {
|
|
|
|
|
|
AccessSecret string `json:",default=Hardman_2026"`
|
|
|
|
|
|
AccessExpire int64 `json:",default=1800"` // 有效期(秒)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MesConfig MES 服务地址(内部 API)
|
|
|
|
|
|
type MesConfig struct {
|
|
|
|
|
|
BaseURL string `json:",default=http://127.0.0.1:8888"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// InternalConfig 项目间内部 API 写死 token(请求头 X-API-TOKEN)
|
|
|
|
|
|
type InternalConfig struct {
|
|
|
|
|
|
Token string `json:",default=Hardman_2026"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SqliteConfig 本地 SQLite 缓存库
|
|
|
|
|
|
type SqliteConfig struct {
|
|
|
|
|
|
Path string `json:",default=workstation.db"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 16:59:15 +08:00
|
|
|
|
// StationConfig 工位配置:启动时由 yaml 加载到内存,固定本终端工位号。
|
2026-11-09 18:58:47 +08:00
|
|
|
|
// 2026-11-09 拍板(用户):StationNo>0=固定工位(登录页不允许选择);<=0=未配置(登录页
|
|
|
|
|
|
// 可选工位,实体+虚拟 0/13 都可选)。默认接驳台 Dock 配置已删除:叫料期望接驳台由工人
|
|
|
|
|
|
// 当次可选(可空,留空=配送时库房定),不再有终端级固定接驳台。
|
2026-08-28 15:06:01 +08:00
|
|
|
|
type StationConfig struct {
|
2026-11-09 18:58:47 +08:00
|
|
|
|
StationNo int `json:",default=0"` // >0=固定工位号;0=未配置(登录页选择工位,可含虚拟工位);启动时校验 >=0
|
2026-10-06 19:36:22 +08:00
|
|
|
|
// 核实4:空闲无操作自动登出阈值(秒)。超时清登录态并失效 Bearer 凭证,
|
|
|
|
|
|
// 强制下一班/换班操作工重新登录,避免共享终端身份错位(张三未登出、李四直接用)。
|
|
|
|
|
|
// 应小于登录 JWT 有效期(AccessExpire),才能真正先于令牌过期拦截"忘了登出"的场景。
|
|
|
|
|
|
IdleLogoutSeconds int64 `json:",default=900"`
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PdfCacheConfig 工艺文件 PDF 本地预缓存目录
|
|
|
|
|
|
type PdfCacheConfig struct {
|
|
|
|
|
|
Dir string `json:",default=pdf_cache"` // 本地缓存目录;留空关闭缓存
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-14 17:24:59 +08:00
|
|
|
|
// ScannerConfig 扫码中间件(键盘 HID 注入)开关配置。
|
|
|
|
|
|
// 启用后终端启动时监听 7757,接收网络型扫码枪(iData PAD / 新大陆手机)推送,
|
|
|
|
|
|
// 解析后模拟键盘注入当前光标窗口(任意输入框自动填入,前端无需轮询)。Enable=false 时不监听。
|
|
|
|
|
|
type ScannerConfig struct {
|
2026-11-09 18:58:47 +08:00
|
|
|
|
Enabled bool `json:",default=true"`
|
|
|
|
|
|
Addrs []string `json:",optional"` // 监听地址列表;默认 [":7757"],可配置备用端口在同机被占用时自动降级
|
2026-10-14 17:24:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TighteningConfig 拧紧枪控制器(阿特拉斯 Open Protocol)连接配置。
|
|
|
|
|
|
// Enable=false 时终端不走 OP 自动接收,仍由人工在界面录入扭矩值(兼容无控制器/调试环境)。
|
|
|
|
|
|
// 类型定义见 internal/tightening.TighteningConfig(config 直接复用,避免重复定义)。
|
|
|
|
|
|
|
2026-08-28 15:06:01 +08:00
|
|
|
|
type Config struct {
|
|
|
|
|
|
rest.RestConf
|
|
|
|
|
|
Auth AuthConfig `json:",optional"`
|
|
|
|
|
|
Mes MesConfig `json:",optional"`
|
|
|
|
|
|
Internal InternalConfig `json:",optional"`
|
|
|
|
|
|
Sqlite SqliteConfig `json:",optional"`
|
|
|
|
|
|
Station StationConfig `json:",optional"`
|
|
|
|
|
|
PdfCache PdfCacheConfig `json:",optional"`
|
2026-10-14 17:24:59 +08:00
|
|
|
|
Tightening tightening.TighteningConfig `json:",optional"`
|
|
|
|
|
|
Scanner ScannerConfig `json:",optional"`
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|