chart.go 41 KB

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