feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段
- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统 - 为BomItem实体添加relatedStandard字段及相关CRUD方法 - 为InspectionRecord实体添加reportNo、materialCode、materialName等字段 - 更新ent schema确保新字段的验证和默认值设置 - 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
@@ -178,6 +178,27 @@ func main() {
|
||||
handler.RegisterRoutes(server, svcCtx)
|
||||
handler.RegisterProductionRoutes(server, svcCtx)
|
||||
|
||||
// 可生产数量 / 未来5天需求:后台定时计算并推送 WMS(两系统独立,仅 MES→WMS 单向)。
|
||||
// 未配置 WMS 地址时不启动;WMS 不可达时单次同步失败仅记录日志,不影响下个周期。
|
||||
if c.Wms.BaseURL != "" {
|
||||
go func() {
|
||||
runSync := func() {
|
||||
sctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
if err := logic.New(svcCtx).SyncProducibleToWMS(sctx); err != nil {
|
||||
logx.Errorf("可生产数量同步失败: %v", err)
|
||||
}
|
||||
}
|
||||
time.Sleep(15 * time.Second) // 避开启动瞬时压力后首次同步
|
||||
runSync()
|
||||
ticker := time.NewTicker(10 * time.Minute)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
runSync()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
fmt.Printf("Starting bj_power_mes server at %s:%d...\n", c.Host, c.Port)
|
||||
logx.Infof("Starting bj_power_mes server at %s:%d...", c.Host, c.Port)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user