Browse Source

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

dev_shibei_match
jianjun 4 years ago
parent
commit
9885ccdadd
  1. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  2. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  3. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
  4. 18
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java
  5. 26
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java
  6. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java
  7. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  8. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  9. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java
  10. 28
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  11. 31
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  12. 30
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  13. 74
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  14. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java
  15. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls
  16. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xlsx
  17. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xls
  18. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xlsx

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java

@ -188,8 +188,7 @@ public class BuildingController {
}
List<IcBuildingExcel> result =importResult.getList();
buildingService.importExcel(customerId,result);
return new Result().ok("导入成功");
return new Result().ok(buildingService.importExcel(customerId,result,tokenDTO.getUserId()));
}
/**

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -153,8 +153,7 @@ public class HouseController {
}
List<IcHouseExcel> result =importResult.getList();
houseService.importExcel(customerId,result);
return new Result().ok("导入成功");
return new Result().ok(houseService.importExcel(customerId,result,tokenDTO.getUserId()));
}
@PostMapping( "queryListHouseInfo")

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java

@ -215,7 +215,7 @@ public class NeighborHoodController {
}
List<IcNeighborHoodExcel> result =importResult.getList();
// log.info(JSON.toJSONString(result));
neighborHoodService.importExcel(customerId,result);
neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId());
return new Result();
}

18
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java

@ -93,35 +93,35 @@ public class IcBuildingExcel extends ExcelVerifyInfo implements Serializable {
private Date updatedTime;*/
@Excel(name = "所属组织")
@NotBlank(message = "所属组织不能位空")
@NotBlank(message = "不能为空")
private String agencyName;
@Excel(name = "所属网格")
@NotBlank(message = "所属网格不能位空")
@NotBlank(message = "不能为空")
private String gridName;
@Excel(name = "小区名称")
@NotBlank(message = "小区名称不能位空")
@Length(max=50,message = "小区名称不能超过50个字")
@NotBlank(message = "不能为空")
@Length(max=50,message = "不能超过50个字")
private String neighborHoodName;
@Excel(name = "楼栋名称")
@NotBlank(message = "楼栋名称不能位空")
@NotBlank(message = "不能为空")
private String buildingName;
@Excel(name = "楼栋类型")
@NotBlank(message = "楼栋类型不能位空")
@NotBlank(message = "不能为空")
private String type;
@Excel(name = "单元数")
@NotNull(message = "单元数不能位空")
@NotNull(message = "不能为空")
private Integer totalUnitNum;
@Excel(name = "层数")
@NotNull(message = "层数不能位空")
@NotNull(message = "不能为空")
private Integer totalFloorNum;
@Excel(name = "户数")
@NotNull(message = "户数不能位空")
@NotNull(message = "不能为空")
private Integer totalHouseNum;
}

26
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java

@ -96,52 +96,52 @@ public class IcHouseExcel extends ExcelVerifyInfo implements Serializable {
private Date updatedTime;*/
@Excel(name = "所属组织")
@NotBlank(message = "所属组织不能位空")
@NotBlank(message = "不能为空")
private String agencyName;
@Excel(name = "所属网格")
@NotBlank(message = "所属网格不能位空")
@NotBlank(message = "不能为空")
private String gridName;
@Excel(name = "所属小区")
@NotBlank(message = "小区名称不能位空")
@Length(max=50,message = "小区名称不能超过50个字")
@NotBlank(message = "不能为空")
@Length(max=50,message = "不能超过50个字")
private String neighborHoodName;
@Excel(name = "所属楼栋")
@NotBlank(message = "楼栋名称不能位空")
@NotBlank(message = "不能为空")
private String buildingName;
@Excel(name = "单元号")
@NotNull(message = "单元号不能位空")
@NotNull(message = "不能为空")
private Integer buildingUnit;
@Excel(name = "门牌号")
@NotBlank(message = "门牌号不能位空")
@NotBlank(message = "不能为空")
private String doorName;
@Excel(name = "房屋类型")
@NotBlank(message = "房屋类型不能位空")
@NotBlank(message = "不能为空")
private String houseType;
@Excel(name = "房屋用途")
@NotBlank(message = "房屋用途不能位空")
@NotBlank(message = "不能为空")
private String purpose;
@Excel(name = "出租")
@NotBlank(message = "出租不能位空")
@NotBlank(message = "不能为空")
private String rentFlag;
@Excel(name = "房主姓名")
@NotBlank(message = "房主姓名不能位空")
@NotBlank(message = "不能为空")
private String ownerName;
@Excel(name = "房主电话")
@NotBlank(message = "房主电话不能位空")
@NotBlank(message = "不能为空")
private String ownerPhone;
@Excel(name = "房主身份证")
@NotBlank(message = "房主身份证号不能位空")
@NotBlank(message = "不能为空")
private String ownerIdCard;
}

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java

