common.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package models
  2. import "eta/eta_index_lib/utils"
  3. // BaseEdbInfoInterface 基础指标接口
  4. type BaseEdbInfoInterface interface {
  5. Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, err error, errMsg string)
  6. Edit(params EditCalculateBatchParams) (err error, errMsg string)
  7. Refresh(params RefreshParams) (err error, errMsg string)
  8. GetSource() int
  9. GetSourceName() string
  10. GetEdbType() int
  11. }
  12. // AddCalculateBatchParams 添加的请求参
  13. type AddCalculateBatchParams struct {
  14. Req *EdbInfoCalculateBatchSaveReq
  15. FromEdbInfo *EdbInfo
  16. EdbCode string
  17. UniqueCode string
  18. SysUserId int
  19. SysUserRealName string
  20. }
  21. // EditCalculateBatchParams 编辑的请求参
  22. type EditCalculateBatchParams struct {
  23. Req *EdbInfoCalculateBatchEditReq
  24. EdbInfo *EdbInfo
  25. FromEdbInfo *EdbInfo
  26. }
  27. // RefreshParams 编辑的请求参
  28. type RefreshParams struct {
  29. EdbInfo *EdbInfo
  30. FromEdbInfo *EdbInfo
  31. StartDate string
  32. EndDate string
  33. }
  34. // GetBaseEdbInfoModel 获取普通指标的model
  35. func GetBaseEdbInfoModel(source int) (baseEdbInfoModel BaseEdbInfoInterface) {
  36. switch source {
  37. case utils.DATA_SOURCE_CALCULATE_LJZZJ:
  38. baseEdbInfoModel = Ljzzj{}
  39. case utils.DATA_SOURCE_CALCULATE_LJZ:
  40. baseEdbInfoModel = Ljz{}
  41. case utils.DATA_SOURCE_CALCULATE_LJZNCZJ:
  42. baseEdbInfoModel = LjzNczj{}
  43. case utils.DATA_SOURCE_CALCULATE_STANDARD_DEVIATION:
  44. baseEdbInfoModel = StandardDeviation{}
  45. case utils.DATA_SOURCE_CALCULATE_PERCENTILE:
  46. baseEdbInfoModel = Percentile{}
  47. case utils.DATA_SOURCE_CALCULATE_ZSXY:
  48. baseEdbInfoModel = ExponentialSmoothing{}
  49. case utils.DATA_SOURCE_CALCULATE_ZDYFX:
  50. baseEdbInfoModel = CustomAnalysis{}
  51. case utils.DATA_SOURCE_CALCULATE_SUM:
  52. baseEdbInfoModel = CalculateSum{}
  53. case utils.DATA_SOURCE_CALCULATE_AVG:
  54. baseEdbInfoModel = CalculateAvg{}
  55. default:
  56. }
  57. return
  58. }
  59. // BatchSaveCalculateBatchParams 编辑的请求参
  60. type BatchSaveCalculateBatchParams struct {
  61. Req EdbInfoCalculateBatchSaveReq
  62. EdbInfo *EdbInfo
  63. FromEdbInfo *EdbInfo
  64. EdbCode string
  65. UniqueCode string
  66. SysUserId int
  67. SysUserRealName string
  68. }
  69. // BasePredictEdbInfoInterface 基础指标接口
  70. type BasePredictEdbInfoInterface interface {
  71. Add(params BatchSaveCalculateBatchParams) (edbInfo *EdbInfo, latestDateStr string, latestValue float64, err error, errMsg string)
  72. Edit(params BatchSaveCalculateBatchParams) (latestDateStr string, latestValue float64, err error, errMsg string)
  73. Refresh(params RefreshParams) (latestDateStr string, latestValue float64, err error, errMsg string)
  74. GetSourceName() string
  75. }
  76. // GetBasePredictEdbInfoModel 获取预测指标的model
  77. func GetBasePredictEdbInfoModel(source int) (baseEdbInfoModel BasePredictEdbInfoInterface) {
  78. switch source {
  79. case utils.DATA_SOURCE_PREDICT_CALCULATE_TBZ:
  80. baseEdbInfoModel = PredictTb{}
  81. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZJ:
  82. baseEdbInfoModel = PredictLjzzj{}
  83. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZ:
  84. baseEdbInfoModel = PredictLjz{}
  85. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZNCZJ:
  86. baseEdbInfoModel = PredictLjzNczj{}
  87. case utils.DATA_SOURCE_PREDICT_CALCULATE_STANDARD_DEVIATION:
  88. baseEdbInfoModel = PredictStandardDeviation{}
  89. case utils.DATA_SOURCE_PREDICT_CALCULATE_PERCENTILE:
  90. baseEdbInfoModel = PredictPercentile{}
  91. case utils.DATA_SOURCE_PREDICT_CALCULATE_ZSXY:
  92. baseEdbInfoModel = PredictExponentialSmoothing{}
  93. default:
  94. }
  95. return
  96. }