base_from_trade_index.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "time"
  7. )
  8. type BaseFromTradeShanghaiIndex struct {
  9. BaseFromTradeShangHaiIndexId int `orm:"column(base_from_trade_shanghai_index_id);pk"`
  10. Rank int
  11. DealShortName string
  12. DealName string
  13. DealCode string
  14. DealValue string
  15. DealChange string
  16. BuyShortName string
  17. BuyName string
  18. BuyCode string
  19. BuyValue string
  20. BuyChange string
  21. SoldShortName string
  22. SoldName string
  23. SoldCode string
  24. SoldValue string
  25. SoldChange string
  26. Frequency string
  27. ClassifyName string
  28. ClassifyType string
  29. CreateTime time.Time
  30. ModifyTime time.Time
  31. DataTime string
  32. }
  33. type BaseFromTradeCffexIndex struct {
  34. BaseFromTradeCffexIndexId int `orm:"column(base_from_trade_cffex_index_id);pk"`
  35. Rank int
  36. DealShortName string
  37. DealName string
  38. DealCode string
  39. DealValue string
  40. DealChange string
  41. BuyShortName string
  42. BuyName string
  43. BuyCode string
  44. BuyValue string
  45. BuyChange string
  46. SoldShortName string
  47. SoldName string
  48. SoldCode string
  49. SoldValue string
  50. SoldChange string
  51. Frequency string
  52. ClassifyName string
  53. ClassifyType string
  54. CreateTime time.Time
  55. ModifyTime time.Time
  56. DataTime string
  57. }
  58. type BaseFromTradeIneIndex struct {
  59. BaseFromTradeIneIndexId int `orm:"column(base_from_trade_ine_index_id);pk"`
  60. Rank int
  61. DealShortName string
  62. DealName string
  63. DealCode string
  64. DealValue string
  65. DealChange string
  66. BuyShortName string
  67. BuyName string
  68. BuyCode string
  69. BuyValue string
  70. BuyChange string
  71. SoldShortName string
  72. SoldName string
  73. SoldCode string
  74. SoldValue string
  75. SoldChange string
  76. Frequency string
  77. ClassifyName string
  78. ClassifyType string
  79. CreateTime time.Time
  80. ModifyTime time.Time
  81. DataTime string
  82. }
  83. type BaseFromTradeEicIndex struct {
  84. BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
  85. Country string
  86. Type string
  87. EicCode string
  88. ShortName string
  89. Name string
  90. Status string
  91. GasDayStartedOn string
  92. GasInStorage string
  93. GasInStorageCode string
  94. Full string
  95. FullCode string
  96. Trend string
  97. TrendCode string
  98. Injection string
  99. InjectionCode string
  100. Withdrawal string
  101. WithdrawalCode string
  102. WorkingGasVolume string
  103. WorkingGasVolumeCode string
  104. InjectionCapacity string
  105. InjectionCapacityCode string
  106. WithdrawalCapacity string
  107. WithdrawalCapacityCode string
  108. Info string
  109. CreateTime time.Time
  110. ModifyTime time.Time
  111. }
  112. func GetBaseFromTradeIndexByParam(exchange, date, classifyName, classifyType string) (list []*BaseFromTradeShanghaiIndex, err error) {
  113. o := orm.NewOrmUsingDB("data")
  114. if classifyName == "" {
  115. sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=?"
  116. _, err = o.Raw(sql, date).QueryRows(&list)
  117. return
  118. } else if classifyType == "" {
  119. sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=? and classify_name=? ORDER BY classify_type,`rank`"
  120. _, err = o.Raw(sql, date, classifyName).QueryRows(&list)
  121. return
  122. } else {
  123. sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=? and classify_name=? and classify_type=?"
  124. _, err = o.Raw(sql, date, classifyName, classifyType).QueryRows(&list)
  125. return
  126. }
  127. }
  128. func GetExchangeClassify(exchange, dataTime string) (classifyName []string, err error) {
  129. o := orm.NewOrmUsingDB("data")
  130. sql := "SELECT DISTINCT classify_name FROM base_from_trade_" + exchange + "_index where data_time=? ORDER BY CONVERT(classify_name using gbk) DESC"
  131. _, err = o.Raw(sql, dataTime).QueryRows(&classifyName)
  132. return
  133. }
  134. func GetLatestDate(exchange string) (dataTime string, err error) {
  135. o := orm.NewOrmUsingDB("data")
  136. sql := "SELECT data_time FROM base_from_trade_" + exchange + "_index ORDER BY data_time desc limit 1"
  137. err = o.Raw(sql).QueryRow(&dataTime)
  138. return
  139. }
  140. func GetExchangeClassifyContract(exchange, Classify, dataTime string) (classifyName []*string, err error) {
  141. o := orm.NewOrmUsingDB("data")
  142. sql := "SELECT DISTINCT classify_type FROM base_from_trade_" + exchange + "_index where classify_name=? and data_time=?"
  143. _, err = o.Raw(sql, Classify, dataTime).QueryRows(&classifyName)
  144. return
  145. }
  146. func GetContinentEicDate(date string) (data []*BaseFromTradeEicIndex, err error) {
  147. o := orm.NewOrmUsingDB("data")
  148. sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and type='continent' "
  149. _, err = o.Raw(sql, date).QueryRows(&data)
  150. return
  151. }
  152. func GetCountryEicDate(date string) (data []*BaseFromTradeEicIndex, err error) {
  153. o := orm.NewOrmUsingDB("data")
  154. sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and type='country' "
  155. _, err = o.Raw(sql, date).QueryRows(&data)
  156. return
  157. }
  158. func GetSSOEicDate(date, country string) (data []*BaseFromTradeEicIndex, err error) {
  159. o := orm.NewOrmUsingDB("data")
  160. sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and country=? and type='SSO' "
  161. _, err = o.Raw(sql, date, country).QueryRows(&data)
  162. return
  163. }
  164. func GetStorageEicDate(date, country string) (data []*BaseFromTradeEicIndex, err error) {
  165. o := orm.NewOrmUsingDB("data")
  166. sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and country=? " +
  167. " and (type='Storage Facility' or type='Storage Group') "
  168. _, err = o.Raw(sql, date, country).QueryRows(&data)
  169. return
  170. }
  171. func GetEicDate() (date []*BaseFromTradeEicIndex, err error) {
  172. o := orm.NewOrmUsingDB("data")
  173. sql := "SELECT * FROM base_from_trade_eic_index ORDER BY gas_day_started_on desc limit 1"
  174. _, err = o.Raw(sql).QueryRows(&date)
  175. return
  176. }
  177. func GetEicHistoryDate(code string) (date []*BaseFromTradeEicIndex, err error) {
  178. o := orm.NewOrmUsingDB("data")
  179. sql := "SELECT * FROM base_from_trade_eic_index WHERE eic_code=? ORDER BY gas_day_started_on desc limit 30"
  180. _, err = o.Raw(sql, code).QueryRows(&date)
  181. return
  182. }
  183. func GetEicHistoryDateByDate(code, startDate, endDate string) (date []*BaseFromTradeEicIndex, err error) {
  184. o := orm.NewOrmUsingDB("data")
  185. sql := "SELECT * FROM base_from_trade_eic_index WHERE eic_code=? and gas_day_started_on between ? and ? ORDER BY gas_day_started_on desc"
  186. _, err = o.Raw(sql, code, startDate, endDate).QueryRows(&date)
  187. return
  188. }
  189. type BaseFromCoalmineJsmIndex struct {
  190. BaseFromCoalmineJsmIndexId int `orm:"column(base_from_coalmine_jsm_index_id);pk"`
  191. IndexName string `description:"持买单量指标名称"`
  192. IndexCode string `description:"持买单量指标编码"`
  193. Exchange string `description:"样本统计类别"`
  194. DealValue string `description:"成交量"`
  195. DataTime string `description:"数据日期"`
  196. Source string `description:"来源"`
  197. Province string `description:"省份"`
  198. Description string `description:"描述"`
  199. Unit string `description:"单位"`
  200. Frequency string `description:"频率"`
  201. CreateTime string `description:"插入时间"`
  202. ModifyTime string `description:"修改时间"`
  203. }
  204. // GetBaseFromCoalmineIndex 查询数据
  205. func GetBaseFromCoalmineIndex(startDate, endDate string) (items []*BaseFromCoalmineJsmIndex, err error) {
  206. o := orm.NewOrmUsingDB("data")
  207. sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE data_time between ? and ? `
  208. _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
  209. return
  210. }
  211. type BaseFromCoalmineCompanyIndex struct {
  212. BaseFromCoalmineCompanyIndexId int `orm:"column(base_from_coalmine_company_index_id);pk"`
  213. IndexName string `description:"持买单量指标名称"`
  214. IndexCode string `description:"持买单量指标编码"`
  215. DealValue string `description:"成交量"`
  216. DataTime string `description:"数据日期"`
  217. Source string `description:"来源"`
  218. Province string `description:"省份"`
  219. City string `description:"城市"`
  220. GroupName string `description:"集团名称"`
  221. Unit string `description:"单位"`
  222. Frequency string `description:"频率"`
  223. CreateTime string `description:"插入时间"`
  224. ModifyTime string `description:"修改时间"`
  225. }
  226. // GetBaseFromCoalmineCompanyIndex 查询公司指标
  227. func GetBaseFromCoalmineCompanyIndex(startDate, endDate string) (items []*BaseFromCoalmineCompanyIndex, err error) {
  228. o := orm.NewOrmUsingDB("data")
  229. sql := `SELECT * FROM base_from_coalmine_company_index WHERE data_time between ? and ? `
  230. _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
  231. return
  232. }
  233. // BaseFromCoalmineFirmIndex 煤矿产量周度公司数据表
  234. type BaseFromCoalmineFirmIndex struct {
  235. BaseFromCoalmineFirmIndexID int `orm:"column(base_from_coalmine_firm_index_id);pk"`
  236. IndexName string // 省份/企业名称
  237. IndexCode string // 持买单量指标编码
  238. DataTime string // 指标时间
  239. DataTimeDate string // 指标时间
  240. DealValue string // 数据量
  241. GroupName string // 集团名
  242. Source string // 来源
  243. Unit string // 来源
  244. Frequency string `description:"频率"`
  245. CreateTime string `description:"插入时间"`
  246. ModifyTime string `description:"修改时间"`
  247. }
  248. // 查询指标
  249. func GetBaseFromCoalmineFirmIndex(dataTime string) (items []*BaseFromCoalmineFirmIndex, err error) {
  250. o := orm.NewOrmUsingDB("data")
  251. sql := `SELECT * FROM base_from_coalmine_firm_index WHERE data_time LIKE `
  252. sql = sql + "'" + dataTime + "%" + "'"
  253. _, err = o.Raw(sql).QueryRows(&items)
  254. fmt.Println(sql)
  255. return
  256. }
  257. // BaseFromCoalmineCoastalIndex 沿海八省动力煤用户供耗存数据指标表
  258. type BaseFromCoalmineCoastalIndex struct {
  259. BaseFromCoalmineCoastalIndexID int `orm:"column(base_from_coalmine_coastal_index_id);pk"`
  260. IndexName string // 省份/企业名称
  261. IndexCode string // 持买单量指标编码
  262. DataTime string // 指标时间
  263. DealValue string // 数据量
  264. GroupName string // 地区
  265. Source string // 来源
  266. Unit string //单位
  267. Frequency string `description:"频率"`
  268. CreateTime string `description:"插入时间"`
  269. ModifyTime string `description:"修改时间"`
  270. }
  271. // 查询指标
  272. func GetBaseFromCoalmineCoastalIndex(startDate, endDate string) (items []*BaseFromCoalmineCoastalIndex, err error) {
  273. o := orm.NewOrmUsingDB("data")
  274. sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE data_time between ? and ? `
  275. _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
  276. return
  277. }
  278. // BaseFromCoalmineInlandIndex 内陆动力煤用户供耗存数据指标表
  279. type BaseFromCoalmineInlandIndex struct {
  280. BaseFromCoalmineInlandIndexID int `orm:"column(base_from_coalmine_inland_index_id);pk"`
  281. IndexName string // 省份/企业名称
  282. IndexCode string // 持买单量指标编码
  283. DataTime string // 指标时间
  284. DealValue string // 数据量
  285. GroupName string // 地区
  286. Source string // 来源
  287. Unit string // 来源
  288. Frequency string `description:"频率"`
  289. CreateTime string `description:"插入时间"`
  290. ModifyTime string `description:"修改时间"`
  291. }
  292. // 查询指标
  293. func GetBaseFromCoalmineInlandIndex(startDate, endDate string) (items []*BaseFromCoalmineInlandIndex, err error) {
  294. o := orm.NewOrmUsingDB("data")
  295. sql := `SELECT * FROM base_from_coalmine_inland_index WHERE data_time between ? and ? `
  296. _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
  297. return
  298. }
  299. type BaseFromCoalmineClassifyItem struct {
  300. ClassifyId int
  301. ClassifyName string
  302. Child []CoalChild
  303. }
  304. type CoalChild struct {
  305. ClassifyId int
  306. ClassifyName string
  307. }
  308. type CoalmineDataResp struct {
  309. IndexName string
  310. IndexCode string // 持买单量指标编码
  311. Unit string // 来源
  312. Frequency string
  313. ModifyTime string
  314. DataList []DataList
  315. }
  316. type CoalmineDataPageResp struct {
  317. IndexName string
  318. IndexCode string // 持买单量指标编码
  319. Unit string // 来源
  320. Frequency string
  321. ModifyTime string
  322. Paging *paging.PagingItem `description:"分页数据"`
  323. DataList []DataList
  324. }
  325. type CoalmineSingalDataResp struct {
  326. IndexName string
  327. IndexCode string // 持买单量指标编码
  328. Unit string // 来源
  329. GroupId int // 二级id
  330. GroupName string // 二级名称
  331. Frequency string
  332. ModifyTime string
  333. ClassifyId int
  334. DataList []DataList
  335. }
  336. type DataList struct {
  337. Value string
  338. DataTime string
  339. }
  340. type FrequencyResp struct {
  341. Frequency int
  342. }
  343. // GetFrequencyFromCoal 获取指标信息
  344. func GetFrequencyFromCoal(suffix string) (list *string, err error) {
  345. o := orm.NewOrmUsingDB("data")
  346. sql := `SELECT DISTINCT frequency FROM base_from_coalmine_%s `
  347. sql = fmt.Sprintf(sql, suffix)
  348. err = o.Raw(sql).QueryRow(&list)
  349. return
  350. }
  351. // 查询数据
  352. func GetBaseFromCoalmineIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineJsmIndex, err error) {
  353. o := orm.NewOrmUsingDB("data")
  354. sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE frequency=? AND province=?`
  355. _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
  356. return
  357. }
  358. // 查询数据
  359. func GetGroupNameFromCoalmineIndex(suffix string) (items []*string, err error) {
  360. o := orm.NewOrmUsingDB("data")
  361. sql := `SELECT DISTINCT group_name FROM base_from_coalmine_%s `
  362. sql = fmt.Sprintf(sql, suffix)
  363. _, err = o.Raw(sql).QueryRows(&items)
  364. return
  365. }
  366. // 查询数据
  367. func GetProvinceFromCoalmineIndex(suffix string) (items []*string, err error) {
  368. o := orm.NewOrmUsingDB("data")
  369. sql := `SELECT DISTINCT province FROM base_from_coalmine_%s `
  370. sql = fmt.Sprintf(sql, suffix)
  371. _, err = o.Raw(sql).QueryRows(&items)
  372. return
  373. }
  374. // 查询数据
  375. func GetClassifyCoalmineIndexByGroupName(groupName string) (items []*string, err error) {
  376. o := orm.NewOrmUsingDB("data")
  377. sql := `SELECT DISTINCT index_code FROM base_from_coalmine_jsm_index WHERE province=? `
  378. _, err = o.Raw(sql, groupName).QueryRows(&items)
  379. return
  380. }
  381. // 查询数据
  382. func GetPageFromCoalmineIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineJsmIndex, err error) {
  383. o := orm.NewOrmUsingDB("data")
  384. sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
  385. _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
  386. return
  387. }
  388. // 查询数据
  389. func GetCountFromJsm(indexCode string) (item int, err error) {
  390. o := orm.NewOrmUsingDB("data")
  391. sql := `SELECT COUNT(1) FROM base_from_coalmine_jsm_index WHERE index_code=? `
  392. err = o.Raw(sql, indexCode).QueryRow(&item)
  393. return
  394. }
  395. func GetClassifyCompanyByGroupName(groupName string) (items []*string, err error) {
  396. o := orm.NewOrmUsingDB("data")
  397. sql := `SELECT DISTINCT index_code FROM base_from_coalmine_company_index WHERE group_name=? `
  398. _, err = o.Raw(sql, groupName).QueryRows(&items)
  399. return
  400. }
  401. func GetClassifyJsmByGroupName(groupName string) (items []*string, err error) {
  402. o := orm.NewOrmUsingDB("data")
  403. sql := `SELECT DISTINCT index_code FROM base_from_coalmine_jsm_index WHERE province=? `
  404. _, err = o.Raw(sql, groupName).QueryRows(&items)
  405. return
  406. }
  407. // 查询公司指标
  408. func GetPageFromCoalmineCompanyIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineCompanyIndex, err error) {
  409. o := orm.NewOrmUsingDB("data")
  410. sql := `SELECT * FROM base_from_coalmine_company_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
  411. _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
  412. return
  413. }
  414. func GetCountFromCompany(indexCode string) (item int, err error) {
  415. o := orm.NewOrmUsingDB("data")
  416. sql := `SELECT COUNT(1) FROM base_from_coalmine_company_index WHERE index_code=? `
  417. err = o.Raw(sql, indexCode).QueryRow(&item)
  418. return
  419. }
  420. func GetCountFromFirm(indexCode string) (item int, err error) {
  421. o := orm.NewOrmUsingDB("data")
  422. sql := `SELECT COUNT(1) FROM base_from_coalmine_firm_index WHERE index_code=? `
  423. err = o.Raw(sql, indexCode).QueryRow(&item)
  424. return
  425. }
  426. func GetClassifyFirmByGroupName(groupName string) (items []*string, err error) {
  427. o := orm.NewOrmUsingDB("data")
  428. sql := `SELECT DISTINCT index_code FROM base_from_coalmine_firm_index WHERE group_name=? `
  429. _, err = o.Raw(sql, groupName).QueryRows(&items)
  430. return
  431. }
  432. // 查询指标
  433. func GetPageFromCoalmineFirmIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineFirmIndex, err error) {
  434. o := orm.NewOrmUsingDB("data")
  435. sql := `SELECT * FROM base_from_coalmine_firm_index WHERE frequency=? AND index_code=? ORDER BY data_time_date DESC LIMIT ?,? `
  436. _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
  437. return
  438. }
  439. func GetCountFromCoastal(indexCode string) (item int, err error) {
  440. o := orm.NewOrmUsingDB("data")
  441. sql := `SELECT COUNT(1) FROM base_from_coalmine_coastal_index WHERE index_code=? `
  442. err = o.Raw(sql, indexCode).QueryRow(&item)
  443. return
  444. }
  445. func GetClassifyCoastalByGroupName(groupName string) (items []*string, err error) {
  446. o := orm.NewOrmUsingDB("data")
  447. sql := `SELECT DISTINCT index_code FROM base_from_coalmine_coastal_index WHERE group_name=? `
  448. _, err = o.Raw(sql, groupName).QueryRows(&items)
  449. return
  450. }
  451. // 查询指标
  452. func GetPageFromCoalmineCoastalIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineCoastalIndex, err error) {
  453. o := orm.NewOrmUsingDB("data")
  454. sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
  455. _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
  456. return
  457. }
  458. func GetCountFromInland(indexCode string) (item int, err error) {
  459. o := orm.NewOrmUsingDB("data")
  460. sql := `SELECT COUNT(1) FROM base_from_coalmine_inland_index WHERE index_code=? `
  461. err = o.Raw(sql, indexCode).QueryRow(&item)
  462. return
  463. }
  464. func GetClassifyInlandByGroupName(groupName string) (items []*string, err error) {
  465. o := orm.NewOrmUsingDB("data")
  466. sql := `SELECT DISTINCT index_code FROM base_from_coalmine_inland_index WHERE group_name=? `
  467. _, err = o.Raw(sql, groupName).QueryRows(&items)
  468. return
  469. }
  470. // 查询指标
  471. func GetPageFromCoalmineInlandIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineInlandIndex, err error) {
  472. o := orm.NewOrmUsingDB("data")
  473. sql := `SELECT * FROM base_from_coalmine_inland_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
  474. _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
  475. return
  476. }
  477. // 查询公司指标
  478. func GetBaseFromCoalmineCompanyIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineCompanyIndex, err error) {
  479. o := orm.NewOrmUsingDB("data")
  480. sql := `SELECT * FROM base_from_coalmine_company_index WHERE frequency=? AND group_name=? `
  481. _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
  482. return
  483. }
  484. // 查询指标
  485. func GetBaseFromCoalmineFirmIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineFirmIndex, err error) {
  486. o := orm.NewOrmUsingDB("data")
  487. sql := `SELECT * FROM base_from_coalmine_firm_index WHERE frequency=? AND group_name=? `
  488. _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
  489. return
  490. }
  491. // 查询指标
  492. func GetBaseFromCoalmineCoastalIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineCoastalIndex, err error) {
  493. o := orm.NewOrmUsingDB("data")
  494. sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE frequency=? AND group_name=? `
  495. _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
  496. return
  497. }
  498. // 查询指标
  499. func GetBaseFromCoalmineInlandIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineInlandIndex, err error) {
  500. o := orm.NewOrmUsingDB("data")
  501. sql := `SELECT * FROM base_from_coalmine_inland_index WHERE frequency=? AND group_name=? `
  502. _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
  503. return
  504. }
  505. // 查询数据
  506. func GetBaseFromCoalmineIndexByCode(indexCode string) (items []*BaseFromCoalmineJsmIndex, err error) {
  507. o := orm.NewOrmUsingDB("data")
  508. sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE index_code=?`
  509. _, err = o.Raw(sql, indexCode).QueryRows(&items)
  510. return
  511. }
  512. // 查询公司指标
  513. func GetBaseFromCoalmineCompanyIndexByCode(indexCode string) (items []*BaseFromCoalmineCompanyIndex, err error) {
  514. o := orm.NewOrmUsingDB("data")
  515. sql := `SELECT * FROM base_from_coalmine_company_index WHERE index_code=? `
  516. _, err = o.Raw(sql, indexCode).QueryRows(&items)
  517. return
  518. }
  519. // 查询指标
  520. func GetBaseFromCoalmineFirmIndexByCode(indexCode string) (items []*BaseFromCoalmineFirmIndex, err error) {
  521. o := orm.NewOrmUsingDB("data")
  522. sql := `SELECT * FROM base_from_coalmine_firm_index WHERE index_code=? `
  523. _, err = o.Raw(sql, indexCode).QueryRows(&items)
  524. return
  525. }
  526. // 查询指标
  527. func GetBaseFromCoalmineCoastalIndexByCode(indexCode string) (items []*BaseFromCoalmineCoastalIndex, err error) {
  528. o := orm.NewOrmUsingDB("data")
  529. sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE index_code=? `
  530. _, err = o.Raw(sql, indexCode).QueryRows(&items)
  531. return
  532. }
  533. // 查询指标
  534. func GetBaseFromCoalmineInlandIndexByCode(indexCode string) (items []*BaseFromCoalmineInlandIndex, err error) {
  535. o := orm.NewOrmUsingDB("data")
  536. sql := `SELECT * FROM base_from_coalmine_inland_index WHERE index_code=? `
  537. _, err = o.Raw(sql, indexCode).QueryRows(&items)
  538. return
  539. }
  540. type BaseFromTradeEicIndexV2 struct {
  541. BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
  542. Type string
  543. EicCode string
  544. Name string
  545. Status string
  546. GasDayStart string
  547. GasInStorage float64
  548. GasInStorageCode string
  549. Consumption string
  550. ConsumptionCode string
  551. ConsumptionFull string
  552. ConsumptionFullCode string
  553. Full float64
  554. FullCode string
  555. Trend float64
  556. TrendCode string
  557. Injection float64
  558. InjectionCode string
  559. Withdrawal float64
  560. WithdrawalCode string
  561. WorkingGasVolume float64
  562. WorkingGasVolumeCode string
  563. InjectionCapacity float64
  564. InjectionCapacityCode string
  565. WithdrawalCapacity float64
  566. WithdrawalCapacityCode string
  567. Info string
  568. Parent string
  569. CreateTime time.Time
  570. ModifyTime time.Time
  571. Children []BaseFromTradeEicIndexV2
  572. }
  573. func GetEicDateV2() (date []*BaseFromTradeEicIndexV2, err error) {
  574. o := orm.NewOrmUsingDB("data")
  575. sql := "SELECT * FROM base_from_trade_eic_index_v2 ORDER BY gas_day_start desc limit 1"
  576. _, err = o.Raw(sql).QueryRows(&date)
  577. return
  578. }
  579. func GetEicDataV2(date string) (data []*BaseFromTradeEicIndexV2, err error) {
  580. o := orm.NewOrmUsingDB("data")
  581. sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? "
  582. _, err = o.Raw(sql, date).QueryRows(&data)
  583. return
  584. }
  585. func GetEicHistoryDateByDateV2(code, startDate, endDate string) (date []*BaseFromTradeEicIndexV2, err error) {
  586. o := orm.NewOrmUsingDB("data")
  587. sql := "SELECT * FROM base_from_trade_eic_index_v2 WHERE eic_code=? and gas_day_start between ? and ? ORDER BY gas_day_start desc"
  588. _, err = o.Raw(sql, code, startDate, endDate).QueryRows(&date)
  589. return
  590. }
  591. func GetEicHistoryDateV2(code string) (date []*BaseFromTradeEicIndexV2, err error) {
  592. o := orm.NewOrmUsingDB("data")
  593. sql := "SELECT * FROM base_from_trade_eic_index_v2 WHERE eic_code=? ORDER BY gas_day_start desc limit 30"
  594. _, err = o.Raw(sql, code).QueryRows(&date)
  595. return
  596. }
  597. func GetContinentAndCountryEicDateV2(date string) (data []*BaseFromTradeEicIndexV2, err error) {
  598. o := orm.NewOrmUsingDB("data")
  599. sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and (type='continent' OR type='country') "
  600. _, err = o.Raw(sql, date).QueryRows(&data)
  601. return
  602. }
  603. func GetSSOAndFacEicDateV2(date, name string) (data []*BaseFromTradeEicIndexV2, err error) {
  604. o := orm.NewOrmUsingDB("data")
  605. sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and (type='sso' OR type='fac') "
  606. _, err = o.Raw(sql, date).QueryRows(&data)
  607. return
  608. }
  609. func GetBaseFromTradeIndexByDate(exchange, startDate, endDate string) (list []*BaseFromTradeShanghaiIndex, err error) {
  610. o := orm.NewOrmUsingDB("data")
  611. sql := "SELECT * FROM base_from_trade_" + exchange + "_index where `rank` < 50 and data_time between ? and ? order by data_time asc"
  612. _, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
  613. return
  614. }
  615. func GetFirstBaseFromTradeIndexByDate(exchange string) (item *BaseFromTradeShanghaiIndex, err error) {
  616. o := orm.NewOrmUsingDB("data")
  617. sql := "SELECT * FROM base_from_trade_" + exchange + "_index where `rank` < 50 order by data_time asc"
  618. err = o.Raw(sql).QueryRow(&item)
  619. return
  620. }
  621. type BaseFromCoalmineClassify struct {
  622. BaseFromCoalmineClassifyId int `orm:"column(base_from_coalmine_classify_id);pk"`
  623. ClassifyName string // 分类名称
  624. Suffix string // 表名后缀
  625. CreateTime time.Time
  626. }
  627. func GetCoalmineClassifyList() (list []*BaseFromCoalmineClassify, err error) {
  628. o := orm.NewOrmUsingDB("data")
  629. sql := "SELECT * FROM base_from_coalmine_classify"
  630. _, err = o.Raw(sql).QueryRows(&list)
  631. return
  632. }