|
|
@ -28,6 +28,7 @@ import com.fr.report.cell.FloatElement; |
|
|
|
import com.fr.report.cell.tabledata.ElementUsedTableDataProvider; |
|
|
|
import com.fr.report.cell.tabledata.ElementUsedTableDataProvider; |
|
|
|
import com.fr.report.worksheet.FormElementCase; |
|
|
|
import com.fr.report.worksheet.FormElementCase; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -97,20 +98,32 @@ public class TableDataFollowingPasteUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 处理存储过程名称问题
|
|
|
|
return dealWithTableDataMap(tempMap); |
|
|
|
return dealWithStoreProcedure(tempMap); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error("transfer widget tabledata failed", e); |
|
|
|
FineLoggerFactory.getLogger().error("transfer widget tabledata failed", e); |
|
|
|
} |
|
|
|
} |
|
|
|
return new HashMap<>(); |
|
|
|
return new HashMap<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 处理结果集 |
|
|
|
|
|
|
|
* @param tableDataMap |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static Map<String, TableData> dealWithTableDataMap(Map<String, TableData> tableDataMap) { |
|
|
|
|
|
|
|
// 处理存储过程名称问题,名称问题需要优先处理,否则就找不到匹配的TableData了
|
|
|
|
|
|
|
|
tableDataMap = dealWithStoreProcedure(tableDataMap); |
|
|
|
|
|
|
|
// 对TableData做clone处理
|
|
|
|
|
|
|
|
tableDataMap = dealWithTableData4Clone(tableDataMap); |
|
|
|
|
|
|
|
return tableDataMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 处理结果集,将结果集中的存储过程子表替换为原本的存储过程,否则跟随粘贴过去的存储过程名称有问题 |
|
|
|
* 处理结果集,将结果集中的存储过程子表替换为原本的存储过程,否则跟随粘贴过去的存储过程名称有问题 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param tableDataMap |
|
|
|
* @param tableDataMap |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static Map<String, TableData> dealWithStoreProcedure(Map<String, TableData> tableDataMap) { |
|
|
|
private static Map<String, TableData> dealWithStoreProcedure(Map<String, TableData> tableDataMap) { |
|
|
|
Map<String, TableData> resultMap = new HashMap<>(); |
|
|
|
Map<String, TableData> resultMap = new HashMap<>(); |
|
|
|
if (tableDataMap == null) { |
|
|
|
if (tableDataMap == null) { |
|
|
|
return resultMap; |
|
|
|
return resultMap; |
|
|
@ -150,7 +163,7 @@ public class TableDataFollowingPasteUtils { |
|
|
|
for (Map.Entry<String, TableDataWrapper> dataWrapperEntry : dataWrapperMap.entrySet()) { |
|
|
|
for (Map.Entry<String, TableDataWrapper> dataWrapperEntry : dataWrapperMap.entrySet()) { |
|
|
|
String tdName = dataWrapperEntry.getKey(); |
|
|
|
String tdName = dataWrapperEntry.getKey(); |
|
|
|
TableData td = dataWrapperEntry.getValue().getTableData(); |
|
|
|
TableData td = dataWrapperEntry.getValue().getTableData(); |
|
|
|
if (ComparatorUtils.equals(td, tableData)) { |
|
|
|
if (td.equals(tableData)) { |
|
|
|
return tdName; |
|
|
|
return tdName; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -179,14 +192,30 @@ public class TableDataFollowingPasteUtils { |
|
|
|
collectTableDataInChartCollection(templateTableData, tempMap, widget); |
|
|
|
collectTableDataInChartCollection(templateTableData, tempMap, widget); |
|
|
|
collectTableDataInElementCaseEditor(templateTableData, tempMap, widget); |
|
|
|
collectTableDataInElementCaseEditor(templateTableData, tempMap, widget); |
|
|
|
} |
|
|
|
} |
|
|
|
// 处理存储过程名称问题
|
|
|
|
return dealWithTableDataMap(tempMap); |
|
|
|
return dealWithStoreProcedure(tempMap); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error("transfer widget tabledata failed", e); |
|
|
|
FineLoggerFactory.getLogger().error("transfer widget tabledata failed", e); |
|
|
|
} |
|
|
|
} |
|
|
|
return new HashMap<>(); |
|
|
|
return new HashMap<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 对Map中所有的TableData做clone处理 |
|
|
|
|
|
|
|
* @param tempMap |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static Map<String, TableData> dealWithTableData4Clone(Map<String, TableData> tempMap) { |
|
|
|
|
|
|
|
Map<String, TableData> resultMap = new HashMap<>(); |
|
|
|
|
|
|
|
for (Map.Entry<String, TableData> entry : tempMap.entrySet()) { |
|
|
|
|
|
|
|
String name = entry.getKey(); |
|
|
|
|
|
|
|
TableData tableData = entry.getValue(); |
|
|
|
|
|
|
|
TableData clonedTableData = cloneTableData(tableData); |
|
|
|
|
|
|
|
if (clonedTableData != null) { |
|
|
|
|
|
|
|
resultMap.put(name, clonedTableData); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return resultMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 收集控件-报表块中使用的数据集 |
|
|
|
* 收集控件-报表块中使用的数据集 |
|
|
|
* |
|
|
|
* |
|
|
@ -353,4 +382,19 @@ public class TableDataFollowingPasteUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
return tableDataPane; |
|
|
|
return tableDataPane; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* clone数据源,如果失败,打印日志,并返回null,谨慎使用 |
|
|
|
|
|
|
|
* @param tableData |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
public static TableData cloneTableData(TableData tableData) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return (TableData) tableData.clone(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e, "clone table data {} failed", tableData.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|