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

fix:自有数据处理时,需要过滤掉重复日期,将后面重复日期的值赋值给改日期

Roc 4 сар өмнө
parent
commit
6a041e2fbb

+ 14 - 0
controllers/business_edb.go

@@ -60,6 +60,20 @@ func (c *EdbController) Push() {
 		return
 	}
 
+	// 先过滤掉重复的日期
+	dataList := make([]data_manage.AddBusinessDataReq, 0)
+	dateKeyMap := make(map[string]int)
+	for _, v := range req.DataList {
+		dataIndex, ok := dateKeyMap[v.Date]
+		if !ok {
+			dataList = append(dataList, v)
+			dateKeyMap[v.Date] = len(dataList) - 1
+		} else {
+			dataList[dataIndex] = v
+		}
+	}
+	req.DataList = dataList
+
 	reqJson, err := json.Marshal(req)
 	if err != nil {
 		br.Msg = "参数解析异常!"

+ 9 - 0
services/data/base_edb_lib.go

@@ -36,6 +36,9 @@ type BaseFromBusinessIndexResp struct {
 // @return err error
 func PushEdb(paramStr string) (resp *PushEdbResponse, err error) {
 	_, resultByte, err := postEdbLib(paramStr, "/business_index/handle")
+	if err != nil {
+		return
+	}
 	err = json.Unmarshal(resultByte, &resp)
 	if err != nil {
 		return
@@ -67,6 +70,9 @@ type DelBusinessIndexResp struct {
 // @return err error
 func DelBusinessIndex(paramStr string) (resp *DelBusinessIndexResponse, err error) {
 	_, resultByte, err := postEdbLib(paramStr, "/business_index/index/del")
+	if err != nil {
+		return
+	}
 	err = json.Unmarshal(resultByte, &resp)
 	if err != nil {
 		return
@@ -83,6 +89,9 @@ func DelBusinessIndex(paramStr string) (resp *DelBusinessIndexResponse, err erro
 // @return err error
 func DelBusinessIndexData(paramStr string) (resp *models.BaseResponse, err error) {
 	_, resultByte, err := postEdbLib(paramStr, "/business_index/data/del")
+	if err != nil {
+		return
+	}
 	err = json.Unmarshal(resultByte, &resp)
 	if err != nil {
 		return