edb_info_calculate.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. package data_manage
  2. import (
  3. "fmt"
  4. "strings"
  5. "time"
  6. "github.com/beego/beego/v2/client/orm"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. )
  9. type EdbInfoCalculateSaveReq struct {
  10. EdbName string `description:"指标名称"`
  11. Frequency string `description:"频率"`
  12. Unit string `description:"单位"`
  13. ClassifyId int `description:"分类id"`
  14. CalculateFormula string `description:"计算公式"`
  15. Calendar string `description:"公历/农历"`
  16. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  17. MaxEmptyType int `description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
  18. Extra string `description:"指标的额外配置"`
  19. EdbInfoIdArr []EdbInfoFromTag `description:"指标信息"`
  20. }
  21. // EdbInfoFromTag 计算指标的关联指标
  22. type EdbInfoFromTag struct {
  23. EdbInfoId int `description:"指标id"`
  24. FromTag string `description:"指标对应标签"`
  25. MoveValue int `description:"移动的值"`
  26. }
  27. type EdbInfoCalculate struct {
  28. EdbInfoCalculateId int `orm:"column(edb_info_calculate_id);pk"`
  29. EdbInfoId int `description:"指标id"`
  30. EdbCode string `description:"指标编码"`
  31. FromEdbInfoId int `description:"计算指标id"`
  32. FromEdbCode string `description:"计算指标编码"`
  33. FromEdbName string `description:"计算指标名称"`
  34. FromSource int `description:"计算指标来源"`
  35. FromSourceName string `description:"计算指标来源名称"`
  36. FromTag string `description:"来源指标标签"`
  37. Sort int `description:"计算指标名称排序"`
  38. CreateTime time.Time `description:"创建时间"`
  39. ModifyTime time.Time `description:"修改时间"`
  40. }
  41. func AddEdbInfoCalculateMulti(items []*EdbInfoCalculate) (err error) {
  42. o := orm.NewOrmUsingDB("data")
  43. _, err = o.InsertMulti(1, items)
  44. return
  45. }
  46. type FromEdbInfoData struct {
  47. EdbInfoId int `description:"指标id"`
  48. EdbName string `description:"指标名称"`
  49. DataList []*EdbInfoSearchData
  50. }
  51. type EdbInfoCalculateDetail struct {
  52. EdbInfoCalculateId int `orm:"column(edb_info_calculate_id);pk"`
  53. EdbInfoId int `description:"指标id"`
  54. EdbCode string `description:"指标编码"`
  55. FromEdbInfoId int `description:"计算指标id"`
  56. FromEdbCode string `description:"计算指标编码"`
  57. FromEdbName string `description:"计算指标名称"`
  58. FromEdbNameEn string `description:"计算指标名称"`
  59. FromSource int `description:"计算指标来源"`
  60. FromSourceName string `description:"计算指标来源名称"`
  61. FromTag string `description:"来源指标标签"`
  62. MoveValue int `description:"移动的值,小于0是提前,0是不变,大于0是滞后"`
  63. Sort int `description:"计算指标名称排序"`
  64. CreateTime time.Time `description:"创建时间"`
  65. ModifyTime time.Time `description:"修改时间"`
  66. StartDate string `description:"开始日期"`
  67. EndDate string `description:"结束日期"`
  68. LatestDate string `description:"实际的结束日期"`
  69. LatestValue float64 `description:"最近实际数据的值"`
  70. EndValue float64 `description:"结束日期的值(可能是插入值)"`
  71. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  72. Frequency string `description:"频率"`
  73. Unit string `description:"单位"`
  74. ClassifyId int `description:"分类id"`
  75. }
  76. func GetEdbInfoCalculateDetail(edbInfoId, source int) (list []*EdbInfoCalculateDetail, err error) {
  77. o := orm.NewOrmUsingDB("data")
  78. //calculateTableName := GetEdbInfoCalculateTableName(source)
  79. //sql := ` SELECT a.*,b.start_date,b.end_date,b.edb_type FROM %s AS a
  80. // INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  81. // WHERE a.edb_info_id=? ORDER BY sort ASC `
  82. //
  83. //sql = fmt.Sprintf(sql, calculateTableName)
  84. sql := ` SELECT a.edb_info_calculate_mapping_id,a.edb_info_id,a.source,a.source_name,a.edb_code,a.from_edb_info_id,a.from_edb_code,a.from_source,a.from_source_name,a.sort,a.create_time,a.modify_time,a.from_tag,a.move_value,b.edb_name as from_edb_name,b.edb_name_en as from_edb_name_en,b.start_date,b.end_date,b.latest_date,b.latest_value,b.edb_type, b.frequency, b.unit, b.classify_id FROM edb_info_calculate_mapping AS a
  85. INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  86. WHERE a.edb_info_id=? ORDER BY sort ASC `
  87. _, err = o.Raw(sql, edbInfoId).QueryRows(&list)
  88. return
  89. }
  90. type CalculateDetailResp struct {
  91. EdbInfoDetail *EdbInfoFullClassify
  92. CalculateList []*EdbInfoCalculateDetail
  93. }
  94. type EdbInfoCalculateEditReq struct {
  95. EdbInfoId int `description:"指标id"`
  96. EdbName string `description:"指标名称"`
  97. Frequency string `description:"频率"`
  98. Unit string `description:"单位"`
  99. ClassifyId int `description:"分类id"`
  100. CalculateFormula string `description:"计算公式"`
  101. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  102. MaxEmptyType int `description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
  103. Extra string `description:"指标的额外配置"`
  104. EdbInfoIdArr []EdbInfoFromTag `description:"指标信息"`
  105. }
  106. func GetCalculateEdbInfo(edbInfoId int) (from_edb_info_id string, err error) {
  107. o := orm.NewOrmUsingDB("data")
  108. sql := ` SELECT GROUP_CONCAT(from_edb_info_id ORDER BY sort ASC SEPARATOR ',') AS from_edb_info_id
  109. FROM edb_info_calculate_mapping
  110. WHERE edb_info_id=?
  111. GROUP BY edb_info_id
  112. `
  113. err = o.Raw(sql, edbInfoId).QueryRow(&from_edb_info_id)
  114. return
  115. }
  116. func DeleteCalculateEdbInfo(edbInfoId int) (err error) {
  117. o := orm.NewOrmUsingDB("data")
  118. to, err := o.Begin()
  119. if err != nil {
  120. return
  121. }
  122. defer func() {
  123. if err != nil {
  124. _ = to.Rollback()
  125. } else {
  126. _ = to.Commit()
  127. }
  128. }()
  129. sql := `DELETE FROM edb_data_calculate WHERE edb_info_id=?`
  130. _, err = to.Raw(sql, edbInfoId).Exec()
  131. if err != nil {
  132. return
  133. }
  134. sql = `DELETE FROM edb_info_calculate_mapping WHERE edb_info_id=?`
  135. _, err = to.Raw(sql, edbInfoId).Exec()
  136. return
  137. }
  138. func DeleteCalculateData(edbInfoId int) (err error) {
  139. o := orm.NewOrmUsingDB("data")
  140. sql := `DELETE FROM edb_data_calculate WHERE edb_info_id=?`
  141. _, err = o.Raw(sql, edbInfoId).Exec()
  142. return
  143. }
  144. type EdbInfoBase struct {
  145. EdbInfoId int `description:"指标id"`
  146. EdbName string `description:"指标名称"`
  147. EdbNameEn string `description:"英文指标名称"`
  148. Frequency string `description:"频度"`
  149. Unit string `description:"单位"`
  150. UnitEn string `description:"英文单位"`
  151. ClassifyId int `description:"分类id"`
  152. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  153. EdbInfoType int `description:"指标类型: 0-普通指标; 1-预测指标"`
  154. }
  155. type CalculateEdbInfoItem struct {
  156. EdbInfoId int `description:"指标id"`
  157. EdbName string `description:"指标名称"`
  158. Frequency string `description:"频度"`
  159. Unit string `description:"单位"`
  160. ClassifyId int `description:"分类id"`
  161. CalculateId string `description:"当前请求时,单个计算的唯一标识"`
  162. FromEdbInfoId int `description:"计算来源指标id"`
  163. }
  164. type EdbInfoCalculateBatchSaveMultiReq struct {
  165. List []CalculateEdbInfoItem
  166. Formula string `description:"N值/移动天数"`
  167. FromEdbInfoId int `description:"计算来源指标id"`
  168. Source int `description:"来源:1:同花顺,2:wind,3:彭博,4:指标运算,5:累计值转月,6:同比值,7:同差值,8:N数值移动平均计算,12:环比值,13:环差值,14:变频"`
  169. CalculateFormula string `description:"计算公式"`
  170. EdbInfoIdArr []EdbInfoFromTag `description:"指标信息"`
  171. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  172. MoveFrequency string `description:"移动频度:天/周/月/季/年"`
  173. Extra string `description:"指标的额外配置"`
  174. Calendar string `description:"公历/农历"`
  175. }
  176. type EdbInfoCalculateBatchSaveReq struct {
  177. EdbInfoId int `description:"指标id"`
  178. EdbName string `description:"指标名称"`
  179. Frequency string `description:"频度"`
  180. Unit string `description:"单位"`
  181. ClassifyId int `description:"分类id"`
  182. Formula string `description:"N值/移动天数"`
  183. FromEdbInfoId int `description:"计算来源指标id"`
  184. Source int `description:"来源:1:同花顺,2:wind,3:彭博,4:指标运算,5:累计值转月,6:同比值,7:同差值,8:N数值移动平均计算,12:环比值,13:环差值,14:变频"`
  185. CalculateFormula string `description:"计算公式"`
  186. EdbInfoIdArr []EdbInfoFromTag `description:"指标信息"`
  187. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  188. MoveFrequency string `description:"移动频度:天/周/月/季/年"`
  189. Extra string `description:"指标的额外配置"`
  190. Calendar string `description:"公历/农历"`
  191. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  192. }
  193. type EdbInfoCalculateBatchEditReq struct {
  194. EdbName string `description:"指标名称"`
  195. Frequency string `description:"频度"`
  196. Unit string `description:"单位"`
  197. ClassifyId int `description:"分类id"`
  198. Formula string `description:"N值"`
  199. EdbInfoId int `description:"编辑指标id"`
  200. FromEdbInfoId int `description:"计算来源指标id"`
  201. Source int `description:"来源:1:同花顺,2:wind,3:彭博,4:指标运算,5:累计值转月,6:同比值,7:同差值,8:N数值移动平均计算,12:环比值,13:环差值,14:变频"`
  202. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  203. MoveFrequency string `description:"移动频度:天/周/月/季/年"`
  204. Calendar string `description:"公历/农历"`
  205. Extra string `description:"指标的额外配置"`
  206. EdbInfoIdArr []EdbInfoFromTag
  207. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  208. }
  209. // EdbInfoCalculateBatchSaveReqByEdbLib edb指标库的请求逻辑
  210. type EdbInfoCalculateBatchSaveReqByEdbLib struct {
  211. AdminId int `description:"添加人id"`
  212. AdminName string `description:"添加人名称"`
  213. EdbInfoId int `description:"指标id"`
  214. EdbName string `description:"指标名称"`
  215. Frequency string `description:"频度"`
  216. Unit string `description:"单位"`
  217. ClassifyId int `description:"分类id"`
  218. Formula string `description:"N值/移动天数"`
  219. FromEdbInfoId int `description:"计算来源指标id"`
  220. Source int `description:"来源:1:同花顺,2:wind,3:彭博,4:指标运算,5:累计值转月,6:同比值,7:同差值,8:N数值移动平均计算,12:环比值,13:环差值,14:变频"`
  221. CalculateFormula string `description:"计算公式"`
  222. EdbInfoIdArr []EdbInfoFromTag `description:"指标信息"`
  223. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  224. MoveFrequency string `description:"移动频度:天/周/月/季/年"`
  225. Calendar string `description:"公历/农历"`
  226. Data interface{} `description:"数据列"`
  227. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  228. MaxEmptyType int `description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
  229. Extra string `description:"指标的额外配置"`
  230. }
  231. // EdbInfoCalculateBatchEditReqByEdbLib 编辑计算指标的请求参数
  232. type EdbInfoCalculateBatchEditReqByEdbLib struct {
  233. EdbName string `description:"指标名称"`
  234. Frequency string `description:"频度"`
  235. Unit string `description:"单位"`
  236. ClassifyId int `description:"分类id"`
  237. AdminId int `description:"操作人id"`
  238. AdminName string `description:"操作人姓名"`
  239. Formula string `description:"N值"`
  240. EdbInfoId int `description:"编辑指标id"`
  241. FromEdbInfoId int `description:"计算来源指标id"`
  242. Source int `description:"来源:1:同花顺,2:wind,3:彭博,4:指标运算,5:累计值转月,6:同比值,7:同差值,8:N数值移动平均计算,12:环比值,13:环差值,14:变频"`
  243. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  244. MoveFrequency string `description:"移动频度:天/周/月/季/年"`
  245. Calendar string `description:"公历/农历"`
  246. EdbInfoIdArr []EdbInfoFromTag
  247. Data interface{} `description:"数据列"`
  248. Extra string `description:"指标的额外配置"`
  249. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  250. CalculateFormula string `description:"计算公式"`
  251. }
  252. func GetEdbInfoCalculateMap(edbInfoId, source int) (list []*EdbInfo, err error) {
  253. o := orm.NewOrmUsingDB("data")
  254. //calculateTableName := GetEdbInfoCalculateTableName(source)
  255. //sql := ` SELECT b.* FROM %s AS a
  256. // INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  257. // WHERE a.edb_info_id=? ORDER BY sort ASC `
  258. //sql = fmt.Sprintf(sql, calculateTableName)
  259. sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
  260. INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  261. WHERE a.edb_info_id=? ORDER BY sort ASC `
  262. _, err = o.Raw(sql, edbInfoId).QueryRows(&list)
  263. return
  264. }
  265. type CalculateItems struct {
  266. EdbInfoId int
  267. DataMap map[string]float64
  268. }
  269. func CheckFormula(formula string) map[string]string {
  270. mathFormula := []string{"MAX", "MIN", "ABS", "ACOS", "ASIN", "CEIL", "MOD", "POW", "ROUND", "SIGN", "SIN", "TAN", "LOG10", "LOG2", "LOG", "LN"}
  271. str := strings.ToUpper(formula)
  272. for _, v := range mathFormula {
  273. str = strings.Replace(str, v, "", -1)
  274. }
  275. str = strings.Replace(str, "(", "", -1)
  276. str = strings.Replace(str, ")", "", -1)
  277. byteMap := make(map[string]string)
  278. for i := 0; i < len(str); i++ {
  279. byteInt := str[i]
  280. if byteInt >= 65 && byteInt <= 90 {
  281. byteStr := string(byteInt)
  282. if _, ok := byteMap[byteStr]; !ok {
  283. byteMap[byteStr] = byteStr
  284. }
  285. }
  286. }
  287. return byteMap
  288. }
  289. func ReplaceFormula(edbInfoIdArr []*EdbInfo, valArr map[int]float64, formulaMap map[string]string, formulaStr string, edbInfoIdBytes []string) string {
  290. funMap := GetFormulaMap()
  291. for k, v := range funMap {
  292. formulaStr = strings.Replace(formulaStr, k, v, -1)
  293. }
  294. replaceCount := 0
  295. for dk, dv := range edbInfoIdArr {
  296. if dk == 0 {
  297. dKey := edbInfoIdBytes[dk]
  298. if _, ok := formulaMap[dKey]; ok { //公式中存在
  299. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  300. dvStr := fmt.Sprintf("%v", val)
  301. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  302. replaceCount++
  303. }
  304. }
  305. }
  306. if dk == 1 {
  307. dKey := edbInfoIdBytes[dk]
  308. if _, ok := formulaMap[dKey]; ok { //公式中存在
  309. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  310. dvStr := fmt.Sprintf("%v", val)
  311. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  312. replaceCount++
  313. }
  314. }
  315. }
  316. if dk == 2 {
  317. dKey := edbInfoIdBytes[dk]
  318. if _, ok := formulaMap[dKey]; ok { //公式中存在
  319. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  320. dvStr := fmt.Sprintf("%v", val)
  321. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  322. replaceCount++
  323. }
  324. }
  325. }
  326. if dk == 3 {
  327. dKey := edbInfoIdBytes[dk]
  328. if _, ok := formulaMap[dKey]; ok { //公式中存在
  329. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  330. dvStr := fmt.Sprintf("%v", val)
  331. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  332. replaceCount++
  333. }
  334. }
  335. }
  336. if dk == 4 {
  337. dKey := edbInfoIdBytes[dk]
  338. if _, ok := formulaMap[dKey]; ok { //公式中存在
  339. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  340. dvStr := fmt.Sprintf("%v", val)
  341. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  342. replaceCount++
  343. }
  344. }
  345. }
  346. if dk == 5 {
  347. dKey := edbInfoIdBytes[dk]
  348. if _, ok := formulaMap[dKey]; ok { //公式中存在
  349. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  350. dvStr := fmt.Sprintf("%v", val)
  351. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  352. replaceCount++
  353. }
  354. }
  355. }
  356. if dk == 6 {
  357. dKey := edbInfoIdBytes[dk]
  358. if _, ok := formulaMap[dKey]; ok { //公式中存在
  359. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  360. dvStr := fmt.Sprintf("%v", val)
  361. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  362. replaceCount++
  363. }
  364. }
  365. }
  366. if dk == 7 {
  367. dKey := edbInfoIdBytes[dk]
  368. if _, ok := formulaMap[dKey]; ok { //公式中存在
  369. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  370. dvStr := fmt.Sprintf("%v", val)
  371. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  372. replaceCount++
  373. }
  374. }
  375. }
  376. if dk == 8 {
  377. dKey := edbInfoIdBytes[dk]
  378. if _, ok := formulaMap[dKey]; ok { //公式中存在
  379. if val, valOk := valArr[dv.EdbInfoId]; valOk { //值存在
  380. dvStr := fmt.Sprintf("%v", val)
  381. formulaStr = strings.Replace(formulaStr, dKey, dvStr, -1)
  382. replaceCount++
  383. }
  384. }
  385. }
  386. }
  387. for k, v := range funMap {
  388. formulaStr = strings.Replace(formulaStr, v, k, -1)
  389. }
  390. if replaceCount == len(formulaMap) {
  391. return formulaStr
  392. } else {
  393. return ""
  394. }
  395. }
  396. func GetFormulaMap() map[string]string {
  397. funMap := make(map[string]string)
  398. funMap["MAX"] = "[@@]"
  399. funMap["MIN"] = "[@!]"
  400. funMap["ABS"] = "[@#]"
  401. funMap["CEIL"] = "[@$]"
  402. funMap["COS"] = "[@%]"
  403. funMap["FLOOR"] = "[@^]"
  404. funMap["MOD"] = "[@&]"
  405. funMap["POW"] = "[@*]"
  406. funMap["ROUND"] = "[@(]"
  407. return funMap
  408. }
  409. // SaveAdjustEdbInfoReq 保存数据调整请求参数(请求指标服务)
  410. type SaveAdjustEdbInfoReq struct {
  411. AdminId int `description:"添加人id"`
  412. AdminName string `description:"添加人名称"`
  413. EdbInfoId int `description:"指标id"`
  414. FromEdbInfoId int `description:"来源指标id"`
  415. EdbName string `description:"指标名称"`
  416. Frequency string `description:"频度"`
  417. Unit string `description:"单位"`
  418. ClassifyId int `description:"分类id"`
  419. DataList []SaveAdjustEdbDataReq `description:"指标对应的数据值"`
  420. }
  421. // SaveAdjustEdbDataReq 保存数据调整请求的数据的参数
  422. type SaveAdjustEdbDataReq struct {
  423. Date string `description:"数据日期"`
  424. Value float64 `description:"数据值"`
  425. }
  426. // BatchEdbInfoCalculateBatchSaveReq 批量添加 计算指标
  427. type BatchEdbInfoCalculateBatchSaveReq struct {
  428. AdminId int `description:"添加人id"`
  429. AdminName string `description:"添加人名称"`
  430. EdbList []*CalculateEdbInfoItem //需要批量计算的指标列表
  431. Formula string `description:"N值/移动天数"`
  432. Source int `description:"来源:1:同花顺,2:wind,3:彭博,4:指标运算,5:累计值转月,6:同比值,7:同差值,8:N数值移动平均计算,12:环比值,13:环差值,14:升频"`
  433. CalculateFormula string `description:"计算公式"`
  434. EdbInfoIdArr []EdbInfoFromTag `description:"关联指标列表"`
  435. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  436. MoveFrequency string `description:"移动频度:天/周/月/季/年"`
  437. Calendar string `description:"公历/农历"`
  438. Data interface{} `description:"数据"`
  439. EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
  440. MaxEmptyType int `description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
  441. Extra string `description:"指标的额外配置"`
  442. }
  443. // BatchEdbInfoCalculateBatchSaveResp 批量添加 计算指标 返回数据
  444. type BatchEdbInfoCalculateBatchSaveResp struct {
  445. Fail []BatchEdbInfoCalculateBatchSaveFailResp `description:"添加失败的指标"`
  446. Success []BatchEdbInfoCalculateBatchSaveSuccessResp `description:"添加成功的指标"`
  447. }
  448. // BatchEdbInfoCalculateBatchSaveFailResp 添加失败的指标信息
  449. type BatchEdbInfoCalculateBatchSaveFailResp struct {
  450. CalculateId string `description:"当前请求时,单个计算的唯一标识"`
  451. Msg string `description:"用户提示信息"`
  452. ErrMsg string `description:"错误信息,内部查看"`
  453. }
  454. // BatchEdbInfoCalculateBatchSaveSuccessResp 添加成功的指标信息
  455. type BatchEdbInfoCalculateBatchSaveSuccessResp struct {
  456. ClassifyId int `description:"分类id"`
  457. CalculateId string `description:"当前请求时,单个计算的唯一标识"`
  458. EdbInfoId int `description:"指标ID"`
  459. UniqueCode string `description:"指标唯一编码"`
  460. }
  461. // CalculateMultiSearchReq 批量计算模块下的指标搜索
  462. type CalculateMultiChoiceReq struct {
  463. ClassifyIds string `description:"分类ID, 用英文逗号拼接"`
  464. Frequency string `description:"频度"`
  465. SysUserIds string `description:"创建人ID,用英文逗号拼接"`
  466. Keyword string `description:"关键字"`
  467. SelectAll bool `description:"是否全选"`
  468. EdbInfoIds string `description:"指标Id, 用英文逗号拼接"`
  469. }
  470. type CalculateMultiChoiceResp struct {
  471. SearchItem []EdbInfoBase `description:"查询结果"`
  472. }
  473. type CalculateMultiEdbSearchResp struct {
  474. SearchItem []CalculateMultiEdbSearchItem `description:"查询结果"`
  475. Paging *paging.PagingItem
  476. }
  477. type CalculateMultiEdbSearchItem struct {
  478. EdbInfoId int `description:"指标id"`
  479. EdbName string `description:"指标名称"`
  480. EdbNameEn string `description:"英文指标名称"`
  481. Frequency string `description:"频度"`
  482. Unit string `description:"单位"`
  483. UnitEn string `description:"英文单位"`
  484. ClassifyId int `description:"分类id"`
  485. SysUserId int
  486. SysUserRealName string
  487. EndValue float64 `description:"数据的最新值(预测日期的最新值)"`
  488. EndDate string `description:"终止日期"`
  489. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  490. EdbInfoType int `description:"指标类型: 0-普通指标; 1-预测指标"`
  491. }
  492. // BaseStepCalculateReq 指标库-基础分步骤计算请求
  493. type BaseStepCalculateReq struct {
  494. DataList []*EdbInfoSearchData
  495. Calculates []FactorEdbSeriesCalculatePars
  496. }