@ -98,27 +98,27 @@ public class IcNeighborHoodExcel extends ExcelVerifyInfo implements Serializable
@Excel(name = "所属组织")
@NotBlank(message = "所属组织不能位空")
@NotBlank(message = "不能为空")
private String agencyName;
@Excel(name = "所属网格")
@NotBlank(message = "所属网格不能位空")
@NotBlank(message = "不能为空")
private String gridName;
@Excel(name = "小区名称")
@NotBlank(message = "小区名称不能位空")
@Length(max=50,message = "小区名称不能超过50个字")
@NotBlank(message = "不能为空")
@Length(max=50,message = "不能超过50个字")
private String neighborHoodName;
@Excel(name = "关联物业")
private String propertyName;
@Excel(name = "详细地址")
@NotBlank(message = "详细地址不能位空")
@NotBlank(message = "不能为空")
private String address;
@Excel(name = "备注")
@Length(max=500,message = "备注不能超过500个字")
@Length(max=500,message = "不能超过500个字")
private String remark;
}

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java

@ -17,13 +17,13 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcNeighborHoodExcel;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -53,7 +53,7 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(String customerId);
void importExcel(String customerId, List<IcBuildingExcel> list);
Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId);
IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java

@ -17,6 +17,7 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO;
@ -47,7 +48,7 @@ public interface HouseService {
void delHouse(String houseId);
void importExcel(String customerId, List<IcHouseExcel> list);
Result importExcel(String customerId, List<IcHouseExcel> list, String staffId);
IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO);

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java

@ -52,5 +52,5 @@ public interface NeighborHoodService{
*/
void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ;
void importExcel(String customerId,List<IcNeighborHoodExcel> list);
void importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId);
}

28
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java

@ -4,9 +4,12 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.*;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.CustomerStaffAgencyDTO;
@ -207,10 +210,23 @@ public class BuildingServiceImpl implements BuildingService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(String customerId, List<IcBuildingExcel> list) {
public Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
Iterator<IcBuildingExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcBuildingExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return ;
return new Result();
}
//查询所有组织和网格根据名字
@ -235,6 +251,10 @@ public class BuildingServiceImpl implements BuildingService {
entity.setId(uuid);
entity.setCustomerId(customerId);
entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()
if ("".equals(entity.getNeighborHoodId())) {
str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName()));
continue;
}
entity.setBuildingName(icBuildingExcel.getBuildingName());
entity.setType(BuildingTypeEnums.getKeyByValue(icBuildingExcel.getType()));
entity.setSort(0);
@ -266,6 +286,10 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingService.insertBatch(buildingEntityList);
icBuildingUnitService.insertBatch(icBuildingUnitEntityList);
if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}
@Override

31
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java

@ -3,9 +3,12 @@ package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dao.IcHouseDao;
@ -21,6 +24,7 @@ import com.epmet.entity.IcHouseEntity;
import com.epmet.enums.HousePurposeEnums;
import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcHouseExcel;
import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService;
@ -119,10 +123,23 @@ public class HouseServiceImpl implements HouseService {
}
@Override
public void importExcel(String customerId, List<IcHouseExcel> list) {
public Result importExcel(String customerId, List<IcHouseExcel> list, String staffId) {
//2021.11.10 需求变更 当前工作人员只能导致自己所属组织下数据,对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
Iterator<IcHouseExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcHouseExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return ;
return new Result();
}
//获取所有小区 list
// List<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList());
@ -155,7 +172,10 @@ public class HouseServiceImpl implements HouseService {
entity.setBuildingId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingId")).orElse("")));
entity.setBuildingUnitId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingUnitId")).orElse("")));
entity.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName());
if ("".equals(entity.getNeighborHoodId()) || "".equals(entity.getBuildingId()) || "".equals(entity.getBuildingUnitId())) {
str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit()));
continue;
}
entity.setDoorName(icHouseExcel.getDoorName());
entity.setHouseType(HouseTypeEnums.getKeyByValue(icHouseExcel.getHouseType()));
entity.setPurpose(HousePurposeEnums.getKeyByValue(icHouseExcel.getPurpose()));
@ -173,6 +193,11 @@ public class HouseServiceImpl implements HouseService {
//3.保存
icHouseService.insertBatch(houseEntityList);
if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}
@Override

