2026-08-28 15:06:01 +08:00
|
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"bj_power_mes/common/logx"
|
|
|
|
|
|
"bj_power_mes/internal/db"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/redis"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Config 全局配置
|
|
|
|
|
|
type Config struct {
|
2026-08-28 17:03:03 +08:00
|
|
|
|
rest.RestConf // 自带 Host/Port 等
|
|
|
|
|
|
Database db.DatabaseConf
|
|
|
|
|
|
Redis RedisConfWrapper
|
|
|
|
|
|
Auth AuthConf
|
|
|
|
|
|
Internal InternalConf
|
|
|
|
|
|
Cli CliConf
|
|
|
|
|
|
Logger logx.LogConf
|
|
|
|
|
|
Wms WmsConf
|
|
|
|
|
|
Plc PlcConf
|
2026-10-14 17:24:59 +08:00
|
|
|
|
Agv AgvConf
|
2026-08-31 08:06:55 +08:00
|
|
|
|
Upload UploadConf
|
2026-10-14 17:24:59 +08:00
|
|
|
|
Scanner ScannerConf
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ScannerConf 扫码中间件(键盘 HID 注入)开关配置。
|
|
|
|
|
|
// 默认关闭;需用时在 yaml 设 Enabled: true 并重启。若 MES 与 WMS 同机且都开,7757 谁先启动谁监听,后到的只记日志。
|
|
|
|
|
|
type ScannerConf struct {
|
|
|
|
|
|
Enabled bool `json:",default=false"`
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type RedisConfWrapper struct {
|
|
|
|
|
|
redis.RedisConf
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AuthConf 鉴权配置:JWT Secret / 有效期
|
2026-09-10 16:59:15 +08:00
|
|
|
|
// 只保留滑动续签:AccessExpire = 会话闲置窗口
|
2026-08-28 15:06:01 +08:00
|
|
|
|
type AuthConf struct {
|
2026-10-06 19:36:22 +08:00
|
|
|
|
// AccessSecret 必须由 yaml 提供,禁止编译期默认密钥(防默认密钥被绕过)
|
|
|
|
|
|
AccessSecret string `json:"AccessSecret"`
|
2026-09-10 16:59:15 +08:00
|
|
|
|
AccessExpire int64 `json:",default=3600"` // 会话闲置窗口(秒),滑动续签下 = 距最后请求多久后需重登
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// InternalConf 内部服务间鉴权
|
|
|
|
|
|
type InternalConf struct {
|
2026-10-06 19:36:22 +08:00
|
|
|
|
// Token 必须由 yaml 提供,禁止编译期默认密钥(防空 token 绕过内部接口鉴权)
|
|
|
|
|
|
Token string `json:"Token"`
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-28 17:03:03 +08:00
|
|
|
|
// CliConf 命令行敏感操作门禁密码(与管理员账号密码保持一致,改密时自动同步)
|
|
|
|
|
|
type CliConf struct {
|
2026-10-06 19:36:22 +08:00
|
|
|
|
// AdminPassword 必须由 yaml 提供,禁止编译期默认密钥(migrate/reset-all/seed 高危门禁)
|
|
|
|
|
|
AdminPassword string `json:"AdminPassword"`
|
2026-08-28 17:03:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-28 15:06:01 +08:00
|
|
|
|
// WmsConf WMS 内部服务地址
|
|
|
|
|
|
type WmsConf struct {
|
|
|
|
|
|
BaseURL string `json:",default="`
|
2026-10-06 19:36:22 +08:00
|
|
|
|
// Token 必须由 yaml 提供,禁止编译期默认密钥
|
|
|
|
|
|
Token string `json:"Token"`
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-14 17:24:59 +08:00
|
|
|
|
// PlcConf PLC 对接配置(mock 时不用)。
|
|
|
|
|
|
// 真读:48 位块(MB895..MB900,6 字节)覆盖产线点位信号;布局见 internal/plc/tcp.go 顶部注释。
|
2026-08-28 15:06:01 +08:00
|
|
|
|
type PlcConf struct {
|
2026-08-28 17:03:03 +08:00
|
|
|
|
Enable bool `json:",default=false"`
|
|
|
|
|
|
Host string `json:",default=127.0.0.1"`
|
|
|
|
|
|
Port int `json:",default=102"`
|
2026-10-14 17:24:59 +08:00
|
|
|
|
Rack int `json:",default=0"` // S7 机架号(1200=0,300=0)
|
|
|
|
|
|
Slot int `json:",default=1"` // S7 槽号(1200=1,300=2)
|
|
|
|
|
|
// DoneByte/DoneBit 工艺完成信号位(PLC 完成上一条下发后置位,MES 读此位决定是否下发下一条)。
|
|
|
|
|
|
// 待现场 PLC 点位表确认;未配置时 QueryDone 安全返回 false(不下发下一条,不误进)。
|
|
|
|
|
|
DoneByte int `json:",default=-1"`
|
|
|
|
|
|
DoneBit int `json:",default=-1"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-17 17:49:47 +08:00
|
|
|
|
// AgvConf 海康 AGV(RCS-Lite V1.5) 调度系统对接(2026-10-17 由 RCS-2000 改为 RCS-Lite 1.5)。
|
|
|
|
|
|
// RCS-Lite 无签名鉴权;未配置 BaseURL 或 EnableMock=true 时,使用 mock 客户端(模拟下发成功/到位),便于离线联调。
|
2026-10-14 17:24:59 +08:00
|
|
|
|
type AgvConf struct {
|
2026-10-17 17:49:47 +08:00
|
|
|
|
EnableMock bool `json:",default=true"` // 是否模拟(未接真实 RCS-Lite 前保持 true)
|
|
|
|
|
|
BaseURL string `json:",default=http://127.0.0.1:8182/rCMS/services/rest/hikRpcService"` // RCS-Lite 服务地址(含 /rCMS/services/rest/hikRpcService,默认端口 8182)
|
|
|
|
|
|
CarrierCode string `json:",default=DEFAULT"` // 默认载具/托盘编号(选填,下发时作为 podCode)
|
|
|
|
|
|
MapCode string `json:",default="` // 地图编号(选填,RCS-Lite 多地图场景使用)
|
|
|
|
|
|
Priority string `json:",default=1"` // 任务优先级(字符串 1-127,默认 1)
|
2026-08-28 17:03:03 +08:00
|
|
|
|
}
|
2026-08-31 08:06:55 +08:00
|
|
|
|
|
2026-09-19 10:54:15 +08:00
|
|
|
|
// UploadConf 附件统一存储配置。
|
|
|
|
|
|
// Dir 即附件根目录(相对服务启动目录或绝对路径),落盘结构:Dir/年/月/日/<文件类型>/<uuid>.<ext>。
|
2026-08-31 08:06:55 +08:00
|
|
|
|
type UploadConf struct {
|
|
|
|
|
|
Dir string `json:",default=uploads"`
|
2026-09-19 10:54:15 +08:00
|
|
|
|
MaxMB int64 `json:",default=20"` // 单文件默认上限(MB)
|
|
|
|
|
|
// 按文件类型覆盖上限(字节),键为大写枚举,如 PROCESS_PDF: 52428800
|
|
|
|
|
|
MaxSize map[string]int64 `json:",optional"`
|
2026-10-28 10:10:17 +08:00
|
|
|
|
// 本地保留年数(检验记录质量追溯保留期,期内禁删)
|
2026-09-19 10:54:15 +08:00
|
|
|
|
LocalRetentionYears int `json:",default=1"`
|
|
|
|
|
|
// 磁盘空间监控:每天 DiskCheckHour 点检测一次
|
|
|
|
|
|
DiskWarnPercent int `json:",default=20"` // 剩余低于该百分比告警
|
|
|
|
|
|
DiskCriticalPercent int `json:",default=10"` // 剩余低于该百分比提示清理
|
|
|
|
|
|
DiskCheckHour int `json:",default=7"` // 每天检测时刻(0~23)
|
2026-08-31 08:06:55 +08:00
|
|
|
|
}
|