|
@@ -2,9 +2,9 @@ package services
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "eta/eta_crawler/models"
|
|
|
+ "eta/eta_crawler/utils"
|
|
|
"fmt"
|
|
|
- "hongze/hongze_data_crawler/models"
|
|
|
- "hongze/hongze_data_crawler/utils"
|
|
|
"io/ioutil"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
@@ -12,8 +12,8 @@ import (
|
|
|
)
|
|
|
|
|
|
type EicData struct {
|
|
|
- LastPage int `json:"last_page"`
|
|
|
- Total int `json:"total"`
|
|
|
+ LastPage int `json:"last_page"`
|
|
|
+ Total int `json:"total"`
|
|
|
DataSet string `json:"dataset"`
|
|
|
GasDay string `json:"gas_day"`
|
|
|
Data []Children `json:"data"`
|
|
@@ -65,7 +65,7 @@ func SyncStorageFromEicV2() {
|
|
|
for _, item := range allCode {
|
|
|
eicIndexCodeMapV2[item.IndexName] = item.IndexCode
|
|
|
}
|
|
|
- for i :=10; i >= 0; i-- {
|
|
|
+ for i := 10; i >= 0; i-- {
|
|
|
baseUrl := "https://agsi.gie.eu/api?date=%s"
|
|
|
//t, _ := time.Parse(utils.FormatDate, "2022-08-15")
|
|
|
//st := t.AddDate(0, 0, i).Format(utils.FormatDate)
|
|
@@ -169,13 +169,13 @@ func SyncStorageFromEicV2() {
|
|
|
|
|
|
if existIndex, ok := existIndexMap[continentItem.GasDayStart+continentItem.EicCode]; !ok {
|
|
|
//新增
|
|
|
- if continentItem.Status != "N"{
|
|
|
+ if continentItem.Status != "N" {
|
|
|
insertItems = append(insertItems, &continentItem)
|
|
|
existIndexMap[continentItem.GasDayStart+continentItem.EicCode] = &continentItem
|
|
|
}
|
|
|
} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
|
|
|
//更新
|
|
|
- if continentItem.Status != "N"{
|
|
|
+ if continentItem.Status != "N" {
|
|
|
err := models.ModifyBaseFromEicIndexV2(continentItem.GasInStorage, continentItem.Full, continentItem.Trend, continentItem.Injection, continentItem.Withdrawal, existIndex.BaseFromEicIndexId)
|
|
|
if err != nil {
|
|
|
fmt.Println("data update err:", err)
|
|
@@ -251,13 +251,13 @@ func SyncStorageFromEicV2() {
|
|
|
|
|
|
if existIndex, ok := existIndexMap[countryItem.GasDayStart+countryItem.EicCode]; !ok {
|
|
|
//新增
|
|
|
- if countryItem.Status != "N"{
|
|
|
+ if countryItem.Status != "N" {
|
|
|
insertItems = append(insertItems, &countryItem)
|
|
|
existIndexMap[countryItem.GasDayStart+countryItem.EicCode] = &countryItem
|
|
|
}
|
|
|
} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
|
|
|
//更新
|
|
|
- if countryItem.Status != "N"{
|
|
|
+ if countryItem.Status != "N" {
|
|
|
err := models.ModifyBaseFromEicIndexV2(countryItem.GasInStorage, countryItem.Full, countryItem.Trend, countryItem.Injection, countryItem.Withdrawal, existIndex.BaseFromEicIndexId)
|
|
|
if err != nil {
|
|
|
fmt.Println("data update err:", err)
|
|
@@ -334,13 +334,13 @@ func SyncStorageFromEicV2() {
|
|
|
|
|
|
if existIndex, ok := existIndexMap[ssoItem.GasDayStart+ssoItem.EicCode]; !ok {
|
|
|
//新增
|
|
|
- if ssoItem.Status != "N"{
|
|
|
+ if ssoItem.Status != "N" {
|
|
|
insertItems = append(insertItems, &ssoItem)
|
|
|
existIndexMap[ssoItem.GasDayStart+ssoItem.EicCode] = &ssoItem
|
|
|
}
|
|
|
} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
|
|
|
//更新
|
|
|
- if ssoItem.Status != "N"{
|
|
|
+ if ssoItem.Status != "N" {
|
|
|
err := models.ModifyBaseFromEicIndexV2(ssoItem.GasInStorage, ssoItem.Full, ssoItem.Trend, ssoItem.Injection, ssoItem.Withdrawal, existIndex.BaseFromEicIndexId)
|
|
|
if err != nil {
|
|
|
fmt.Println("data update err:", err)
|
|
@@ -417,13 +417,13 @@ func SyncStorageFromEicV2() {
|
|
|
|
|
|
if existIndex, ok := existIndexMap[facItem.GasDayStart+facItem.EicCode]; !ok {
|
|
|
//新增
|
|
|
- if facItem.Status != "N"{
|
|
|
+ if facItem.Status != "N" {
|
|
|
insertItems = append(insertItems, &facItem)
|
|
|
existIndexMap[facItem.GasDayStart+facItem.EicCode] = &facItem
|
|
|
}
|
|
|
} else if existIndex != nil && itemVerifyCode != (existIndex.GasInStorage+existIndex.Full+existIndex.Trend+existIndex.Injection+existIndex.Withdrawal) {
|
|
|
//更新
|
|
|
- if facItem.Status != "N"{
|
|
|
+ if facItem.Status != "N" {
|
|
|
err := models.ModifyBaseFromEicIndexV2(facItem.GasInStorage, facItem.Full, facItem.Trend, facItem.Injection, facItem.Withdrawal, existIndex.BaseFromEicIndexId)
|
|
|
if err != nil {
|
|
|
fmt.Println("data update err:", err)
|