chart.go 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. package models
  2. import (
  3. "errors"
  4. "eta/eta_chart_lib/models/mgo"
  5. "eta/eta_chart_lib/utils"
  6. "fmt"
  7. "strconv"
  8. "time"
  9. "github.com/beego/beego/v2/client/orm"
  10. "go.mongodb.org/mongo-driver/bson"
  11. "github.com/nosixtools/solarlunar"
  12. )
  13. type ChartInfo struct {
  14. ChartInfoId int `json:"-" orm:"column(chart_info_id);pk"`
  15. ChartName string `description:"来源名称"`
  16. ChartNameEn string `description:"英文图表名称"`
  17. ChartClassifyId int `json:"-" description:"图表分类id"`
  18. SysUserId int `json:"-"`
  19. SysUserRealName string `json:"-"`
  20. UniqueCode string `description:"图表唯一编码"`
  21. CreateTime time.Time `json:"-"`
  22. ModifyTime time.Time `json:"-"`
  23. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  24. StartDate string `description:"自定义开始日期"`
  25. EndDate string `description:"自定义结束日期"`
  26. IsSetName int `description:"设置名称"`
  27. EdbInfoIds string `description:"指标id"`
  28. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  29. Calendar string `description:"公历/农历"`
  30. SeasonStartDate string `description:"季节性图开始日期"`
  31. SeasonEndDate string `description:"季节性图开始日期"`
  32. ChartImage string `description:"图表图片"`
  33. BarConfig string `description:"柱方图的配置,json数据" json:"-"`
  34. XMin string `description:"图表X轴最小值"`
  35. XMax string `description:"图表X轴最大值"`
  36. LeftMin string `description:"图表左侧最小值"`
  37. LeftMax string `description:"图表左侧最大值"`
  38. RightMin string `description:"图表右侧最小值"`
  39. RightMax string `description:"图表右侧最大值"`
  40. Right2Min string `description:"图表右侧2最小值"`
  41. Right2Max string `description:"图表右侧2最大值"`
  42. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  43. Source int `description:"1:ETA图库;2:商品价格曲线"`
  44. UnitEn string `description:"英文图表单位"`
  45. Unit string `description:"图表单位"`
  46. ExtraConfig string `description:"图表额外配置,json数据" json:"-"`
  47. ChartSource string `description:"图表来源str"`
  48. ChartSourceEn string `description:"图表来源(英文)"`
  49. SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
  50. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  51. ChartThemeId int `description:"图表应用主题ID"`
  52. ChartThemeStyle string `description:"图表应用主题样式"`
  53. SourcesFrom string `description:"图表来源"`
  54. Instructions string `description:"图表说明"`
  55. MarkersLines string `description:"标识线"`
  56. MarkersAreas string `description:"标识区"`
  57. }
  58. func GetChartInfoByUniqueCode(uniqueCode string) (item *ChartInfo, err error) {
  59. o := orm.NewOrmUsingDB("data")
  60. sql := ` SELECT * FROM chart_info WHERE unique_code=? `
  61. err = o.Raw(sql, uniqueCode).QueryRow(&item)
  62. return
  63. }
  64. type ChartEdbInfoMapping struct {
  65. EdbInfoId int `description:"指标id"`
  66. SourceName string `description:"来源名称"`
  67. Source int `description:"来源id"`
  68. EdbCode string `description:"指标编码"`
  69. EdbName string `description:"指标名称"`
  70. EdbAliasName string `description:"指标名称(别名)"`
  71. EdbAliasNameEn string `description:"英文指标名称(别名)"`
  72. EdbNameEn string `description:"英文指标名称"`
  73. Frequency string `description:"频率"`
  74. FrequencyEn string `description:"英文频率"`
  75. Unit string `description:"单位"`
  76. UnitEn string `description:"英文单位"`
  77. StartDate string `description:"起始日期"`
  78. EndDate string `description:"终止日期"`
  79. ModifyTime string `description:"指标最后更新时间"`
  80. ChartEdbMappingId int `description:"图表指标id" json:"-"`
  81. ChartInfoId int `description:"图表id"`
  82. MaxData float64 `description:"上限"`
  83. MinData float64 `description:"下限"`
  84. IsOrder bool `description:"true:正序,false:逆序"`
  85. IsAxis int `description:"1:左轴,0:右轴"`
  86. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  87. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  88. LeadValue int `description:"领先值"`
  89. LeadUnit string `description:"领先单位"`
  90. LeadUnitEn string `description:"领先英文单位"`
  91. ChartStyle string `description:"图表类型"`
  92. ChartColor string `description:"颜色"`
  93. ChartWidth float64 `description:"线条大小"`
  94. DataList interface{}
  95. EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
  96. PredictChartColor string `description:"预测数据的颜色"`
  97. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图"`
  98. LatestDate string `description:"数据最新日期"`
  99. LatestValue float64 `description:"数据最新值"`
  100. MoveLatestDate string `description:"移动后的数据最新日期"`
  101. UniqueCode string `description:"指标唯一编码"`
  102. MinValue float64 `json:"-" description:"最小值"`
  103. MaxValue float64 `json:"-" description:"最大值"`
  104. IsNullData bool `json:"-" description:"是否空数据"`
  105. MappingSource int `description:"1:ETA图库;2:商品价格曲线"`
  106. SubSource int `description:"子数据来源:0:经济数据库,1:日期序列"`
  107. SubSourceName string `description:"子数据来源名称"`
  108. IndicatorCode string `description:"指标代码"`
  109. StockCode string `description:"证券代码"`
  110. IsConvert int `description:"是否数据转换 0不转 1转"`
  111. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  112. ConvertValue float64 `description:"数据转换值"`
  113. ConvertUnit string `description:"数据转换单位"`
  114. ConvertEnUnit string `description:"数据转换单位"`
  115. ClassifyId int `description:"分类id"`
  116. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  117. }
  118. func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
  119. o := orm.NewOrmUsingDB("data")
  120. aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source,a.edb_alias_name`
  121. sql := ` SELECT ` + aField + `,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.edb_type,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.sub_source,
  122. a.is_convert, a.convert_type, a.convert_value, a.convert_unit, a.convert_en_unit
  123. FROM chart_edb_mapping AS a
  124. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  125. WHERE chart_info_id=?
  126. ORDER BY chart_edb_mapping_id ASC `
  127. _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
  128. return
  129. }
  130. type EdbDataList struct {
  131. EdbDataId int `json:"-" description:" 指标数据ID"`
  132. EdbInfoId int `json:"-" description:"指标ID"`
  133. DataTime string `description:"数据日期"`
  134. DataTimestamp int64 `description:"数据日期"`
  135. Value float64 `description:"数据值"`
  136. }
  137. // GetEdbDataList 获取指标的数据(日期正序返回)
  138. func GetEdbDataList(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
  139. // 自有数据需要额外处理(从mongo获取)
  140. if source == utils.DATA_SOURCE_BUSINESS && utils.UseMongo {
  141. return getEdbDataListByMongo(source, subSource, edbInfoId, startDate, endDate)
  142. }
  143. if source == utils.DATA_SOURCE_THS && subSource == utils.DATA_SUB_SOURCE_HIGH_FREQUENCY && utils.UseMongo {
  144. return getThsHfEdbDataListByMongo(source, subSource, edbInfoId, startDate, endDate)
  145. }
  146. return getEdbDataListByMysql(source, subSource, edbInfoId, startDate, endDate)
  147. }
  148. // getEdbDataListByMysql
  149. // @Description: 从mysql中获取指标的数据(日期正序返回)
  150. // @author: Roc
  151. // @datetime 2024-05-08 16:49:48
  152. // @param source int
  153. // @param subSource int
  154. // @param edbInfoId int
  155. // @param startDate string
  156. // @param endDate string
  157. // @return list []*EdbDataList
  158. // @return err error
  159. func getEdbDataListByMysql(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
  160. tableName := GetEdbDataTableName(source, subSource)
  161. if tableName == "" {
  162. err = errors.New("无效的渠道:" + strconv.Itoa(source))
  163. list = make([]*EdbDataList, 0)
  164. return list, err
  165. }
  166. var pars []interface{}
  167. var condition string
  168. if startDate != "" {
  169. condition += ` AND data_time>=? `
  170. pars = append(pars, startDate)
  171. }
  172. if endDate != "" {
  173. condition += ` AND data_time<=? `
  174. pars = append(pars, endDate)
  175. }
  176. sql := `SELECT edb_data_id,edb_info_id,data_time,value,data_timestamp FROM %s WHERE edb_info_id=? `
  177. if condition != "" {
  178. sql += condition
  179. }
  180. sql += ` ORDER BY data_time ASC `
  181. sql = fmt.Sprintf(sql, tableName)
  182. o := orm.NewOrmUsingDB("data")
  183. _, err = o.Raw(sql, edbInfoId, pars).QueryRows(&list)
  184. return
  185. }
  186. // getEdbDataListByMongo
  187. // @Description: 从mongo中获取指标的数据(日期正序返回)
  188. // @author: Roc
  189. // @datetime 2024-05-08 16:49:59
  190. // @param source int
  191. // @param subSource int
  192. // @param edbInfoId int
  193. // @param startDate string
  194. // @param endDate string
  195. // @return list []*EdbDataList
  196. // @return err error
  197. func getEdbDataListByMongo(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
  198. list = make([]*EdbDataList, 0)
  199. mogDataObj := mgo.EdbDataBusiness{}
  200. // 构建查询条件
  201. queryConditions := bson.M{
  202. "edb_info_id": edbInfoId,
  203. }
  204. // 日期
  205. dateCondition, err := mgo.BuildDateCondition(startDate, endDate)
  206. if err != nil {
  207. return
  208. }
  209. if len(dateCondition) > 0 {
  210. queryConditions["data_time"] = dateCondition
  211. }
  212. // 获取列表数据
  213. tmpDataList, tmpErr := mogDataObj.GetAllDataList(queryConditions, []string{"data_time"})
  214. if tmpErr != nil {
  215. err = tmpErr
  216. return
  217. }
  218. for k, v := range tmpDataList {
  219. list = append(list, &EdbDataList{
  220. EdbDataId: k + 1,
  221. EdbInfoId: v.EdbInfoId,
  222. DataTime: v.DataTime.Format(utils.FormatDate),
  223. DataTimestamp: v.DataTimestamp,
  224. Value: v.Value,
  225. })
  226. }
  227. return
  228. }
  229. type EdbDataItemList struct {
  230. EdbDataId int `json:"-" description:" 指标数据ID"`
  231. EdbInfoId int `json:"-" description:"指标ID"`
  232. DataTime string `description:"数据日期"`
  233. DataTimestamp int64 `description:"数据日期"`
  234. Value float64 `description:"数据值"`
  235. }
  236. type EdbDataItems struct {
  237. Items []*EdbDataList
  238. Year int
  239. BetweenDay int `json:"-" description:"公历与农历之间相差的天数"`
  240. CuttingDataTimestamp int64 `description:"切割的时间戳"`
  241. }
  242. type EdbDataResult struct {
  243. List []*EdbDataItems
  244. }
  245. type QuarterData struct {
  246. Year string
  247. DataList []*EdbDataList
  248. CuttingDataTimestamp int64 `description:"切割的时间戳"`
  249. ChartLegend string
  250. Years string
  251. }
  252. type QuarterXDateItem struct {
  253. StartDate time.Time
  254. EndDate time.Time
  255. ShowName string
  256. ChartLegend string
  257. CuttingDataTimestamp int64 `description:"切割的时间戳"`
  258. }
  259. type ChartInfoDetailResp struct {
  260. ChartInfo *ChartInfo
  261. EdbInfoList []*ChartEdbInfoMapping
  262. XEdbIdValue []int `description:"柱方图的x轴数据,指标id"`
  263. YDataList []YData `description:"柱方图的y轴数据"`
  264. XDataList []XData `description:"商品价格曲线的X轴数据"`
  265. CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
  266. DataResp interface{} `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
  267. WaterMark string `description:"水印"`
  268. IsCollect bool `description:"是否收藏"`
  269. }
  270. // XData 商品价格曲线的的x轴数据
  271. type XData struct {
  272. Name string `description:"别名"`
  273. NameEn string `description:"英文别名"`
  274. IsHide int `description:"是否隐藏,0不隐藏,1隐藏"`
  275. }
  276. // YData 柱方图的y轴数据
  277. type YData struct {
  278. Date string `description:"数据日期"`
  279. ConfigDate time.Time `description:"配置的日期" json:"-"`
  280. Color string `description:"数据颜色"`
  281. Name string `description:"别名"`
  282. NameEn string `description:"英文别名"`
  283. Value []float64 `description:"每个指标的值"`
  284. NoDataEdbList []int `description:"没有数据的指标列表"`
  285. XEdbInfoIdList []int `description:"对应X轴的指标id列表"`
  286. EdbValMap map[int]float64 `description:"指标与值的对应" json:"-"`
  287. M []int `description:"对应开始日期的间隔值" json:"-"`
  288. NameList []string `description:"每个值对应的名称"`
  289. EnNameList []string `description:"每个值对应的英文名称"`
  290. Unit string `description:"中文单位名称"`
  291. UnitEn string `description:"英文单位名称"`
  292. SeriesEdb struct {
  293. SeriesId int `description:"因子指标系列ID"`
  294. EdbInfoId int `description:"指标ID"`
  295. } `description:"对应的系列指标"`
  296. }
  297. // RollingCorrelationChartDataResp 滚动相关性图
  298. type RollingCorrelationChartDataResp struct {
  299. XDateTimeValue []string `description:"滚动相关性图的x轴数据,日期数据"`
  300. YDataList []YData `description:"滚动相关性图的y轴数据"`
  301. }
  302. // 指标季度数据计算(公历转农历)
  303. func AddCalculateQuarterV5(dataList []*EdbDataList) (result *EdbDataResult, err error) {
  304. var errMsg string
  305. defer func() {
  306. if errMsg != "" {
  307. fmt.Println("errMsg:", errMsg)
  308. }
  309. }()
  310. if len(dataList) <= 0 {
  311. result.List = make([]*EdbDataItems, 0)
  312. return
  313. }
  314. endDate := dataList[len(dataList)-1].DataTime
  315. endDateForm, err := time.Parse(utils.FormatDate, endDate)
  316. if err != nil {
  317. return result, err
  318. }
  319. thisMonth := int(endDateForm.Month())
  320. result = new(EdbDataResult)
  321. var yearArr []int
  322. yearMap := make(map[int]int)
  323. var cureentDate time.Time
  324. if thisMonth < 11 {
  325. for k, v := range dataList {
  326. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  327. if err != nil {
  328. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  329. return result, err
  330. }
  331. if k == len(dataList)-1 {
  332. cureentDate = dateTime
  333. }
  334. year := dateTime.Year()
  335. if _, ok := yearMap[year]; !ok {
  336. yearArr = append(yearArr, year)
  337. }
  338. yearMap[year] = year
  339. }
  340. } else {
  341. for k, v := range dataList {
  342. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  343. if err != nil {
  344. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  345. return result, err
  346. }
  347. if k == len(dataList)-1 {
  348. cureentDate = dateTime
  349. }
  350. year := dateTime.Year() + 1
  351. if _, ok := yearMap[year]; !ok {
  352. yearArr = append(yearArr, year)
  353. }
  354. yearMap[year] = year
  355. }
  356. }
  357. //排序
  358. fmt.Println("yearArr:", yearArr)
  359. thisYear := cureentDate.Year()
  360. //thisMonth := int(cureentDate.Month())
  361. fmt.Println("thisMonth:", thisMonth)
  362. for ky, vy := range yearArr {
  363. fmt.Println("line 432:", ky, vy, thisYear, thisMonth)
  364. if thisMonth < 11 {
  365. currentYearCjnl := strconv.Itoa(thisYear) + "-01-01" //当前年份春节农历
  366. currentYearCjgl := solarlunar.LunarToSolar(currentYearCjnl, false) //当前年份春节公历
  367. currentYearCjglDate, err := time.Parse(utils.FormatDate, currentYearCjgl)
  368. if err != nil {
  369. errMsg = "生成当前春节失败,Err:" + err.Error()
  370. return result, err
  371. }
  372. preYear := vy
  373. preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
  374. preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
  375. preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
  376. if err != nil {
  377. errMsg = "生成历史年份春节失败,Err:" + err.Error()
  378. return result, err
  379. }
  380. day := currentYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
  381. items := new(EdbDataItems)
  382. items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
  383. items.Year = preYear
  384. for _, v := range dataList {
  385. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  386. if err != nil {
  387. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  388. return result, err
  389. }
  390. newDate := dateTime.AddDate(0, 0, int(day))
  391. selectDateStr := strconv.Itoa(thisYear) + "-11" + "-30"
  392. selectDate, _ := time.Parse(utils.FormatDate, selectDateStr)
  393. if newDate.Before(selectDate) || newDate == selectDate {
  394. timestamp := newDate.UnixNano() / 1e6
  395. item := new(EdbDataList)
  396. item.DataTime = newDate.Format(utils.FormatDate)
  397. item.EdbInfoId = v.EdbInfoId
  398. item.Value = v.Value
  399. item.EdbDataId = v.EdbDataId
  400. item.DataTimestamp = timestamp
  401. items.Items = append(items.Items, item)
  402. }
  403. }
  404. result.List = append(result.List, items)
  405. } else {
  406. nextYear := thisYear + 1
  407. nextYearCjnl := strconv.Itoa(nextYear) + "-01-01" //当前年份春节农历
  408. nextYearCjgl := solarlunar.LunarToSolar(nextYearCjnl, false) //当前年份春节公历
  409. nextYearCjglDate, err := time.Parse(utils.FormatDate, nextYearCjgl)
  410. if err != nil {
  411. errMsg = "生成当前春节失败,Err:" + err.Error()
  412. return result, err
  413. }
  414. preYear := vy
  415. preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
  416. preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
  417. preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
  418. if err != nil {
  419. errMsg = "生成历史年份春节失败,Err:" + err.Error()
  420. return result, err
  421. }
  422. day := nextYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
  423. fmt.Println("day:", day, nextYearCjglDate, preYearCjglDate)
  424. items := new(EdbDataItems)
  425. items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
  426. items.Year = preYear - 1
  427. fmt.Println("preYear:", preYear, "ky:", ky, "yearArrLen:", len(yearArr))
  428. if ky+1 < len(yearArr) {
  429. for _, v := range dataList {
  430. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  431. if err != nil {
  432. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  433. return result, err
  434. }
  435. newDate := dateTime.AddDate(0, 0, int(day))
  436. selectDateStr := strconv.Itoa(nextYear) + "-05" + "-31"
  437. selectDate, _ := time.Parse(utils.FormatDate, selectDateStr)
  438. if newDate.Before(selectDate) || newDate == selectDate {
  439. timestamp := newDate.UnixNano() / 1e6
  440. item := new(EdbDataList)
  441. item.DataTime = newDate.Format(utils.FormatDate)
  442. item.EdbInfoId = v.EdbInfoId
  443. item.Value = v.Value
  444. item.EdbDataId = v.EdbDataId
  445. item.DataTimestamp = timestamp
  446. items.Items = append(items.Items, item)
  447. }
  448. }
  449. result.List = append(result.List, items)
  450. } else {
  451. for _, v := range dataList {
  452. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  453. if err != nil {
  454. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  455. return result, err
  456. }
  457. timestamp := dateTime.UnixNano() / 1e6
  458. item := new(EdbDataList)
  459. item.DataTime = dateTime.Format(utils.FormatDate)
  460. item.EdbInfoId = v.EdbInfoId
  461. item.Value = v.Value
  462. item.EdbDataId = v.EdbDataId
  463. item.DataTimestamp = timestamp
  464. items.Items = append(items.Items, item)
  465. }
  466. result.List = append(result.List, items)
  467. }
  468. }
  469. }
  470. return
  471. }
  472. // AddCalculateQuarterV6 指标季度数据计算(季节性图表)
  473. func AddCalculateQuarterV6(dataList []*EdbDataList) (result *EdbDataResult, err error) {
  474. var errMsg string
  475. defer func() {
  476. if errMsg != "" {
  477. fmt.Println("errMsg:", errMsg)
  478. }
  479. }()
  480. endDate := dataList[len(dataList)-1].DataTime
  481. endDateForm, err := time.Parse(utils.FormatDate, endDate)
  482. if err != nil {
  483. return result, err
  484. }
  485. thisMonth := int(endDateForm.Month())
  486. result = new(EdbDataResult)
  487. var yearArr []int
  488. yearMap := make(map[int]int)
  489. var cureentDate time.Time
  490. if thisMonth < 11 {
  491. for k, v := range dataList {
  492. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  493. if err != nil {
  494. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  495. return result, err
  496. }
  497. if k == len(dataList)-1 {
  498. cureentDate = dateTime
  499. }
  500. year := dateTime.Year()
  501. if _, ok := yearMap[year]; !ok {
  502. yearArr = append(yearArr, year)
  503. }
  504. yearMap[year] = year
  505. }
  506. } else {
  507. for k, v := range dataList {
  508. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  509. if err != nil {
  510. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  511. return result, err
  512. }
  513. if k == len(dataList)-1 {
  514. cureentDate = dateTime
  515. }
  516. year := dateTime.Year() + 1
  517. if _, ok := yearMap[year]; !ok {
  518. yearArr = append(yearArr, year)
  519. }
  520. yearMap[year] = year
  521. }
  522. }
  523. //排序
  524. fmt.Println("yearArr:", yearArr)
  525. thisYear := cureentDate.Year()
  526. //thisMonth := int(cureentDate.Month())
  527. fmt.Println("thisMonth:", thisMonth)
  528. for ky, vy := range yearArr {
  529. fmt.Printf("line 432:ky:%d, vy:%d, thisYear:%d, thisMonth:%d", ky, vy, thisYear, thisMonth)
  530. fmt.Println("")
  531. if thisMonth < 11 {
  532. currentYearCjnl := strconv.Itoa(thisYear) + "-01-01" //当前年份春节农历
  533. currentYearCjgl := solarlunar.LunarToSolar(currentYearCjnl, false) //当前年份春节公历
  534. currentYearCjglDate, err := time.Parse(utils.FormatDate, currentYearCjgl)
  535. if err != nil {
  536. errMsg = "生成当前春节失败,Err:" + err.Error()
  537. return result, err
  538. }
  539. preYear := vy
  540. preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
  541. preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
  542. preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
  543. if err != nil {
  544. errMsg = "生成历史年份春节失败,Err:" + err.Error()
  545. return result, err
  546. }
  547. day := currentYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
  548. fmt.Println("day:", day, currentYearCjglDate, preYearCjglDate)
  549. items := new(EdbDataItems)
  550. items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
  551. items.Year = preYear
  552. for _, v := range dataList {
  553. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  554. if err != nil {
  555. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  556. return result, err
  557. }
  558. newDate := dateTime.AddDate(0, 0, int(day))
  559. timestamp := newDate.UnixNano() / 1e6
  560. item := new(EdbDataList)
  561. item.DataTime = newDate.Format(utils.FormatDate)
  562. item.EdbInfoId = v.EdbInfoId
  563. item.Value = v.Value
  564. item.EdbDataId = v.EdbDataId
  565. item.DataTimestamp = timestamp
  566. items.Items = append(items.Items, item)
  567. }
  568. result.List = append(result.List, items)
  569. } else {
  570. nextYear := thisYear + 1
  571. nextYearCjnl := strconv.Itoa(nextYear) + "-01-01" //当前年份春节农历
  572. nextYearCjgl := solarlunar.LunarToSolar(nextYearCjnl, false) //当前年份春节公历
  573. nextYearCjglDate, err := time.Parse(utils.FormatDate, nextYearCjgl)
  574. if err != nil {
  575. errMsg = "生成当前春节失败,Err:" + err.Error()
  576. return result, err
  577. }
  578. preYear := vy
  579. preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
  580. preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
  581. preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
  582. if err != nil {
  583. errMsg = "生成历史年份春节失败,Err:" + err.Error()
  584. return result, err
  585. }
  586. day := nextYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
  587. fmt.Println("day:", day, nextYearCjglDate, preYearCjglDate)
  588. items := new(EdbDataItems)
  589. items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
  590. items.Year = preYear
  591. fmt.Println("preYear:", preYear, "ky:", ky, "yearArrLen:", len(yearArr))
  592. //if ky+1 < len(yearArr) {
  593. for _, v := range dataList {
  594. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  595. if err != nil {
  596. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  597. return result, err
  598. }
  599. newDate := dateTime.AddDate(0, 0, int(day))
  600. timestamp := newDate.UnixNano() / 1e6
  601. item := new(EdbDataList)
  602. item.DataTime = newDate.Format(utils.FormatDate)
  603. item.EdbInfoId = v.EdbInfoId
  604. item.Value = v.Value
  605. item.EdbDataId = v.EdbDataId
  606. item.DataTimestamp = timestamp
  607. items.Items = append(items.Items, item)
  608. }
  609. result.List = append(result.List, items)
  610. /*} else {
  611. for _, v := range dataList {
  612. dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
  613. if err != nil {
  614. errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
  615. return result, err
  616. }
  617. timestamp := dateTime.UnixNano() / 1e6
  618. item := new(EdbDataList)
  619. item.DataTime = dateTime.Format(utils.FormatDate)
  620. item.EdbInfoId = v.EdbInfoId
  621. item.Value = v.Value
  622. item.EdbDataId = v.EdbDataId
  623. item.DataTimestamp = timestamp
  624. items.Items = append(items.Items, item)
  625. }
  626. result.List = append(result.List, items)
  627. }*/
  628. }
  629. }
  630. return
  631. }
  632. type CorrelationInfo struct {
  633. LeadValue int `description:"领先值"`
  634. LeadUnit string `description:"领先单位"`
  635. StartDate string `description:"开始日期"`
  636. EndDate string `description:"结束日期"`
  637. EdbInfoIdFirst int `description:"A指标ID"`
  638. EdbInfoIdSecond int `description:"B指标ID"`
  639. PeriodData string `description:"X轴-期数数据"`
  640. CorrelationData string `description:"Y轴-相关性系数"`
  641. AnalysisMode int `description:"分析模式: 0-单因子; 1-多因子"`
  642. }
  643. type SeasonExtraItem struct {
  644. ChartLegend []SeasonChartLegend `description:"自定义的图例名称"`
  645. XStartDate string `description:"横坐标显示的起始日"`
  646. XEndDate string `description:"横坐标显示的截止日"`
  647. JumpYear int `description:"横坐标日期是否跨年,1跨年,0不跨年"`
  648. RightAxis SeasonRightAxis `description:"自定义右轴指标"`
  649. MaxMinLimits MaxMinLimits `description:"自定义同期上下限"`
  650. SamePeriodAverage SamePeriodAverage `description:"自定义同期均线"`
  651. SamePeriodStandardDeviation SamePeriodStandardDeviation `description:"自定义同期标准差"`
  652. }
  653. // 自定义右轴指标
  654. type SeasonRightAxis struct {
  655. IndicatorType int `description:"右轴指标类型 1:左轴指标同比,2:指标库,3:预测指标 "`
  656. Style string `description:"生成样式"`
  657. Shape string `description:"形状"`
  658. ChartColor string `description:"图表颜色"`
  659. Size int `description:"大小"`
  660. Legend string `description:"图例名称"`
  661. NumFormat int `description:"数值格式 1:百分比 2:小数"`
  662. IsConnected int `description:"是否连接 0不连接 1连接"`
  663. LineColor string `description:"线条颜色"`
  664. LineWidth float64 `description:"线条宽度"`
  665. LineStyle string `description:"线条样式"`
  666. IsShow bool `description:"是否显示"`
  667. IsAdd bool `description:"是否添加"`
  668. }
  669. // 自定义同期上下限
  670. type MaxMinLimits struct {
  671. Color string `description:"颜色"`
  672. Year int `description:"上下限取值范围"`
  673. Legend string `description:"图例名称"`
  674. IsShow bool `description:"是否显示"`
  675. IsAdd bool `description:"是否添加"`
  676. }
  677. // 自定义同期均线
  678. type SamePeriodAverage struct {
  679. Color string `description:"颜色"`
  680. Year int `description:"均线取值范围"`
  681. Legend string `description:"图例名称"`
  682. LineType string `description:"线型"`
  683. LineWidth float64 `description:"线宽"`
  684. IsShow bool `description:"是否显示"`
  685. IsAdd bool `description:"是否添加"`
  686. }
  687. // 自定义同期均线
  688. type SamePeriodAverageResp struct {
  689. Color string `description:"颜色"`
  690. Year int `description:"均线取值范围"`
  691. Legend string `description:"图例名称"`
  692. LineType string `description:"线型"`
  693. LineWidth float64 `description:"线宽"`
  694. IsShow bool `description:"是否显示"`
  695. List []*SamePeriodAverageData `description:"自定义均线列表"`
  696. IsAdd bool `description:"是否添加"`
  697. }
  698. type SamePeriodAverageData struct {
  699. DataTime string `description:"数据日期"`
  700. DataTimestamp int64 `description:"数据日期时间戳"`
  701. Value float64 `description:"均值"`
  702. }
  703. // 自定义同期标准差
  704. type SamePeriodStandardDeviation struct {
  705. Color string `description:"颜色"`
  706. Year int `description:"标准差取值范围"`
  707. Legend string `description:"图例名称"`
  708. Multiple float64 `description:"标准差倍数"`
  709. IsShow bool `description:"是否显示"`
  710. IsAdd bool `description:"是否添加"`
  711. }
  712. type SamePeriodStandardDeviationResp struct {
  713. Color string `description:"颜色"`
  714. Year int `description:"标准差取值范围"`
  715. Legend string `description:"图例名称"`
  716. Multiple float64 `description:"标准差倍数"`
  717. IsShow bool `description:"是否显示"`
  718. List []*MaxMinLimitsData `description:"自定义标准差列表"`
  719. IsAdd bool `description:"是否添加"`
  720. }
  721. type SeasonChartResp struct {
  722. MaxMinLimits MaxMinLimitsResp `description:"自定义上下限"`
  723. SamePeriodAverage SamePeriodAverageResp `description:"自定义同期均线"`
  724. SamePeriodStandardDeviation SamePeriodStandardDeviationResp `description:"自定义同期标准差线"`
  725. RightAxis SeasonRightAxisResp `description:"自定义右轴指标"`
  726. }
  727. // 自定义右轴指标
  728. type SeasonRightAxisResp struct {
  729. SeasonRightAxis
  730. EdbInfoList []*ChartEdbInfoMapping
  731. }
  732. type MaxMinLimitsResp struct {
  733. List []*MaxMinLimitsData `description:"自定义上下限列表"`
  734. Color string `description:"颜色"`
  735. Year int `description:"上下限取值范围"`
  736. Legend string `description:"图例名称"`
  737. IsShow bool `description:"是否显示"`
  738. IsAdd bool `description:"是否添加"`
  739. }
  740. type MaxMinLimitsData struct {
  741. DataTime string `description:"数据日期"`
  742. DataTimestamp int64 `description:"数据日期时间戳"`
  743. MaxValue float64 `description:"最大值"`
  744. MinValue float64 `description:"最小值"`
  745. }
  746. type SeasonChartLegend struct {
  747. Name string
  748. Value string
  749. }
  750. type QuarterDataList []*QuarterData
  751. func (m QuarterDataList) Len() int {
  752. return len(m)
  753. }
  754. func (m QuarterDataList) Less(i, j int) bool {
  755. return m[i].Years < m[j].Years
  756. }
  757. func (m QuarterDataList) Swap(i, j int) {
  758. m[i], m[j] = m[j], m[i]
  759. }
  760. type ChartDwCollectReq struct {
  761. UniqueCode string
  762. Token string
  763. }
  764. // 截面组合图额外配置
  765. type ChartSectionExtraConf struct {
  766. DateConfList []*ChartSectionDateConfItem
  767. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  768. XDataList []XData `description:"横轴名称设置"`
  769. UnitList *ChartSectionCombineUnit `description:"纵轴单位设置"`
  770. BaseChartSeriesName string `description:"基准系列名称"`
  771. SortType int `description:"排序类型,0默认,1升序,2降序"`
  772. }
  773. // 截面组合图额外配置
  774. type ChartSectionAllExtraConf struct {
  775. ChartSectionExtraConf
  776. SeriesList []*ChartSectionSeriesItem
  777. }
  778. type ChartSectionDateConfItem struct {
  779. MoveForward int `description:"前移的期数"`
  780. EdbInfoId int `description:"指标ID"`
  781. EdbName string `description:"指标名称"`
  782. EdbNameEn string `description:"指标名称英文"`
  783. EdbInfoType int `description:"指标类型"`
  784. Frequency string `description:"频度"`
  785. EndDate string `description:"最新日期"`
  786. StaticDate string `description:"固定日期"`
  787. DateType int `description:"日期类型:0 指标日期,1系统日期, 2固定日期"`
  788. DateConfName string `description:"引用日期名称"` // 引用日期名称不能重复
  789. DateConfNameEn string `description:"引用日期英文名称"`
  790. DateChange []*ChartSectionDateChange
  791. }
  792. // 截面组合图引用日期配置
  793. type ChartSectionDateChange struct {
  794. Year int
  795. Month int
  796. Day int
  797. Frequency string `description:"频度变换"`
  798. FrequencyDay string `description:"频度的固定日期"`
  799. ChangeType int `description:"日期变换类型1日期位移,2指定频率"`
  800. }
  801. // 截面组合图系列配置
  802. type ChartSectionSeriesItem struct {
  803. ChartSeriesId int `description:"系列ID"`
  804. SeriesName string `description:"系列名称"` //系列名称不可同名
  805. SeriesNameEn string `description:"系列英文名称"`
  806. ChartStyle string `description:"图表类型"`
  807. ChartColor string `description:"颜色"`
  808. ChartWidth int `description:"线条大小"`
  809. IsPoint int `description:"是否用数据点展示(0 否,1是)"`
  810. IsNumber int `description:"是否用数值展示(0 否,1是)"`
  811. IsAxis int `description:"1:左轴,0:右轴"`
  812. MaxData float64 `description:"上限"`
  813. MinData float64 `description:"下限"`
  814. //IsOrder bool `description:"true:正序,false:逆序"`
  815. EdbInfoList []*ChartSectionSeriesEdbConf
  816. DataList []float64
  817. NoDataEdbIndex []int
  818. }
  819. type ChartSectionSeriesEdbConf struct {
  820. ChartSeriesEdbMappingId int `description:"映射ID"`
  821. ChartSeriesId int `description:"系列ID"`
  822. //ChartInfoId int `description:"图表ID"`
  823. EdbInfoId int `description:"指标id"`
  824. DateConf *ChartSectionSeriesDateConfItem
  825. EdbName string `description:"中文别名"`
  826. EdbNameEn string `description:"英文别名"`
  827. EdbInfoType int `description:"指标类型"`
  828. Unit string `description:"单位"`
  829. UnitEn string `description:"英文单位"`
  830. DateConfName string `description:"引用日期名称"`
  831. DateConfType int `description:"日期类型,0指标最新日期, 1引用日期"`
  832. }
  833. type ChartSectionCombineDataResp struct {
  834. DateConfList []*ChartSectionDateConfItem
  835. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  836. XDataList []XData `description:"横轴名称设置"`
  837. UnitList *ChartSectionCombineUnit `description:"纵轴单位设置"`
  838. BaseChartSeriesName string `description:"基准系列名称"`
  839. SortType int `description:"排序类型,0默认,1升序,2降序"`
  840. SeriesList []*ChartSectionSeriesItem
  841. LeftMin string `description:"图表左侧最小值"`
  842. LeftMax string `description:"图表左侧最大值"`
  843. RightMin string `description:"图表右侧最小值"`
  844. RightMax string `description:"图表右侧最大值"`
  845. Right2Min string `description:"图表右侧最小值"`
  846. Right2Max string `description:"图表右侧最大值"`
  847. }
  848. // 系列里的指标日期配置
  849. type ChartSectionSeriesDateConfItem struct {
  850. MoveForward int `description:"前移的期数"`
  851. DateChange []*ChartSectionDateChange
  852. }
  853. // PreviewSectionCombineChartReq 预览截面组合图的请求
  854. type PreviewSectionCombineChartReq struct {
  855. ChartName string `description:"图表名称"`
  856. ChartClassifyId int `description:"分类id"`
  857. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  858. }
  859. type ChartSectionCombineUnit struct {
  860. LeftName string `description:"左轴单位"`
  861. LeftNameEn string `description:"左轴英文单位"`
  862. RightName string `description:"右轴单位"`
  863. RightNameEn string `description:"右轴英文单位"`
  864. RightTwoName string `description:"右2轴单位"`
  865. RightTwoNameEn string `description:"右2轴英文单位"`
  866. }
  867. // 时序组合图额外配置
  868. type ChartTimeCombineExtraConf struct {
  869. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  870. }
  871. type ChartTimeCombineDataResp struct {
  872. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  873. }
  874. func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
  875. o := orm.NewOrmUsingDB("data")
  876. sql := ` SELECT * FROM chart_info WHERE chart_info_id=? `
  877. err = o.Raw(sql, chartInfoId).QueryRow(&item)
  878. return
  879. }
  880. type MarkersLine struct {
  881. Axis int `json:"axis" description:"1左轴 2右轴 3横轴"`
  882. AxisName string `json:"axisName" description:"轴的名称,例如'左轴'"`
  883. MarkerType string `json:"markerType" description:"标识线或标识区"`
  884. MarkLineType int `json:"markLineType" description:"1:固定 2:指标计算"`
  885. Value string `json:"value" description:"连线指向的数值,例如'4000'"`
  886. FromValue string `json:"fromValue" description:"连线的起始点,可以为空"`
  887. ToValue string `json:"toValue" description:"连线的结束点,可以为空"`
  888. LineWidth float64 `json:"lineWidth" description:"连线的宽度"`
  889. DashStyle string `json:"dashStyle" description:"连线的虚线样式,例如'ShortDashDot'"`
  890. Color string `json:"color" description:"连线的颜色"`
  891. Text string `json:"text" description:"连线旁边显示的文本"`
  892. TextPosition string `json:"textPosition" description:"文本的显示位置,例如'bottom'"`
  893. TextColor string `json:"textColor" description:"文本颜色"`
  894. TextFontSize int `json:"textFontSize" description:"文本的字号大小"`
  895. IsShow bool `json:"isShow" description:"是否显示连线及文本"`
  896. EdbType int `json:"edbType" description:"指标类型 0图中第一个指标 1其他指标 前端回显用"`
  897. EdbInfoId int `json:"edbInfoId" description:"指标id"`
  898. Calculation int `json:"calculation" description:"计算方式 1区间均值 2区间均值加N倍标准差 3区间个数分位 4区间数值分位"`
  899. CalculationValue int `json:"calculationValue" description:"计算方式对应的值 2就是几倍标准差 3就是分位值 4就是数值值·"`
  900. TimeIntervalType int `json:"timeInterval" description:"时间区间 0跟随图表 1自定义"`
  901. StartDate MarkersLineTime `json:"startTime" description:"开始时间"`
  902. EndDate MarkersLineTime `json:"endTime" description:"结束时间"`
  903. }
  904. type MarkersLineTime struct {
  905. TimeType int `json:"timeType" description:"时间类型 1固定 2动态 3至今(仅结束时间)"`
  906. Date string `json:"date" description:"日期"`
  907. Conf EdbDateChangeConf `json:"conf" description:"动态时间配置"`
  908. }
  909. // EdbDateExtraConf
  910. // @Description: 导入指标日期前移和日期变换
  911. type EdbDateChangeConf struct {
  912. MoveForward int `json:"moveForward" description:"前移的期数"`
  913. BaseDate int `json:"baseDate" description:"基准日期 0系统日期 1指标最新日期"`
  914. DateChange []*EdbDateConfDateChange
  915. }
  916. type EdbDateConfDateChange struct {
  917. Year int `json:"year" description:"前移的期数"`
  918. Month int `json:"month" description:"前移的期数"`
  919. Day int `json:"day" description:"前移的期数"`
  920. Frequency string `json:"moveForward" description:"频度变换"`
  921. FrequencyDay string `json:"frequencyDay" description:"频度的固定日期"`
  922. ChangeType int `json:"changeType" description:"日期变换类型1日期位移,2指定频率"`
  923. }
  924. func getThsHfEdbDataListByMongo(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
  925. list = make([]*EdbDataList, 0)
  926. mogDataObj := mgo.EdbDataThsHf{}
  927. // 构建查询条件
  928. queryConditions := bson.M{
  929. "edb_info_id": edbInfoId,
  930. }
  931. // 数据日期
  932. dateCondition, err := mgo.BuildDateCondition(startDate, endDate)
  933. if err != nil {
  934. return
  935. }
  936. if len(dateCondition) > 0 {
  937. queryConditions["data_time"] = dateCondition
  938. }
  939. // 获取列表数据
  940. tmpDataList, tmpErr := mogDataObj.GetAllDataList(queryConditions, []string{"data_time"})
  941. if tmpErr != nil {
  942. err = tmpErr
  943. return
  944. }
  945. for k, v := range tmpDataList {
  946. list = append(list, &EdbDataList{
  947. EdbDataId: k + 1,
  948. EdbInfoId: v.EdbInfoId,
  949. DataTime: v.DataTime.Format(utils.FormatDate),
  950. DataTimestamp: v.DataTimestamp,
  951. Value: v.Value,
  952. })
  953. }
  954. return
  955. }