|
@@ -89,16 +89,17 @@ func GenerateExcelCustomAnalysisExcel(excelInfo *excel.ExcelInfo) (downloadFileP
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 数据集
|
|
|
+type dataStruct struct {
|
|
|
+ Value float64
|
|
|
+ Ok bool
|
|
|
+}
|
|
|
+
|
|
|
// HandleEdbSequenceVal 处理日期集和数据集(获取可用的日期、数据集)
|
|
|
func HandleEdbSequenceVal(dateSequenceVal, dataSequenceVal []string) (newDateList []string, newDataList []float64, err error, errMsg string) {
|
|
|
newDateList = make([]string, 0)
|
|
|
newDataList = make([]float64, 0)
|
|
|
|
|
|
- // 数据集
|
|
|
- type dataStruct struct {
|
|
|
- Value float64
|
|
|
- Ok bool
|
|
|
- }
|
|
|
dataList := make([]dataStruct, 0)
|
|
|
{
|
|
|
for _, v := range dataSequenceVal {
|
|
@@ -203,6 +204,13 @@ func HandleEdbSequenceVal(dateSequenceVal, dataSequenceVal []string) (newDateLis
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// ResetCustomAnalysisData 数据重置的结构体
|
|
|
+type ResetCustomAnalysisData struct {
|
|
|
+ EdbInfoId int
|
|
|
+ DateList []string
|
|
|
+ DataList []float64
|
|
|
+}
|
|
|
+
|
|
|
// Refresh 刷新表格关联的指标信息
|
|
|
func Refresh(excelInfo *excel.ExcelInfo) (err error, errMsg string, isSendEmail bool) {
|
|
|
isSendEmail = true
|
|
@@ -244,13 +252,6 @@ func Refresh(excelInfo *excel.ExcelInfo) (err error, errMsg string, isSendEmail
|
|
|
|
|
|
//fmt.Println(xlsxFile)
|
|
|
|
|
|
- // ResetCustomAnalysisData 数据重置的结构体
|
|
|
- type ResetCustomAnalysisData struct {
|
|
|
- EdbInfoId int
|
|
|
- DateList []string
|
|
|
- DataList []float64
|
|
|
- }
|
|
|
-
|
|
|
edbInfoIdList := make([]int, 0)
|
|
|
|
|
|
for _, v := range list {
|
|
@@ -263,6 +264,7 @@ func Refresh(excelInfo *excel.ExcelInfo) (err error, errMsg string, isSendEmail
|
|
|
errMsg = tmpErrMsg
|
|
|
return
|
|
|
}
|
|
|
+ //fmt.Println(v)
|
|
|
req2 := &ResetCustomAnalysisData{
|
|
|
EdbInfoId: v.EdbInfoId,
|
|
|
DateList: relDateList,
|
|
@@ -285,7 +287,6 @@ func Refresh(excelInfo *excel.ExcelInfo) (err error, errMsg string, isSendEmail
|
|
|
err = errors.New(respItem.ErrMsg)
|
|
|
return
|
|
|
}
|
|
|
- //sheetInfo.Cell()
|
|
|
}
|
|
|
|
|
|
if len(edbInfoIdList) > 0 {
|
|
@@ -297,9 +298,18 @@ func Refresh(excelInfo *excel.ExcelInfo) (err error, errMsg string, isSendEmail
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// getDateAndDataList
|
|
|
+// @Description: 获取待刷新的日期和数据
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2023-12-21 15:21:14
|
|
|
+// @param excelEdbMappingItem *excel.ExcelEdbMappingItem
|
|
|
+// @param xlsxFile *xlsx.File
|
|
|
+// @return newDateList []string
|
|
|
+// @return newDataList []float64
|
|
|
+// @return err error
|
|
|
+// @return errMsg string
|
|
|
func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile *xlsx.File) (newDateList []string, newDataList []float64, err error, errMsg string) {
|
|
|
- dateList := make([]string, 0)
|
|
|
- dataList := make([]string, 0)
|
|
|
+ var dateList, dataList []string
|
|
|
|
|
|
// 日期序列
|
|
|
{
|
|
@@ -347,6 +357,16 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
endColumn = tmpEndColumn - 1
|
|
|
}
|
|
|
|
|
|
+ // 最大列数,如果设置的超过了最大列数,那么结束列就是最大列数
|
|
|
+ maxCol := len(sheetInfo.Cols)
|
|
|
+ if endColumn > maxCol {
|
|
|
+ endColumn = maxCol - 1
|
|
|
+ }
|
|
|
+
|
|
|
+ // 长度固定,避免一直申请内存空间
|
|
|
+ dateList = make([]string, endColumn-startColumn+1)
|
|
|
+
|
|
|
+ i := 0
|
|
|
for currColumn := startColumn; currColumn <= endColumn; currColumn++ {
|
|
|
currCell := sheetInfo.Cell(startNum, currColumn)
|
|
|
if currCell == nil {
|
|
@@ -354,7 +374,9 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
- dateList = append(dateList, currCell.Value)
|
|
|
+ //dateList = append(dateList, currCell.Value)
|
|
|
+ dateList[i] = currCell.Value
|
|
|
+ i++
|
|
|
}
|
|
|
|
|
|
} else if isColumn { // 选择列的数据
|
|
@@ -371,6 +393,14 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
}
|
|
|
startColumn = startColumn - 1
|
|
|
|
|
|
+ // 最大行数,如果设置的超过了最大行数,那么结束行就是最大行数
|
|
|
+ maxRow := len(sheetInfo.Rows)
|
|
|
+ if endNum > maxRow {
|
|
|
+ endNum = maxRow - 1
|
|
|
+ }
|
|
|
+ // 长度固定,避免一直申请内存空间
|
|
|
+ dateList = make([]string, endNum-startNum+1)
|
|
|
+ i := 0
|
|
|
for currRow := startNum; currRow <= endNum; currRow++ {
|
|
|
currCell := sheetInfo.Cell(currRow, startColumn)
|
|
|
if currCell == nil {
|
|
@@ -378,7 +408,9 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
- dateList = append(dateList, currCell.Value)
|
|
|
+ //dateList = append(dateList, currCell.Value)
|
|
|
+ dateList[i] = currCell.Value
|
|
|
+ i++
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -428,6 +460,14 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
endColumn = tmpEndColumn - 1
|
|
|
}
|
|
|
|
|
|
+ // 最大列数,如果设置的超过了最大列数,那么结束列就是最大列数
|
|
|
+ maxCol := len(sheetInfo.Cols)
|
|
|
+ if endColumn > maxCol {
|
|
|
+ endColumn = maxCol - 1
|
|
|
+ }
|
|
|
+ // 长度固定,避免一直申请内存空间
|
|
|
+ dataList = make([]string, endColumn-startColumn+1)
|
|
|
+ i := 0
|
|
|
for currColumn := startColumn; currColumn <= endColumn; currColumn++ {
|
|
|
currCell := sheetInfo.Cell(startNum, currColumn)
|
|
|
if currCell == nil {
|
|
@@ -435,7 +475,9 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
- dataList = append(dataList, currCell.Value)
|
|
|
+ //dataList = append(dataList, currCell.Value)
|
|
|
+ dataList[i] = currCell.Value
|
|
|
+ i++
|
|
|
}
|
|
|
|
|
|
} else if isColumn { // 选择列的数据
|
|
@@ -452,6 +494,15 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
}
|
|
|
startColumn = startColumn - 1
|
|
|
|
|
|
+ // 最大行数,如果设置的超过了最大行数,那么结束行就是最大行数
|
|
|
+ maxRow := len(sheetInfo.Rows)
|
|
|
+ if endNum > maxRow {
|
|
|
+ endNum = maxRow - 1
|
|
|
+ }
|
|
|
+
|
|
|
+ // 长度固定,避免一直申请内存空间
|
|
|
+ dataList = make([]string, endNum-startNum+1)
|
|
|
+ i := 0
|
|
|
for currRow := startNum; currRow <= endNum; currRow++ {
|
|
|
currCell := sheetInfo.Cell(currRow, startColumn)
|
|
|
if currCell == nil {
|
|
@@ -459,12 +510,15 @@ func getDateAndDataList(excelEdbMappingItem *excel.ExcelEdbMappingItem, xlsxFile
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
- dataList = append(dataList, currCell.Value)
|
|
|
+ //dataList = append(dataList, currCell.Value)
|
|
|
+ dataList[i] = currCell.Value
|
|
|
+ i++
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //fmt.Println(dateList, dataList)
|
|
|
//fmt.Println("日期序列结束")
|
|
|
|
|
|
// 将excel中的日期、数据系列处理
|