Browse Source

Merge branch 'pool/380' into debug

Roc 1 year ago
parent
commit
14dd6a85b8

+ 15 - 9
controller/chart/chart_common.go

@@ -62,31 +62,29 @@ func CommonChartInfoDetailFromUniqueCode(c *gin.Context) {
 		return
 	}
 
+	var resp *chart_info.ChartInfoDetailResp
 	switch chartInfo.Source {
 	case utils.CHART_SOURCE_DEFAULT:
-		resp, isOk, msg, errMsg := getChartInfoDetail(chartInfo, myChartClassifyId, user.GetInfoByClaims(c))
+		tmpResp, isOk, msg, errMsg := getChartInfoDetail(chartInfo, myChartClassifyId, user.GetInfoByClaims(c))
 		if !isOk {
 			response.FailMsg(msg, errMsg, c)
 			return
 		}
-		response.OkData("获取成功", resp, c)
-		return
+		resp = tmpResp
 	case utils.CHART_SOURCE_FUTURE_GOOD:
-		resp, isOk, msg, errMsg := getFutureGoodChartInfoDetail(chartInfo, myChartClassifyId, user.GetInfoByClaims(c))
+		tmpResp, isOk, msg, errMsg := getFutureGoodChartInfoDetail(chartInfo, myChartClassifyId, user.GetInfoByClaims(c))
 		if !isOk {
 			response.FailMsg(msg, errMsg, c)
 			return
 		}
-		response.OkData("获取成功", resp, c)
-		return
+		resp = tmpResp
 	case utils.CHART_SOURCE_CORRELATION, utils.CHART_SOURCE_ROLLING_CORRELATION:
-		resp, isOk, msg, errMsg := getCorrelationChartInfoDetail(chartInfo, myChartClassifyId, user.GetInfoByClaims(c))
+		tmpResp, isOk, msg, errMsg := getCorrelationChartInfoDetail(chartInfo, myChartClassifyId, user.GetInfoByClaims(c))
 		if !isOk {
 			response.FailMsg(msg, errMsg, c)
 			return
 		}
-		response.OkData("获取成功", resp, c)
-		return
+		resp = tmpResp
 	default:
 		msg := "错误的图表"
 		errMsg := "错误的图表"
@@ -94,6 +92,14 @@ func CommonChartInfoDetailFromUniqueCode(c *gin.Context) {
 		return
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := chart.GetEdbSourceByEdbInfoIdList(resp.EdbInfoList)
+	resp.ChartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	resp.ChartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+	response.OkData("获取成功", resp, c)
+
+	return
+
 }
 
 // getFutureGoodChartInfoDetail 获取商品价格曲线图表详情

+ 1 - 0
models/tables/chart_info/query.go

@@ -35,6 +35,7 @@ type ChartInfoView struct {
 	RightMin          string `description:"图表右侧最小值"`
 	RightMax          string `description:"图表右侧最大值"`
 	ChartSource       string `description:"图表来源str"`
+	ChartSourceEn     string `description:"图表来源(英文)"`
 	BarConfig         string `description:"柱方图的配置,json数据" json:"-"`
 	ChartNameEn       string `description:"英文图表名称"`
 	UnitEn            string `description:"英文单位名称"`

+ 3 - 0
models/tables/edb_info/query.go

@@ -48,6 +48,9 @@ func GetRefreshEdbInfoFromBase(edbInfoId, source int) (baseEdbInfoArr, calculate
 		return
 	}
 	for _, item := range calculateList {
+		if item.EdbInfoId == edbInfoId { //	如果查出来关联的指标就是自己的话,那么就过滤
+			continue
+		}
 		if item.EdbType == 1 {
 			baseEdbInfoArr = append(baseEdbInfoArr, item)
 		} else {

+ 38 - 0
services/chart/edb_info.go

@@ -3,6 +3,7 @@ package chart
 import (
 	"errors"
 	"fmt"
+	chartEdbMappingModel "hongze/hongze_yb/models/tables/chart_edb_mapping"
 	edbInfoModel "hongze/hongze_yb/models/tables/edb_info"
 	predictEdbConfCalculateMappingModel "hongze/hongze_yb/models/tables/predict_edb_conf_calculate_mapping"
 	"hongze/hongze_yb/services/alarm_msg"
@@ -541,3 +542,40 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
 
 	return
 }
+
+// GetEdbSourceByEdbInfoIdList 获取关联指标的来源
+func GetEdbSourceByEdbInfoIdList(chartEdbInfoMappingList []*chartEdbMappingModel.ChartEdbInfoMappingList) (sourceNameList, sourceNameEnList []string) {
+	fmt.Println(chartEdbInfoMappingList)
+	sourceNameList = []string{}
+	sourceNameEnList = []string{}
+	sourceMap := make(map[int]string)
+	for _, v := range chartEdbInfoMappingList {
+		// 指标类型:1:基础指标,2:计算指标
+		if v.EdbType == 2 {
+			//sourceMap[0] = "弘则研究"
+			baseEdbInfoArr, _, _ := edbInfoModel.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
+			for _, baseEdbInfo := range baseEdbInfoArr {
+				sourceMap[baseEdbInfo.Source] = baseEdbInfo.SourceName
+			}
+		} else {
+			sourceMap[v.Source] = v.SourceName
+		}
+	}
+
+	for source, sourceName := range sourceMap {
+		if source == utils.DATA_SOURCE_MANUAL {
+			continue
+		}
+		sourceNameList = append(sourceNameList, sourceName)
+
+		sourceNameEn, ok := utils.DataSourceEnMap[source]
+		if !ok {
+			sourceNameEn = sourceName
+		}
+		sourceNameEnList = append(sourceNameEnList, sourceNameEn)
+	}
+	sourceNameList = append(sourceNameList, `弘则研究`)
+	sourceNameEnList = append(sourceNameEnList, `Horizon Insights`)
+
+	return
+}

+ 25 - 0
utils/constants.go

@@ -285,3 +285,28 @@ const (
 var FrequencyDaysMap = map[string]int{
 	"天": 1, "周": 7, "月": 30, "季": 90, "年": 365,
 }
+
+// DataSourceEnMap 指标来源的英文名称
+var DataSourceEnMap = map[int]string{
+	DATA_SOURCE_WIND:          "Wind",
+	DATA_SOURCE_THS:           "iFind",
+	DATA_SOURCE_PB:            "Bloomberg",
+	DATA_SOURCE_PB_FINANCE:    "Bloomberg Finance",
+	DATA_SOURCE_LT:            "Reuters",
+	DATA_SOURCE_MANUAL:        "Horizon Insights",
+	DATA_SOURCE_LZ:            "OilChem",
+	DATA_SOURCE_YS:            "SMM",
+	DATA_SOURCE_GL:            "MySteel",
+	DATA_SOURCE_ZZ:            "Zhengzhou Commodity Exchange",
+	DATA_SOURCE_DL:            "Dalian Commodity Exchange",
+	DATA_SOURCE_SH:            "Shanghai Futures Exchange",
+	DATA_SOURCE_CFFEX:         "China Financial Futures Exchange",
+	DATA_SOURCE_SHFE:          "Shanghai International Energy Exchange",
+	DATA_SOURCE_GIE:           "Eurostat",
+	DATA_SOURCE_COAL:          "China Coal Transport & Distribution Association",
+	DATA_SOURCE_GOOGLE_TRAVEL: "Our World in Data",
+	DATA_SOURCE_EIA_STEO:      "Energy Information Administration",
+	DATA_SOURCE_COM_TRADE:     "United Nations",
+	DATA_SOURCE_SCI:           "Sublime China Information",
+	DATA_SOURCE_BAIINFO:       "BAIINFO",
+}