【MES】 - AGV点位/线路点位/AGV任务/工单 ent schema 重构(全量重生成 ent 代码) - 新增派车锁 agv_point_lock.go:目标点位占用即拒车,JBT21 库房接驳台卸货后保持锁定待库管手动解锁 - 新增进程内 TTL 缓存 cache.go,由 Redis 看板缓存迁移至内存(singleflight 防击穿,去除外部依赖) - AGV 三段链安全机制、车辆状态/接驳台左右互换、补料损耗闭环完善 - 来料检/工序卡/工单/质检/日排产/AGV 前端与帮助文档更新 - 新增 migrations/、sql/ 目录 【WMS】 - 出库、Excel 导出、物料、路由处理增强 - 配置与 DB 初始化调整;基础数据/成品入库/入库前端调整 【工位终端】 - 移除离线同步队列(syncer 包、sync.go、SyncQueueDialog.vue),改为实时直连上报 MES(断网即失败报错),以本人身份操作 - 本地 SQLite 仅保留操作日志 + 内置账号 + 登录态;保留空闲自动登出 【文档】 - 删除 AGV海康litev1.5.md;案例.md 更新
92 lines
3.8 KiB
Go
92 lines
3.8 KiB
Go
package config
|
||
|
||
import (
|
||
"strconv"
|
||
|
||
"github.com/zeromicro/go-zero/rest"
|
||
)
|
||
|
||
// PostgresConfig PostgreSQL 连接配置(go-zero 按 json tag + 字段名小写匹配 yaml)
|
||
type PostgresConfig struct {
|
||
Host string `json:",default=127.0.0.1"`
|
||
Port int `json:",default=5432"`
|
||
User string `json:",default=postgres"`
|
||
Password string `json:",default=postgres"`
|
||
DBName string `json:",default=bj_power_wms"`
|
||
SSLMode string `json:",default=disable"`
|
||
}
|
||
|
||
type AuthConfig struct {
|
||
// AccessSecret 必须由 yaml 提供,禁止编译期默认密钥(防默认密钥被绕过)
|
||
AccessSecret string `json:"AccessSecret"`
|
||
// AccessExpire 会话闲置窗口(秒):滑动续签下 = 距最后一次请求多久后需要重新登录
|
||
AccessExpire int64 `json:",default=3600"`
|
||
}
|
||
|
||
// InternalConfig 项目间内部 API 配置
|
||
type InternalConfig struct {
|
||
// Token 必须由 yaml 提供,禁止编译期默认密钥(防空 token 绕过内部接口鉴权)
|
||
Token string `json:"Token"` // 写死的项目间 API token(X-API-TOKEN)
|
||
}
|
||
|
||
// MesConfig 下游 MES 服务对接(备料/台账需取工单与物料清单)
|
||
type MesConfig struct {
|
||
BaseURL string `json:",default=http://127.0.0.1:8888"` // MES 服务地址
|
||
// Token 必须由 yaml 提供,禁止编译期默认密钥
|
||
Token string `json:"Token"` // 调 MES 内部接口的 X-API-TOKEN
|
||
}
|
||
|
||
// WebConfig 前端静态资源托管配置(原库房客户端 8891 已合并进主服务)
|
||
type WebConfig struct {
|
||
OpenBrowser bool `json:",default=true"` // 本机开发时启动后自动打开浏览器;服务器部署设为 false
|
||
}
|
||
|
||
// CliConfig 命令行敏感操作门禁密码(migrate/reset-all/seed 需输入,独立于后台登录账号密码)。
|
||
// 与 MES 对齐:DDL/删库等高危操作一律显式触发 + 密码校验,绝不随服务启动自动执行。
|
||
type CliConfig struct {
|
||
// AdminPassword 必须由 yaml 提供,禁止编译期默认密钥(migrate/reset-all/seed 高危门禁)
|
||
AdminPassword string `json:"AdminPassword"`
|
||
}
|
||
|
||
// AttachmentConfig 附件存储 / 归档 / 磁盘监控配置(etc/*.yaml 的 Attachment 段)。
|
||
// 落盘约定:<RootDir>/年/月/日/<文件类型大写>/<uuid>.<ext>,库内只存相对路径。
|
||
type AttachmentConfig struct {
|
||
RootDir string `json:",default=attachments"` // 附件根目录(年/月/日/文件类型/uuid.ext)
|
||
// 单文件上限(字节),按文件类型(大写,如 PROCESS_PDF)可配;未列出的类型用 DefaultMaxSize
|
||
MaxSize map[string]int64 `json:",optional"`
|
||
DefaultMaxSize int64 `json:",default=20971520"` // 默认 20MB
|
||
LocalRetentionYears int `json:",default=1"` // 本地保留年数(早于此的年份可归档)
|
||
DiskWarnPercent int `json:",default=20"` // 剩余空间低于该百分比 → 告警
|
||
DiskCriticalPercent int `json:",default=10"` // 剩余空间低于该百分比 → 提示清理/归档
|
||
DiskCheckHour int `json:",default=7"` // 每天几点执行磁盘检测(默认 07:00)
|
||
}
|
||
|
||
// ScannerConfig 扫码中间件(键盘 HID 注入)开关配置。
|
||
// 启用后 WMS 启动时监听 7757,接收网络型扫码枪(iData PAD / 新大陆手机)推送,
|
||
// 模拟键盘注入当前光标窗口(库房屏同机可用)。Enable=false 时不监听。
|
||
type ScannerConfig struct {
|
||
Enabled bool `json:",default=true"`
|
||
}
|
||
|
||
type Config struct {
|
||
rest.RestConf
|
||
Postgres PostgresConfig
|
||
Auth AuthConfig
|
||
Internal InternalConfig
|
||
Mes MesConfig
|
||
Web WebConfig
|
||
Attachment AttachmentConfig
|
||
Cli CliConfig
|
||
Scanner ScannerConfig
|
||
}
|
||
|
||
// DSN 返回 PostgreSQL 连接串
|
||
func (p PostgresConfig) DSN() string {
|
||
return "host=" + p.Host +
|
||
" port=" + strconv.Itoa(p.Port) +
|
||
" user=" + p.User +
|
||
" password=" + p.Password +
|
||
" dbname=" + p.DBName +
|
||
" sslmode=" + p.SSLMode
|
||
}
|