Эх сурвалжийг харах

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_data_crawler

xingzai 3 жил өмнө
parent
commit
86ea18088e

+ 3 - 3
services/commodity_trade_cffex.go

@@ -123,7 +123,7 @@ func SyncRankingFromCffex() {
 				switch i.Value {
 				case "0":
 					item.DealShortName = i.ShortName
-					item.DealName = fmt.Sprintf("%s", i.ShortName+"_成交量_"+i.ContractCode)
+					item.DealName = fmt.Sprintf("%s", i.ShortName+"_"+i.ContractCode+"_成交量(手)")
 					item.DealCode = cffexIndexCodeGenerator(item.DealShortName, item.DealName, i.ContractCode, "deal")
 					item.DealValue = i.Volume
 					item.DealChange = i.Varvolume
@@ -132,7 +132,7 @@ func SyncRankingFromCffex() {
 					dataCode = item.DealCode
 				case "1":
 					item.BuyShortName = i.ShortName
-					item.BuyName = fmt.Sprintf("%s", i.ShortName+"_持买单量_"+i.ContractCode)
+					item.BuyName = fmt.Sprintf("%s", i.ShortName+"_"+i.ContractCode+"_持买单量(手)")
 					item.BuyCode = cffexIndexCodeGenerator(item.BuyShortName, item.BuyName, i.ContractCode, "buy")
 					item.BuyValue = i.Volume
 					item.BuyChange = i.Varvolume
@@ -141,7 +141,7 @@ func SyncRankingFromCffex() {
 					dataCode = item.BuyCode
 				case "2":
 					item.SoldShortName = i.ShortName
-					item.SoldName = fmt.Sprintf("%s", i.ShortName+"_持卖单量_"+i.ContractCode)
+					item.SoldName = fmt.Sprintf("%s", i.ShortName+"_"+i.ContractCode+"_持卖单量(手)")
 					item.SoldCode = cffexIndexCodeGenerator(item.SoldShortName, item.SoldName, i.ContractCode, "sold")
 					item.SoldValue = i.Volume
 					item.SoldChange = i.Varvolume

+ 6 - 6
services/commodity_trade_ine.go

@@ -44,7 +44,7 @@ var ineIndexCode string
 var ineIndexCodeMap = make(map[string]string)
 
 func IneIndexCodeGenerator(shortName, indexName, contractCode, suffix string) string {
-	if shortName == ""{
+	if shortName == "" {
 		indexCode = ""
 		return indexCode
 	}
@@ -57,7 +57,7 @@ func IneIndexCodeGenerator(shortName, indexName, contractCode, suffix string) st
 			strResult += rows[i][0]
 		}
 	}
-	ineIndexCode,_ := ineIndexCodeMap[indexName]
+	ineIndexCode, _ := ineIndexCodeMap[indexName]
 	if ineIndexCode == "" {
 		ineIndexCode = strResult + contractCode + suffix
 		ineIndexCodeMap[indexName] = ineIndexCode
@@ -116,10 +116,10 @@ func SyncRankingFromIne() {
 				item.DealShortName = p.ParticipantName1
 				item.BuyShortName = p.ParticipantName2
 				item.SoldShortName = p.ParticipantName3
-				item.DealName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName1+"_成交量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-				item.BuyName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName2+"_持买单量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-				item.SoldName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName3+"_持卖单量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-				item.DealCode = IneIndexCodeGenerator(item.DealShortName, item.DealName, p.ContractCode,  "deal")
+				item.DealName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName1+"_"+p.ContractCode+"_成交量"), " ", "", -1)
+				item.BuyName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName2+"_"+p.ContractCode+"_持买单量"), " ", "", -1)
+				item.SoldName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName3+"_"+p.ContractCode+"_持卖单量"), " ", "", -1)
+				item.DealCode = IneIndexCodeGenerator(item.DealShortName, item.DealName, p.ContractCode, "deal")
 				item.BuyCode = IneIndexCodeGenerator(item.BuyShortName, item.BuyName, p.ContractCode, "buy")
 				item.SoldCode = IneIndexCodeGenerator(item.SoldShortName, item.SoldName, p.ContractCode, "sold")
 				item.DealValue = p.Deal

+ 12 - 12
services/commodity_trade_shanghai.go

