|
@@ -8,7 +8,6 @@ import (
|
|
|
"eta/eta_api/models/data_manage/excel/request"
|
|
|
"eta/eta_api/models/system"
|
|
|
"eta/eta_api/utils"
|
|
|
- "fmt"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
|
@@ -118,11 +117,25 @@ func AddCustomAnalysisTable(excelName, content, excelImage string, excelClassify
|
|
|
isSendEmail = false
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ sheetConf, tmpErr := json.Marshal(sheetInfo.Config)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 计算公式
|
|
|
+ sheetCalcChain, tmpErr := json.Marshal(sheetInfo.CalcChain)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
addSheetItem := excel.AddExcelSheetParams{
|
|
|
ExcelSheetId: 0,
|
|
|
ExcelInfoId: 0,
|
|
|
SheetName: sheetName,
|
|
|
Sort: k,
|
|
|
+ Config: string(sheetConf),
|
|
|
+ CalcChain: string(sheetCalcChain),
|
|
|
}
|
|
|
|
|
|
lenCellData := len(sheetInfo.Celldata)
|
|
@@ -169,6 +182,7 @@ func AddCustomAnalysisTable(excelName, content, excelImage string, excelClassify
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// SaveCustomAnalysisTable 编辑自定义分析表格
|
|
|
func SaveCustomAnalysisTable(excelInfo *data_manage.ExcelInfo, excelName, content, excelImage string, excelClassifyId int, sheetOpList []request.SheetOp) (err error, errMsg string, isSendEmail bool) {
|
|
|
isSendEmail = true
|
|
|
|
|
@@ -190,12 +204,12 @@ func SaveCustomAnalysisTable(excelInfo *data_manage.ExcelInfo, excelName, conten
|
|
|
}
|
|
|
|
|
|
// sheet内容为空
|
|
|
- if len(sheetOpList) <= 0 {
|
|
|
- errMsg = "sheet操作为空"
|
|
|
- err = errors.New(errMsg)
|
|
|
- isSendEmail = false
|
|
|
- return
|
|
|
- }
|
|
|
+ //if len(sheetOpList) <= 0 {
|
|
|
+ // errMsg = "sheet操作为空"
|
|
|
+ // err = errors.New(errMsg)
|
|
|
+ // isSendEmail = false
|
|
|
+ // return
|
|
|
+ //}
|
|
|
|
|
|
excelClassify, err := data_manage.GetExcelClassifyById(excelClassifyId)
|
|
|
if err != nil {
|
|
@@ -248,46 +262,48 @@ func SaveCustomAnalysisTable(excelInfo *data_manage.ExcelInfo, excelName, conten
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 查找当前excel的sheet列表
|
|
|
- currSheetList, err := excel.GetAllSheetList(excelInfo.ExcelInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "保存失败"
|
|
|
- err = errors.New("查找当前excel的sheet列表失败,Err:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- currSheetMap := make(map[string]string)
|
|
|
- for _, currSheet := range currSheetList {
|
|
|
- currSheetMap[currSheet.SheetName] = currSheet.SheetName
|
|
|
- }
|
|
|
-
|
|
|
- for k, sheetOp := range sheetOpList {
|
|
|
- sheetName := utils.TrimLRStr(sheetOp.SheetName)
|
|
|
- switch sheetOp.OpType {
|
|
|
- case "add":
|
|
|
- // 新增
|
|
|
- _, ok := currSheetMap[sheetName]
|
|
|
- if ok {
|
|
|
- errMsg = "存在同名sheet:" + sheetName
|
|
|
- err = errors.New(errMsg)
|
|
|
- isSendEmail = false
|
|
|
- return
|
|
|
- }
|
|
|
- case "replace":
|
|
|
- // 替换
|
|
|
- case "append":
|
|
|
- // 追加
|
|
|
- default:
|
|
|
- errMsg = fmt.Sprint("第", k+1, "个sheet,错误的操作类型")
|
|
|
- err = errors.New(errMsg + "op:" + sheetOp.OpType)
|
|
|
- isSendEmail = false
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ //// 查找当前excel的sheet列表
|
|
|
+ //currSheetList, err := excel.GetAllSheetList(excelInfo.ExcelInfoId)
|
|
|
+ //if err != nil {
|
|
|
+ // errMsg = "保存失败"
|
|
|
+ // err = errors.New("查找当前excel的sheet列表失败,Err:" + err.Error())
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //currSheetMap := make(map[string]string)
|
|
|
+ //for _, currSheet := range currSheetList {
|
|
|
+ // currSheetMap[currSheet.SheetName] = currSheet.SheetName
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //for k, sheetOp := range sheetOpList {
|
|
|
+ // sheetName := utils.TrimLRStr(sheetOp.SheetName)
|
|
|
+ // switch sheetOp.OpType {
|
|
|
+ // case "add":
|
|
|
+ // // 新增
|
|
|
+ // _, ok := currSheetMap[sheetName]
|
|
|
+ // if ok {
|
|
|
+ // errMsg = "存在同名sheet:" + sheetName
|
|
|
+ // err = errors.New(errMsg)
|
|
|
+ // isSendEmail = false
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // case "replace":
|
|
|
+ // // 替换
|
|
|
+ // case "append":
|
|
|
+ // // 追加
|
|
|
+ // default:
|
|
|
+ // errMsg = fmt.Sprint("第", k+1, "个sheet,错误的操作类型")
|
|
|
+ // err = errors.New(errMsg + "op:" + sheetOp.OpType)
|
|
|
+ // isSendEmail = false
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
// 表格
|
|
|
excelInfo.ExcelName = excelName
|
|
|
excelInfo.ExcelClassifyId = excelClassifyId
|
|
|
+ excelInfo.ExcelImage = excelImage
|
|
|
excelInfo.ModifyTime = time.Now()
|
|
|
+ updateExcelInfoParam := []string{"ExcelName", "ExcelClassifyId", "ExcelImage", "ModifyTime"}
|
|
|
|
|
|
addSheetList := make([]excel.AddExcelSheetParams, 0)
|
|
|
splitNum := 2000 // 基础分割单元格数
|
|
@@ -303,11 +319,25 @@ func SaveCustomAnalysisTable(excelInfo *data_manage.ExcelInfo, excelName, conten
|
|
|
isSendEmail = false
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ sheetConf, tmpErr := json.Marshal(sheetInfo.Config)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 计算公式
|
|
|
+ sheetCalcChain, tmpErr := json.Marshal(sheetInfo.CalcChain)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
addSheetItem := excel.AddExcelSheetParams{
|
|
|
ExcelSheetId: 0,
|
|
|
- ExcelInfoId: 0,
|
|
|
+ ExcelInfoId: excelInfo.ExcelInfoId,
|
|
|
SheetName: sheetName,
|
|
|
Sort: k,
|
|
|
+ Config: string(sheetConf),
|
|
|
+ CalcChain: string(sheetCalcChain),
|
|
|
}
|
|
|
|
|
|
lenCellData := len(sheetInfo.Celldata)
|
|
@@ -336,7 +366,7 @@ func SaveCustomAnalysisTable(excelInfo *data_manage.ExcelInfo, excelName, conten
|
|
|
}
|
|
|
sheetDataList = append(sheetDataList, &excel.ExcelSheetData{
|
|
|
ExcelDataId: 0,
|
|
|
- ExcelInfoId: 0,
|
|
|
+ ExcelInfoId: excelInfo.ExcelInfoId,
|
|
|
ExcelSheetId: 0,
|
|
|
Sort: i + 1,
|
|
|
Data: string(tmpDataByte),
|
|
@@ -349,7 +379,7 @@ func SaveCustomAnalysisTable(excelInfo *data_manage.ExcelInfo, excelName, conten
|
|
|
addSheetList = append(addSheetList, addSheetItem)
|
|
|
}
|
|
|
|
|
|
- err = data_manage.AddExcelInfoAndSheet(excelInfo, addSheetList)
|
|
|
+ err = data_manage.SaveExcelInfoAndSheet(excelInfo, updateExcelInfoParam, addSheetList)
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -365,6 +395,7 @@ type LuckySheet struct {
|
|
|
// Num35 int `json:"35"`
|
|
|
// } `json:"columnlen"`
|
|
|
//} `json:"config"`
|
|
|
+ Config interface{}
|
|
|
Index string `json:"index"`
|
|
|
Order string `json:"order"`
|
|
|
ZoomRatio int `json:"zoomRatio"`
|