zwxi 8 months ago
parent
commit
f49901be18

+ 64 - 0
controllers/data_manage/excel/excel_info.go

@@ -663,6 +663,70 @@ func (c *ExcelInfoController) Detail() {
 		excelDetail.Editor = markStatus.Editor
 	}
 
+	// 图表的指标来源
+	if excelDetail.Source == utils.TIME_TABLE {
+		jsonStrByte, err := json.Marshal(excelDetail.TableData)
+		if err != nil {
+			br.Msg = "自定义表格数据获取失败"
+			br.ErrMsg = "自定义表格数据获取失败,转json失败,Err:" + err.Error()
+			return
+		}
+		var tableData request.TableDataReq
+		err = json.Unmarshal(jsonStrByte, &tableData)
+		if err != nil {
+			br.Msg = "自定义表格数据获取失败"
+			br.ErrMsg = "自定义表格数据获取失败,json转结构体失败,Err:" + err.Error()
+			return
+		}
+		sourceNameList, sourceNameEnList, err := excel2.GetEdbSourceByEdbInfoIdList(tableData.EdbInfoIdList)
+		if err != nil {
+			br.Msg = "自定义表格数据获取失败"
+			br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
+			return
+		}
+		excelDetail.ExcelSource = strings.Join(sourceNameList, ",")
+		excelDetail.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
+
+	}
+
+	// 数据刷新-混合表格
+	if excelDetail.Source == utils.MIXED_TABLE {
+		// todo 刷新动态表的所有子表中关联的指标数据
+		jsonByte, e := json.Marshal(excelDetail.TableData)
+		if e != nil {
+			br.Msg = "刷新失败"
+			br.ErrMsg = "JSON格式化混合表格数据失败, Err: " + e.Error()
+			return
+		}
+		var tableData request.MixedTableReq
+		if e = json.Unmarshal(jsonByte, &tableData); e != nil {
+			br.Msg = "刷新失败"
+			br.ErrMsg = "解析混合表格数据失败, Err: " + e.Error()
+			return
+		}
+		edbInfoIds := make([]int, 0)
+		edbInfoIdExist := make(map[int]bool)
+		if len(tableData.Data) > 0 {
+			for _, t := range tableData.Data {
+				for _, v := range t {
+					if v.EdbInfoId > 0 && !edbInfoIdExist[v.EdbInfoId] {
+						edbInfoIdExist[v.EdbInfoId] = true
+						edbInfoIds = append(edbInfoIds, v.EdbInfoId)
+					}
+				}
+			}
+		}
+		sourceNameList, sourceNameEnList, err := excel2.GetEdbSourceByEdbInfoIdList(edbInfoIds)
+		if err != nil {
+			br.Msg = "自定义表格数据获取失败"
+			br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
+			return
+		}
+		excelDetail.ExcelSource = strings.Join(sourceNameList, ",")
+		excelDetail.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
+	}
+
+
 	// excel表格按钮权限
 	if excelDetail.Source != utils.BALANCE_TABLE {
 		excelDetail.Button = excel2.GetExcelInfoOpButton(sysUser, excelDetail.SysUserId, excelDetail.Source, excelDetail.HaveOperaAuth)

+ 2 - 0
models/data_manage/excel/response/excel_info.go

@@ -84,6 +84,8 @@ type ExcelInfoDetail struct {
 	UpdateUserRealName string                       `description:"更新人真实姓名"`
 	RelExcelInfoId     int                          `description:"平衡表里静态表关联的动态表excel id"`
 	SourcesFrom        string                       `description:"图表来源"`
+	ExcelSource        string                       `description:"表格来源str"`
+	ExcelSourceEn      string                       `description:"表格来源(英文)"`
 }
 
 type BalanceChildTableResp struct {

+ 53 - 0
services/data/excel/excel_info.go

@@ -3,6 +3,7 @@ package excel
 import (
 	"encoding/json"
 	"errors"
+	"eta/eta_api/models"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/data_manage/excel/request"
@@ -528,3 +529,55 @@ func GetExcelEdbBatchRefreshKey(source string, reportId, chapterId int) string {
 
 	return fmt.Sprint("batch_refresh_excel_edb:", source, ":", reportId, ":", chapterId)
 }
+
+// GetEdbSourceByEdbInfoIdList 获取关联指标的来源
+func GetEdbSourceByEdbInfoIdList(edbInfoIdList []int) (sourceNameList, sourceNameEnList []string,err error) {
+	sourceNameList = make([]string, 0)
+	sourceNameEnList = make([]string, 0)
+	sourceMap := make(map[int]string)
+	edbInfoList, tmpErr := data_manage.GetEdbInfoByIdList(edbInfoIdList)
+	if tmpErr != nil {
+		err = tmpErr
+		return
+	}
+	for _, v := range edbInfoList {
+		// 指标类型:1:基础指标,2:计算指标
+		if v.EdbType == 2 {
+			//sourceMap[0] = "弘则研究"
+			baseEdbInfoArr, _, _ := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
+			for _, baseEdbInfo := range baseEdbInfoArr {
+				if baseEdbInfo.EdbInfoType == 0 { //普通指标才参与,预测指标不参与
+					sourceMap[baseEdbInfo.Source] = baseEdbInfo.SourceName
+				}
+			}
+		} else {
+			sourceMap[v.Source] = v.SourceName
+		}
+	}
+
+	for source, sourceName := range sourceMap {
+		if utils.InArrayByInt([]int{utils.DATA_SOURCE_MANUAL, utils.DATA_SOURCE_MYSTEEL_CHEMICAL}, source) {
+			continue
+		}
+		sourceNameList = append(sourceNameList, sourceName)
+
+		sourceNameEn, ok := utils.DataSourceEnMap[source]
+		if !ok {
+			sourceNameEn = sourceName
+		}
+		sourceNameEnList = append(sourceNameEnList, sourceNameEn)
+	}
+	//sourceNameList = append(sourceNameList, utils.ChartDefaultNameCn)
+	//sourceNameEnList = append(sourceNameEnList, utils.ChartDefaultNameEn)
+
+	// 图表来源
+	conf, e := models.GetBusinessConf()
+	if e != nil {
+		return
+	}
+	if conf[models.BusinessConfCompanyName] != "" {
+		sourceNameList = append(sourceNameList, conf[models.BusinessConfCompanyName])
+		sourceNameEnList = append(sourceNameEnList, conf[models.BusinessConfCompanyName])
+	}
+	return
+}