浏览代码

Merge branch 'feature/eta1.8.5_excel_balance' into debug

xyxie 10 月之前
父节点
当前提交
344310ac73

+ 8 - 8
controllers/data_manage/excel/balance_table.go

@@ -463,10 +463,10 @@ func (c *ExcelInfoController) BalanceChartInfoAdd() {
 				DateSequence:    mapping.DateSequenceStr,
 				DataSequence:    mapping.DataSequenceStr,
 			}
-			err, errMsg = excelService.GetBalanceExcelEdbData(tmpMapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
-			if err != nil {
-				err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
-				return
+			er, msg := excelService.GetBalanceExcelEdbData(tmpMapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
+			if er != nil {
+				utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
+				continue
 			}
 		}
 	}
@@ -638,10 +638,10 @@ func (c *ExcelInfoController) BalanceChartInfoEdit() {
 				DateSequence:    mapping.DateSequenceStr,
 				DataSequence:    mapping.DataSequenceStr,
 			}
-			err, errMsg = excelService.GetBalanceExcelEdbData(tmpMapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
-			if err != nil {
-				err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
-				return
+			er, msg := excelService.GetBalanceExcelEdbData(tmpMapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
+			if er != nil {
+				utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
+				continue
 			}
 		}
 	}

+ 10 - 0
models/data_manage/excel/excel_chart_edb.go

@@ -166,6 +166,16 @@ func (e *ExcelChartEdb) AddChartEdbAndData(list []*AddChartEdbAndDataItem, chart
 		sql = `update chart_info set edb_info_ids = ? where chart_info_id = ?`
 		_, err = o.Raw(sql, edbInfoIdStr, chartInfoId).Exec()
 	}
+
+	if len(updateIds) > 0 {
+		//更新图表数据
+		sql = `update excel_chart_data set chart_info_id = ? where excel_chart_edb_id in (` + utils.GetOrmInReplace(len(updateIds)) + `) and chart_info_id=0`
+		_, err = o.Raw(sql, chartInfoId, updateIds).Exec()
+		if err != nil {
+			err = fmt.Errorf("更新图表id失败,AddChartEdbAndData: %v", err)
+			return
+		}
+	}
 	return
 }
 

+ 3 - 3
services/data/chart_info_excel_balance.go

@@ -397,7 +397,7 @@ func EditBalanceExcelChart(excelInfo *excelModel.ExcelInfo, req request.AddBalan
 	}
 	chartInfo, err, errMsg, isSendEmail = editBalanceExcelChart(req)
 	if err != nil {
-		errMsg = "新增图表失败!"
+		//errMsg = "新增图表失败!"
 		err = fmt.Errorf("新增图表失败!%s, %s", errMsg, err.Error())
 		return
 	}
@@ -1237,7 +1237,7 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, excelClassifyId i
 	// 表格信息
 	timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
 	excelName := oldExcelInfo.ExcelName
-	if pingNameFlag && versionName != "" {
+	if pingNameFlag && versionName != "" && parentId == 0 {
 		excelName += "(" + versionName + ")"
 	}
 
@@ -1290,7 +1290,7 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, excelClassifyId i
 	}
 	if parentId == 0 && len(childExcelList) > 0 {
 		for _, childExcelInfo := range childExcelList {
-			_, err, errMsg, isSendEmail = AddBalanceStaticExcel(childExcelInfo, excelClassifyId, versionName, sysUser, excelInfo.ExcelInfoId, relExcelInfoId, balanceType, []*excelModel.ExcelInfo{}, false, excelDataMap)
+			_, err, errMsg, isSendEmail = AddBalanceStaticExcel(childExcelInfo, excelClassifyId, versionName, sysUser, excelInfo.ExcelInfoId, relExcelInfoId, balanceType, []*excelModel.ExcelInfo{}, pingNameFlag, excelDataMap)
 			if err != nil {
 				return
 			}

+ 12 - 6
services/data/excel/balance_table.go

@@ -318,17 +318,23 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 	}
 	newDataMap := make(map[int]float64, len(newDataList))
 	for i, v := range newDataList {
-		val, e := strconv.ParseFloat(v, 64)
-		if e != nil {
-			err = fmt.Errorf(" 处理日期和数据系列失败 %s", e.Error())
-			return
+		if v != "" {
+			val, e := strconv.ParseFloat(v, 64)
+			if e != nil {
+				err = fmt.Errorf(" 处理日期和数据系列失败 %s", e.Error())
+				return
+			}
+			newDataMap[i] = val
 		}
-		newDataMap[i] = val
 	}
 	//组装成excelEdbData
 	list := make([]*data_manage.EdbDataList, 0)
 
 	for i, v := range newDateList {
+		val, ok := newDataMap[i]
+		if !ok {
+			continue
+		}
 		// todo 处理DataTimestamp
 		dataTime, e := time.ParseInLocation(utils.FormatDate, v, time.Local)
 		if e != nil {
@@ -341,7 +347,7 @@ func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMi
 			EdbInfoId:     excelEdbMappingItem.ExcelChartEdbId,
 			DataTime:      v,
 			DataTimestamp: timestamp,
-			Value:         newDataMap[i],
+			Value:         val,
 		}
 		list = append(list, tmp)
 	}