|
@@ -1804,6 +1804,9 @@ func (c *ExcelInfoController) GetHistoryDateData() {
|
|
|
func (c *ExcelInfoController) Refresh() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
c.Data["json"] = br
|
|
|
c.ServeJSON()
|
|
|
}()
|
|
@@ -1844,7 +1847,7 @@ func (c *ExcelInfoController) Refresh() {
|
|
|
}
|
|
|
|
|
|
// 数据刷新(只有自定义表格有刷新)
|
|
|
- if excelDetail.Source == 2 {
|
|
|
+ if excelDetail.Source == utils.TIME_TABLE {
|
|
|
jsonStrByte, err := json.Marshal(excelDetail.TableData)
|
|
|
if err != nil {
|
|
|
br.Msg = "自定义表格数据获取失败"
|
|
@@ -1869,6 +1872,48 @@ func (c *ExcelInfoController) Refresh() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 数据刷新-混合表格
|
|
|
+ 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 {
|
|
|
+ e, _ = data.EdbInfoRefreshAllFromBaseV3(edbInfoIds, false, true, false)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "刷新混合表格数据失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清除缓存
|
|
|
+ key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + excelDetail.UniqueCode
|
|
|
+ if utils.Re == nil {
|
|
|
+ _ = utils.Rc.Delete(key)
|
|
|
+ }
|
|
|
+
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "刷新成功"
|
|
@@ -2244,3 +2289,117 @@ func (this *ExcelInfoController) MarkEditStatus() {
|
|
|
br.Msg = msg
|
|
|
br.Data = data
|
|
|
}
|
|
|
+
|
|
|
+// BatchRefresh
|
|
|
+// @Title 批量刷新表格接口
|
|
|
+// @Description 批量刷新图表接口
|
|
|
+// @Param request body excel3.BatchRefreshExcelReq true "type json string"
|
|
|
+// @Success Ret=200 刷新成功
|
|
|
+// @router /excel_info/table/batch_refresh [post]
|
|
|
+func (this *ExcelInfoController) BatchRefresh() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var req excel3.BatchRefreshExcelReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(req.ExcelCodes) == 0 {
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "刷新成功"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取表格关联的指标IDs
|
|
|
+ edbIds, e := excel2.GetEdbIdsFromExcelCodes(req.ExcelCodes)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "获取表格关联的指标IDs失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ redisKey := data.GetBatchChartRefreshKey(req.Source, req.ReportId, req.ReportChapterId)
|
|
|
+ refreshKeys := make([]string, 0)
|
|
|
+ for _, v := range req.ExcelCodes {
|
|
|
+ refreshKeys = append(refreshKeys, fmt.Sprint(utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL, v))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 刷新相关指标
|
|
|
+ syncing, e := data.BatchRefreshEdbByEdbIds(edbIds, redisKey, refreshKeys)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "刷新失败"
|
|
|
+ br.ErrMsg = "刷新表格关联指标信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Msg = "刷新成功"
|
|
|
+ if syncing {
|
|
|
+ br.Msg = "表格关联指标较多,请10分钟后刷新页面查看最新数据"
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+}
|
|
|
+
|
|
|
+// GetBatchChartRefreshResult
|
|
|
+// @Title 获取批量刷新表格结果
|
|
|
+// @Description 获取批量刷新表格结果
|
|
|
+// @Param request body excel3.BatchRefreshExcelReq true "type json string"
|
|
|
+// @Success Ret=200 刷新成功
|
|
|
+// @router /excel_info/table/batch_refresh/result [post]
|
|
|
+func (this *ExcelInfoController) GetBatchChartRefreshResult() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var req excel3.BatchRefreshExcelReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验缓存是否存在, 存在说明还在刷新中
|
|
|
+ result := true
|
|
|
+ redisKey := excel2.GetExcelEdbBatchRefreshKey(req.Source, req.ReportId, req.ReportChapterId)
|
|
|
+ if redisKey != `` {
|
|
|
+ // 如果找到了key,那么就是还在更新中
|
|
|
+ ok := utils.Rc.IsExist(redisKey)
|
|
|
+ if ok {
|
|
|
+ result = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := struct {
|
|
|
+ RefreshResult bool `description:"刷新结果"`
|
|
|
+ }{
|
|
|
+ RefreshResult: result,
|
|
|
+ }
|
|
|
+ br.Data = resp
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+}
|