|
|
@ -46,7 +46,6 @@ import com.epmet.excel.IcResiUserExcel; |
|
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
import com.epmet.service.IcResiUserService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.usermodel.Name; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -152,14 +151,15 @@ public class IcResiUserController { |
|
|
|
for (Map.Entry<String, List<ExcelExportEntity>> entry : sheetHeaderMap.entrySet()) { |
|
|
|
String sheetName = entry.getKey(); |
|
|
|
List<ExcelExportEntity> headers = entry.getValue(); |
|
|
|
ExportParams exportParams = new ExportParams(); |
|
|
|
exportParams.setSheetName(sheetName); |
|
|
|
exportParams.setAutoSize(true); |
|
|
|
new ExcelExportService().createSheetForMap(workbook, exportParams, headers,new ArrayList<>()); |
|
|
|
System.out.println("headers:"+sheetName+JSON.toJSONString(headers)); |
|
|
|
ExportParams exportParams = new ExportParams(null,sheetName); |
|
|
|
//exportParams.setAutoSize(true);
|
|
|
|
List<Map<String,String>> dataSet = new ArrayList<>(); |
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
|
map.put("1","2"); |
|
|
|
dataSet.add(map); |
|
|
|
new ExcelExportService().createSheetForMap(workbook, exportParams, headers, dataSet); |
|
|
|
} |
|
|
|
List<? extends Name> allNames = workbook.getAllNames(); |
|
|
|
System.out.println("======"+allNames); |
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream fos = new FileOutputStream("//Users/liujianjun/Downloads/基础信息表/Dow.tt.xls"); |
|
|
|
workbook.write(fos); |
|
|
@ -176,38 +176,38 @@ public class IcResiUserController { |
|
|
|
Map<String,List<ExcelExportEntity>> everySheetHeaderMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
List<ExcelExportEntity> firstSheetHeaderList = new ArrayList<>(); |
|
|
|
//Map<String, String> groupNameMap = groupList.stream().collect(Collectors.toMap(FormGroupDTO::getGroupId,FormGroupDTO::getLabel));
|
|
|
|
itemList.forEach(item->{ |
|
|
|
if (StringUtils.isBlank(item.getColumnName())){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getColumnName().concat(String.valueOf(item.getColumnNum())),30); |
|
|
|
header.setNeedMerge(true); |
|
|
|
if (item.getChildGroup() == null){ |
|
|
|
System.out.println(item.getLabel()); |
|
|
|
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getColumnName().concat(String.valueOf(item.getColumnNum())),30); |
|
|
|
header.setNeedMerge(true); |
|
|
|
firstSheetHeaderList.add(header); |
|
|
|
return; |
|
|
|
} |
|
|
|
everySheetHeaderMap.putIfAbsent(resultForm.getData().getFormName(),firstSheetHeaderList); |
|
|
|
|
|
|
|
//这些是动态的 formGroup
|
|
|
|
if (item.getChildGroup() != null){ |
|
|
|
//baseTableName单独的一个sheet
|
|
|
|
System.out.println("childGroup:"+item.getLabel()); |
|
|
|
if (BASE_TABLE_NAME.equals(item.getTableName())){ |
|
|
|
header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName()); |
|
|
|
header.setNeedMerge(true); |
|
|
|
// header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName());
|
|
|
|
//header.setNeedMerge(true);
|
|
|
|
List<ExcelExportEntity> otherSheetHeaderList = new ArrayList<>(); |
|
|
|
List<ExcelExportEntity> secondHeaderList = new ArrayList<>(); |
|
|
|
//这里是设置除基础信息之外的sheet的表头
|
|
|
|
item.getChildGroup().getItemList().forEach(item2->{ |
|
|
|
if (!BASE_TABLE_NAME.equals(item2.getTableName())){ |
|
|
|
|
|
|
|
everySheetHeaderMap.putIfAbsent(item.getLabel(),otherSheetHeaderList); |
|
|
|
} |
|
|
|
ExcelExportEntity secondHeader = new ExcelExportEntity(item2.getLabel(),item2.getColumnName().concat(String.valueOf(item2.getColumnNum()))); |
|
|
|
secondHeader.setNeedMerge(true); |
|
|
|
secondHeaderList.add(secondHeader); |
|
|
|
if (!item2.getItemType().equals("radio") && com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(item2.getOptions())){ |
|
|
|
|
|
|
|
otherSheetHeaderList.add(secondHeader); |
|
|
|
if (!"radio".equals(item2.getItemType()) && CollectionUtils.isNotEmpty(item2.getOptions())){ |
|
|
|
secondHeader.setNeedMerge(true); |
|
|
|
List<ExcelExportEntity> thirdHeaderList = new ArrayList<>(); |
|
|
|
item2.getOptions().forEach(child->{ |
|
|
|
ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel()); |
|
|
@ -217,18 +217,16 @@ public class IcResiUserController { |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
header.setList(secondHeaderList); |
|
|
|
otherSheetHeaderList.add(header); |
|
|
|
//header.setList(secondHeaderList);
|
|
|
|
//otherSheetHeaderList.add(header);
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//List<ExcelExportEntity> firstSheetHeaderList = new ArrayList<>();
|
|
|
|
groupList.forEach(item->{ |
|
|
|
/* if (!"兴趣爱好".equals(item.getLabel()) && !"宗教信仰".equals(item.getLabel())){ |
|
|
|
return; |
|
|
|
}*/ |
|
|
|
if (!BASE_TABLE_NAME.equals(item.getTableName())){ |
|
|
|
System.out.println(item.getLabel()+"--"+item.getTableName()); |
|
|
|
if (!BASE_TABLE_NAME.equals(item.getTableName())){ |
|
|
|
return; |
|
|
|
} |
|
|
|
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getTableName()); |
|
|
|