浏览代码

Merge branch 'hotfix/custom_balance_table' of eta_server/eta_api into master

xyxie 9 月之前
父节点
当前提交
0f3fbf1612
共有 2 个文件被更改,包括 27 次插入21 次删除
  1. 6 5
      controllers/data_manage/excel/balance_table.go
  2. 21 16
      services/data/excel/balance_table.go

+ 6 - 5
controllers/data_manage/excel/balance_table.go

@@ -1103,7 +1103,8 @@ func (c *ExcelInfoController) AddStaticExcel() {
 		}
 		tmpMappingList, e := excel.GetExcelChartEdbMappingByExcelInfoId(childExcelInfo.ExcelInfoId)
 		if e != nil {
-			err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
+			br.Msg = "获取图表,指标信息失败"
+			br.ErrMsg = fmt.Sprintf(" 获取图表,指标信息失败 Err:%s", err.Error())
 			return
 		}
 		if len(tmpMappingList) > 0 {
@@ -1112,10 +1113,10 @@ func (c *ExcelInfoController) AddStaticExcel() {
 				if !ok {
 					child = make(map[int][]*data_manage.EdbDataList)
 				}
-				err, errMsg = excelService.GetBalanceExcelEdbData(mapping, newExcelDataMap, child, excelAllRows, excelAllCols)
-				if err != nil {
-					err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
-					return
+				er, msg := excelService.GetBalanceExcelEdbData(mapping, newExcelDataMap, child, excelAllRows, excelAllCols)
+				if er != nil {
+					utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
+					continue
 				}
 				excelDataMap[mapping.ChartInfoId] = child
 			}

+ 21 - 16
services/data/excel/balance_table.go

@@ -162,8 +162,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 			}
 
 			// 长度固定,避免一直申请内存空间
-			dateList = make([]string, endColumn-startColumn+1)
-
+			//dateList = make([]string, endColumn-startColumn+1)
+			dateList = make([]string, 0)
 			i := 0
 			for currColumn := startColumn; currColumn <= endColumn; currColumn++ {
 				currCell, ok := newMixedTableCellDataListMap[startNum][currColumn]
@@ -172,7 +172,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 					err = errors.New(errMsg)
 					return
 				}
-				dateList[i] = currCell.ShowValue
+				dateList = append(dateList, currCell.ShowValue)
+				//dateList[i] = currCell.ShowValue
 				i++
 			}
 
@@ -196,7 +197,9 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 				endNum = maxRow - 1
 			}
 			// 长度固定,避免一直申请内存空间
-			dateList = make([]string, endNum-startNum+1)
+			//dateList = make([]string, endNum-startNum+1)
+			fmt.Println("startNum:", startNum, "endNum:", endNum)
+			dateList = make([]string, 0)
 			i := 0
 			for currRow := startNum; currRow <= endNum; currRow++ {
 				currCell, ok := newMixedTableCellDataListMap[currRow][startColumn]
@@ -205,8 +208,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 					err = errors.New(errMsg)
 					return
 				}
-				//dateList = append(dateList, currCell.Value)
-				dateList[i] = currCell.ShowValue
+				dateList = append(dateList, currCell.Value)
+				//dateList[i] = currCell.ShowValue
 				i++
 			}
 		}
@@ -255,7 +258,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 				endColumn = maxCol - 1
 			}
 			// 长度固定,避免一直申请内存空间
-			dataList = make([]string, endColumn-startColumn+1)
+			//dataList = make([]string, endColumn-startColumn+1)
+			dataList = make([]string, 0)
 			i := 0
 			for currColumn := startColumn; currColumn <= endColumn; currColumn++ {
 				currCell, ok := newMixedTableCellDataListMap[startNum][currColumn]
@@ -264,8 +268,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 					err = errors.New(errMsg)
 					return
 				}
-				//dataList = append(dataList, currCell.Value)
-				dataList[i] = currCell.ShowValue
+				dataList = append(dataList, currCell.Value)
+				//dataList[i] = currCell.ShowValue
 				i++
 			}
 
@@ -290,7 +294,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 			}
 
 			// 长度固定,避免一直申请内存空间
-			dataList = make([]string, endNum-startNum+1)
+			//dataList = make([]string, endNum-startNum+1)
+			dataList = make([]string, 0)
 			i := 0
 			for currRow := startNum; currRow <= endNum; currRow++ {
 				currCell, ok := newMixedTableCellDataListMap[currRow][startColumn]
@@ -299,8 +304,8 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 					err = errors.New(errMsg)
 					return
 				}
-				//dataList = append(dataList, currCell.Value)
-				dataList[i] = currCell.ShowValue
+				dataList = append(dataList, currCell.Value)
+				//dataList[i] = currCell.ShowValue
 				i++
 			}
 		}
@@ -534,10 +539,10 @@ func SyncBalanceEdbData(excelInfo *excelModel.ExcelInfo, balanceTableData [][]re
 
 	for _, mapping := range tmpMappingList {
 		excelEdbMap[mapping.ExcelChartEdbId] = mapping
-		err, _ = GetBalanceExcelEdbData(mapping, newExcelDataMap, excelDataMap, excelAllRows, excelAllCols)
-		if err != nil {
-			err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
-			return
+		er, msg := GetBalanceExcelEdbData(mapping, newExcelDataMap, excelDataMap, excelAllRows, excelAllCols)
+		if er != nil {
+			utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
+			continue
 		}
 	}
 	// 批量更新图表数据