Browse Source

Merge commit '69c2918f653be05b3ea49171d94250e7825680ba' into custom

Roc 4 months ago
parent
commit
7e0305efaa

+ 16 - 46
controllers/data_manage/edb_info.go

@@ -85,9 +85,18 @@ func (this *EdbInfoController) EdbInfoSearch() {
 	//判断指标是否存在
 	var item *data_manage.EdbInfo
 	var err error
-	if source == utils.DATA_SOURCE_GL {
-		// 如果是钢联的话,那么就先判断是不是存在钢联化工
-		item, err = data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_MYSTEEL_CHEMICAL, edbCode)
+	if utils.InArrayByInt([]int{utils.DATA_SOURCE_GL, utils.DATA_SOURCE_MYSTEEL_CHEMICAL}, source) {
+		//source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
+		source, item, err = data.GetMySteelSourceByEdbCode(edbCode)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	if item == nil {
+		item, err = data_manage.GetEdbInfoByEdbCode(source, edbCode)
 		if err != nil {
 			if err.Error() != utils.ErrNoRow() {
 				br.Msg = "获取失败"
@@ -95,50 +104,8 @@ func (this *EdbInfoController) EdbInfoSearch() {
 				return
 			}
 		}
-		err = nil
-		if item != nil {
-			source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
-		} else {
-			// 判断是不是已经在钢联这边已经存在了
-			item, err = data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_GL, edbCode)
-			if err != nil {
-				if err.Error() != utils.ErrNoRow() {
-					br.Msg = "获取失败"
-					br.ErrMsg = "获取失败,Err:" + err.Error()
-					return
-				}
-			}
-			err = nil
-
-			// 如果在钢联来源也没找到,那么就需要再判断下是否处于 《钢联化工》 数据源里面
-			if item == nil {
-				tmpInfo, err := data_manage.GetBaseFromMysteelChemicalIndexByCode(edbCode)
-				if err != nil {
-					if err.Error() != utils.ErrNoRow() {
-						br.Msg = "获取失败"
-						br.ErrMsg = "获取失败,Err:" + err.Error()
-						return
-					}
-				}
-				err = nil
-				if tmpInfo != nil {
-					source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
-				}
-			}
-
-		}
 	}
 
-	if item == nil {
-		item, err = data_manage.GetEdbInfoByEdbCode(source, edbCode)
-	}
-	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-	}
 	var isAdd bool
 	var isInEdb bool //是否在指标库中
 	if item != nil && item.EdbInfoId > 0 {
@@ -2435,7 +2402,7 @@ func (this *EdbInfoController) EdbInfoAdd() {
 	//}
 
 	// 兼容钢联与钢联化工数据
-	if source == utils.DATA_SOURCE_GL {
+	if utils.InArrayByInt([]int{utils.DATA_SOURCE_GL, utils.DATA_SOURCE_MYSTEEL_CHEMICAL}, source) {
 		// 如果是钢联的话,那么就先判断是不是存在钢联化工
 		tmpInfo, err := data_manage.GetBaseFromMysteelChemicalIndexByCode(req.EdbCode)
 		if err != nil {
@@ -2448,6 +2415,9 @@ func (this *EdbInfoController) EdbInfoAdd() {
 		if tmpInfo != nil {
 			source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
 			req.Source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
+		} else {
+			source = utils.DATA_SOURCE_GL
+			req.Source = utils.DATA_SOURCE_GL
 		}
 	}
 

+ 8 - 2
controllers/data_manage/manual_edb.go

@@ -10,12 +10,13 @@ import (
 	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
-	"github.com/shopspring/decimal"
 	"os"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/shopspring/decimal"
 )
 
 // ManualEdbController 手工指标服务(鉴权)
@@ -585,6 +586,11 @@ func (c *ManualEdbController) EditExcelData() {
 	dateValueMap := make(map[string]string)
 	//取到所有数据
 	for _, dateValue := range req.Data {
+		// 检验时间格式
+		_, err := time.Parse(utils.FormatDate, dateValue.Date)
+		if err != nil {
+			continue
+		}
 		dateValueMap[dateValue.Date] = strconv.FormatFloat(dateValue.Value, 'f', -1, 64)
 	}
 

+ 36 - 5
controllers/english_report/report.go

@@ -12,11 +12,12 @@ import (
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"html"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 // EnglishReportController 研报活动模块
@@ -90,9 +91,19 @@ func (this *EnglishReportController) Add() {
 		br.ErrMsg = "期数获取失败,Err:" + err.Error()
 		return
 	}
+	reportClassify, e := models.GetEnglishReportClassifyById(req.ClassifyIdFirst)
+	if e != nil {
+		if e.Error() == utils.ErrNoRow() {
+			br.Msg = "报告所在分类异常"
+			return
+		}
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取分类失败, Err: " + e.Error()
+		return
+	}
 
 	// 根据审批开关及审批流判断当前报告状态
-	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, req.ClassifyIdFirst, req.ClassifyIdSecond, req.ClassifyIdThird, models.ReportOperateAdd)
+	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, reportClassify.RootId, req.ClassifyIdFirst, req.ClassifyIdSecond, models.ReportOperateAdd)
 	if e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
@@ -1299,9 +1310,19 @@ func (this *EnglishReportController) SubmitApprove() {
 		br.ErrMsg = "获取报告失败, Err: " + e.Error()
 		return
 	}
+	reportClassify, e := models.GetEnglishReportClassifyById(reportItem.ClassifyIdFirst)
+	if e != nil {
+		if e.Error() == utils.ErrNoRow() {
+			br.Msg = "报告所在分类异常"
+			return
+		}
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取分类失败, Err: " + e.Error()
+		return
+	}
 
 	// 校验当前审批配置, 返回下一个状态
-	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, 0, models.ReportOperateSubmitApprove)
+	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, reportClassify.RootId, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, models.ReportOperateSubmitApprove)
 	if e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = "校验报告状态失败, Err: " + e.Error()
@@ -1324,7 +1345,7 @@ func (this *EnglishReportController) SubmitApprove() {
 	}
 
 	// 提交审批
-	approveId, e := services.SubmitReportApprove(report_approve.FlowReportTypeEnglish, reportItem.Id, reportItem.Title, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, 0, sysUser.AdminId, sysUser.RealName)
+	approveId, e := services.SubmitReportApprove(report_approve.FlowReportTypeEnglish, reportItem.Id, reportItem.Title, reportClassify.RootId, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, sysUser.AdminId, sysUser.RealName)
 	if e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = "提交审批失败, Err: " + e.Error()
@@ -1390,9 +1411,19 @@ func (this *EnglishReportController) CancelApprove() {
 		br.ErrMsg = "获取报告失败, Err: " + e.Error()
 		return
 	}
+	reportClassify, e := models.GetEnglishReportClassifyById(reportItem.ClassifyIdFirst)
+	if e != nil {
+		if e.Error() == utils.ErrNoRow() {
+			br.Msg = "报告所在分类异常"
+			return
+		}
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取分类失败, Err: " + e.Error()
+		return
+	}
 
 	// 校验当前审批配置, 返回下一个状态
-	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, 0, models.ReportOperateCancelApprove)
+	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, reportClassify.RootId, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, models.ReportOperateCancelApprove)
 	if e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = "校验报告状态失败, Err: " + e.Error()

+ 4 - 2
controllers/report_chapter.go

@@ -377,6 +377,7 @@ func (this *ReportController) EditDayWeekChapter() {
 	reportInfo.LastModifyAdminName = sysUser.RealName
 	reportInfo.ModifyTime = time.Now()
 
+	updateCols := make([]string, 0)
 	reqTickerList := req.TickerList
 	// 更新章节及指标
 	contentSub := ""
@@ -405,6 +406,7 @@ func (this *ReportController) EditDayWeekChapter() {
 
 	if req.Title != "" {
 		reportChapterInfo.Title = req.Title
+		updateCols = append(updateCols, "Title")
 	}
 	//reportChapterInfo.AddType = req.AddType
 	reportChapterInfo.Author = req.Author
@@ -414,6 +416,7 @@ func (this *ReportController) EditDayWeekChapter() {
 	reportChapterInfo.ModifyTime = time.Now()
 	if req.CreateTime != `` {
 		reportChapterInfo.CreateTime = req.CreateTime
+		updateCols = append(updateCols, "CreateTime")
 	}
 
 	reportChapterInfo.LastModifyAdminId = sysUser.AdminId
@@ -421,8 +424,7 @@ func (this *ReportController) EditDayWeekChapter() {
 	reportChapterInfo.ContentModifyTime = time.Now()
 	reportChapterInfo.ContentStruct = html.EscapeString(req.ContentStruct)
 
-	updateCols := make([]string, 0)
-	updateCols = append(updateCols, "Title", "AddType", "Author", "Content", "ContentSub", "IsEdit", "CreateTime", "ModifyTime")
+	updateCols = append(updateCols, "Author", "Content", "ContentSub", "IsEdit", "ModifyTime")
 
 	updateCols = append(updateCols, "LastModifyAdminId", "LastModifyAdminName", "ContentModifyTime", "ContentStruct")
 

+ 26 - 18
controllers/target.go

@@ -767,34 +767,42 @@ func (this *TargetController) ClassifyList() {
 		return
 	}
 
-	classifyIdStrList := make([]string, 0)
+	classifyIdList := make([]int, 0)
 	for _, classifyList := range list {
 		if classifyList.Child != nil {
 			for _, classify := range classifyList.Child {
-				classifyIdStrList = append(classifyIdStrList, strconv.Itoa(classify.ClassifyId))
+				classifyIdList = append(classifyIdList, classify.ClassifyId)
 			}
 		}
 	}
-	if len(classifyIdStrList) > 0 {
-		edbInfoGroupCountList, err := models.GetEdbInfoGroupCountByClassifyIds(strings.Join(classifyIdStrList, ","))
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取分类下有数据的指标数量失败,Err:" + err.Error()
-			return
-		}
-
-		edbInfoGroupCountMap := make(map[int]int)
-		for _, edbInfoGroupCount := range edbInfoGroupCountList {
-			edbInfoGroupCountMap[edbInfoGroupCount.ClassifyId] = edbInfoGroupCount.Count
-		}
+	if len(classifyIdList) > 0 {
+		//edbInfoGroupCountList, err := models.GetEdbInfoGroupCountByClassifyIds(classifyIdList)
+		//if err != nil {
+		//	br.Msg = "获取失败"
+		//	br.ErrMsg = "获取分类下有数据的指标数量失败,Err:" + err.Error()
+		//	return
+		//}
+		//
+		//edbInfoGroupCountMap := make(map[int]int)
+		//for _, edbInfoGroupCount := range edbInfoGroupCountList {
+		//	edbInfoGroupCountMap[edbInfoGroupCount.ClassifyId] = edbInfoGroupCount.Count
+		//}
+		//for _, classifyList := range list {
+		//	classifyList.UniqueCode = utils.MD5(fmt.Sprint(classifyList.ClassifyId))
+		//	if classifyList.Child != nil {
+		//		for _, classify := range classifyList.Child {
+		//			if total, ok := edbInfoGroupCountMap[classify.ClassifyId]; ok {
+		//				classify.EdbInfoTotal = total
+		//				classify.UniqueCode = utils.MD5(fmt.Sprint(classify.ClassifyId))
+		//			}
+		//		}
+		//	}
+		//}
 		for _, classifyList := range list {
 			classifyList.UniqueCode = utils.MD5(fmt.Sprint(classifyList.ClassifyId))
 			if classifyList.Child != nil {
 				for _, classify := range classifyList.Child {
-					if total, ok := edbInfoGroupCountMap[classify.ClassifyId]; ok {
-						classify.EdbInfoTotal = total
-						classify.UniqueCode = utils.MD5(fmt.Sprint(classify.ClassifyId))
-					}
+					classify.UniqueCode = utils.MD5(fmt.Sprint(classify.ClassifyId))
 				}
 			}
 		}

+ 18 - 2
models/data_manage/chart_classify.go

@@ -481,7 +481,15 @@ func GetChartClassifyAndInfoByParentId(parentId int) (items []*ChartClassifyItem
 	sys_user_real_name,
 	sort,
 	level,
-	unique_code
+	unique_code,
+	source,
+	0 as date_type,
+	'' as start_date,
+	'' as end_date,
+	0 as chart_type,
+	'' as calendar,
+	'' as season_start_date,
+	'' as season_end_date
 FROM
 	chart_classify 
 WHERE
@@ -498,7 +506,15 @@ SELECT
 	sys_user_real_name,
 	sort,
 	0 AS level,
-	unique_code
+	unique_code,
+	source,
+	date_type,
+	start_date,
+	end_date,
+	chart_type,
+	calendar,
+	season_start_date,
+	season_end_date
 FROM
 	chart_info 
 WHERE

+ 2 - 2
models/data_manage/excel/request/mixed_table.go

@@ -136,8 +136,8 @@ type MixCellShowStyle struct {
 	Pn              int         `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
 	Nt              string      `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
 	GlObj           interface{} `description:"公式对象:1:数值,2:百分比,3:文本" json:"glObj"`
-	Decimal         *int        `description:"小数点位数"`
-	Last            string      `description:"起始操作:nt|decimal"`
+	Decimal         *int        `description:"小数点位数" json:"decimal"`
+	Last            string      `description:"起始操作:nt|decimal" json:"last"`
 	Color           string      `description:"颜色值,#RRG" json:"color"`
 	BackgroundColor string      `description:"背景颜色值,#RRG" json:"background-color"`
 }

+ 1 - 1
models/document_manage_model/outside_report.go

@@ -65,7 +65,7 @@ func GetOutsideReportListByConditionCount(condition string, pars []interface{})
 // GetOutsideReportListByCondition 根据条件查询列表
 func GetOutsideReportListByCondition(condition string, pars []interface{}, currentIndex int, pageSize int) (list []OutsideReport, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `select t1.outside_report_id, t1.source, t1.title, t1.abstract, t1.classify_id, 
+	sql := `select DISTINCT t1.outside_report_id, t1.source, t1.title, t1.abstract, t1.classify_id, 
 t1.classify_name, t1.sys_user_id, t1.sys_user_name, t1.email_message_uid, t1.report_update_time, 
 t1.modify_time, t1.create_time, t1.report_code from outside_report t1 
 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `

+ 0 - 2
models/english_report.go

@@ -96,8 +96,6 @@ type AddEnglishReportReq struct {
 	ClassifyNameFirst  string `description:"一级分类名称"`
 	ClassifyIdSecond   int    `description:"二级分类id"`
 	ClassifyNameSecond string `description:"二级分类名称"`
-	ClassifyIdThird    int    `description:"三级分类id"`
-	ClassifyNameThird  string `description:"三级分类名称"`
 	Title              string `description:"标题"`
 	Abstract           string `description:"摘要"`
 	Author             string `description:"作者"`

+ 2 - 2
models/report.go

@@ -201,9 +201,9 @@ func GetReportListV1(condition string, pars []interface{}, startSize, pageSize i
 func GetReportListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 
-	sql := `SELECT a.id, a.title, a.author, a.modify_time, a.publish_time,a.classify_id_first,
+	sql := `SELECT DISTINCT a.id, a.title, a.author, a.modify_time, a.publish_time,a.classify_id_first,
 a.classify_name_first,a.classify_id_second,a.classify_name_second,a.classify_id_third,
-a.classify_name_third FROM report as a WHERE 1=1  `
+a.classify_name_third,a.abstract,a.admin_id,a.admin_real_name,a.last_modify_admin_id,a.last_modify_admin_name FROM report as a WHERE 1=1  `
 	if condition != "" {
 		sql += condition
 	}

+ 31 - 21
models/target.go

@@ -427,28 +427,34 @@ func GetEdbdataClassify(userId int64) (items []*EdbdataClassifyList, err error)
 	}
 	classifyLen := len(newItems)
 
+	// 获取子集分类
+	var allChildItems []*EdbdataClassify
+	if userId > 0 {
+		userClassifyList, _ := GetManualUserClassify(int(userId))
+		var userIdArr []int
+		for _, v := range userClassifyList {
+			userIdArr = append(userIdArr, v.ClassifyId)
+		}
+		num := len(userClassifyList)
+		if num > 0 {
+			childSql := "SELECT a.classify_id,a.classify_name,a.parent_id FROM edbdata_classify AS a WHERE a.is_show=1 and a.classify_id IN(" + utils.GetOrmInReplace(num) + ") ORDER BY a.create_time ASC "
+			_, err = o.Raw(childSql, userIdArr).QueryRows(&allChildItems)
+		}
+	} else {
+		childSql := "SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE is_show=1 ORDER BY create_time ASC "
+		_, err = o.Raw(childSql).QueryRows(&allChildItems)
+	}
+	if err != nil {
+		return
+	}
+
 	for i := 0; i < classifyLen; i++ {
 		var childItems []*EdbdataClassify
 		parentId := newItems[i].ClassifyId
-		childSql := ``
-		if userId > 0 {
-			userClassifyList, _ := GetManualUserClassify(int(userId))
-			var userIdArr []string
-			for _, v := range userClassifyList {
-				userIdArr = append(userIdArr, strconv.Itoa(v.ClassifyId))
-			}
-
-			userIdStr := strings.Join(userIdArr, ",")
-			if userIdStr != "" {
-				childSql = "SELECT a.classify_id,a.classify_name,a.parent_id FROM edbdata_classify AS a WHERE a.is_show=1 and a.classify_id IN(" + userIdStr + ") AND parent_id=? ORDER BY a.create_time ASC "
-				_, err = o.Raw(childSql, parentId).QueryRows(&childItems)
+		for _, v := range allChildItems {
+			if v.ParentId == parentId {
+				childItems = append(childItems, v)
 			}
-		} else {
-			childSql = "SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE is_show=1 and parent_id=? ORDER BY create_time ASC "
-			_, err = o.Raw(childSql, parentId).QueryRows(&childItems)
-		}
-		if err != nil {
-			return
 		}
 		newItems[i].Child = childItems
 	}
@@ -1473,13 +1479,17 @@ type EdbInfoGroupCount struct {
 }
 
 // GetEdbInfoGroupCountByClassifyIds 根据指标分类id获取当前分类下的指标数量
-func GetEdbInfoGroupCountByClassifyIds(classifyIds string) (list []*EdbInfoGroupCount, err error) {
+func GetEdbInfoGroupCountByClassifyIds(classifyIdList []int) (list []*EdbInfoGroupCount, err error) {
+	num := len(classifyIdList)
+	if num <= 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count,classify_id FROM ( SELECT a.*,b.CLOSE FROM edbinfo AS a 
              INNER JOIN edbdata AS b ON a.TRADE_CODE=b.TRADE_CODE
-             WHERE a.classify_id in (` + classifyIds + `) group by a.TRADE_CODE) d 
+             WHERE a.classify_id in (` + utils.GetOrmInReplace(num) + `) group by a.TRADE_CODE) d 
 						 GROUP BY classify_id `
-	_, err = o.Raw(sql).QueryRows(&list)
+	_, err = o.Raw(sql, classifyIdList).QueryRows(&list)
 	return
 }
 

+ 4 - 0
services/data/chart_info.go

@@ -1637,6 +1637,8 @@ func BatchChartInfoRefreshV2(chartInfoList []*data_manage.ChartInfo, redisKey st
 		for _, v := range chartInfoList {
 			key := utils.HZ_CHART_LIB_DETAIL + v.UniqueCode
 			refreshItem.ItemRefreshKeys = append(refreshItem.ItemRefreshKeys, key)
+			// eta平台的缓存,用于Ppt等地方的展示
+			refreshItem.ItemRefreshKeys = append(refreshItem.ItemRefreshKeys, GetChartInfoDataKey(v.ChartInfoId))
 		}
 		refreshItem.BaseEdbInfoArr = newBaseEdbInfoArr
 		refreshItem.BasePredictEdbInfoArr = newBasePredictEdbInfoArr
@@ -1652,6 +1654,8 @@ func BatchChartInfoRefreshV2(chartInfoList []*data_manage.ChartInfo, redisKey st
 		for _, v := range chartInfoList {
 			key := utils.HZ_CHART_LIB_DETAIL + v.UniqueCode
 			_ = utils.Rc.Delete(key)
+			// eta平台的缓存,用于Ppt等地方的展示
+			_ = utils.Rc.Delete(GetChartInfoDataKey(v.ChartInfoId))
 		}
 	}
 

+ 67 - 0
services/data/edb_info.go

@@ -3122,3 +3122,70 @@ func GetIsSupplierStop(source int, edbCode string) (isSupplierStop int) {
 
 	return
 }
+
+// GetMySteelSourceByEdbCode
+// @Description: 根据钢联的指标编码,获取该数据应该从哪个数据源查询
+// @author: Roc
+// @datetime 2024-09-10 13:25:07
+// @param edbCode string
+// @return source int
+// @return item *data_manage.EdbInfo
+// @return err error
+func GetMySteelSourceByEdbCode(edbCode string) (source int, item *data_manage.EdbInfo, err error) {
+	// 先判断在指标库的“上海钢联”中是否存在,存在就直接返回
+	source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
+	item, err = data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_MYSTEEL_CHEMICAL, edbCode)
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			return
+		}
+		err = nil
+	}
+	if item != nil {
+		source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
+		return
+	}
+
+	// 再判断在指标库的“钢联原始”中是否存在,存在就直接返回
+	item, err = data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_GL, edbCode)
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			return
+		}
+		err = nil
+	}
+	if item != nil {
+		source = utils.DATA_SOURCE_GL
+		return
+	}
+
+	// 再没有就判断下是否处于 《上海钢联》 数据源里面
+	{
+		tmpInfo, tmpErr := data_manage.GetBaseFromMysteelChemicalIndexByCode(edbCode)
+		if tmpErr != nil {
+			if tmpErr.Error() != utils.ErrNoRow() {
+				err = tmpErr
+				return
+			}
+		}
+		if tmpInfo != nil {
+			source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
+		}
+	}
+
+	// 再没有就判断下是否处于 《钢联原始》 数据源里面
+	{
+		tmpInfo, tmpErr := data_manage.GetGlIndexByCode(edbCode)
+		if tmpErr != nil {
+			if tmpErr.Error() != utils.ErrNoRow() {
+				err = tmpErr
+				return
+			}
+		}
+		if tmpInfo != nil {
+			source = utils.DATA_SOURCE_GL
+		}
+	}
+
+	return
+}

+ 1 - 1
services/data/excel/excel_info.go

@@ -148,7 +148,7 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 
 			// 获取所有有权限的指标和分类
 			permissionEdbIdList, permissionClassifyIdList, tmpErr := data_manage_permission.GetUserEdbAndClassifyPermissionList(sysUserId, 0, 0)
-			if err != nil {
+			if tmpErr != nil {
 				err = errors.New("获取所有有权限的指标和分类失败,Err:" + tmpErr.Error())
 				return
 			}

+ 60 - 12
services/data/excel/mixed_table.go

@@ -1186,10 +1186,19 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 
 			cell := config[cellPosition.Column][cellPosition.Row]
 			val := cell.ShowValue
-			isPercent := false
-			if strings.Contains(val, "%") {
-				isPercent = true
-				val = strings.Trim(val, "%")
+			// 前端不支持手动输入的%数
+			// isPercent := false
+			// if strings.Contains(val, "%") {
+			// 	isPercent = true
+			// 	val = strings.Trim(val, "%")
+			// }
+			// 如果没有showValue, 则使用value
+			if cell.ShowValue == "" {
+				_, err := strconv.ParseFloat(cell.Value, 64)
+				if err == nil {
+					val = cell.Value
+					cell.ShowValue = cell.Value
+				}
 			}
 			_, e := strconv.ParseFloat(val, 64) // 将字符串转换成float类型
 			if e != nil {                       // 如果没有错误发生则返回true,说明该字符串是一个合法的数字
@@ -1216,19 +1225,45 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 				err = fmt.Errorf("日期计算配置json解析失败失败: %s, Err:%s", config, err.Error())
 				return
 			}
+			hasPercent := false
+			if styleConf.Nt == "percent" {
+				hasPercent = true
+			}
 			if styleConf.Pn != 0 || styleConf.Nt != "" {
-				val = changePointDecimalPlaces(val, styleConf.Pn, styleConf.Nt, isPercent)
-				cell.ShowFormatValue = val
+				// val = changePointDecimalPlaces(val, styleConf.Pn, styleConf.Nt, hasPercent)
+				// cell.ShowFormatValue = val
+				// 修复历史数据,没有保存小数位数,重置小数位数
+				if styleConf.Pn != 0 {
+					if styleConf.Decimal == nil {
+						styleConf.Decimal = new(int)
+					}
+					*styleConf.Decimal += styleConf.Pn
+					if *styleConf.Decimal < 0 {
+						*styleConf.Decimal = 0
+					}
+					cell.ShowFormatValue = utils.RoundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
+					styleConf.Pn = 0
+				} else if styleConf.Decimal != nil {
+					cell.ShowFormatValue = utils.RoundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
+				} else {
+					if hasPercent {
+						numDecimal, _ := decimal.NewFromString(cell.ShowValue)
+						tmpStr := numDecimal.Mul(decimal.NewFromInt(100)).String()
+						cell.ShowFormatValue = tmpStr + "%"
+					} else {
+						cell.ShowFormatValue = cell.ShowValue
+					}
+				}
+			} else if styleConf.Decimal != nil {
+				cell.ShowFormatValue = utils.RoundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
 			} else {
 				cell.ShowFormatValue = cell.ShowValue
 			}
 			// 前端传过来的json中有可能有glObj,需要去掉
-			if styleConf.GlObj != nil {
-				styleConf.GlObj = nil
-				tmpStyleConf, err := json.Marshal(styleConf)
-				if err == nil {
-					cell.ShowStyle = string(tmpStyleConf)
-				}
+			styleConf.GlObj = nil
+			tmpStyleConf, err := json.Marshal(styleConf)
+			if err == nil {
+				cell.ShowStyle = string(tmpStyleConf)
 			}
 			config[cellPosition.Column][cellPosition.Row] = cell
 		}
@@ -1236,6 +1271,19 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 	return
 }
 
+func getDecimalLen(str string, isPercent bool) (decimalPlaces int) {
+	dotIndex := strings.Index(str, ".") // 查找小数点的位置
+	if dotIndex == -1 {
+		decimalPlaces = 0
+	} else {
+		decimalPlaces = len(str) - dotIndex - 1
+	}
+	if isPercent && decimalPlaces >= 1 {
+		decimalPlaces -= 1
+	}
+	return
+}
+
 // changePointDecimalPlaces 小数点位数加减和百分比格式
 func changePointDecimalPlaces(str string, changeNum int, numberType string, isPercent bool) (newStr string) {
 	newStr = str

+ 14 - 0
services/data/range_analysis/chart_info.go

@@ -424,6 +424,13 @@ func GetChartDataByEdbInfoList(chartInfoId int, dateType, startYear int, startDa
 			edbInfoMapping.ConvertUnit = req.DataConvertConf.Unit
 			edbInfoMapping.ConvertEnUnit = req.DataConvertConf.Unit
 		}
+		if edbInfoMapping.ConvertUnit == "无" {
+			edbInfoMapping.ConvertUnit = ""
+		}
+		if edbInfoMapping.ConvertEnUnit == "无" {
+			edbInfoMapping.ConvertEnUnit = ""
+		}
+
 		dataList := edbInfoMapping.DataList.([]*data_manage.EdbDataList)
 		// 处理上下限
 		var maxData, minData float64
@@ -570,6 +577,12 @@ func GetChartDataByEdbInfoListBySeries(chartInfoId int, dateType, startYear int,
 			edbInfoMapping.ConvertUnit = req.DataConvertConf.Unit
 			edbInfoMapping.ConvertEnUnit = req.DataConvertConf.Unit
 		}
+		if edbInfoMapping.ConvertUnit == "无" {
+			edbInfoMapping.ConvertUnit = ""
+		}
+		if edbInfoMapping.ConvertEnUnit == "无" {
+			edbInfoMapping.ConvertEnUnit = ""
+		}
 		edbInfoMapping.DataList = dataList
 		// 处理上下限
 		var maxData, minData float64
@@ -824,6 +837,7 @@ func getChartDataByEdbInfo(edbInfoMapping *data_manage.ChartEdbInfoMapping, req
 					dealDataList = append(dealDataList, v)
 				}
 			}
+			newDataList = dealDataList
 		case 2:
 			for i, v := range newDataList {
 				if utils.CompareFloatByOpStrings(req.UnNormalDataConf.Formula, v.Value, req.UnNormalDataConf.Value) {

+ 4 - 4
services/document_manage_service/document_manage_service.go

@@ -174,9 +174,9 @@ func DocumentReportList(documentType int, chartPermissionIdList []string, classi
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` group by t1.outside_report_id order by t1.` + orderField + ` ` + orderType
+		condition += ` order by t1.` + orderField + ` ` + orderType
 	} else {
-		condition += ` group by t1.outside_report_id order by t1.report_update_time desc`
+		condition += ` order by t1.report_update_time desc`
 	}
 
 	outsideReportList, err := document_manage_model.GetOutsideReportListByCondition(condition, pars, startSize, pageSize)
@@ -276,9 +276,9 @@ func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, cha
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` group by a.id order by a.` + orderField + ` ` + orderType
+		condition += ` order by a.` + orderField + ` ` + orderType
 	} else {
-		condition += ` group by a.id order by a.publish_time desc`
+		condition += ` order by a.publish_time desc`
 	}
 
 	reportList, err := models.GetReportListByCondition(condition, pars, startSize, pageSize)

+ 65 - 27
services/excel/lucky_sheet.go

@@ -6,13 +6,13 @@ import (
 	"eta/eta_api/models/data_manage/excel/request"
 	"eta/eta_api/utils"
 	"fmt"
-	"math"
 	"os"
 	"reflect"
 	"strconv"
 	"strings"
 	"time"
 
+	"github.com/shopspring/decimal"
 	"github.com/tealeg/xlsx"
 	"github.com/xuri/excelize/v2"
 )
@@ -1757,40 +1757,78 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 						tmp.FontColor = styleConfig.Color
 					}
 					tmp.Monitor = showFormatValue
-					tmpShowValue, err := strconv.ParseFloat(cell.Value, 64)
+					// 如果没有showValue, 则使用value
+					if cell.ShowValue == "" {
+						_, err := strconv.ParseFloat(cell.Value, 64)
+						if err == nil {
+							cell.ShowValue = cell.Value
+						}
+					}
+					_, err := strconv.ParseFloat(cell.Value, 64)
 					if err == nil {
-						switch styleConfig.Last {
-						case "nt":
-							// 先进行数字的百分比计算,然后保留小数点位数
-							percent := tmpShowValue * 100
+						hasPercent := false
+						if styleConfig.Nt == "percent" {
+							hasPercent = true
+						}
+						// 修复历史数据
+						if styleConfig.Pn != 0 {
 							if styleConfig.Decimal == nil {
-								continue
+								styleConfig.Decimal = new(int)
 							}
-							factor := math.Pow(10, float64(*styleConfig.Decimal))
-							rounded := math.Round(percent*factor) / factor
-							tmp.Monitor = fmt.Sprintf("%g%%", rounded)
-						case "decimal":
-							// 先保留小数点位数,再进行百分比计算
-							if styleConfig.Decimal == nil {
-								continue
+							*styleConfig.Decimal += styleConfig.Pn
+							if *styleConfig.Decimal < 0 {
+								*styleConfig.Decimal = 0
 							}
-							factor := math.Pow(10, float64(*styleConfig.Decimal))
-							rounded := math.Round(tmpShowValue*factor) / factor
-							if styleConfig.Nt == "percent" {
-								percent := rounded * 100
-								var precisionStr string
-								if *styleConfig.Decimal > 2 {
-									precision := *styleConfig.Decimal - 2
-									precisionStr = strconv.FormatFloat(rounded, 'f', precision, 64)
-								} else {
-									precisionStr = strconv.FormatFloat(math.Round(percent), 'f', -1, 64)
-								}
-								tmp.Monitor = fmt.Sprintf("%s%%", precisionStr)
+						}
+
+						if styleConfig.Decimal != nil {
+							tmp.Monitor = utils.RoundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
+						} else {
+							if hasPercent {
+								numDecimal, _ := decimal.NewFromString(cell.ShowValue)
+								tmpStr := numDecimal.Mul(decimal.NewFromInt(100)).String()
+								tmp.Monitor = tmpStr + "%"
 							} else {
-								tmp.Monitor = fmt.Sprintf("%g", rounded)
+								tmp.Monitor = cell.ShowValue
 							}
 						}
+					} else {
+						if cell.DataType == request.CustomTextDT {
+							tmp.Monitor = cell.Value
+						}
 					}
+					// 	switch styleConfig.Last {
+					// 	case "nt":
+					// 		// 先进行数字的百分比计算,然后保留小数点位数
+					// 		percent := tmpShowValue * 100
+					// 		if styleConfig.Decimal == nil {
+					// 			continue
+					// 		}
+					// 		factor := math.Pow(10, float64(*styleConfig.Decimal))
+					// 		rounded := math.Round(percent*factor) / factor
+					// 		tmp.Monitor = fmt.Sprintf("%g%%", rounded)
+					// 	case "decimal":
+					// 		// 先保留小数点位数,再进行百分比计算
+					// 		if styleConfig.Decimal == nil {
+					// 			continue
+					// 		}
+					// 		factor := math.Pow(10, float64(*styleConfig.Decimal))
+					// 		rounded := math.Round(tmpShowValue*factor) / factor
+					// 		if styleConfig.Nt == "percent" {
+					// 			percent := rounded * 100
+					// 			var precisionStr string
+					// 			if *styleConfig.Decimal > 2 {
+					// 				precision := *styleConfig.Decimal - 2
+					// 				precisionStr = strconv.FormatFloat(rounded, 'f', precision, 64)
+					// 			} else {
+					// 				precisionStr = strconv.FormatFloat(math.Round(percent), 'f', -1, 64)
+					// 			}
+					// 			tmp.Monitor = fmt.Sprintf("%s%%", precisionStr)
+					// 		} else {
+					// 			tmp.Monitor = fmt.Sprintf("%g", rounded)
+					// 		}
+					// 	}
+					// }
 
 				}
 				dataCol = append(dataCol, tmp)

+ 1 - 1
services/ppt.go

@@ -144,7 +144,7 @@ func SavePPTReport(pptId, classifyId int, title string, adminInfo *system.Admin)
 		ClassifyNameThird:  classifyNameThird,
 		Title:              title,
 		Abstract:           "",
-		Author:             "FICC团队",
+		Author:             "",
 		Frequency:          utils.ReportFrequencyDefault,
 		State:              1,
 		Content:            htm,

+ 12 - 0
services/report_v2.go

@@ -4,6 +4,7 @@ import (
 	"archive/zip"
 	"errors"
 	"eta/eta_api/models"
+	"eta/eta_api/models/company"
 	"eta/eta_api/models/report"
 	"eta/eta_api/models/report_approve"
 	"eta/eta_api/models/system"
@@ -1412,6 +1413,17 @@ func UpdateReportVideo(reportInfo *models.Report) {
 			if reportInfo.VideoUrl != "" && reportInfo.VideoName != "" && reportInfo.VideoSize != "" && reportInfo.VideoPlaySeconds != "" {
 				return
 			}
+
+			weekClassifyId, err := company.GetReportClassifyIdByConfigKey("report_week_classify_id")
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				msg := "获取周报ID配置失败:" + err.Error()
+				utils.FileLog.Info(msg)
+				return
+			}
+
+			if reportInfo.ClassifyIdFirst == weekClassifyId {
+				return
+			}
 			videoUrl, videoName, videoSize, videoPlaySeconds, e := CreateReportVideo(reportInfo.Title, html.UnescapeString(reportContent), time.Now().Format(utils.FormatDateTime))
 			if e != nil {
 				err = e

+ 1 - 1
services/smart_report.go

@@ -160,7 +160,7 @@ async def main():
     })
 
     # 在生成PDF之前等待2秒
-    await asyncio.sleep(10)
+    await asyncio.sleep(15)
 
     await page.pdf({
         'path': "%s",

+ 13 - 0
utils/common.go

@@ -2752,3 +2752,16 @@ func GenerateEdbCode(num int, pre string) (edbCode string, err error) {
 func GetCurrentTime() string {
 	return time.Now().Format("2006-01-02 15:04:05")
 }
+
+// RoundNumber 保留小数位数
+func RoundNumber(num string, decimalPlaces int, hasPercent bool) string {
+	numDecimal, _ := decimal.NewFromString(num)
+	if hasPercent {
+		numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
+	}
+	numStr := numDecimal.Round(int32(decimalPlaces)).StringFixed(int32(decimalPlaces))
+	if hasPercent {
+		numStr += "%"
+	}
+	return numStr
+}