forked from github/dataease
Merge pull request #4822 from dataease/pr@dev@feat_app-linkage-jump
feat(应用): 应用导出支持导出原仪表板的联动与跳转效果 #4753
This commit is contained in:
commit
59b116217d
@ -33,5 +33,13 @@ public class PanelAppTemplateApplyRequest {
|
||||
|
||||
private String datasourceHistoryId;
|
||||
|
||||
private String linkJumps;
|
||||
|
||||
private String linkJumpInfos;
|
||||
|
||||
private String linkages;
|
||||
|
||||
private String linkageFields;
|
||||
|
||||
private List<DatasourceDTO> datasourceList;
|
||||
}
|
||||
|
@ -37,6 +37,14 @@ public class PanelExport2App {
|
||||
|
||||
private String datasourceInfo;
|
||||
|
||||
private String linkJumps;
|
||||
|
||||
private String linkJumpInfos;
|
||||
|
||||
private String linkages;
|
||||
|
||||
private String linkageFields;
|
||||
|
||||
public PanelExport2App() {
|
||||
|
||||
}
|
||||
@ -45,7 +53,11 @@ public class PanelExport2App {
|
||||
this.checkMes = checkMes;
|
||||
}
|
||||
|
||||
public PanelExport2App(List<ChartViewWithBLOBs> chartViewsInfo, List<ChartViewField> chartViewFieldsInfo, List<DatasetTable> datasetTablesInfo, List<DatasetTableField> datasetTableFieldsInfo, List<DataSetTaskDTO> datasetTasksInfo, List<DatasourceDTO> datasourceInfo, List<PanelView> panelViewsInfo) {
|
||||
public PanelExport2App(List<ChartViewWithBLOBs> chartViewsInfo, List<ChartViewField> chartViewFieldsInfo,
|
||||
List<DatasetTable> datasetTablesInfo, List<DatasetTableField> datasetTableFieldsInfo,
|
||||
List<DataSetTaskDTO> datasetTasksInfo, List<DatasourceDTO> datasourceInfo,
|
||||
List<PanelView> panelViewsInfo,List<PanelLinkJump> linkJumps,List<PanelLinkJumpInfo> linkJumpInfos,
|
||||
List<PanelViewLinkage> linkages, List<PanelViewLinkageField> linkageFields) {
|
||||
List empty = new ArrayList();
|
||||
this.checkStatus = true;
|
||||
this.checkMes = "success";
|
||||
@ -56,5 +68,9 @@ public class PanelExport2App {
|
||||
this.datasetTasksInfo = JSON.toJSONString(datasetTasksInfo!=null?datasetTasksInfo:empty);
|
||||
this.datasourceInfo = JSON.toJSONString(datasourceInfo!=null?datasourceInfo:empty);
|
||||
this.panelViewsInfo = JSON.toJSONString(panelViewsInfo!=null?panelViewsInfo:empty);
|
||||
this.linkJumps = JSON.toJSONString(linkJumps!=null?linkJumps:empty);
|
||||
this.linkJumpInfos = JSON.toJSONString(linkJumpInfos!=null?linkJumpInfos:empty);
|
||||
this.linkages = JSON.toJSONString(linkages!=null?linkages:empty);
|
||||
this.linkageFields = JSON.toJSONString(linkJumpInfos!=null?linkageFields:empty);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package io.dataease.ext;
|
||||
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseRequest;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpDTO;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkJump;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkJumpInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -30,4 +32,7 @@ public interface ExtPanelLinkJumpMapper {
|
||||
void copyLinkJumpInfo(@Param("copyId")String copyId);
|
||||
|
||||
void copyLinkJumpTarget(@Param("copyId")String copyId);
|
||||
|
||||
List<PanelLinkJump> findLinkJumpWithPanelId(@Param("panelId")String panelId);
|
||||
List<PanelLinkJumpInfo> findLinkJumpInfoWithPanelId(@Param("panelId")String panelId);
|
||||
}
|
||||
|
@ -269,4 +269,29 @@
|
||||
WHERE copy_id = #{copyId}) plji_copy
|
||||
ON panel_link_jump_target_view_info.link_jump_info_id = plji_copy.s_id
|
||||
</insert>
|
||||
|
||||
<select id="findLinkJumpWithPanelId" resultType="io.dataease.plugins.common.base.domain.PanelLinkJump">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
panel_link_jump
|
||||
WHERE
|
||||
source_panel_id = #{panelId}
|
||||
</select>
|
||||
|
||||
<select id="findLinkJumpInfoWithPanelId" resultType="io.dataease.plugins.common.base.domain.PanelLinkJumpInfo">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
panel_link_jump_info
|
||||
WHERE
|
||||
link_type = 'outer'
|
||||
AND link_jump_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
panel_link_jump
|
||||
WHERE
|
||||
source_panel_id = #{panelId})
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -3,6 +3,8 @@ package io.dataease.ext;
|
||||
import io.dataease.dto.LinkageInfoDTO;
|
||||
import io.dataease.dto.PanelViewLinkageDTO;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.PanelViewLinkage;
|
||||
import io.dataease.plugins.common.base.domain.PanelViewLinkageField;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -24,4 +26,8 @@ public interface ExtPanelViewLinkageMapper {
|
||||
void copyViewLinkage(@Param("copyId") String copyId);
|
||||
|
||||
void copyViewLinkageField(@Param("copyId") String copyId);
|
||||
|
||||
List<PanelViewLinkage> findLinkageWithPanelId(@Param("panelId") String panelId);
|
||||
|
||||
List<PanelViewLinkageField> findLinkageFieldWithPanelId(@Param("panelId") String panelId);
|
||||
}
|
||||
|
@ -195,4 +195,18 @@
|
||||
) pvlf_copy ON panel_view_linkage_field.linkage_id = pvlf_copy.s_id
|
||||
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="findLinkageWithPanelId" resultType="io.dataease.plugins.common.base.domain.PanelViewLinkage">
|
||||
select * from panel_view_linkage where panel_id =#{panelId};
|
||||
</select>
|
||||
|
||||
<select id="findLinkageFieldWithPanelId" resultType="io.dataease.plugins.common.base.domain.PanelViewLinkageField">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
panel_view_linkage_field
|
||||
WHERE
|
||||
linkage_id IN ( SELECT id FROM panel_view_linkage WHERE panel_id = #{panelId} );
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -14,7 +14,7 @@ import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.dto.DatasourceDTO;
|
||||
import io.dataease.ext.ExtPanelAppTemplateMapper;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.PanelAppTemplateMapper;
|
||||
import io.dataease.plugins.common.base.mapper.*;
|
||||
import io.dataease.plugins.common.constants.DatasetType;
|
||||
import io.dataease.service.chart.ChartViewFieldService;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
@ -72,6 +72,14 @@ public class PanelAppTemplateService {
|
||||
private StaticResourceService staticResourceService;
|
||||
@Resource
|
||||
private ExtractDataService extractDataService;
|
||||
@Resource
|
||||
private PanelLinkJumpMapper panelLinkJumpMapper;
|
||||
@Resource
|
||||
private PanelLinkJumpInfoMapper panelLinkJumpInfoMapper;
|
||||
@Resource
|
||||
private PanelViewLinkageMapper panelViewLinkageMapper;
|
||||
@Resource
|
||||
private PanelViewLinkageFieldMapper panelViewLinkageFieldMapper;
|
||||
|
||||
public List<PanelAppTemplateWithBLOBs> list(PanelAppTemplateRequest request) {
|
||||
return extPanelAppTemplateMapper.queryBaseInfo(request.getNodeType(), request.getPid());
|
||||
@ -411,4 +419,67 @@ public class PanelAppTemplateService {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String,String> applyLinkJumps(List<PanelLinkJump> linkJumps, Map<String, String> chartViewsRealMap, String newPanelId) {
|
||||
Map<String,String> linkJumpIdMap = new HashMap<>();
|
||||
if(!CollectionUtils.isEmpty(linkJumps)){
|
||||
for(PanelLinkJump linkJump :linkJumps){
|
||||
String newLinkJumpId = UUIDUtil.getUUIDAsString();
|
||||
linkJumpIdMap.put(linkJump.getId(),newLinkJumpId);
|
||||
linkJump.setId(newLinkJumpId);
|
||||
linkJump.setSourcePanelId(newPanelId);
|
||||
linkJump.setSourceViewId(chartViewsRealMap.get(linkJump.getSourceViewId()));
|
||||
panelLinkJumpMapper.insertSelective(linkJump);
|
||||
}
|
||||
}
|
||||
return linkJumpIdMap;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void applyLinkJumpInfos(List<PanelLinkJumpInfo> linkJumpInfos, Map<String, String> linkJumpIdMap, Map<String, String> datasetFieldsRealMap) {
|
||||
if(!CollectionUtils.isEmpty(linkJumpInfos)){
|
||||
for(PanelLinkJumpInfo linkJumpInfo :linkJumpInfos){
|
||||
String newLinkJumpInfoId = UUIDUtil.getUUIDAsString();
|
||||
linkJumpInfo.setId(newLinkJumpInfoId);
|
||||
linkJumpInfo.setLinkJumpId(linkJumpIdMap.get(linkJumpInfo.getLinkJumpId()));
|
||||
linkJumpInfo.setSourceFieldId(datasetFieldsRealMap.get(linkJumpInfo.getSourceFieldId()));
|
||||
datasetFieldsRealMap.forEach((k, v) -> {
|
||||
linkJumpInfo.setContent(linkJumpInfo.getContent().replaceAll(k, v));
|
||||
});
|
||||
panelLinkJumpInfoMapper.insertSelective(linkJumpInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String,String> applyLinkages(List<PanelViewLinkage> linkages, Map<String, String> chartViewsRealMap, String newPanelId) {
|
||||
Map<String,String> linkageIdMap = new HashMap<>();
|
||||
if(!CollectionUtils.isEmpty(linkages)){
|
||||
for(PanelViewLinkage linkage :linkages){
|
||||
String newId = UUIDUtil.getUUIDAsString();
|
||||
linkageIdMap.put(linkage.getId(),newId);
|
||||
linkage.setId(newId);
|
||||
linkage.setPanelId(newPanelId);
|
||||
linkage.setSourceViewId(chartViewsRealMap.get(linkage.getSourceViewId()));
|
||||
linkage.setTargetViewId(chartViewsRealMap.get(linkage.getTargetViewId()));
|
||||
panelViewLinkageMapper.insertSelective(linkage);
|
||||
}
|
||||
}
|
||||
return linkageIdMap;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void applyLinkageFields(List<PanelViewLinkageField> linkageFields, Map<String, String> linkageIdMap, Map<String, String> datasetFieldsRealMap) {
|
||||
if(!CollectionUtils.isEmpty(linkageFields)){
|
||||
for(PanelViewLinkageField linkageField :linkageFields){
|
||||
String newId = UUIDUtil.getUUIDAsString();
|
||||
linkageField.setId(newId);
|
||||
linkageField.setLinkageId(linkageIdMap.get(linkageField.getLinkageId()));
|
||||
linkageField.setSourceField(datasetFieldsRealMap.get(linkageField.getSourceField()));
|
||||
linkageField.setTargetField(datasetFieldsRealMap.get(linkageField.getTargetField()));
|
||||
panelViewLinkageFieldMapper.insertSelective(linkageField);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -964,6 +964,14 @@ public class PanelGroupService {
|
||||
List<DatasourceDTO> datasourceDTOS = extDataSourceMapper.findByTableIds(allTableIds);
|
||||
|
||||
List<PanelView> panelViews = panelViewService.findPanelViewsByPanelId(panelId);
|
||||
//获取所有跳转信息
|
||||
List<PanelLinkJump> linkJumps = extPanelLinkJumpMapper.findLinkJumpWithPanelId(panelId);
|
||||
//获取所有跳转关联信息
|
||||
List<PanelLinkJumpInfo> linkJumpInfos = extPanelLinkJumpMapper.findLinkJumpInfoWithPanelId(panelId);
|
||||
//获取所有联动信息
|
||||
List<PanelViewLinkage> linkages = extPanelViewLinkageMapper.findLinkageWithPanelId(panelId);
|
||||
//获取所有联动关联信息
|
||||
List<PanelViewLinkageField> LinkageFields = extPanelViewLinkageMapper.findLinkageFieldWithPanelId(panelId);
|
||||
|
||||
//校验标准 1.存在视图且所有视图的数据来源必须是dataset 2.存在数据集且没有excel数据集 3.存在数据源且是单数据源
|
||||
//1.view check
|
||||
@ -979,7 +987,8 @@ public class PanelGroupService {
|
||||
} else if (datasourceDTOS.size() > 1) {
|
||||
return new PanelExport2App(Translator.get("I18N_APP_ONE_DATASOURCE_TIPS"));
|
||||
}
|
||||
return new PanelExport2App(chartViewsInfo, chartViewFieldsInfo, datasetTablesInfo, datasetTableFieldsInfo, dataSetTasksInfo, datasourceDTOS, panelViews);
|
||||
return new PanelExport2App(chartViewsInfo, chartViewFieldsInfo, datasetTablesInfo, datasetTableFieldsInfo,
|
||||
dataSetTasksInfo, datasourceDTOS, panelViews, linkJumps, linkJumpInfos, linkages, LinkageFields);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -1016,11 +1025,32 @@ public class PanelGroupService {
|
||||
//6.获取所有数据源信息
|
||||
List<Datasource> oldDatasourceInfo = gson.fromJson(appInfo.getDatasourceInfo(), new TypeToken<List<Datasource>>() {
|
||||
}.getType());
|
||||
//获取仪表板信息
|
||||
//7.获取仪表板信息
|
||||
PanelGroupRequest panelInfo = gson.fromJson(appInfo.getPanelInfo(), PanelGroupRequest.class);
|
||||
//获取仪表板视图信息
|
||||
//8.获取仪表板视图信息
|
||||
List<PanelView> panelViewsInfo = gson.fromJson(appInfo.getPanelViewsInfo(), new TypeToken<List<PanelView>>() {
|
||||
}.getType());
|
||||
//9.获取跳转信息
|
||||
List<PanelLinkJump> linkJumps = null;
|
||||
if(StringUtils.isNotEmpty(appInfo.getLinkJumps())){
|
||||
linkJumps = gson.fromJson(appInfo.getLinkJumps(), new TypeToken<List<PanelLinkJump>>() {}.getType());
|
||||
}
|
||||
//10.获取跳转关联信息
|
||||
List<PanelLinkJumpInfo> linkJumpInfos = null;
|
||||
if(StringUtils.isNotEmpty(appInfo.getLinkJumpInfos())){
|
||||
linkJumpInfos = gson.fromJson(appInfo.getLinkJumpInfos(), new TypeToken<List<PanelLinkJumpInfo>>() {}.getType());
|
||||
}
|
||||
//11.获取联动信息
|
||||
List<PanelViewLinkage> linkages = null;
|
||||
if(StringUtils.isNotEmpty(appInfo.getLinkages())){
|
||||
linkages = gson.fromJson(appInfo.getLinkages(), new TypeToken<List<PanelViewLinkage>>() {}.getType());
|
||||
}
|
||||
|
||||
//12.获取联动关联信息
|
||||
List<PanelViewLinkageField> linkageFields = null;
|
||||
if(StringUtils.isNotEmpty(appInfo.getLinkageFields())){
|
||||
linkageFields = gson.fromJson(appInfo.getLinkageFields(), new TypeToken<List<PanelViewLinkageField>>() {}.getType());
|
||||
}
|
||||
|
||||
Map<String, String> datasourceRealMap = panelAppTemplateService.applyDatasource(oldDatasourceInfo, request);
|
||||
|
||||
@ -1044,8 +1074,15 @@ public class PanelGroupService {
|
||||
|
||||
panelAppTemplateService.applyPanelView(panelViewsInfo, chartViewsRealMap, newPanelId);
|
||||
|
||||
String newDatasourceId = datasourceRealMap.entrySet().stream().findFirst().get().getValue();
|
||||
Map<String,String> linkageIdMap = panelAppTemplateService.applyLinkages(linkages,chartViewsRealMap,newPanelId);
|
||||
|
||||
panelAppTemplateService.applyLinkageFields(linkageFields,linkageIdMap,datasetFieldsRealMap);
|
||||
|
||||
Map<String,String> linkJumpIdMap = panelAppTemplateService.applyLinkJumps(linkJumps,chartViewsRealMap,newPanelId);
|
||||
|
||||
panelAppTemplateService.applyLinkJumpInfos(linkJumpInfos,linkJumpIdMap,datasetFieldsRealMap);
|
||||
|
||||
String newDatasourceId = datasourceRealMap.entrySet().stream().findFirst().get().getValue();
|
||||
|
||||
PanelAppTemplateLog templateLog = new PanelAppTemplateLog();
|
||||
templateLog.setPanelId(newPanelId);
|
||||
|
@ -54,4 +54,10 @@ END
|
||||
;;
|
||||
delimiter ;
|
||||
|
||||
INSERT INTO `system_parameter` (`param_key`, `param_value`, `type`, `sort`) VALUES ('loginlimit.multiLogin', '0', 'text', '3');
|
||||
INSERT INTO `system_parameter` (`param_key`, `param_value`, `type`, `sort`) VALUES ('loginlimit.multiLogin', '0', 'text', '3');
|
||||
|
||||
ALTER TABLE `panel_app_template`
|
||||
ADD COLUMN `link_jumps` longtext NULL AFTER `datasource_info`,
|
||||
ADD COLUMN `link_jump_infos` longtext NULL AFTER `link_jumps`,
|
||||
ADD COLUMN `linkages` longtext NULL AFTER `link_jump_infos`,
|
||||
ADD COLUMN `linkage_fields` longtext NULL AFTER `linkages`;
|
Loading…
Reference in New Issue
Block a user