30
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java

@ -4,9 +4,11 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.NeighborhoodConstant;
@ -238,7 +240,19 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(String customerId,List<IcNeighborHoodExcel> list) {
public void importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
Iterator<IcNeighborHoodExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcNeighborHoodExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
iterator.remove();
}
}
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return ;
@ -265,7 +279,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
//同一客户下,小区名称唯一
Integer count = icNeighborHoodDao.checkNameUq(customerId,icNeighborHoodExcel.getNeighborHoodName(),null);
if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg());
throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), icNeighborHoodExcel.getNeighborHoodName()+EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg());
}
IcNeighborHoodEntity entity = new IcNeighborHoodEntity();
@ -274,10 +288,14 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
entity.setCustomerId(customerId);
entity.setNeighborHoodName(icNeighborHoodExcel.getNeighborHoodName());
entity.setAgencyId(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName())).map(u->u.getId()).orElse("")); // agencyMap.get(icNeighborHoodExcel.getAgencyName()).getId());
entity.setParentAgencyId(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName())).map(u->u.getPid()).orElse(""));//agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPid()
entity.setAgencyPids(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName())).map(u->u.getPids()).orElse(""));//agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPids()
entity.setGridId(Optional.ofNullable(gridMap.get(icNeighborHoodExcel.getGridName())).map(u->u.getId()).orElse(""));//gridMap.get(icNeighborHoodExcel.getGridName()).getId()
entity.setAgencyId(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName().trim())).map(u->u.getId()).orElse("")); // agencyMap.get(icNeighborHoodExcel.getAgencyName()).getId());
entity.setParentAgencyId(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName().trim())).map(u->u.getPid()).orElse(""));//agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPid()
entity.setAgencyPids(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName().trim())).map(u->u.getPids()).orElse(""));//agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPids()
entity.setGridId(Optional.ofNullable(gridMap.get(icNeighborHoodExcel.getGridName().trim())).map(u->u.getId()).orElse(""));//gridMap.get(icNeighborHoodExcel.getGridName()).getId()
//网格名对应不上的数据舍弃
if ("".equals(entity.getGridId())) {
continue;
}
entity.setAddress(icNeighborHoodExcel.getAddress());
entity.setRemark(icNeighborHoodExcel.getRemark());
neighborHoodEntityList.add(entity);

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

