Browse Source

Merge branch 'eta/1.4.1' into debug

# Conflicts:
#	controllers/data_manage/chart_theme.go
#	models/business_conf.go
Roc 1 year ago
parent
commit
90d2001f11

+ 15 - 0
controllers/data_manage/chart_info.go

@@ -1103,6 +1103,11 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 		IsSetName: chartInfo.IsSetName,
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp := new(data_manage.ChartInfoDetailResp)
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
@@ -1305,6 +1310,11 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 		IsSetName: chartInfo.IsSetName,
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp := new(data_manage.ChartInfoDetailResp)
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
@@ -2169,6 +2179,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		IsSetName: chartInfo.IsSetName,
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp.ChartInfo = chartInfo
 	resp.XEdbIdValue = xEdbIdValue
 	resp.YDataList = yDataList

+ 37 - 4
controllers/data_manage/chart_theme.go

@@ -134,25 +134,42 @@ func (c *ChartThemeController) GetThemePreviewData() {
 	extraConfigStr := ``
 	var barConfig data_manage.BarChartInfoReq
 
+	// 开始时间,结束时间
+	var tmpStartDate, tmpEndDate string
+
 	edbInfoIdList := make([]int, 0) // 指标列表
 	switch chartType {
-	case 1, 4, 6: // 曲线图、堆积柱状图、组合图
+	case 1: // 曲线图
+		edbInfoIdList = []int{1, 2, 3, 4, 5}
+		chartInfo.ChartName = "曲线图"
+	case 4: // 堆积柱状图
+		edbInfoIdList = []int{1, 2, 3, 4, 5}
+		chartInfo.ChartName = "堆积柱状图"
+		dateType = 5
+		tmpStartDate = `2021-03-05`
+	case 6: // 组合图
 		edbInfoIdList = []int{1, 2, 3, 4, 5}
+		chartInfo.ChartName = "组合图"
+		dateType = 5
+		tmpStartDate = `2021-03-05`
 	case 2: // 季节性
 		dateType = 20 // 季节性图
 		edbInfoIdList = []int{6}
+		chartInfo.ChartName = "季节性图"
 	case 5: // 散点图
 		edbInfoIdList = []int{7, 8}
+		chartInfo.ChartName = "散点图"
 	case 7: // 柱形图
 		edbInfoIdList = []int{1, 2, 3, 4, 5}
 		chartInfo.LeftMin = "260"
 		chartInfo.LeftMax = "430"
 		extraConfigStr = `{"EdbInfoIdList":[{"EdbInfoId":1,"Name":"指标1","NameEn":"","Source":0},{"EdbInfoId":2,"Name":"指标2","NameEn":"","Source":0},{"EdbInfoId":3,"Name":"指标3","NameEn":"","Source":0},{"EdbInfoId":4,"Name":"指标4","NameEn":"","Source":0},{"EdbInfoId":5,"Name":"指标5","NameEn":"","Source":0}],"DateList":[{"Type":2,"Date":"","Value":100,"Color":"#00f","Name":""},{"Type":1,"Date":"","Value":0,"Color":"#f00","Name":""}],"Sort":{"Sort":0,"DateIndex":0},"XEdbList":null,"YEdbList":null,"Unit":"千桶","UnitEn":""}`
-		err = json.Unmarshal([]byte(extraConfigStr), &barConfig)
+		chartInfo.ChartName = "柱形图"
 	case 10: // 截面散点图
 		edbInfoIdList = []int{9, 10, 11, 12, 13, 14, 15, 16, 17, 18}
 		extraConfigStr = `{"XName":"123","XNameEn":"123","XUnitName":"无","XUnitNameEn":"none","YName":"321","YNameEn":"321","YUnitName":"无","YUnitNameEn":"none","XMinValue":"250","XMaxValue":"371","YMinValue":"400","YMaxValue":"821","SeriesList":[{"Name":"2021-11-21","NameEn":"2021-11-21","IsNameDefault":true,"Color":"#00f","EdbInfoList":[{"XEdbInfoId":9,"YEdbInfoId":14,"Name":"指标1","NameEn":"","XDateType":1,"XDate":"","XDateValue":0,"YDateType":1,"YDate":"","YDateValue":0,"IsShow":false},{"XEdbInfoId":10,"YEdbInfoId":15,"Name":"指标2","NameEn":"指标2","XDateType":1,"XDate":"","XDateValue":0,"YDateType":1,"YDate":"","YDateValue":0,"IsShow":false},{"XEdbInfoId":11,"YEdbInfoId":16,"Name":"指标3","NameEn":"","XDateType":1,"XDate":"","XDateValue":0,"YDateType":1,"YDate":"","YDateValue":0,"IsShow":false},{"XEdbInfoId":12,"YEdbInfoId":17,"Name":"指标4","NameEn":"指标4","XDateType":1,"XDate":"","XDateValue":0,"YDateType":1,"YDate":"","YDateValue":0,"IsShow":false},{"XEdbInfoId":13,"YEdbInfoId":18,"Name":"指标5","NameEn":"","XDateType":1,"XDate":"","XDateValue":0,"YDateType":1,"YDate":"","YDateValue":0,"IsShow":false}],"ShowTrendLine":false,"ShowFitEquation":false,"ShowRSquare":false}]}`
-	default:
+		chartInfo.ChartName = "截面散点图"
+		default:
 		br.Msg = "暂不支持该类型"
 		br.IsSendEmail = false
 		return
@@ -193,7 +210,7 @@ func (c *ChartThemeController) GetThemePreviewData() {
 		}
 	}
 	// 开始/结束日期
-	startDate, endDate := utils.GetDateByDateTypeV2(dateType, ``, ``, startYear, yearMax)
+	startDate, endDate := utils.GetDateByDateTypeV2(dateType, tmpStartDate, tmpEndDate, startYear, yearMax)
 
 	// 获取图表中的指标数据
 	edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := data.GetThemePreviewChartEdbData(chartType, calendar, startDate, endDate, mappingList, extraConfigStr, chartInfo.SeasonExtraConfig)
@@ -422,6 +439,22 @@ func (c *ChartThemeController) Delete() {
 		return
 	}
 
+	// 根据给定的图表主题类型ID获取图表主题类型
+	chartThemeType, err := chart_theme.GetChartThemeTypeById(chartTheme.ChartThemeTypeId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取图表主题类型信息失败,Err:" + err.Error()
+		return
+	}
+
+	// 判断是否是配置为默认设置,如果已经设置了,那么不能删除
+	if chartThemeType.DefaultChartThemeId == 1 {
+		br.Msg = "该主题已经配置为默认设置,无法删除"
+		br.ErrMsg = "该主题已经配置为默认设置,无法删除"
+		br.IsSendEmail = false
+		return
+	}
+
 	// 更新
 	chartTheme.IsDelete = 1
 	err = chartTheme.Update([]string{"IsDelete"})

+ 10 - 0
controllers/data_manage/correlation/correlation_chart_info.go

@@ -782,6 +782,11 @@ func (this *CorrelationChartInfoController) Detail() {
 	chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList[0:1], chartInfo.Source, chartInfo.ChartType)
 	chartInfo.UnitEn = edbInfoMappingA.UnitEn
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	isSaveAs := true
 	if chartInfo.Source == utils.CHART_SOURCE_ROLLING_CORRELATION {
 		isSaveAs = false
@@ -1285,6 +1290,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		IsSetName: chartInfo.IsSetName,
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.XEdbIdValue = xEdbIdValue

+ 5 - 0
controllers/data_manage/cross_variety/chart_info.go

@@ -1562,6 +1562,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		IsCopy:    true,
 		IsSetName: chartInfo.IsSetName,
 	}
+	
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
 
 	resp.ChartInfo = chartInfo
 	resp.DataResp = dataResp

+ 10 - 0
controllers/data_manage/future_good/future_good_chart_info.go

@@ -1404,6 +1404,11 @@ func getFutureGoodChartInfo(chartInfo *data_manage.ChartInfoView, chartType, dat
 	chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList[0:1], chartInfo.Source, chartInfo.ChartType)
 	chartInfo.UnitEn = baseEdbInfo.UnitEn
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp := new(data_manage.ChartInfoDetailResp)
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
@@ -1648,6 +1653,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 	chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList[0:1], chartInfo.Source, chartInfo.ChartType)
 	chartInfo.UnitEn = baseEdbInfo.UnitEn
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.XEdbIdValue = xEdbIdValue

