Browse Source

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

zwxi 8 months ago
parent
commit
2a1481c978

+ 58 - 48
controllers/data_manage/base_from_ths_hf.go

@@ -299,7 +299,7 @@ func (this *BaseFromThsHfController) List() {
 
 	// 查询所有分类-分类查询/分类完整路径用
 	classifyOb := new(data_manage.BaseFromThsHfClassify)
-	classifies := make([]*data_manage.BaseFromThsHfClassify, 0)
+	//classifies := make([]*data_manage.BaseFromThsHfClassify, 0)
 	classifyIdItem := make(map[int]*data_manage.BaseFromThsHfClassify)
 	{
 		list, e := classifyOb.GetItemsByCondition(``, make([]interface{}, 0), []string{classifyOb.Cols().PrimaryId, classifyOb.Cols().ClassifyName, classifyOb.Cols().ClassifyNameEn, classifyOb.Cols().LevelPath}, "")
@@ -311,7 +311,7 @@ func (this *BaseFromThsHfController) List() {
 		for _, v := range list {
 			classifyIdItem[v.BaseFromThsHfClassifyId] = v
 		}
-		classifies = list
+		//classifies = list
 	}
 
 	// 筛选项
@@ -332,53 +332,63 @@ func (this *BaseFromThsHfController) List() {
 					classifyIds = append(classifyIds, t)
 				}
 			}
-
-			// 不包含子分类
-			if len(classifyIds) > 0 && !params.IncludeChild {
-				cond += fmt.Sprintf(" AND %s IN (%s)", indexOb.Cols().BaseFromThsHfClassifyId, utils.GetOrmInReplace(len(classifyIds)))
-				pars = append(pars, classifyIds)
-			}
-
-			// 包含子分类
-			if len(classifyIds) > 0 && params.IncludeChild {
-				queryClassifyIds := make([]int, 0)
-				queryClassifyExist := make(map[int]bool)
-
-				for _, v := range classifyIds {
-					// 遍历所有分类从LevelPath中找含有查询分类ID的...=_=!
-					for _, cv := range classifies {
-						if queryClassifyExist[cv.BaseFromThsHfClassifyId] {
-							continue
-						}
-						if cv.LevelPath == "" {
-							continue
-						}
-						strArr := strings.Split(cv.LevelPath, ",")
-						if len(strArr) == 0 {
-							continue
-						}
-						for _, sv := range strArr {
-							tv, _ := strconv.Atoi(sv)
-							if tv == v {
-								queryClassifyIds = append(queryClassifyIds, cv.BaseFromThsHfClassifyId)
-								queryClassifyExist[cv.BaseFromThsHfClassifyId] = true
-								break
-							}
-						}
-					}
-				}
-
-				if len(queryClassifyIds) == 0 {
-					page := paging.GetPaging(params.CurrentIndex, params.PageSize, 0)
-					resp.Paging = page
-					br.Ret = 200
-					br.Success = true
-					br.Msg = "获取成功"
-					return
-				}
-				cond += fmt.Sprintf(" AND %s IN (%s)", indexOb.Cols().BaseFromThsHfClassifyId, utils.GetOrmInReplace(len(queryClassifyIds)))
-				pars = append(pars, queryClassifyIds)
+			if len(classifyIds) == 0 {
+				page := paging.GetPaging(params.CurrentIndex, params.PageSize, 0)
+				resp.Paging = page
+				br.Ret = 200
+				br.Success = true
+				br.Msg = "获取成功"
+				return
 			}
+			cond += fmt.Sprintf(" AND %s IN (%s)", indexOb.Cols().BaseFromThsHfClassifyId, utils.GetOrmInReplace(len(classifyIds)))
+			pars = append(pars, classifyIds)
+
+			//// 不包含子分类
+			//if len(classifyIds) > 0 && !params.IncludeChild {
+			//	cond += fmt.Sprintf(" AND %s IN (%s)", indexOb.Cols().BaseFromThsHfClassifyId, utils.GetOrmInReplace(len(classifyIds)))
+			//	pars = append(pars, classifyIds)
+			//}
+			//
+			//// 包含子分类
+			//if len(classifyIds) > 0 && params.IncludeChild {
+			//	queryClassifyIds := make([]int, 0)
+			//	queryClassifyExist := make(map[int]bool)
+			//
+			//	for _, v := range classifyIds {
+			//		// 遍历所有分类从LevelPath中找含有查询分类ID的...=_=!
+			//		for _, cv := range classifies {
+			//			if queryClassifyExist[cv.BaseFromThsHfClassifyId] {
+			//				continue
+			//			}
+			//			if cv.LevelPath == "" {
+			//				continue
+			//			}
+			//			strArr := strings.Split(cv.LevelPath, ",")
+			//			if len(strArr) == 0 {
+			//				continue
+			//			}
+			//			for _, sv := range strArr {
+			//				tv, _ := strconv.Atoi(sv)
+			//				if tv == v {
+			//					queryClassifyIds = append(queryClassifyIds, cv.BaseFromThsHfClassifyId)
+			//					queryClassifyExist[cv.BaseFromThsHfClassifyId] = true
+			//					break
+			//				}
+			//			}
+			//		}
+			//	}
+			//
+			//	if len(queryClassifyIds) == 0 {
+			//		page := paging.GetPaging(params.CurrentIndex, params.PageSize, 0)
+			//		resp.Paging = page
+			//		br.Ret = 200
+			//		br.Success = true
+			//		br.Msg = "获取成功"
+			//		return
+			//	}
+			//	cond += fmt.Sprintf(" AND %s IN (%s)", indexOb.Cols().BaseFromThsHfClassifyId, utils.GetOrmInReplace(len(queryClassifyIds)))
+			//	pars = append(pars, queryClassifyIds)
+			//}
 		}
 
 		if params.Frequency != "" {

+ 51 - 23
controllers/data_manage/future_good/future_good_profit_chart_info.go

@@ -120,12 +120,22 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoAdd() {
 	var edbInfoIdArr []int
 	baseEdbInfo := new(data_manage.EdbInfo)
 	// ETA指标
-	edbInfoList, err := data_manage.GetEdbInfoByIdList(extraReq.EdbInfoIdList)
+	edbInfoListTmp, err := data_manage.GetEdbInfoByIdList(extraReq.EdbInfoIdList)
 	if err != nil {
 		br.Msg = "获取指标信息失败!"
 		br.ErrMsg = "获取图表的指标信息失败,Err:" + err.Error()
 		return
 	}
+	//按照请求顺序排序
+	edbInfoMap := make(map[int]*data_manage.EdbInfo)
+	for _, v := range edbInfoListTmp {
+		edbInfoMap[v.EdbInfoId] = v
+	}
+	edbInfoList := make([]*data_manage.EdbInfo, 0)
+	for _, v := range extraReq.EdbInfoIdList {
+		edbInfoList = append(edbInfoList, edbInfoMap[v])
+	}
+
 	edbInfoListMap := make(map[int]*data_manage.EdbInfo)
 	for k, v := range edbInfoList {
 		edbInfoList[k].EdbNameSource = v.EdbName
@@ -465,12 +475,21 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoEdit() {
 	var edbInfoIdArr []int
 	baseEdbInfo := new(data_manage.EdbInfo)
 	// ETA指标
-	edbInfoList, err := data_manage.GetEdbInfoByIdList(extraReq.EdbInfoIdList)
+	edbInfoListTmp, err := data_manage.GetEdbInfoByIdList(extraReq.EdbInfoIdList)
 	if err != nil {
 		br.Msg = "获取指标信息失败!"
 		br.ErrMsg = "获取图表的指标信息失败,Err:" + err.Error()
 		return
 	}
+	//按照请求顺序排序
+	edbInfoMap := make(map[int]*data_manage.EdbInfo)
+	for _, v := range edbInfoListTmp {
+		edbInfoMap[v.EdbInfoId] = v
+	}
+	edbInfoList := make([]*data_manage.EdbInfo, 0)
+	for _, v := range extraReq.EdbInfoIdList {
+		edbInfoList = append(edbInfoList, edbInfoMap[v])
+	}
 	edbInfoListMap := make(map[int]*data_manage.EdbInfo)
 	for k, v := range edbInfoList {
 		edbInfoList[k].EdbNameSource = v.EdbName
@@ -936,13 +955,20 @@ func (this *FutureGoodChartInfoController) PreviewProfitChartInfo() {
 		return
 	}
 	//查询基本指标信息
-	edbInfoList, err := data_manage.GetEdbInfoByIdList(req.EdbInfoIdList)
+	edbInfoListTmp, err := data_manage.GetEdbInfoByIdList(req.EdbInfoIdList)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
 		return
 	}
-
+	edbInfoMap := make(map[int]*data_manage.EdbInfo)
+	for _, v := range edbInfoListTmp {
+		edbInfoMap[v.EdbInfoId] = v
+	}
+	edbInfoList := make([]*data_manage.EdbInfo, 0)
+	for _, v := range req.EdbInfoIdList {
+		edbInfoList = append(edbInfoList, edbInfoMap[v])
+	}
 	// 获取图表中的指标数据
 	barConfigEdbInfoIdList, _, _, xDataList, yDataList, err := future_goodServ.GetProfitChartEdbData(baseEdbInfo, edbInfoList, zlFutureGoodEdbInfoList, req.DateList, req.CalculateFormula, req.FutureGoodEdbInfoIdList, req.XDataList)
 	if err != nil {
@@ -952,25 +978,27 @@ func (this *FutureGoodChartInfoController) PreviewProfitChartInfo() {
 	}
 
 	edbList := make([]*data_manage.ChartEdbInfoMapping, 0)
-	edbList = append(edbList, &data_manage.ChartEdbInfoMapping{
-		EdbInfoId:      baseEdbInfo.EdbInfoId,
-		SourceName:     baseEdbInfo.SourceName,
-		Source:         baseEdbInfo.Source,
-		EdbCode:        baseEdbInfo.EdbCode,
-		EdbName:        baseEdbInfo.EdbName,
-		EdbAliasName:   baseEdbInfo.EdbName,
-		EdbNameEn:      baseEdbInfo.EdbNameEn,
-		EdbAliasNameEn: baseEdbInfo.EdbNameEn,
-		EdbType:        baseEdbInfo.EdbType,
-		Frequency:      baseEdbInfo.Frequency,
-		FrequencyEn:    data.GetFrequencyEn(baseEdbInfo.Frequency),
-		Unit:           baseEdbInfo.Unit,
-		UnitEn:         baseEdbInfo.UnitEn,
-		StartDate:      baseEdbInfo.StartDate,
-		EndDate:        baseEdbInfo.EndDate,
-		ModifyTime:     baseEdbInfo.ModifyTime.Format(utils.FormatDateTime),
-		MappingSource:  1,
-	})
+	for _, v := range edbInfoList {
+		edbList = append(edbList, &data_manage.ChartEdbInfoMapping{
+			EdbInfoId:      v.EdbInfoId,
+			SourceName:     v.SourceName,
+			Source:         v.Source,
+			EdbCode:        v.EdbCode,
+			EdbName:        v.EdbName,
+			EdbAliasName:   v.EdbName,
+			EdbNameEn:      v.EdbNameEn,
+			EdbAliasNameEn: v.EdbNameEn,
+			EdbType:        v.EdbType,
+			Frequency:      v.Frequency,
+			FrequencyEn:    data.GetFrequencyEn(v.Frequency),
+			Unit:           v.Unit,
+			UnitEn:         v.UnitEn,
+			StartDate:      v.StartDate,
+			EndDate:        v.EndDate,
+			ModifyTime:     v.ModifyTime.Format(utils.FormatDateTime),
+			MappingSource:  1,
+		})
+	}
 
 	warnEdbList := make([]string, 0)
 	for _, v := range edbList {

+ 11 - 0
controllers/data_manage/mysteel_chemical_data.go

@@ -593,6 +593,17 @@ func (this *EdbInfoController) MysteelChemicalData() {
 		if dataList == nil {
 			dataList = make([]*data_manage.MysteelChemicalData, 0)
 		}
+		edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_MYSTEEL_CHEMICAL, v.IndexCode)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取指标库统计数据失败,Err:" + err.Error()
+			return
+		}
+		if edbInfo == nil {
+			list[k].EdbInfoId = 0
+		} else {
+			list[k].EdbInfoId = edbInfo.EdbInfoId
+		}
 		list[k].DataList = dataList
 		list[k].Paging = page
 	}

+ 3 - 0
controllers/report_chapter.go

@@ -1387,6 +1387,9 @@ func (this *ReportController) PublishDayWeekReportChapter() {
 		}
 	}()
 
+	// 生成音频
+	go services.UpdateChaptersVideo([]int{chapterInfo.ReportChapterId})
+
 	// 更新章节ES
 	{
 		go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)

+ 53 - 8
controllers/report_v2.go

@@ -131,7 +131,6 @@ func (this *ReportController) ListReport() {
 		condition += ` AND a.is_public_publish = ? `
 		pars = append(pars, 1)
 		condition += `  AND a.state in (2,6) `
-
 	case 3:
 		condition += ` AND a.admin_id = ? `
 		pars = append(pars, this.SysUser.AdminId)
@@ -173,11 +172,11 @@ func (this *ReportController) ListReport() {
 	if listLen > 0 {
 		pvMap := make(map[int]int)
 		uvMap := make(map[int]int)
-		reportIdArr := make([]string, 0)
+		reportIdArr := make([]int, 0)
 		syncReportIdArr := make([]string, 0)      // 同步过来的报告IDs
 		oldAndNewReportIdMap := make(map[int]int) // 旧报告和新报告的id对应关系
 		for i := 0; i < listLen; i++ {
-			reportIdArr = append(reportIdArr, strconv.Itoa(list[i].Id))
+			reportIdArr = append(reportIdArr, list[i].Id)
 			if list[i].OldReportId > 0 && list[i].ReportLayout == 1 {
 				syncReportIdArr = append(syncReportIdArr, strconv.Itoa(list[i].OldReportId))
 				oldAndNewReportIdMap[list[i].OldReportId] = list[i].Id
@@ -246,8 +245,53 @@ func (this *ReportController) ListReport() {
 				}
 			}
 			list[i].ChapterVideoList = chapterList
-			list[i].Pv += pvMap[list[i].Id]
-			list[i].Uv += uvMap[list[i].Id]
+			list[i].Pv = pvMap[list[i].Id]
+			list[i].Uv = uvMap[list[i].Id]
+		}
+
+		// 多人协作的协作报告,需要判断是否可编辑
+		{
+			grantObj := report.ReportGrant{}
+			grantList, err := grantObj.GetGrantListByIdList(reportIdArr)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取报告授权失败,Err:" + err.Error()
+				return
+			}
+
+			//grantMap := make(map[报告id]map[用户id]bool)
+			grantMap := make(map[int]map[int]bool)
+			for _, v := range grantList {
+				grantUserMap, ok := grantMap[v.ReportId]
+				if !ok {
+					grantUserMap = make(map[int]bool)
+				}
+				grantUserMap[v.AdminId] = true
+				grantMap[v.ReportId] = grantUserMap
+			}
+
+			for i, item := range list {
+				if item.AdminId == this.SysUser.AdminId {
+					list[i].HasAuth = true
+					continue
+				}
+
+				// 查找授权
+				var hasAuth bool
+				grantUserMap, ok := grantMap[item.Id]
+
+				// 如果报告根本没有授权用户,说明没有授权当前用户
+				if !ok {
+					continue
+				}
+				_, ok = grantUserMap[this.SysUser.AdminId]
+				list[i].HasAuth = hasAuth
+				// 如果报告关联用户找到,说明有授权当前用户
+				if ok {
+					list[i].HasAuth = true
+				}
+			}
+
 		}
 	}
 
@@ -1378,8 +1422,9 @@ func (this *ReportController) PrePublishReport() {
 	}
 
 	// 生成报告pdf和长图
-	if req.ReportUrl != "" {
-		go services.Report2pdfAndJpeg(req.ReportUrl, reportDetail.Id, 1)
+	{
+		reportPdfUrl := services.GetGeneralPdfUrl(reportDetail.ReportCode, reportDetail.ReportLayout)
+		go services.Report2pdfAndJpeg(reportPdfUrl, reportDetail.Id, 1)
 	}
 
 	br.Ret = 200
@@ -1625,7 +1670,7 @@ func fixApproveRecord() {
 	}
 	for _, recordItem := range list {
 		//fmt.Println(recordItem)
-		recordItem.NodeState = report_approve.ReportApproveStatePass
+		recordItem.NodeState = recordItem.State
 		recordItem.NodeApproveUserId = recordItem.ApproveUserId
 		recordItem.NodeApproveUserName = recordItem.ApproveUserName
 		recordItem.NodeApproveTime = recordItem.ApproveTime

+ 1 - 0
models/data_manage/mysteel_chemical_index.go

@@ -187,6 +187,7 @@ type MysteelChemicalList struct {
 	UnitName                          string             `orm:"column(unit)"`
 	UniqueCode                        string             `description:"唯一编码"`
 	FrequencyName                     string             `orm:"column(frequency)"`
+	EdbInfoId                         int                `description:"指标库的id"`
 	UpdateTime                        string             `orm:"column(modify_time)"`
 	IsStop                            int                `description:"是否停更:1:停更,0:未停更"`
 	Paging                            *paging.PagingItem `description:"分页数据"`

+ 4 - 3
models/report.go

@@ -123,6 +123,7 @@ type ReportList struct {
 	OldReportId        int                       `description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
 	MsgSendTime        string                    `description:"模版消息发送时间"`
 	CanEdit            bool                      `description:"是否可编辑"`
+	HasAuth            bool                      `description:"是否可操作"`
 	Editor             string                    `description:"编辑人"`
 	AdminId            int                       `description:"创建者账号"`
 	AdminRealName      string                    `description:"创建者姓名"`
@@ -201,7 +202,7 @@ type ReportPvUv struct {
 	UvTotal  int
 }
 
-func GetReportPvUvByReportIdList(reportIdList []string) (items []ReportPvUv, err error) {
+func GetReportPvUvByReportIdList(reportIdList []int) (items []ReportPvUv, err error) {
 	num := len(reportIdList)
 	if num <= 0 {
 		return
@@ -249,12 +250,12 @@ func GetReportListCountByGrant(condition string, pars []interface{}) (count int,
 func GetReportListByGrant(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 
-	sql := `SELECT * FROM report as a JOIN report_grant b on a.id = b.report_id  WHERE 1=1  `
+	sql := `SELECT a.* FROM report as a JOIN report_grant b on a.id = b.report_id  WHERE 1=1  `
 	if condition != "" {
 		sql += condition
 	}
 	// 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
-	sql += ` GROUP BY a.id ORDER BY FIELD(state,3,1,4,5,6,2), modify_time DESC LIMIT ?,?`
+	sql += ` GROUP BY a.id ORDER BY FIELD(state,3,1,4,5,6,2), a.modify_time DESC LIMIT ?,?`
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 1 - 1
models/report_approve/report_approve.go

@@ -328,7 +328,7 @@ func GetApprovedReportApprovePageList(cond string, pars []interface{}, orderRule
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
-	sql := fmt.Sprintf(`SELECT a.report_approve_record_id, a.state AS record_state,a.node_state,a.node_approve_time, a.node_approve_time AS handle_time, b.*
+	sql := fmt.Sprintf(`SELECT a.report_approve_record_id, a.node_state AS record_state,a.node_state,a.node_approve_time, a.node_approve_time AS handle_time, b.*
 		FROM report_approve_record AS a
 		JOIN report_approve AS b ON a.report_approve_id = b.report_approve_id
 		WHERE 1 = 1 %s %s

+ 1 - 1
models/report_chapter.go

@@ -304,7 +304,7 @@ func GetReportChapterVideoList(reportId int) (list []*ReportChapterVideoList, er
 }
 
 // GetReportChapterVideoListByReportIds 根据报告ID集合获取报告章节音频列表
-func GetReportChapterVideoListByReportIds(reportIds []string) (list []*ReportChapterVideoList, err error) {
+func GetReportChapterVideoListByReportIds(reportIds []int) (list []*ReportChapterVideoList, err error) {
 	if len(reportIds) == 0 {
 		return
 	}

+ 6 - 0
services/classify.go

@@ -560,6 +560,12 @@ func inheritReportChapterType(parentClassifyId, currClassifyId int) (err error)
 	obj := models.ReportChapterType{}
 	err = obj.MultiCreate(addList)
 
+	// 修改CRM权限
+	go func() {
+		var syncReq ChapterTypeSyncReq
+		_, _ = ReportChapterTypeSync(&syncReq)
+	}()
+
 	return
 }
 

+ 37 - 20
services/data/future_good/chart_info.go

@@ -517,7 +517,7 @@ func BarChartData(baseEdbInfoMapping *data_manage.ChartEdbInfoMapping, edbInfoMa
 
 		// 先找到基准日期
 		var realDateTime time.Time
-		realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[baseEdbInfoMapping.EdbInfoId], baseEdbDataMap[baseEdbInfoMapping.EdbInfoId])
+		realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[baseEdbInfoMapping.EdbInfoId], baseEdbDataMap[baseEdbInfoMapping.EdbInfoId], edbDataMap)
 		if tmpErr != nil {
 			err = tmpErr
 			return
@@ -536,19 +536,11 @@ func BarChartData(baseEdbInfoMapping *data_manage.ChartEdbInfoMapping, edbInfoMa
 				xEdbInfoIdList = append(xEdbInfoIdList, v.EdbInfoId)
 				continue
 			}
-			tmpRealDateTime, findDataValueTmp, isFindTmp, e := GetNeedDateData(realDateTime, edbDataListMap[v.EdbInfoId], baseEdbDataMap[v.EdbInfoId])
-			if e != nil {
-				err = e
-				return
-			}
+
+			findDataValueTmp, isFindTmp := baseEdbDataMap[v.EdbInfoId][realDateTime.Format(utils.FormatDate)]
 			findDataList = append(findDataList, findDataValueTmp)
 			yDataMap[v.EdbInfoId] = findDataValueTmp
-			if isFindTmp {
-				// todo 是否需要变更 maxDate
-				if maxDate.IsZero() || maxDate.Before(tmpRealDateTime) {
-					maxDate = tmpRealDateTime
-				}
-			} else {
+			if !isFindTmp {
 				noDataIdList = append(noDataIdList, v.EdbInfoId)
 				noDataIdMap[v.EdbInfoId] = v.EdbInfoId
 			}
@@ -975,7 +967,7 @@ func getFutureGoodEdbInfoList(latestDateTime time.Time, tmpFutureGoodEdbInfoList
 }
 
 // GetNeedDateData 获取合约内需要的日期数据
-func GetNeedDateData(needDateTime time.Time, dataList []*data_manage.EdbDataList, edbDataMap map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
+func GetNeedDateData(needDateTime time.Time, dataList []*data_manage.EdbDataList, edbDataMap map[string]float64, allEdbDataMap map[int]map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
 	//dataList := edbDataListMap[edbInfoId] //指标的所有数据值
 	if len(dataList) <= 0 {
 		// 没有数据的指标id
@@ -988,18 +980,43 @@ func GetNeedDateData(needDateTime time.Time, dataList []*data_manage.EdbDataList
 		return
 	}
 
+	// 该日期存在数据的期货指标的最小数量,目前是现货和期货各1个,总共2个
+	maxCount := 1
+
 	for tmpDateTime := needDateTime; tmpDateTime.After(minDateTime) || tmpDateTime.Equal(minDateTime); tmpDateTime = tmpDateTime.AddDate(0, 0, -1) {
 		tmpDate := tmpDateTime.Format(utils.FormatDate)
-		if tmpValue, ok := edbDataMap[tmpDate]; ok { //如果能找到数据,那么就返回
-			// 数据为0,也直接返回,做无值处理
-			if tmpValue == 0 {
-				return
+		tmpValue, ok := edbDataMap[tmpDate]
+		if !ok {
+			continue
+		}
+
+		// 该日期存在数据的指标数量
+		count := 0
+
+		for _, currEdbDataMap := range allEdbDataMap {
+			_, tmpIsFind := currEdbDataMap[tmpDate]
+			if tmpIsFind {
+				count++
+				if count >= maxCount {
+					continue
+				}
 			}
-			findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
-			findDataValue = tmpValue
-			isFind = true
+		}
+
+		// 该日期存在数据的期货指标数量小于2个,那么要继续往前找
+		if count < maxCount {
+			continue
+		}
+
+		//如果能找到数据,那么就返回
+		// 数据为0,也直接返回,做无值处理
+		if tmpValue == 0 {
 			return
 		}
+		findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
+		findDataValue = tmpValue
+		isFind = true
+		return
 	}
 
 	return

+ 61 - 19
services/data/future_good/profit_chart_info.go

@@ -177,7 +177,9 @@ func GetProfitChartEdbData(baseEdbInfo *data_manage.EdbInfo, edbInfoList []*data
 	sort.Slice(dateList, func(i, j int) bool {
 		return dateList[i] < dateList[j]
 	})
+	var reqEdbInfoIds []int
 	for _, v := range edbInfoList {
+		reqEdbInfoIds = append(reqEdbInfoIds, v.EdbInfoId)
 		tmp := data_manage.XData{
 			Name:   v.EdbName,
 			NameEn: v.EdbNameEn,
@@ -185,7 +187,8 @@ func GetProfitChartEdbData(baseEdbInfo *data_manage.EdbInfo, edbInfoList []*data
 		xDataList = append(xDataList, tmp)
 	}
 	var edbIdList []int
-	edbIdList, yDataList, err = ProfitChartChartData(baseEdbInfo, baseDataListMap, futureGoodEdbInfoDateMap, futureGoodDataListMap, chartInfoDateList, baseEdbInfo.EndDate, specialFutureGoodEdbInfoMap, formulaStr, tagEdbIdMap, dateList, maxN)
+
+	edbIdList, yDataList, err = ProfitChartChartData(baseEdbInfo, baseDataListMap, futureGoodEdbInfoDateMap, futureGoodDataListMap, chartInfoDateList, baseEdbInfo.EndDate, specialFutureGoodEdbInfoMap, formulaStr, tagEdbIdMap, dateList, maxN, reqEdbInfoIds)
 
 	// todo 最后处理数据
 	tmpXDataList, newYDataList, err := handleProfitResultData(xDataList, baseEdbInfo, yDataList, earliestDateTime, edbIdList)
@@ -204,7 +207,7 @@ func GetProfitChartEdbData(baseEdbInfo *data_manage.EdbInfo, edbInfoList []*data
 }
 
 // ProfitChartChartData 获取数据
-func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[int][]*data_manage.EdbDataList, futureGoodEdbInfoMap map[int]map[string]*future_good.FutureGoodEdbInfo, futureGoodEdbDataListMap map[int][]*data_manage.EdbDataList, chartInfoDateList []request.ChartInfoDateReq, latestDate string, specialFutureGoodEdbInfoMap map[int]map[int]*future_good.FutureGoodEdbInfo, formulaStr string, tagEdbIdMap map[string]int, dateList []string, maxN int) (edbIdList []int, yDataList []data_manage.YData, err error) {
+func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[int][]*data_manage.EdbDataList, futureGoodEdbInfoMap map[int]map[string]*future_good.FutureGoodEdbInfo, futureGoodEdbDataListMap map[int][]*data_manage.EdbDataList, chartInfoDateList []request.ChartInfoDateReq, latestDate string, specialFutureGoodEdbInfoMap map[int]map[int]*future_good.FutureGoodEdbInfo, formulaStr string, tagEdbIdMap map[string]int, dateList []string, maxN int, reqEdbInfoIds []int) (edbIdList []int, yDataList []data_manage.YData, err error) {
 	// 指标数据数组(10086:{"2022-12-02":100.01,"2022-12-01":102.3})
 	//earliestDateTime time.Time
 	// ETA指标数据
@@ -261,9 +264,10 @@ func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[
 			return
 		}
 
-		findDataList := make([]float64, 0) // 当前日期的数据值
-		noDataIdList := make([]int, 0)     // 没有数据的指标id
-		xEdbInfoIdList := make([]int, 0)   // 当前数据的指标id列表
+		findDataList := make([]float64, 0)  // 当前日期的数据值
+		noDataIdList := make([]int, 0)      // 没有数据的指标id
+		noDataIdMap := make(map[int]int, 0) // 没有数据的指标map
+		xEdbInfoIdList := make([]int, 0)    // 当前数据的指标id列表
 
 		// 现货指标
 		index := 0
@@ -274,7 +278,7 @@ func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[
 			err = fmt.Errorf("指标id: %d 没有数据", baseEdbInfo.EdbInfoId)
 			return
 		}
-		realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, baseDataListMap[baseEdbInfo.EdbInfoId], baseEdbDateData)
+		realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, baseDataListMap[baseEdbInfo.EdbInfoId], baseEdbDateData, edbDataMap)
 		if tmpErr != nil {
 			err = tmpErr
 			return
@@ -283,10 +287,10 @@ func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[
 			maxDate = realDateTime
 		}
 		edbIdList = make([]int, 0) //普通指标ID
-		for edbInfoId, baseDataList := range baseDataListMap {
+		for _, edbInfoId := range reqEdbInfoIds {
 			if edbInfoId == baseEdbInfo.EdbInfoId {
 				findDataList = append(findDataList, findDataValue)
-				yDataMap[0] = findDataValue
+				yDataMap[index] = findDataValue
 				xEdbInfoIdList = append(xEdbInfoIdList, edbInfoId)
 				edbIdList = append(edbIdList, edbInfoId)
 				index += 1
@@ -297,10 +301,11 @@ func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[
 				err = fmt.Errorf("指标id: %d 没有数据", edbInfoId)
 				return
 			}
-			_, findDataValueTmp, _, e := GetNeedDateData(realDateTime, baseDataList, baseEdbDateDataTmp)
-			if e != nil {
-				err = e
-				return
+
+			findDataValueTmp, isFindTmp := baseEdbDateDataTmp[realDateTime.Format(utils.FormatDate)]
+			if !isFindTmp {
+				noDataIdList = append(noDataIdList, edbInfoId)
+				noDataIdMap[edbInfoId] = edbInfoId
 			}
 			findDataList = append(findDataList, findDataValueTmp)
 			yDataMap[index] = findDataValueTmp
@@ -379,7 +384,7 @@ func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[
 			//计算公式异常,那么就移除该指标
 			if formulaFormStr == `` {
 				//removeDateList = append(removeDateList, sk)
-				//fmt.Println("异常了")
+				fmt.Println("异常了")
 				continue
 			}
 
@@ -432,6 +437,33 @@ func ProfitChartChartData(baseEdbInfo *data_manage.EdbInfo, baseDataListMap map[
 			yDate = maxDate.Format(utils.FormatDate)
 		}
 
+		{
+			hasDataIndexList := make([]int, 0)
+			for dataK, edbInfoId := range xEdbInfoIdList {
+				if _, ok := noDataIdMap[edbInfoId]; !ok { // 如果是没有数据的指标id
+					hasDataIndexList = append(hasDataIndexList, dataK)
+				}
+			}
+			lenHasDataIndex := len(hasDataIndexList)
+			if lenHasDataIndex > 0 {
+				for lenHasDataI := 1; lenHasDataI < lenHasDataIndex; lenHasDataI++ {
+					perK := hasDataIndexList[lenHasDataI-1] //上一个有数据的指标下标
+					currK := hasDataIndexList[lenHasDataI]  //当前有数据的指标下标
+					preVal := findDataList[perK]            //上一个有数据的坐标的值
+					currVal := findDataList[currK]          //当前有数据的指标的值
+
+					// 环差值
+					hcValDeci := decimal.NewFromFloat(currVal).Sub(decimal.NewFromFloat(preVal)).Div(decimal.NewFromInt(int64(currK - perK)))
+					var tmpI int64
+					// 将两个中间的数据做平均值补全
+					for hcI := perK + 1; hcI < currK; hcI++ {
+						tmpI++
+						findDataList[hcI], _ = decimal.NewFromFloat(preVal).Add(hcValDeci.Mul(decimal.NewFromInt(tmpI))).RoundCeil(4).Float64()
+					}
+				}
+			}
+		}
+
 		yDataList = append(yDataList, data_manage.YData{
 			Date:           yDate,
 			ConfigDate:     realDateTime,
@@ -529,10 +561,14 @@ func handleProfitResultData(xDataListInit []data_manage.XData, baseEdbInfo *data
 
 	nMap := make(map[int]int)
 	nList := make([]int, 0)
+	nListEdbMap := make(map[int]struct{})
 	for _, v := range yDataList {
 		for _, n := range v.XEdbInfoIdList {
 			if utils.InArrayByInt(allEdbInfoIds, n) {
-				nList = append(nList, n)
+				if _, ok := nListEdbMap[n]; !ok {
+					nList = append(nList, n)
+					nListEdbMap[n] = struct{}{}
+				}
 			} else {
 				nMap[n] = n
 			}
@@ -584,8 +620,12 @@ func handleProfitResultData(xDataListInit []data_manage.XData, baseEdbInfo *data
 							newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, tmpVal)
 						}
 					}
+					if utils.InArrayByInt(allEdbInfoIds, currN) {
+						newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, currN)
+					} else {
+						newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, currN+1)
+					}
 
-					newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, currN+1)
 					newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[valIndex])
 					valIndex++
 					needNum = 0
@@ -625,10 +665,11 @@ func handleProfitResultData(xDataListInit []data_manage.XData, baseEdbInfo *data
 
 		nameList := make([]string, 0)
 		enNameList := make([]string, 0)
-		for _, n := range newYDataList[yIndex].XEdbInfoIdList {
-			if n == 1 { // 现货价不处理
-				nameList = append(nameList, baseEdbInfo.EdbName)
-				enNameList = append(enNameList, baseEdbInfo.EdbNameEn)
+		for k1, n := range newYDataList[yIndex].XEdbInfoIdList {
+			if utils.InArrayByInt(allEdbInfoIds, n) { // 现货价不处理
+				tmpItem := xDataListInit[k1]
+				nameList = append(nameList, tmpItem.Name)
+				enNameList = append(enNameList, tmpItem.NameEn)
 				continue
 			}
 			if n <= 0 {
@@ -693,6 +734,7 @@ func ReplaceFormula(tagEdbIdMap map[string]int, valArr map[int]float64, formulaS
 	for k, v := range funMap {
 		formulaStr = strings.Replace(formulaStr, v, k, -1)
 	}
+	fmt.Println(formulaStr)
 	if replaceCount == len(tagEdbIdMap) {
 		return formulaStr
 	} else {

+ 1 - 1
services/ppt.go

@@ -107,7 +107,7 @@ func SavePPTReport(pptId, classifyId int, title string, adminInfo *system.Admin)
 		return
 	}
 	twoClassify, hasTwo = classifyMap[baseClassify.ParentId]
-	if ok {
+	if hasTwo {
 		threeClassify, hasThird = classifyMap[twoClassify.ParentId]
 	}
 

+ 0 - 31
services/report.go

@@ -322,37 +322,6 @@ func updateReportChapterEsByChapter(chapterInfo *models.ReportChapter) (err erro
 	return
 }
 
-// DeleteReportAndChapter 删除报告及章节
-func DeleteReportAndChapter(reportId int) (err error) {
-	reportInfo, err := models.GetReportByReportId(reportId)
-	if err != nil {
-		err = errors.New("报告信息有误, Err: " + err.Error())
-		return
-	}
-	if reportInfo.State == 2 {
-		err = errors.New("报告已发布,不可删除")
-		return
-	}
-	// 更新ES
-	_ = UpdateReportEs(reportId, 1)
-	// 删除
-	if reportInfo.HasChapter == 1 && (reportInfo.ChapterType == utils.REPORT_TYPE_DAY || reportInfo.ChapterType == utils.REPORT_TYPE_WEEK) {
-		err = models.DeleteDayWeekReportAndChapter(reportId)
-	} else {
-		err = models.DeleteReport(reportId)
-	}
-	if err != nil {
-		err = errors.New("删除失败, Err: " + err.Error())
-		return
-	}
-	// 重置PPT关联报告
-	go func() {
-		_ = ResetPPTReport(reportId, false)
-	}()
-
-	return
-}
-
 // 替换报告内容中的base64图片
 func replaceReportBase64ToImg(content string) (newContent string, err error) {
 	if content == "" {

+ 8 - 4
services/report_approve.go

@@ -676,9 +676,6 @@ func PassReportApprove(approveItem *report_approve.ReportApprove, recordItem *re
 				return
 			}
 		}()
-
-		// 生成报告pdf和长图
-		go Report2pdfAndJpeg(reportUrl, approveItem.ReportId, approveItem.ReportType)
 	}
 	return
 }
@@ -701,7 +698,7 @@ func RefuseReportApprove(approveItem *report_approve.ReportApprove, recordItem *
 	recordItem.ApproveTime = now
 	recordItem.ModifyTime = now
 
-	recordItem.NodeState = report_approve.ReportApproveStatePass
+	recordItem.NodeState = report_approve.ReportApproveStateRefuse
 	recordItem.NodeApproveUserId = recordItem.ApproveUserId
 	recordItem.NodeApproveUserName = recordItem.ApproveUserName
 	recordItem.NodeApproveTime = now
@@ -841,6 +838,13 @@ func AfterReportApprovePass(reportType, reportId int) (err error) {
 		}
 		// 重新生成音频,里面还涉及到章节类型的报告
 		go UpdateReportVideo(reportInfo)
+
+		// 生成报告pdf和长图
+		{
+			reportPdfUrl := GetGeneralPdfUrl(reportInfo.ReportCode, reportInfo.ReportLayout)
+			go Report2pdfAndJpeg(reportPdfUrl, reportId, 1)
+		}
+
 		//_ = CreateVideo(reportInfo)
 		_ = UpdateReportEs(reportInfo.Id, models.ReportStatePublished)
 

+ 62 - 4
services/report_v2.go

@@ -1117,8 +1117,9 @@ func PublishReport(reportId int, reportUrl string, sysUser *system.Admin) (tips
 	}()
 
 	// 生成报告pdf和长图
-	if reportUrl != "" {
-		go Report2pdfAndJpeg(reportUrl, reportId, 1)
+	{
+		reportPdfUrl := GetGeneralPdfUrl(reportInfo.ReportCode, reportInfo.ReportLayout)
+		go Report2pdfAndJpeg(reportPdfUrl, reportId, 1)
 	}
 
 	// 报告权限处理
@@ -1248,13 +1249,45 @@ func PublishChapterReport(reportInfo *models.Report, reportUrl string, sysUser *
 	go SaveReportLogs(reportInfo, chapters, reportInfo.AdminId, reportInfo.AdminRealName)
 
 	// 生成报告pdf和长图
-	if reportUrl != "" {
-		go Report2pdfAndJpeg(reportUrl, reportId, 1)
+	{
+		reportPdfUrl := GetGeneralPdfUrl(reportInfo.ReportCode, reportInfo.ReportLayout)
+		go Report2pdfAndJpeg(reportPdfUrl, reportId, 1)
 	}
 
 	return
 }
 
+// DeleteReportAndChapter 删除报告及章节
+func DeleteReportAndChapter(reportId int) (err error) {
+	reportInfo, err := models.GetReportByReportId(reportId)
+	if err != nil {
+		err = errors.New("报告信息有误, Err: " + err.Error())
+		return
+	}
+	if reportInfo.State == 2 {
+		err = errors.New("报告已发布,不可删除")
+		return
+	}
+	// 更新ES
+	_ = UpdateReportEs(reportId, 1)
+	// 删除
+	if reportInfo.HasChapter == 1 {
+		err = models.DeleteDayWeekReportAndChapter(reportId)
+	} else {
+		err = models.DeleteReport(reportId)
+	}
+	if err != nil {
+		err = errors.New("删除失败, Err: " + err.Error())
+		return
+	}
+	// 重置PPT关联报告
+	go func() {
+		_ = ResetPPTReport(reportId, false)
+	}()
+
+	return
+}
+
 // getMinClassify
 // @Description: 获取最小分类ID
 // @author: Roc
@@ -1370,3 +1403,28 @@ func UpdateReportVideo(reportInfo *models.Report) {
 		}
 	}
 }
+
+// GetGeneralPdfUrl
+// @Description: 获取生成pdf的地址
+// @author: Roc
+// @datetime 2024-07-19 14:09:28
+// @param reportCode string
+// @param reportLayout int8
+// @return pdfUrl string
+func GetGeneralPdfUrl(reportCode string, reportLayout int8) (pdfUrl string) {
+	conf, e := models.GetBusinessConfByKey("ReportViewUrl")
+	if e != nil {
+		return
+	}
+
+	switch reportLayout {
+	case 1:
+		// 普通布局
+		pdfUrl = fmt.Sprintf("%s/reportshare_pdf?code=%s", conf.ConfVal, reportCode)
+	case 2:
+		// 智能布局
+		pdfUrl = fmt.Sprintf("%s/reportshare_smart_pdf?code=%s", conf.ConfVal, reportCode)
+	}
+
+	return
+}

+ 11 - 0
services/smart_report.go

@@ -282,6 +282,13 @@ finally:
 	return
 }
 
+// Report2pdfAndJpeg
+// @Description: 报告转pdf和图片
+// @author: Roc
+// @datetime 2024-07-19 14:11:38
+// @param reportUrl string
+// @param reportId int
+// @param reportType int
 func Report2pdfAndJpeg(reportUrl string, reportId, reportType int) {
 	var err error
 
@@ -292,6 +299,10 @@ func Report2pdfAndJpeg(reportUrl string, reportId, reportType int) {
 		}
 	}()
 
+	if reportUrl == `` {
+		return
+	}
+
 	// 先清空字段
 	if reportType == 1 {
 		err = models.UpdatePdfUrlReportById(reportId)

+ 13 - 2
services/video.go

@@ -81,6 +81,13 @@ func CreateVideo(report *models.Report) (err error) {
 	//if utils.FileIsExist(savePath) {
 	//	os.Remove(savePath)
 	//}
+
+	// 如果没有文本内容,那么就不生成了
+	videoContent = strings.TrimSpace(videoContent)
+	if videoContent == `` {
+		return
+	}
+
 	contentArr := GetChineseCount(videoContent)
 	for _, v := range contentArr {
 		newText := v
@@ -124,7 +131,7 @@ func CreateVideo(report *models.Report) (err error) {
 		return
 	}
 
-	fileBody, err := ioutil.ReadFile(savePath)
+	fileBody, err := os.ReadFile(savePath)
 	videoSize := len(fileBody)
 	sizeFloat := (float64(videoSize) / float64(1024)) / float64(1024)
 	sizeStr := utils.SubFloatToFloatStr(sizeFloat, 2)
@@ -144,6 +151,7 @@ func CreateVideo(report *models.Report) (err error) {
 		}
 	}
 	err = models.ModifyReportVideo(report.Id, uploadUrl, videoName, sizeStr, playSeconds)
+
 	return
 }
 
@@ -235,7 +243,10 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
 			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "CreateReportVideo, reportTitle:" + reportTitle +", Err:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}()
-	if reportContent == "" {
+
+	// 如果没有文本内容,那么就不生成了
+	reportContent = strings.TrimSpace(reportContent)
+	if reportContent == `` {
 		return
 	}