浏览代码

Merge branch 'master' into yb_pc2.0

# Conflicts:
#	models/response/report.go
#	models/tables/rddp/report_chapter/query.go
ziwen 2 年之前
父节点
当前提交
5b94399cb3

+ 23 - 22
controller/chart/chart_info.go

@@ -37,7 +37,7 @@ import (
 // @Success 200 {object} chart_info.ChartInfoDetailResp
 // @failure 400 {string} string "图表详情获取失败"
 // @Router /my_chart/getChartInfoDetail [get]
-func GetChartInfoDetail(c *gin.Context)  {
+func GetChartInfoDetail(c *gin.Context) {
 	// 图表ID
 	reqChartInfoId := c.DefaultQuery("ChartInfoId", "")
 	if reqChartInfoId == "" {
@@ -68,7 +68,7 @@ func GetChartInfoDetail(c *gin.Context)  {
 			response.Fail("图表不存在,请刷新页面", c)
 			return
 		}
-		response.FailMsg("获取失败", "获取图表信息失败, Err:" + err.Error(), c)
+		response.FailMsg("获取失败", "获取图表信息失败, Err:"+err.Error(), c)
 		return
 	}
 	chartType = chartInfo.ChartType
@@ -84,7 +84,7 @@ func GetChartInfoDetail(c *gin.Context)  {
 		dateType, _ = strconv.Atoi(reqDateType)
 	}
 	if dateType <= 0 {
-		dateType = 3	// 默认同后台15年至今
+		dateType = 3 // 默认同后台15年至今
 	}
 
 	switch dateType {
@@ -149,14 +149,14 @@ func GetChartInfoDetail(c *gin.Context)  {
 	if chartInfoId > 0 {
 		mappingList, err = chartEdbMappingModel.GetMappingListByChartInfoId(chartInfoId)
 		if err != nil {
-			response.FailMsg("获取失败", "获取图表指标信息失败4001, Err:" + err.Error(), c)
+			response.FailMsg("获取失败", "获取图表指标信息失败4001, Err:"+err.Error(), c)
 			return
 		}
 	} else {
 		if edbInfoId != "" {
 			mappingList, err = chartEdbMappingModel.GetMappingListByEdbInfoId(edbInfoId)
 			if err != nil {
-				response.FailMsg("获取失败", "获取图表指标信息失败4002, Err:" + err.Error(), c)
+				response.FailMsg("获取失败", "获取图表指标信息失败4002, Err:"+err.Error(), c)
 				return
 			}
 		}
@@ -210,10 +210,13 @@ func GetChartInfoDetail(c *gin.Context)  {
 		item.LatestValue = v.LatestValue
 		item.LatestDate = v.LatestDate
 		item.UniqueCode = v.UniqueCode
+		item.ChartStyle = v.ChartStyle
 
 		var startDateReal string
 		var diffSeconds int64
-		if chartType == 1 {
+		if chartType == 2 { //季节性图表
+			startDateReal = startDate
+		} else {
 			if v.EdbInfoType == 0 && v.LeadUnit != "" && v.LeadValue > 0 {
 				// 领先指标
 				var startTimeRealTemp time.Time
@@ -240,15 +243,13 @@ func GetChartInfoDetail(c *gin.Context)  {
 			} else {
 				startDateReal = startDate
 			}
-		} else {
-			startDateReal = startDate
 		}
 		//fmt.Println("line 1011 chart:", v.Source, v.EdbInfoId, startDateReal, endDate)
 		calendarPreYear := 0
 		if calendar == "农历" {
 			newStartDateReal, err := time.Parse(utils.FormatDate, startDateReal)
 			if err != nil {
-				response.FailMsg("获取失败", "农历时间转换有误4001, Err:" + err.Error(), c)
+				response.FailMsg("获取失败", "农历时间转换有误4001, Err:"+err.Error(), c)
 				//fmt.Println("time.Parse:" + err.Error())
 				return
 			}
@@ -260,7 +261,7 @@ func GetChartInfoDetail(c *gin.Context)  {
 		fmt.Println("chart:", v.Source, v.EdbInfoId, startDateReal, endDate)
 		dataList, err = edbDataModel.GetEdbDataList(v.Source, v.EdbInfoId, startDateReal, endDate)
 		if err != nil {
-			response.FailMsg("获取失败", "获取图表指标信息失败4003, Err:" + err.Error(), c)
+			response.FailMsg("获取失败", "获取图表指标信息失败4003, Err:"+err.Error(), c)
 			return
 		}
 		if diffSeconds != 0 && v.EdbInfoType == 0 {
@@ -278,7 +279,7 @@ func GetChartInfoDetail(c *gin.Context)  {
 				} else {
 					result, err := edbDataService.AddCalculateQuarter(dataList)
 					if err != nil {
-						response.FailMsg("获取失败", "获取农历数据失败4002, Err:" + err.Error(), c)
+						response.FailMsg("获取失败", "获取农历数据失败4002, Err:"+err.Error(), c)
 						return
 					}
 					if result.List[0].Year != calendarPreYear {
@@ -304,7 +305,7 @@ func GetChartInfoDetail(c *gin.Context)  {
 				for _, v := range dataList {
 					itemDate, err := time.Parse(utils.FormatDate, v.DataTime)
 					if err != nil {
-						response.FailMsg("获取失败", "季度指标日期转换失败, Err:" + err.Error() + ";DataTime:" + v.DataTime, c)
+						response.FailMsg("获取失败", "季度指标日期转换失败, Err:"+err.Error()+";DataTime:"+v.DataTime, c)
 						return
 					}
 					year := itemDate.Year()
@@ -364,7 +365,7 @@ func GetChartInfoDetail(c *gin.Context)  {
 // @Success 200 {string} string "操作成功"
 // @failure 400 {string} string "操作失败"
 // @Router /my_chart/refreshChartInfo [post]
-func RefreshChartInfo(c *gin.Context)  {
+func RefreshChartInfo(c *gin.Context) {
 	// 参数校验
 	var req chartInfoModel.RefreshChartInfoReq
 	if c.ShouldBind(&req) != nil {
@@ -380,7 +381,7 @@ func RefreshChartInfo(c *gin.Context)  {
 	userInfo := user.GetInfoByClaims(c)
 	ok, _, err := user.GetAdminByUserInfo(userInfo)
 	if err != nil {
-		response.FailMsg("刷新失败", "RefreshChartInfo-获取系统用户信息失败" + err.Error(), c)
+		response.FailMsg("刷新失败", "RefreshChartInfo-获取系统用户信息失败"+err.Error(), c)
 		return
 	}
 	if !ok {
@@ -406,7 +407,7 @@ func RefreshChartInfo(c *gin.Context)  {
 			response.Fail("图表已被删除,无需刷新", c)
 			return
 		}
-		response.FailMsg("刷新失败", "刷新失败, Err:" + err.Error(), c)
+		response.FailMsg("刷新失败", "刷新失败, Err:"+err.Error(), c)
 		return
 	}
 
@@ -442,7 +443,7 @@ func RefreshChartInfo(c *gin.Context)  {
 // @Success 200 {string} string "操作成功"
 // @failure 400 {string} string "操作失败"
 // @Router /my_chart/editChartInfo [post]
-func EditChartInfo(c *gin.Context)  {
+func EditChartInfo(c *gin.Context) {
 	// 参数校验
 	var req chartInfoModel.SaveChartInfoReq
 	if c.ShouldBind(&req) != nil {
@@ -474,7 +475,7 @@ func EditChartInfo(c *gin.Context)  {
 			response.Fail("图表已被删除,请刷新页面!", c)
 			return
 		}
-		response.FailMsg("操作失败", "获取图表信息失败, Err:" + err.Error(), c)
+		response.FailMsg("操作失败", "获取图表信息失败, Err:"+err.Error(), c)
 		return
 	}
 	if chartItem.ChartType == 2 && len(req.ChartEdbInfoList) > 1 {
@@ -493,14 +494,14 @@ func EditChartInfo(c *gin.Context)  {
 		edbInfo, err := edbInfoModel.GetEdbInfoById(v.EdbInfoId)
 		if err != nil {
 			if err == utils.ErrNoRow {
-				response.FailMsg("操作失败", "图表不存在,ChartInfoId:" + strconv.Itoa(v.EdbInfoId), c)
+				response.FailMsg("操作失败", "图表不存在,ChartInfoId:"+strconv.Itoa(v.EdbInfoId), c)
 				return
 			}
-			response.FailMsg("操作失败", "获取图表的指标信息失败,Err:" + err.Error(), c)
+			response.FailMsg("操作失败", "获取图表的指标信息失败,Err:"+err.Error(), c)
 			return
 		}
 		if edbInfo == nil {
-			response.FailMsg("操作失败", "指标不存在,ChartInfoId:" + strconv.Itoa(v.EdbInfoId), c)
+			response.FailMsg("操作失败", "指标不存在,ChartInfoId:"+strconv.Itoa(v.EdbInfoId), c)
 			return
 		}
 		edbInfoIdArr = append(edbInfoIdArr, v.EdbInfoId)
@@ -516,7 +517,7 @@ func EditChartInfo(c *gin.Context)  {
 
 	err = chart.ModifyChartInfoAndMapping(edbInfoIdStr, &req, chartItem.ChartType)
 	if err != nil {
-		response.Fail("图表保存失败, Err:" + err.Error(), c)
+		response.Fail("图表保存失败, Err:"+err.Error(), c)
 		return
 	}
 
@@ -542,4 +543,4 @@ func EditChartInfo(c *gin.Context)  {
 	}
 
 	response.OkData("操作成功", "", c)
-}
+}

+ 1 - 0
models/response/report.go

@@ -40,6 +40,7 @@ type ReportItem struct {
 	VideoName          string `description:"音频文件名称" json:"video_name"`
 	VideoSize          string `description:"音频文件大小,单位M" json:"video_size"`
 	VideoPlaySeconds   string `description:"音频播放时长" json:"video_play_seconds"`
+	VideoImg           string    `description:"音频播放条的图片" json:"video_img"`
 	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
 	BannerUrl          string `description:"详情页banner" json:"banner_url"`
 }

+ 3 - 3
models/tables/edb_data/query.go

@@ -15,7 +15,7 @@ func GetEdbDataTableName(source int) (tableName string) {
 		tableName = "edb_data_ths"
 	case utils.DATA_SOURCE_WIND:
 		tableName = "edb_data_wind"
-	case utils.DATA_SOURCE_PB:
+	case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
 		tableName = "edb_data_pb"
 	case utils.DATA_SOURCE_CALCULATE:
 		tableName = "edb_data_calculate"
@@ -119,7 +119,7 @@ func GetEdbDataList(source, endInfoId int, startDate, endDate string) (list []*E
 	if len(list) > 0 {
 		for _, row := range list {
 			if row.DataTime != "" {
-				row.DataTime = row.DataTime[:10]	// 此处获取的字符串row.DataTime长度有长有短,截取年月日
+				row.DataTime = row.DataTime[:10] // 此处获取的字符串row.DataTime长度有长有短,截取年月日
 				//tempTime, _ := time.Parse("2006-01-02T00:00:00+08:00", row.DataTime)
 				//row.DataTime = tempTime.Format(utils.FormatDate)
 			}
@@ -150,4 +150,4 @@ func GetEdbInfoMaxAndMinInfo(source int, edbCode string) (item *EdbInfoMaxAndMin
 	err = global.MYSQL["data"].Raw(sql, edbCode).Scan(&latest_value).Error
 	item.LatestValue = latest_value
 	return
-}
+}

+ 1 - 1
models/tables/rddp/report_chapter/query.go

@@ -59,7 +59,7 @@ func GetListByReportIdTypeIds(reportId int, typeIds []int, classifyNameFirst str
 
 // GetContentById 根据ID获取章节详情
 func GetContentById(id int, typeIds []int) (info *ReportChapter, err error)  {
-	err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id,  is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, abstract, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size").
+	err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id,  is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size, report_type, video_size").
 		Where("report_chapter_id = ? and type_id in (?) AND publish_state = 2 ", id, typeIds).
 		First(&info).Error
 	if err == utils.ErrNoRow {

+ 3 - 1
services/chart/edb_data.go

@@ -35,6 +35,8 @@ func RefreshEdbData(edbInfoId, source int, edbCode, startDate string) (resp *Ref
 		urlStr = "/wind/refresh"
 	case utils.DATA_SOURCE_PB:
 		urlStr = "/pb/refresh"
+	case utils.DATA_SOURCE_PB_FINANCE:
+		urlStr = "/pb_finance/refresh"
 	case utils.DATA_SOURCE_MANUAL:
 		urlStr = "/manual/refresh"
 	case utils.DATA_SOURCE_LZ:
@@ -121,4 +123,4 @@ func RefreshEdbCalculateData(edbInfoId int, edbCode, startDate string) (resp *Re
 	param["StartDate"] = startDate
 	resp, err = postRefreshEdbData(param, "/calculate/refresh")
 	return
-}
+}

+ 31 - 0
services/report/report.go

@@ -442,6 +442,30 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
 				return
 			}
 		}
+	} else {
+		// 音频播放条图片用分类图片
+		reportItem.VideoImg = utils.HZ_DEFAULT_AVATAR
+		permissionIds, tmpErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(reportItem.ClassifyNameSecond)
+		if tmpErr != nil {
+			errMsg = tmpErr.Error()
+			err = errors.New("查询报告权限失败")
+			return
+		}
+		if len(permissionIds) > 0 {
+			chartPermission, tmpErr := chart_permission.GetListByIds(permissionIds)
+			if tmpErr != nil {
+				errMsg = tmpErr.Error()
+				err = errors.New("查询品种信息失败")
+				return
+			}
+			lenChart := len(chartPermission)
+			for i := 0; i < lenChart; i++ {
+				if chartPermission[i].YbImgUrl != "" {
+					reportItem.VideoImg = utils.ALIYUN_YBIMG_HOST + chartPermission[i].YbImgUrl
+					break
+				}
+			}
+		}
 	}
 	//如果有权限则展示content
 	if authOk {
@@ -788,6 +812,9 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 			if classifyParent.ClassifyName == "晨报" && productAuthOk {
 				// 查询当前晨报的所有音频
 				if vList, ok := videoMap[reportInfo.Id]; ok {
+					for _,vd := range vList {
+						vd.VideoImg = reportItem.ReportImgUrl
+					}
 					reportItem.VideoList = vList
 				}
 				reportItem.AuthOk = productAuthOk
@@ -797,6 +824,9 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 					if wAuth {
 						// 查询当前晨报的所有音频
 						if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
+							for _,vd := range vList {
+								vd.VideoImg = reportItem.ReportImgUrl
+							}
 							reportItem.VideoList = vList
 						}
 					}
@@ -810,6 +840,7 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 						videoTemp.VideoName = reportInfo.Title
 					}
 					videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
+					videoTemp.VideoImg = reportItem.ReportImgUrl
 					reportItem.VideoList = append(reportItem.VideoList, videoTemp)
 				}
 				reportItem.AuthOk = authOk

+ 7 - 2
services/report/report_chapter.go

@@ -197,7 +197,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 
 	reportInfo, tErr := report.GetByReportId(reportChapter.ReportId)
 	if tErr != nil {
-		errMsg = err.Error()
+		errMsg = tErr.Error()
 		err = errors.New("报告查询出错")
 		return
 	}
@@ -209,7 +209,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 		err = errors.New("章节未编辑")
 		return
 	}
-	//判断权限 TODO 查询章节相关的报告的charPermissionId
+	//判断权限
 	var newTypeIds []int
 	if reportInfo.ClassifyNameFirst == "晨报"{
 		authOk, permissionCheckInfo, err = CheckDayReportPermission(user, productAuthOk)
@@ -248,6 +248,11 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 		reportChapterItem.VideoName = reportChapter.Title
 	}
 	reportChapterItem.VideoSize = reportChapter.VideoSize
+	videoImgMap := map[string]string{
+		"day": "report_list_chen.png",
+		"week": "report_list_zhou.png",
+	}
+	reportChapterItem.VideoImg = utils.ALIYUN_YBIMG_HOST + videoImgMap[reportChapter.ReportType]
 	reportChapterItem.TypeName = reportChapter.TypeName
 	reportChapterItem.Author = reportChapter.Author
 	reportChapterItem.Stage = reportChapter.Stage

+ 8 - 7
utils/constants.go

@@ -23,7 +23,7 @@ const (
 )
 
 const (
-	APPNAME = "弘则研报"
+	APPNAME          = "弘则研报"
 	EmailSendToUsers = "317699326@qq.com;984198890@qq.com;hsun@hzinsights.com;xyxie@hzinsights.com"
 )
 
@@ -69,11 +69,12 @@ const (
 	DATA_SOURCE_LT                              //路透->25
 	DATA_SOURCE_COAL                            //中国煤炭网->26
 	DATA_SOURCE_PYTHON                          //python代码->27
+	DATA_SOURCE_PB_FINANCE                      //彭博财务数据->28
 )
 
 const (
 	HZ_CHART_LIB_DETAIL = "HZ_CHART_LIB_DETAIL_"
-	HONGZEYB_ = "hongze_yb:"
+	HONGZEYB_           = "hongze_yb:"
 )
 
 //var (
@@ -87,9 +88,9 @@ const (
 
 //数据刷新频率
 const (
-	DATA_REFRESH        = 7 //7个单位,日/周/月/季度/年
+	DATA_REFRESH             = 7 //7个单位,日/周/月/季度/年
 	DATA_START_REFRESH_LIMIT = 7 //7个单位,日/周/月/季度/年
-	DATA_END_DATE_LIMIT = 4 //数据结束日期为,当前日期,加上4年时间
+	DATA_END_DATE_LIMIT      = 4 //数据结束日期为,当前日期,加上4年时间
 )
 
 const (
@@ -99,7 +100,6 @@ const (
 	EDB_DATA_LIMIT = 10
 )
 
-
 var PermissionFiccClassifyArr = [...]string{"宏观经济", "化工产业", "黑色产业", "有色产业", "市场策略"}
 
 //缓存key
@@ -109,7 +109,7 @@ const (
 
 // es相关
 const (
-	ES_INDEX_RDDP_REPORT = "research_report_v1"                //报告
+	ES_INDEX_RDDP_REPORT = "research_report_v1" //报告
 )
 
 //EDB_LIB
@@ -119,5 +119,6 @@ var (
 )
 
 const ALIYUN_YBIMG_HOST = "https://hzstatic.hzinsights.com/static/yb_wx/"
+const HZ_DEFAULT_AVATAR = "https://hzstatic.hzinsights.com/static/yb_wx/hz_default_avatar.png"
 
-const HZPHONE = "057187186319"    //弘则电话
+const HZPHONE = "057187186319" //弘则电话