forked from github/dataease
feat: 从模板新建的仪表板支持查看模板缓存数据
This commit is contained in:
parent
558dfa7d62
commit
2feb5138b3
@ -14,6 +14,7 @@ import io.dataease.controller.request.chart.ChartViewRequest;
|
||||
import io.dataease.controller.response.ChartDetail;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.dataease.service.panel.PanelViewService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -33,6 +34,8 @@ import java.util.List;
|
||||
public class ChartViewController {
|
||||
@Resource
|
||||
private ChartViewService chartViewService;
|
||||
@Resource
|
||||
private PanelViewService panelViewService;
|
||||
|
||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
|
||||
@ApiOperation("保存")
|
||||
@ -73,7 +76,8 @@ public class ChartViewController {
|
||||
@ApiOperation("详细信息")
|
||||
@PostMapping("/get/{id}/{panelId}")
|
||||
public ChartViewDTO get(@PathVariable String id, @PathVariable String panelId,@RequestBody ChartViewRequest viewRequest) {
|
||||
return chartViewService.getOne(id,viewRequest.getQueryFrom());
|
||||
String dataFrom = panelViewService.findViewDataFrom(id);
|
||||
return chartViewService.getOne(id,viewRequest.getQueryFrom(),dataFrom);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
|
@ -233,18 +233,32 @@ public class ChartViewService {
|
||||
return extChartViewMapper.searchOneWithPrivileges(userId, id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public ChartViewDTO getOne(String id, String queryFrom) {
|
||||
return getOne(id,queryFrom,CommonConstants.VIEW_DATA_FROM.CHART);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public ChartViewDTO getOne(String id, String queryFrom,String dataFrom) {
|
||||
ChartViewDTO result;
|
||||
//仪表板编辑页面 从缓存表中取数据 缓存表中没有数据则进行插入
|
||||
if (CommonConstants.VIEW_QUERY_FROM.PANEL_EDIT.equals(queryFrom)) {
|
||||
//从模板中去数据
|
||||
if(CommonConstants.VIEW_DATA_FROM.TEMPLATE.equals(dataFrom)){
|
||||
result = extendDataService.getChartInfo(id);
|
||||
if(result!=null){
|
||||
result.setData(null);
|
||||
}
|
||||
}else if (CommonConstants.VIEW_QUERY_FROM.PANEL_EDIT.equals(queryFrom)) {
|
||||
//仪表板编辑页面 从缓存表中取数据 缓存表中没有数据则进行插入
|
||||
result = extChartViewMapper.searchOneFromCache(id);
|
||||
if (result == null) {
|
||||
extChartViewMapper.copyToCache(id);
|
||||
result = extChartViewMapper.searchOneFromCache(id);
|
||||
}
|
||||
result.setDataFrom(CommonConstants.VIEW_DATA_FROM.CHART);
|
||||
} else {
|
||||
result = extChartViewMapper.searchOne(id);
|
||||
result.setDataFrom(CommonConstants.VIEW_DATA_FROM.CHART);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -266,7 +280,6 @@ public class ChartViewService {
|
||||
if(CommonConstants.VIEW_DATA_FROM.TEMPLATE.equals(dataFrom)){
|
||||
return extendDataService.getChartInfo(id);
|
||||
}else{// 从视图读取数据
|
||||
|
||||
ChartViewDTO view = this.getOne(id,request.getQueryFrom());
|
||||
view.setDataFrom(dataFrom);
|
||||
// 如果是从仪表板获取视图数据,则仪表板的查询模式,查询结果的数量,覆盖视图对应的属性
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.*;
|
||||
@ -323,10 +324,12 @@ public class PanelGroupService {
|
||||
Map<String,String> dynamicDataMap = JSON.parseObject(dynamicData,Map.class);
|
||||
List<PanelViewInsertDTO> panelViews = new ArrayList<>();
|
||||
List<PanelGroupExtendDataDTO> viewsData = new ArrayList<>();
|
||||
List<ChartViewWithBLOBs> chartViews = new ArrayList<>();
|
||||
for(Map.Entry<String, String> entry : dynamicDataMap.entrySet()){
|
||||
String originViewId = entry.getKey();
|
||||
String originViewData = entry.getValue();
|
||||
String position = JSON.parseObject(originViewData).getString("position");
|
||||
JSONObject chartViewJson = JSON.parseObject(originViewData);
|
||||
String position = chartViewJson.getString("position");
|
||||
String newViewId = UUIDUtil.getUUIDAsString();
|
||||
//TODO 数据处理 1.替换viewId 2.加入panelView 数据(数据来源为template) 3.加入模板view data数据
|
||||
templateData = templateData.replaceAll(originViewId,newViewId);
|
||||
|
@ -1788,7 +1788,7 @@ export default {
|
||||
getChart(id, queryFrom = 'panel_edit') {
|
||||
if (id) {
|
||||
getChartDetails(id, this.panelInfo.id, { queryFrom: queryFrom }).then(response => {
|
||||
this.initTableData(response.data.tableId)
|
||||
response.data.dataFrom !== 'template' && this.initTableData(response.data.tableId)
|
||||
this.view = JSON.parse(JSON.stringify(response.data))
|
||||
this.view.xaxis = this.view.xaxis ? JSON.parse(this.view.xaxis) : []
|
||||
this.view.xaxisExt = this.view.xaxisExt ? JSON.parse(this.view.xaxisExt) : []
|
||||
@ -2150,6 +2150,7 @@ export default {
|
||||
// this.save(true, 'chart', false)
|
||||
this.calcData(true, 'chart', false)
|
||||
this.initTableData(this.view.tableId)
|
||||
this.closeChangeChart()
|
||||
},
|
||||
|
||||
fieldFilter(val) {
|
||||
|
Loading…
Reference in New Issue
Block a user