Browse Source

Merge branch 'feature/eta1.5.6_excel' into debug

# Conflicts:
#	services/data/excel/mixed_table.go
xyxie 1 year ago
parent
commit
76dc2f5a95

+ 39 - 2
controllers/data_manage/excel/excel_classify.go

@@ -136,14 +136,51 @@ func (this *ExcelClassifyController) ExcelClassifyItems() {
 	if source <= 0 {
 		source = utils.EXCEL_DEFAULT
 	}
-	rootList, err := excel.GetExcelClassifyByParentId(0, source)
+	classifyList, err := excel.GetExcelClassifyBySource(source)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+
+	// 获取二级分类
+	// 获取三级分类
+	classifyMap := make(map[int][]*excel.ExcelClassifyItems)
+	for _, v := range classifyList {
+		if v.ParentId > 0 {
+			classifyMap[v.ParentId] = append(classifyMap[v.ParentId], v)
+		}
+	}
+	// todo 整理第三层
+	//组装三级分类
+	for key, classify := range classifyList {
+		subList, ok := classifyMap[classify.ExcelClassifyId]
+		if ok && classify.Level == 3 {
+			classifyList[key].Children = append(classifyList[key].Children, subList...)
+		}
+	}
+	// todo 整理第二层
+	for key, classify := range classifyList {
+		subList, ok := classifyMap[classify.ExcelClassifyId]
+		if ok && classify.Level == 2 {
+			classifyList[key].Children = append(classifyList[key].Children, subList...)
+		}
+	}
+	// todo 整理第一层
+	for key, classify := range classifyList {
+		subList, ok := classifyMap[classify.ExcelClassifyId]
+		if ok && classify.Level == 1 {
+			classifyList[key].Children = append(classifyList[key].Children, subList...)
+		}
+	}
+	nodeAll := make([]*excel.ExcelClassifyItems, 0)
+	for _, v := range classifyList {
+		if v.ParentId == 0 {
+			nodeAll = append(nodeAll, v)
+		}
+	}
 	resp := response2.ExcelClassifyListResp{
-		AllNodes: rootList,
+		AllNodes: nodeAll,
 	}
 	br.Ret = 200
 	br.Success = true

+ 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 - 37
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 {
@@ -168,11 +167,9 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 				if cell.Value == `` {
 					if edbInfo, ok := edbInfoMap[cell.EdbInfoId]; ok {
 						cell.ShowValue = edbInfo.EdbName
-						cell.RealValue = cell.ShowValue
 					}
 				} else {
 					cell.ShowValue = cell.Value
-					cell.RealValue = cell.ShowValue
 				}
 			case request.InsertDataDT, request.PopInsertDataDT: // 数据类型
 				// 数值先清空
@@ -213,7 +210,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 {
 					// 如果不是取得一个关联的日期,那么就是指定日期
@@ -245,7 +241,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 								}
 								cellKeyVal[cell.Uid] = finalVal
 								cell.ShowValue = utils.FormatTableDataShowValue(dateValList[tmpLenData-1].Value)
-								cell.RealValue = cell.ShowValue
 							}
 						}
 					} else {
@@ -267,7 +262,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
 						}
 					}
 				}
@@ -396,7 +390,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{
@@ -408,14 +401,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
@@ -448,7 +433,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
 
 		}
@@ -460,12 +444,6 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 		return
 	}
 
-	// todo 样式调整
-	config, err, errMsg = handleMixCellShowStyle(showStyleList, calculateCellMap, config)
-	if err != nil {
-		return
-	}
-
 	newMixedTableCellDataList = config
 
 	return
@@ -729,13 +707,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
 				}
@@ -780,8 +756,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 {
@@ -789,8 +764,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)
@@ -801,10 +776,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)
@@ -1085,7 +1059,6 @@ func handlerDateCalculate(dateCalculateList []string, calculateCellMap map[strin
 			}
 
 			cell.ShowValue = utils.FormatTableDataShowValue(val)
-			cell.RealValue = cell.ShowValue
 			config[cellPosition.Column][cellPosition.Row] = cell
 		}
 	}