tuoling805 1 年之前
父节点
当前提交
dcc93c0037
共有 3 个文件被更改,包括 33 次插入3 次删除
  1. 10 0
      controllers/base_from_fubao.go
  2. 20 1
      models/base_from_fubao.go
  3. 3 2
      utils/constants.go

+ 10 - 0
controllers/base_from_fubao.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_edb_lib/services"
 	"hongze/hongze_edb_lib/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -54,6 +55,15 @@ func (this *FuBaoController) Add() {
 			br.ErrMsg = "获取富宝指标数据失败 GetEdbDataFromLt,Code:" + strconv.Itoa(dataItem.Code)
 			return
 		}
+		if len(dataItem.ReturnValue.Data) > 0 {
+			priceStr := dataItem.ReturnValue.Data[0].PriceStr
+			if strings.Contains(priceStr, "-") {
+				br.Msg = "此指标的数据格式暂不支持!"
+				br.ErrMsg = "此指标的数据格式暂不支持,Val:" + priceStr + ";pid:" + req.EdbCode
+				return
+			}
+		}
+
 		err = models.AddEdbDataFromFubao(req.EdbCode, dataItem)
 		if err != nil {
 			br.Msg = "获取指标信息失败!"

+ 20 - 1
models/base_from_fubao.go

@@ -78,17 +78,26 @@ func RefreshEdbDataFromFubao(edbInfoId int, edbCode, startDate string, fubaoData
 		existMap[v.DataTime] = v
 	}
 
+	fmt.Println("existMap start")
+	fmt.Println(existMap)
+	fmt.Println("existMap end")
+
 	edbInfoIdStr := strconv.Itoa(edbInfoId)
 
 	addSql := ` INSERT INTO edb_data_fubao(edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) values `
 	var isAdd bool
 
-	for _, dataItem := range fubaoData.ReturnValue.Data {
+	for k, dataItem := range fubaoData.ReturnValue.Data {
 
 		dataTime, err := time.ParseInLocation(utils.FormatDate, dataItem.Datadate, time.Local)
 		if err != nil {
 			return err
 		}
+		if k < 3 {
+			fmt.Println("dataItem.Datadate start")
+			fmt.Println(dataItem.Datadate)
+			fmt.Println("dataItem.Datadate end")
+		}
 
 		if findItem, ok := existMap[dataItem.Datadate]; !ok {
 			timestamp := dataTime.UnixNano() / 1e6
@@ -97,6 +106,12 @@ func RefreshEdbDataFromFubao(edbInfoId int, edbCode, startDate string, fubaoData
 			addSql += GetAddSql(edbInfoIdStr, edbCode, dataItem.Datadate, timeStr, dataItem.PriceStr)
 			isAdd = true
 		} else {
+			fmt.Println("update start")
+			fmt.Println(findItem.Value)
+			fmt.Println(dataItem.PriceStr)
+			fmt.Println(utils.SubFloatToString(findItem.Value, 30))
+			fmt.Println("update end")
+
 			if findItem != nil && utils.SubFloatToString(findItem.Value, 30) != dataItem.PriceStr {
 				err = ModifyEdbDataById(source, findItem.EdbDataId, dataItem.PriceStr)
 				if err != nil {
@@ -114,6 +129,10 @@ func RefreshEdbDataFromFubao(edbInfoId int, edbCode, startDate string, fubaoData
 				isFindConfigDateRealData = true
 			}
 		}
+
+		if dataItem.Datadate == startDate {
+			break
+		}
 	}
 
 	// 处理手工数据补充的配置

+ 3 - 2
utils/constants.go

@@ -75,7 +75,7 @@ const (
 	DATA_SOURCE_PREDICT_CALCULATE_LJZZY                         //预测指标 - 累计值转月->42
 	DATA_SOURCE_PREDICT_CALCULATE_HBZ                           //预测指标 - 环比值->43
 	DATA_SOURCE_PREDICT_CALCULATE_HCZ                           //预测指标 - 环差值->44
-	DATA_SOURCE_PREDICT_CALCULATE_BP                            //预测指标 - 频->45
+	DATA_SOURCE_PREDICT_CALCULATE_BP                            //预测指标 - 频->45
 	DATA_SOURCE_PREDICT_CALCULATE_TIME_SHIFT                    //预测指标 - 时间移位->46
 	DATA_SOURCE_PREDICT_CALCULATE_ZJPJ                          //预测指标 - 直接拼接->47
 	DATA_SOURCE_PREDICT_CALCULATE_LJZTBPJ                       //预测指标 - 累计值同比拼接->48
@@ -101,7 +101,7 @@ const (
 	DATA_SOURCE_CALCULATE_PERCENTILE                            //百分位->68
 	DATA_SOURCE_PREDICT_CALCULATE_STANDARD_DEVIATION            //预测标准差->69
 	DATA_SOURCE_PREDICT_CALCULATE_PERCENTILE                    //预测百分位->70
-	DATA_SOURCE_FUBAO                                           //富宝->71
+	DATA_SOURCE_FUBAO                                           //富宝数据->71
 )
 
 // 指标来源的中文展示
@@ -176,6 +176,7 @@ const (
 	DATA_SOURCE_NAME_CALCULATE_PERCENTILE                 = `百分位`               //百分位->68
 	DATA_SOURCE_NAME_PREDICT_CALCULATE_STANDARD_DEVIATION = `预测标准差`             //预测标准差->69
 	DATA_SOURCE_NAME_PREDICT_CALCULATE_PERCENTILE         = `预测百分位`             //预测百分位->70
+	DATA_SOURCE_NAME_FUBAO                                = `富宝数据`              //富宝数据->71
 )
 
 // 基础数据初始化日期