chart_info.go 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017
  1. package models
  2. import (
  3. "errors"
  4. "eta/eta_forum_hub/models/system"
  5. "eta/eta_forum_hub/utils"
  6. "fmt"
  7. "github.com/beego/beego/v2/client/orm"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. type ChartInfo struct {
  13. ChartInfoId int `orm:"column(chart_info_id);pk"`
  14. ChartName string `description:"来源名称"`
  15. ChartNameEn string `description:"英文图表名称"`
  16. ChartClassifyId int `description:"图表分类id"`
  17. SysUserId int
  18. SysUserRealName string
  19. UniqueCode string `description:"图表唯一编码"`
  20. CreateTime time.Time
  21. ModifyTime time.Time
  22. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  23. StartDate string `description:"自定义开始日期"`
  24. EndDate string `description:"自定义结束日期"`
  25. IsSetName int `description:"设置名称"`
  26. EdbInfoIds string `description:"指标id"`
  27. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图,10:截面散点图, 11:雷达图"`
  28. Calendar string `description:"公历/农历"`
  29. SeasonStartDate string `description:"季节性图开始日期"`
  30. SeasonEndDate string `description:"季节性图开始日期"`
  31. ChartImage string `description:"图表图片"`
  32. Sort int `description:"排序字段,数字越小越排前面"`
  33. XMin string `description:"图表X轴最小值"`
  34. XMax string `description:"图表X轴最大值"`
  35. LeftMin string `description:"图表左侧最小值"`
  36. LeftMax string `description:"图表左侧最大值"`
  37. RightMin string `description:"图表右侧最小值"`
  38. RightMax string `description:"图表右侧最大值"`
  39. Right2Min string `description:"图表右侧2最小值"`
  40. Right2Max string `description:"图表右侧2最大值"`
  41. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  42. Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
  43. BarConfig string `description:"柱方图的配置,json数据"`
  44. Source int `description:"1:ETA图库;2:商品价格曲线"`
  45. ExtraConfig string `description:"图表额外配置,json数据"`
  46. SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
  47. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  48. ChartThemeId int `description:"图表应用主题ID"`
  49. SourcesFrom string `description:"图表来源"`
  50. Instructions string `description:"图表说明"`
  51. MarkersLines string `description:"标识线"`
  52. MarkersAreas string `description:"标识区"`
  53. Unit string `description:"中文单位名称"`
  54. UnitEn string `description:"英文单位名称"`
  55. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  56. Description string
  57. UploadUserId int
  58. UploadUserRealName string
  59. }
  60. type ChartInfoMore struct {
  61. ChartInfo
  62. IsEnChart bool `description:"是否展示英文标识"`
  63. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  64. }
  65. func AddChartInfo(item *ChartInfo) (lastId int64, err error) {
  66. o := orm.NewOrm()
  67. lastId, err = o.Insert(item)
  68. return
  69. }
  70. func UpdateChartInfo(item *ChartInfo) (err error) {
  71. o := orm.NewOrm()
  72. _, err = o.Update(&item)
  73. return
  74. }
  75. type ChartInfoItem struct {
  76. ChartInfoId int `description:"图表id"`
  77. ChartName string `description:"图表名称"`
  78. ChartClassifyId int `description:"图表分类"`
  79. }
  80. // GetChartInfoAll 用于分类展示
  81. // @param source int 1:ETA图库;2:商品价格曲线
  82. func GetChartInfoAll(sourceList []int) (items []*ChartClassifyItems, err error) {
  83. num := len(sourceList)
  84. if num <= 0 {
  85. return
  86. }
  87. o := orm.NewOrm()
  88. sql := ` SELECT chart_info_id,chart_classify_id,chart_name AS chart_classify_name,
  89. unique_code,sys_user_id,sys_user_real_name,date_type,start_date,end_date,chart_type,calendar,season_start_date,season_end_date,source
  90. FROM chart_info WHERE source in (` + utils.GetOrmInReplace(num) + `) ORDER BY sort asc,chart_info_id ASC `
  91. _, err = o.Raw(sql, sourceList).QueryRows(&items)
  92. return
  93. }
  94. // GetChartInfoByAdminId 获取所有我创建的图表,用于分类展示
  95. func GetChartInfoByAdminId(sourceList []int, adminId int) (items []*ChartClassifyItems, err error) {
  96. num := len(sourceList)
  97. if num <= 0 {
  98. return
  99. }
  100. o := orm.NewOrm()
  101. sql := ` SELECT chart_info_id,chart_classify_id,chart_name AS chart_classify_name,
  102. unique_code,sys_user_id,sys_user_real_name,date_type,start_date,end_date,chart_type,calendar,season_start_date,season_end_date
  103. FROM chart_info where source in (` + utils.GetOrmInReplace(num) + `) AND sys_user_id = ? ORDER BY sort asc,create_time ASC `
  104. _, err = o.Raw(sql, sourceList, adminId).QueryRows(&items)
  105. return
  106. }
  107. // 用于分类展示
  108. func GetChartInfoAllList() (items []*ChartInfo, err error) {
  109. o := orm.NewOrm()
  110. sql := ` SELECT *
  111. FROM chart_info ORDER BY create_time ASC `
  112. _, err = o.Raw(sql).QueryRows(&items)
  113. return
  114. }
  115. // 图表检索数据
  116. type ChartInfoSearch struct {
  117. EdbCode string `description:"图表编码"`
  118. StartDate string `description:"起始日期"`
  119. EndDate string `description:"终止日期"`
  120. DataList []*EdbInfoSearchData
  121. }
  122. type ChartInfoSearchData struct {
  123. DataTime string `description:"数据日期"`
  124. Value float64 `description:"数据"`
  125. }
  126. type ChartInfoSearchResp struct {
  127. SearchItem *EdbInfoSearch `description:"图表分类"`
  128. Status int `description:"1:数据已存在于弘则数据库,2:新数据"`
  129. }
  130. func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
  131. o := orm.NewOrm()
  132. sql := ` SELECT * FROM chart_info WHERE chart_info_id=? `
  133. err = o.Raw(sql, chartInfoId).QueryRow(&item)
  134. return
  135. }
  136. func GetChartInfoViewById(chartInfoId int) (item *ChartInfoView, err error) {
  137. o := orm.NewOrm()
  138. sql := ` SELECT * FROM chart_info WHERE chart_info_id=? `
  139. err = o.Raw(sql, chartInfoId).QueryRow(&item)
  140. return
  141. }
  142. func GetChartInfoViewByIds(chartInfoIds []string) (list []*ChartInfoView, err error) {
  143. o := orm.NewOrm()
  144. sql := ` SELECT * FROM chart_info WHERE chart_info_id in ("` + strings.Join(chartInfoIds, `","`) + `") `
  145. _, err = o.Raw(sql).QueryRows(&list)
  146. return
  147. }
  148. type SaveChartInfoReq struct {
  149. ChartEdbInfoList []*ChartSaveItem `description:"指标及配置信息"`
  150. ChartInfoId int `description:"图表id,新增时传0"`
  151. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间,6:起始日期至今"`
  152. StartDate string `description:"自定义开始日期"`
  153. EndDate string `description:"自定义结束日期"`
  154. Calendar string `description:"公历/农历"`
  155. LeftMin string `description:"图表左侧最小值"`
  156. LeftMax string `description:"图表左侧最大值"`
  157. RightMin string `description:"图表右侧最小值"`
  158. RightMax string `description:"图表右侧最大值"`
  159. Right2Min string `description:"图表右侧最小值"`
  160. Right2Max string `description:"图表右侧最大值"`
  161. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  162. ExtraConfig string `description:"图表额外配置,json数据"`
  163. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  164. }
  165. type ChartSaveItem struct {
  166. EdbInfoId int `description:"指标id"`
  167. MaxData float64 `description:"上限"`
  168. MinData float64 `description:"下限"`
  169. IsOrder bool `description:"true:正序,false:逆序"`
  170. IsAxis int `description:"1:左轴,0:右轴"`
  171. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  172. LeadValue int `description:"领先值"`
  173. LeadUnit string `description:"领先单位"`
  174. ChartStyle string `description:"图表类型"`
  175. ChartColor string `description:"颜色"`
  176. PredictChartColor string `description:"预测数据的颜色"`
  177. ChartWidth float64 `description:"线条大小"`
  178. Source int `description:"1:ETA图库;2:商品价格曲线"`
  179. EdbAliasName string `description:"中文别名"`
  180. IsConvert int `description:"是否数据转换 0不转 1转"`
  181. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  182. ConvertValue float64 `description:"数据转换值"`
  183. ConvertUnit string `description:"数据转换单位"`
  184. ConvertEnUnit string `description:"数据转换单位"`
  185. }
  186. func DeleteChartInfoAndData(chartInfoId int) (err error) {
  187. o := orm.NewOrm()
  188. to, err := o.Begin()
  189. if err != nil {
  190. return
  191. }
  192. defer func() {
  193. if err != nil {
  194. _ = to.Rollback()
  195. } else {
  196. _ = to.Commit()
  197. }
  198. }()
  199. sql := ` DELETE FROM chart_info WHERE chart_info_id=? `
  200. _, err = to.Raw(sql, chartInfoId).Exec()
  201. if err != nil {
  202. return
  203. }
  204. sql = ` DELETE FROM chart_edb_mapping WHERE chart_info_id=? `
  205. _, err = to.Raw(sql, chartInfoId).Exec()
  206. return
  207. }
  208. func GetChartInfoCountByCondition(condition string, pars []interface{}) (count int, err error) {
  209. o := orm.NewOrm()
  210. sql := ` SELECT COUNT(1) AS count FROM chart_info WHERE 1=1 `
  211. if condition != "" {
  212. sql += condition
  213. }
  214. err = o.Raw(sql, pars).QueryRow(&count)
  215. return
  216. }
  217. type EditChartInfoReq struct {
  218. ChartInfoId int `description:"图表ID"`
  219. ChartName string `description:"图表名称"`
  220. ChartClassifyId int `description:"分类id"`
  221. ChartEdbInfoList []*ChartSaveItem `description:"指标及配置信息"`
  222. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图,10:截面散点图"`
  223. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间,6:起始日期至今,20:N年至今"`
  224. StartDate string `description:"自定义开始日期"`
  225. EndDate string `description:"自定义结束日期"`
  226. Calendar string `description:"公历/农历"`
  227. LeftMin string `description:"图表左侧最小值"`
  228. LeftMax string `description:"图表左侧最大值"`
  229. RightMin string `description:"图表右侧最小值"`
  230. RightMax string `description:"图表右侧最大值"`
  231. Right2Min string `description:"图表右侧最小值"`
  232. Right2Max string `description:"图表右侧最大值"`
  233. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  234. BarChartInfo BarChartInfoReq `description:"柱方图的配置"`
  235. CorrelationChartInfo CorrelationChartInfoReq `description:"相关性图表配置"`
  236. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  237. SeasonExtraConfig SeasonExtraItem `description:"季节性图表中的配置,json数据"`
  238. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  239. ChartThemeId int `description:"图表应用主题ID"`
  240. SourcesFrom string `description:"图表来源"`
  241. Instructions string `description:"图表说明"`
  242. MarkersLines string `description:"标识线"`
  243. MarkersAreas string `description:"标识区"`
  244. Unit string `description:"中文单位名称"`
  245. UnitEn string `description:"英文单位名称"`
  246. }
  247. type EditChartEnInfoReq struct {
  248. ChartInfoId int `description:"图表ID"`
  249. ChartNameEn string `description:"英文图表名称"`
  250. ChartEdbInfoList []*EditChartEnInfoEdbItem `description:"指标及配置信息"`
  251. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  252. }
  253. type EditChartEnInfoEdbItem struct {
  254. EdbInfoId int `description:"指标ID"`
  255. EdbNameEn string `description:"英文指标名称"`
  256. UnitEn string `description:"英文单位"`
  257. }
  258. func ModifyChartInfo(item *EditChartInfoReq) (err error) {
  259. o := orm.NewOrm()
  260. sql := ` UPDATE chart_info
  261. SET
  262. chart_name =?,
  263. chart_classify_id = ?,
  264. is_set_name=1,
  265. modify_time = NOW()
  266. WHERE chart_info_id = ?`
  267. _, err = o.Raw(sql, item.ChartName, item.ChartClassifyId, item.ChartInfoId).Exec()
  268. return
  269. }
  270. type ChartInfoList struct {
  271. ChartInfoId int `orm:"column(chart_info_id);pk"`
  272. ChartName string `description:"来源名称"`
  273. ChartChartClassifyId int `description:"图表分类id"`
  274. SysUserId int
  275. SysUserRealName string
  276. UniqueCode string `description:"图表唯一编码"`
  277. CreateTime time.Time
  278. ModifyTime time.Time
  279. EdbInfoList []*EdbInfoList
  280. }
  281. type ChartInfoListResp struct {
  282. Item *ChartInfoList
  283. }
  284. func GetChartInfoByCondition(condition string, pars []interface{}) (item *ChartInfo, err error) {
  285. o := orm.NewOrm()
  286. sql := ` SELECT * FROM chart_info WHERE 1=1 `
  287. if condition != "" {
  288. sql += condition
  289. }
  290. err = o.Raw(sql, pars).QueryRow(&item)
  291. return
  292. }
  293. func GetChartInfoByNewest(source int) (item *ChartInfoList, err error) {
  294. o := orm.NewOrm()
  295. sql := ` SELECT * FROM chart_info WHERE 1=1 AND source = ? ORDER BY modify_time DESC LIMIT 1 `
  296. err = o.Raw(sql, source).QueryRow(&item)
  297. return
  298. }
  299. func ModifyChartInfoModifyTime(chartInfoId int64) (err error) {
  300. o := orm.NewOrm()
  301. sql := ` UPDATE chart_info SET modify_time = NOW() WHERE chart_info_id = ? `
  302. _, err = o.Raw(sql, chartInfoId).Exec()
  303. return
  304. }
  305. type MoveChartInfoReq struct {
  306. ChartInfoId int `description:"图表ID"`
  307. PrevChartInfoId int `description:"上一个图表ID"`
  308. NextChartInfoId int `description:"下一个图表ID"`
  309. ChartClassifyId int `description:"分类id"`
  310. }
  311. func MoveChartInfo(chartInfoId, classifyId int) (err error) {
  312. o := orm.NewOrm()
  313. sql := ` UPDATE chart_info
  314. SET
  315. chart_classify_id = ?
  316. WHERE chart_info_id = ?`
  317. _, err = o.Raw(sql, classifyId, chartInfoId).Exec()
  318. return
  319. }
  320. type DeleteChartInfoReq struct {
  321. ChartInfoId int `description:"图表ID"`
  322. }
  323. type EdbDataList struct {
  324. EdbDataId int `description:" 指标数据ID"`
  325. EdbInfoId int `description:"指标ID"`
  326. DataTime string //`json:"-" description:"数据日期"`
  327. DataTimestamp int64 `description:"数据日期"`
  328. Value float64 `description:"数据值"`
  329. }
  330. type EdbDataListByUniqueCode struct {
  331. EdbDataId int `description:" 指标数据ID" json:"-"`
  332. EdbInfoId int `description:"指标ID" json:"-"`
  333. DataTime string //`json:"-" description:"数据日期"`
  334. DataTimestamp int64 `description:"数据日期"`
  335. Value float64 `description:"数据值"`
  336. }
  337. func GetEdbDataLunarList(endInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
  338. tableName := "edb_data_quarter"
  339. sql := `SELECT edb_data_id,edb_info_id,data_time,TRUNCATE(value,2) AS value,data_timestamp FROM %s WHERE edb_info_id=? AND data_time>=? AND data_time<=? ORDER BY data_time ASC `
  340. sql = fmt.Sprintf(sql, tableName)
  341. o := orm.NewOrm()
  342. _, err = o.Raw(sql, endInfoId, startDate, endDate).QueryRows(&list)
  343. return
  344. }
  345. type ChartEdbInfoMapping struct {
  346. EdbInfoId int `description:"指标id"`
  347. SourceName string `description:"来源名称"`
  348. Source int `description:"来源id"`
  349. SubSource int `description:"来源id"`
  350. EdbCode string `description:"指标编码"`
  351. EdbName string `description:"指标名称"`
  352. EdbAliasName string `description:"指标名称(别名)"`
  353. EdbNameEn string `description:"英文指标名称"`
  354. EdbAliasNameEn string `description:"英文指标名称(别名)"`
  355. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  356. Frequency string `description:"频率"`
  357. FrequencyEn string `description:"英文频率"`
  358. Unit string `description:"单位"`
  359. UnitEn string `description:"英文单位"`
  360. StartDate string `description:"起始日期"`
  361. EndDate string `description:"终止日期"`
  362. ModifyTime string `description:"指标最后更新时间"`
  363. ChartEdbMappingId int `description:"图表指标id"`
  364. ChartInfoId int `description:"图表id"`
  365. MaxData float64 `description:"上限"`
  366. MinData float64 `description:"下限"`
  367. IsOrder bool `description:"true:正序,false:逆序"`
  368. IsAxis int `description:"1:左轴,0:右轴"`
  369. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  370. EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
  371. LeadValue int `description:"领先值"`
  372. LeadUnit string `description:"领先单位"`
  373. LeadUnitEn string `description:"领先英文单位"`
  374. ChartStyle string `description:"图表类型"`
  375. ChartColor string `description:"颜色"`
  376. PredictChartColor string `description:"预测数据的颜色"`
  377. ChartWidth float64 `description:"线条大小"`
  378. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
  379. LatestDate string `description:"数据最新日期"`
  380. LatestValue float64 `description:"数据最新值"`
  381. MoveLatestDate string `description:"移动后的数据最新日期"`
  382. UniqueCode string `description:"指标唯一编码"`
  383. MinValue float64 `json:"-" description:"最小值"`
  384. MaxValue float64 `json:"-" description:"最大值"`
  385. DataList interface{}
  386. IsNullData bool `json:"-" description:"是否空数据"`
  387. MappingSource int `description:"1:ETA图库;2:商品价格曲线"`
  388. RegionType string `description:"交易所来源,海外还是国内" json:"-"`
  389. ClassifyId int `description:"分类id"`
  390. IsConvert int `description:"是否数据转换 0不转 1转"`
  391. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  392. ConvertValue float64 `description:"数据转换值"`
  393. ConvertUnit string `description:"数据转换单位"`
  394. ConvertEnUnit string `description:"数据转换单位"`
  395. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  396. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  397. }
  398. type QuarterData struct {
  399. Year int
  400. DataList []*EdbDataList
  401. CuttingDataTimestamp int64 `description:"切割的时间戳"`
  402. ChartLegend string
  403. Years string
  404. }
  405. type QuarterXDateItem struct {
  406. StartDate time.Time
  407. EndDate time.Time
  408. ShowName string
  409. ChartLegend string
  410. CuttingDataTimestamp int64 `description:"切割的时间戳"`
  411. }
  412. type QuarterDataByUniqueCode struct {
  413. Year int
  414. DataList []*EdbDataListByUniqueCode
  415. }
  416. type ChartEdbInfoDetailResp struct {
  417. EdbInfo *ChartEdbInfoMapping
  418. }
  419. type ChartInfoDetailResp struct {
  420. ChartInfo *ChartInfoView
  421. EdbInfoList []*ChartEdbInfoMapping
  422. XEdbIdValue []int `description:"柱方图的x轴数据,指标id"`
  423. YDataList []YData `description:"柱方图的y轴数据"`
  424. XDataList []XData `description:"商品价格曲线的X轴数据"`
  425. BarChartInfo BarChartInfoReq `description:"柱方图的配置"`
  426. //CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
  427. DataResp interface{} `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
  428. }
  429. // XData 商品价格曲线的的x轴数据
  430. type XData struct {
  431. Name string `description:"别名"`
  432. NameEn string `description:"英文别名"`
  433. }
  434. // YData 柱方图的y轴数据
  435. type YData struct {
  436. Date string `description:"数据日期"`
  437. ConfigDate time.Time `description:"配置的日期" json:"-"`
  438. Color string `description:"数据颜色"`
  439. Name string `description:"别名"`
  440. NameEn string `description:"英文别名"`
  441. Value []float64 `description:"每个指标的值"`
  442. NoDataEdbList []int `description:"没有数据的指标列表"`
  443. XEdbInfoIdList []int `description:"对应X轴的指标id列表"`
  444. NameList []string `description:"每个值对应的名称"`
  445. EnNameList []string `description:"每个值对应的英文名称"`
  446. EdbValMap map[int]float64 `description:"指标与值的对应" json:"-"`
  447. M []int `description:"对应开始日期的间隔值" json:"-"`
  448. Unit string `description:"中文单位名称"`
  449. UnitEn string `description:"英文单位名称"`
  450. }
  451. func AddChartInfoAndMapping(chartInfo *ChartInfo, mapList []*ChartEdbMapping, updateExtraConfigFlag bool) (err error) {
  452. o := orm.NewOrm()
  453. to, err := o.Begin()
  454. if err != nil {
  455. return
  456. }
  457. defer func() {
  458. if err != nil {
  459. _ = to.Rollback()
  460. } else {
  461. _ = to.Commit()
  462. }
  463. }()
  464. newId, err := o.Insert(chartInfo)
  465. if err != nil {
  466. err = errors.New("保存失败,Err:" + err.Error())
  467. return
  468. }
  469. chartInfo.ChartInfoId = int(newId)
  470. if len(mapList) > 0 {
  471. for _, v := range mapList {
  472. v.ChartInfoId = int(newId)
  473. }
  474. _, err = o.InsertMulti(len(mapList), mapList)
  475. }
  476. //更新图表的特殊字段
  477. if updateExtraConfigFlag {
  478. _, err = o.Update(chartInfo, []string{"ExtraConfig", "BarConfig"}...)
  479. if err != nil {
  480. err = errors.New("保存图表配置失败,Err:" + err.Error())
  481. return
  482. }
  483. }
  484. return
  485. }
  486. func ModifyChartInfoAndMapping(chartInfo *ChartInfo, addMapList []*ChartEdbMapping, updateMapList []*ChartEdbMapping, removeIdStr string, updateExtraConfigFlag bool) (err error) {
  487. o := orm.NewOrm()
  488. to, err := o.Begin()
  489. if err != nil {
  490. return
  491. }
  492. defer func() {
  493. if err != nil {
  494. _ = to.Rollback()
  495. } else {
  496. _ = to.Commit()
  497. }
  498. }()
  499. _, err = o.Update(chartInfo, []string{}...)
  500. if err != nil {
  501. err = errors.New("图表更新失败,Err:" + err.Error())
  502. return
  503. }
  504. if len(updateMapList) > 0 {
  505. for _, v := range updateMapList {
  506. _, err = o.Update(v, []string{}...)
  507. if err != nil {
  508. err = errors.New("更新图表指标映射关系失败,Err:" + err.Error())
  509. return
  510. }
  511. }
  512. }
  513. if len(addMapList) > 0 {
  514. _, err = o.InsertMulti(len(addMapList), addMapList)
  515. if err != nil {
  516. err = errors.New("保存图表指标映射关系失败,Err:" + err.Error())
  517. return
  518. }
  519. }
  520. if removeIdStr != "" {
  521. sql := fmt.Sprintf(` DELETE FROM chart_edb_mapping WHERE chart_edb_mapping_id in (%s) `, removeIdStr)
  522. _, err = o.Raw(sql).Exec()
  523. if err != nil {
  524. err = fmt.Errorf("删除映射关系失败,Err:" + err.Error())
  525. return
  526. }
  527. }
  528. //更新图表的特殊字段
  529. if updateExtraConfigFlag {
  530. _, err = o.Update(chartInfo, []string{"ExtraConfig", "BarConfig"}...)
  531. if err != nil {
  532. err = errors.New("保存图表配置失败,Err:" + err.Error())
  533. return
  534. }
  535. }
  536. return
  537. }
  538. // EditChartInfoAndMapping 修改 ETA图库 的 图表与指标 的关系
  539. func EditChartInfoAndMapping(req *EditChartInfoReq, edbInfoIdStr string, calendar string, dateType, disabled int, barChartConf string, chartEdbInfoList []*ChartSaveItem, seasonExtra string) (err error) {
  540. o := orm.NewOrm()
  541. to, err := o.Begin()
  542. if err != nil {
  543. return
  544. }
  545. defer func() {
  546. if err != nil {
  547. _ = to.Rollback()
  548. } else {
  549. _ = to.Commit()
  550. }
  551. }()
  552. var pars []interface{}
  553. pars = append(pars, req.ChartName)
  554. pars = append(pars, edbInfoIdStr)
  555. pars = append(pars, req.ChartType)
  556. pars = append(pars, req.ChartClassifyId)
  557. pars = append(pars, disabled)
  558. pars = append(pars, barChartConf)
  559. pars = append(pars, req.ExtraConfig)
  560. pars = append(pars, seasonExtra)
  561. pars = append(pars, req.StartYear)
  562. pars = append(pars, req.ChartThemeId)
  563. pars = append(pars, req.SourcesFrom)
  564. pars = append(pars, req.Instructions)
  565. pars = append(pars, req.MarkersLines)
  566. pars = append(pars, req.MarkersAreas)
  567. pars = append(pars, req.Unit)
  568. pars = append(pars, req.UnitEn)
  569. sql := ` UPDATE chart_info
  570. SET
  571. chart_name =?,
  572. edb_info_ids=?,
  573. chart_type=?,
  574. chart_classify_id = ?,
  575. modify_time = NOW(),
  576. disabled = ?,
  577. bar_config = ?,
  578. extra_config = ?,
  579. season_extra_config = ?,
  580. start_year = ?,
  581. chart_theme_id = ?,
  582. sources_from = ?,
  583. instructions = ?,
  584. markers_lines = ?,
  585. markers_areas = ?,
  586. unit = ?,
  587. unit_en = ?
  588. `
  589. if calendar != "" {
  590. sql += `,calendar = ? `
  591. pars = append(pars, calendar)
  592. }
  593. if dateType > 0 {
  594. sql += `,date_type = ? `
  595. pars = append(pars, dateType)
  596. }
  597. sql += `,start_date = ? `
  598. pars = append(pars, req.StartDate)
  599. sql += `,end_date = ? `
  600. pars = append(pars, req.EndDate)
  601. sql += `,season_start_date = ? `
  602. pars = append(pars, req.StartDate)
  603. sql += `,season_end_date = ? `
  604. pars = append(pars, req.EndDate)
  605. sql += `,left_min = ? `
  606. pars = append(pars, req.LeftMin)
  607. sql += `,left_max = ? `
  608. pars = append(pars, req.LeftMax)
  609. sql += `,right_min = ? `
  610. pars = append(pars, req.RightMin)
  611. sql += `,right_max = ? `
  612. pars = append(pars, req.RightMax)
  613. sql += `,right2_min = ? `
  614. pars = append(pars, req.Right2Min)
  615. sql += `,right2_max = ? `
  616. pars = append(pars, req.Right2Max)
  617. sql += `,min_max_save = ? `
  618. pars = append(pars, req.MinMaxSave)
  619. sql += `WHERE chart_info_id = ?`
  620. pars = append(pars, req.ChartInfoId)
  621. _, err = to.Raw(sql, pars).Exec()
  622. if err != nil {
  623. fmt.Println("UPDATE chart_info Err:", err.Error())
  624. return err
  625. }
  626. chartEdbMappingIdList := make([]string, 0)
  627. for _, v := range chartEdbInfoList {
  628. // 查询该指标是否存在,如果存在的话,那么就去修改,否则新增
  629. var tmpChartEdbMapping *ChartEdbMapping
  630. csql := `SELECT * FROM chart_edb_mapping WHERE chart_info_id=? AND edb_info_id=? AND source = ? `
  631. err = to.Raw(csql, req.ChartInfoId, v.EdbInfoId, utils.CHART_SOURCE_DEFAULT).QueryRow(&tmpChartEdbMapping)
  632. if err != nil && err.Error() != utils.ErrNoRow() {
  633. fmt.Println("QueryRow Err:", err.Error())
  634. return err
  635. }
  636. if tmpChartEdbMapping != nil {
  637. chartEdbMappingIdList = append(chartEdbMappingIdList, strconv.Itoa(tmpChartEdbMapping.ChartEdbMappingId))
  638. tmpChartEdbMapping.ModifyTime = time.Now()
  639. tmpChartEdbMapping.MaxData = v.MaxData
  640. tmpChartEdbMapping.MinData = v.MinData
  641. tmpChartEdbMapping.IsOrder = v.IsOrder
  642. tmpChartEdbMapping.IsAxis = v.IsAxis
  643. tmpChartEdbMapping.EdbInfoType = v.EdbInfoType
  644. tmpChartEdbMapping.LeadValue = v.LeadValue
  645. tmpChartEdbMapping.LeadUnit = v.LeadUnit
  646. tmpChartEdbMapping.ChartStyle = v.ChartStyle
  647. tmpChartEdbMapping.ChartColor = v.ChartColor
  648. tmpChartEdbMapping.PredictChartColor = v.PredictChartColor
  649. tmpChartEdbMapping.ChartWidth = v.ChartWidth
  650. tmpChartEdbMapping.EdbAliasName = v.EdbAliasName
  651. tmpChartEdbMapping.IsConvert = v.IsConvert
  652. tmpChartEdbMapping.ConvertType = v.ConvertType
  653. tmpChartEdbMapping.ConvertValue = v.ConvertValue
  654. tmpChartEdbMapping.ConvertUnit = v.ConvertUnit
  655. tmpChartEdbMapping.ConvertEnUnit = v.ConvertEnUnit
  656. _, err = to.Update(tmpChartEdbMapping, "ModifyTime", "MaxData", "MinData", "IsOrder", "IsAxis", "EdbInfoType", "LeadValue", "LeadUnit", "ChartStyle", "ChartColor", "PredictChartColor", "ChartWidth", "EdbAliasName",
  657. "IsConvert", "ConvertType", "ConvertValue", "ConvertUnit", "ConvertEnUnit")
  658. if err != nil {
  659. fmt.Println("chart_edb_mapping Err:" + err.Error())
  660. return err
  661. }
  662. } else {
  663. mapItem := new(ChartEdbMapping)
  664. mapItem.ChartInfoId = req.ChartInfoId
  665. mapItem.EdbInfoId = v.EdbInfoId
  666. mapItem.CreateTime = time.Now()
  667. mapItem.ModifyTime = time.Now()
  668. timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
  669. mapItem.UniqueCode = utils.MD5(utils.CHART_PREFIX + "_" + timestamp + "_" + strconv.Itoa(v.EdbInfoId))
  670. mapItem.MaxData = v.MaxData
  671. mapItem.MinData = v.MinData
  672. mapItem.IsOrder = v.IsOrder
  673. mapItem.IsAxis = v.IsAxis
  674. mapItem.EdbInfoType = v.EdbInfoType
  675. mapItem.LeadValue = v.LeadValue
  676. mapItem.LeadUnit = v.LeadUnit
  677. mapItem.ChartStyle = v.ChartStyle
  678. mapItem.ChartColor = v.ChartColor
  679. mapItem.PredictChartColor = v.PredictChartColor
  680. mapItem.ChartWidth = v.ChartWidth
  681. mapItem.Source = utils.CHART_SOURCE_DEFAULT
  682. mapItem.EdbAliasName = v.EdbAliasName
  683. mapItem.IsConvert = v.IsConvert
  684. mapItem.ConvertType = v.ConvertType
  685. mapItem.ConvertValue = v.ConvertValue
  686. mapItem.ConvertUnit = v.ConvertUnit
  687. mapItem.ConvertEnUnit = v.ConvertEnUnit
  688. tmpId, err := to.Insert(mapItem)
  689. if err != nil {
  690. fmt.Println("AddChartEdbMapping Err:" + err.Error())
  691. return err
  692. }
  693. mapItem.ChartEdbMappingId = int(tmpId)
  694. chartEdbMappingIdList = append(chartEdbMappingIdList, strconv.Itoa(mapItem.ChartEdbMappingId))
  695. }
  696. }
  697. if len(chartEdbMappingIdList) > 0 {
  698. chartEdbMappingIdStr := strings.Join(chartEdbMappingIdList, ",")
  699. dsql := `DELETE FROM chart_edb_mapping WHERE chart_info_id=? AND chart_edb_mapping_id NOT IN(` + chartEdbMappingIdStr + `)`
  700. _, err = to.Raw(dsql, req.ChartInfoId).Exec()
  701. if err != nil {
  702. fmt.Println("delete err:" + err.Error())
  703. return err
  704. }
  705. }
  706. return
  707. }
  708. // EditFutureGoodChartInfoAndMapping 修改商品价格曲线的 图表与指标 的关系
  709. func EditFutureGoodChartInfoAndMapping(req *EditChartInfoReq, edbInfoIdStr string, calendar string, dateType, disabled int, barChartConf string) (err error) {
  710. o := orm.NewOrm()
  711. to, err := o.Begin()
  712. if err != nil {
  713. return
  714. }
  715. defer func() {
  716. if err != nil {
  717. _ = to.Rollback()
  718. } else {
  719. _ = to.Commit()
  720. }
  721. }()
  722. var pars []interface{}
  723. pars = append(pars, req.ChartName)
  724. pars = append(pars, edbInfoIdStr)
  725. pars = append(pars, req.ChartType)
  726. pars = append(pars, req.ChartClassifyId)
  727. pars = append(pars, disabled)
  728. pars = append(pars, barChartConf)
  729. sql := ` UPDATE chart_info
  730. SET
  731. chart_name =?,
  732. edb_info_ids=?,
  733. chart_type=?,
  734. chart_classify_id = ?,
  735. modify_time = NOW(),
  736. disabled = ?,
  737. bar_config = ?
  738. `
  739. if calendar != "" {
  740. sql += `,calendar = ? `
  741. pars = append(pars, calendar)
  742. }
  743. if dateType > 0 {
  744. sql += `,date_type = ? `
  745. pars = append(pars, dateType)
  746. }
  747. sql += `,start_date = ? `
  748. pars = append(pars, req.StartDate)
  749. sql += `,end_date = ? `
  750. pars = append(pars, req.EndDate)
  751. sql += `,season_start_date = ? `
  752. pars = append(pars, req.StartDate)
  753. sql += `,season_end_date = ? `
  754. pars = append(pars, req.EndDate)
  755. sql += `,left_min = ? `
  756. pars = append(pars, req.LeftMin)
  757. sql += `,left_max = ? `
  758. pars = append(pars, req.LeftMax)
  759. sql += `,right_min = ? `
  760. pars = append(pars, req.RightMin)
  761. sql += `,right_max = ? `
  762. pars = append(pars, req.RightMax)
  763. sql += `,right2_min = ? `
  764. pars = append(pars, req.Right2Min)
  765. sql += `,right2_max = ? `
  766. pars = append(pars, req.Right2Max)
  767. sql += `WHERE chart_info_id = ?`
  768. pars = append(pars, req.ChartInfoId)
  769. _, err = to.Raw(sql, pars).Exec()
  770. if err != nil {
  771. fmt.Println("UPDATE chart_info Err:", err.Error())
  772. return err
  773. }
  774. chartEdbMappingIdList := make([]string, 0)
  775. for _, v := range req.BarChartInfo.EdbInfoIdList {
  776. // 查询该指标是否存在,如果存在的话,那么就去修改,否则新增
  777. var tmpChartEdbMapping *ChartEdbMapping
  778. csql := `SELECT * FROM chart_edb_mapping WHERE chart_info_id=? AND edb_info_id=? AND source = ? `
  779. err = to.Raw(csql, req.ChartInfoId, v.EdbInfoId, v.Source).QueryRow(&tmpChartEdbMapping)
  780. if err != nil && err.Error() != utils.ErrNoRow() {
  781. fmt.Println("QueryRow Err:", err.Error())
  782. return err
  783. }
  784. if tmpChartEdbMapping != nil {
  785. chartEdbMappingIdList = append(chartEdbMappingIdList, strconv.Itoa(tmpChartEdbMapping.ChartEdbMappingId))
  786. //tmpChartEdbMapping.ModifyTime = time.Now()
  787. //tmpChartEdbMapping.MaxData = v.MaxData
  788. //tmpChartEdbMapping.MinData = v.MinData
  789. //tmpChartEdbMapping.IsOrder = v.IsOrder
  790. //tmpChartEdbMapping.IsAxis = v.IsAxis
  791. //tmpChartEdbMapping.EdbInfoType = v.EdbInfoType
  792. //tmpChartEdbMapping.LeadValue = v.LeadValue
  793. //tmpChartEdbMapping.LeadUnit = v.LeadUnit
  794. //tmpChartEdbMapping.ChartStyle = v.ChartStyle
  795. //tmpChartEdbMapping.ChartColor = v.ChartColor
  796. //tmpChartEdbMapping.PredictChartColor = v.PredictChartColor
  797. //tmpChartEdbMapping.ChartWidth = v.ChartWidth
  798. //_, err = to.Update(tmpChartEdbMapping, "ModifyTime", "MaxData", "MinData", "IsOrder", "IsAxis", "EdbInfoType", "LeadValue", "LeadUnit", "ChartStyle", "ChartColor", "PredictChartColor", "ChartWidth")
  799. //if err != nil {
  800. // fmt.Println("chart_edb_mapping Err:" + err.Error())
  801. // return err
  802. //}
  803. } else {
  804. mapItem := new(ChartEdbMapping)
  805. mapItem.ChartInfoId = req.ChartInfoId
  806. mapItem.EdbInfoId = v.EdbInfoId
  807. mapItem.CreateTime = time.Now()
  808. mapItem.ModifyTime = time.Now()
  809. timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
  810. mapItem.UniqueCode = utils.MD5(utils.CHART_PREFIX + "_" + timestamp + "_" + strconv.Itoa(v.EdbInfoId))
  811. //mapItem.MaxData = v.MaxData
  812. //mapItem.MinData = v.MinData
  813. mapItem.IsOrder = true
  814. mapItem.IsAxis = 1
  815. mapItem.EdbInfoType = 1
  816. //mapItem.LeadValue = v.LeadValue
  817. //mapItem.LeadUnit = v.LeadUnit
  818. //mapItem.ChartStyle = v.ChartStyle
  819. //mapItem.ChartColor = v.ChartColor
  820. //mapItem.PredictChartColor = v.PredictChartColor
  821. //mapItem.ChartWidth = v.ChartWidth
  822. mapItem.Source = v.Source
  823. tmpId, err := to.Insert(mapItem)
  824. if err != nil {
  825. fmt.Println("AddChartEdbMapping Err:" + err.Error())
  826. return err
  827. }
  828. mapItem.ChartEdbMappingId = int(tmpId)
  829. chartEdbMappingIdList = append(chartEdbMappingIdList, strconv.Itoa(mapItem.ChartEdbMappingId))
  830. }
  831. }
  832. if len(chartEdbMappingIdList) > 0 {
  833. chartEdbMappingIdStr := strings.Join(chartEdbMappingIdList, ",")
  834. dsql := `DELETE FROM chart_edb_mapping WHERE chart_info_id=? AND chart_edb_mapping_id NOT IN(` + chartEdbMappingIdStr + `)`
  835. _, err = to.Raw(dsql, req.ChartInfoId).Exec()
  836. if err != nil {
  837. fmt.Println("delete err:" + err.Error())
  838. return err
  839. }
  840. }
  841. return
  842. }
  843. func EditChartEnInfoAndEdbEnInfo(req *EditChartEnInfoReq) (err error) {
  844. o := orm.NewOrm()
  845. to, err := o.Begin()
  846. if err != nil {
  847. return
  848. }
  849. defer func() {
  850. if err != nil {
  851. _ = to.Rollback()
  852. } else {
  853. _ = to.Commit()
  854. }
  855. }()
  856. var pars []interface{}
  857. updateField := ` chart_name_en =?, `
  858. pars = append(pars, req.ChartNameEn)
  859. if req.ExtraConfig != `` {
  860. updateField += ` extra_config =?, `
  861. pars = append(pars, req.ExtraConfig)
  862. }
  863. sql := ` UPDATE chart_info
  864. SET ` + updateField + ` modify_time = NOW()
  865. WHERE chart_info_id = ?`
  866. pars = append(pars, req.ChartInfoId)
  867. _, err = to.Raw(sql, pars).Exec()
  868. if err != nil {
  869. fmt.Println("UPDATE chart_info Err:", err.Error())
  870. return err
  871. }
  872. var edbInfoIdArr []string
  873. for _, v := range req.ChartEdbInfoList {
  874. edbInfoIdArr = append(edbInfoIdArr, strconv.Itoa(v.EdbInfoId))
  875. var count int
  876. csql := `SELECT COUNT(1) AS count FROM chart_edb_mapping WHERE chart_info_id=? AND edb_info_id=? `
  877. err = to.Raw(csql, req.ChartInfoId, v.EdbInfoId).QueryRow(&count)
  878. if err != nil {
  879. fmt.Println("QueryRow Err:", err.Error())
  880. return err
  881. }
  882. if count > 0 {
  883. msql := ` UPDATE edb_info
  884. SET
  885. edb_name_en =?,
  886. unit_en = ?,
  887. modify_time = NOW()
  888. WHERE edb_info_id = ? `
  889. _, err = to.Raw(msql, v.EdbNameEn, v.UnitEn, v.EdbInfoId).Exec()
  890. if err != nil {
  891. fmt.Println("edb_info Err:" + err.Error())
  892. return err
  893. }
  894. }
  895. }
  896. return
  897. }
  898. type AddChartInfoReq struct {
  899. ChartEdbInfoList []*ChartSaveItem `description:"指标及配置信息"`
  900. //ChartClassifyId int `description:"分类id"`
  901. ChartName string `description:"图表名称"`
  902. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图"`
  903. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间,6:起始日期至今"`
  904. StartDate string `description:"自定义开始日期"`
  905. EndDate string `description:"自定义结束日期"`
  906. Calendar string `description:"公历/农历"`
  907. LeftMin string `description:"图表左侧最小值"`
  908. LeftMax string `description:"图表左侧最大值"`
  909. RightMin string `description:"图表右侧最小值"`
  910. RightMax string `description:"图表右侧最大值"`
  911. Right2Min string `description:"图表右侧2最小值"`
  912. Right2Max string `description:"图表右侧2最大值"`
  913. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  914. Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
  915. BarConfig string `description:"柱方图的配置,json数据"`
  916. CorrelationChartInfo CorrelationChartInfoReq `description:"相关性图表配置"`
  917. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  918. ChartImage string `description:"封面图" json:"-"`
  919. SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
  920. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  921. Source int `description:"1:ETA图库;2:商品价格曲线"`
  922. ChartThemeId int `description:"图表应用主题ID"`
  923. SourcesFrom string `description:"图表来源"`
  924. Instructions string `description:"图表说明"`
  925. MarkersLines string `description:"标识线"`
  926. MarkersAreas string `description:"标识区"`
  927. Unit string `description:"中文单位名称"`
  928. UnitEn string `description:"英文单位名称"`
  929. }
  930. type AddChartReq struct {
  931. ChartInfo *ChartInfo
  932. Description string `description:"逻辑简述"`
  933. EdbInfoList []*EdbInfo
  934. ChartThemeList []*ChartTheme
  935. EdbInfoDataList []*AddEdbDataReq
  936. ChartEdbMapping []*ChartEdbMapping
  937. EdbInfoCalculateMapping []*EdbInfoCalculateMapping
  938. ChartSeries []*ChartSeries
  939. ChartSeriesEdbMapping []*ChartSeriesEdbMapping
  940. CreatorInfo *system.Admin //创建者的账号信息
  941. UploaderInfo *system.Admin //上传者的账号信息
  942. }
  943. type AddEdbDataReq struct {
  944. EdbCode string
  945. EdbType int
  946. DataList []*EdbDataBase
  947. }
  948. type EdbDataBase struct {
  949. EdbInfoId int
  950. EdbCode string
  951. DataTime string
  952. Value string
  953. Status int
  954. CreateTime time.Time
  955. ModifyTime time.Time
  956. DataTimestamp int64
  957. }
  958. type DeleteChartReq struct {
  959. ChartInfoId int `description:"图表id"`
  960. }
  961. type PreviewChartInfoReq struct {
  962. ChartEdbInfoList []*ChartSaveItem `description:"指标及配置信息"`
  963. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间,6:起始日期至今 20:最近N年"`
  964. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图"`
  965. StartDate string `description:"自定义开始日期"`
  966. EndDate string `description:"自定义结束日期"`
  967. Calendar string `description:"公历/农历"`
  968. SeasonExtraConfig SeasonExtraItem `description:"季节性图表中的配置,json数据"`
  969. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  970. }
  971. type SeasonExtraItem struct {
  972. ChartLegend []SeasonChartLegend `description:"自定义的图例名称"`
  973. XStartDate string `description:"横坐标显示的起始日"`
  974. XEndDate string `description:"横坐标显示的截止日"`
  975. JumpYear int `description:"横坐标日期是否跨年,1跨年,0不跨年"`
  976. }
  977. type SeasonChartLegend struct {
  978. Name string
  979. Value string
  980. }
  981. type AddChartInfoResp struct {
  982. ChartInfoId int `description:"图表id"`
  983. UniqueCode string `description:"图表唯一编码"`
  984. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  985. }
  986. type QuarterDataList []*QuarterData
  987. func (m QuarterDataList) Len() int {
  988. return len(m)
  989. }
  990. func (m QuarterDataList) Less(i, j int) bool {
  991. return m[i].Years < m[j].Years
  992. }
  993. func (m QuarterDataList) Swap(i, j int) {
  994. m[i], m[j] = m[j], m[i]
  995. }
  996. // 判断图表指标是否已经存在
  997. func ChartInfoExist(condition, edbInfoIdStr string) (count int, err error) {
  998. sql := `SELECT COUNT(1) AS count FROM (
  999. SELECT GROUP_CONCAT(edb_info_id ORDER BY edb_info_id ASC SEPARATOR ',') AS edb_info_id_str
  1000. FROM chart_edb_mapping AS a
  1001. WHERE 1=1`
  1002. if condition != "" {
  1003. sql += condition
  1004. }
  1005. sql += ` GROUP BY chart_info_id
  1006. )AS t
  1007. WHERE t.edb_info_id_str=?
  1008. GROUP BY t.edb_info_id_str `
  1009. o := orm.NewOrm()
  1010. err = o.Raw(sql, edbInfoIdStr).QueryRow(&count)
  1011. return
  1012. }
  1013. func ChartInfoSearchByKeyWord(keyword string, showSysId int) (searchList []*ChartInfo, err error) {
  1014. o := orm.NewOrm()
  1015. sql := ` SELECT * FROM chart_info WHERE 1=1 `
  1016. var pars []interface{}
  1017. if keyword != "" {
  1018. sql += `AND chart_name LIKE ? `
  1019. pars = append(pars, utils.GetLikeKeyword(keyword))
  1020. }
  1021. if showSysId > 0 {
  1022. sql += ` AND sys_user_id = ? `
  1023. pars = append(pars, showSysId)
  1024. }
  1025. sql += ` ORDER BY create_time DESC `
  1026. if keyword == "" {
  1027. sql += ` LIMIT 100 `
  1028. }
  1029. _, err = o.Raw(sql, pars).QueryRows(&searchList)
  1030. return
  1031. }
  1032. // ChartInfoSearchByEmptyKeyWord 没有关键字的时候获取默认100条数据
  1033. func ChartInfoSearchByEmptyKeyWord(showSysId int, sourceList []int, noPermissionChartIdList []int, startSize, pageSize int) (total int64, searchList []*ChartInfo, err error) {
  1034. num := len(sourceList)
  1035. o := orm.NewOrm()
  1036. baseSql := ` FROM chart_info WHERE 1=1 AND source in (` + utils.GetOrmInReplace(num) + `)`
  1037. var basePars []interface{}
  1038. basePars = append(basePars, sourceList)
  1039. if showSysId > 0 {
  1040. baseSql += ` AND sys_user_id = ? `
  1041. basePars = append(basePars, showSysId)
  1042. }
  1043. lenNoPermissionChartIdList := len(noPermissionChartIdList)
  1044. if lenNoPermissionChartIdList > 0 {
  1045. baseSql += ` AND chart_info_id not in (` + utils.GetOrmInReplace(lenNoPermissionChartIdList) + `) `
  1046. basePars = append(basePars, noPermissionChartIdList)
  1047. }
  1048. // 查找数量
  1049. totalSql := " SELECT count(1) as total " + baseSql
  1050. err = o.Raw(totalSql, basePars).QueryRow(&total)
  1051. if err != nil {
  1052. return
  1053. }
  1054. // 查找列表数据
  1055. sql := " SELECT * " + baseSql + ` ORDER BY create_time DESC LIMIT ?,? `
  1056. basePars = append(basePars, startSize, pageSize)
  1057. _, err = o.Raw(sql, basePars).QueryRows(&searchList)
  1058. return
  1059. }
  1060. func GetNextChartInfo(classifyId int) (item *ChartInfo, err error) {
  1061. o := orm.NewOrm()
  1062. sql := ` SELECT b.* FROM chart_classify AS a
  1063. INNER JOIN chart_info AS b ON a.chart_classify_id=b.chart_classify_id
  1064. WHERE a.chart_classify_id>?
  1065. ORDER BY a.chart_classify_id ASC
  1066. LIMIT 1 `
  1067. err = o.Raw(sql, classifyId).QueryRow(&item)
  1068. return
  1069. }
  1070. type SetChartInfoImageReq struct {
  1071. ChartInfoId int `description:"图表ID"`
  1072. ImageUrl string `description:"图表图片地址"`
  1073. }
  1074. func EditChartInfoImage(req *SetChartInfoImageReq) (err error) {
  1075. o := orm.NewOrm()
  1076. sql := ` UPDATE chart_info SET chart_image=?, modify_time = NOW() WHERE chart_info_id = ? `
  1077. _, err = o.Raw(sql, req.ImageUrl, req.ChartInfoId).Exec()
  1078. if err != nil {
  1079. fmt.Println("EditChartInfoImage Err:", err.Error())
  1080. return err
  1081. }
  1082. return
  1083. }
  1084. type ChartInfoDetailFromUniqueCodeResp struct {
  1085. ChartInfo *ChartInfoView
  1086. Status bool `description:"true:图表存在,false:图表不存在"`
  1087. EdbInfoList []*ChartEdbInfoMapping
  1088. XEdbIdValue []int `description:"柱方图的x轴数据,指标id"`
  1089. YDataList []YData `description:"柱方图的y轴数据"`
  1090. XDataList []XData `description:"商品价格曲线的X轴数据"`
  1091. BarChartInfo BarChartInfoReq `description:"柱方图的配置"`
  1092. //CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
  1093. DataResp interface{} `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
  1094. }
  1095. func GetChartInfoByUniqueCode(uniqueCode string) (item *ChartInfo, err error) {
  1096. o := orm.NewOrm()
  1097. sql := ` SELECT * FROM chart_info WHERE unique_code=? `
  1098. err = o.Raw(sql, uniqueCode).QueryRow(&item)
  1099. return
  1100. }
  1101. func GetChartInfoViewByUniqueCode(uniqueCode string) (item *ChartInfoView, err error) {
  1102. o := orm.NewOrm()
  1103. sql := ` SELECT * FROM chart_info WHERE unique_code=? `
  1104. err = o.Raw(sql, uniqueCode).QueryRow(&item)
  1105. return
  1106. }
  1107. // GetFirstChartInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
  1108. func GetFirstChartInfoByClassifyId(classifyId int) (item *ChartInfo, err error) {
  1109. o := orm.NewOrm()
  1110. sql := ` SELECT * FROM chart_info WHERE chart_classify_id=? order by sort asc,chart_info_id asc limit 1`
  1111. err = o.Raw(sql, classifyId).QueryRow(&item)
  1112. return
  1113. }
  1114. // UpdateChartInfoSortByClassifyId 根据图表id更新排序
  1115. func UpdateChartInfoSortByClassifyId(classifyId, nowSort, prevChartInfoId int, sourceList []int, updateSort string) (err error) {
  1116. o := orm.NewOrm()
  1117. num := len(sourceList)
  1118. if num <= 0 {
  1119. return
  1120. }
  1121. sql := ` update chart_info set sort = ` + updateSort + ` WHERE chart_classify_id=? AND source in (` + utils.GetOrmInReplace(num) + `) AND `
  1122. if prevChartInfoId > 0 {
  1123. sql += ` (sort > ? or (chart_info_id > ` + fmt.Sprint(prevChartInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `))`
  1124. }
  1125. _, err = o.Raw(sql, classifyId, sourceList, nowSort).Exec()
  1126. return
  1127. }
  1128. // Update 更新图表基础信息
  1129. func (chartInfo *ChartInfo) Update(cols []string) (err error) {
  1130. o := orm.NewOrm()
  1131. _, err = o.Update(chartInfo, cols...)
  1132. return
  1133. }
  1134. type ChartInfoView struct {
  1135. ChartInfoId int `orm:"column(chart_info_id);pk"`
  1136. ChartName string `description:"来源名称"`
  1137. ChartNameEn string `description:"英文图表名称"`
  1138. Unit string `description:"中文单位名称"`
  1139. UnitEn string `description:"英文单位名称"`
  1140. ChartClassifyId int `description:"图表分类id"`
  1141. ChartClassifyName string `description:"图表名称"`
  1142. SysUserId int
  1143. SysUserRealName string
  1144. UniqueCode string `description:"图表唯一编码"`
  1145. CreateTime time.Time
  1146. ModifyTime time.Time
  1147. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  1148. StartDate string `description:"自定义开始日期"`
  1149. EndDate string `description:"自定义结束日期"`
  1150. IsSetName int `description:"设置名称"`
  1151. EdbInfoIds string `description:"指标id"`
  1152. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  1153. Calendar string `description:"公历/农历"`
  1154. SeasonStartDate string `description:"季节性图开始日期"`
  1155. SeasonEndDate string `description:"季节性图开始日期"`
  1156. ChartImage string `description:"图表图片"`
  1157. Sort int `description:"排序字段,数字越小越排前面"`
  1158. IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
  1159. MyChartId int
  1160. MyChartClassifyId string `description:"我的图表分类,多个用逗号隔开"`
  1161. ChartClassify []*ChartClassifyView
  1162. EdbEndDate string `description:"指标最新更新日期"`
  1163. XMin string `description:"图表X轴最小值"`
  1164. XMax string `description:"图表X轴最大值"`
  1165. LeftMin string `description:"图表左侧最小值"`
  1166. LeftMax string `description:"图表左侧最大值"`
  1167. RightMin string `description:"图表右侧最小值"`
  1168. RightMax string `description:"图表右侧最大值"`
  1169. Right2Min string `description:"图表右侧最小值"`
  1170. Right2Max string `description:"图表右侧最大值"`
  1171. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  1172. IsEdit bool `description:"是否有编辑权限"`
  1173. IsEnChart bool `description:"是否展示英文标识"`
  1174. WarnMsg string `description:"错误信息"`
  1175. Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
  1176. BarConfig string `description:"柱方图的配置,json数据" json:"-"`
  1177. Source int `description:"1:ETA图库;2:商品价格曲线;3:相关性图表"`
  1178. //CorrelationLeadUnit string `description:"相关性图表-领先单位"`
  1179. ExtraConfig string `description:"图表额外配置,json数据"`
  1180. ChartSource string `description:"图表来源str"`
  1181. ChartSourceEn string `description:"图表来源(英文)"`
  1182. Button ChartViewButton `description:"操作按钮"`
  1183. SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
  1184. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  1185. ChartThemeId int `description:"图表应用主题ID"`
  1186. ChartThemeStyle string `description:"图表应用主题样式"`
  1187. SourcesFrom string `description:"图表来源"`
  1188. Instructions string `description:"图表说明"`
  1189. MarkersLines string `description:"标识线"`
  1190. MarkersAreas string `description:"标识区"`
  1191. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  1192. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  1193. }
  1194. type ChartViewButton struct {
  1195. IsEdit bool `description:"是否有编辑权限"`
  1196. IsEnChart bool `description:"是否展示英文标识"`
  1197. IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
  1198. IsCopy bool `description:"是否有另存为按钮"`
  1199. IsSetName int `description:"设置名称"`
  1200. }
  1201. type ImageSvgToPngResp struct {
  1202. Data struct {
  1203. ResourceURL string `json:"ResourceUrl"`
  1204. } `json:"Data"`
  1205. ErrCode string `json:"ErrCode"`
  1206. ErrMsg string `json:"ErrMsg"`
  1207. IsSendEmail bool `json:"IsSendEmail"`
  1208. Msg string `json:"Msg"`
  1209. Ret int64 `json:"Ret"`
  1210. Success bool `json:"Success"`
  1211. }
  1212. // GetChartInfoByClassifyIdAndName 根据分类id和图表名获取图表信息
  1213. func GetChartInfoByClassifyIdAndName(classifyId int, chartName string) (item *ChartInfo, err error) {
  1214. o := orm.NewOrm()
  1215. sql := ` SELECT * FROM chart_info WHERE chart_classify_id = ? and chart_name=? `
  1216. err = o.Raw(sql, classifyId, chartName).QueryRow(&item)
  1217. return
  1218. }
  1219. // BatchChartRefreshReq 批量刷新图表请求
  1220. type BatchChartRefreshReq struct {
  1221. ChartInfoCode []string `description:"图表编码数组"`
  1222. ReportId int `description:"报告id"`
  1223. ReportChapterId int `description:"报告章节id"`
  1224. Source string `description:"来源,枚举值:report、english_report、smart_report"`
  1225. }
  1226. // GetChartInfoListByUniqueCodeSlice 根据图表编码获取图表列表数据
  1227. func GetChartInfoListByUniqueCodeSlice(uniqueCodeSlice []string) (total int64, items []*ChartInfo, err error) {
  1228. if len(uniqueCodeSlice) <= 0 {
  1229. return
  1230. }
  1231. o := orm.NewOrm()
  1232. sql := ` SELECT * FROM chart_info WHERE unique_code in ("` + strings.Join(uniqueCodeSlice, `","`) + `") `
  1233. total, err = o.Raw(sql).QueryRows(&items)
  1234. return
  1235. }
  1236. // CopyAddChartInfoReq 复制并新增图表
  1237. type CopyAddChartInfoReq struct {
  1238. ChartInfoId int `description:"待复制的图表id"`
  1239. ChartClassifyId int `description:"分类id"`
  1240. ChartName string `description:"图表名称"`
  1241. }
  1242. // GetChartInfoListByCondition 根据条件获取图表数据了列表
  1243. func GetChartInfoListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*ChartInfo, err error) {
  1244. o := orm.NewOrm()
  1245. sql := ` SELECT * FROM chart_info WHERE 1=1 `
  1246. if condition != "" {
  1247. sql += condition
  1248. }
  1249. sql += ` ORDER BY chart_info_id DESC LIMIT ?,? `
  1250. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  1251. return
  1252. }
  1253. // GetChartInfoListGroupByUserId 根据指标id列表、用户分组获取指标信息
  1254. func GetChartInfoListGroupByUserId(edbIdList []string) (items []*ChartInfo, err error) {
  1255. num := len(edbIdList)
  1256. if num <= 0 {
  1257. return
  1258. }
  1259. o := orm.NewOrm()
  1260. sql := ` SELECT * FROM chart_info WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `) ORDER BY chart_info_id desc `
  1261. _, err = o.Raw(sql, edbIdList).QueryRows(&items)
  1262. return
  1263. }
  1264. // GetChartInfoListByChartIdList
  1265. // @Description: 根据图表id列表获取列表信息
  1266. // @param edbIdList
  1267. // @return items
  1268. // @return err
  1269. func GetChartInfoListByChartIdList(charIdList []string) (items []*ChartInfo, err error) {
  1270. num := len(charIdList)
  1271. if num <= 0 {
  1272. return
  1273. }
  1274. o := orm.NewOrm()
  1275. sql := ` SELECT * FROM chart_info WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `) ORDER BY chart_info_id desc `
  1276. _, err = o.Raw(sql, charIdList).QueryRows(&items)
  1277. return
  1278. }
  1279. // GetChartInfoListByUserId
  1280. // @Description: 根据图表id列表获取列表信息
  1281. // @param userIdList []int
  1282. // @param source int
  1283. // @return items
  1284. // @return err
  1285. func GetChartInfoListByUserId(userIdList []int, source int) (items []*ChartInfo, err error) {
  1286. num := len(userIdList)
  1287. if num <= 0 {
  1288. return
  1289. }
  1290. o := orm.NewOrm()
  1291. sql := ` SELECT * FROM chart_info WHERE source = ? AND sys_user_id in (` + utils.GetOrmInReplace(num) + `) ORDER BY chart_info_id desc `
  1292. _, err = o.Raw(sql, source, userIdList).QueryRows(&items)
  1293. return
  1294. }
  1295. // ModifyChartInfoUserIdByCodeList 根据指标code列表修改创建人
  1296. func ModifyChartInfoUserIdByCodeList(edbIdList []string, userId int, userName string) (err error) {
  1297. num := len(edbIdList)
  1298. if num <= 0 {
  1299. return
  1300. }
  1301. o := orm.NewOrm()
  1302. sql := `UPDATE chart_info SET sys_user_id=?,sys_user_real_name=? WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `) `
  1303. _, err = o.Raw(sql, userId, userName, edbIdList).Exec()
  1304. return
  1305. }
  1306. // ModifyChartInfoUserIdByOldUserId
  1307. // @Description: 根据旧的用户id修改创建人
  1308. // @author: Roc
  1309. // @datetime 2024-03-25 19:14:59
  1310. // @param oldUserId int
  1311. // @param userId int
  1312. // @param userName string
  1313. // @return err error
  1314. func ModifyChartInfoUserIdByOldUserId(oldUserIdList []int, userId int, userName string) (err error) {
  1315. num := len(oldUserIdList)
  1316. if num <= 0 {
  1317. return
  1318. }
  1319. o := orm.NewOrm()
  1320. sql := `UPDATE chart_info SET sys_user_id=?,sys_user_real_name=? WHERE sys_user_id in (` + utils.GetOrmInReplace(num) + `) `
  1321. _, err = o.Raw(sql, userId, userName, oldUserIdList).Exec()
  1322. return
  1323. }
  1324. // BarChartInfoReq 柱方图预览请求数据
  1325. type BarChartInfoReq struct {
  1326. EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
  1327. DateList []BarChartInfoDateReq `description:"日期配置"`
  1328. Sort BarChartInfoSortReq `description:"排序"`
  1329. XEdbList []BarChartInfoEdbItemReq `description:"X轴选择的指标列表"`
  1330. YEdbList []BarChartInfoEdbItemReq `description:"Y轴选择的指标列表"`
  1331. Unit string `description:"中文单位"`
  1332. UnitEn string `description:"英文单位"`
  1333. }
  1334. // BarChartInfoEdbItemReq 柱方图预览请求数据(指标相关)
  1335. type BarChartInfoEdbItemReq struct {
  1336. EdbInfoId int `description:"指标ID"`
  1337. Name string `description:"别名"`
  1338. NameEn string `description:"英文别名"`
  1339. Source int `description:"1:ETA图库;2:商品价格"`
  1340. IsConvert int `description:"是否数据转换 0不转 1转"`
  1341. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  1342. ConvertValue float64 `description:"数据转换值"`
  1343. ConvertUnit string `description:"数据转换单位"`
  1344. ConvertEnUnit string `description:"数据转换单位"`
  1345. }
  1346. // BarChartInfoDateReq 柱方图预览请求数据(日期相关)
  1347. type BarChartInfoDateReq struct {
  1348. Type int `description:"配置类型"`
  1349. Date string `description:"固定日期"`
  1350. Value int `description:"N天的值"`
  1351. Color string `description:"颜色"`
  1352. Name string `description:"别名"`
  1353. }
  1354. // BarChartInfoSortReq 柱方图预览请求数据(排序相关)
  1355. type BarChartInfoSortReq struct {
  1356. Sort int `description:"排序类型,0:默认,1:升序,2:降序"`
  1357. DateIndex int `description:"日期数据的下标,从0开始"`
  1358. }
  1359. // CorrelationChartInfoReq 相关性图表请求体
  1360. type CorrelationChartInfoReq struct {
  1361. LeadValue int `description:"领先期数"`
  1362. LeadUnit string `description:"频度"`
  1363. CalculateValue int `description:"计算窗口"`
  1364. CalculateUnit string `description:"计算频度"`
  1365. BaseCalculateValue int `description:"基础计算窗口(滚动相关性的时候用到)"`
  1366. BaseCalculateUnit string `description:"基础计算频度(滚动相关性的时候用到)"`
  1367. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间,6:起始日期至今"`
  1368. StartDate string `description:"开始日期"`
  1369. EndDate string `description:"结束日期"`
  1370. EdbInfoIdList []CorrelationChartInfoEdbItemReq `description:"指标信息"`
  1371. }
  1372. // CorrelationChartInfoEdbItemReq 相关性图表请求指标
  1373. type CorrelationChartInfoEdbItemReq struct {
  1374. EdbInfoId int `description:"指标ID"`
  1375. Name string `description:"别名"`
  1376. NameEn string `description:"英文别名"`
  1377. //Source int `description:"1:ETA图库;2:商品价格"`
  1378. }
  1379. /*
  1380. // EditCorrelationChartInfoAndMapping 修改相关性图表的 图表与指标 的关系
  1381. func EditCorrelationChartInfoAndMapping(req *EditChartInfoReq, edbInfoIdStr string, calendar string, dateType, disabled int, barChartConf string, correlationChart *ChartInfoCorrelation, correlationUpdateCols []string) (err error) {
  1382. o := orm.NewOrm()
  1383. to, err := o.Begin()
  1384. if err != nil {
  1385. return
  1386. }
  1387. defer func() {
  1388. if err != nil {
  1389. _ = to.Rollback()
  1390. } else {
  1391. _ = to.Commit()
  1392. }
  1393. }()
  1394. var pars []interface{}
  1395. pars = append(pars, req.ChartName)
  1396. pars = append(pars, edbInfoIdStr)
  1397. pars = append(pars, req.ChartType)
  1398. pars = append(pars, req.ChartClassifyId)
  1399. pars = append(pars, disabled)
  1400. pars = append(pars, barChartConf)
  1401. sql := ` UPDATE chart_info
  1402. SET
  1403. chart_name =?,
  1404. edb_info_ids=?,
  1405. chart_type=?,
  1406. chart_classify_id = ?,
  1407. modify_time = NOW(),
  1408. disabled = ?,
  1409. bar_config = ?
  1410. `
  1411. if calendar != "" {
  1412. sql += `,calendar = ? `
  1413. pars = append(pars, calendar)
  1414. }
  1415. if dateType > 0 {
  1416. sql += `,date_type = ? `
  1417. pars = append(pars, dateType)
  1418. }
  1419. sql += `,start_date = ? `
  1420. pars = append(pars, req.StartDate)
  1421. sql += `,end_date = ? `
  1422. pars = append(pars, req.EndDate)
  1423. sql += `,season_start_date = ? `
  1424. pars = append(pars, req.StartDate)
  1425. sql += `,season_end_date = ? `
  1426. pars = append(pars, req.EndDate)
  1427. sql += `,left_min = ? `
  1428. pars = append(pars, req.LeftMin)
  1429. sql += `,left_max = ? `
  1430. pars = append(pars, req.LeftMax)
  1431. sql += `,right_min = ? `
  1432. pars = append(pars, req.RightMin)
  1433. sql += `,right_max = ? `
  1434. pars = append(pars, req.RightMax)
  1435. sql += `WHERE chart_info_id = ?`
  1436. pars = append(pars, req.ChartInfoId)
  1437. _, err = to.Raw(sql, pars).Exec()
  1438. if err != nil {
  1439. fmt.Println("UPDATE chart_info Err:", err.Error())
  1440. return err
  1441. }
  1442. chartEdbMappingIdList := make([]string, 0)
  1443. for _, v := range req.CorrelationChartInfo.EdbInfoIdList {
  1444. // 查询该指标是否存在,如果存在的话,那么就去修改,否则新增
  1445. var tmpChartEdbMapping *ChartEdbMapping
  1446. csql := `SELECT * FROM chart_edb_mapping WHERE chart_info_id=? AND edb_info_id=? AND source = ? `
  1447. err = to.Raw(csql, req.ChartInfoId, v.EdbInfoId, utils.CHART_SOURCE_CORRELATION).QueryRow(&tmpChartEdbMapping)
  1448. if err != nil && err.Error() != utils.ErrNoRow() {
  1449. fmt.Println("QueryRow Err:", err.Error())
  1450. return err
  1451. }
  1452. if tmpChartEdbMapping != nil {
  1453. chartEdbMappingIdList = append(chartEdbMappingIdList, strconv.Itoa(tmpChartEdbMapping.ChartEdbMappingId))
  1454. //tmpChartEdbMapping.ModifyTime = time.Now()
  1455. //tmpChartEdbMapping.MaxData = v.MaxData
  1456. //tmpChartEdbMapping.MinData = v.MinData
  1457. //tmpChartEdbMapping.IsOrder = v.IsOrder
  1458. //tmpChartEdbMapping.IsAxis = v.IsAxis
  1459. //tmpChartEdbMapping.EdbInfoType = v.EdbInfoType
  1460. //tmpChartEdbMapping.LeadValue = v.LeadValue
  1461. //tmpChartEdbMapping.LeadUnit = v.LeadUnit
  1462. //tmpChartEdbMapping.ChartStyle = v.ChartStyle
  1463. //tmpChartEdbMapping.ChartColor = v.ChartColor
  1464. //tmpChartEdbMapping.PredictChartColor = v.PredictChartColor
  1465. //tmpChartEdbMapping.ChartWidth = v.ChartWidth
  1466. //_, err = to.Update(tmpChartEdbMapping, "ModifyTime", "MaxData", "MinData", "IsOrder", "IsAxis", "EdbInfoType", "LeadValue", "LeadUnit", "ChartStyle", "ChartColor", "PredictChartColor", "ChartWidth")
  1467. //if err != nil {
  1468. // fmt.Println("chart_edb_mapping Err:" + err.Error())
  1469. // return err
  1470. //}
  1471. } else {
  1472. mapItem := new(ChartEdbMapping)
  1473. mapItem.ChartInfoId = req.ChartInfoId
  1474. mapItem.EdbInfoId = v.EdbInfoId
  1475. mapItem.CreateTime = time.Now()
  1476. mapItem.ModifyTime = time.Now()
  1477. timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
  1478. mapItem.UniqueCode = utils.MD5(utils.CHART_PREFIX + "_" + timestamp + "_" + strconv.Itoa(v.EdbInfoId))
  1479. //mapItem.MaxData = v.MaxData
  1480. //mapItem.MinData = v.MinData
  1481. mapItem.IsOrder = true
  1482. mapItem.IsAxis = 1
  1483. mapItem.EdbInfoType = 1
  1484. //mapItem.LeadValue = v.LeadValue
  1485. //mapItem.LeadUnit = v.LeadUnit
  1486. //mapItem.ChartStyle = v.ChartStyle
  1487. //mapItem.ChartColor = v.ChartColor
  1488. //mapItem.PredictChartColor = v.PredictChartColor
  1489. //mapItem.ChartWidth = v.ChartWidth
  1490. mapItem.Source = utils.CHART_SOURCE_CORRELATION
  1491. tmpId, err := to.Insert(mapItem)
  1492. if err != nil {
  1493. fmt.Println("AddChartEdbMapping Err:" + err.Error())
  1494. return err
  1495. }
  1496. mapItem.ChartEdbMappingId = int(tmpId)
  1497. chartEdbMappingIdList = append(chartEdbMappingIdList, strconv.Itoa(mapItem.ChartEdbMappingId))
  1498. }
  1499. }
  1500. if len(chartEdbMappingIdList) > 0 {
  1501. chartEdbMappingIdStr := strings.Join(chartEdbMappingIdList, ",")
  1502. dsql := `DELETE FROM chart_edb_mapping WHERE chart_info_id=? AND chart_edb_mapping_id NOT IN(` + chartEdbMappingIdStr + `)`
  1503. _, err = to.Raw(dsql, req.ChartInfoId).Exec()
  1504. if err != nil {
  1505. fmt.Println("delete err:" + err.Error())
  1506. return err
  1507. }
  1508. }
  1509. // 相关性图表
  1510. _, err = to.Update(correlationChart, correlationUpdateCols...)
  1511. return
  1512. }*/
  1513. // PreviewSectionScatterChartReq 预览截面散点图的请求
  1514. type PreviewSectionScatterChartReq struct {
  1515. ChartName string `description:"图表名称"`
  1516. ChartClassifyId int `description:"分类id"`
  1517. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  1518. }
  1519. // SectionScatterReq 截面散点请求
  1520. type SectionScatterReq struct {
  1521. XName string `description:"x轴名称"`
  1522. XNameEn string `description:"x轴名称(英文)"`
  1523. XUnitName string `description:"x轴单位名称"`
  1524. XUnitNameEn string `description:"x轴单位名称(英文)"`
  1525. YName string `description:"y轴名称"`
  1526. YNameEn string `description:"y轴名称(英文)"`
  1527. YUnitName string `description:"y轴单位名称"`
  1528. YUnitNameEn string `description:"y轴单位名称(英文)"`
  1529. XMinValue string `description:"X轴的最小值"`
  1530. XMaxValue string `description:"X轴的最大值"`
  1531. YMinValue string `description:"Y轴的最小值"`
  1532. YMaxValue string `description:"Y轴的最大值"`
  1533. //EdbList []SectionScatterEdbItemReq `description:"指标数据"`
  1534. SeriesList []SectionScatterSeriesItemReq `description:"系列数据"`
  1535. }
  1536. // SectionScatterSeriesItemReq 系列的请求
  1537. type SectionScatterSeriesItemReq struct {
  1538. Name string `description:"系列名"`
  1539. NameEn string `description:"系列名(英文名)"`
  1540. IsNameDefault bool `description:"是否使用默认的系列名 false修改过 true默认 影响自动更新"`
  1541. Color string `description:"颜色"`
  1542. EdbInfoList []SectionScatterEdbItemReq
  1543. ShowTrendLine bool `description:"是否展示趋势线"`
  1544. ShowFitEquation bool `description:"是否展示方程式"`
  1545. ShowRSquare bool `description:"是否展示R平方"`
  1546. }
  1547. // SectionScatterEdbItemReq 截面散点请求的指标
  1548. type SectionScatterEdbItemReq struct {
  1549. XEdbInfoId int `description:"X轴的指标ID"`
  1550. YEdbInfoId int `description:"Y轴的指标ID"`
  1551. Name string `description:"别名"`
  1552. NameEn string `description:"英文别名"`
  1553. XDateType int `description:"X轴的日期配置类型"`
  1554. XDate string `description:"X轴的日期固定日期"`
  1555. XDateValue int `description:"X轴的日期N天的值"`
  1556. YDateType int `description:"Y轴的日期配置类型"`
  1557. YDate string `description:"Y轴的日期固定日期"`
  1558. YDateValue int `description:"Y轴的日期N天的值"`
  1559. IsShow bool `description:"是否展示"`
  1560. }
  1561. // SectionScatterInfoResp 截面散点图数据
  1562. type SectionScatterInfoResp struct {
  1563. XName string `description:"x轴名称"`
  1564. XNameEn string `description:"x轴名称(英文)"`
  1565. XUnitName string `description:"x轴单位名称"`
  1566. XUnitNameEn string `description:"x轴单位名称(英文)"`
  1567. YName string `description:"y轴名称"`
  1568. YNameEn string `description:"y轴名称(英文)"`
  1569. YUnitName string `description:"y轴单位名称"`
  1570. YUnitNameEn string `description:"y轴单位名称(英文)"`
  1571. XMinValue string `description:"X轴的最小值"`
  1572. XMaxValue string `description:"X轴的最大值"`
  1573. YMinValue string `description:"Y轴的最小值"`
  1574. YMaxValue string `description:"Y轴的最大值"`
  1575. DataList []SectionScatterSeriesItemResp `description:"数据列"`
  1576. }
  1577. // SectionScatterSeriesItemResp 系列的返回
  1578. type SectionScatterSeriesItemResp struct {
  1579. Name string `description:"系列名"`
  1580. NameEn string `description:"系列名(英文)"`
  1581. IsNameDefault bool `description:"是否使用默认的系列名 false修改过 true默认 影响自动更新"`
  1582. Color string `description:"颜色"`
  1583. EdbInfoList []SectionScatterEdbItemResp
  1584. ShowTrendLine bool `description:"是否展示趋势线"`
  1585. ShowFitEquation bool `description:"是否展示方程式"`
  1586. ShowRSquare bool `description:"是否展示R平方"`
  1587. TrendLine string `description:"方程式"`
  1588. RSquare string `description:"R平方的值(决定系数R2)"`
  1589. TrendLimitData []CoordinatePoint `description:"趋势线的前后坐标点"`
  1590. }
  1591. // SectionScatterEdbItemResp 截面散点的返回参数
  1592. type SectionScatterEdbItemResp struct {
  1593. XEdbInfoId int `description:"X轴指标id"`
  1594. XDate string `description:"X轴指标实际日期"`
  1595. XName string `description:"X轴指标名称"`
  1596. XNameEn string `description:"X轴指标英文名称"`
  1597. XValue float64 `description:"X轴实际值"`
  1598. YEdbInfoId int `description:"Y轴指标id"`
  1599. YDate string `description:"Y轴指标实际日期"`
  1600. YName string `description:"Y轴指标名称"`
  1601. YNameEn string `description:"Y轴指标英文名称"`
  1602. YValue float64 `description:"Y轴实际值"`
  1603. IsShow bool `description:"是否展示"`
  1604. Name string `description:"标签名称"`
  1605. NameEn string `description:"英文标签名称"`
  1606. }
  1607. // CoordinatePoint 坐标点
  1608. type CoordinatePoint struct {
  1609. X float64
  1610. Y float64
  1611. }
  1612. // RollingCorrelationChartDataResp 滚动相关性图
  1613. type RollingCorrelationChartDataResp struct {
  1614. XDateTimeValue []string `description:"滚动相关性图的x轴数据,日期数据"`
  1615. YDataList []YData `description:"滚动相关性图的y轴数据"`
  1616. }
  1617. // GetChartInfoAll 用于分类展示
  1618. // @param source int 1:ETA图库;2:商品价格曲线
  1619. func GetChartInfoAllByClassifyId(source, classifyId int) (items []*ChartClassifyItems, err error) {
  1620. o := orm.NewOrm()
  1621. sql := ` SELECT chart_info_id,chart_classify_id,chart_name AS chart_classify_name,chart_name_en AS chart_classify_name_en,
  1622. unique_code,sys_user_id,sys_user_real_name,date_type,start_date,end_date,chart_type,calendar,season_start_date,season_end_date,is_join_permission
  1623. FROM chart_info WHERE chart_classify_id = ? AND source = ? ORDER BY sort asc,create_time DESC `
  1624. _, err = o.Raw(sql, classifyId, source).QueryRows(&items)
  1625. return
  1626. }
  1627. // ProfitFutureGoodChartResp 商品利润图
  1628. type ProfitFutureGoodChartResp struct {
  1629. XDataList []XData
  1630. YDataList []YData
  1631. ProfitName string `description:"利润的名称"`
  1632. ProfitNameEn string `description:"利润的英文名称"`
  1633. }
  1634. func FIXChartClassifyId(newId, oldId int) (err error) {
  1635. o := orm.NewOrm()
  1636. sql := ` UPDATE chart_info SET chart_classify_id=? WHERE chart_classify_id=? `
  1637. _, err = o.Raw(sql, newId, oldId).Exec()
  1638. return
  1639. }
  1640. // GetChartInfoByAdminIdAndClassify 获取所有我创建的图表,用于分类展示
  1641. func GetChartInfoByAdminIdAndClassify(sourceList []int, adminId, classifyId int) (items []*ChartClassifyItems, err error) {
  1642. num := len(sourceList)
  1643. if num <= 0 {
  1644. return
  1645. }
  1646. o := orm.NewOrm()
  1647. sql := ` SELECT chart_info_id,chart_classify_id,chart_name AS chart_classify_name,
  1648. unique_code,sys_user_id,sys_user_real_name,date_type,start_date,end_date,chart_type,calendar,season_start_date,season_end_date,is_join_permission
  1649. FROM chart_info where source in (` + utils.GetOrmInReplace(num) + `) AND sys_user_id = ? AND chart_classify_id = ? ORDER BY sort asc,create_time ASC `
  1650. _, err = o.Raw(sql, sourceList, adminId, classifyId).QueryRows(&items)
  1651. return
  1652. }
  1653. // GetChartInfoAdminList 根据条件获取图表数据了列表
  1654. func GetChartInfoAdminList() (items []int, err error) {
  1655. o := orm.NewOrm()
  1656. sql := ` SELECT sys_user_id FROM chart_info GROUP BY sys_user_id `
  1657. _, err = o.Raw(sql).QueryRows(&items)
  1658. return
  1659. }
  1660. // EditChartInfoExtraConfig 修改 ETA图库 的 图表额外配置
  1661. func EditChartInfoExtraConfig(chartId int, extraConfig string) (err error) {
  1662. o := orm.NewOrm()
  1663. var pars []interface{}
  1664. pars = append(pars, extraConfig)
  1665. sql := ` UPDATE chart_info
  1666. SET
  1667. modify_time = NOW(),
  1668. extra_config = ?
  1669. `
  1670. sql += `WHERE chart_info_id = ?`
  1671. pars = append(pars, chartId)
  1672. _, err = o.Raw(sql, pars).Exec()
  1673. if err != nil {
  1674. fmt.Println("UPDATE chart_info Err:", err.Error())
  1675. return err
  1676. }
  1677. return
  1678. }
  1679. // PreviewRadarChartReq 预览雷达图的请求入参
  1680. type PreviewRadarChartReq struct {
  1681. ChartEdbInfoList []*ChartSaveItem `description:"指标及配置信息"`
  1682. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  1683. }
  1684. // RadarChartInfoReq 雷达图预览请求数据
  1685. type RadarChartInfoReq struct {
  1686. DateList []RadarChartInfoDateReq `description:"日期配置"`
  1687. }
  1688. // RadarChartInfoEdbItemReq 雷达图预览请求数据(指标相关)
  1689. type RadarChartInfoEdbItemReq struct {
  1690. EdbInfoId int `description:"指标ID"`
  1691. Name string `description:"别名"`
  1692. //NameEn string `description:"英文别名"`
  1693. //Source int `description:"1:ETA图库;2:商品价格"`
  1694. }
  1695. // RadarChartInfoDateReq 雷达图预览请求数据(日期相关)
  1696. type RadarChartInfoDateReq struct {
  1697. Type int `description:"配置类型"`
  1698. Date string `description:"固定日期"`
  1699. Value int `description:"N天的值"`
  1700. Color string `description:"颜色"`
  1701. Name string `description:"别名"`
  1702. }
  1703. // RadarChartInfoResp 雷达图数据
  1704. type RadarChartInfoResp struct {
  1705. YDataList []RadarYData `description:"数据列"`
  1706. XEdbIdValue []int
  1707. }
  1708. // RadarYData 雷达图的y轴数据
  1709. type RadarYData struct {
  1710. Date string `description:"数据日期"`
  1711. Color string `description:"数据颜色"`
  1712. Name string `description:"别名"`
  1713. Value []float64 `description:"每个指标的值"`
  1714. }
  1715. // 截面组合图额外配置
  1716. type ChartSectionExtraConf struct {
  1717. DateConfList []*ChartSectionDateConfItem
  1718. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  1719. XDataList []XData `description:"横轴名称设置"`
  1720. UnitList *ChartSectionCombineUnit `description:"纵轴单位设置"`
  1721. BaseChartSeriesName string `description:"基准系列名称"`
  1722. SortType int `description:"排序类型,0默认,1升序,2降序"`
  1723. }
  1724. // 截面组合图额外配置
  1725. type ChartSectionAllExtraConf struct {
  1726. ChartSectionExtraConf
  1727. SeriesList []*ChartSectionSeriesItem
  1728. }
  1729. type ChartSectionDateConfItem struct {
  1730. MoveForward int `description:"前移的期数"`
  1731. EdbInfoId int `description:"指标ID"`
  1732. EdbName string `description:"指标名称"`
  1733. EdbNameEn string `description:"指标名称英文"`
  1734. EdbInfoType int `description:"指标类型"`
  1735. Frequency string `description:"频度"`
  1736. EndDate string `description:"最新日期"`
  1737. DateType int `description:"日期类型:0 指标日期,1系统日期"`
  1738. DateConfName string `description:"引用日期名称"` // 引用日期名称不能重复
  1739. DateConfNameEn string `description:"引用日期英文名称"`
  1740. DateChange []*ChartSectionDateChange
  1741. }
  1742. // 截面组合图引用日期配置
  1743. type ChartSectionDateChange struct {
  1744. Year int
  1745. Month int
  1746. Day int
  1747. Frequency string `description:"频度变换"`
  1748. FrequencyDay string `description:"频度的固定日期"`
  1749. ChangeType int `description:"日期变换类型1日期位移,2指定频率"`
  1750. }
  1751. // 截面组合图系列配置
  1752. type ChartSectionSeriesItem struct {
  1753. ChartSeriesId int `description:"系列ID"`
  1754. SeriesName string `description:"系列名称"` //系列名称不可同名
  1755. SeriesNameEn string `description:"系列英文名称"`
  1756. ChartStyle string `description:"图表类型"`
  1757. ChartColor string `description:"颜色"`
  1758. ChartWidth int `description:"线条大小"`
  1759. IsPoint int `description:"是否用数据点展示(0 否,1是)"`
  1760. IsNumber int `description:"是否用数值展示(0 否,1是)"`
  1761. IsAxis int `description:"1:左轴,0:右轴"`
  1762. MaxData float64 `description:"上限"`
  1763. MinData float64 `description:"下限"`
  1764. //IsOrder bool `description:"true:正序,false:逆序"`
  1765. EdbInfoList []*ChartSectionSeriesEdbConf
  1766. DataList []float64
  1767. NoDataEdbIndex []int
  1768. }
  1769. type ChartSectionSeriesEdbConf struct {
  1770. ChartSeriesEdbMappingId int `description:"映射ID"`
  1771. ChartSeriesId int `description:"系列ID"`
  1772. //ChartInfoId int `description:"图表ID"`
  1773. EdbInfoId int `description:"指标id"`
  1774. DateConf *ChartSectionSeriesDateConfItem
  1775. EdbName string `description:"中文别名"`
  1776. EdbNameEn string `description:"英文别名"`
  1777. EdbInfoType int `description:"指标类型"`
  1778. Unit string `description:"单位"`
  1779. UnitEn string `description:"英文单位"`
  1780. DateConfName string `description:"引用日期名称"`
  1781. DateConfType int `description:"日期类型,0指标最新日期, 1引用日期"`
  1782. }
  1783. type ChartSectionCombineDataResp struct {
  1784. DateConfList []*ChartSectionDateConfItem
  1785. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  1786. XDataList []XData `description:"横轴名称设置"`
  1787. UnitList *ChartSectionCombineUnit `description:"纵轴单位设置"`
  1788. BaseChartSeriesName string `description:"基准系列名称"`
  1789. SortType int `description:"排序类型,0默认,1升序,2降序"`
  1790. SeriesList []*ChartSectionSeriesItem
  1791. LeftMin string `description:"图表左侧最小值"`
  1792. LeftMax string `description:"图表左侧最大值"`
  1793. RightMin string `description:"图表右侧最小值"`
  1794. RightMax string `description:"图表右侧最大值"`
  1795. Right2Min string `description:"图表右侧最小值"`
  1796. Right2Max string `description:"图表右侧最大值"`
  1797. }
  1798. // 系列里的指标日期配置
  1799. type ChartSectionSeriesDateConfItem struct {
  1800. MoveForward int `description:"前移的期数"`
  1801. DateChange []*ChartSectionDateChange
  1802. }
  1803. // PreviewSectionCombineChartReq 预览截面组合图的请求
  1804. type PreviewSectionCombineChartReq struct {
  1805. ChartName string `description:"图表名称"`
  1806. ChartClassifyId int `description:"分类id"`
  1807. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  1808. }
  1809. type ChartSectionCombineUnit struct {
  1810. LeftName string `description:"左轴单位"`
  1811. LeftNameEn string `description:"左轴英文单位"`
  1812. RightName string `description:"右轴单位"`
  1813. RightNameEn string `description:"右轴英文单位"`
  1814. RightTwoName string `description:"右2轴单位"`
  1815. RightTwoNameEn string `description:"右2轴英文单位"`
  1816. }
  1817. // 时序组合图额外配置
  1818. type ChartTimeCombineExtraConf struct {
  1819. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  1820. }
  1821. type ChartTimeCombineDataResp struct {
  1822. IsHeap int `description:"是否堆积(1.堆积,0不堆积)"`
  1823. }