|
@@ -107,27 +107,27 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
String tableName = commonEntity.getQueryMap().get("tableName").toString();
|
|
|
//查询标题信息
|
|
|
TableSql tableSql = tableSqlMapper.selectTableSqlByTSqlKey(sqlKey);
|
|
|
+
|
|
|
//查询列表信息
|
|
|
-// List<CommonEntity> commonEntities = commonMapper.selectList(tableName, new HashMap<>());
|
|
|
- List<CommonEntity> commonEntities = new ArrayList<>();
|
|
|
- CommonEntity commonEntity1 = new CommonEntity();
|
|
|
+ List<Map<String,Object>> mapList = null;
|
|
|
//根据条件获取列表信息
|
|
|
- if (StringUtils.hasLength(commonEntity.getExeclMap().get("dataList").toString())) {
|
|
|
- for (CommonEntity dataList : (List<CommonEntity>) commonEntity.getExeclMap().get("dataList")) {
|
|
|
- System.out.println(dataList);
|
|
|
- commonEntities.add(dataList);
|
|
|
- }
|
|
|
+ if (commonEntity.getExeclMap().size()>0) {
|
|
|
+ mapList = commonEntity.getExeclMap();
|
|
|
} else {
|
|
|
- commonEntities = queryTableList(commonEntity, tableSql);
|
|
|
+ List<Map<String,Object>> maps = new ArrayList<>();
|
|
|
+ List<CommonEntity> commonEntities = queryTableList(commonEntity, tableSql);
|
|
|
+ commonEntities.stream().forEach(c -> maps.add(c.getResultMap()));
|
|
|
+ mapList = maps;
|
|
|
}
|
|
|
- commonEntities.add(commonEntity1);
|
|
|
+
|
|
|
//获取列表标题和字段
|
|
|
Map<String, String> map = (Map) JSONObject.parseObject(tableSql.getTableExportField());
|
|
|
// 创建Excel文档
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
- XSSFSheet sheet = workbook.createSheet("Sheet10");
|
|
|
-
|
|
|
+ XSSFSheet sheet = workbook.createSheet("Sheet1");
|
|
|
+ //标题
|
|
|
List<String> titleList = new ArrayList<>();
|
|
|
+ //字段
|
|
|
List<String> fieldList = new ArrayList<>();
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
fieldList.add(entry.getKey());
|
|
@@ -140,10 +140,10 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
}
|
|
|
int rowIndex = 1;
|
|
|
//获取列表信息
|
|
|
- for (int w = 0; w < commonEntities.size(); w++) {
|
|
|
+ for (int w = 0; w < mapList.size(); w++) {
|
|
|
XSSFRow row = sheet.createRow(rowIndex++);
|
|
|
for (int e = 0; e < fieldList.size(); e++) {
|
|
|
- Object val = commonEntities.get(w).getResultMap().get(toUnderScoreCase(fieldList.get(e)));
|
|
|
+ Object val = mapList.get(w).get(toUnderScoreCase(fieldList.get(e)));
|
|
|
row.createCell(e).setCellValue((val == null ? "" : val).toString());
|
|
|
}
|
|
|
}
|