common.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package models
  2. import "eta_gn/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. case utils.DATA_SOURCE_CALCULATE_RANGEANLYSIS:
  56. baseEdbInfoModel = CalculateRangeAnalysis{}
  57. default:
  58. }
  59. return
  60. }
  61. // BatchSaveCalculateBatchParams 编辑的请求参
  62. type BatchSaveCalculateBatchParams struct {
  63. Req EdbInfoCalculateBatchSaveReq
  64. EdbInfo *EdbInfo
  65. FromEdbInfo *EdbInfo
  66. EdbCode string
  67. UniqueCode string
  68. SysUserId int
  69. SysUserRealName string
  70. Lang string
  71. }
  72. // BasePredictEdbInfoInterface 基础指标接口
  73. type BasePredictEdbInfoInterface interface {
  74. Add(params BatchSaveCalculateBatchParams) (edbInfo *EdbInfo, latestDateStr string, latestValue float64, err error, errMsg string)
  75. Edit(params BatchSaveCalculateBatchParams) (latestDateStr string, latestValue float64, err error, errMsg string)
  76. Refresh(params RefreshParams) (latestDateStr string, latestValue float64, err error, errMsg string)
  77. GetSourceName() string
  78. }
  79. // GetBasePredictEdbInfoModel 获取预测指标的model
  80. func GetBasePredictEdbInfoModel(source int) (baseEdbInfoModel BasePredictEdbInfoInterface) {
  81. switch source {
  82. case utils.DATA_SOURCE_PREDICT_CALCULATE_TBZ:
  83. baseEdbInfoModel = PredictTb{}
  84. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZJ:
  85. baseEdbInfoModel = PredictLjzzj{}
  86. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZ:
  87. baseEdbInfoModel = PredictLjz{}
  88. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZNCZJ:
  89. baseEdbInfoModel = PredictLjzNczj{}
  90. case utils.DATA_SOURCE_PREDICT_CALCULATE_STANDARD_DEVIATION:
  91. baseEdbInfoModel = PredictStandardDeviation{}
  92. case utils.DATA_SOURCE_PREDICT_CALCULATE_PERCENTILE:
  93. baseEdbInfoModel = PredictPercentile{}
  94. case utils.DATA_SOURCE_PREDICT_CALCULATE_ZSXY:
  95. baseEdbInfoModel = PredictExponentialSmoothing{}
  96. case utils.DATA_SOURCE_PREDICT_CALCULATE_RANGEANLYSIS:
  97. baseEdbInfoModel = PredictCalculateRangeAnalysis{}
  98. default:
  99. }
  100. return
  101. }