|
@@ -2009,3 +2009,111 @@ func GetBaseIndexDataMinMax(source, subSource int, indexCode string) (item *Base
|
|
|
item.LatestValue = latestVal
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+type BaseFromMtjhIndex struct {
|
|
|
+ BaseFromMtjhIndexId int `orm:"column(base_from_mtjh_index_id);pk"`
|
|
|
+ IndexCode string `description:"指标编码"`
|
|
|
+ IndexName string `description:"指标名称"`
|
|
|
+ DealValue float64 `description:"成交量"`
|
|
|
+ DataTime time.Time `description:"数据日期"`
|
|
|
+ Unit string `description:"单位"`
|
|
|
+ Frequency string `description:"频度"`
|
|
|
+ StartDate time.Time `description:"开始日期"`
|
|
|
+ EndDate time.Time `description:"结束日期"`
|
|
|
+ LatestValue float64 `description:"最新值"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+ ModifyTime time.Time `description:"更新时间"`
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func GetMtjhBaseInfoFromDataTable(codes []string) (items []*BaseFromMtjhIndex, err error) {
|
|
|
+ codeLens := len(codes)
|
|
|
+ if codeLens == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sql := fmt.Sprintf(`SELECT * FROM base_from_mtjh_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(codeLens))
|
|
|
+ _, err = orm.NewOrmUsingDB("data").Raw(sql, codes).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+type BaseFromCoalmineIndexBase struct {
|
|
|
+ IndexCode string `description:"指标编码"`
|
|
|
+ IndexName string `description:"指标名称"`
|
|
|
+ Unit string `description:"单位"`
|
|
|
+ Frequency string `description:"频度"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+ ModifyTime time.Time `description:"更新时间"`
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func GetCoalmineBaseInfoFromDataTable(codes []string) (items []*BaseFromCoalmineIndexBase, err error) {
|
|
|
+ codeLens := len(codes)
|
|
|
+ if codeLens == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ items = make([]*BaseFromCoalmineIndexBase, 0)
|
|
|
+ var jsmCodes, companyCodes, firmCodes, coastalCodes, inlandCodes []string
|
|
|
+ for _, code := range codes {
|
|
|
+ if strings.Contains(code, "jsm") {
|
|
|
+ jsmCodes = append(jsmCodes, code)
|
|
|
+ }
|
|
|
+ if strings.Contains(code, "company") {
|
|
|
+ companyCodes = append(companyCodes, code)
|
|
|
+ }
|
|
|
+ if strings.Contains(code, "firm") {
|
|
|
+ firmCodes = append(firmCodes, code)
|
|
|
+ }
|
|
|
+ if strings.Contains(code, "coastal") {
|
|
|
+ coastalCodes = append(coastalCodes, code)
|
|
|
+ }
|
|
|
+ if strings.Contains(code, "inland") {
|
|
|
+ inlandCodes = append(inlandCodes, code)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var sql string
|
|
|
+ itemsOnce := make([]*BaseFromCoalmineIndexBase, 0)
|
|
|
+ if len(jsmCodes) > 0 {
|
|
|
+ sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_jsm_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(jsmCodes)))
|
|
|
+ _, err = o.Raw(sql, codes).QueryRows(&itemsOnce)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items = append(items, itemsOnce...)
|
|
|
+ }
|
|
|
+ if len(companyCodes) > 0 {
|
|
|
+ sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_company_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(companyCodes)))
|
|
|
+ _, err = o.Raw(sql, codes).QueryRows(&itemsOnce)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items = append(items, itemsOnce...)
|
|
|
+ }
|
|
|
+ if len(firmCodes) > 0 {
|
|
|
+ sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_firm_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(firmCodes)))
|
|
|
+ _, err = o.Raw(sql, codes).QueryRows(&itemsOnce)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items = append(items, itemsOnce...)
|
|
|
+ }
|
|
|
+ if len(coastalCodes) > 0 {
|
|
|
+ sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_coastal_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(coastalCodes)))
|
|
|
+ _, err = o.Raw(sql, codes).QueryRows(&itemsOnce)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items = append(items, itemsOnce...)
|
|
|
+ }
|
|
|
+ if len(inlandCodes) > 0 {
|
|
|
+ sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_inland_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(inlandCodes)))
|
|
|
+ _, err = o.Raw(sql, codes).QueryRows(&itemsOnce)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items = append(items, itemsOnce...)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|