瀏覽代碼

调整混合表格

xyxie 1 年之前
父節點
當前提交
069add31b0
共有 2 個文件被更改,包括 14 次插入46 次删除
  1. 4 10
      models/data_manage/excel/request/mixed_table.go
  2. 10 36
      services/data/excel/mixed_table.go

+ 4 - 10
models/data_manage/excel/request/mixed_table.go

@@ -90,18 +90,12 @@ type EdbDateChangeConf struct {
 }
 
 type EdbDateConfDateChange struct {
-	DateCalculate   *EdbDateConfDateCalculate
-	FrequencyChange *EdbDateConfFrequencyChange
-}
-type EdbDateConfDateCalculate struct {
-	Year  int
-	Month int
-	Day   int
-}
-
-type EdbDateConfFrequencyChange struct {
+	Year         int
+	Month        int
+	Day          int
 	Frequency    string `description:"频度变换"`
 	FrequencyDay string `description:"频度的固定日期"`
+	ChangeType   int    `description:"日期变换类型1日期位移,2指定频率"`
 }
 
 // MixedDateCalculateReq 混合表格日期计算

+ 10 - 36
services/data/excel/mixed_table.go

@@ -152,7 +152,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 	calculateCellMap := make(map[string]Cell)
 	calculateChainList := make([]string, 0)
 	dateCalculateList := make([]string, 0)
-	showStyleList := make([]string, 0)
 	// 处理单元格中的数据类型(除去基础计算,因为这个是依赖于其他)
 	for k, row := range config {
 		for i, cell := range row {
@@ -167,7 +166,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 			case request.EdbDT: // 指标类型
 				if edbInfo, ok := edbInfoMap[cell.EdbInfoId]; ok {
 					cell.ShowValue = edbInfo.EdbName
-					cell.RealValue = cell.ShowValue
 				}
 			case request.InsertDataDT, request.PopInsertDataDT: // 数据类型
 				// 数值先清空
@@ -208,7 +206,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 						//cell.ShowValue = fmt.Sprint(val)
 						cellKeyVal[cell.Uid] = val
 						cell.ShowValue = utils.FormatTableDataShowValue(val)
-						cell.RealValue = cell.ShowValue
 					}
 				} else {
 					// 如果不是取得一个关联的日期,那么就是指定日期
@@ -240,7 +237,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 								}
 								cellKeyVal[cell.Uid] = finalVal
 								cell.ShowValue = utils.FormatTableDataShowValue(dateValList[tmpLenData-1].Value)
-								cell.RealValue = cell.ShowValue
 							}
 						}
 					} else {
@@ -262,7 +258,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 							//cell.ShowValue = fmt.Sprint(val)
 							cellKeyVal[cell.Uid] = val
 							cell.ShowValue = utils.FormatTableDataShowValue(val)
-							cell.RealValue = cell.ShowValue
 						}
 					}
 				}
@@ -391,7 +386,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 				val := tmpDataMap[cellDateTime]
 				cellKeyVal[cell.Uid] = val
 				cell.ShowValue = utils.FormatTableDataShowValue(val)
-				cell.RealValue = cell.ShowValue
 			case request.DateCalculateDataDT: //日期计算
 				// 把关联的单元格存在数组里
 				calculateCellMap[cell.Uid] = Cell{
@@ -403,14 +397,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 				// 遍历数组,根据公式进行计算,并将得到的结果放到对应的单元格中
 			}
 
-			if cell.ShowValue != `` {
-				calculateCellMap[cell.Uid] = Cell{
-					Column:   k,
-					Row:      i,
-					CellInfo: cell,
-				}
-				showStyleList = append(showStyleList, cell.Uid)
-			}
 			row[i] = cell
 		}
 		config[k] = row
@@ -443,7 +429,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 
 			cellKeyVal[cell.Uid] = val
 			cell.ShowValue = utils.FormatTableDataShowValue(val)
-			cell.RealValue = cell.ShowValue
 			config[cellPosition.Column][cellPosition.Row] = cell
 
 		}
@@ -455,12 +440,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 		return
 	}
 
-	// todo 样式调整
-	config, err, errMsg = handleMixCellShowStyle(showStyleList, calculateCellMap, config)
-	if err != nil {
-		return
-	}
-
 	newMixedTableCellDataList = config
 
 	return
@@ -724,13 +703,11 @@ func HandleMixTableDateChange(date, conf string) (newDate string, err error) {
 			return
 		}
 		for _, v := range edbDateConf.DateChange {
-			if v.DateCalculate != nil {
-				dateTime = dateTime.AddDate(v.DateCalculate.Year, v.DateCalculate.Month, v.DateCalculate.Day)
+			if v.ChangeType == 1 {
+				dateTime = dateTime.AddDate(v.Year, v.Month, v.Day)
 				newDate = dateTime.Format(utils.FormatDate)
-			}
-
-			if v.FrequencyChange != nil {
-				newDate, err, _ = handleSystemAppointDateT(dateTime, v.FrequencyChange.FrequencyDay, v.FrequencyChange.Frequency)
+			} else if v.ChangeType == 2 {
+				newDate, err, _ = handleSystemAppointDateT(dateTime, v.FrequencyDay, v.Frequency)
 				if err != nil {
 					return
 				}
@@ -775,8 +752,7 @@ func handleOldSystemDateT(confStr string) (newConf string, err error, errMsg str
 
 	newConfig := new(request.EdbDateConf)
 	dateChange := new(request.EdbDateConfDateChange)
-	dateCalculate := new(request.EdbDateConfDateCalculate)
-	frequencyChange := new(request.EdbDateConfFrequencyChange)
+
 	dateChangeList := make([]*request.EdbDateConfDateChange, 0)
 
 	switch config.Source {
@@ -784,8 +760,8 @@ func handleOldSystemDateT(confStr string) (newConf string, err error, errMsg str
 		return
 	case request.SystemCalculateDateT:
 		// todo 是否直接更新该excel记录,
-		dateCalculate.Day = config.CalculateNum
-		dateChange.DateCalculate = dateCalculate
+		dateChange.Day = config.CalculateNum
+		dateChange.ChangeType = 1
 		dateChangeList = append(dateChangeList, dateChange)
 		newConfig.DateChange = dateChangeList
 		newConfByte, e := json.Marshal(newConfig)
@@ -796,10 +772,9 @@ func handleOldSystemDateT(confStr string) (newConf string, err error, errMsg str
 		newConf = string(newConfByte)
 		return
 	case request.SystemFrequencyDateT: // 处理系统日期相关的指定频率(所在周/旬/月/季/半年/年的最后/最早一天)
-		frequencyChange.FrequencyDay = config.Day
-		frequencyChange.Frequency = config.Frequency
-
-		dateChange.FrequencyChange = frequencyChange
+		dateChange.FrequencyDay = config.Day
+		dateChange.Frequency = config.Frequency
+		dateChange.ChangeType = 1
 		dateChangeList = append(dateChangeList, dateChange)
 		newConfig.DateChange = dateChangeList
 		newConfByte, e := json.Marshal(newConfig)
@@ -1080,7 +1055,6 @@ func handlerDateCalculate(dateCalculateList []string, calculateCellMap map[strin
 			}
 
 			cell.ShowValue = utils.FormatTableDataShowValue(val)
-			cell.RealValue = cell.ShowValue
 			config[cellPosition.Column][cellPosition.Row] = cell
 		}
 	}