sync_index.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. package models
  2. import (
  3. "errors"
  4. "fmt"
  5. "github.com/beego/beego/v2/client/orm"
  6. "time"
  7. )
  8. type EdbClassifyItem struct {
  9. ClassifyID int64 `orm:"column(classify_id);pk"`
  10. ClassifyType uint32
  11. ClassifyName string
  12. ParentID int64
  13. HasData int32
  14. CreateTime time.Time
  15. ModifyTime time.Time
  16. SysUserID int64
  17. SysUserRealName string
  18. Level int64
  19. UniqueCode string
  20. Sort uint32
  21. RootID int64
  22. LastModifyUserID uint32
  23. LastModifyUserName string
  24. }
  25. // GetAllEdbClassifyListByCondition
  26. // @Description: 获取分类列表
  27. // @author: Roc
  28. // @datetime 2024-02-29 10:55:38
  29. // @param condition string
  30. // @param pars []interface{}
  31. // @return item []*EdbInfoUpdateLog
  32. // @return err error
  33. func GetAllEdbClassifyListByCondition(condition string, pars []interface{}) (item []*EdbClassifyItem, err error) {
  34. o := orm.NewOrmUsingDB("data")
  35. sql := ` SELECT * FROM edb_classify WHERE 1=1 `
  36. if condition != "" {
  37. sql += condition
  38. }
  39. sql += ` ORDER BY classify_id ASC `
  40. _, err = o.Raw(sql, pars).QueryRows(&item)
  41. return
  42. }
  43. type EdbInfoItem struct {
  44. CalculateFormula string `json:"calculate_formula"`
  45. Calendar string `json:"calendar"`
  46. ChartImage string `json:"chart_image"`
  47. ClassifyId int `json:"classify_id"`
  48. CreateTime string `json:"create_time"`
  49. DataDateType string `json:"data_date_type"`
  50. DataUpdateTime string `json:"data_update_time"`
  51. EdbCode string `json:"edb_code"`
  52. EdbInfoId int `json:"edb_info_id"`
  53. EdbInfoType int `json:"edb_info_type"`
  54. EdbName string `json:"edb_name"`
  55. EdbNameEn string `json:"edb_name_en"`
  56. EdbNameSource string `json:"edb_name_source"`
  57. EdbType int `json:"edb_type"`
  58. EmptyType int `json:"empty_type"`
  59. EndDate string `json:"end_date"`
  60. EndValue float64 `json:"end_value"`
  61. ErDataUpdateDate string `json:"er_data_update_date"`
  62. Extra string `json:"extra"`
  63. Frequency string `json:"frequency"`
  64. IndicatorCode string `json:"indicator_code"`
  65. IsUpdate int `json:"is_update"`
  66. LatestDate string `json:"latest_date"`
  67. LatestValue float64 `json:"latest_value"`
  68. ManualSave int `json:"manual_save"`
  69. MaxEmptyType int `json:"max_empty_type"`
  70. MaxValue float64 `json:"max_value"`
  71. MinValue float64 `json:"min_value"`
  72. ModifyTime string `json:"modify_time"`
  73. MoveFrequency string `json:"move_frequency"`
  74. MoveType int `json:"move_type"`
  75. NoUpdate int `json:"no_update"`
  76. ServerUrl string `json:"server_url"`
  77. Sort int `json:"sort"`
  78. Source int `json:"source"`
  79. SourceIndexName string `json:"source_index_name"`
  80. SourceName string `json:"source_name"`
  81. StartDate string `json:"start_date"`
  82. StockCode string `json:"stock_code"`
  83. SubSource int `json:"sub_source"`
  84. SubSourceName string `json:"sub_source_name"`
  85. SysUserId int `json:"sys_user_id"`
  86. SysUserRealName string `json:"sys_user_real_name"`
  87. TerminalCode string `json:"terminal_code"`
  88. UniqueCode string `json:"unique_code"`
  89. Unit string `json:"unit"`
  90. UnitEn string `json:"unit_en"`
  91. }
  92. // GetAllEdbInfoListByCondition
  93. // @Description: 获取所有的指标
  94. // @author: Roc
  95. // @datetime 2024-02-29 10:55:38
  96. // @param condition string
  97. // @param pars []interface{}
  98. // @return item []*EdbInfoUpdateLog
  99. // @return err error
  100. func GetAllEdbInfoListByCondition(condition string, pars []interface{}) (item []*EdbInfoItem, err error) {
  101. o := orm.NewOrmUsingDB("data")
  102. sql := ` SELECT * FROM edb_info WHERE 1=1 `
  103. if condition != "" {
  104. sql += condition
  105. }
  106. sql += ` ORDER BY edb_info_id ASC `
  107. _, err = o.Raw(sql, pars).QueryRows(&item)
  108. return
  109. }
  110. type EdbData struct {
  111. EdbDataId int32 `orm:"column(edb_data_id);pk" json:"edb_data_id"`
  112. EdbInfoId int32 `json:"edb_info_id"` // 指标id
  113. EdbCode string `json:"edb_code"` // 指标编码
  114. //DataTime time.Time `json:"data_time"` // 数据日期
  115. DataTime string `json:"data_time"` // 数据日期
  116. Value float64 `json:"value"` // 数据值
  117. //CreateTime time.Time `json:"create_time"` // 创建时间
  118. //ModifyTime time.Time `json:"modify_time"` // 修改时间
  119. CreateTime string `json:"create_time"` // 创建时间
  120. ModifyTime string `json:"modify_time"` // 修改时间
  121. DataTimestamp int64 `json:"data_timestamp"` // 数据日期时间戳
  122. }
  123. // GetAllEdbDataListByCondition
  124. // @Description: 根据指标id和表名获取指标数据
  125. // @author: Roc
  126. // @datetime 2024-03-14 13:22:01
  127. // @param tableName string
  128. // @param edbInfoId int
  129. // @return item []*EdbData
  130. // @return err error
  131. func GetAllEdbDataListByCondition(tableName string, edbInfoId int) (item []*EdbData, err error) {
  132. if tableName == `` {
  133. err = errors.New("错误的表名")
  134. return
  135. }
  136. o := orm.NewOrmUsingDB("data")
  137. sql := fmt.Sprintf(` SELECT * FROM %s WHERE 1=1 and edb_info_id = ? `, tableName)
  138. sql += ` ORDER BY edb_data_id ASC `
  139. _, err = o.Raw(sql, edbInfoId).QueryRows(&item)
  140. return
  141. }
  142. type BaseFromMysteelChemicalIndexItem struct {
  143. BaseFromMysteelChemicalIndexId int32 `json:"base_from_mysteel_chemical_index_id"`
  144. BaseFromMysteelChemicalClassifyId int32 `json:"base_from_mysteel_chemical_classify_id"` // 钢联化工指标分类id
  145. IndexCode string `json:"index_code"` // 指标编码
  146. IndexName string `json:"index_name"` // 指标名称
  147. Unit string `json:"unit"` // 单位
  148. Source string `json:"source"` // 数据来源
  149. Frequency string `json:"frequency"` // 频度
  150. StartDate string `json:"start_date"` // 开始日期
  151. EndDate string `json:"end_date"` // 结束日期
  152. Describe string `json:"describe"` // 指标描述
  153. UpdateWeek string `json:"update_week"` // 更新周期
  154. UpdateTime string `json:"update_time"` // 更新时间,多个时间点用英文,隔开
  155. UpdateTime2 string `json:"update_time2"` // 更新时间2
  156. SysUserId int32 `json:"sys_user_id"` // 创建人id
  157. SysUserRealName string `json:"sys_user_real_name"` // 创建人姓名
  158. CreateTime string `json:"create_time"` // 创建时间
  159. ModifyTime string `json:"modify_time"` // 修改时间
  160. FilePath string `json:"file_path"` // 文件存储路径
  161. Sort int32 `json:"sort"` // 排序
  162. MergeFilePath string `json:"merge_file_path"`
  163. FileIndex int32 `json:"file_index"`
  164. MergeUpdateWeek string `json:"merge_update_week"` // 合并文件的更新周
  165. MergeFilePathWeek string `json:"merge_file_path_week"` // 更新文件
  166. UpdateDate string `json:"update_date"` // 更新日期
  167. IsRefresh int32 `json:"is_refresh"` // 0:不需要及时刷新,1:需要及时刷新
  168. IsStop int32 `json:"is_stop"` // 是否停更:1:停更,0:未停更
  169. TerminalCode string `json:"terminal_code"` // 所属终端编码
  170. EndValue float64 `json:"end_value"` // 指标的最新值
  171. }
  172. // GetBaseFromMysteelChemicalIndexItemByCode
  173. // @Description: 根据指标编码获取钢联指标详情
  174. // @author: Roc
  175. // @datetime 2024-03-11 16:42:56
  176. // @param edbCode string
  177. // @return item *BaseFromMysteelChemicalIndexItem
  178. // @return err error
  179. func GetBaseFromMysteelChemicalIndexItemByCode(edbCode string) (item *BaseFromMysteelChemicalIndexItem, err error) {
  180. o := orm.NewOrmUsingDB("data")
  181. sql := ` SELECT * FROM base_from_mysteel_chemical_index WHERE index_code = ?`
  182. err = o.Raw(sql, edbCode).QueryRow(&item)
  183. return
  184. }
  185. type BaseFromSmmIndexItem struct {
  186. BaseFromSmmIndexId int32 `json:"base_from_smm_index_id"`
  187. ClassifyId int32 `json:"classify_id"` // Smm原始数据指标分类id
  188. Interface string `json:"interface"`
  189. Name string `json:"name"`
  190. IndexCode string `json:"index_code"` // 指标编码
  191. IndexName string `json:"index_name"` // 指标名称
  192. Type1 string `json:"type_1"` // 类型1
  193. Type2 string `json:"type_2"` // 类型2
  194. Type3 string `json:"type_3"` // 类型3
  195. Frequency string `json:"frequency"` // 频度
  196. Unit string `json:"unit"` // 单位
  197. ApiStartTime string `json:"api_start_time"` // 接口开始日期
  198. ApiUpdateTime string `json:"api_update_time"` // 接口更新日期
  199. StartTime string `json:"start_time"` // 开始日期
  200. FinishTime string `json:"finish_time"` // 完成日期
  201. CreateTime string `json:"create_time"`
  202. ModifyTime string `json:"modify_time"`
  203. StartDate string `json:"start_date"`
  204. EndDate string `json:"end_date"`
  205. IsGet int32 `json:"is_get"` // 0:未获取数据,1:已获取数据
  206. Sort int32 `json:"sort"` // 排序
  207. BaseFileName string `json:"base_file_name"` // 文件目录
  208. RenameFileName string `json:"rename_file_name"` // 重命名文件目录
  209. TerminalCode string `json:"terminal_code"` // 所属终端编码
  210. DataState string `json:"data_state"` // 指标数据状态 normal/空白-正常更新 ceased-已停更irregular-更新依赖外部会有不定期延迟
  211. ReleaseTime string `json:"release_time"` // 预计发布时间
  212. IsStop int32 `json:"is_stop"` // 是否停更:1:停更,0:未停更
  213. EndValue float64 `json:"end_value"` // 指标的最新值
  214. }
  215. // GetBaseFromSmmIndexItemItemByCode
  216. // @Description: 根据指标编码获取指标信息
  217. // @author: Roc
  218. // @datetime 2024-03-11 16:41:02
  219. // @param source int
  220. // @param edbCode string
  221. // @return item *BaseFromSmmIndexItem
  222. // @return err error
  223. func GetBaseFromSmmIndexItemItemByCode(edbCode string) (item *BaseFromSmmIndexItem, err error) {
  224. o := orm.NewOrmUsingDB("data")
  225. sql := ` SELECT * FROM base_from_smm_index WHERE index_code=? `
  226. err = o.Raw(sql, edbCode).QueryRow(&item)
  227. return
  228. }