|
@@ -132,7 +132,7 @@ func (this *ExcelInfoController) GetTableDetail() {
|
|
|
br.ErrMsg = "表格json转结构体失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- newResult, tmpErr, tmpErrMsg := excel2.GetMixedTableCellData(result)
|
|
|
+ newResult, tmpErr, tmpErrMsg := excel2.GetMixedTableCellData(result, this.Lang)
|
|
|
if tmpErr != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
if tmpErrMsg != `` {
|
|
@@ -184,7 +184,7 @@ func (this *ExcelInfoController) GetTableDetail() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
-func refreshBalanceTable(excelDetail *excel3.ExcelInfo) (err error) {
|
|
|
+func refreshBalanceTable(excelDetail *excel3.ExcelInfo, lang string) (err error) {
|
|
|
|
|
|
edbInfoIds := make([]int, 0)
|
|
|
edbInfoIdExist := make(map[int]bool)
|
|
@@ -194,7 +194,7 @@ func refreshBalanceTable(excelDetail *excel3.ExcelInfo) (err error) {
|
|
|
err = fmt.Errorf("表格json转结构体失败,Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
- newData, tmpErr, _ := excel2.GetMixedTableCellData(result)
|
|
|
+ newData, tmpErr, _ := excel2.GetMixedTableCellData(result, lang)
|
|
|
if tmpErr != nil {
|
|
|
err = tmpErr
|
|
|
return
|
|
@@ -225,3 +225,119 @@ func refreshBalanceTable(excelDetail *excel3.ExcelInfo) (err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (this *ExcelInfoController) Refresh() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ uniqueCode := this.GetString("UniqueCode")
|
|
|
+ if uniqueCode == "" {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ br.ErrMsg = "参数错误, UniqueCode is empty"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL_REFRESH + ":" + uniqueCode
|
|
|
+ ok := utils.Rc.SetNX(key, 1, time.Second*300)
|
|
|
+ if !ok {
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "表格刷新中"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ _ = utils.Rc.Delete(key)
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
+ excelDetail, errMsg, err := excel2.GetExcelDetailInfoByExcelInfoId(uniqueCode, this.Lang)
|
|
|
+ if err != nil {
|
|
|
+ if err.Error() == utils.ErrNoRow() {
|
|
|
+ br.Msg = "该表格已被删除,请刷新页面"
|
|
|
+ br.ErrMsg = "该表格已被删除,请刷新页面,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = errMsg
|
|
|
+ br.ErrMsg = "获取表格表信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if excelDetail.Source == utils.TIME_TABLE {
|
|
|
+ jsonByte, e := json.Marshal(excelDetail.TableData)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "自定义表格数据获取失败"
|
|
|
+ br.ErrMsg = "自定义表格数据获取失败,转json失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var tableData request.TableDataReq
|
|
|
+ if e = json.Unmarshal(jsonByte, &tableData); e != nil {
|
|
|
+ br.Msg = "自定义表格数据获取失败"
|
|
|
+ br.ErrMsg = "自定义表格数据获取失败,json转结构体失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(tableData.EdbInfoIdList) > 0 {
|
|
|
+ if e, _ = data.EdbInfoRefreshAllFromBase(tableData.EdbInfoIdList, false); e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "刷新失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if excelDetail.Source == utils.MIXED_TABLE {
|
|
|
+ jsonByte, e := json.Marshal(excelDetail.TableData)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "JSON格式化混合表格数据失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var tableData request.MixedTableReq
|
|
|
+ if e = json.Unmarshal(jsonByte, &tableData); e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "解析混合表格数据失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ edbInfoIds := make([]int, 0)
|
|
|
+ edbInfoIdExist := make(map[int]bool)
|
|
|
+ if len(tableData.Data) > 0 {
|
|
|
+ for _, t := range tableData.Data {
|
|
|
+ for _, v := range t {
|
|
|
+ if v.EdbInfoId > 0 && !edbInfoIdExist[v.EdbInfoId] {
|
|
|
+ edbInfoIdExist[v.EdbInfoId] = true
|
|
|
+ edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(edbInfoIds) > 0 {
|
|
|
+ if e, _ = data.EdbInfoRefreshAllFromBase(edbInfoIds, false); e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "刷新混合表格数据失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ detailKey := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + excelDetail.UniqueCode
|
|
|
+ if utils.Re == nil {
|
|
|
+ _ = utils.Rc.Delete(detailKey)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "刷新成功"
|
|
|
+}
|