@@ -44,7 +44,7 @@ var indexCode string
 var indexCodeMap = make(map[string]string)
 
 func shIndexCodeGenerator(shortName, indexName, contractCode, suffix string) string {
-	if shortName == ""{
+	if shortName == "" {
 		indexCode = ""
 		return indexCode
 	}
@@ -57,7 +57,7 @@ func shIndexCodeGenerator(shortName, indexName, contractCode, suffix string) str
 			strResult += rows[i][0]
 		}
 	}
-	indexCode,_ := indexCodeMap[indexName]
+	indexCode, _ := indexCodeMap[indexName]
 	if indexCode == "" {
 		indexCode = strResult + contractCode + suffix
 		indexCodeMap[indexName] = indexCode
@@ -66,7 +66,7 @@ func shIndexCodeGenerator(shortName, indexName, contractCode, suffix string) str
 			fmt.Println("add Code err:", err)
 		}
 	}
-	return indexCode
+	return strings.Replace(indexCode, " ", "", -1)
 }
 
 // SyncRankingFromShangHai 上海商品交易所持单排名
@@ -111,19 +111,19 @@ func SyncRankingFromShangHai() {
 		var itemVerifyCode int
 		//处理指标
 		for _, p := range position {
-			if p.Rank > 0 && p.Rank <40 && p.ParticipantName1 != "" {
-				if strings.Replace(p.ProductName, " ", "", -1) != "20号胶"{
+			if p.Rank > 0 && p.Rank < 40 && p.ParticipantName1 != "" {
+				if strings.Replace(p.ProductName, " ", "", -1) != "20号胶" && strings.Replace(p.ProductName, " ", "", -1) != "低硫燃料油" {
 					//成交量
 					item.Rank = p.Rank
 					item.DealShortName = p.ParticipantName1
 					item.BuyShortName = p.ParticipantName2
 					item.SoldShortName = p.ParticipantName3
-					item.DealName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName1+"_成交量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-					item.BuyName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName2+"_持买单量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-					item.SoldName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName3+"_持卖单量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-					item.DealCode =  shIndexCodeGenerator(item.DealShortName, item.DealName, p.ContractCode, "deal")
-					item.BuyCode =  shIndexCodeGenerator(item.BuyShortName, item.BuyName, p.ContractCode, "buy")
-					item.SoldCode =  shIndexCodeGenerator(item.SoldShortName, item.SoldName, p.ContractCode, "sold")
+					item.DealName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName1+"_"+p.ContractCode+"_成交量"), " ", "", -1)
+					item.BuyName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName2+"_"+p.ContractCode+"_持买单量"), " ", "", -1)
+					item.SoldName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName3+"_"+p.ContractCode+"_持卖单量"), " ", "", -1)
+					item.DealCode = shIndexCodeGenerator(item.DealShortName, item.DealName, p.ContractCode, "deal")
+					item.BuyCode = shIndexCodeGenerator(item.BuyShortName, item.BuyName, p.ContractCode, "buy")
+					item.SoldCode = shIndexCodeGenerator(item.SoldShortName, item.SoldName, p.ContractCode, "sold")
 					item.DealValue = p.Deal
 					item.DealChange = p.Change1
 					item.BuyValue = p.BuyIn
