base_from_mysteel_chemical_index.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package data_manage
  2. import (
  3. "eta/eta_hub/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. // BaseFromMysteelChemicalIndex 钢联化工指标表
  8. type BaseFromMysteelChemicalIndex struct {
  9. BaseFromMysteelChemicalIndexId int `orm:"column(base_from_mysteel_chemical_index_id);pk"`
  10. BaseFromMysteelChemicalClassifyId int `orm:"column(base_from_mysteel_chemical_classify_id)" description:"钢联化工指标分类id"`
  11. IndexCode string `description:"指标编码"`
  12. IndexName string `description:"指标名称"`
  13. Unit string `description:"单位"`
  14. Source string `description:"数据来源"`
  15. Frequency string `description:"频度"`
  16. StartDate string `description:"开始日期"`
  17. EndDate string `description:"结束日期"`
  18. Describe string `description:"指标描述"`
  19. UpdateWeek string `description:"更新周期"`
  20. UpdateTime string `description:"更新时间1"`
  21. UpdateTime2 string `description:"更新时间2"`
  22. SysUserId int `description:"创建人id"`
  23. SysUserRealName string `description:"创建人姓名"`
  24. ModifyTime time.Time `description:"修改时间"`
  25. CreateTime time.Time `description:"创建时间"`
  26. Sort int `description:"排序字段"`
  27. MergeFilePath string `description:"合并文件"`
  28. TerminalCode string `description:"终端编码"`
  29. IsStop int `description:"是否停更:1:停更,0:未停更"`
  30. EndValue float64 `description:"指标的最新值"`
  31. IsSupplierStop int `description:"是否供应商停更:1:停更,0:未停更"`
  32. }
  33. // GetNotIsSupplierStopIndexByCodeList
  34. // @Description: 获取未被供应商停更的指标
  35. // @author: Roc
  36. // @datetime 2024-08-28 18:15:03
  37. // @param codeList []string
  38. // @param isStop int
  39. // @return items []*BaseFromMysteelChemicalIndex
  40. // @return err error
  41. func GetNotIsSupplierStopIndexByCodeList(codeList []string, isStop int) (items []*BaseFromMysteelChemicalIndex, err error) {
  42. num := len(codeList)
  43. if num <= 0 {
  44. return
  45. }
  46. o := orm.NewOrmUsingDB("data")
  47. sql := `SELECT * FROM base_from_mysteel_chemical_index WHERE is_supplier_stop = ? AND index_code in (` + utils.GetOrmInReplace(num) + `) `
  48. _, err = o.Raw(sql, isStop, codeList).QueryRows(&items)
  49. return
  50. }
  51. func ModifyMysteelChemicalUpdateStatusByEdbInfoIds(edbInfoIds []int, isStop int, edbCodes []string, calculateEdbInfoIds []int) (err error) {
  52. o, err := orm.NewOrmUsingDB("data").Begin()
  53. if err != nil {
  54. return
  55. }
  56. defer func() {
  57. if err != nil {
  58. _ = o.Rollback()
  59. return
  60. }
  61. _ = o.Commit()
  62. }()
  63. // 更改数据源的更新状态
  64. sql := ` UPDATE base_from_mysteel_chemical_index SET is_stop = ? WHERE index_code IN (` + utils.GetOrmInReplace(len(edbCodes)) + `) `
  65. _, err = o.Raw(sql, isStop, edbCodes).Exec()
  66. if err != nil {
  67. return
  68. }
  69. // 更改指标的更新状态
  70. sql = ` UPDATE edb_info SET no_update = ? WHERE source = ? AND edb_info_id IN (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) `
  71. _, err = o.Raw(sql, isStop, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, edbInfoIds).Exec()
  72. if err != nil {
  73. return
  74. }
  75. if len(calculateEdbInfoIds) > 0 {
  76. // 批量更新相关联的指标ID
  77. sql = ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(calculateEdbInfoIds)) + `) `
  78. _, err = o.Raw(sql, isStop, calculateEdbInfoIds).Exec()
  79. if err != nil {
  80. return
  81. }
  82. }
  83. return
  84. }