From b783cf42c8bf9921c1453f301578cbd60883eb3d Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 7 Nov 2022 11:06:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=BA=94=E7=94=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=96=B0=E5=BB=BA=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=8F=AF=E8=83=BD=E6=97=A0=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 2 +- .../panel/PanelAppTemplateService.java | 14 ++-- .../service/panel/PanelGroupService.java | 70 +++++++++++-------- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 73e233c704..c5f536df90 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -2866,7 +2866,7 @@ public class DataSetTableService { createDorisView(TableUtils.tableName(tableId), sql); } - public void updateDatasetInfo(DatasetTable datasetTable){ + public void updateDatasetInfo(DatasetTable datasetTable) { datasetTableMapper.updateByPrimaryKeySelective(datasetTable); } } diff --git a/backend/src/main/java/io/dataease/service/panel/PanelAppTemplateService.java b/backend/src/main/java/io/dataease/service/panel/PanelAppTemplateService.java index 4015d9ac20..0ce6e59753 100644 --- a/backend/src/main/java/io/dataease/service/panel/PanelAppTemplateService.java +++ b/backend/src/main/java/io/dataease/service/panel/PanelAppTemplateService.java @@ -69,7 +69,7 @@ public class PanelAppTemplateService { private StaticResourceService staticResourceService; public List list(PanelAppTemplateRequest request) { - return extPanelAppTemplateMapper.queryBaseInfo(request.getNodeType(),request.getPid()); + return extPanelAppTemplateMapper.queryBaseInfo(request.getNodeType(), request.getPid()); } public void save(PanelAppTemplateRequest request) { @@ -81,7 +81,7 @@ public class PanelAppTemplateService { if (StringUtils.isEmpty(requestTemplate.getNodeType())) { requestTemplate.setNodeType("template"); } - if(StringUtils.isNotEmpty(request.getSnapshot())){ + if (StringUtils.isNotEmpty(request.getSnapshot())) { //Store static resource into the server String snapshotName = "app-template-" + request.getId() + ".jpeg"; staticResourceService.saveSingleFileToServe(snapshotName, request.getSnapshot().replace("data:image/jpeg;base64,", "")); @@ -98,7 +98,7 @@ public class PanelAppTemplateService { PanelAppTemplateWithBLOBs requestTemplate = new PanelAppTemplateWithBLOBs(); BeanUtils.copyBean(requestTemplate, request); //Store static resource into the server - if(StringUtils.isNotEmpty(request.getSnapshot())){ + if (StringUtils.isNotEmpty(request.getSnapshot())) { String snapshotName = "app-template-" + request.getId() + ".jpeg"; staticResourceService.saveSingleFileToServe(snapshotName, request.getSnapshot().replace("data:image/jpeg;base64,", "")); requestTemplate.setSnapshot("/" + UPLOAD_URL_PREFIX + '/' + snapshotName); @@ -159,7 +159,7 @@ public class PanelAppTemplateService { } @Transactional(rollbackFor = Exception.class) - public String applyPanel(PanelGroupRequest panelInfo, Map chartViewsRealMap,Map datasetsRealMap ,Map datasetFieldsRealMap, String newPanelId, String panelName, String pid) { + public String applyPanel(PanelGroupRequest panelInfo, Map chartViewsRealMap, Map datasetsRealMap, Map datasetFieldsRealMap, String newPanelId, String panelName, String pid) { panelInfo.setId(newPanelId); panelInfo.setPid(pid); panelInfo.setName(panelName); @@ -200,7 +200,7 @@ public class PanelAppTemplateService { public Map applyDatasetField(List datasetTableFieldsInfo, Map datasetsRealMap) { Map datasetFieldsRealMap = new HashMap<>(); for (DatasetTableField datasetTableField : datasetTableFieldsInfo) { - if(datasetTableField.getExtField()!=2){ + if (datasetTableField.getExtField() != 2) { String oldId = datasetTableField.getId(); datasetTableField.setTableId(datasetsRealMap.get(datasetTableField.getTableId())); datasetTableField.setId(null); @@ -210,7 +210,7 @@ public class PanelAppTemplateService { } //数据集计算字段替换 for (DatasetTableField datasetTableField : datasetTableFieldsInfo) { - if(datasetTableField.getExtField()==2){ + if (datasetTableField.getExtField() == 2) { String oldId = datasetTableField.getId(); datasetTableField.setTableId(datasetsRealMap.get(datasetTableField.getTableId())); datasetTableField.setId(null); @@ -240,7 +240,7 @@ public class PanelAppTemplateService { } else if (DatasetType.UNION.name().equalsIgnoreCase(datasetTable.getType())) { dataSetTableService.createAppUnionDorisView(datasetTable.getInfo(), datasetTable.getId()); } - }else{ + } else { dataSetTableService.updateDatasetInfo(datasetTable); } } diff --git a/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java b/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java index d31f73cf27..fccd45ab89 100644 --- a/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java +++ b/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java @@ -29,7 +29,6 @@ import io.dataease.listener.util.CacheUtils; import io.dataease.plugins.common.base.domain.*; import io.dataease.plugins.common.base.mapper.*; import io.dataease.plugins.common.constants.DeTypeConstants; -import io.dataease.service.chart.ChartGroupService; import io.dataease.service.chart.ChartViewService; import io.dataease.service.dataset.DataSetGroupService; import io.dataease.service.dataset.DataSetTableService; @@ -38,7 +37,8 @@ import io.dataease.service.sys.SysAuthService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.pentaho.di.core.util.UUIDUtil; @@ -233,7 +233,7 @@ public class PanelGroupService { return panelId; } - public void move(PanelGroupRequest request){ + public void move(PanelGroupRequest request) { PanelGroupWithBLOBs panelInfo = panelGroupMapper.selectByPrimaryKey(request.getId()); if (panelInfo.getPid().equalsIgnoreCase(request.getPid())) { DataEaseException.throwException(Translator.get("i18n_select_diff_folder")); @@ -420,14 +420,15 @@ public class PanelGroupService { panelGroupMapper.insertSelective(newPanel); return newPanelId; } + @Transactional(rollbackFor = Exception.class) - public String newPanelFromApp(PanelGroupRequest request,Map chartViewsRealMap){ + public String newPanelFromApp(PanelGroupRequest request, Map chartViewsRealMap) { String newPanelId = request.getId(); String templateData = request.getPanelData(); String staticResource = request.getStaticResource(); Boolean mobileLayout = panelViewService.haveMobileLayout(templateData); - for(Map.Entry entry:chartViewsRealMap.entrySet()){ - templateData = templateData.replaceAll(entry.getKey(),entry.getValue()); + for (Map.Entry entry : chartViewsRealMap.entrySet()) { + templateData = templateData.replaceAll(entry.getKey(), entry.getValue()); } request.setMobileLayout(mobileLayout); request.setPanelData(templateData); @@ -825,13 +826,13 @@ 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); } @Transactional(rollbackFor = Exception.class) - public String appApply(PanelAppTemplateApplyRequest request) throws Exception{ + public String appApply(PanelAppTemplateApplyRequest request) throws Exception { //仪表板名称校验,数据集分组名称校验,数据源名称校验 - panelAppTemplateService.nameCheck(request,"add"); + panelAppTemplateService.nameCheck(request, "add"); String newPanelId = UUIDUtil.getUUIDAsString(); // 新建数据集分组 @@ -845,39 +846,46 @@ public class PanelGroupService { //查询应用信息 PanelAppTemplateWithBLOBs appInfo = panelAppTemplateMapper.selectByPrimaryKey(request.getAppTemplateId()); //1.获取所有视图信息 - List chartViewsInfo = gson.fromJson(appInfo.getChartViewsInfo(), new TypeToken>(){}.getType()); + List chartViewsInfo = gson.fromJson(appInfo.getChartViewsInfo(), new TypeToken>() { + }.getType()); //2.获取视图扩展字段信息 - List chartViewFieldsInfo = gson.fromJson(appInfo.getChartViewFieldsInfo(), new TypeToken>(){}.getType()); + List chartViewFieldsInfo = gson.fromJson(appInfo.getChartViewFieldsInfo(), new TypeToken>() { + }.getType()); //3.获取所有数据集信息 - List datasetTablesInfo = gson.fromJson(appInfo.getDatasetTablesInfo(), new TypeToken>(){}.getType()); + List datasetTablesInfo = gson.fromJson(appInfo.getDatasetTablesInfo(), new TypeToken>() { + }.getType()); //4.获取所有数据集字段信息 - List datasetTableFieldsInfo = gson.fromJson(appInfo.getDatasetTableFieldsInfo(), new TypeToken>(){}.getType()); + List datasetTableFieldsInfo = gson.fromJson(appInfo.getDatasetTableFieldsInfo(), new TypeToken>() { + }.getType()); //5.获取所有任务信息 - List dataSetTasksInfo = gson.fromJson(appInfo.getDatasetTasksInfo(), new TypeToken>(){}.getType()); + List dataSetTasksInfo = gson.fromJson(appInfo.getDatasetTasksInfo(), new TypeToken>() { + }.getType()); //6.获取所有数据源信息 - List oldDatasourceInfo = gson.fromJson(appInfo.getDatasourceInfo(), new TypeToken>(){}.getType()); + List oldDatasourceInfo = gson.fromJson(appInfo.getDatasourceInfo(), new TypeToken>() { + }.getType()); //获取仪表板信息 - PanelGroupRequest panelInfo = gson.fromJson(appInfo.getPanelInfo(),PanelGroupRequest.class); + PanelGroupRequest panelInfo = gson.fromJson(appInfo.getPanelInfo(), PanelGroupRequest.class); //获取仪表板视图信息 - List panelViewsInfo = gson.fromJson(appInfo.getPanelViewsInfo(), new TypeToken>(){}.getType()); + List panelViewsInfo = gson.fromJson(appInfo.getPanelViewsInfo(), new TypeToken>() { + }.getType()); - Map datasourceRealMap = panelAppTemplateService.applyDatasource(oldDatasourceInfo,request.getDatasourceList()); + Map datasourceRealMap = panelAppTemplateService.applyDatasource(oldDatasourceInfo, request.getDatasourceList()); - Map datasetsRealMap = panelAppTemplateService.applyDataset(datasetTablesInfo,datasourceRealMap,asideDatasetGroupId); + Map datasetsRealMap = panelAppTemplateService.applyDataset(datasetTablesInfo, datasourceRealMap, asideDatasetGroupId); - Map datasetFieldsRealMap = panelAppTemplateService.applyDatasetField(datasetTableFieldsInfo,datasetsRealMap); + Map datasetFieldsRealMap = panelAppTemplateService.applyDatasetField(datasetTableFieldsInfo, datasetsRealMap); - panelAppTemplateService.resetCustomAndUnionDataset(datasetTablesInfo,datasetsRealMap,datasetFieldsRealMap); + panelAppTemplateService.resetCustomAndUnionDataset(datasetTablesInfo, datasetsRealMap, datasetFieldsRealMap); - Map chartViewsRealMap = panelAppTemplateService.applyViews(chartViewsInfo,datasetsRealMap,datasetFieldsRealMap,newPanelId); + Map chartViewsRealMap = panelAppTemplateService.applyViews(chartViewsInfo, datasetsRealMap, datasetFieldsRealMap, newPanelId); - panelAppTemplateService.applyViewsField(chartViewFieldsInfo,chartViewsRealMap,datasetsRealMap,datasetFieldsRealMap); + panelAppTemplateService.applyViewsField(chartViewFieldsInfo, chartViewsRealMap, datasetsRealMap, datasetFieldsRealMap); - panelAppTemplateService.applyPanel(panelInfo,chartViewsRealMap,datasetsRealMap,datasetFieldsRealMap,newPanelId, request.getPanelName(), request.getPanelGroupPid()); + panelAppTemplateService.applyPanel(panelInfo, chartViewsRealMap, datasetsRealMap, datasetFieldsRealMap, newPanelId, request.getPanelName(), request.getPanelGroupPid()); - panelAppTemplateService.applyPanelView(panelViewsInfo,chartViewsRealMap,newPanelId); + panelAppTemplateService.applyPanelView(panelViewsInfo, chartViewsRealMap, newPanelId); - String newDatasourceId =datasourceRealMap.entrySet().stream().findFirst().get().getValue(); + String newDatasourceId = datasourceRealMap.entrySet().stream().findFirst().get().getValue(); String newDatasourceName = request.getDatasourceList().get(0).getName(); @@ -895,18 +903,18 @@ public class PanelGroupService { } @Transactional(rollbackFor = Exception.class) - public void appEdit(PanelAppTemplateApplyRequest request) throws Exception{ + public void appEdit(PanelAppTemplateApplyRequest request) throws Exception { long currentTime = System.currentTimeMillis(); String userName = AuthUtils.getUser().getUsername(); //名称校验,数据集分组名称校验,数据源名称校验 - panelAppTemplateService.nameCheck(request,"update"); + panelAppTemplateService.nameCheck(request, "update"); //仪表板移动更新名称 PanelGroup panelHistoryInfo = panelGroupMapper.selectByPrimaryKey(request.getPanelId()); String panelHistoryPid = panelHistoryInfo.getPid(); - if(panelHistoryPid.equals(request.getPanelGroupPid())){ + if (panelHistoryPid.equals(request.getPanelGroupPid())) { // 未移动 checkPanelName(request.getPanelName(), request.getPanelGroupPid(), PanelConstants.OPT_TYPE_UPDATE, request.getPanelId(), "panel"); - }else{ + } else { checkPanelName(request.getPanelName(), request.getPanelGroupPid(), PanelConstants.OPT_TYPE_INSERT, null, "panel"); } panelHistoryInfo.setName(request.getPanelName()); @@ -920,7 +928,7 @@ public class PanelGroupService { DatasetGroup datasetGroup = new DatasetGroup(); datasetGroup.setName(request.getDatasetGroupName()); datasetGroup.setId(request.getDatasetGroupId()); - if(datasetGroupHistoryInfo.getPid().equals(request.getDatasetGroupPid())){ + if (datasetGroupHistoryInfo.getPid().equals(request.getDatasetGroupPid())) { datasetGroup.setPid(request.getDatasetGroupPid()); } dataSetGroupService.checkName(datasetGroup);