diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java index 83d6f590e0..2ee335dace 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result; +import cn.afterturn.easypoi.excel.annotation.Excel; import lombok.Data; import java.io.Serializable; @@ -16,23 +17,43 @@ public class IcHouseListResultDTO implements Serializable { private static final long serialVersionUID = 4963952996288796744L; private String houseId; - private String ownerPhone; - private String purpose; + private String doorName; - private String houseType; - private String unitNum; + private String agencyId; private String buildingId; private String houseName; - private String buildingName; + private String rentFlag; - private String ownerName; + private String neighborHoodId; private String purposeKey; - private String neighborHoodName; + private String unitNumKey; + @Excel(name = "所属组织") + private String agencyName; + @Excel(name = "所属网格") + private String gridName; + @Excel(name = "所属小区") + private String neighborHoodName; + @Excel(name = "所属楼栋") + private String buildingName; + @Excel(name = "单元号") + private String unitNum; + @Excel(name = "房屋类型") + private String houseType; + @Excel(name = "房屋用途") + private String purpose; + @Excel(name = "是否出租") + private Integer rentFlagKey; + @Excel(name = "房主姓名") + private String ownerName; + @Excel(name = "房主电话") + private String ownerPhone; + @Excel(name = "房主身份证") private String ownerIdCard; private String gridId; + private String houseTypeKey; - private Integer rentFlagKey; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 957e1f7c90..a4d675a279 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -18,7 +18,6 @@ package com.epmet.controller; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; -import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; @@ -36,7 +35,6 @@ import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcHouseListResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.LoginUserDetailsResultDTO; -import com.epmet.excel.IcHouseExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.HouseService; @@ -44,16 +42,14 @@ import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.io.InputStream; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; /** @@ -170,11 +166,8 @@ public class HouseController implements ResultDataResolver { */ @PostMapping("exporttemplate") public void exportTemplate(HttpServletResponse response) throws Exception { -// ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); TemplateExportParams templatePath = new TemplateExportParams("excel/house_template.xlsx"); - Map map = new HashMap<>(); - map.put("maplist", new ArrayList()); - ExcelPoiUtils.exportExcel(templatePath, map, "房屋信息录入表", response); + ExcelPoiUtils.exportExcel(templatePath, null, "房屋信息录入表", response); } @@ -188,50 +181,11 @@ public class HouseController implements ResultDataResolver { @RequestMapping("exporthouseinfo") public void exporthouseinfo(@RequestBody IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { ValidatorUtils.validateEntity(formDTO); + formDTO.setIsPage(false); houseService.exportBuildinginfo(formDTO, response); } - /** - * 导入数据 - * - * @param file - * @return - * @throws IOException - */ - @PostMapping("import") - public Result importExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file) throws IOException { - - String customerId = tokenDTO.getCustomerId(); -// String customerId = "123123"; - - ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcHouseExcel.class); - - List failList = importResult.getFailList(); - - //存放错误数据行号 - List numList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(failList)) { - for (IcHouseExcel entity : failList) { - log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());//打印失败的行 和失败的信息 - numList.add(entity.getRowNum()); - } - } - List result = importResult.getList(); - - List resultList = houseService.importExcel(customerId, result, tokenDTO.getUserId(), numList); - String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - resultList.size()); - if (resultList.size() > NumConstant.ZERO) { - Collections.sort(resultList); - String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); - log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!"); - } - return new Result().ok(str); - } - - - @PostMapping("queryListHouseInfo") Result> queryListHouseInfo(@RequestBody Set houseIds, @RequestParam("customerId") String customerId) { return new Result>().ok(houseService.queryListHouseInfo(houseIds, customerId)); @@ -240,7 +194,7 @@ public class HouseController implements ResultDataResolver { @PostMapping("houseimport") public Result houseImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, @RequestParam("orgId") String orgId, - @RequestParam("orgType") String orgType, HttpServletRequest multipartRequest) { + @RequestParam("orgType") String orgType) { ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setOrgType(orgType); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index 4e8353d993..3b7428dd8b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -8,7 +8,6 @@ import com.epmet.dto.result.HousesNameResultDTO; import com.epmet.dto.result.IcHouseListResultDTO; import com.epmet.dto.result.NeighborHoodManageDelResultDTO; import com.epmet.entity.IcHouseEntity; -import com.epmet.excel.IcHouseExcel; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -26,8 +25,6 @@ public interface IcHouseDao extends BaseDao { List searchHouseByPage(IcHouseListFormDTO formDTO); - List searchAllHouse(@Param("house") IcHouseEntity house); - List queryHouseInfo(@Param("houseIdList") Set houseIdList); HouseInfoDTO queryHouseInfoByHouseId(@Param("houseId") String houseId); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java index be716f7c94..740892f4cd 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java @@ -38,7 +38,7 @@ public class HouseInfoModel { @ExcelProperty(value = "房屋用途") private String purpose; - @ExcelProperty(value = "出租") + @ExcelProperty(value = "房屋状态") private String rentFlagString; @ExcelProperty(value = "房主姓名") diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index 56a8722a1c..bc9af52b79 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -20,13 +20,12 @@ package com.epmet.service; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.IcHouseAddFormDTO; -import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.IcHouseListFormDTO; +import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.NeighborHoodManageDelFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcHouseListResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; -import com.epmet.excel.IcHouseExcel; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; @@ -52,9 +51,6 @@ public interface HouseService { */ void delHouse(String houseId); - - List importExcel(String customerId, List list, String staffId, List numList); - PageData getHouseList(IcHouseListFormDTO formDTO); void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 0c8b368b1c..8491d853f9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -6,7 +6,6 @@ import com.alibaba.excel.ExcelReader; import com.alibaba.excel.read.metadata.ReadSheet; 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.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -14,7 +13,6 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; -import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; @@ -35,7 +33,6 @@ import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.NeighborHoodManageDelResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.enums.HousePurposeEnums; -import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; import com.epmet.excel.IcHouseExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; @@ -163,92 +160,6 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { allDelete(formDTO); } - @Override - @Transactional(rollbackFor = Exception.class) - public List importExcel(String customerId, List list, String staffId, List numList) { - //2021.11.10 需求变更 当前工作人员只能导致自己所属组织下数据,对应不上的数据舍弃【注:需求就这样】 sun - CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); - //组织名称不一样的数据舍弃 - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - IcHouseExcel obj = iterator.next(); - if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { - numList.add(obj.getRowNum()); - iterator.remove(); - } - } - //用于存储匹配不上的数据给前端的提示 如南宁社区不存在 - //StringBuffer str = new StringBuffer(""); - //end sun - //导入 - if(CollectionUtils.isEmpty(list)){ - return numList; - } - //获取所有小区 list -// List neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList()); -// List neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList)); -// Map neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1)); - - //获取所有楼宇 list -// List buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toList()); - -// icBuildingDao.selectList(new QueryWrapper().lambda().in(IcBuildingEntity::getBuildingName, buildingNameList).in(); - Set neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); - Set buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet()); - Set buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet()); - List> buildMapList = icBuildingDao.selectListByName(customerId, new ArrayList(neighborNameList),new ArrayList(buildingNameList),new ArrayList(buildingUnitList)); - //转Map - Map> buildMap = new HashMap<>(); - buildMapList.forEach(item->{ - buildMap.put(item.get("neighborName")+","+item.get("buildingName")+","+item.get("unitNum"),item); - }); - //封装数据 - List houseEntityList = new ArrayList<>(); - Iterator iterator1 = list.iterator(); - while (iterator1.hasNext()) { - IcHouseExcel icHouseExcel = iterator1.next(); - IcHouseEntity entity = new IcHouseEntity(); - String uuid = UUID.randomUUID().toString().replace("-", ""); - entity.setId(uuid); - entity.setCustomerId(customerId); - Map item = buildMap.get(icHouseExcel.getNeighborHoodName()+","+icHouseExcel.getBuildingName()+","+icHouseExcel.getBuildingUnit()); - - entity.setNeighborHoodId(String.valueOf(Optional.ofNullable(item).map(u->u.get("neighborId")).orElse(""))); - 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())); - numList.add(icHouseExcel.getRowNum()); - iterator1.remove(); - continue; - } - entity.setDoorName(icHouseExcel.getDoorName()); - entity.setHouseType(HouseTypeEnums.getKeyByValue(icHouseExcel.getHouseType())); - entity.setPurpose(HousePurposeEnums.getKeyByValue(icHouseExcel.getPurpose())); - entity.setRentFlag(HouseRentFlagEnums.getCodeByName(icHouseExcel.getRentFlag())); - entity.setOwnerName(icHouseExcel.getOwnerName()); - entity.setOwnerPhone(icHouseExcel.getOwnerPhone()); - entity.setOwnerIdCard(icHouseExcel.getOwnerIdCard()); - //同一楼栋,单元内,房屋名称唯一 - Integer count = icHouseDao.checkDoorNameUq(entity.getNeighborHoodId(), entity.getBuildingId(), entity.getBuildingUnitId(), entity.getDoorName(),null); - if (null != count && count > 0) { - //throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); - log.error(EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); - numList.add(icHouseExcel.getRowNum()); - iterator1.remove(); - continue; - } - houseEntityList.add(entity); - } - //3.保存 - icHouseService.insertBatch(houseEntityList); - - - return numList; - - } - @Override public PageData getHouseList(IcHouseListFormDTO formDTO) { @@ -293,50 +204,14 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { public void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { //如果类型是house 查房屋 //导出房屋 - - List icHouseExcels = searchAllHouse(formDTO); + PageData icHouseExcels = getHouseList(formDTO); TemplateExportParams templatePath = new TemplateExportParams("excel/house_export.xlsx"); Map map = new HashMap<>(); - map.put("maplist",icHouseExcels); + map.put("maplist",icHouseExcels.getList()); ExcelPoiUtils.exportExcel(templatePath ,map,"房屋信息录入表",response); return ; } - private List searchAllHouse(IcHouseListFormDTO formDTO) { - - //IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); - // - //IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class); - - - IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class); - house.setDelFlag("0"); - - List icHouseExcels = icHouseDao.searchAllHouse(house); - icHouseExcels.forEach(item->{ - item.setHouseType(HouseTypeEnums.getTypeValue(item.getHouseType())); - item.setPurpose(HousePurposeEnums.getTypeValue(item.getPurpose())); - }); - return icHouseExcels; - } - - /*private IPage> searchHouse(String buildingId, - String ownerName, - String ownerPhone, - String neighborHoodName, - String buildingName, - Integer pageNo, - Integer pageSize) { - IPage page = new Page(pageNo,pageSize); - - IPage> mapIPage = icHouseDao.searchHouseByPage(page, buildingId, ownerName, ownerPhone, neighborHoodName, buildingName); - List> records = mapIPage.getRecords(); - records.forEach(item->{ - item.put("houseType", HouseTypeEnums.getTypeValue(item.get("houseTypeKey"))); - item.put("purpose", HousePurposeEnums.getTypeValue(item.get("purposeKey"))); - }); - return mapIPage; - }*/ @Override public List queryListHouseInfo(Set houseIdList, String customerId) { diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx index 815e222273..eb163082f3 100644 Binary files a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx index 0f58eff1d8..cf5681e1f4 100644 Binary files a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index ab43322f81..515b5df72f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -75,15 +75,13 @@ a.HOUSE_NAME as houseName, c.NEIGHBOR_HOOD_NAME as neighborHoodName, b.BUILDING_NAME as buildingName, - d.UNIT_NUM as unitNum, + CONCAT(d.UNIT_NUM,'单元') as unitNum, a.DOOR_NAME as doorName, (case when a.RENT_FLAG = '0' then '自住' when a.RENT_FLAG = '1' then '出租' when a.RENT_FLAG = '2' then '闲置' else '' end) as rentFlag, a.OWNER_NAME as ownerName, - /*a.RENT_FLAG as rentFlag, - a.PURPOSE as purpose,*/ a.OWNER_PHONE as ownerPhone, a.OWNER_ID_CARD as ownerIdCard, @@ -95,11 +93,15 @@ a.PURPOSE as purposeKey, CAST(a.RENT_FLAG AS CHAR) as rentFlagKey, c.AGENCY_ID as agencyId, - c.GRID_ID as gridId + ag.ORGANIZATION_NAME agencyName, + c.GRID_ID as gridId, + gr.GRID_NAME from ic_house a LEFT JOIN ic_building b on a.BUILDING_ID = b.ID and b.DEL_FLAG = '0' LEFT JOIN ic_neighbor_hood c on a.NEIGHBOR_HOOD_ID = c.ID and c.DEL_FLAG = '0' LEFT JOIN ic_building_unit d on a.BUILDING_UNIT_ID = d.ID and d.DEL_FLAG = '0' + LEFT JOIN customer_grid gr on gr.ID = c.GRID_ID and d.DEL_FLAG = '0' + LEFT JOIN customer_agency ag on ag.ID = c.AGENCY_ID and d.DEL_FLAG = '0' 1 = 1 @@ -145,44 +147,6 @@ CAST(a.DOOR_NAME AS SIGNED), CONVERT(a.DOOR_NAME using gbk) - -