chart.go 41 KB

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