Browse Source

Merge branch 'develop' of http://git.elinkit.com.cn:7070/r/epmet-cloud into release_temp

master
jianjun 4 years ago
parent
commit
ef08e7c612
  1. 94
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  2. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  3. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  4. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls
  5. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xls
  6. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx

94
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -68,6 +68,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@ -208,19 +209,22 @@ public class IcResiUserController {
sheetMap.put(0, mapData);
AtomicInteger n = new AtomicInteger();
for (FormItemResult item : resiFormItems.getItemList()) {
//如果 childGroup是空 或者是主表 则跳过 继续下次循环
if (item.getChildGroup() == null || BASE_TABLE_NAME.equals(item.getChildGroup().getTableName())) {
continue;
}
String tableName = item.getChildGroup().getTableName();
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName);
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1, resiMainList, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
Map<String, Object> mapData2 = new HashMap<>();
mapData2.put("list", resiChildMap.values());
System.out.println("===resiChildMap===" + tableName + " " + JSON.toJSONString(resiChildMap.values()));
sheetMap.put(n.incrementAndGet(), mapData2);
if (item.getChildGroup() != null) {
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) {
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName());
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, item.getChildGroup().getTableName(),pageFormDTO,staffInfoCacheResult.getAgencyId(),staffOrgPath);
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
Map<String, Object> mapData2 = new HashMap<>();
mapData2.put("list", resiChildMap.values());
System.out.println("===resiChildMap==="+item.getChildGroup().getTableName()+" "+JSON.toJSONString(resiChildMap.values()));
sheetMap.put(n.incrementAndGet(), mapData2);
}
}
}
Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params);
@ -229,8 +233,8 @@ 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");
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 = null;
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
@ -246,37 +250,61 @@ public class IcResiUserController {
/*List<FormItemResult> resiFormAllItems = getResiFormAllItems(pageFormDTO.getCustomerId());
resiFormAllItems.stream().collect(Collectors.groupingBy(e ->e.get));*/
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), BASE_TABLE_NAME, pageFormDTO,staffInfoCacheResult.getAgencyId(),staffOrgPath);
//=========================================
//读取模版
String templatePath = "excel/ic_resi_info_cid_for_easy_excel.xlsx";
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(templatePath);
String fileName = "居民基本信息.xlsx";
ExcelWriter excelWriter = EasyExcel.write(getOutputStream(fileName,response)).withTemplate(inputStream).build();
FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).build();
WriteSheet fistSheet = EasyExcel.writerSheet(NumConstant.ZERO).build();
System.out.println("===resiMainList==="+" "+JSON.toJSONString(resiMainList.values()));
excelWriter.fill(new FillWrapper("t1", resiMainList.values()),fillConfig, fistSheet);
//=======================================
AtomicInteger n = new AtomicInteger();
for (FormItemResult item : resiFormItems.getItemList()) {
pageFormDTO.setPageNo(NumConstant.ONE);
pageFormDTO.setPageSize(NumConstant.ONE_THOUSAND);
AtomicBoolean isGoon = new AtomicBoolean(true);
Map<String,AtomicBoolean> childTableIsGoonMap = new HashMap<>();
Map<String,WriteSheet> childTableWriteSheetMap = new HashMap<>();
do {
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), BASE_TABLE_NAME, pageFormDTO,staffInfoCacheResult.getAgencyId(),staffOrgPath);
//如果 返回的条数小于每页显示的数 则退出查询
if (resiMainList.keySet().size()<pageFormDTO.getPageSize()){
isGoon.set(false);
}
if (item.getChildGroup() != null) {
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) {
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName());
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList,item.getChildGroup().getTableName() , pageFormDTO, staffInfoCacheResult.getAgencyId(),staffOrgPath);
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
System.out.println("===resiMainList==="+" "+JSON.toJSONString(resiMainList.values()));
//写入数据
excelWriter.fill(new FillWrapper("t1", resiMainList.values()),fillConfig, fistSheet);
int sheetNo = n.incrementAndGet();
WriteSheet writeSheet = EasyExcel.writerSheet(sheetNo).build();
System.out.println("===resiChildMap==="+item.getChildGroup().getTableName()+" "+JSON.toJSONString(resiChildMap.values()));
excelWriter.fill(new FillWrapper("t"+(sheetNo+1), resiChildMap.values()), writeSheet);
//子表数据写入
AtomicInteger n = new AtomicInteger();
for (FormItemResult item : resiFormItems.getItemList()) {
//如果 childGroup是空 或者是主表 则跳过 继续下次循环
if (item.getChildGroup() == null || BASE_TABLE_NAME.equals(item.getChildGroup().getTableName())) {
continue;
}
String tableName = item.getChildGroup().getTableName();
AtomicBoolean childIsGoon = childTableIsGoonMap.getOrDefault(tableName, new AtomicBoolean(true));
if (!childIsGoon.get()){
continue;
}
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName);
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1, resiMainList, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
//如果 返回的条数小于每页显示的数 则退出查询
if (resiChildMap.keySet().size()<pageFormDTO.getPageSize()){
childIsGoon.set(false);
}
System.out.println("===resiChildMap===" + tableName + " " + JSON.toJSONString(resiChildMap.values()));
//构建新的sheet
WriteSheet childWriteSheet = childTableWriteSheetMap.getOrDefault(tableName, EasyExcel.writerSheet(n.incrementAndGet()).build());
//int sheetNo = n.incrementAndGet();
//WriteSheet writeSheet = EasyExcel.writerSheet(sheetNo).build();
//写入数据
excelWriter.fill(new FillWrapper("t" + (n.get() + 1), resiChildMap.values()), childWriteSheet);
}
}
pageFormDTO.setPageNo(pageFormDTO.getPageNo()+1);
}while (isGoon.get());
excelWriter.finish();

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java

@ -108,7 +108,7 @@ public interface IcResiUserService extends BaseService<IcResiUserEntity> {
* @param itemList
* @param resiMainList
* @param baseTableName
* @return
* @return Map<String,Map<String,Object>> 用户Id用户信息所有的字段名及值
*/
Map<String, Map<String, Object>> getDataForExport(Map<String, FormItemResult> itemList, Map<String, Map<String, Object>> resiMainList, String baseTableName, IcResiUserPageFormDTO pageFormDTO, String currentStaffAgencyId,
String staffOrgPath);

6
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -50,6 +50,7 @@ import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.service.IcResiUserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
@ -621,7 +622,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
public Map<String, Map<String, Object>> getDataForExport(Map<String, FormItemResult> formItemMap, Map<String, Map<String, Object>> resiMainList, String baseTableName,IcResiUserPageFormDTO pageFormDTO,
String currentStaffAgencyId,
String staffOrgPath) {
List<Map<String, Object>> mapList = this.dynamicQuery(pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), baseTableName, pageFormDTO.getConditions(),currentStaffAgencyId,staffOrgPath);
Page<Map<String, Object>> mapListPage = PageHelper.startPage(pageFormDTO.getPageNo(), pageFormDTO.getPageSize(), pageFormDTO.getPageFlag()).doSelectPage(() -> {
this.dynamicQuery(pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), baseTableName, pageFormDTO.getConditions(), currentStaffAgencyId, staffOrgPath);
});
List<Map<String, Object>> mapList = mapListPage.getResult();
Map<String, Map<String, Object>> result = new LinkedHashMap<>();
mapList.stream().filter(Objects::nonNull).forEach(map -> {
//遍历所有字段 格式化时间字段

BIN
epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls

Binary file not shown.

BIN
epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xls

Binary file not shown.

BIN
epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx

Binary file not shown.
Loading…
Cancel
Save