|
|
@ -144,14 +144,7 @@ public class IcResiUserController { |
|
|
|
|
|
|
|
@GetMapping("download/template") |
|
|
|
public void downloadTemplate(@RequestParam String customerId) throws Exception { |
|
|
|
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); |
|
|
|
queryDTO.setFormCode("resi_base_info"); |
|
|
|
queryDTO.setCustomerId(customerId); |
|
|
|
Result<CustomerFormResultDTO> resultForm = operCustomizeOpenFeignClient.getCustomerForm(queryDTO); |
|
|
|
if (resultForm == null || !resultForm.success() ||resultForm.getData() == null){ |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} |
|
|
|
System.out.println(JSON.toJSONString(resultForm.getData())); |
|
|
|
CustomerFormResultDTO resultForm = getResiFormItems(customerId); |
|
|
|
|
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(); |
|
|
|
Map<String, List<ExcelExportEntity>> sheetHeaderMap = buildHeaderByItem(resultForm); |
|
|
@ -175,11 +168,24 @@ public class IcResiUserController { |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private Map<String,List<ExcelExportEntity>> buildHeaderByItem(Result<CustomerFormResultDTO> resultForm) { |
|
|
|
private CustomerFormResultDTO getResiFormItems(String customerId) { |
|
|
|
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); |
|
|
|
queryDTO.setFormCode("resi_base_info"); |
|
|
|
queryDTO.setCustomerId(customerId); |
|
|
|
Result<CustomerFormResultDTO> resultForm = operCustomizeOpenFeignClient.getCustomerForm(queryDTO); |
|
|
|
if (resultForm == null || !resultForm.success() ||resultForm.getData() == null){ |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} |
|
|
|
System.out.println(JSON.toJSONString(resultForm.getData())); |
|
|
|
return resultForm.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private Map<String,List<ExcelExportEntity>> buildHeaderByItem(CustomerFormResultDTO resultForm) { |
|
|
|
//form中的itemlist 为一级表头 但是要排除每个item中含有childGroup的
|
|
|
|
|
|
|
|
List<FormItem> itemList = resultForm.getData().getItemList(); |
|
|
|
List<FormGroupDTO> groupList = resultForm.getData().getGroupList(); |
|
|
|
List<FormItem> itemList = resultForm.getItemList(); |
|
|
|
List<FormGroupDTO> groupList = resultForm.getGroupList(); |
|
|
|
|
|
|
|
Map<String,List<ExcelExportEntity>> everySheetHeaderMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
@ -196,7 +202,7 @@ public class IcResiUserController { |
|
|
|
firstSheetHeaderList.add(header); |
|
|
|
return; |
|
|
|
} |
|
|
|
everySheetHeaderMap.putIfAbsent(resultForm.getData().getFormName(),firstSheetHeaderList); |
|
|
|
everySheetHeaderMap.putIfAbsent(resultForm.getFormName(),firstSheetHeaderList); |
|
|
|
|
|
|
|
//这些是动态的 formGroup
|
|
|
|
if (item.getChildGroup() != null){ |
|
|
@ -326,29 +332,31 @@ public class IcResiUserController { |
|
|
|
public void exportExcel(/*@LoginUser TokenDto tokenDto,*/ @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws IOException { |
|
|
|
pageFormDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); |
|
|
|
pageFormDTO.setPageFlag(false); |
|
|
|
PageData<Map<String, Object>> mapPageData = icResiUserService.pageResiMap(pageFormDTO); |
|
|
|
List<Map<String, Object>> list = mapPageData.getList(); |
|
|
|
//PageData<Map<String, Object>> mapPageData = icResiUserService.pageResiMap(pageFormDTO);
|
|
|
|
//List<Map<String, Object>> list = mapPageData.getList();
|
|
|
|
List<Map<String, Object>> list = (List<Map<String, Object>>)JSON.parse("[{\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest2\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":null,\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":null,\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":null,\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"},{\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":\"心理咨询\",\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":\"2021-10-28 00:00:00\",\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":\"10180002\",\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"}]" |
|
|
|
); |
|
|
|
Map<String, Object> mapData = new HashMap<>(); |
|
|
|
log.info("list:{}", JSON.toJSONString(list)); |
|
|
|
|
|
|
|
mapData.put("list", list); |
|
|
|
String templatePath = "excel/ic_resi_info_cid.xls"; |
|
|
|
|
|
|
|
CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId()); |
|
|
|
String templatePath = "excel/ic_resi_info_cid.xls"; |
|
|
|
TemplateExportParams params = new TemplateExportParams(templatePath, 0,1); |
|
|
|
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData); |
|
|
|
//header
|
|
|
|
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|
|
|
response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("继续追踪导出详情-" + ".xlsx", "UTF-8")); |
|
|
|
response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("继续追踪导出详情-" + ".xls", "UTF-8")); |
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
|
|
|
|
/* |
|
|
|
//方式1 通过mv导出
|
|
|
|
/* //方式1 通过mv导出
|
|
|
|
ModelAndView mv = new ModelAndView(new EasypoiTemplateExcelView()); |
|
|
|
mv.addObject(TemplateExcelConstants.FILE_NAME, "继续追踪导出详情-".concat(DateUtils.formatDate())); |
|
|
|
mv.addObject(TemplateExcelConstants.PARAMS, new TemplateExportParams(templatePath,dataType)); |
|
|
|
mv.addObject(TemplateExcelConstants.FILE_NAME, "继续追踪导出详情-")); |
|
|
|
mv.addObject(TemplateExcelConstants.PARAMS, new TemplateExportParams(templatePath)); |
|
|
|
mv.addObject(TemplateExcelConstants.MAP_DATA, mapData); |
|
|
|
return mv; |
|
|
|
*/ |
|
|
|
return mv;*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|