...
|
...
|
@@ -18,6 +18,7 @@ import com.anjiplus.template.gaea.business.modules.report.service.ReportService; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
...
|
...
|
@@ -51,6 +52,12 @@ public class ExportServiceImpl implements ExportService { |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<String> getReportCodeList(List<String> reportIdList) {
|
|
|
List<Report> reportList = reportService.getMapper().selectBatchIds(reportIdList);
|
|
|
return reportList.stream().map(Report::getReportCode).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<Report> export(List<String> reportCodeList) {
|
|
|
//大屏
|
|
|
List<Report> reportList = reportService.list(new LambdaQueryWrapper<Report>()
|
...
|
...
|
@@ -70,10 +77,19 @@ public class ExportServiceImpl implements ExportService { |
|
|
reportDashboardWidgetList.stream().filter(item -> item.getData().contains("setCode")).forEach(item -> {
|
|
|
String data = item.getData();
|
|
|
int startIndex = data.indexOf("setCode");
|
|
|
while (startIndex != -1) {
|
|
|
int endIndex = data.indexOf(",", startIndex);
|
|
|
String setCode = data.substring(startIndex + 10, endIndex - 1);
|
|
|
setCodeList.add(setCode);
|
|
|
item.setSetCode(setCode);
|
|
|
if (endIndex + 2 <= data.length()) {
|
|
|
data = data.substring(endIndex + 2);
|
|
|
} else {
|
|
|
data = "";
|
|
|
}
|
|
|
startIndex = data.indexOf("setCode");
|
|
|
}
|
|
|
;
|
|
|
});
|
|
|
if (setCodeList.size() == 0) {
|
|
|
return reportList;
|
...
|
...
|
@@ -109,8 +125,11 @@ public class ExportServiceImpl implements ExportService { |
|
|
//组合组件接口
|
|
|
Map<String, List<DataSet>> dataSetMap = dataSetList.stream().collect(Collectors.groupingBy(DataSet::getSetCode));
|
|
|
reportDashboardWidgetList.stream().filter(item -> item.getData().contains("setCode")).forEach(reportDashboardWidget -> {
|
|
|
if (dataSetMap.get(reportDashboardWidget.getSetCode()) != null) {
|
|
|
reportDashboardWidget.getDataSetList().addAll(dataSetMap.get(reportDashboardWidget.getSetCode()));
|
|
|
String data = reportDashboardWidget.getData();
|
|
|
for (Map.Entry<String, List<DataSet>> map : dataSetMap.entrySet()) {
|
|
|
if (data.contains("\"setCode\":\"" + map.getKey() + "\"")) {
|
|
|
reportDashboardWidget.getDataSetList().addAll(dataSetMap.get(map.getKey()));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
//组合接口参数转换数据源
|
...
|
...
|
@@ -132,6 +151,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void importE(List<Report> reportList) {
|
|
|
|
|
|
//新增大屏
|
...
|
...
|
@@ -144,7 +164,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
|
|
//新增大屏配置
|
|
|
List<ReportDashboard> reportDashboardList = new ArrayList<>();
|
|
|
reportList.stream().map(Report::getReportDashboardList).forEach(reportDashboardList::addAll);
|
|
|
reportList.stream().map(Report::getReportDashboardList).distinct().forEach(reportDashboardList::addAll);
|
|
|
if (reportDashboardList.size() != 0) {
|
|
|
reportDashboardService.delete(new LambdaQueryWrapper<ReportDashboard>().in(ReportDashboard::getReportCode, reportCodeList));
|
|
|
reportDashboardService.insertBatch(reportDashboardList);
|
...
|
...
|
@@ -152,7 +172,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
|
|
//新增大屏组件
|
|
|
List<ReportDashboardWidget> reportDashboardWidgetList = new ArrayList<>();
|
|
|
reportList.stream().map(Report::getReportDashboardWidgetList).forEach(reportDashboardWidgetList::addAll);
|
|
|
reportList.stream().map(Report::getReportDashboardWidgetList).distinct().forEach(reportDashboardWidgetList::addAll);
|
|
|
if (reportDashboardWidgetList.size() == 0) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -162,7 +182,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
//新增数据集
|
|
|
List<String> setCodeList = reportDashboardWidgetList.stream().map(ReportDashboardWidget::getSetCode).distinct().collect(Collectors.toList());
|
|
|
List<DataSet> dataSetList = new ArrayList<>();
|
|
|
reportDashboardWidgetList.stream().map(ReportDashboardWidget::getDataSetList).forEach(dataSetList::addAll);
|
|
|
reportDashboardWidgetList.stream().map(ReportDashboardWidget::getDataSetList).distinct().forEach(dataSetList::addAll);
|
|
|
if (dataSetList.size() != 0) {
|
|
|
dataSetService.delete(new LambdaQueryWrapper<DataSet>().in(DataSet::getSetCode, setCodeList));
|
|
|
for (DataSet dataSet : dataSetList) {
|
...
|
...
|
@@ -175,7 +195,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
|
|
//新增数据集参数
|
|
|
List<DataSetParam> dataSetParamList = new ArrayList<>();
|
|
|
dataSetList.stream().map(DataSet::getDataSetParamList).forEach(dataSetParamList::addAll);
|
|
|
dataSetList.stream().map(DataSet::getDataSetParamList).distinct().forEach(dataSetParamList::addAll);
|
|
|
if (dataSetParamList.size() != 0) {
|
|
|
dataSetParamService.delete(new LambdaQueryWrapper<DataSetParam>().in(DataSetParam::getSetCode, setCodeList));
|
|
|
dataSetParamService.insertBatch(dataSetParamList);
|
...
|
...
|
@@ -183,7 +203,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
|
|
//新增数据源转换
|
|
|
List<DataSetTransform> dataSetTransformList = new ArrayList<>();
|
|
|
dataSetList.stream().map(DataSet::getDataSetTransformList).forEach(dataSetTransformList::addAll);
|
|
|
dataSetList.stream().map(DataSet::getDataSetTransformList).distinct().forEach(dataSetTransformList::addAll);
|
|
|
if (dataSetTransformList.size() != 0) {
|
|
|
dataSetTransformService.delete(new LambdaQueryWrapper<DataSetTransform>().in(DataSetTransform::getSetCode, setCodeList));
|
|
|
dataSetTransformService.insertBatch(dataSetTransformList);
|
...
|
...
|
|