소스 검색

Merge remote-tracking branch 'origin/debug' into debug

zwxi 8 달 전
부모
커밋
2045f44876

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

@@ -1310,6 +1310,10 @@ func getFutureGoodChartInfo(chartInfo *data_manage.ChartInfoView, chartType, dat
 	}
 	futureGoodEdbInfoMapping, err = data_manage.GetFutureGoodEdbChartEdbMapping(chartInfoId)
 	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "期货指标不存在"
+			return
+		}
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
 		return

+ 35 - 35
models/classify.go

@@ -9,41 +9,41 @@ import (
 )
 
 type Classify struct {
-	Id                int       `orm:"column(id);pk"`
-	ClassifyName      string    `description:"分类名称"`
-	Sort              int       `json:"-"`
-	ParentId          int       `description:"父级分类id"`
-	CreateTime        time.Time `description:"创建时间"`
-	ModifyTime        time.Time `description:"修改时间"`
-	Abstract          string    `description:"栏目简介"`
-	Descript          string    `description:"分享描述"`
-	ReportAuthor      string    `description:"栏目作者"`
-	AuthorDescript    string    `description:"作者简介"`
-	ColumnImgUrl      string    `description:"栏目配图"`
-	HeadImgUrl        string    `description:"头部banner"`
-	AvatarImgUrl      string    `description:"头像"`
-	ReportImgUrl      string    `description:"报告配图"`
-	HomeImgUrl        string    `description:"首页配图"`
-	ClassifyLabel     string    `description:"分类标签"`
-	ShowType          int       `description:"展示类型:1-列表 2-专栏"`
-	HasTeleconference int       `description:"是否有电话会:0-否 1-是"`
-	VipTitle          string    `description:"研究员头衔"`
-	IsShow            int       `description:"是否在小程序显示:1-显示 0-隐藏"`
-	YbFiccSort        int       `description:"小程序FICC页排序"`
-	YbFiccIcon        string    `description:"小程序FICC页icon"`
-	YbFiccPcIcon      string    `description:"小程序PC端FICC页背景图"`
-	YbIconUrl         string    `description:"小程序已购页icon"`
-	YbBgUrl           string    `description:"小程序已购详情背景图"`
-	YbListImg         string    `description:"小程序研报列表封面图"`
-	YbShareBgImg      string    `description:"小程序研报详情分享背景图"`
-	YbRightBanner     string    `description:"Pc端详情页,右侧,报告合集背景图"`
-	RelateTel         int       `description:"是否在电话会中可选: 0-否; 1-是"`
-	RelateVideo       int       `description:"是否在路演视频中可选: 0-否; 1-是"`
-	IsMassSend        int       `description:"1:群发,0:非群发"`
-	Enabled           int       `description:"是否可用,1可用,0禁用"`
-	Level             int       `description:"层级"`
-	HasChild          int       `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
-	ReportShowType    int       `description:"报告详情的展示类型:1-拼接;2:目录"`
+	Id                   int       `orm:"column(id);pk"`
+	ClassifyName         string    `description:"分类名称"`
+	Sort                 int       `json:"-"`
+	ParentId             int       `description:"父级分类id"`
+	CreateTime           time.Time `description:"创建时间"`
+	ModifyTime           time.Time `description:"修改时间"`
+	Abstract             string    `description:"栏目简介"`
+	Descript             string    `description:"分享描述"`
+	ReportAuthor         string    `description:"栏目作者"`
+	AuthorDescript       string    `description:"作者简介"`
+	ColumnImgUrl         string    `description:"栏目配图"`
+	HeadImgUrl           string    `description:"头部banner"`
+	AvatarImgUrl         string    `description:"头像"`
+	ReportImgUrl         string    `description:"报告配图"`
+	HomeImgUrl           string    `description:"首页配图"`
+	ClassifyLabel        string    `description:"分类标签"`
+	ShowType             int       `description:"展示类型:1-列表 2-专栏"`
+	HasTeleconference    int       `description:"是否有电话会:0-否 1-是"`
+	VipTitle             string    `description:"研究员头衔"`
+	IsShow               int       `description:"是否在小程序显示:1-显示 0-隐藏"`
+	YbFiccSort           int       `description:"小程序FICC页排序"`
+	YbFiccIcon           string    `description:"小程序FICC页icon"`
+	YbFiccPcIcon         string    `description:"小程序PC端FICC页背景图"`
+	YbIconUrl            string    `description:"小程序已购页icon"`
+	YbBgUrl              string    `description:"小程序已购详情背景图"`
+	YbListImg            string    `description:"小程序研报列表封面图"`
+	YbShareBgImg         string    `description:"小程序研报详情分享背景图"`
+	YbRightBanner        string    `description:"Pc端详情页,右侧,报告合集背景图"`
+	RelateTel            int       `description:"是否在电话会中可选: 0-否; 1-是"`
+	RelateVideo          int       `description:"是否在路演视频中可选: 0-否; 1-是"`
+	IsMassSend           int       `description:"1:群发,0:非群发"`
+	Enabled              int       `description:"是否可用,1可用,0禁用"`
+	Level                int       `description:"层级"`
+	HasChild             int       `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
+	ReportDetailShowType int       `description:"报告详情的展示类型:1-拼接;2:目录"`
 }
 
 type ClassifyAddReq struct {

+ 5 - 5
models/data_manage/chart_info.go

@@ -265,6 +265,11 @@ type EditChartInfoReq struct {
 	ChartAlias           string                  `description:"图表别名"`
 }
 
+type EditFutureGoodChartInfoReq struct {
+	EditChartInfoReq
+	BarChartInfo FutureGoodBarChartInfoReq
+}
+
 type MarkersLine struct {
 	Axis             int             `json:"axis" description:"1左轴 2右轴 3横轴"`
 	AxisName         string          `json:"axisName" description:"轴的名称,例如'左轴'"`
@@ -313,11 +318,6 @@ type EdbDateConfDateChange struct {
 	ChangeType   int    `json:"changeType" description:"日期变换类型1日期位移,2指定频率"`
 }
 
-type EditFutureGoodChartInfoReq struct {
-	EditChartInfoReq
-	BarChartInfo FutureGoodBarChartInfoReq
-}
-
 type EditChartEnInfoReq struct {
 	ChartInfoId      int                       `description:"图表ID"`
 	ChartNameEn      string                    `description:"英文图表名称"`

+ 21 - 0
models/data_manage/chart_info_future_good.go

@@ -0,0 +1,21 @@
+package data_manage
+
+// FutureGoodProfitChartInfoReq 图表预览请求数据
+type FutureGoodProfitChartInfoReq struct {
+	FutureGoodEdbInfoIdList []EdbInfoFromTag                   `description:"指标信息"`
+	CalculateFormula        string                             `description:"计算公式"`
+	BaseEdbInfoId           int                                `description:"基础的指标id"`
+	DateList                []FutureGoodProfitChartInfoDateReq `description:"日期配置"`
+	ProfitNameEn            string                             `description:"利润英文名称"`
+	EdbInfoIdList           []int                              `description:"现货指标ID列表"`
+	XDataList               []XData                            `description:"横轴配置"`
+}
+
+// FutureGoodProfitChartInfoDateReq 图表的日期数据(日期相关)
+type FutureGoodProfitChartInfoDateReq struct {
+	Type  int    `description:"配置类型"`
+	Date  string `description:"固定日期"`
+	Value int    `description:"N天的值"`
+	Color string `description:"颜色"`
+	Name  string `description:"别名"`
+}

+ 56 - 2
models/data_manage/edb_info.go

@@ -931,9 +931,63 @@ func ReplaceChartEdb(oldEdbInfo, newEdbInfo *EdbInfo) (relationEdbInfoIdList []i
 					chartInfo.EdbInfoIds = strings.Join(edbInfoIds, ",")
 					updateStr = append(updateStr, "EdbInfoIds")
 				}
-				if chartInfo.ExtraConfig != "" {
+				if chartInfo.ExtraConfig != "" || chartInfo.BarConfig != "" {
 					//判断是否是拟合方程或者散点图截面图
-					if chartInfo.Source == utils.CHART_SOURCE_LINE_EQUATION {
+					if chartInfo.Source == utils.CHART_SOURCE_FUTURE_GOOD {
+						// 商品价格曲线图的一些配置
+						var barConfig FutureGoodBarChartInfoReq
+						err = json.Unmarshal([]byte(chartInfo.BarConfig), &barConfig)
+						if err != nil {
+							errmsg = "商品价格曲线图配置异常 json.Unmarshal:Err:" + err.Error()
+							return
+						}
+						if barConfig.BaseEdbInfoId == oldEdbInfo.EdbInfoId {
+							barConfig.BaseEdbInfoId = newEdbInfo.EdbInfoId
+						}
+						for k, item := range barConfig.EdbInfoIdList {
+							if item.EdbInfoId == oldEdbInfo.EdbInfoId && item.Source == 1 {
+								barConfig.EdbInfoIdList[k].EdbInfoId = newEdbInfo.EdbInfoId
+							}
+						}
+						// 更新图表配置信息
+						// 重新序列化
+						configJson, e := json.Marshal(barConfig)
+						if e != nil {
+							err = e
+							errmsg = "图表配置信息序列化失败:json.Marshal Err: " + e.Error()
+							return
+						}
+						configStr := string(configJson)
+						chartInfo.BarConfig = configStr
+						updateStr = append(updateStr, "BarConfig")
+					} else if chartInfo.Source == utils.CHART_SOURCE_FUTURE_GOOD_PROFIT {
+						// 商品利润曲线图的一些配置
+						var extraConf FutureGoodProfitChartInfoReq
+						err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &extraConf)
+						if err != nil {
+							errmsg = "商品利润曲线图配置异常 json.Unmarshal:Err:" + err.Error()
+							return
+						}
+						if extraConf.BaseEdbInfoId == oldEdbInfo.EdbInfoId {
+							extraConf.BaseEdbInfoId = newEdbInfo.EdbInfoId
+						}
+						for k, v := range extraConf.EdbInfoIdList {
+							if v == oldEdbInfo.EdbInfoId {
+								extraConf.EdbInfoIdList[k] = newEdbInfo.EdbInfoId
+							}
+						}
+						// 更新图表配置信息
+						// 重新序列化
+						configJson, e := json.Marshal(extraConf)
+						if e != nil {
+							err = e
+							errmsg = "图表配置信息序列化失败:json.Marshal Err: " + e.Error()
+							return
+						}
+						configStr := string(configJson)
+						chartInfo.ExtraConfig = configStr
+						updateStr = append(updateStr, "ExtraConfig")
+					} else if chartInfo.Source == utils.CHART_SOURCE_LINE_EQUATION {
 						//解析配置内容
 						var lineChartInfoConfig request.LineChartInfoReq
 						err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &lineChartInfoConfig)

+ 2 - 2
services/classify.go

@@ -265,8 +265,8 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
 	classify.ModifyTime = nowTime
 	classify.Sort = maxSort + 1
 	classify.Enabled = 1
-	classify.ShowType = 1       //默认列表格式
-	classify.ReportShowType = 1 //默认列表格式
+	classify.ShowType = 1             //默认列表格式
+	classify.ReportDetailShowType = 1 //默认列表格式
 	classify.IsShow = 1
 	classify.Level = level
 	/*classify.Abstract = req.Abstract

+ 2 - 0
services/data/edb_info.go

@@ -2644,8 +2644,10 @@ func EdbInfoWsdAdd(item *data_manage.EdbInfo) (edbInfo *data_manage.EdbInfo, err
 	edbInfo.EdbCode = item.EdbCode
 	edbInfo.EdbName = item.EdbName
 	edbInfo.EdbNameSource = item.EdbName
+	edbInfo.EdbNameEn = item.EdbNameEn
 	edbInfo.Frequency = item.Frequency
 	edbInfo.Unit = item.Unit
+	edbInfo.UnitEn = item.UnitEn
 	edbInfo.ClassifyId = item.ClassifyId
 	edbInfo.SysUserId = item.SysUserId
 	edbInfo.SysUserRealName = item.SysUserRealName

+ 4 - 4
services/data/future_good/chart_info.go

@@ -439,7 +439,6 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, baseEdbInfoMapp
 // BarChartData 获取数据
 func BarChartData(baseEdbInfoMapping *data_manage.ChartEdbInfoMapping, edbInfoMappingList []*data_manage.ChartEdbInfoMapping, futureGoodMappingList []*future_good2.FutureGoodEdbInfo, edbDataListMap map[int][]*data_manage.EdbDataList, barChartInfoDateList []data_manage.BarChartInfoDateReq, regionType, latestDate string) (edbIdList []int, yDataList []data_manage.YData, err error) {
 	// 指标数据数组(10086:{"2022-12-02":100.01,"2022-12-01":102.3})
-	edbDataMap := make(map[int]map[string]float64)
 	// 现货指标数据map
 	baseEdbDataMap := make(map[int]map[string]float64)
 	edbInfoMappingMap := make(map[int]struct{})
@@ -456,8 +455,7 @@ func BarChartData(baseEdbInfoMapping *data_manage.ChartEdbInfoMapping, edbInfoMa
 		}
 	}
 
-	// 期货指标数据map
-	//futureGoodEdbDataMap := make(map[int]map[string]float64)
+	edbDataMap := make(map[int]map[string]float64)
 	for edbInfoId, edbDataList := range edbDataListMap {
 		if _, ok := edbInfoMappingMap[edbInfoId]; ok {
 			continue
@@ -552,7 +550,9 @@ func BarChartData(baseEdbInfoMapping *data_manage.ChartEdbInfoMapping, edbInfoMa
 		// 用实际日期的月份作为基准,往前推12个月(2024-5-13 16:26:43修改)
 		currMonth := realDateTime.Month() // 当前月份
 		currYear := realDateTime.Year()   // 当前年份
-		mList := make([]int, 0)           // 间隔月份
+
+		mList := make([]int, 0) // 间隔月份
+
 		indexList := make([]int, 0)
 		if regionType == `国内` {
 			for i := currMonth + 1; i <= 12; i++ {

+ 1 - 1
services/data/future_good/profit_chart_info.go

@@ -652,7 +652,7 @@ func handleProfitResultData(xDataListInit []data_manage.XData, baseEdbInfo *data
 	}
 
 	earliestDateTime = time.Date(earliestDateTime.Year(), earliestDateTime.Month(), 1, 0, 0, 0, 0, time.Local)
-	xDataList = xDataList[0:maxI]
+	xDataList = xDataList[0 : maxI+1]
 	for yIndex, yData := range newYDataList {
 		if len(yData.XEdbInfoIdList) > maxI+1 {
 			newYDataList[yIndex].XEdbInfoIdList = yData.XEdbInfoIdList[0 : maxI+1]