+ 10 - 0
controllers/data_manage/future_good/future_good_profit_chart_info.go

@@ -1080,6 +1080,11 @@ func getFutureGoodProfitChartInfo(chartInfo *data_manage.ChartInfoView, sysUser
 	chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList[0:1], chartInfo.Source, chartInfo.ChartType)
 	chartInfo.UnitEn = baseEdbInfo.UnitEn
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp := new(data_manage.ChartInfoDetailResp)
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
@@ -1250,6 +1255,11 @@ func GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo *data_manage.Cha
 	chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList[0:1], chartInfo.Source, chartInfo.ChartType)
 	chartInfo.UnitEn = baseEdbInfo.UnitEn
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.DataResp = response.ProfitFutureGoodChartResp{

+ 5 - 0
controllers/data_manage/line_equation/line_chart_info.go

@@ -1273,6 +1273,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		IsSetName: chartInfo.IsSetName,
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.DataResp = resultResp

+ 5 - 0
controllers/data_manage/line_feature/chart_info.go

@@ -2410,6 +2410,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		IsSetName: chartInfo.IsSetName,
 	}
 
+	// 图表的指标来源
+	sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
+	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
+	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
+
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.DataResp = resultResp

+ 3 - 0
models/business_conf.go

@@ -15,6 +15,9 @@ const (
 	BusinessConfXfApiSecret       = "XfApiSecret"
 	BusinessConfXfVcn             = "XfVcn"
 	BusinessConfEnPptCoverImgs    = "EnPptCoverImgs"
+	BusinessConfCompanyName      = "CompanyName"
+	BusinessConfCompanyWatermark = "CompanyWatermark"
+	BusinessConfWatermarkChart   = "WatermarkChart"
 	BusinessConfIsReportApprove   = "IsReportApprove"
 	BusinessConfReportApproveType = "ReportApproveType"
 )

