edb_data_wind.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. )
  7. func EdbInfoUpdateStatusByEdbInfoId(edbInfoIds []int, isStop int, calculateEdbInfoIds []int) (err error) {
  8. o := global.DmSQL["data"].Begin()
  9. defer func() {
  10. if err != nil {
  11. _ = o.Rollback()
  12. return
  13. }
  14. _ = o.Commit()
  15. }()
  16. // 更改指标的更新状态
  17. if len(edbInfoIds) == 1 {
  18. sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id=? `
  19. err = o.Exec(sql, isStop, edbInfoIds[0]).Error
  20. if err != nil {
  21. return
  22. }
  23. } else {
  24. sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) `
  25. err = o.Exec(sql, isStop, edbInfoIds).Error
  26. if err != nil {
  27. return
  28. }
  29. }
  30. if len(calculateEdbInfoIds) > 0 {
  31. // 批量更新相关联的指标ID
  32. sql := ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(calculateEdbInfoIds)) + `) `
  33. err = o.Exec(sql, isStop, calculateEdbInfoIds).Error
  34. if err != nil {
  35. return
  36. }
  37. }
  38. return
  39. }
  40. func ModifyEdbInfoWindWsdDataStatus(source, subSource int, edbInfoId int64, edbCode string) (err error) {
  41. tableName := GetEdbDataTableNameAndSubSource(source, subSource)
  42. sql := ` UPDATE %s SET edb_info_id=?,modify_time=NOW() WHERE edb_code=? `
  43. sql = fmt.Sprintf(sql, tableName)
  44. err = global.DmSQL["data"].Exec(sql, edbInfoId, edbCode).Error
  45. return
  46. }