zwxi 8 months ago
parent
commit
8c6f860f38

+ 108 - 6
controllers/data_manage/excel/excel_info.go

@@ -1270,6 +1270,7 @@ func (c *ExcelInfoController) GetExcelTableData() {
 	}
 
 	var tableData excel.TableData
+	var excelSource, excelSourceEn string
 	switch excelInfo.Source {
 	case utils.EXCEL_DEFAULT:
 		luckySheetData, err := excel.GetLuckySheetData(excelInfo.Content)
@@ -1304,6 +1305,14 @@ func (c *ExcelInfoController) GetExcelTableData() {
 			br.ErrMsg = "转换成table失败,Err:" + err.Error()
 			return
 		}
+		sourceNameList, sourceNameEnList, err := excel2.GetEdbSourceByEdbInfoIdList(result.EdbInfoIdList)
+		if err != nil {
+			br.Msg = "自定义表格数据获取失败"
+			br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
+			return
+		}
+		excelSource = strings.Join(sourceNameList, ",")
+		excelSourceEn = strings.Join(sourceNameEnList, ",")
 	case utils.MIXED_TABLE:
 		var result request.MixedTableReq
 		err = json.Unmarshal([]byte(excelInfo.Content), &result)
@@ -1327,6 +1336,26 @@ func (c *ExcelInfoController) GetExcelTableData() {
 			br.ErrMsg = "转换成table失败,Err:" + err.Error()
 			return
 		}
+		edbInfoIds := make([]int, 0)
+		edbInfoIdExist := make(map[int]bool)
+		if len(newResult) > 0 {
+			for _, t := range newResult {
+				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
+		}
+		excelSource = strings.Join(sourceNameList, ",")
+		excelSourceEn = strings.Join(sourceNameEnList, ",")
 
 	}
 
@@ -1349,12 +1378,14 @@ func (c *ExcelInfoController) GetExcelTableData() {
 	}
 
 	resp := response.ExcelTableDetailResp{
-		UniqueCode:  excelInfo.UniqueCode,
-		ExcelImage:  excelInfo.ExcelImage,
-		ExcelName:   excelInfo.ExcelName,
-		TableInfo:   tableData,
-		Config:      config,
-		SourcesFrom: excelInfo.SourcesFrom,
+		UniqueCode:    excelInfo.UniqueCode,
+		ExcelImage:    excelInfo.ExcelImage,
+		ExcelName:     excelInfo.ExcelName,
+		TableInfo:     tableData,
+		Config:        config,
+		SourcesFrom:   excelInfo.SourcesFrom,
+		ExcelSource:   excelSource,
+		ExcelSourceEn: excelSourceEn,
 	}
 	br.Ret = 200
 	br.Success = true
@@ -1535,12 +1566,23 @@ func (c *ExcelInfoController) GetFirstEdbData() {
 		}
 	}
 
+	sourceNameList, sourceNameEnList, err := excel2.GetEdbSourceByEdbInfoIdList([]int{edbInfoId})
+	if err != nil {
+		br.Msg = "自定义表格数据获取失败"
+		br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
+		return
+	}
+	excelSource := strings.Join(sourceNameList, ",")
+	excelSourceEn := strings.Join(sourceNameEnList, ",")
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = response.TableDataItem{
 		EdbInfoId: edbInfoId,
 		Data:      dataList,
+		ExcelSource: excelSource,
+		ExcelSourceEn: excelSourceEn,
 	}
 }
 
@@ -1603,12 +1645,23 @@ func (c *ExcelInfoController) GetOtherEdbData() {
 		}
 	}
 
+	sourceNameList, sourceNameEnList, err := excel2.GetEdbSourceByEdbInfoIdList([]int{req.EdbInfoId})
+	if err != nil {
+		br.Msg = "自定义表格数据获取失败"
+		br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
+		return
+	}
+	excelSource := strings.Join(sourceNameList, ",")
+	excelSourceEn := strings.Join(sourceNameEnList, ",")
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = response.TableDataItem{
 		EdbInfoId: req.EdbInfoId,
 		Data:      dataList,
+		ExcelSource: excelSource,
+		ExcelSourceEn: excelSourceEn,
 	}
 }
 
@@ -2530,3 +2583,52 @@ func (c *ExcelInfoController) GetBatchChartRefreshResult() {
 	br.Ret = 200
 	br.Success = true
 }
+
+
+// GetBatchChartRefreshResult
+// @Title 获取批量刷新表格结果
+// @Description 获取批量刷新表格结果
+// @Param   EdbInfoId   query   int  true       "edb id"
+// @Success Ret=200 刷新成功
+// @router /excel_info/get_edb_source [get]
+func (c *ExcelInfoController) GetEdbSource() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	edbInfoId, _ := c.GetInt("EdbInfoId")
+	if edbInfoId <= 0  {
+		br.Msg = "请选择指标"
+		br.ErrMsg = "请选择指标"
+		br.IsSendEmail = false
+		return
+	}
+	sourceNameList, sourceNameEnList, err := excel2.GetEdbSourceByEdbInfoIdList([]int{edbInfoId})
+	if err != nil {
+		br.Msg = "自定义表格数据获取失败"
+		br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
+		return
+	}
+	excelSource := strings.Join(sourceNameList, ",")
+	excelSourceEn := strings.Join(sourceNameEnList, ",")
+
+	var resp struct {
+		ExcelSource string `description:"表格来源"`
+		ExcelSourceEn string `description:"表格来源(英文)"`
+	}
+
+	resp.ExcelSource = excelSource
+	resp.ExcelSourceEn = excelSourceEn
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+}

