chart.go 42 KB

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