edb_info_stat.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package data_stat
  2. import (
  3. "eta/eta_mobile/models/data_manage"
  4. "eta/eta_mobile/models/data_stat"
  5. "eta/eta_mobile/models/system"
  6. "fmt"
  7. "time"
  8. )
  9. // AddEdbInfoUpdateLog 添加指标编辑/刷新日志
  10. func AddEdbInfoUpdateLog(edbInfoId int, updateResult int, updateFailedReason string, sysUser *system.Admin, updateType int) (err error) {
  11. var edbInfo *data_manage.EdbInfo
  12. if edbInfoId > 0 {
  13. // 获取指标详情
  14. edbInfo, err = data_manage.GetEdbInfoById(edbInfoId)
  15. if err != nil {
  16. err = fmt.Errorf("指标不存在")
  17. return
  18. }
  19. nowTime := time.Now()
  20. log := new(data_stat.EdbInfoUpdateLog)
  21. log.EdbInfoId = edbInfo.EdbInfoId
  22. log.SourceName = edbInfo.SourceName
  23. log.Source = edbInfo.Source
  24. log.EdbCode = edbInfo.EdbCode
  25. log.EdbName = edbInfo.EdbName
  26. log.EdbNameSource = edbInfo.SourceIndexName
  27. log.Frequency = edbInfo.Frequency
  28. log.Unit = edbInfo.Unit
  29. log.StartDate = edbInfo.StartDate
  30. log.EndDate = edbInfo.EndDate
  31. log.SysUserId = edbInfo.SysUserId
  32. log.SysUserRealName = edbInfo.SysUserRealName
  33. log.UpdateSysUserId = sysUser.AdminId
  34. log.UpdateSysUserRealName = sysUser.RealName
  35. log.UniqueCode = edbInfo.UniqueCode
  36. log.EdbCreateTime = edbInfo.CreateTime
  37. log.EdbModifyTime = edbInfo.ModifyTime
  38. log.CreateTime = nowTime
  39. log.LatestDate = edbInfo.LatestDate
  40. log.LatestValue = edbInfo.LatestValue
  41. log.TerminalCode = edbInfo.TerminalCode
  42. log.UpdateResult = updateResult
  43. log.UpdateFailedReason = updateFailedReason
  44. log.DataUpdateTime = edbInfo.DataUpdateTime
  45. log.ErDataUpdateDate = edbInfo.ErDataUpdateDate
  46. log.UpdateType = updateType
  47. _, err = data_stat.AddEdbUpdateLog(log)
  48. if err != nil {
  49. err = fmt.Errorf("新增指标更新日志失败,Err: %s", err)
  50. return
  51. }
  52. }
  53. return
  54. }