+ 14 - 8
models/data_manage/excel/response/excel_info.go

@@ -22,12 +22,14 @@ type ExcelListResp struct {
 
 // ExcelTableDetailResp  excel表格详情
 type ExcelTableDetailResp struct {
-	UniqueCode  string `description:"表格唯一code"`
-	ExcelImage  string `description:"表格截图"`
-	ExcelName   string `description:"表格名称"`
-	TableInfo   excel.TableData
-	Config      ExcelTableDetailConfigResp
-	SourcesFrom string `description:"图表来源"`
+	UniqueCode    string `description:"表格唯一code"`
+	ExcelImage    string `description:"表格截图"`
+	ExcelName     string `description:"表格名称"`
+	TableInfo     excel.TableData
+	Config        ExcelTableDetailConfigResp
+	SourcesFrom   string `description:"图表来源"`
+	ExcelSource   string `description:"表格来源str"`
+	ExcelSourceEn string `description:"表格来源(英文)"`
 }
 
 // ExcelTableDetailConfigResp
@@ -45,8 +47,10 @@ type TableCellResp struct {
 }
 
 type TableDataItem struct {
-	EdbInfoId int                     `description:"指标id"`
-	Data      []request.ManualDataReq `description:"数据列表"`
+	EdbInfoId     int                     `description:"指标id"`
+	Data          []request.ManualDataReq `description:"数据列表"`
+	ExcelSource   string                  `description:"表格来源str"`
+	ExcelSourceEn string                  `description:"表格来源(英文)"`
 }
 
 // TableDetailResp  excel表格详情
@@ -84,6 +88,8 @@ type ExcelInfoDetail struct {
 	UpdateUserRealName string                       `description:"更新人真实姓名"`
 	RelExcelInfoId     int                          `description:"平衡表里静态表关联的动态表excel id"`
 	SourcesFrom        string                       `description:"图表来源"`
+	ExcelSource        string                       `description:"表格来源str"`
+	ExcelSourceEn      string                       `description:"表格来源(英文)"`
 }
 
 // ExcelInfoDetailButton 操作按钮

+ 9 - 0
routers/commentsRouter.go

@@ -817,6 +817,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_mobile/controllers/data_manage/excel:ExcelInfoController"] = append(beego.GlobalControllerRouter["eta/eta_mobile/controllers/data_manage/excel:ExcelInfoController"],
+        beego.ControllerComments{
+            Method: "GetEdbSource",
+            Router: `/excel_info/get_edb_source`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_mobile/controllers/data_manage/excel:ExcelInfoController"] = append(beego.GlobalControllerRouter["eta/eta_mobile/controllers/data_manage/excel:ExcelInfoController"],
         beego.ControllerComments{
             Method: "GetSystemDate",

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

@@ -3,6 +3,7 @@ package excel
 import (
 	"encoding/json"
 	"errors"
+	"eta/eta_mobile/models"
 	"eta/eta_mobile/models/data_manage"
 	"eta/eta_mobile/models/data_manage/excel"
 	"eta/eta_mobile/models/data_manage/excel/request"
@@ -152,7 +153,13 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 				}
 			}
 		}
-
+		sourceNameList, sourceNameEnList, e := GetEdbSourceByEdbInfoIdList(result.EdbInfoIdList)
+		if e != nil {
+			err = errors.New("自定义表格数据获取失败,Err:" + e.Error())
+			return
+		}
+		excelDetail.ExcelSource = strings.Join(sourceNameList, ",")
+		excelDetail.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
 		excelDetail.TableData = result
 	case utils.MIXED_TABLE: // 混合表格
 		var result request.MixedTableReq
@@ -172,6 +179,26 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 		}
 		result.Data = newData
 		excelDetail.TableData = result
+
+		edbInfoIds := make([]int, 0)
+		edbInfoIdExist := make(map[int]bool)
+		if len(result.Data) > 0 {
+			for _, t := range result.Data {
+				for _, v := range t {
+					if v.EdbInfoId > 0 && !edbInfoIdExist[v.EdbInfoId] {
+						edbInfoIdExist[v.EdbInfoId] = true
+						edbInfoIds = append(edbInfoIds, v.EdbInfoId)
+					}
+				}
+			}
+		}
+		sourceNameList, sourceNameEnList, e := GetEdbSourceByEdbInfoIdList(edbInfoIds)
+		if e != nil {
+			err = errors.New("自定义表格数据获取失败,Err:" + e.Error())
+			return
+		}
+		excelDetail.ExcelSource = strings.Join(sourceNameList, ",")
+		excelDetail.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
 	}
 	if excelDetail.Source == utils.BALANCE_TABLE {
 		excelDetail.Button = GetBalanceExcelInfoOpButton(sysUserId, checkExcelInfo.SysUserId, excelDetail.HaveOperaAuth, checkExcelInfo.ExcelInfoId)
@@ -1428,3 +1455,56 @@ 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
+}