handle_data.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. package eta_bridge
  2. import (
  3. "encoding/json"
  4. "eta/eta_task/models/data_manage"
  5. "eta/eta_task/utils"
  6. "fmt"
  7. "strings"
  8. )
  9. // handleData
  10. // @Description: 监听的数据处理
  11. // @author: Roc
  12. // @datetime 2024-03-11 14:52:49
  13. // @param edbUpdateLog *data_manage.EdbUpdateLog
  14. // @return pushIndexData *PushIndexParamDataReq
  15. // @return pushEdbClassify *PushEdbClassifyItemReq
  16. // @return pushIndexValue *PushIndexValueItemReq
  17. // @return err error
  18. func handleData(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIndexParamDataReq, pushEdbClassify *PushEdbClassifyItemReq, pushIndexValue *PushIndexValueItemReq, err error) {
  19. switch edbUpdateLog.OpType {
  20. case "insert":
  21. return handleInsert(edbUpdateLog)
  22. case "update":
  23. return handleUpdate(edbUpdateLog)
  24. case "delete":
  25. return handleDelete(edbUpdateLog)
  26. }
  27. return
  28. }
  29. // handleInsert
  30. // @Description: 新增数据处理
  31. // @author: Roc
  32. // @datetime 2024-03-11 14:53:03
  33. // @param edbUpdateLog *data_manage.EdbUpdateLog
  34. // @return pushIndexData *PushIndexParamDataReq
  35. // @return pushEdbClassify *PushEdbClassifyItemReq
  36. // @return pushIndexValue *PushIndexValueItemReq
  37. // @return err error
  38. func handleInsert(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIndexParamDataReq, pushEdbClassify *PushEdbClassifyItemReq, pushIndexValue *PushIndexValueItemReq, err error) {
  39. data := edbUpdateLog.NewData
  40. //指标信息
  41. if edbUpdateLog.OpTableName == "edb_info" {
  42. var edbInfo *data_manage.EdbInfoItem
  43. err = json.Unmarshal([]byte(data), &edbInfo)
  44. if err != nil {
  45. return
  46. }
  47. // 预测指标不处理
  48. if edbInfo.EdbInfoType == 1 {
  49. return
  50. }
  51. // 计算指标不处理
  52. if edbInfo.EdbType == 2 {
  53. return
  54. }
  55. // 获取数据源中指标的基础信息
  56. origInfo := getOrigInfo(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbCode)
  57. // 指标信息
  58. pushIndexData = &PushIndexParamDataReq{
  59. SourceIndexCode: edbInfo.EdbCode,
  60. IndexCode: fmt.Sprint(edbInfo.Source, "_", edbInfo.EdbCode),
  61. IndexName: origInfo.EdbName,
  62. IndexShortName: edbInfo.EdbName,
  63. FrequenceName: edbInfo.Frequency,
  64. UnitName: edbInfo.Unit,
  65. AssetBeginDate: edbInfo.StartDate,
  66. AssetEndDate: edbInfo.EndDate,
  67. CreateUser: edbInfo.SysUserRealName,
  68. IndexCreateTime: edbInfo.CreateTime,
  69. UpdateUser: edbInfo.SysUserRealName,
  70. DetailUpdateTime: getMaxModifyTime(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbCode, edbUpdateLog.CreateTime.Format(utils.FormatDateTime)),
  71. IndexUpdateTime: edbInfo.ModifyTime,
  72. OrginSource: edbInfo.SourceName,
  73. OrginSysSource: origInfo.SourceName,
  74. SysSource: "产研平台",
  75. SourceType: getSourceType(edbInfo.Source),
  76. Status: 1,
  77. }
  78. // 指标与分类的关系信息
  79. pushEdbClassify = &PushEdbClassifyItemReq{
  80. Id: fmt.Sprint(edbInfo.EdbInfoId),
  81. ClassifyId: edbInfo.ClassifyId,
  82. IndexCode: fmt.Sprint(edbInfo.Source, "_", edbInfo.EdbCode),
  83. CreateTime: edbInfo.CreateTime,
  84. CreateUser: edbInfo.SysUserRealName,
  85. UpdateTime: edbInfo.ModifyTime,
  86. UpdateUser: edbInfo.SysUserRealName,
  87. }
  88. return
  89. }
  90. // 分类信息
  91. //if edbUpdateLog.OpTableName == "edb_classify" {
  92. // var edbClassify *data_manage.EdbClassify
  93. // err = json.Unmarshal([]byte(data), &edbClassify)
  94. // if err != nil {
  95. // return
  96. // }
  97. //
  98. // // 指标信息
  99. // pushClassify = PushClassifyItemReq{
  100. // ClassifyId: int(edbClassify.ClassifyID),
  101. // ClassifyType: int(edbClassify.ClassifyType),
  102. // ClassifyName: edbClassify.ClassifyName,
  103. // ParentId: int(edbClassify.ParentID),
  104. // HasData: int(edbClassify.HasData),
  105. // CreateTime: edbClassify.CreateTime.Format(utils.FormatDateTime),
  106. // UpdateTime: edbClassify.ModifyTime.Format(utils.FormatDateTime),
  107. // SysUserId: int(edbClassify.SysUserID),
  108. // SysUserRealName: edbClassify.SysUserRealName,
  109. // Level: int(edbClassify.Level),
  110. // UniqueCode: edbClassify.UniqueCode,
  111. // SortColumn: int(edbClassify.Sort),
  112. // }
  113. //
  114. // return
  115. //}
  116. // 数据信息
  117. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_") {
  118. // 计算指标不处理
  119. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_calculate") {
  120. return
  121. }
  122. // 预测指标不处理
  123. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_predict") {
  124. return
  125. }
  126. var edbData *data_manage.EdbData
  127. err = json.Unmarshal([]byte(data), &edbData)
  128. if err != nil {
  129. return
  130. }
  131. edbSource, ok := data_manage.EdbTableNameSourceMap[edbUpdateLog.OpTableName]
  132. if !ok {
  133. // 没有找到来源,那就过滤
  134. return
  135. }
  136. // 数据信息
  137. pushIndexValue = &PushIndexValueItemReq{
  138. Id: utils.MD5(fmt.Sprint(edbSource.EdbSourceId, "_", edbSource.SourceName, "_", edbData.EdbDataId)),
  139. IndexCode: fmt.Sprint(edbSource.EdbSourceId, "_", edbData.EdbCode),
  140. Value: fmt.Sprint(edbData.Value),
  141. BusinessDate: edbData.DataTime,
  142. CreateTime: edbData.CreateTime,
  143. UpdateTime: edbData.ModifyTime,
  144. Status: "1",
  145. }
  146. return
  147. }
  148. return
  149. }
  150. // handleDelete
  151. // @Description: 删除数据处理
  152. // @author: Roc
  153. // @datetime 2024-03-11 14:53:20
  154. // @param edbUpdateLog *data_manage.EdbUpdateLog
  155. // @return pushIndexData *PushIndexParamDataReq
  156. // @return pushEdbClassify *PushEdbClassifyItemReq
  157. // @return pushIndexValue *PushIndexValueItemReq
  158. // @return err error
  159. func handleDelete(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIndexParamDataReq, pushEdbClassify *PushEdbClassifyItemReq, pushIndexValue *PushIndexValueItemReq, err error) {
  160. data := edbUpdateLog.OldData
  161. //指标信息
  162. if edbUpdateLog.OpTableName == "edb_info" {
  163. var edbInfo *data_manage.EdbInfoItem
  164. err = json.Unmarshal([]byte(data), &edbInfo)
  165. if err != nil {
  166. return
  167. }
  168. // 预测指标不处理
  169. if edbInfo.EdbInfoType == 1 {
  170. return
  171. }
  172. // 计算指标不处理
  173. if edbInfo.EdbType == 2 {
  174. return
  175. }
  176. // 获取数据源中指标的基础信息
  177. origInfo := getOrigInfo(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbCode)
  178. // 指标信息
  179. pushIndexData = &PushIndexParamDataReq{
  180. SourceIndexCode: edbInfo.EdbCode,
  181. IndexCode: fmt.Sprint(edbInfo.Source, "_", edbInfo.EdbCode),
  182. IndexName: origInfo.EdbName,
  183. IndexShortName: edbInfo.EdbName,
  184. FrequenceName: edbInfo.Frequency,
  185. UnitName: edbInfo.Unit,
  186. AssetBeginDate: edbInfo.StartDate,
  187. AssetEndDate: edbInfo.EndDate,
  188. CreateUser: edbInfo.SysUserRealName,
  189. IndexCreateTime: edbInfo.CreateTime,
  190. UpdateUser: edbInfo.SysUserRealName,
  191. DetailUpdateTime: edbUpdateLog.CreateTime.Format(utils.FormatDateTime),
  192. IndexUpdateTime: edbInfo.ModifyTime,
  193. OrginSource: edbInfo.SourceName,
  194. OrginSysSource: origInfo.SourceName,
  195. SysSource: "产研平台",
  196. SourceType: getSourceType(edbInfo.Source),
  197. Status: 0,
  198. }
  199. // 指标与分类的关系信息
  200. pushEdbClassify = &PushEdbClassifyItemReq{
  201. Id: fmt.Sprint(edbInfo.EdbInfoId),
  202. ClassifyId: edbInfo.ClassifyId,
  203. IndexCode: fmt.Sprint(edbInfo.Source, "_", edbInfo.EdbCode),
  204. CreateTime: edbInfo.CreateTime,
  205. CreateUser: edbInfo.SysUserRealName,
  206. UpdateTime: edbInfo.ModifyTime,
  207. UpdateUser: edbInfo.SysUserRealName,
  208. }
  209. return
  210. }
  211. // 分类信息
  212. //if edbUpdateLog.OpTableName == "edb_classify" {
  213. // var edbClassify *data_manage.EdbClassify
  214. // err = json.Unmarshal([]byte(data), &edbClassify)
  215. // if err != nil {
  216. // return
  217. // }
  218. //
  219. // // 指标信息
  220. // pushClassify = PushClassifyItemReq{
  221. // ClassifyId: int(edbClassify.ClassifyID),
  222. // ClassifyType: int(edbClassify.ClassifyType),
  223. // ClassifyName: edbClassify.ClassifyName,
  224. // ParentId: int(edbClassify.ParentID),
  225. // HasData: int(edbClassify.HasData),
  226. // CreateTime: edbClassify.CreateTime.Format(utils.FormatDateTime),
  227. // UpdateTime: edbClassify.ModifyTime.Format(utils.FormatDateTime),
  228. // SysUserId: int(edbClassify.SysUserID),
  229. // SysUserRealName: edbClassify.SysUserRealName,
  230. // Level: int(edbClassify.Level),
  231. // UniqueCode: edbClassify.UniqueCode,
  232. // SortColumn: int(edbClassify.Sort),
  233. // }
  234. //
  235. // return
  236. //}
  237. // 数据信息
  238. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_") {
  239. // 计算指标不处理
  240. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_calculate") {
  241. return
  242. }
  243. // 预测指标不处理
  244. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_predict") {
  245. return
  246. }
  247. var edbData *data_manage.EdbData
  248. err = json.Unmarshal([]byte(data), &edbData)
  249. if err != nil {
  250. return
  251. }
  252. edbSource, ok := data_manage.EdbTableNameSourceMap[edbUpdateLog.OpTableName]
  253. if !ok {
  254. // 没有找到来源,那就过滤
  255. return
  256. }
  257. // 数据信息
  258. pushIndexValue = &PushIndexValueItemReq{
  259. Id: utils.MD5(fmt.Sprint(edbSource.EdbSourceId, "_", edbSource.SourceName, "_", edbData.EdbDataId)),
  260. IndexCode: fmt.Sprint(edbSource.EdbSourceId, "_", edbData.EdbCode),
  261. Value: fmt.Sprint(edbData.Value),
  262. BusinessDate: edbData.DataTime,
  263. CreateTime: edbData.CreateTime,
  264. UpdateTime: edbData.ModifyTime,
  265. Status: "0",
  266. }
  267. return
  268. }
  269. return
  270. }
  271. // handleUpdate
  272. // @Description: 更新数据处理
  273. // @author: Roc
  274. // @datetime 2024-03-11 14:53:35
  275. // @param edbUpdateLog *data_manage.EdbUpdateLog
  276. // @return pushIndexData *PushIndexParamDataReq
  277. // @return pushEdbClassify *PushEdbClassifyItemReq
  278. // @return pushIndexValue *PushIndexValueItemReq
  279. // @return err error
  280. func handleUpdate(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIndexParamDataReq, pushEdbClassify *PushEdbClassifyItemReq, pushIndexValue *PushIndexValueItemReq, err error) {
  281. oldData := edbUpdateLog.OldData
  282. newData := edbUpdateLog.NewData
  283. //指标信息
  284. if edbUpdateLog.OpTableName == "edb_info" {
  285. var oldEdbInfo *data_manage.EdbInfoItem
  286. err = json.Unmarshal([]byte(oldData), &oldEdbInfo)
  287. if err != nil {
  288. return
  289. }
  290. // 预测指标不处理
  291. if oldEdbInfo.EdbInfoType == 1 {
  292. return
  293. }
  294. // 计算指标不处理
  295. if oldEdbInfo.EdbType == 2 {
  296. return
  297. }
  298. var newEdbInfo *data_manage.EdbInfoItem
  299. err = json.Unmarshal([]byte(newData), &newEdbInfo)
  300. if err != nil {
  301. return
  302. }
  303. isUpdateEdbInfo := checkUpdateType(oldEdbInfo, newEdbInfo)
  304. // 指标信息
  305. if isUpdateEdbInfo {
  306. // 获取数据源中指标的基础信息
  307. origInfo := getOrigInfo(newEdbInfo.Source, newEdbInfo.SubSource, newEdbInfo.EdbCode)
  308. pushIndexData = &PushIndexParamDataReq{
  309. SourceIndexCode: newEdbInfo.EdbCode,
  310. IndexCode: fmt.Sprint(newEdbInfo.Source, "_", newEdbInfo.EdbCode),
  311. IndexName: origInfo.EdbName,
  312. IndexShortName: newEdbInfo.EdbName,
  313. FrequenceName: newEdbInfo.Frequency,
  314. UnitName: newEdbInfo.Unit,
  315. AssetBeginDate: newEdbInfo.StartDate,
  316. AssetEndDate: newEdbInfo.EndDate,
  317. CreateUser: newEdbInfo.SysUserRealName,
  318. IndexCreateTime: newEdbInfo.CreateTime,
  319. UpdateUser: newEdbInfo.SysUserRealName,
  320. DetailUpdateTime: getMaxModifyTime(newEdbInfo.Source, newEdbInfo.SubSource, newEdbInfo.EdbCode, edbUpdateLog.CreateTime.Format(utils.FormatDateTime)),
  321. IndexUpdateTime: newEdbInfo.ModifyTime,
  322. OrginSource: newEdbInfo.SourceName,
  323. OrginSysSource: origInfo.SourceName,
  324. SysSource: "产研平台",
  325. SourceType: getSourceType(newEdbInfo.Source),
  326. Status: 1,
  327. }
  328. }
  329. // 指标与分类的关系信息
  330. if oldEdbInfo.ClassifyId != newEdbInfo.ClassifyId {
  331. pushEdbClassify = &PushEdbClassifyItemReq{
  332. Id: fmt.Sprint(newEdbInfo.EdbInfoId),
  333. ClassifyId: newEdbInfo.ClassifyId,
  334. IndexCode: fmt.Sprint(newEdbInfo.Source, "_", newEdbInfo.EdbCode),
  335. CreateTime: newEdbInfo.CreateTime,
  336. CreateUser: newEdbInfo.SysUserRealName,
  337. UpdateTime: newEdbInfo.ModifyTime,
  338. UpdateUser: newEdbInfo.SysUserRealName,
  339. }
  340. }
  341. return
  342. }
  343. // 数据信息
  344. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_") {
  345. // 计算指标不处理
  346. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_calculate") {
  347. return
  348. }
  349. // 预测指标不处理
  350. if strings.HasPrefix(edbUpdateLog.OpTableName, "edb_data_predict") {
  351. return
  352. }
  353. var edbData *data_manage.EdbData
  354. err = json.Unmarshal([]byte(newData), &edbData)
  355. if err != nil {
  356. return
  357. }
  358. edbSource, ok := data_manage.EdbTableNameSourceMap[edbUpdateLog.OpTableName]
  359. if !ok {
  360. // 没有找到来源,那就过滤
  361. return
  362. }
  363. // 数据信息
  364. pushIndexValue = &PushIndexValueItemReq{
  365. Id: utils.MD5(fmt.Sprint(edbSource.EdbSourceId, "_", edbSource.SourceName, "_", edbData.EdbDataId)),
  366. IndexCode: fmt.Sprint(edbSource.EdbSourceId, "_", edbData.EdbCode),
  367. Value: fmt.Sprint(edbData.Value),
  368. BusinessDate: edbData.DataTime,
  369. CreateTime: edbData.CreateTime,
  370. UpdateTime: edbData.ModifyTime,
  371. Status: "1",
  372. }
  373. return
  374. }
  375. // 上面都没有匹配到的话,那就是数据源的
  376. return handleUpdateDataSource(edbUpdateLog)
  377. }
  378. // handleUpdateDataSource
  379. // @Description: 更新数据处理(数据源的基础数据)
  380. // @author: Roc
  381. // @datetime 2024-03-11 14:53:35
  382. // @param edbUpdateLog *data_manage.EdbUpdateLog
  383. // @return pushIndexData *PushIndexParamDataReq
  384. // @return pushEdbClassify *PushEdbClassifyItemReq
  385. // @return pushIndexValue *PushIndexValueItemReq
  386. // @return err error
  387. func handleUpdateDataSource(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIndexParamDataReq, pushEdbClassify *PushEdbClassifyItemReq, pushIndexValue *PushIndexValueItemReq, err error) {
  388. oldData := edbUpdateLog.OldData
  389. newData := edbUpdateLog.NewData
  390. isUpdateIndexInfo := false
  391. indexName := ``
  392. indexSourceName := ``
  393. source := 0
  394. edbCode := ``
  395. // 钢联
  396. if edbUpdateLog.OpTableName == "base_from_mysteel_chemical_index" {
  397. var oldEdbInfo *data_manage.BaseFromMysteelChemicalIndexItem
  398. err = json.Unmarshal([]byte(oldData), &oldEdbInfo)
  399. if err != nil {
  400. return
  401. }
  402. var newEdbInfo *data_manage.BaseFromMysteelChemicalIndexItem
  403. err = json.Unmarshal([]byte(newData), &newEdbInfo)
  404. if err != nil {
  405. return
  406. }
  407. if oldEdbInfo.IndexName != newEdbInfo.IndexName {
  408. isUpdateIndexInfo = true
  409. } else if oldEdbInfo.Source != newEdbInfo.Source {
  410. isUpdateIndexInfo = true
  411. }
  412. if isUpdateIndexInfo {
  413. indexName = newEdbInfo.IndexName
  414. indexSourceName = newEdbInfo.Source
  415. edbCode = newEdbInfo.IndexCode
  416. source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
  417. }
  418. } else if edbUpdateLog.OpTableName == "base_from_smm_index" {
  419. // 有色
  420. var oldEdbInfo *data_manage.BaseFromSmmIndexItem
  421. err = json.Unmarshal([]byte(oldData), &oldEdbInfo)
  422. if err != nil {
  423. return
  424. }
  425. var newEdbInfo *data_manage.BaseFromSmmIndexItem
  426. err = json.Unmarshal([]byte(newData), &newEdbInfo)
  427. if err != nil {
  428. return
  429. }
  430. if oldEdbInfo.IndexName != newEdbInfo.IndexName {
  431. isUpdateIndexInfo = true
  432. } else if oldEdbInfo.Interface != newEdbInfo.Interface {
  433. isUpdateIndexInfo = true
  434. }
  435. if isUpdateIndexInfo {
  436. indexName = newEdbInfo.IndexName
  437. indexSourceName = newEdbInfo.Interface
  438. edbCode = newEdbInfo.IndexCode
  439. source = utils.DATA_SOURCE_YS
  440. }
  441. }
  442. // 数据源的指标信息变更了
  443. if isUpdateIndexInfo {
  444. newEdbInfo, tmpErr := data_manage.GetEdbInfoItemByCodeAndSource(source, edbCode)
  445. if tmpErr != nil {
  446. if tmpErr.Error() != utils.ErrNoRow() {
  447. err = tmpErr
  448. return
  449. }
  450. return
  451. }
  452. pushIndexData = &PushIndexParamDataReq{
  453. SourceIndexCode: newEdbInfo.EdbCode,
  454. IndexCode: fmt.Sprint(newEdbInfo.Source, "_", newEdbInfo.EdbCode),
  455. IndexName: indexName,
  456. IndexShortName: newEdbInfo.EdbName,
  457. FrequenceName: newEdbInfo.Frequency,
  458. UnitName: newEdbInfo.Unit,
  459. AssetBeginDate: newEdbInfo.StartDate,
  460. AssetEndDate: newEdbInfo.EndDate,
  461. CreateUser: newEdbInfo.SysUserRealName,
  462. IndexCreateTime: newEdbInfo.CreateTime,
  463. UpdateUser: newEdbInfo.SysUserRealName,
  464. DetailUpdateTime: getMaxModifyTime(newEdbInfo.Source, newEdbInfo.SubSource, newEdbInfo.EdbCode, edbUpdateLog.CreateTime.Format(utils.FormatDateTime)),
  465. IndexUpdateTime: newEdbInfo.ModifyTime,
  466. OrginSource: newEdbInfo.SourceName,
  467. OrginSysSource: indexSourceName,
  468. SysSource: "产研平台",
  469. SourceType: getSourceType(newEdbInfo.Source),
  470. Status: 1,
  471. }
  472. }
  473. return
  474. }
  475. // getSourceType
  476. // @Description: 获取指标来源类型
  477. // @author: Roc
  478. // @datetime 2024-03-01 13:40:03
  479. // @param source int
  480. // @return string
  481. func getSourceType(source int) string {
  482. switch source {
  483. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS, utils.DATA_SOURCE_BAIINFO, utils.DATA_SOURCE_SCI: //钢联,有色,百川盈孚,红桃3
  484. return "RPA"
  485. case utils.DATA_SOURCE_MANUAL:
  486. return "手工"
  487. default:
  488. return "接口"
  489. }
  490. }
  491. // checkUpdateType
  492. // @Description: 检查指标更新状态
  493. // @author: Roc
  494. // @datetime 2024-03-11 16:35:22
  495. // @param oldEdbInfo *data_manage.EdbInfoItem
  496. // @param newEdbInfo *data_manage.EdbInfoItem
  497. // @return isUpdateEdbInfo bool
  498. func checkUpdateType(oldEdbInfo, newEdbInfo *data_manage.EdbInfoItem) (isUpdateEdbInfo bool) {
  499. // eta内部名称
  500. if oldEdbInfo.EdbName != newEdbInfo.EdbName {
  501. isUpdateEdbInfo = true
  502. return
  503. }
  504. if oldEdbInfo.Frequency != newEdbInfo.Frequency {
  505. isUpdateEdbInfo = true
  506. return
  507. }
  508. if oldEdbInfo.Unit != newEdbInfo.Unit {
  509. isUpdateEdbInfo = true
  510. return
  511. }
  512. if oldEdbInfo.StartDate != newEdbInfo.StartDate {
  513. isUpdateEdbInfo = true
  514. return
  515. }
  516. if oldEdbInfo.EndDate != newEdbInfo.EndDate {
  517. isUpdateEdbInfo = true
  518. return
  519. }
  520. if oldEdbInfo.SysUserId != newEdbInfo.SysUserId {
  521. isUpdateEdbInfo = true
  522. return
  523. }
  524. if oldEdbInfo.SysUserRealName != newEdbInfo.SysUserRealName {
  525. isUpdateEdbInfo = true
  526. return
  527. }
  528. return
  529. }
  530. // OrigInfo
  531. // @Description: 数据源中的指标基础信息
  532. type OrigInfo struct {
  533. EdbName string
  534. SourceName string
  535. }
  536. // getOrigInfo
  537. // @Description: 获取数据源中的指标基础信息
  538. // @author: Roc
  539. // @datetime 2024-03-11 16:45:34
  540. // @param source int
  541. // @param subSource int
  542. // @param edbCode string
  543. // @return origInfo OrigInfo
  544. func getOrigInfo(source, subSource int, edbCode string) (origInfo OrigInfo) {
  545. switch source {
  546. case utils.DATA_SOURCE_THS, utils.DATA_SOURCE_WIND: // 同花顺、wind
  547. origInfo.SourceName = "经济数据库"
  548. if subSource == utils.DATA_SUB_SOURCE_DATE {
  549. origInfo.SourceName = "日期序列"
  550. }
  551. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
  552. edbInfo, err := data_manage.GetBaseFromMysteelChemicalIndexItemByCode(edbCode)
  553. if err != nil {
  554. return
  555. }
  556. origInfo.EdbName = edbInfo.IndexName
  557. origInfo.SourceName = edbInfo.Source
  558. // 钢联化工
  559. case utils.DATA_SOURCE_YS: // 有色
  560. edbInfo, err := data_manage.GetBaseFromSmmIndexItemItemByCode(edbCode)
  561. if err != nil {
  562. return
  563. }
  564. origInfo.EdbName = edbInfo.IndexName
  565. origInfo.SourceName = edbInfo.Interface
  566. }
  567. return
  568. }
  569. // getMaxModifyTime
  570. // @Description: 获取eta指标明细中的指标最大修改时间
  571. // @author: Roc
  572. // @datetime 2024-03-11 17:10:28
  573. // @param source int
  574. // @param edbCode string
  575. // @param addUpdateTime string
  576. // @return modifyTime string
  577. func getMaxModifyTime(source, subSource int, edbCode, addUpdateTime string) (modifyTime string) {
  578. modifyTime, err := data_manage.GetEdbInfoMaxModifyTime(source, subSource, edbCode)
  579. if err != nil {
  580. modifyTime = addUpdateTime
  581. return
  582. }
  583. return
  584. }