@ -21,12 +21,12 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.converters.date.DateDateConverter;
import com.alibaba.excel.converters.date.DateStringConverter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillWrapper;
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.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
@ -41,7 +41,6 @@ import com.epmet.dto.result.*;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.service.IcResiUserImportService;
import com.epmet.service.IcResiUserService;
import com.epmet.util.TestFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
@ -223,7 +222,7 @@ public class IcResiUserController {
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions());
//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\"}]");
log.info("resiMainList:{}", JSON.toJSONString(resiMainList));
String templatePath = "excel/ic_resi_info_cid.xlsx";
String templatePath = "excel/ic_resi_info_cid.xls";
TemplateExportParams params = new TemplateExportParams(templatePath, true);
Map<Integer, Map<String, Object>> sheetMap = new HashMap<>();
@ -238,7 +237,7 @@ public class IcResiUserController {
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) {
Map<String, FormItem> 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());
resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
Map<String, Object> mapData2 = new HashMap<>();
mapData2.put("list", resiChildMap.values());
@ -250,7 +249,7 @@ public class IcResiUserController {
Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params);
workbook.setActiveSheet(0);
workbook.write(getOutputStream("居民基本信息.xlsx",response));
workbook.write(getOutputStream("居民基本信息.xls",response));
}
@RequestMapping(value = "/exportExcel2")
@ -308,57 +307,15 @@ public class IcResiUserController {
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions());
//=========================================
// 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
// {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list
// String templatePath = "/excel/ic_resi_info_cid_for_easy_excel.xls";
// String s1 = this.getClass().getResource(templatePath).getPath();
// System.out.println("模版路径:"+s1);
//
// String templateFileName = s1;
// System.out.println("=templateFileName=="+templateFileName);
// String fileName = TestFileUtil.getPath() + "/excel/ic_resi_info_cid_for_easy_excel0000.xls";
// System.out.println(fileName);
// ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build();
// WriteSheet writeSheet = EasyExcel.writerSheet(0).build();
// WriteSheet build = EasyExcel.writerSheet(1).build();
// // 如果有多个list 模板上必须有{前缀.} 这里的前缀就是 data1,然后多个list必须用 FillWrapper包裹
// excelWriter.fill(new FillWrapper("t1", resiMainList.values()), writeSheet);
// excelWriter.fill(new FillWrapper("t2", resiMainList.values()), build);
// 别忘记关闭流
//excelWriter.finish();
//EasyExcel.write(new File(fileName));
//=========================================
//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\"}]");
String originValue = JSON.toJSONString(resiMainList.values());
System.out.println("========="+ originValue);
String templatePath = "/excel/ic_resi_info_cid_for_easy_excel.xls";
String s1 = this.getClass().getResource(templatePath).getPath();
System.out.println("模版路径:"+s1);
//TemplateExportParams params = new TemplateExportParams(templatePath, true);
String fileName = TestFileUtil.getPath() + "compositeFill" + "ic_resi_info_cid_for_easy_excel.xls";
fileName = "/Users/liujianjun/Downloads/ic_resi_info_cid_for_easy_excel2.xls";
System.out.println("fileName======="+fileName);
//String fileName = "居民基本信息.xls";
ExcelWriter excelWriter = EasyExcel.write(getOutputStream(fileName,response)).registerConverter(new DateStringConverter()).registerConverter(new DateDateConverter()).withTemplate(s1).build();
//ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(s1).build();
WriteSheet fistSheet = EasyExcel.writerSheet(0).build();
try {
String templatePath = this.getClass().getResource("/excel/ic_resi_info_cid_for_easy_excel.xls").getPath();
String fileName = "居民基本信息.xls";
ExcelWriter excelWriter = EasyExcel.write(getOutputStream(fileName,response)).withTemplate(templatePath).build();
WriteSheet fistSheet = EasyExcel.writerSheet(NumConstant.ZERO).build();
excelWriter.fill(new FillWrapper("t1", resiMainList.values()), fistSheet);
} catch (Exception e) {
e.printStackTrace();
}
//=======================================
/* Map<Integer, Map<String, Object>> sheetMap = new HashMap<>();
Map<String, Object> mapData = new HashMap<>();
mapData.put("list", resiMainList.values());
System.out.println("========="+JSON.toJSONString(resiMainList.values()));
sheetMap.put(0, mapData);*/
AtomicInteger n = new AtomicInteger();
for (FormItem item : resiFormItems.getItemList()) {
@ -368,10 +325,6 @@ public class IcResiUserController {
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions());
resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
/*Map<String, Object> mapData2 = new HashMap<>();
mapData2.put("list", resiChildMap.values());
System.out.println("========="+JSON.toJSONString(mapData2));
sheetMap.put(n.incrementAndGet(), mapData2);*/
int sheetNo = n.incrementAndGet();
WriteSheet writeSheet = EasyExcel.writerSheet(sheetNo).build();
System.out.println("======"+JSON.toJSONString(resiChildMap.values()));
@ -380,14 +333,8 @@ public class IcResiUserController {
}
}
/* Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params);
workbook.setActiveSheet(0);*/
excelWriter.finish();
/* response.setHeader("content-Type", "application/vnd.ms-excel");
response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));
workbook.write(response.getOutputStream());*/
}
private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception {
fileName = URLEncoder.encode(fileName, "UTF-8");
@ -404,6 +351,7 @@ public class IcResiUserController {
*
* @return
*/
@NoRepeatSubmit
@PostMapping("importExcel")
public void importExcelByEasyExcel(@RequestPart("file") MultipartFile file, HttpServletResponse response) {
if (file.isEmpty()) {

4
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

@ -929,9 +929,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
list.addAll(entry.getValue());
}
//list.forEach(row -> {System.out.println(row.getTableName());row.setSheetName(IcResiUserTableEnums.getObjectByTableName(row.tableName).getTableComment());});
list.forEach(row -> {row.setSheetName(IcResiUserTableEnums.getObjectByTableName(row.tableName).getTableComment());});
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的条目列表","导入失败"),
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的列表","导入失败列表(没有数据说明全部成功)"),
ErrorRow.class, list);
workbook.write(response.getOutputStream());

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.xlsx

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