|
@@ -1,8 +1,9 @@
|
|
|
// @Author gmy 2024/8/6 10:50:00
|
|
|
-package main
|
|
|
+package liangyou
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "encoding/json"
|
|
|
"eta/eta_data_analysis/models"
|
|
|
"eta/eta_data_analysis/utils"
|
|
|
"fmt"
|
|
@@ -122,12 +123,18 @@ func (p *ImportCostProcessor) Process(ctx context.Context, product string, repor
|
|
|
logs.Error("ProcessingImportCostProcessor Process() : Failed to get index id: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ProcessingImportCostProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingImportCostProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
continue
|
|
@@ -152,9 +159,7 @@ func (p *ImportCostProcessor) Process(ctx context.Context, product string, repor
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
return result, nil
|
|
@@ -244,11 +249,18 @@ func (p *ProcessingProfitProcessor) Process(ctx context.Context, product string,
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ProcessingProfitProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingProfitProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
continue
|
|
@@ -357,11 +369,18 @@ func (p *ShippingCostProcessor) Process(ctx context.Context, product string, rep
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ShippingCostProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ShippingCostProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
continue
|
|
@@ -492,11 +511,19 @@ func (p *SupplyDemandBalanceProcessor) Process(ctx context.Context, product stri
|
|
|
logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get year month: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTimeYM(indexId, yearMonth)
|
|
|
+
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["YearMonth"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME_YM)
|
|
|
if err != nil {
|
|
|
logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 存在走更新逻辑 主要更新今年在去年的预估值
|
|
@@ -514,20 +541,36 @@ func (p *SupplyDemandBalanceProcessor) Process(ctx context.Context, product stri
|
|
|
|
|
|
if time.Before(timeZero) {
|
|
|
// 更新指标数据
|
|
|
- err := models.UpdateLyDataById(indexData.BaseFromLyDataId, value)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["Id"] = indexData.BaseFromLyDataId
|
|
|
+ paramsLib["Value"] = value
|
|
|
+ _, err := httpRequestFill(paramsLib, utils.UPDATE_LY_DATA_BY_ID)
|
|
|
if err != nil {
|
|
|
- logs.Error("SupplyDemandBalanceProcessor Process() : Failed to update data: %v", err)
|
|
|
- continue
|
|
|
+ return nil, fmt.Errorf("SupplyDemandBalanceProcessor Process() : failed to parse value '%s': %v", valueStr, err)
|
|
|
}
|
|
|
// 更新指标库数据
|
|
|
- edbIndexData, err := models.GetLyEdbDataByIndexCodeAndDataTime(indexData.IndexCode, yearMonth)
|
|
|
+ paramsLib = make(map[string]interface{})
|
|
|
+ paramsLib["IndexCode"] = indexData.IndexCode
|
|
|
+ paramsLib["DataTime"] = yearMonth
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_EDB_DATA_BY_INDEX_CODE_AND_DATA_TIME)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ var requestResponse models.RequestResponse[[]models.EdbDataLy]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
+ edbIndexData := requestResponse.Data
|
|
|
if len(edbIndexData) > 0 {
|
|
|
- err := models.UpdateLyEdbDataById(edbIndexData[0].EdbInfoId, value)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["Id"] = edbIndexData[0].EdbInfoId
|
|
|
+ paramsLib["Value"] = value
|
|
|
+ _, err := httpRequestFill(paramsLib, utils.UPDATE_LY_EDB_DATA_BY_ID)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, fmt.Errorf("SupplyDemandBalanceProcessor Process() : failed to parse value '%s': %v", valueStr, err)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -647,11 +690,19 @@ func (p *PurchaseShippingProcessor) Process(ctx context.Context, product string,
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTimeYM(indexId, month)
|
|
|
+
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["YearMonth"] = month
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME_YM)
|
|
|
if err != nil {
|
|
|
logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
if indexData[0].Value != value {
|
|
|
logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
@@ -669,20 +720,37 @@ func (p *PurchaseShippingProcessor) Process(ctx context.Context, product string,
|
|
|
|
|
|
if time.Before(timeZero) {
|
|
|
// 更新指标数据
|
|
|
- err := models.UpdateLyDataById(lyData.BaseFromLyDataId, value)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["Id"] = lyData.BaseFromLyDataId
|
|
|
+ paramsLib["Value"] = value
|
|
|
+ _, err := httpRequestFill(paramsLib, utils.UPDATE_LY_DATA_BY_ID)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, fmt.Errorf("SupplyDemandBalanceProcessor Process() : failed to parse value '%s': %v", valueStr, err)
|
|
|
}
|
|
|
|
|
|
// 同步更新指标库数据 须根据指标编码和日期更新
|
|
|
- edbIndexData, err := models.GetLyEdbDataByIndexCodeAndDataTime(lyData.IndexCode, month)
|
|
|
+ paramsLib = make(map[string]interface{})
|
|
|
+ paramsLib["IndexCode"] = lyData.IndexCode
|
|
|
+ paramsLib["DataTime"] = yearMonth
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_EDB_DATA_BY_INDEX_CODE_AND_DATA_TIME)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ var requestResponse models.RequestResponse[[]models.EdbDataLy]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ edbIndexData := requestResponse.Data
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(edbIndexData) > 0 {
|
|
|
- err := models.UpdateLyEdbDataById(edbIndexData[0].EdbInfoId, value)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["Id"] = edbIndexData[0].EdbInfoId
|
|
|
+ paramsLib["Value"] = value
|
|
|
+ _, err := httpRequestFill(paramsLib, utils.UPDATE_LY_EDB_DATA_BY_ID)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, fmt.Errorf("SupplyDemandBalanceProcessor Process() : failed to parse value '%s': %v", valueStr, err)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -748,10 +816,18 @@ func (p *ProcessingReportProcessor) Process(ctx context.Context, product string,
|
|
|
if err != nil {
|
|
|
return []models.BaseFromLyData{}, err
|
|
|
}
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
return []models.BaseFromLyData{}, fmt.Errorf("ProcessingReportProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingReportProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 不必做更新处理,报告每周刷新,即使本周和上周数据一致,也需要每周记录
|
|
@@ -820,11 +896,18 @@ func (p *ProcessingReportProcessor) Process(ctx context.Context, product string,
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ProcessingReportProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingReportProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需走更新逻辑,报告每日更新,即使今天和昨天数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -948,11 +1031,18 @@ func (p *InventoryAnalysisProcessor) Process(ctx context.Context, product string
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需走更新逻辑,报告每周更新,即使本周和上周数据一致,也需要每周记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -1054,11 +1144,18 @@ func (p *PriceSpreadArbitrageProcessor) Process(ctx context.Context, product str
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ProcessingProfitProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingProfitProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需走更新逻辑,报告每天更新,即使今天和每天数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -1169,11 +1266,18 @@ func (p *DailyTransactionProcessor) Process(ctx context.Context, product string,
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("DailyTransactionProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("DailyTransactionProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需走更新逻辑,报告每周更新,一周出来一周中每天得数据,即使本周和上周数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -1227,11 +1331,18 @@ func (p *DailyTransactionProcessor) Process(ctx context.Context, product string,
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("DailyTransactionProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("DailyTransactionProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需走更新逻辑,报告每周更新,即使本周和上周数据一致,也需要每周记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -1312,11 +1423,18 @@ func (p *DailyTransactionProcessor) Process(ctx context.Context, product string,
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("SupplyDemandBalanceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
continue
|
|
@@ -1444,11 +1562,18 @@ func (p *PalmOilImportCostProcessor) Process(ctx context.Context, product string
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("PalmOilImportCostProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("PalmOilImportCostProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
continue
|
|
@@ -1567,11 +1692,18 @@ func (p *ImportEstimateProcessor) Process(ctx context.Context, product string, r
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, slice)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ImportEstimateProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
|
|
|
valueStr := row[columnIdx]
|
|
|
value, err := strconv.ParseFloat(valueStr, 64)
|
|
@@ -1596,20 +1728,37 @@ func (p *ImportEstimateProcessor) Process(ctx context.Context, product string, r
|
|
|
|
|
|
if lyData.Value != value && time.Before(timeZero) {
|
|
|
// 更新指标数据
|
|
|
- err := models.UpdateLyDataById(lyData.BaseFromLyDataId, value)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["Id"] = lyData.BaseFromLyDataId
|
|
|
+ paramsLib["Value"] = value
|
|
|
+ _, err := httpRequestFill(paramsLib, utils.UPDATE_LY_DATA_BY_ID)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, fmt.Errorf("ImportEstimateProcessor Process() : failed to parse value '%s': %v", valueStr, err)
|
|
|
}
|
|
|
|
|
|
// 同步更新指标库数据
|
|
|
- lyEdbIndexData, err := models.GetLyEdbDataByIndexCodeAndExactDataTime(lyData.IndexCode, lyData.DataTime)
|
|
|
+ paramsLib = make(map[string]interface{})
|
|
|
+ paramsLib["IndexCode"] = lyData.IndexCode
|
|
|
+ paramsLib["DataTime"] = lyData.DataTime
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_EDB_DATA_BY_INDEX_CODE_AND_EXACT_DATA_TIME)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("ImportEstimateProcessor Process() : Failed to get ly edb data by index code and exact data time: %v", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ var requestResponse models.RequestResponse[[]models.EdbDataLy]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
+ lyEdbIndexData := requestResponse.Data
|
|
|
if len(lyEdbIndexData) > 0 {
|
|
|
- err := models.UpdateLyEdbDataById(lyEdbIndexData[0].EdbInfoId, value)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["Id"] = lyEdbIndexData[0].EdbInfoId
|
|
|
+ paramsLib["Value"] = value
|
|
|
+ _, err := httpRequestFill(paramsLib, utils.UPDATE_LY_EDB_DATA_BY_ID)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, fmt.Errorf("ImportEstimateProcessor Process() : failed to parse value '%s': %v", valueStr, err)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1723,11 +1872,18 @@ func (p *InternationalPriceProcessor) Process(ctx context.Context, product strin
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("InternationalPriceProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("InternationalPriceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需更新 指标展示本月和后两月的数据,报告每天更新,每天的值可能会改变,即使今天和每天数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -1826,11 +1982,18 @@ func (p *CanadaStatisticsBureauProcessor) Process(ctx context.Context, product s
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, format)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("CanadaStatisticsBureauProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("CanadaStatisticsBureauProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
// 无需更新 指标展示本周的数据,报告每周更新,即使本周和上周数据一致,也需要每周记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
@@ -1941,11 +2104,18 @@ func (p *ImportExportAnalysisProcessor) Process(ctx context.Context, product str
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- indexData, err := models.GetLyDataByIndexIdAndDataTime(indexId, lastDayOfMonth)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexId"] = indexId
|
|
|
+ paramsLib["DataTime"] = format
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_DATA_BY_INDEX_ID_AND_DATA_TIME)
|
|
|
if err != nil {
|
|
|
logs.Error("ProcessingProfitProcessor Process() : Failed to get data by index id and date: %v", err)
|
|
|
continue
|
|
|
}
|
|
|
+ var requestResponse models.RequestResponse[[]models.BaseFromLyData]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
+
|
|
|
+ indexData := requestResponse.Data
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingProfitProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
continue
|
|
@@ -1997,11 +2167,19 @@ func getIndexId(indexCode string, indexName string, classifyId int, sourceName s
|
|
|
|
|
|
// 判断指标是否存在
|
|
|
var indexId int
|
|
|
- indexInfo, err := models.GetLyIndexByCode(indexCode)
|
|
|
+ paramsLib := make(map[string]interface{})
|
|
|
+ paramsLib["IndexCode"] = indexCode
|
|
|
+ postEdbLib, err := httpRequestFill(paramsLib, utils.GET_LY_INDEX_BY_CODE)
|
|
|
+ if err != nil {
|
|
|
+ return 0, fmt.Errorf("getIndexId() : Failed to get ly index by code: %v", err)
|
|
|
+ }
|
|
|
+ var requestResponse models.RequestResponse[models.BaseFromLyIndex]
|
|
|
+ err = json.Unmarshal(postEdbLib, &requestResponse)
|
|
|
if err != nil {
|
|
|
- return indexId, err
|
|
|
+ return 0, fmt.Errorf("getIndexId() : Failed to unmarshal response: %v", err)
|
|
|
}
|
|
|
- if indexInfo == nil {
|
|
|
+ indexInfo := requestResponse.Data
|
|
|
+ if indexInfo.IndexName == "" {
|
|
|
// 新增指标
|
|
|
index, err := addLyIndex(classifyId, indexCode, indexName, frequency, unit)
|
|
|
if err != nil {
|