|
@@ -39,13 +39,50 @@ type BaseFromTradeEicIndex struct {
|
|
|
ModifyTime time.Time
|
|
|
}
|
|
|
|
|
|
-func GetBaseFromEicDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeEicIndex, err error) {
|
|
|
+type BaseFromTradeEicIndexV2 struct {
|
|
|
+ BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
|
|
|
+ Type string
|
|
|
+ EicCode string
|
|
|
+ Name string
|
|
|
+ Status string
|
|
|
+ GasDayStart string
|
|
|
+ GasInStorage string
|
|
|
+ GasInStorageCode string
|
|
|
+ Consumption string
|
|
|
+ ConsumptionCode string
|
|
|
+ ConsumptionFull string
|
|
|
+ ConsumptionFullCode string
|
|
|
+ Full string
|
|
|
+ FullCode string
|
|
|
+ Trend string
|
|
|
+ TrendCode string
|
|
|
+ Injection string
|
|
|
+ InjectionCode string
|
|
|
+ Withdrawal string
|
|
|
+ WithdrawalCode string
|
|
|
+ WorkingGasVolume string
|
|
|
+ WorkingGasVolumeCode string
|
|
|
+ InjectionCapacity string
|
|
|
+ InjectionCapacityCode string
|
|
|
+ WithdrawalCapacity string
|
|
|
+ WithdrawalCapacityCode string
|
|
|
+ Info string
|
|
|
+ Parent string
|
|
|
+ CreateTime time.Time
|
|
|
+ ModifyTime time.Time
|
|
|
+}
|
|
|
+
|
|
|
+func GetBaseFromEicDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeEicIndexV2, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
var name string
|
|
|
if suffix == "" {
|
|
|
name = "eic_code"
|
|
|
} else if suffix == "GS" {
|
|
|
name = "gas_in_storage_code"
|
|
|
+ } else if suffix == "C" {
|
|
|
+ name = "consumption_code"
|
|
|
+ } else if suffix == "CF" {
|
|
|
+ name = "consumption_full_code"
|
|
|
} else if suffix == "F" {
|
|
|
name = "full_code"
|
|
|
} else if suffix == "T" {
|
|
@@ -61,7 +98,7 @@ func GetBaseFromEicDataAllByIndexCode(indexCode, suffix string) (list []*BaseFro
|
|
|
} else if suffix == "WC" {
|
|
|
name = "withdrawal_capacity_code"
|
|
|
}
|
|
|
- sql := `SELECT * FROM base_from_trade_eic_index WHERE %s=? `
|
|
|
+ sql := `SELECT * FROM base_from_trade_eic_index_v2 WHERE %s=? `
|
|
|
sql = fmt.Sprintf(sql, name)
|
|
|
_, err = o.Raw(sql, indexCode).QueryRows(&list)
|
|
|
return
|
|
@@ -79,15 +116,27 @@ func GetGieDataByTradeCode(condition string, pars []interface{}) (item []*BaseFr
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//新增上期能源指标数据
|
|
|
+func GetGieDataByTradeCodeV2(condition string, pars []interface{}) (item []*BaseFromTradeEicIndexV2, err error) {
|
|
|
+ sql := ` SELECT * FROM base_from_trade_eic_index_v2 WHERE 1=1 `
|
|
|
+ o := orm.NewOrm()
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ sql += ` ORDER BY gas_day_start DESC `
|
|
|
+ fmt.Println(sql, pars)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+//新增欧洲天然气指标数据
|
|
|
func AddEdbDataFromGie(edbCode string) (err error) {
|
|
|
var suffix string
|
|
|
l := len(edbCode)
|
|
|
if strings.Contains(edbCode[l-2:], "GS") {
|
|
|
suffix = "GS"
|
|
|
- } else if strings.Contains(edbCode[l-1:], "F") {
|
|
|
- suffix = "F"
|
|
|
- } else if strings.Contains(edbCode[l-1:], "T") {
|
|
|
+ }else if strings.Contains(edbCode[l-2:], "CF") {
|
|
|
+ suffix = "CF"
|
|
|
+ } else if strings.Contains(edbCode[l-1:], "T") {
|
|
|
suffix = "T"
|
|
|
} else if strings.Contains(edbCode[l-2:], "In") {
|
|
|
suffix = "In"
|
|
@@ -99,6 +148,10 @@ func AddEdbDataFromGie(edbCode string) (err error) {
|
|
|
suffix = "IC"
|
|
|
} else if strings.Contains(edbCode[l-2:], "WC") {
|
|
|
suffix = "WC"
|
|
|
+ } else if strings.Contains(edbCode[l-1:], "F") {
|
|
|
+ suffix = "F"
|
|
|
+ } else if strings.Contains(edbCode[l-1:], "C") {
|
|
|
+ suffix = "C"
|
|
|
} else {
|
|
|
suffix = ""
|
|
|
}
|
|
@@ -115,7 +168,7 @@ func AddEdbDataFromGie(edbCode string) (err error) {
|
|
|
existMap := make(map[string]string)
|
|
|
|
|
|
for _, sv := range eicBaseDataAll {
|
|
|
- eDate := sv.GasDayStartedOn
|
|
|
+ eDate := sv.GasDayStart
|
|
|
dataTime, err := time.Parse(utils.FormatDate, eDate)
|
|
|
if err != nil {
|
|
|
fmt.Println("time.Parse Err:" + eDate)
|
|
@@ -129,6 +182,14 @@ func AddEdbDataFromGie(edbCode string) (err error) {
|
|
|
//name = "gas_in_storage"
|
|
|
addSql += GetAddSql("0", edbCode, eDate, timeStr, sv.GasInStorage)
|
|
|
existMap[eDate] = sv.GasInStorage
|
|
|
+ } else if suffix == "C" {
|
|
|
+ //name = "consumption"
|
|
|
+ addSql += GetAddSql("0", edbCode, eDate, timeStr, sv.Full)
|
|
|
+ existMap[eDate] = sv.Consumption
|
|
|
+ } else if suffix == "CF" {
|
|
|
+ //name = "consumption_full"
|
|
|
+ addSql += GetAddSql("0", edbCode, eDate, timeStr, sv.Full)
|
|
|
+ existMap[eDate] = sv.ConsumptionFull
|
|
|
} else if suffix == "F" {
|
|
|
//name = "full"
|
|
|
addSql += GetAddSql("0", edbCode, eDate, timeStr, sv.Full)
|
|
@@ -184,9 +245,9 @@ func RefreshEdbDataFromGie(edbInfoId int, edbCode, startDate string) (err error)
|
|
|
l := len(edbCode)
|
|
|
if strings.Contains(edbCode[l-2:], "GS") {
|
|
|
suffix = "GS"
|
|
|
- } else if strings.Contains(edbCode[l-1:], "F") {
|
|
|
- suffix = "F"
|
|
|
- } else if strings.Contains(edbCode[l-1:], "T") {
|
|
|
+ }else if strings.Contains(edbCode[l-2:], "CF") {
|
|
|
+ suffix = "CF"
|
|
|
+ } else if strings.Contains(edbCode[l-1:], "T") {
|
|
|
suffix = "T"
|
|
|
} else if strings.Contains(edbCode[l-2:], "In") {
|
|
|
suffix = "In"
|
|
@@ -198,6 +259,10 @@ func RefreshEdbDataFromGie(edbInfoId int, edbCode, startDate string) (err error)
|
|
|
suffix = "IC"
|
|
|
} else if strings.Contains(edbCode[l-2:], "WC") {
|
|
|
suffix = "WC"
|
|
|
+ } else if strings.Contains(edbCode[l-1:], "F") {
|
|
|
+ suffix = "F"
|
|
|
+ } else if strings.Contains(edbCode[l-1:], "C") {
|
|
|
+ suffix = "C"
|
|
|
} else {
|
|
|
suffix = ""
|
|
|
}
|
|
@@ -212,10 +277,10 @@ func RefreshEdbDataFromGie(edbInfoId int, edbCode, startDate string) (err error)
|
|
|
}
|
|
|
|
|
|
if startDate != "" {
|
|
|
- condition += " AND gas_day_started_on>=? "
|
|
|
+ condition += " AND gas_day_start>=? "
|
|
|
pars = append(pars, startDate)
|
|
|
}
|
|
|
- eicDataList, err := GetGieDataByTradeCode(condition, pars)
|
|
|
+ eicDataList, err := GetGieDataByTradeCodeV2(condition, pars)
|
|
|
fmt.Println("all eicDataList", len(eicDataList))
|
|
|
//获取指标所有数据
|
|
|
var existCondition string
|
|
@@ -244,6 +309,10 @@ func RefreshEdbDataFromGie(edbInfoId int, edbCode, startDate string) (err error)
|
|
|
var value string
|
|
|
if suffix == "GS" {
|
|
|
value = v.GasInStorage
|
|
|
+ } else if suffix == "C" {
|
|
|
+ value = v.Consumption
|
|
|
+ } else if suffix == "CF" {
|
|
|
+ value = v.ConsumptionFull
|
|
|
} else if suffix == "F" {
|
|
|
value = v.Full
|
|
|
} else if suffix == "T" {
|
|
@@ -261,8 +330,8 @@ func RefreshEdbDataFromGie(edbInfoId int, edbCode, startDate string) (err error)
|
|
|
}
|
|
|
item := v
|
|
|
itemValue := value
|
|
|
- if findItem, ok := existMap[v.GasDayStartedOn]; !ok {
|
|
|
- eDate := item.GasDayStartedOn
|
|
|
+ if findItem, ok := existMap[v.GasDayStart]; !ok {
|
|
|
+ eDate := item.GasDayStart
|
|
|
sValue := itemValue
|
|
|
if sValue != "" {
|
|
|
dataTime, err := time.Parse(utils.FormatDate, eDate)
|
|
@@ -286,7 +355,7 @@ func RefreshEdbDataFromGie(edbInfoId int, edbCode, startDate string) (err error)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- dataMap[v.GasDayStartedOn] = v.GasDayStartedOn
|
|
|
+ dataMap[v.GasDayStart] = v.GasDayStart
|
|
|
}
|
|
|
if isAdd {
|
|
|
addSql = strings.TrimRight(addSql, ",")
|