package data import ( "hongze/hongze_task/models/data_manage" "hongze/hongze_task/utils" "sync" ) var lock sync.Mutex //同步钢炼数据 func SyncGlDataBase() { lock.Lock() var err error defer func() { if err != nil { utils.FileLog.Info("SyncGlDataBase Err:" + err.Error()) } }() var condition string var pars []interface{} condition += " AND source=? " pars = append(pars, utils.DATA_SOURCE_GL) items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0) if err != nil { return } for _, v := range items { err = data_manage.RefreshEdbDataByGl(v.EdbInfoId, v.EdbCode, v.StartDate.Format(utils.FormatDate), "") if err != nil { return } item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode) if err != nil { return } if item != nil { err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item) if err != nil { return } } } lock.Unlock() } var lzLock sync.Mutex //同步隆重数据 func SyncLzDataBase() { lzLock.Lock() var err error defer func() { if err != nil { utils.FileLog.Info("SyncLzDataBase Err:" + err.Error()) go utils.SendEmailByHongze("同步隆众数据失败", "同步隆众数据失败 Err:"+err.Error(), utils.RefreshEdbInfoEmailSendToUsers, "", "") } }() var condition string var pars []interface{} condition += " AND source=? " pars = append(pars, utils.DATA_SOURCE_LZ) items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0) if err != nil { return } for _, v := range items { err = data_manage.RefreshEdbDataByLz(v.EdbInfoId, v.EdbCode, v.StartDate.Format(utils.FormatDate), "") if err != nil { return } item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode) if err != nil { return } if item != nil { err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item) if err != nil { return } } } lzLock.Unlock() } var smmLock sync.Mutex //同步有色数据 func SyncSmmDataBase() { smmLock.Lock() var err error defer func() { if err != nil { utils.FileLog.Info("SyncSmmDataBase Err:" + err.Error()) go utils.SendEmailByHongze("同步有色数据失败", "同步隆众数据失败 Err:"+err.Error(), utils.RefreshEdbInfoEmailSendToUsers, "", "") } }() var condition string var pars []interface{} condition += " AND source=? " pars = append(pars, utils.DATA_SOURCE_YS) items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0) if err != nil { return } for _, v := range items { err = data_manage.RefreshEdbDataByYs(v.EdbInfoId, v.EdbCode, v.StartDate.Format(utils.FormatDate), "") if err != nil { return } item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode) if err != nil { return } if item != nil { err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item) if err != nil { return } } } smmLock.Unlock() } var manualLock sync.Mutex //同步手工数据 func SyncManualDataBase() { var err error manualLock.Lock() defer func() { if err != nil { utils.FileLog.Info("SyncLzDataBase Err:" + err.Error()) go utils.SendEmailByHongze("同步手工数据失败", "同步手工数据失败 Err:"+err.Error(), utils.RefreshEdbInfoEmailSendToUsers, "", "") } }() var condition string var pars []interface{} condition += " AND source=? " //condition += " AND edb_code='W000156' " pars = append(pars, utils.DATA_SOURCE_MANUAL) items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0) if err != nil { return } for _, v := range items { err = data_manage.RefreshManual(v) if err != nil { return } item, err := data_manage.GetEdbInfoMaxAndMinInfo(v.Source, v.EdbCode) if err != nil { return } if item != nil { err = data_manage.ModifyEdbInfoMaxAndMinInfo(v.EdbInfoId, item) if err != nil { return } } } manualLock.Unlock() }