+ 2 - 0
models/data_manage/chart_info.go

@@ -1370,6 +1370,8 @@ type ChartInfoView struct {
 	Source            int    `description:"1:ETA图库;2:商品价格曲线;3:相关性图表"`
 	//CorrelationLeadUnit string `description:"相关性图表-领先单位"`
 	ExtraConfig       string          `description:"图表额外配置,json数据"`
+	ChartSource       string          `description:"图表来源str"`
+	ChartSourceEn     string          `description:"图表来源(英文)"`
 	Button            ChartViewButton `description:"操作按钮"`
 	SeasonExtraConfig string          `description:"季节性图表中的配置,json数据"`
 	StartYear         int             `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`

+ 48 - 0
services/data/chart_info.go

@@ -3,6 +3,7 @@ package data
 import (
 	"encoding/json"
 	"errors"
+	"eta/eta_api/models"
 	"eta/eta_api/models/company"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/system"
@@ -2466,3 +2467,50 @@ func EditChartInfo(req data_manage.EditChartInfoReq, sysUser *system.Admin) (cha
 
 	return
 }
+
+// GetEdbSourceByEdbInfoIdList 获取关联指标的来源
+func GetEdbSourceByEdbInfoIdList(chartEdbInfoMappingList []*data_manage.ChartEdbInfoMapping) (sourceNameList, sourceNameEnList []string) {
+	sourceNameList = make([]string, 0)
+	sourceNameEnList = make([]string, 0)
+	sourceMap := make(map[int]string)
+	for _, v := range chartEdbInfoMappingList {
+		// 指标类型:1:基础指标,2:计算指标
+		if v.EdbType == 2 || v.EdbInfoCategoryType == 1 {
+			//sourceMap[0] = "弘则研究"
+			baseEdbInfoArr, _, _ := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
+			for _, baseEdbInfo := range baseEdbInfoArr {
+				if baseEdbInfo.EdbInfoType == 0 { //普通指标才参与,预测指标不参与
+					sourceMap[baseEdbInfo.Source] = baseEdbInfo.SourceName
+				}
+			}
+		} else {
+			sourceMap[v.Source] = v.SourceName
+		}
+	}
+
+	for source, sourceName := range sourceMap {
+		if utils.InArrayByInt([]int{utils.DATA_SOURCE_MANUAL, utils.DATA_SOURCE_MYSTEEL_CHEMICAL}, source) {
+			continue
+		}
+		sourceNameList = append(sourceNameList, sourceName)
+
+		sourceNameEn, ok := utils.DataSourceEnMap[source]
+		if !ok {
+			sourceNameEn = sourceName
+		}
+		sourceNameEnList = append(sourceNameEnList, sourceNameEn)
+	}
+	//sourceNameList = append(sourceNameList, utils.ChartDefaultNameCn)
+	//sourceNameEnList = append(sourceNameEnList, utils.ChartDefaultNameEn)
+
+	// 图表来源
+	conf, e := models.GetBusinessConf()
+	if e != nil {
+		return
+	}
+	if conf[models.BusinessConfCompanyName] != "" {
+		sourceNameList = append(sourceNameList, conf[models.BusinessConfCompanyName])
+		sourceNameEnList = append(sourceNameEnList, conf[models.BusinessConfCompanyName])
+	}
+	return
+}

+ 28 - 1
utils/constants.go

@@ -362,10 +362,37 @@ const (
 
 const (
 	WindDbWsd = "wsd"
-	ThsDs = "thsds"
+	ThsDs     = "thsds"
 )
 
 const (
 	UserLoginSalt = "MiQM9yusNA9T2uIH"         // 用户登录盐值
 	DesKeySalt    = "JMCqSoUrTAmyNNIRb0TtlrPk" // DesKey盐值
 )
+
+// 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",
+	DATA_SOURCE_MYSTEEL_CHEMICAL: "Horizon Insights",
+	DATA_SOURCE_FUBAO:            "FuBao",
+}