1. 新增跨平台磁盘空间监控能力,每日7点自动检测附件目录剩余空间,触发阈值告警 2. 重构附件存储方案为年/月/日/文件类型分层结构,统一MES与WMS的附件管理逻辑 3. 对齐物料档案与入库单的质量状态校验规则,仅合格品计入库存与出库 4. 实现入库单作废功能与区域库位的多级父子结构管理 5. 删除物料简称字段,补充规格型号与单位必填项,统一系统数据口径 6. 新增附件中心与磁盘状态查询接口,完善权限控制与操作日志
93 lines
3.9 KiB
Go
93 lines
3.9 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 string `json:",default=Hardman_2026"`
|
||
// AccessExpire 会话闲置窗口(秒):滑动续签下 = 距最后一次请求多久后需要重新登录
|
||
AccessExpire int64 `json:",default=3600"`
|
||
}
|
||
|
||
// InternalConfig 项目间内部 API 配置
|
||
type InternalConfig struct {
|
||
Token string `json:",default=Hardman_2026"` // 写死的项目间 API token(X-API-TOKEN)
|
||
}
|
||
|
||
// MesConfig 下游 MES 服务对接(备料/台账需取工单与 BOM)
|
||
type MesConfig struct {
|
||
BaseURL string `json:",default=http://127.0.0.1:8888"` // MES 服务地址
|
||
Token string `json:",default=Hardman_2026"` // 调 MES 内部接口的 X-API-TOKEN
|
||
}
|
||
|
||
// AgvConfig 海康 AGV(RCS-2000) 调度系统对接
|
||
// 未配置 appKey/appSecret/RCS 地址 或 EnableMock=true 时,使用 mock 客户端(模拟下发成功/到位),便于离线联调。
|
||
type AgvConfig struct {
|
||
EnableMock bool `json:",default=true"` // 是否模拟(未接真实 RCS 前保持 true)
|
||
BaseURL string `json:",default=http://127.0.0.1:1010/rcs/rtas"` // RCS 服务前缀,如 http://10.10.10.10:1010/rcs/rtas
|
||
AppKey string `json:",default=unset"` // RCS 颁发给业务系统的应用标识
|
||
AppSecret string `json:",default=unset"` // RCS 应用私钥
|
||
CarrierCode string `json:",default=DEFAULT"` // 默认载具/托盘编号(选填)
|
||
PollInterval int `json:",default=10"` // 任务状态轮询间隔(秒)
|
||
}
|
||
|
||
// WebConfig 前端静态资源托管配置(原库房客户端 8891 已合并进主服务)
|
||
type WebConfig struct {
|
||
OpenBrowser bool `json:",default=true"` // 本机开发时启动后自动打开浏览器;服务器部署设为 false
|
||
}
|
||
|
||
// 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)
|
||
ArchiveDir string `json:",optional"` // 外部备份目录(NAS/移动硬盘);为空则归档仅标记不动文件
|
||
}
|
||
|
||
type Config struct {
|
||
rest.RestConf
|
||
Postgres PostgresConfig
|
||
Auth AuthConfig
|
||
Internal InternalConfig
|
||
Redis RedisConf
|
||
Mes MesConfig
|
||
Agv AgvConfig
|
||
Web WebConfig
|
||
Attachment AttachmentConfig
|
||
}
|
||
|
||
// RedisConf Redis 连接配置
|
||
type RedisConf struct {
|
||
Host string `json:",default=127.0.0.1:6379"`
|
||
Type string `json:",default=node"`
|
||
}
|
||
|
||
// 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
|
||
}
|