|
@@ -1,10 +1,12 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
+ "eta/eta_index_lib/models/mgo"
|
|
|
"eta/eta_index_lib/utils"
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/shopspring/decimal"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -219,7 +221,17 @@ func RefreshEdbDataFromManual(edbInfoId int, edbCode, startDate string) (err err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// HandleConfigInsertEdbData 处理手工数据补充的配置
|
|
|
+// HandleConfigInsertEdbData
|
|
|
+// @Description: 处理人工数据补充的配置(mysql)
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-05-09 13:07:32
|
|
|
+// @param realDataMaxDate time.Time
|
|
|
+// @param edbDataInsertConfig *EdbDataInsertConfig
|
|
|
+// @param edbInfoId int
|
|
|
+// @param source int
|
|
|
+// @param subSource int
|
|
|
+// @param existMap map[string]*EdbInfoSearchData
|
|
|
+// @param isFindConfigDateRealData bool
|
|
|
func HandleConfigInsertEdbData(realDataMaxDate time.Time, edbDataInsertConfig *EdbDataInsertConfig, edbInfoId, source, subSource int, existMap map[string]*EdbInfoSearchData, isFindConfigDateRealData bool) {
|
|
|
if edbDataInsertConfig == nil {
|
|
|
return
|
|
@@ -249,3 +261,47 @@ func HandleConfigInsertEdbData(realDataMaxDate time.Time, edbDataInsertConfig *E
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// HandleConfigInsertEdbDataByMongo
|
|
|
+// @Description: 处理人工数据补充的配置(mongo)
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-05-09 13:07:12
|
|
|
+// @param realDataMaxDate time.Time
|
|
|
+// @param edbDataInsertConfig *EdbDataInsertConfig
|
|
|
+// @param edbInfoId int
|
|
|
+// @param source int
|
|
|
+// @param subSource int
|
|
|
+// @param existMap map[string]*mgo.EdbDataBusiness
|
|
|
+// @param isFindConfigDateRealData bool
|
|
|
+func HandleConfigInsertEdbDataByMongo(realDataMaxDate time.Time, edbDataInsertConfig *EdbDataInsertConfig, edbInfoId, source, subSource int, existMap map[string]*mgo.EdbDataBusiness, isFindConfigDateRealData bool) {
|
|
|
+ if edbDataInsertConfig == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("处理手工数据补充的配置失败,err:", err)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ edbDataInsertConfigDate := edbDataInsertConfig.Date // 配置的日期
|
|
|
+
|
|
|
+ // 如果存在真实数据的最大日期 && 存在配置插入数据的最大日期 && 真实数据的最大日期 晚于/等于 配置插入数据的最大日期
|
|
|
+ if realDataMaxDate.After(edbDataInsertConfigDate) || realDataMaxDate.Equal(edbDataInsertConfigDate) {
|
|
|
+ go DeleteEdbDataInsertConfigByEdbId(edbInfoId)
|
|
|
+
|
|
|
+ mogDataObj := mgo.EdbDataBusiness{}
|
|
|
+ coll := mogDataObj.GetCollection()
|
|
|
+ edbDataInsertConfigDateStr := edbDataInsertConfigDate.Format(utils.FormatDate)
|
|
|
+ // 如果没有找到找到配置日期的实际数据,那么就直接删除
|
|
|
+ if item, ok := existMap[edbDataInsertConfigDateStr]; ok && !isFindConfigDateRealData {
|
|
|
+ mogDataObj.RemoveManyByColl(coll, bson.M{"_id": item.ID})
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ edbDataInsertConfig.RealDate = realDataMaxDate
|
|
|
+ _, err = o.Update(edbDataInsertConfig, "RealDate")
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|