@@ -138,7 +138,7 @@ func SyncRankingFromShangHai() {
 					item.DataTime = tradeDate
 
 					itemVerifyCode = item.BuyValue + item.DealValue + item.SoldValue
-					if existIndex, ok := existIndexMap[item.DealName + item.BuyName + item.SoldName]; !ok {
+					if existIndex, ok := existIndexMap[item.DealName+item.BuyName+item.SoldName]; !ok {
 						newID, err := models.AddBaseFromTradeShangHaiIndex(item)
 						if err != nil {
 							fmt.Println("insert error:", err)

+ 3 - 3
services/commodity_trade_zhengzhou.go

@@ -220,17 +220,17 @@ func SyncRankingFromZhengzhou() {
 						item := new(models.BaseFromTradeZhengzhouIndex)
 						item.Rank, _ = strconv.Atoi(rank)
 						item.DealShortName = memberShortNameArr[0]
-						item.DealName = memberShortNameArr[0] + "_" + dealSuffix + "_" + classifyName + "_" + classifyType
+						item.DealName = memberShortNameArr[0] + "_" + classifyName + "_" + dealSuffix
 						item.DealCode = zIndexCodeGenerator(item.DealShortName, item.DealName, classifyName, "deal")
 						item.DealValue, _ = strconv.Atoi(dealVal)
 						item.DealChange, _ = strconv.Atoi(dealAddCutVal)
 						item.BuyShortName = memberShortNameArr[1]
-						item.BuyName = memberShortNameArr[1] + "_" + buySuffix + "_" + classifyName + "_" + classifyType
+						item.BuyName = memberShortNameArr[1] + "_" + classifyName + "_" + buySuffix
 						item.BuyCode = zIndexCodeGenerator(item.BuyShortName, item.BuyName, classifyName, "buy")
 						item.BuyValue, _ = strconv.Atoi(buyVal)
 						item.BuyChange, _ = strconv.Atoi(buyAddCutVal)
 						item.SoldShortName = memberShortNameArr[2]
-						item.SoldName = memberShortNameArr[2] + "_" + sellSuffix + "_" + classifyName + "_" + classifyType
+						item.SoldName = memberShortNameArr[2] + "_" + classifyName + "_" + sellSuffix
 						item.SoldCode = zIndexCodeGenerator(item.SoldShortName, item.SoldName, classifyName, "sold")
 						item.SoldValue, _ = strconv.Atoi(sellVal)
 						item.SoldChange, _ = strconv.Atoi(sellAddCutVal)

+ 354 - 0
services/sso_eic.go

@@ -0,0 +1,354 @@
+package services
+
+import (
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_data_crawler/models"
+	"rdluck_tools/http"
+	"strconv"
+	"time"
+)
+
+type EicListing struct {
+	Name       string       `json:"name"`
+	ShortName  string       `json:"short_name"`
+	Type       string       `json:"type"`
+	Eic        string       `json:"eic"`
+	Country    string       `json:"country"`
+	Url        string       `json:"url"`
+	Facilities []Facilities `json:"facilities"`
+}
+
+type Facilities struct {
+	Name    string `json:"name"`
+	Type    string `json:"type"`
+	Eic     string `json:"eic"`
+	Country string `json:"country"`
+	Company string `json:"company"`
+	Url     string `json:"url"`
+}
+type Storage struct {
+	Status             string `json:"status"`
+	GasDayStartedOn    string `json:"gasDayStartedOn"`
+	GasInStorage       string `json:"gasInStorage"`
+	Full               string `json:"full"`
+	Trend              string `json:"trend"`
+	Injection          string `json:"injection"`
+	Withdrawal         string `json:"withdrawal"`
+	WorkingGasVolume   string `json:"workingGasVolume"`
+	InjectionCapacity  string `json:"injectionCapacity"`
+	WithdrawalCapacity string `json:"withdrawalCapacity"`
+	Info               string `json:"info"`
+}
+
+var eicIndexCodeMap = make(map[string]string)
+
+func SyncStorageFromEic() {
+	allCode, err := models.GetIndexCodeFromMapping("Eic")
+	if err != nil {
+		fmt.Println("select Code err:", err)
+	}
+	for _, item := range allCode {
+		eicIndexCodeMap[item.IndexName] = item.IndexCode
+	}
+	baseUrl := "https://agsi.gie.eu/api/eic-listing/SSO/view"
+	body, err := http.Get(baseUrl)
+	if err != nil {
+		fmt.Println("GetData Err:" + err.Error())
+		return
+	}
+
+	var eicListing []EicListing
+	err = json.Unmarshal(body, &eicListing)
+	for _, sso := range eicListing {
+		var codeMapList []*models.BaseFromTradeMapping
+
+		existIndexMap := make(map[string]*models.BaseFromTradeEicIndex)
+		//获取所有指标信息
+		allIndex, err := models.GetSSOFromEicIndexAll(sso.Name)
+		if err != nil {
+			fmt.Println("select err:", err)
+		}
+		for _, v := range allIndex {
+			existIndexMap[v.GasDayStartedOn+v.Name] = v
+		}
+
+		ssoUrl := sso.Url
+		ssoBody, err := http.Get(ssoUrl)
+		fmt.Println("ssoUrl:", ssoUrl)
+		if err != nil {
+			fmt.Println("GetData Err:" + err.Error())
+			continue
+		}
+		var ssoStorages []Storage
+		err = json.Unmarshal(ssoBody, &ssoStorages)
+		//SSO item
+		var ssoItems []*models.BaseFromTradeEicIndex
+		for _, storageItem := range ssoStorages {
+			gasInStorage, _ := strconv.ParseFloat(storageItem.GasInStorage, 64)
+			full, _ := strconv.ParseFloat(storageItem.Full, 64)
+			trend, _ := strconv.ParseFloat(storageItem.Trend, 64)
+			injection, _ := strconv.ParseFloat(storageItem.Injection, 64)
+			withdrawal, _ := strconv.ParseFloat(storageItem.Withdrawal, 64)
+			workingGasVolume, _ := strconv.ParseFloat(storageItem.WorkingGasVolume, 64)
+			injectionCapacity, _ := strconv.ParseFloat(storageItem.InjectionCapacity, 64)
+			withdrawalCapacity, _ := strconv.ParseFloat(storageItem.WithdrawalCapacity, 64)
+			ssoItem := models.BaseFromTradeEicIndex{
+				BaseFromEicIndexId: 0,
+				Country:            sso.Country,
+				Type:               sso.Type,
+				EicCode:            sso.Eic + sso.Country,
+				ShortName:          sso.ShortName,
+				Name:               sso.Name,
+				Status:             storageItem.Status,
+				GasDayStartedOn:    storageItem.GasDayStartedOn,
+				GasInStorage:       gasInStorage,
+				Full:               full,
+				Trend:              trend,
+				Injection:          injection,
+				Withdrawal:         withdrawal,
+				WorkingGasVolume:   workingGasVolume,
+				InjectionCapacity:  injectionCapacity,
+				WithdrawalCapacity: withdrawalCapacity,
+				Info:               storageItem.Info,
+				CreateTime:         time.Now(),
+				ModifyTime:         time.Now(),
+			}
+			itemVerifyCode := ssoItem.GasInStorage + ssoItem.Full + ssoItem.Trend + ssoItem.Injection + ssoItem.Withdrawal
+
+			if existIndex, ok := existIndexMap[ssoItem.GasDayStartedOn+ssoItem.Name]; !ok {
+				ssoItems = append(ssoItems, &ssoItem)
+
+				//newID, err := models.AddBaseFromEicIndex(&ssoItem)
+				//if err != nil {
+				//	fmt.Println("insert error:", err)
+				//}
+				//fmt.Println("insert new indexID:", newID)
+				existIndexMap[ssoItem.GasDayStartedOn+ssoItem.Name] = &ssoItem
+			} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
+				//更新
+				err := models.ModifyBaseFromEicIndex(ssoItem.GasInStorage, ssoItem.Full, ssoItem.Trend, ssoItem.Injection, ssoItem.Withdrawal, existIndex.BaseFromEicIndexId)
+				if err != nil {
+					fmt.Println("data update err:", err)
+				}
+			}
+		}
+		if _, ok := eicIndexCodeMap[sso.Country+sso.Name]; !ok {
+			codeMappingItem := models.BaseFromTradeMapping{
+				BaseFromTradeMappingId: 0,
+				IndexName:              sso.Country+sso.Name,
+				IndexCode:              sso.Country + sso.Eic,
+				Exchange:               "EIC",
+			}
+			codeMapList = append(codeMapList, &codeMappingItem)
+			eicIndexCodeMap[sso.Country+sso.Name] = sso.Country + sso.Eic
+		}
+
+		if len(ssoItems) != 0 {
+			successNums, err := models.AddEicDataMulti(ssoItems)
+			fmt.Println("SSO successNums:", successNums)
+			if err != nil {
+				fmt.Println("AddSSODataMulti err:", err)
+			}
+		}
+
+		facilities := sso.Facilities
+		var facItems []*models.BaseFromTradeEicIndex
+		for _, facility := range facilities {
+			//获取所有指标信息
+			allFacIndex, err := models.GetFacFromEicIndexAll(facility.Name)
+			if err != nil {
+				fmt.Println("select err:", err)
+			}
+			existFacIndexMap := make(map[string]*models.BaseFromTradeEicIndex)
+			for _, v := range allFacIndex {
+				existFacIndexMap[v.Name+v.GasDayStartedOn] = v
+			}
+			facUrl := facility.Url
+			facBody, err := http.Get(ssoUrl)
+			fmt.Println("facUrl:", facUrl)
+			if err != nil {
+				fmt.Println("GetData Err:" + err.Error())
+				continue
+			}
+			var facStorages []Storage
+			err = json.Unmarshal(facBody, &facStorages)
+
+			for _, storageItem := range facStorages {
+				gasInStorage, _ := strconv.ParseFloat(storageItem.GasInStorage, 64)
+				full, _ := strconv.ParseFloat(storageItem.Full, 64)
+				trend, _ := strconv.ParseFloat(storageItem.Trend, 64)
+				injection, _ := strconv.ParseFloat(storageItem.Injection, 64)
+				withdrawal, _ := strconv.ParseFloat(storageItem.Withdrawal, 64)
+				workingGasVolume, _ := strconv.ParseFloat(storageItem.WorkingGasVolume, 64)
+				injectionCapacity, _ := strconv.ParseFloat(storageItem.InjectionCapacity, 64)
+				withdrawalCapacity, _ := strconv.ParseFloat(storageItem.WithdrawalCapacity, 64)
+				facItem := models.BaseFromTradeEicIndex{
+					BaseFromEicIndexId: 0,
+					Country:            facility.Country,
+					Type:               facility.Type,
+					EicCode:            facility.Eic + facility.Country,
+					ShortName:          sso.ShortName,
+					Name:               facility.Name,
+					Status:             storageItem.Status,
+					GasDayStartedOn:    storageItem.GasDayStartedOn,
+					GasInStorage:       gasInStorage,
+					Full:               full,
+					Trend:              trend,
+					Injection:          injection,
+					Withdrawal:         withdrawal,
+					WorkingGasVolume:   workingGasVolume,
+					InjectionCapacity:  injectionCapacity,
+					WithdrawalCapacity: withdrawalCapacity,
+					Info:               storageItem.Info,
+					CreateTime:         time.Now(),
+					ModifyTime:         time.Now(),
+				}
+				itemVerifyCode := facItem.GasInStorage + facItem.Full + facItem.Trend + facItem.Injection + facItem.Withdrawal
+
+				if existIndex, ok := existFacIndexMap[facItem.Name+facItem.GasDayStartedOn]; !ok {
+					facItems = append(facItems, &facItem)
+
+					//newID, err := models.AddBaseFromEicIndex(&facItem)
+					//if err != nil {
+					//	fmt.Println("insert error:", err)
+					//}
+					//fmt.Println("insert new indexID:", newID)
+					existFacIndexMap[facItem.Name+facItem.GasDayStartedOn] = &facItem
+				} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
+					//更新
+					err := models.ModifyBaseFromEicIndex(facItem.GasInStorage, facItem.Full, facItem.Trend, facItem.Injection, facItem.Withdrawal, existIndex.BaseFromEicIndexId)
+					if err != nil {
+						fmt.Println("data update err:", err)
+					}
+				}
+			}
+			if _, ok := eicIndexCodeMap[facility.Country+facility.Name]; !ok {
+				codeMappingItem := models.BaseFromTradeMapping{
+					BaseFromTradeMappingId: 0,
+					IndexName:              facility.Country+facility.Name,
+					IndexCode:              facility.Country+facility.Eic,
+					Exchange:               "EIC",
+				}
+				codeMapList = append(codeMapList, &codeMappingItem)
+				eicIndexCodeMap[facility.Country+facility.Name] = facility.Country+facility.Eic
+			}
+		}
+		if len(facItems) != 0 {
+			successNums, err := models.AddEicDataMulti(facItems)
+			fmt.Println("fac successNums:", successNums)
+			if err != nil {
+				fmt.Println("AddFacDataMulti err:", err)
+			}
+		}
+		successNums, err := models.AddEicCodeMulti(codeMapList)
+		fmt.Println("codeMapping successNums:", successNums)
+		if err != nil {
+			fmt.Println("AddEicCodeMulti err:", err)
+		}
+	}
+	//国家级,洲际级统计
+	var codeMapList []*models.BaseFromTradeMapping
+
+	Countries := []string{"eu", "AT", "BE", "BG", "HR", "CZ",
+		"DK", "FR", "DE", "HU", "IE", "IT", "LV", "NL", "PL",
+		"PT", "RO", "SK", "ES", "SE", "GB", "ne", "RS", "UA"}
+	for _, country := range Countries {
+		var countryItems []*models.BaseFromTradeEicIndex
+		//获取所有指标信息
+		allFacIndex, err := models.GetCountryFromEicIndexAll(country)
+		if err != nil {
+			fmt.Println("select err:", err)
+		}
+		existFacIndexMap := make(map[string]*models.BaseFromTradeEicIndex)
+		for _, v := range allFacIndex {
+			existFacIndexMap[v.Name+v.GasDayStartedOn] = v
+		}
+		countryUrl := fmt.Sprintf("https://agsi.gie.eu/api/data/%s", country)
+		fmt.Println("countryUrl:", countryUrl)
+		body, err := http.Get(countryUrl)
+		if err != nil {
+			fmt.Println("GetData Err:" + err.Error())
+			continue
+		}
+		var countryStorages []Storage
+		err = json.Unmarshal(body, &countryStorages)
+
+		for _, countryStorage := range countryStorages {
+			gasInStorage, _ := strconv.ParseFloat(countryStorage.GasInStorage, 64)
+			full, _ := strconv.ParseFloat(countryStorage.Full, 64)
+			trend, _ := strconv.ParseFloat(countryStorage.Trend, 64)
+			injection, _ := strconv.ParseFloat(countryStorage.Injection, 64)
+			withdrawal, _ := strconv.ParseFloat(countryStorage.Withdrawal, 64)
+			workingGasVolume, _ := strconv.ParseFloat(countryStorage.WorkingGasVolume, 64)
+			injectionCapacity, _ := strconv.ParseFloat(countryStorage.InjectionCapacity, 64)
+			withdrawalCapacity, _ := strconv.ParseFloat(countryStorage.WithdrawalCapacity, 64)
+			countryItem := models.BaseFromTradeEicIndex{
+				BaseFromEicIndexId: 0,
+				Country:            country,
+				Type:               "country",
+				EicCode:            country,
+				ShortName:          country,
+				Name:               country,
+				Status:             countryStorage.Status,
+				GasDayStartedOn:    countryStorage.GasDayStartedOn,
+				GasInStorage:       gasInStorage,
+				Full:               full,
+				Trend:              trend,
+				Injection:          injection,
+				Withdrawal:         withdrawal,
+				WorkingGasVolume:   workingGasVolume,
+				InjectionCapacity:  injectionCapacity,
+				WithdrawalCapacity: withdrawalCapacity,
+				Info:               countryStorage.Info,
+				CreateTime:         time.Now(),
+				ModifyTime:         time.Now(),
+			}
+			if country == "eu" || country == "ne" {
+				countryItem.Type = "continent"
+			}
+			itemVerifyCode := countryItem.GasInStorage + countryItem.Full + countryItem.Trend + countryItem.Injection + countryItem.Withdrawal
+
+			if existIndex, ok := existFacIndexMap[countryItem.Name+countryItem.GasDayStartedOn]; !ok {
+				countryItems = append(countryItems, &countryItem)
+
+				//newID, err := models.AddBaseFromEicIndex(&countryItem)
+				//if err != nil {
+				//	fmt.Println("insert error:", err)
+				//}
+				//fmt.Println("insert new indexID:", newID)
+				existFacIndexMap[countryItem.Name+countryItem.GasDayStartedOn] = &countryItem
+			} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
+				//更新
+				err := models.ModifyBaseFromEicIndex(countryItem.GasInStorage, countryItem.Full, countryItem.Trend, countryItem.Injection, countryItem.Withdrawal, existIndex.BaseFromEicIndexId)
+				if err != nil {
+					fmt.Println("data update err:", err)
+				}
+			}
+		}
+		if len(countryItems) != 0 {
+			successNums, err := models.AddEicDataMulti(countryItems)
+			fmt.Println("Country successNums:", successNums)
+			if err != nil {
+				fmt.Println("AddCountryDataMulti err:", err)
+			}
+
+		}
+
+		if _, ok := eicIndexCodeMap[country]; !ok {
+			codeMappingItem := models.BaseFromTradeMapping{
+				BaseFromTradeMappingId: 0,
+				IndexName:              country,
+				IndexCode:              country,
+				Exchange:               "EIC",
+			}
+			codeMapList = append(codeMapList, &codeMappingItem)
+			eicIndexCodeMap[country] = country
+		}
+	}
+	successNums, err := models.AddEicCodeMulti(codeMapList)
+	fmt.Println("codeMapping successNums:", successNums)
+	if err != nil {
+		fmt.Println("AddEicCodeMulti err:", err)
+	}
+}