|
@@ -502,10 +502,34 @@ func (p *SupplyDemandBalanceProcessor) Process(ctx context.Context, product stri
|
|
|
// 存在走更新逻辑 主要更新今年在去年的预估值
|
|
|
indexData := indexData[0]
|
|
|
if indexData.Value != value {
|
|
|
- err := models.UpdateLyDataById(indexData.BaseFromLyDataId, value)
|
|
|
+ time, err := utils.StringToTime(indexData.ModifyTime)
|
|
|
if err != nil {
|
|
|
- logs.Error("SupplyDemandBalanceProcessor Process() : Failed to update data: %v", err)
|
|
|
- continue
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ timeZero, err := utils.StringToTimeZero(format)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ if time.Before(timeZero) {
|
|
|
+ // 更新指标数据
|
|
|
+ err := models.UpdateLyDataById(indexData.BaseFromLyDataId, value)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("SupplyDemandBalanceProcessor Process() : Failed to update data: %v", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 更新指标库数据
|
|
|
+ edbIndexData, err := models.GetLyEdbDataByIndexCodeAndDataTime(indexData.IndexCode, yearMonth)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if len(edbIndexData) > 0 {
|
|
|
+ err := models.UpdateLyEdbDataById(edbIndexData[0].EdbInfoId, value)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
continue
|
|
@@ -629,23 +653,40 @@ func (p *PurchaseShippingProcessor) Process(ctx context.Context, product string,
|
|
|
continue
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
- logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
- err := models.UpdateLyDataById(indexData[0].BaseFromLyDataId, value)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- // 同步更新指标库数据 须根据指标编码和日期更新
|
|
|
- edbData, err := models.GetLyEdbDataByIndexCodeAndDataTime(indexData[0].IndexCode, month)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- if len(edbData) > 0 {
|
|
|
- err := models.UpdateLyEdbDataById(edbData[0].BaseFromLyDataId, value)
|
|
|
+ if indexData[0].Value != value {
|
|
|
+ logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+
|
|
|
+ lyData := indexData[0]
|
|
|
+ time, err := utils.StringToTime(lyData.ModifyTime)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ timeZero, err := utils.StringToTimeZero(format)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ if time.Before(timeZero) {
|
|
|
+ // 更新指标数据
|
|
|
+ err := models.UpdateLyDataById(lyData.BaseFromLyDataId, value)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步更新指标库数据 须根据指标编码和日期更新
|
|
|
+ edbIndexData, err := models.GetLyEdbDataByIndexCodeAndDataTime(lyData.IndexCode, month)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if len(edbIndexData) > 0 {
|
|
|
+ err := models.UpdateLyEdbDataById(edbIndexData[0].EdbInfoId, value)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -713,6 +754,7 @@ func (p *ProcessingReportProcessor) Process(ctx context.Context, product string,
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingReportProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 不必做更新处理,报告每周刷新,即使本周和上周数据一致,也需要每周记录
|
|
|
return []models.BaseFromLyData{}, nil
|
|
|
}
|
|
|
|
|
@@ -784,9 +826,8 @@ func (p *ProcessingReportProcessor) Process(ctx context.Context, product string,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // TODO 后面把这个日志打印,不做返回错误处理,一个指标找不到会导致后续指标无法处理
|
|
|
- return result, nil
|
|
|
|
|
|
+ return result, nil
|
|
|
}
|
|
|
|
|
|
// InventoryAnalysisProcessor
|
|
@@ -866,6 +907,7 @@ func (p *InventoryAnalysisProcessor) Process(ctx context.Context, product string
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("SupplyDemandBalanceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 无需走更新逻辑,报告每周更新,即使本周和上周数据一致,也需要每周记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -970,6 +1012,7 @@ func (p *PriceSpreadArbitrageProcessor) Process(ctx context.Context, product str
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("ProcessingProfitProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 无需走更新逻辑,报告每天更新,即使今天和每天数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -1076,6 +1119,7 @@ func (p *DailyTransactionProcessor) Process(ctx context.Context, product string,
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("DailyTransactionProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 无需走更新逻辑,报告每周更新,一周出来一周中每天得数据,即使本周和上周数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -1133,6 +1177,7 @@ func (p *DailyTransactionProcessor) Process(ctx context.Context, product string,
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("DailyTransactionProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 无需走更新逻辑,报告每周更新,即使本周和上周数据一致,也需要每周记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -1428,7 +1473,6 @@ func (p *ImportEstimateProcessor) Process(ctx context.Context, product string, r
|
|
|
|
|
|
// 查找目标列
|
|
|
for _, columnDate := range columnDates {
|
|
|
-
|
|
|
columnIdx := -1
|
|
|
for i, tableHeader := range tableHeaders {
|
|
|
if strings.Contains(tableHeader, columnDate) {
|
|
@@ -1479,24 +1523,41 @@ func (p *ImportEstimateProcessor) Process(ctx context.Context, product string, r
|
|
|
}
|
|
|
|
|
|
if len(indexData) > 0 {
|
|
|
- logs.Info("ImportEstimateProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
- lyData := indexData[0]
|
|
|
- time, err := utils.StringToTime(lyData.ModifyTime)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+ if indexData[0].Value != value {
|
|
|
+ logs.Info("ImportEstimateProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
|
|
|
- timeZero, err := utils.StringToTimeZero(format)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+ lyData := indexData[0]
|
|
|
+ time, err := utils.StringToTime(lyData.ModifyTime)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
|
|
|
- if lyData.Value != value && time.Before(timeZero) {
|
|
|
- err := models.UpdateLyDataById(lyData.BaseFromLyDataId, value)
|
|
|
+ timeZero, err := utils.StringToTimeZero(format)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
+ if lyData.Value != value && time.Before(timeZero) {
|
|
|
+ // 更新指标数据
|
|
|
+ err := models.UpdateLyDataById(lyData.BaseFromLyDataId, value)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步更新指标库数据
|
|
|
+ lyEdbIndexData, err := models.GetLyEdbDataByIndexCodeAndExactDataTime(lyData.IndexCode, lyData.DataTime)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if len(lyEdbIndexData) > 0 {
|
|
|
+ err := models.UpdateLyEdbDataById(lyEdbIndexData[0].EdbInfoId, value)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -1612,6 +1673,7 @@ func (p *InternationalPriceProcessor) Process(ctx context.Context, product strin
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("InternationalPriceProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 无需更新 指标展示本月和后两月的数据,报告每天更新,每天的值可能会改变,即使今天和每天数据一致,也需要每天记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -1714,6 +1776,7 @@ func (p *CanadaStatisticsBureauProcessor) Process(ctx context.Context, product s
|
|
|
}
|
|
|
if len(indexData) > 0 {
|
|
|
logs.Info("CanadaStatisticsBureauProcessor Process() : Data already exists for index %d and date %s", indexId, dateText)
|
|
|
+ // 无需更新 指标展示本周的数据,报告每周更新,即使本周和上周数据一致,也需要每周记录,如果到这里也只是说,今天这个报告被读取了两次
|
|
|
continue
|
|
|
}
|
|
|
|