|
|
@ -29,7 +29,6 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
@ -183,7 +182,7 @@ public class IcResiUserController { |
|
|
|
@RequestMapping(value = "/exportExcel2") |
|
|
|
public void exportExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { |
|
|
|
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); |
|
|
|
String staffOrgPath = StrConstant.EPMETY_STR; |
|
|
|
String staffOrgPath = null; |
|
|
|
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { |
|
|
|
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); |
|
|
|
}else{ |
|
|
@ -191,53 +190,9 @@ public class IcResiUserController { |
|
|
|
} |
|
|
|
pageFormDTO.setCustomerId(customerId); |
|
|
|
pageFormDTO.setPageFlag(false); |
|
|
|
CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId()); |
|
|
|
CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId()); |
|
|
|
|
|
|
|
Map<String, Map<String, FormItem>> otherSheetItems = new HashMap<>(); |
|
|
|
|
|
|
|
//主表的
|
|
|
|
for (FormItem formItem : resiFormItems.getItemList()) { |
|
|
|
if (StringUtils.isBlank(formItem.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap); |
|
|
|
if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) { |
|
|
|
itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem); |
|
|
|
} |
|
|
|
if (formItem.getChildGroup() != null) { |
|
|
|
itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap); |
|
|
|
for (FormItem2 item2 : formItem.getChildGroup().getItemList()) { |
|
|
|
if (StringUtils.isBlank(item2.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { |
|
|
|
itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//其他sheet
|
|
|
|
|
|
|
|
for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { |
|
|
|
if (groupItem.getItemList() == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); |
|
|
|
for (FormItem2 formItem2 : groupItem.getItemList()) { |
|
|
|
if (StringUtils.isBlank(formItem2.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) { |
|
|
|
itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems); |
|
|
|
|
|
|
|
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); |
|
|
|
//resiMainList = (List<Map<String, Object>>)JSON.parse("[{\"IS_BDHJ\":\"1\",\"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\"}]");
|
|
|
@ -251,11 +206,11 @@ public class IcResiUserController { |
|
|
|
System.out.println("===resiMainList==="+" "+JSON.toJSONString(resiMainList.values())); |
|
|
|
sheetMap.put(0, mapData); |
|
|
|
AtomicInteger n = new AtomicInteger(); |
|
|
|
for (FormItem item : resiFormItems.getItemList()) { |
|
|
|
for (FormItemResult item : resiFormItems.getItemList()) { |
|
|
|
|
|
|
|
if (item.getChildGroup() != null) { |
|
|
|
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) { |
|
|
|
Map<String, FormItem> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); |
|
|
|
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); |
|
|
|
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); |
|
|
|
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
|
|
|
|
|
|
|
@ -274,8 +229,9 @@ public class IcResiUserController { |
|
|
|
|
|
|
|
@RequestMapping(value = "/exportExcel") |
|
|
|
public void exportExcelByEasyExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { |
|
|
|
//tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02");
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); |
|
|
|
String staffOrgPath = StrConstant.EPMETY_STR; |
|
|
|
String staffOrgPath = null; |
|
|
|
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { |
|
|
|
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); |
|
|
|
}else{ |
|
|
@ -283,53 +239,12 @@ public class IcResiUserController { |
|
|
|
} |
|
|
|
pageFormDTO.setCustomerId(customerId); |
|
|
|
pageFormDTO.setPageFlag(false); |
|
|
|
CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId()); |
|
|
|
|
|
|
|
Map<String, Map<String, FormItem>> otherSheetItems = new HashMap<>(); |
|
|
|
|
|
|
|
//主表的
|
|
|
|
for (FormItem formItem : resiFormItems.getItemList()) { |
|
|
|
if (StringUtils.isBlank(formItem.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap); |
|
|
|
if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) { |
|
|
|
itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem); |
|
|
|
} |
|
|
|
if (formItem.getChildGroup() != null) { |
|
|
|
itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap); |
|
|
|
for (FormItem2 item2 : formItem.getChildGroup().getItemList()) { |
|
|
|
if (StringUtils.isBlank(item2.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { |
|
|
|
itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId()); |
|
|
|
Map<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//其他sheet
|
|
|
|
/*List<FormItemResult> resiFormAllItems = getResiFormAllItems(pageFormDTO.getCustomerId()); |
|
|
|
resiFormAllItems.stream().collect(Collectors.groupingBy(e ->e.get));*/ |
|
|
|
|
|
|
|
for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { |
|
|
|
if (groupItem.getItemList() == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); |
|
|
|
for (FormItem2 formItem2 : groupItem.getItemList()) { |
|
|
|
if (StringUtils.isBlank(formItem2.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) { |
|
|
|
itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); |
|
|
|
|
|
|
@ -346,11 +261,11 @@ public class IcResiUserController { |
|
|
|
|
|
|
|
//=======================================
|
|
|
|
AtomicInteger n = new AtomicInteger(); |
|
|
|
for (FormItem item : resiFormItems.getItemList()) { |
|
|
|
for (FormItemResult item : resiFormItems.getItemList()) { |
|
|
|
|
|
|
|
if (item.getChildGroup() != null) { |
|
|
|
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) { |
|
|
|
Map<String, FormItem> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); |
|
|
|
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); |
|
|
|
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath); |
|
|
|
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
|
|
|
|
|
|
|
@ -365,6 +280,57 @@ public class IcResiUserController { |
|
|
|
excelWriter.finish(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private Map<String, Map<String, FormItemResult>> buildItemMap(CustomerFormResultDTO resiFormItems) { |
|
|
|
Map<String, Map<String, FormItemResult>> otherSheetItems = new HashMap<>(); |
|
|
|
|
|
|
|
//主表的
|
|
|
|
for (FormItemResult formItemResult : resiFormItems.getItemList()) { |
|
|
|
if (StringUtils.isBlank(formItemResult.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, FormItemResult> itemMap = otherSheetItems.getOrDefault(formItemResult.getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(formItemResult.getTableName(), itemMap); |
|
|
|
if (formItemResult.getItemType().equals("checkbox") || formItemResult.getItemType().equals("select") || formItemResult.getItemType().equals("radio")) { |
|
|
|
itemMap.put(formItemResult.getColumnName().concat(formItemResult.getColumnNum() == 0 ? "" : formItemResult.getColumnNum().toString()), formItemResult); |
|
|
|
} |
|
|
|
if (formItemResult.getChildGroup() != null) { |
|
|
|
itemMap = otherSheetItems.getOrDefault(formItemResult.getChildGroup().getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(formItemResult.getChildGroup().getTableName(), itemMap); |
|
|
|
for (FormItemResult2 item2 : formItemResult.getChildGroup().getItemList()) { |
|
|
|
if (StringUtils.isBlank(item2.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { |
|
|
|
itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItemResult.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//其他sheet
|
|
|
|
|
|
|
|
for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { |
|
|
|
if (groupItem.getItemList() == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Map<String, FormItemResult> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); |
|
|
|
otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); |
|
|
|
for (FormItemResult2 formItemResult2 : groupItem.getItemList()) { |
|
|
|
if (StringUtils.isBlank(formItemResult2.getColumnName())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ("checkbox".equals(formItemResult2.getItemType()) || "select".equals(formItemResult2.getItemType()) || "radio".equals(formItemResult2.getItemType())) { |
|
|
|
itemMap.put(formItemResult2.getColumnName().concat(formItemResult2.getColumnNum() == 0 ? "" : formItemResult2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItemResult2, FormItemResult.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return otherSheetItems; |
|
|
|
} |
|
|
|
|
|
|
|
private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception { |
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8"); |
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
@ -449,7 +415,7 @@ public class IcResiUserController { |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private CustomerFormResultDTO getResiFormItems(String customerId) { |
|
|
|
private CustomerFormResultDTO getResiFormAddItems(String customerId) { |
|
|
|
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); |
|
|
|
queryDTO.setFormCode("resi_base_info"); |
|
|
|
queryDTO.setCustomerId(customerId); |
|
|
@ -461,6 +427,19 @@ public class IcResiUserController { |
|
|
|
return resultForm.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private List<FormItemResult> getResiFormAllItems(String customerId) { |
|
|
|
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); |
|
|
|
queryDTO.setFormCode("resi_base_info"); |
|
|
|
queryDTO.setCustomerId(customerId); |
|
|
|
Result<List<FormItemResult>> resultForm = operCustomizeOpenFeignClient.listItems(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(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 个人信息-家庭关系 |
|
|
|
* @Param formDTO |
|
|
|