base_from_manual.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package services
  2. /*
  3. import (
  4. "errors"
  5. "eta/eta_index_lib/models"
  6. "eta/eta_index_lib/utils"
  7. )
  8. func AddEdbDataFromManual(edbCode string) (err error) {
  9. // 判断是否调用桥接服务
  10. var manualDataList []*models.ManualEdbdata
  11. url, _ := GetWindBridgeUrl()
  12. if url != "" {
  13. manualDataList, err = GetManualEdbDataFromBridgeJy(url, edbCode, "", "")
  14. if err != nil {
  15. return
  16. }
  17. // 设置指标与终端关系的缓存
  18. windUrlCacheKey := utils.CACHE_WIND_URL + ":" + edbCode
  19. _ = utils.Rc.SetNX(windUrlCacheKey, url, utils.GetTodayLastSecond())
  20. } else {
  21. var condition string
  22. var pars []interface{}
  23. if edbCode != "" {
  24. condition += " AND TRADE_CODE=? "
  25. pars = append(pars, edbCode)
  26. }
  27. manualDataList, err = models.GetEdbdataManualByCondition(condition, pars)
  28. if err != nil {
  29. return
  30. }
  31. }
  32. err = models.AddEdbDataFromManual(edbCode, manualDataList)
  33. return
  34. }
  35. func RefreshEdbDataFromManual(req models.RefreshEdbInfoReq, edbinfo *models.EdbInfo) (err error) {
  36. var manualDataList []*models.ManualEdbdata
  37. url, _ := GetManualBridgeJYUrl()
  38. if url != "" && edbinfo.ServerUrl == url {
  39. manualDataList, err = GetManualEdbDataFromBridgeJy(url, req.EdbCode, "", "")
  40. if err != nil {
  41. err = errors.New("查询桥接服务手工数据失败,Err:" + err.Error())
  42. return
  43. }
  44. } else {
  45. var condition string
  46. var pars []interface{}
  47. if req.EdbCode != "" {
  48. condition += " AND TRADE_CODE=? "
  49. pars = append(pars, req.EdbCode)
  50. }
  51. if req.StartDate != "" {
  52. condition += " AND DT>=? "
  53. pars = append(pars, req.StartDate)
  54. } else {
  55. condition += " AND DT != ? "
  56. pars = append(pars, `0000-00-00`)
  57. }
  58. manualDataList, err = models.GetEdbdataManualByCondition(condition, pars)
  59. if err != nil {
  60. err = errors.New("查询手工数据失败,Err:" + err.Error())
  61. return
  62. }
  63. }
  64. err = models.RefreshEdbDataFromManual(req.EdbInfoId, req.EdbCode, req.StartDate, manualDataList)
  65. if err != nil && err.Error() != utils.ErrNoRow() {
  66. err = errors.New("刷新指标信息失败 service RefreshEdbDataFromManual,Err:" + err.Error())
  67. return
  68. }
  69. return
  70. }
  71. */