提交
This commit is contained in:
@@ -31,6 +31,10 @@ const (
|
||||
CfgPipelineCache = "pipeline_cache"
|
||||
// CfgAllowCrossDay 允许叫非今日排产的料(B5 跨日:1=允许(默认,工位端预警提示),0=禁止)
|
||||
CfgAllowCrossDay = "call.allow_cross_day"
|
||||
// CfgTorqueNgAlert 拧紧不合格报警开关(B2.1):1=开启(默认,拧紧扭矩不合格立即落预警),0=关闭(只写 step_data + 置待处置标记,不落预警)
|
||||
CfgTorqueNgAlert = "torque.ng.alert.enabled"
|
||||
// CfgDashboardRefreshSeconds 看板大屏轮询兜底刷新间隔(秒,1~10):仅影响 SSE 实时通道不可用时的 HTTP 轮询周期(默认 5)
|
||||
CfgDashboardRefreshSeconds = "dashboard.refresh.seconds"
|
||||
)
|
||||
|
||||
// startedAt 服务启动时刻(本机信息展示用)
|
||||
@@ -46,6 +50,8 @@ type SettingsVO struct {
|
||||
LogRetentionDays int `json:"logRetentionDays"` // 事件日志保留天数(0=不清理)
|
||||
PipelineCache int `json:"pipelineCache"` // 滚筒线缓存模式(1=缓存并行,0=串行;预留,PLC 真机接入时生效)
|
||||
AllowCrossDay int `json:"allowCrossDay"` // 允许叫非今日排产的料(1=允许(默认),0=禁止)
|
||||
TorqueNgAlert bool `json:"torqueNgAlert"` // 拧紧不合格报警开关(1=开启,0=关闭)
|
||||
DashboardRefreshSeconds int `json:"dashboardRefreshSeconds"` // 看板轮询兜底刷新间隔(秒,1~10)
|
||||
|
||||
// 本机基础信息(只读)
|
||||
LocalIPs []string `json:"localIPs"` // 本机内网 IPv4 列表
|
||||
@@ -65,6 +71,8 @@ type SettingsReq struct {
|
||||
LogRetentionDays *int `json:"logRetentionDays"`
|
||||
PipelineCache *int `json:"pipelineCache"`
|
||||
AllowCrossDay *int `json:"allowCrossDay"`
|
||||
TorqueNgAlert *bool `json:"torqueNgAlert"` // B2.1 拧紧不合格报警开关(nil=不改)
|
||||
DashboardRefreshSeconds *int `json:"dashboardRefreshSeconds"` // 看板轮询兜底刷新间隔(秒,nil=不改)
|
||||
}
|
||||
|
||||
// defaults 建议默认值(未配置时生效)
|
||||
@@ -75,6 +83,8 @@ var settingsDefaults = map[string]int{
|
||||
CfgLogRetention: 0,
|
||||
CfgPipelineCache: 0,
|
||||
CfgAllowCrossDay: 1,
|
||||
CfgTorqueNgAlert: 1, // B2.1 默认开启拧紧不合格报警
|
||||
CfgDashboardRefreshSeconds: 5, // 看板轮询兜底刷新间隔(秒)
|
||||
}
|
||||
|
||||
// GetSettings 读取基础设置 + 本机信息。DB 读失败时按默认值返回(设置页必须能打开)。
|
||||
@@ -93,6 +103,8 @@ func (s *Service) GetSettings(ctx context.Context) (*SettingsVO, error) {
|
||||
LogRetentionDays: cfgIntFrom(kv, CfgLogRetention),
|
||||
PipelineCache: cfgIntFrom(kv, CfgPipelineCache),
|
||||
AllowCrossDay: cfgIntFrom(kv, CfgAllowCrossDay),
|
||||
TorqueNgAlert: s.CfgInt(ctx, CfgTorqueNgAlert, 1) == 1, // B2.1 默认开启
|
||||
DashboardRefreshSeconds: cfgIntFrom(kv, CfgDashboardRefreshSeconds),
|
||||
LocalIPs: localIPv4s(),
|
||||
ListenAddr: fmt.Sprintf("%s:%d", s.ctx.Config.Host, s.ctx.Config.Port),
|
||||
DBInfo: fmt.Sprintf("%s:%d/%s", s.ctx.Config.Database.Host, s.ctx.Config.Database.Port, s.ctx.Config.Database.Dbname),
|
||||
@@ -126,6 +138,7 @@ func (s *Service) SaveSettings(ctx context.Context, req SettingsReq, operator st
|
||||
{CfgLogRetention, req.LogRetentionDays, 0, 3650, "事件日志保留天数(0=不清理)"},
|
||||
{CfgPipelineCache, req.PipelineCache, 0, 1, "滚筒线缓存模式(1=启用缓存位并行流转,0=串行不缓存);预留配置,PLC 真机接入时生效"},
|
||||
{CfgAllowCrossDay, req.AllowCrossDay, 0, 1, "允许叫非今日排产的料(1=允许,工位端预警提示;0=禁止)"},
|
||||
{CfgDashboardRefreshSeconds, req.DashboardRefreshSeconds, 1, 10, "看板轮询兜底刷新间隔(秒,1~10,仅 SSE 不可用时的 HTTP 轮询周期)"},
|
||||
}
|
||||
for _, it := range items {
|
||||
if it.val == nil {
|
||||
@@ -138,6 +151,15 @@ func (s *Service) SaveSettings(ctx context.Context, req SettingsReq, operator st
|
||||
return err
|
||||
}
|
||||
}
|
||||
if req.TorqueNgAlert != nil {
|
||||
v := 0
|
||||
if *req.TorqueNgAlert {
|
||||
v = 1
|
||||
}
|
||||
if err := s.upsertConfig(ctx, CfgTorqueNgAlert, strconv.Itoa(v), "拧紧不合格报警开关(1=开启,0=关闭)"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if req.WmsBaseURL != nil {
|
||||
u := strings.TrimSpace(*req.WmsBaseURL)
|
||||
if err := s.upsertConfig(ctx, CfgWmsBaseURL, u, "WMS 服务地址(保存即生效)"); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user