Browse Source

Merge remote-tracking branch 'origin/dev_optimize' into develop

dev
yinzuomei 3 years ago
parent
commit
e12a07e921
  1. 37
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseListResultDTO.java
  2. 58
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  3. 48
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcBuildingController.java
  4. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java
  5. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java
  6. 147
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java
  7. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java
  8. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  9. 24
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  10. 131
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  11. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx
  12. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx
  13. 48
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml

37
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;
}

58
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<String, Object> map = new HashMap<>();
map.put("maplist", new ArrayList<IcHouseExcel>());
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<IcHouseExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcHouseExcel.class);
List<IcHouseExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if (!CollectionUtils.isEmpty(failList)) {
for (IcHouseExcel entity : failList) {
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
}
List<IcHouseExcel> result = importResult.getList();
List<Integer> 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<List<HouseInfoDTO>> queryListHouseInfo(@RequestBody Set<String> houseIds, @RequestParam("customerId") String customerId) {
return new Result<List<HouseInfoDTO>>().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);

48
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcBuildingController.java

@ -18,20 +18,16 @@
package com.epmet.controller;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcBuildingDTO;
import com.epmet.service.IcBuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
@ -47,42 +43,6 @@ public class IcBuildingController {
@Autowired
private IcBuildingService icBuildingService;
@GetMapping("page")
public Result<PageData<IcBuildingDTO>> page(@RequestParam Map<String, Object> params){
PageData<IcBuildingDTO> page = icBuildingService.page(params);
return new Result<PageData<IcBuildingDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<IcBuildingDTO> get(@PathVariable("id") String id){
IcBuildingDTO data = icBuildingService.get(id);
return new Result<IcBuildingDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody IcBuildingDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
icBuildingService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody IcBuildingDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
icBuildingService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
icBuildingService.delete(ids);
return new Result();
}
/**
* @Description 获取小区内的楼栋
* @Param dto

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java

@ -21,6 +21,7 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.form.HouseFormDTO;
import com.epmet.dto.result.HouseListResultDTO;
import com.epmet.dto.result.HousesNameResultDTO;
@ -44,6 +45,12 @@ public class IcHouseController {
@Autowired
private IcHouseService icHouseService;
@GetMapping("{id}")
public Result<IcHouseDTO> get(@PathVariable("id") String id){
IcHouseDTO data = icHouseService.get(id);
return new Result<IcHouseDTO>().ok(data);
}
@PostMapping("houseoption")
public Result<List<OptionResultDTO>> getHouseOption(@RequestBody HouseFormDTO formDTO){
return new Result<List<OptionResultDTO>>().ok(icHouseService.getHouseOption(formDTO));

3
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<IcHouseEntity> {
List<IcHouseListResultDTO> searchHouseByPage(IcHouseListFormDTO formDTO);
List<IcHouseExcel> searchAllHouse(@Param("house") IcHouseEntity house);
List<HouseInfoDTO> queryHouseInfo(@Param("houseIdList") Set<String> houseIdList);
HouseInfoDTO queryHouseInfoByHouseId(@Param("houseId") String houseId);

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

@ -1,147 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.util.ExcelVerifyInfo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 房屋信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
@Data
public class IcHouseExcel extends ExcelVerifyInfo implements Serializable {
/*@Excel(name = "房屋主键")
private String id;
@Excel(name = "客户id")
private String customerId;
@Excel(name = "小区id")
private String neighborHoodId;
@Excel(name = "片区id,neighbor_hood_part.id,可为空。")
private String partId;
@Excel(name = "所属楼栋id")
private String buildingId;
@Excel(name = "所属单元id")
private String buildingUnitId;
@Excel(name = "房屋名字后台插入时生成")
private String houseName;
@Excel(name = "门牌号")
private String doorName;
@Excel(name = "房屋类型,这里存储字典value就可以")
private String houseType;
@Excel(name = "存储字典value")
private String purpose;
@Excel(name = "1出租;0未出租")
private Integer rentFlag;
@Excel(name = "房主姓名")
private String ownerName;
@Excel(name = "房主电话")
private String ownerPhone;
@Excel(name = "房主身份证号")
private String ownerIdCard;
@Excel(name = "删除标识 0未删除、1已删除")
private String delFlag;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;*/
@Excel(name = "所属组织")
@NotBlank(message = "不能为空")
private String agencyName;
@Excel(name = "所属网格")
@NotBlank(message = "不能为空")
private String gridName;
@Excel(name = "所属小区")
@NotBlank(message = "不能为空")
@Length(max=50,message = "不能超过50个字")
private String neighborHoodName;
@Excel(name = "所属楼栋")
@NotBlank(message = "不能为空")
private String buildingName;
@Excel(name = "单元号")
@NotNull(message = "不能为空")
private Integer buildingUnit;
@Excel(name = "门牌号")
@NotBlank(message = "不能为空")
private String doorName;
@Excel(name = "房屋类型")
@NotBlank(message = "不能为空")
private String houseType;
@Excel(name = "房屋用途")
@NotBlank(message = "不能为空")
private String purpose;
@Excel(name = "出租")
@NotBlank(message = "不能为空")
private String rentFlag;
@Excel(name = "房主姓名")
@NotBlank(message = "不能为空")
private String ownerName;
@Excel(name = "房主电话")
@NotBlank(message = "不能为空")
private String ownerPhone;
@Excel(name = "房主身份证")
@NotBlank(message = "不能为空")
private String ownerIdCard;
}

2
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 = "房主姓名")

6
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<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList);
PageData<IcHouseListResultDTO> getHouseList(IcHouseListFormDTO formDTO);
void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception;

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

@ -23,7 +23,10 @@ import com.epmet.dao.*;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.IcBuildingDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcBuildingListResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.*;
import com.epmet.enums.BuildingTypeEnums;
import com.epmet.excel.IcBuildingExcel;
@ -31,7 +34,10 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.model.BuildingInfoModel;
import com.epmet.model.ImportBuildingInfoListener;
import com.epmet.redis.IcHouseRedis;
import com.epmet.service.*;
import com.epmet.service.BuildingService;
import com.epmet.service.IcBuildingService;
import com.epmet.service.IcBuildingUnitService;
import com.epmet.service.IcNeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -44,7 +50,6 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.ExecutorService;
@ -60,15 +65,10 @@ public class BuildingServiceImpl implements BuildingService {
private IcBuildingService icBuildingService;
@Resource
private IcBuildingDao icBuildingDao;
@Autowired
private IcBuildingUnitService icBuildingUnitService;
@Resource
private IcHouseDao icHouseDao;
@Autowired
private IcHouseService icHouseService;
@Resource
private CustomerAgencyDao customerAgencyDao;
@Resource
@ -76,8 +76,6 @@ public class BuildingServiceImpl implements BuildingService {
@Resource
private IcNeighborHoodDao icNeighborHoodDao;
@Resource
private CustomerStaffAgencyDao customerStaffAgencyDao;
@Resource
private IcBuildingUnitDao icBuildingUnitDao;
@Autowired
private IcHouseRedis icHouseRedis;
@ -112,7 +110,7 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingUnit.setUnitNum(String.valueOf(i+1));
unitList.add(icBuildingUnit);
}
icBuildingUnitService.insertBatch(unitList);
icBuildingUnitService.insertBatch(unitList, NumConstant.ONE_HUNDRED);
}
@ -428,12 +426,12 @@ public class BuildingServiceImpl implements BuildingService {
* 3. 选中小区可导入该小区下所有楼宇信息房屋信息没有匹配的楼宇均新增
* 4. 选中楼宇可导入该楼宇下所有房屋信息
* @param formDTO
* @param file
* @param inputStream
* @author zxc
* @date 2022/2/13 10:15 上午
*/
@Override
public Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream,Result<ImportTaskCommonResultDTO> importTask) throws IOException {
public Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream,Result<ImportTaskCommonResultDTO> importTask) {
executorService.submit(() -> {
ExcelReader excelReader = null;
try {

131
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,11 +33,8 @@ import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcHouseListResultDTO;
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;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
@ -165,92 +160,6 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
allDelete(formDTO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public List<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList) {
//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())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
//StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return numList;
}
//获取所有小区 list
// List<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList());
// List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList));
// Map<String,IcNeighborHoodEntity> neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1));
//获取所有楼宇 list
// List<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toList());
// icBuildingDao.selectList(new QueryWrapper<IcBuildingEntity>().lambda().in(IcBuildingEntity::getBuildingName, buildingNameList).in();
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet());
Set<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet());
Set<Integer> buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet());
List<Map<String,Object>> buildMapList = icBuildingDao.selectListByName(customerId, new ArrayList<String>(neighborNameList),new ArrayList<String>(buildingNameList),new ArrayList<Integer>(buildingUnitList));
//转Map
Map<String,Map<String,Object>> buildMap = new HashMap<>();
buildMapList.forEach(item->{
buildMap.put(item.get("neighborName")+","+item.get("buildingName")+","+item.get("unitNum"),item);
});
//封装数据
List<IcHouseEntity> houseEntityList = new ArrayList<>();
Iterator<IcHouseExcel> 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<String,Object> 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<IcHouseListResultDTO> getHouseList(IcHouseListFormDTO formDTO) {
@ -295,50 +204,14 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
public void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
//如果类型是house 查房屋
//导出房屋
List<IcHouseExcel> icHouseExcels = searchAllHouse(formDTO);
PageData<IcHouseListResultDTO> icHouseExcels = getHouseList(formDTO);
TemplateExportParams templatePath = new TemplateExportParams("excel/house_export.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",icHouseExcels);
map.put("maplist",icHouseExcels.getList());
ExcelPoiUtils.exportExcel(templatePath ,map,"房屋信息录入表",response);
return ;
}
private List<IcHouseExcel> 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<IcHouseExcel> icHouseExcels = icHouseDao.searchAllHouse(house);
icHouseExcels.forEach(item->{
item.setHouseType(HouseTypeEnums.getTypeValue(item.getHouseType()));
item.setPurpose(HousePurposeEnums.getTypeValue(item.getPurpose()));
});
return icHouseExcels;
}
/*private IPage<Map<String, Object>> searchHouse(String buildingId,
String ownerName,
String ownerPhone,
String neighborHoodName,
String buildingName,
Integer pageNo,
Integer pageSize) {
IPage<IcHouseEntity> page = new Page<IcHouseEntity>(pageNo,pageSize);
IPage<Map<String, Object>> mapIPage = icHouseDao.searchHouseByPage(page, buildingId, ownerName, ownerPhone, neighborHoodName, buildingName);
List<Map<String, Object>> 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<HouseInfoDTO> queryListHouseInfo(Set<String> houseIdList, String customerId) {

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx

Binary file not shown.

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx

Binary file not shown.

48
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'
<where>
1 = 1
<if test="pids != null and pids != ''">
@ -145,44 +147,6 @@
CAST(a.DOOR_NAME AS SIGNED),
CONVERT(a.DOOR_NAME using gbk)
</select>
<select id="searchAllHouse" resultType="com.epmet.excel.IcHouseExcel">
select
a.HOUSE_NAME as houseName,
a.DOOR_NAME as doorName,
a.HOUSE_TYPE as houseType,
a.PURPOSE as purpose,
if(a.RENT_FLAG=0,'自住',if(a.RENT_FLAG=1,'出租','闲置')) as rentFlag,
a.OWNER_NAME as ownerName,
a.OWNER_PHONE as ownerPhone,
a.OWNER_ID_CARD as ownerIdCard,
b.BUILDING_NAME as buildingName,
c.NEIGHBOR_HOOD_NAME as neighborHoodName,
d.UNIT_NUM as buildingUnit
from ic_house a
INNER JOIN ic_building b on a.BUILDING_ID = b.ID and b.DEL_FLAG = '0'
INNER 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'
<where>
<if test="house.buildingId != null and house.buildingId.trim() != ''">
AND a.BUILDING_ID = #{house.buildingId}
</if>
<if test="house.ownerName != null and house.ownerName.trim() != ''">
AND a.OWNER_NAME like concat('%',#{house.ownerName},'%')
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND a.OWNER_PHONE like concat('%',#{house.ownerPhone},'%')
</if>
<if test="house.delFlag != null and house.delFlag.trim() != ''">
AND a.DEL_FLAG = #{house.delFlag}
</if>
</where>
ORDER BY CONVERT(c.NEIGHBOR_HOOD_NAME using gbk),
CONVERT(b.BUILDING_NAME USING gbk),
CONVERT(d.UNIT_NAME USING gbk),
CAST(a.DOOR_NAME AS SIGNED),
CONVERT(a.DOOR_NAME using gbk)
</select>
<select id="queryHouseInfo" parameterType="map" resultType="com.epmet.dto.result.HouseInfoDTO">
SELECT

Loading…
Cancel
Save