Browse Source

Merge remote-tracking branch 'remotes/origin/dev_ic_platform' into develop

master
jianjun 4 years ago
parent
commit
a0a9da7171
  1. 2
      epmet-commons/epmet-commons-tools/pom.xml
  2. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java
  3. 20
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java
  4. 8
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java
  5. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java
  6. 51
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcPropertyManagementFormDTO.java
  7. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java
  8. 8
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java
  9. 25
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcPropertyManagementResultDTO.java
  10. 70
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  11. 81
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  12. 101
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
  13. 88
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PropertyManagementController.java
  14. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
  15. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java
  16. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
  17. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java
  18. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java
  19. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java
  20. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  21. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  22. 44
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PropertyManagementService.java
  23. 131
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  24. 93
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  25. 157
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  26. 67
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java
  27. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java
  28. 31
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelVerifyInfo.java
  29. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export.xlsx
  30. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx
  31. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export.xlsx
  32. 114
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml
  33. 85
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
  34. 79
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml
  35. 167
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  36. 5
      pom.xml

2
epmet-commons/epmet-commons-tools/pom.xml

@ -89,6 +89,8 @@
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>${easypoi.version}</version>
<!--<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jar/easypoi-base-4.4.0.jar</systemPath>-->
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java

@ -6,10 +6,10 @@ package com.epmet.constant;
*/
public interface NeighborhoodConstant {
String NEIGHBOR_HOOD= "neighbourHood";
String GRID = "grid";
String NEIGHBOR_HOOD= "neighbourHood";
String BUILDING = "building";
String HOUSE = "house";
}

20
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java

@ -24,6 +24,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@ -65,6 +66,11 @@ public class IcBulidingFormDTO implements Serializable {
@Length(max=10,message = "楼栋名称不能超过10个字", groups = {AddGroup.class, UpdateGroup.class})
private String buildingName;
/**
* 楼栋类型
*/
private String type="";
/**
* 客户id
*/
@ -74,43 +80,43 @@ public class IcBulidingFormDTO implements Serializable {
/**
* 排序
*/
@NotBlank(message = "排序不能为空", groups = { UpdateGroup.class})
@NotNull(message = "排序不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Integer sort = 0;
/**
* 总单元数
*/
@NotBlank(message = "总单元数不能为空", groups = {AddGroup.class, UpdateGroup.class})
@NotNull(message = "总单元数不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Integer totalUnitNum=1;
/**
* 总楼层总数
*/
@NotBlank(message = "总楼层总数不能为空", groups = {AddGroup.class, UpdateGroup.class})
@NotNull(message = "总楼层总数不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Integer totalFloorNum;
/**
* 总户数
*/
@NotBlank(message = "总户数不能为空", groups = {AddGroup.class, UpdateGroup.class})
@NotNull(message = "总户数不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Integer totalHouseNum;
/**
* 坐标位置
*/
@NotBlank(message = "坐标位置不能为空", groups = { UpdateGroup.class})
private String location;
/**
* 中心点位经度
*/
@NotBlank(message = "经度不能为空", groups = {UpdateGroup.class})
private String longitude;
/**
* 中心点位纬度
*/
@NotBlank(message = "维度不能为空", groups = {UpdateGroup.class})
private String latitude;

8
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java

@ -21,9 +21,9 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@ -46,7 +46,7 @@ public class IcHouseFormDTO implements Serializable {
private String neighborHoodId;
@NotBlank(message = "所属楼栋ID不能为空", groups = { UpdateGroup.class})
private String belongBuildingId;
private String buildingId;
/**
* 所属单元id
@ -77,8 +77,8 @@ public class IcHouseFormDTO implements Serializable {
/**
* 1出租0未出租
*/
@NotBlank(message = "是否出租不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Boolean rentFlag;
@NotNull(message = "是否出租不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Integer rentFlag;
/**
* 房主姓名

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java

@ -94,13 +94,13 @@ public class IcNeighborHoodFormDTO implements Serializable {
/**
* 中心点位经度
*/
@NotBlank(message = "经度不能为空", groups = {UpdateGroup.class})
private String longitude;
/**
* 中心点位纬度
*/
@NotBlank(message = "纬度不能为空", groups = {UpdateGroup.class})
private String latitude;

51
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcPropertyManagementFormDTO.java

@ -0,0 +1,51 @@
/**
* 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.dto.form;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
@Data
public class IcPropertyManagementFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
public interface DeleteGroup extends CustomerClientShowGroup {
}
@NotBlank(message = "物业id不能为空", groups = { UpdateGroup.class,DeleteGroup.class})
private String id;
/**
* 物业名称
*/
@NotBlank(message = "物业名称不能为空", groups = {AddGroup.class, UpdateGroup.class})
@Length(max=10,message = "物业名称不能超过100个字", groups = {AddGroup.class, UpdateGroup.class})
private String name;
}

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java

@ -70,11 +70,11 @@ public class ListIcNeighborHoodFormDTO implements Serializable{
/**
* 楼栋ID
*/
// private String buildingId;
private String buildingId;
/**
* 小区ID
*/
// private String neighborHoodId;
private String neighborHoodId;
}

8
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java

@ -22,10 +22,10 @@ public class IcNeighborHoodResultDTO implements Serializable {
* */
private Long total;
/**
* 数据类型小区neighbourHood楼栋building房屋house
* */
private String dataType;
// /**
// * 数据类型【小区:neighbourHood,楼栋:building,房屋:house】
// * */
// private String dataType;
/**
* 结果集

25
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcPropertyManagementResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @Description 网格列表信息
* @ClassName GridListInfoResultDTO
* @Author wangc
* @date 2020.04.23 14:21
*/
@Data
public class IcPropertyManagementResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String propertyId;
private String propertyName;
}

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

@ -17,29 +17,43 @@
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.exception.ErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.constant.NeighborhoodConstant;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.IcNeighborHoodFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcHouseExcel;
import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.service.BuildingService;
import com.epmet.service.IcBuildingService;
import com.epmet.service.IcNeighborHoodService;
import com.epmet.service.NeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -70,7 +84,7 @@ public class BuildingController {
public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){
//效验数据
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO);
IcNeighborHoodResultDTO icNeighborHoodResultDTO = buildingService.listBuilding(formDTO);
return new Result().ok(icNeighborHoodResultDTO);
}
@ -110,6 +124,60 @@ public class BuildingController {
List<BuildingTreeLevelDTO> buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getUserId());
return new Result().ok(buildingTreeLevelDTOS);
}
/**
* 导出模板
* @param formDTO
* @param response
* @throws Exception
*/
@PostMapping("exporttemplate")
public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",new ArrayList<IcBuildingExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"楼宇信息录入表",response);
}
/**
* 导出
* @param formDTO
* @param response
* @throws Exception
*/
@RequestMapping("exportbuildinginfo")
public void exportbuildinginfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
buildingService.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<IcBuildingExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcBuildingExcel.class);
List<IcBuildingExcel> failList = importResult.getFailList();
if(!CollectionUtils.isEmpty(failList)){
for ( IcBuildingExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
}
return new Result().error(8000,failList.get(0).getErrorMsg());
}
List<IcBuildingExcel> result =importResult.getList();
buildingService.importExcel(customerId,result);
return new Result().ok("导入成功");
}
}

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

@ -17,24 +17,40 @@
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.exception.ErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.constant.NeighborhoodConstant;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.IcNeighborHoodFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcHouseExcel;
import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.service.HouseService;
import com.epmet.service.NeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -60,7 +76,7 @@ public class HouseController {
public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){
//效验数据
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO);
IcNeighborHoodResultDTO icNeighborHoodResultDTO = houseService.listNeighborhood(formDTO);
return new Result().ok(icNeighborHoodResultDTO);
}
@ -93,5 +109,60 @@ public class HouseController {
houseService.delHouse(formDTO.getHouseId());
return new Result();
}
/**
* 导出模板
* @param formDTO
* @param response
* @throws Exception
*/
@PostMapping("exporttemplate")
public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, 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);
}
/**
* 导出
* @param formDTO
* @param response
* @throws Exception
*/
@RequestMapping("exporthouseinfo")
public void exporthouseinfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
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();
if(!CollectionUtils.isEmpty(failList)){
for ( IcHouseExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
}
return new Result().error(8000,failList.get(0).getErrorMsg());
}
List<IcHouseExcel> result =importResult.getList();
houseService.importExcel(customerId,result);
return new Result().ok("导入成功");
}
}

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

@ -17,21 +17,20 @@
package com.epmet.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.ErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.constant.NeighborhoodConstant;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dto.form.IcNeighborHoodFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcHouseExcel;
import com.epmet.entity.IcBuildingEntity;
import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.service.BuildingService;
import com.epmet.service.HouseService;
@ -39,16 +38,15 @@ import com.epmet.service.IcNeighborHoodService;
import com.epmet.service.NeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -73,6 +71,8 @@ public class NeighborHoodController {
private BuildingService buildingService;
@Autowired
private HouseService houseService;
@Resource
private IcBuildingDao icBuildingDao;
@ -112,8 +112,13 @@ public class NeighborHoodController {
//效验数据
ValidatorUtils.validateEntity(formDTO, IcNeighborHoodFormDTO.DeleteGroup.class);
String neighborHoodId = formDTO.getNeighborHoodId();
//判断是否存在楼宇,如果存在不能删除
List<IcBuildingEntity> icBuildingEntities = icBuildingDao.selectList(new QueryWrapper<IcBuildingEntity>().lambda().eq(IcBuildingEntity::getNeighborHoodId, neighborHoodId));
if(!CollectionUtils.isEmpty(icBuildingEntities)){
return new Result().error(8000,"小区下已存在楼宇,无法删除");
}
neighborHoodService.DelNeighborhood(neighborHoodId);
return new Result();
return new Result().ok("删除成功");
}
@ -123,13 +128,55 @@ public class NeighborHoodController {
* @param response
* @throws Exception
*/
@RequestMapping("exportneighborhoodinfo")
@PostMapping("exportneighborhoodinfo")
public void exportneighborhoodinfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
neighborHoodService.exportNeighborhoodinfo(formDTO,response);
}
/**
* 导出模板
* @param formDTO
* @param response
* @throws Exception
*/
@PostMapping("exporttemplate")
public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",new ArrayList<IcNeighborHoodExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response);
}
/**
* 导出模板
* @param response
* @throws Exception
*/
/*@GetMapping("export")
public void export( HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",new ArrayList<IcNeighborHoodExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response);
}*/
/**
* 导出
* @param response
* @throws Exception
*/
/* @RequestMapping("exportinfo")
public void exportinfo(HttpServletResponse response) throws Exception {
ListIcNeighborHoodFormDTO formDTO = new ListIcNeighborHoodFormDTO();
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
neighborHoodService.exportNeighborhoodinfo(formDTO,response);
}*/
// /**
@ -151,25 +198,25 @@ public class NeighborHoodController {
* @return
* @throws IOException
*/
@PostMapping("importneighborhoodinfo")
public Result importExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException {
String dataType = request.getParameter("dataType");
if(StringUtils.isEmpty(dataType)){
return new Result().error(ErrorCode.PASSWORD_ERROR);
}
@PostMapping("import")
public Result importExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file) throws IOException {
String customerId = tokenDTO.getCustomerId();
// String customerId = "123123";
if(NeighborhoodConstant.NEIGHBOR_HOOD.equals(dataType)){
List<IcNeighborHoodExcel> result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class);
neighborHoodService.importExcel(customerId,result);
}else if(NeighborhoodConstant.BUILDING.equals(dataType)){
List<IcBuildingExcel> result = ExcelPoiUtils.importExcel(file, 0, 1, IcBuildingExcel.class);
buildingService.importExcel(customerId,result);
}else if(NeighborhoodConstant.HOUSE.equals(dataType)){
List<IcHouseExcel> result = ExcelPoiUtils.importExcel(file, 0, 1, IcHouseExcel.class);
houseService.importExcel(customerId,result);
ExcelImportResult<IcNeighborHoodExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcNeighborHoodExcel.class);
// List<IcNeighborHoodExcel> result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class);
List<IcNeighborHoodExcel> failList = importResult.getFailList();
if(!CollectionUtils.isEmpty(failList)){
for ( IcNeighborHoodExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
}
return new Result().error(8000,failList.get(0).getErrorMsg());
}
return new Result().ok("导入成功");
List<IcNeighborHoodExcel> result =importResult.getList();
// log.info(JSON.toJSONString(result));
neighborHoodService.importExcel(customerId,result);
return new Result();
}

88
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PropertyManagementController.java

@ -0,0 +1,88 @@
/**
* 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.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.form.IcPropertyManagementFormDTO;
import com.epmet.dto.result.IcPropertyManagementResultDTO;
import com.epmet.service.IcPropertyManagementService;
import com.epmet.service.PropertyManagementService;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* 物业表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-25
*/
@RestController
@RequestMapping("propertymanagement")
public class PropertyManagementController {
@Autowired
private IcPropertyManagementService icPropertyManagementService;
@Autowired
private PropertyManagementService propertyManagementService;
@PostMapping("list")
public Result<List<IcPropertyManagementResultDTO>> list(){
return new Result<List<IcPropertyManagementResultDTO>>().ok(propertyManagementService.getList());
}
@PostMapping("add")
public Result add(@LoginUser TokenDto tokenDTO, @RequestBody IcPropertyManagementFormDTO formDTO){
//效验数据
ValidatorUtils.validateEntity(formDTO, AddGroup.class);
propertyManagementService.add(formDTO);
return new Result().ok("保存成功");
}
@PostMapping("update")
public Result update(@LoginUser TokenDto tokenDTO, @RequestBody IcPropertyManagementFormDTO formDTO){
//效验数据
ValidatorUtils.validateEntity(formDTO, UpdateGroup.class);
propertyManagementService.update(formDTO);
return new Result();
}
@PostMapping("delete")
public Result delete(@LoginUser TokenDto tokenDTO, @RequestBody IcPropertyManagementFormDTO formDTO){
//效验数据
ValidatorUtils.validateEntity(formDTO, IcPropertyManagementFormDTO.DeleteGroup.class);
propertyManagementService.delete(formDTO);
return new Result();
}
}

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java

@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.IcBuildingEntity;
import com.epmet.entity.IcHouseEntity;
import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.excel.IcBuildingExcel;
import org.apache.ibatis.annotations.Mapper;
@ -45,14 +46,14 @@ public interface IcBuildingDao extends BaseDao<IcBuildingEntity> {
// @Param("neighbor") IcNeighborHoodEntity neighbor,
// @Param("building")IcBuildingEntity building);
IPage<Map<String, Object>> searchBuildingByPage(IPage<IcBuildingEntity> page,
@Param("building")IcBuildingEntity building);
@Param("building")IcBuildingEntity building, @Param("house") IcHouseEntity house);
// List<IcBuildingExcel> searchAllBuilding(@Param(Constants.WRAPPER) QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper,
// @Param("ew1") QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper);
// List<IcBuildingExcel> searchAllBuilding(@Param("neighbor") IcNeighborHoodEntity neighbor,
// @Param("building")IcBuildingEntity building);
List<IcBuildingExcel> searchAllBuilding(
@Param("building")IcBuildingEntity building);
@Param("building")IcBuildingEntity building, @Param("house")IcHouseEntity house);
List<CustomerAgencyEntity> selectAgencyChildrenList(@Param("agencyId") String agencyId);

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java

@ -51,7 +51,5 @@ public interface IcHouseDao extends BaseDao<IcHouseEntity> {
IPage<Map<String, Object>> searchHouseByPage(IPage<IcHouseEntity> page,
@Param("house") IcHouseEntity house);
List<IcHouseExcel> searchAllHouse(@Param("neighbor") IcNeighborHoodEntity neighbor,
@Param("building") IcBuildingEntity building,
@Param("house") IcHouseEntity house);
List<IcHouseExcel> searchAllHouse(@Param("house") IcHouseEntity house);
}

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.IcHouseEntity;
import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.excel.IcNeighborHoodExcel;
import org.apache.ibatis.annotations.Mapper;
@ -40,10 +41,10 @@ import java.util.Set;
public interface IcNeighborHoodDao extends BaseDao<IcNeighborHoodEntity> {
// IPage<Map<String, Object>> searchNeighborhoodByPage(IPage<IcNeighborHoodEntity> page,@Param(Constants.WRAPPER) QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper);
IPage<Map<String, Object>> searchNeighborhoodByPage(IPage<IcNeighborHoodEntity> page,@Param("neighbor") IcNeighborHoodEntity neighbor);
IPage<Map<String, Object>> searchNeighborhoodByPage(IPage<IcNeighborHoodEntity> page, @Param("neighbor") IcNeighborHoodEntity neighbor, @Param("house")IcHouseEntity house);
// List<IcNeighborHoodExcel> searchAllNeighborhood(@Param(Constants.WRAPPER) QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper);
List<IcNeighborHoodExcel> searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor);
List<IcNeighborHoodExcel> searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor, @Param("house")IcHouseEntity house);
List<IcNeighborHoodEntity> selectListByName(@Param("neighborNameList")List<String> neighborNameList,
@Param("agencyNameList") List<String> agencyNameList,

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

@ -18,11 +18,13 @@
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 java.util.Date;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 楼栋信息
@ -31,7 +33,7 @@ import java.util.Date;
* @since v1.0.0 2021-10-27
*/
@Data
public class IcBuildingExcel {
public class IcBuildingExcel extends ExcelVerifyInfo implements Serializable {
/*@Excel(name = "楼栋主键")
private String id;
@ -108,14 +110,14 @@ public class IcBuildingExcel {
private String buildingName;
@Excel(name = "单元数")
@NotBlank(message = "单元数不能位空")
@NotNull(message = "单元数不能位空")
private Integer totalUnitNum;
@Excel(name = "层数")
@NotBlank(message = "层数不能位空")
@NotNull(message = "层数不能位空")
private Integer totalFloorNum;
@Excel(name = "户数")
@NotBlank(message = "户数不能位空")
@NotNull(message = "户数不能位空")
private Integer totalHouseNum;
}

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

@ -18,11 +18,13 @@
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 java.util.Date;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 房屋信息
@ -31,7 +33,7 @@ import java.util.Date;
* @since v1.0.0 2021-10-27
*/
@Data
public class IcHouseExcel {
public class IcHouseExcel extends ExcelVerifyInfo implements Serializable {
/*@Excel(name = "房屋主键")
private String id;
@ -95,17 +97,17 @@ public class IcHouseExcel {
@Excel(name = "小区名称")
@Excel(name = "所属小区")
@NotBlank(message = "小区名称不能位空")
@Length(max=50,message = "小区名称不能超过50个字")
private String neighborHoodName;
@Excel(name = "楼栋名称")
@Excel(name = "所属楼栋")
@NotBlank(message = "楼栋名称不能位空")
private String buildingName;
@Excel(name = "单元号")
@NotBlank(message = "单元号不能位空")
@NotNull(message = "单元号不能位空")
private Integer buildingUnit;
@Excel(name = "门牌号")
@ -132,7 +134,7 @@ public class IcHouseExcel {
@NotBlank(message = "房主电话不能位空")
private String ownerPhone;
@Excel(name = "房主身份证")
@Excel(name = "房主身份证")
@NotBlank(message = "房主身份证号不能位空")
private String ownerIdCard;

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

@ -20,10 +20,12 @@ package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.util.ExcelVerifyInfo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
@ -33,7 +35,7 @@ import java.util.Date;
* @since v1.0.0 2021-10-26
*/
@Data
public class IcNeighborHoodExcel {
public class IcNeighborHoodExcel extends ExcelVerifyInfo implements Serializable {
/*@Excel(name = "小区主键")
private String id;
@ -109,7 +111,6 @@ public class IcNeighborHoodExcel {
private String neighborHoodName;
@Excel(name = "关联物业")
private String propertyName;
@Excel(name = "详细地址")

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

@ -19,9 +19,12 @@ package com.epmet.service;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
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;
/**
@ -50,4 +53,8 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(String customerId);
void importExcel(String customerId, List<IcBuildingExcel> list);
IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO);
void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ;
}

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

@ -18,9 +18,12 @@
package com.epmet.service;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcHouseExcel;
import com.epmet.excel.IcNeighborHoodExcel;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -44,4 +47,8 @@ public interface HouseService {
void importExcel(String customerId, List<IcHouseExcel> list);
IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO);
void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception;
}

44
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PropertyManagementService.java

@ -0,0 +1,44 @@
/**
* 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.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcPropertyManagementDTO;
import com.epmet.dto.form.IcPropertyManagementFormDTO;
import com.epmet.dto.result.IcPropertyManagementResultDTO;
import com.epmet.entity.IcPropertyManagementEntity;
import java.util.List;
import java.util.Map;
/**
* 物业表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-25
*/
public interface PropertyManagementService {
List<IcPropertyManagementResultDTO> getList();
void add(IcPropertyManagementFormDTO formDTO);
void update(IcPropertyManagementFormDTO formDTO);
void delete(IcPropertyManagementFormDTO formDTO);
}

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

@ -1,15 +1,23 @@
package com.epmet.service.impl;
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.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.*;
import com.epmet.dto.*;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.ExtStaffPermissionResultDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.entity.*;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.service.*;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -48,6 +57,8 @@ public class BuildingServiceImpl implements BuildingService {
private IcNeighborHoodDao icNeighborHoodDao;
@Resource
private CustomerStaffAgencyDao customerStaffAgencyDao;
@Resource
private IcBuildingUnitDao icBuildingUnitDao;
@Override
@Transactional(rollbackFor = Exception.class)
@ -62,8 +73,9 @@ public class BuildingServiceImpl implements BuildingService {
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
for(int i =0 ;i<totalUnitNum;i++){
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity();
icBuildingUnit.setCustomerId(customerId);
icBuildingUnit.setBuildingId(entity.getId());
icBuildingUnit.setUnitName(String.valueOf(i+1));
icBuildingUnit.setUnitName(String.valueOf(i+1)+"单元");
icBuildingUnit.setUnitNum(String.valueOf(i+1));
unitList.add(icBuildingUnit);
}
@ -201,8 +213,10 @@ public class BuildingServiceImpl implements BuildingService {
String uuid = UUID.randomUUID().toString().replace("-", "");
entity.setId(uuid);
entity.setCustomerId(customerId);
entity.setNeighborHoodId(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId());
entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()
entity.setBuildingName(icBuildingExcel.getBuildingName());
entity.setType("");
entity.setSort(0);
entity.setTotalUnitNum(icBuildingExcel.getTotalUnitNum());
entity.setTotalFloorNum(icBuildingExcel.getTotalFloorNum());
entity.setTotalHouseNum(icBuildingExcel.getTotalHouseNum());
@ -214,7 +228,8 @@ public class BuildingServiceImpl implements BuildingService {
for(int i =0 ;i<totalUnitNum;i++){
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity();
icBuildingUnit.setBuildingId(uuid);
icBuildingUnit.setUnitName(String.valueOf(i+1));
icBuildingUnit.setCustomerId(customerId);
icBuildingUnit.setUnitName(String.valueOf(i+1)+"单元");
icBuildingUnit.setUnitNum(String.valueOf(i+1));
unitList.add(icBuildingUnit);
}
@ -227,6 +242,74 @@ public class BuildingServiceImpl implements BuildingService {
}
@Override
public IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO) {
IcNeighborHoodResultDTO result = new IcNeighborHoodResultDTO();
IPage<Map<String, Object>> resultMap = searchBuilding(formDTO);
result.setTotal(resultMap.getTotal());
result.setList(resultMap.getRecords());
return result;
}
@Override
public void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
//如果类型是building 查楼栋
//导出楼栋
List<IcBuildingExcel> icBuildingExcels = searchAllBuilding(formDTO);
TemplateExportParams templatePath = new TemplateExportParams("excel/building_export.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",icBuildingExcels);
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"楼宇信息录入表",response);
return ;
}
private List<IcBuildingExcel> searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) {
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// buildingEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
building.setDelFlag("0");
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
return icBuildingDao.searchAllBuilding(building,house);
}
private IPage<Map<String, Object>> searchBuilding(ListIcNeighborHoodFormDTO formDTO) {
IPage<IcBuildingEntity> page = new Page<IcBuildingEntity>(formDTO.getPageNo(),formDTO.getPageSize());
// IcNeighborHoodEntity neighbor = new IcNeighborHoodEntity();
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
building.setDelFlag("0");
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
//
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// buildingEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
return icBuildingDao.searchBuildingByPage(page,building,house);
}
private List<BuildingTreeLevelDTO> covertToTree(CustomerAgencyEntity customerAgency,List<BuildingTreeLevelDTO> agencyList) {
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO();
@ -264,12 +347,16 @@ public class BuildingServiceImpl implements BuildingService {
IcBuildingDTO icBuilding= icBuildingService.get(formDTO.getBuildingId());
if(!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())){
//更新对应房屋小区
//更新对应房屋小区id
List<IcHouseEntity> icHouseEntities = icHouseDao.selectList(new QueryWrapper<IcHouseEntity>().lambda().eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId()));
icHouseEntities.forEach(item->{
item.setNeighborHoodId(formDTO.getNeighborHoodId());
});
icHouseService.updateBatchById(icHouseEntities);
if(!CollectionUtils.isEmpty(icHouseEntities)){
//
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法更新");
// icHouseEntities.forEach(item->{
// item.setNeighborHoodId(formDTO.getNeighborHoodId());
// });
// icHouseService.updateBatchById(icHouseEntities);
}
}
IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class);
icBuildingDTO.setId(formDTO.getBuildingId());
@ -277,7 +364,25 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingService.update(icBuildingDTO);
//更新楼宇单元
//如果楼宇单元大于之前的楼宇单元,新增单元
Integer nowUnit= formDTO.getTotalUnitNum();
Integer unit = icBuilding.getTotalUnitNum();
if(nowUnit>=unit){
//新增单元
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
for(int i =unit ;i<nowUnit;i++){
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity();
icBuildingUnit.setBuildingId(icBuilding.getId());
icBuildingUnit.setCustomerId(customerId);
icBuildingUnit.setUnitName(String.valueOf(i+1)+"单元");
icBuildingUnit.setUnitNum(String.valueOf(i+1));
unitList.add(icBuildingUnit);
}
icBuildingUnitService.insertBatch(unitList);
}else{
//如果小于,判断是否存在房屋,如果存在就提示不能更改
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法更新");
}
}
@ -289,8 +394,16 @@ public class BuildingServiceImpl implements BuildingService {
@Override
@Transactional(rollbackFor = Exception.class)
public void DelBuilding(String buildingId) {
//删除小区
//如果存在房屋,无法删除
List<IcHouseEntity> icHouseEntities = icHouseDao.selectList(new QueryWrapper<IcHouseEntity>().lambda().eq(IcHouseEntity::getBuildingId, buildingId));
if(!CollectionUtils.isEmpty(icHouseEntities)){
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法删除");
}
//删除楼宇
icBuildingService.deleteById(buildingId);
//删除楼宇单元
icBuildingUnitDao.delete(new QueryWrapper<IcBuildingUnitEntity>().lambda().eq(IcBuildingUnitEntity::getBuildingId,buildingId));
}
}

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

@ -1,5 +1,8 @@
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.utils.ConvertUtils;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao;
@ -9,12 +12,17 @@ import com.epmet.dto.IcBuildingDTO;
import com.epmet.dto.IcBuildingUnitDTO;
import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.entity.IcBuildingEntity;
import com.epmet.entity.IcHouseEntity;
import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.excel.IcHouseExcel;
import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService;
import com.epmet.service.IcBuildingUnitService;
import com.epmet.service.IcHouseService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -22,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
@ -51,7 +60,7 @@ public class HouseServiceImpl implements HouseService {
public void addHouse(String customerId, IcHouseFormDTO formDTO) {
IcHouseDTO icHouseDTO= ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class);
icHouseDTO.setCustomerId(customerId);
icHouseDTO.setRentFlag(formDTO.getRentFlag()?1:0);
// icHouseDTO.setRentFlag(formDTO.getRentFlag());
icHouseDTO.setHouseName(getHouseName(formDTO));
icHouseService.save(icHouseDTO);
@ -59,7 +68,7 @@ public class HouseServiceImpl implements HouseService {
private String getHouseName(IcHouseFormDTO formDTO){
//设置房间名 楼栋-单元号-门牌号
IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingUnitId());
IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingId());
IcBuildingUnitDTO icBuildingUnit = icBuildingUnitService.get(formDTO.getBuildingUnitId());
String doorName = formDTO.getDoorName();
String buildingName = Optional.ofNullable(icBuilding).map(u->u.getBuildingName()).orElse("");
@ -78,7 +87,7 @@ public class HouseServiceImpl implements HouseService {
IcHouseDTO icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class);
icHouseDTO.setId(formDTO.getHouseId());
icHouseDTO.setCustomerId(customerId);
icHouseDTO.setRentFlag(formDTO.getRentFlag()?1:0);
icHouseDTO.setRentFlag(formDTO.getRentFlag());
//设置
icHouseDTO.setHouseName(getHouseName(formDTO));
icHouseService.update(icHouseDTO);
@ -127,12 +136,12 @@ public class HouseServiceImpl implements HouseService {
entity.setId(uuid);
entity.setCustomerId(customerId);
Map<String,Object> item = buildMap.get(icHouseExcel.getNeighborHoodName()+","+icHouseExcel.getBuildingName()+","+icHouseExcel.getBuildingUnit());
if(!CollectionUtils.isEmpty(item)){
entity.setNeighborHoodId(String.valueOf(item.get("neighborId")));
entity.setBuildingId(String.valueOf(item.get("buildingId")));
entity.setBuildingUnitId(String.valueOf(item.get("buildingUnitId")));
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());
}
entity.setDoorName(icHouseExcel.getDoorName());
entity.setHouseType(icHouseExcel.getHouseType());
entity.setPurpose(icHouseExcel.getPurpose());
@ -143,10 +152,76 @@ public class HouseServiceImpl implements HouseService {
houseEntityList.add(entity);
}
//3.保存
//4.新增单元
icHouseService.insertBatch(houseEntityList);
}
@Override
public IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO) {
IcNeighborHoodResultDTO result = new IcNeighborHoodResultDTO();
//如果类型是house 查房屋
IPage<Map<String, Object>> resultMap = searchHouse(formDTO);
result.setTotal(resultMap.getTotal());
result.setList(resultMap.getRecords());
return result;
}
@Override
public void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
//如果类型是house 查房屋
//导出房屋
List<IcHouseExcel> icHouseExcels = searchAllHouse(formDTO);
TemplateExportParams templatePath = new TemplateExportParams("excel/house_export.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",icHouseExcels);
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"房屋信息录入表",response);
return ;
}
private List<IcHouseExcel> searchAllHouse(ListIcNeighborHoodFormDTO 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");
return icHouseDao.searchAllHouse(house);
}
private IPage<Map<String, Object>> searchHouse(ListIcNeighborHoodFormDTO formDTO) {
IPage<IcHouseEntity> page = new Page<IcHouseEntity>(formDTO.getPageNo(),formDTO.getPageSize());
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
// QueryWrapper<IcHouseEntity> houseEntityQueryWrapper = new QueryWrapper<>();
// houseEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getOwnerName()),IcHouseEntity::getOwnerName,formDTO.getOwnerName())
// .like(!StringUtils.isEmpty(formDTO.getOwnerPhone()),IcHouseEntity::getOwnerPhone,formDTO.getOwnerPhone());
// houseEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
house.setDelFlag("0");
return icHouseDao.searchHouseByPage(page,house);
}
}

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

@ -102,91 +102,26 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
*/
@Override
public IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO) {
String dataType = formDTO.getLevel();
String level = formDTO.getLevel();
Integer pageNo = formDTO.getPageNo();
Integer pageSize = formDTO.getPageSize();
IcNeighborHoodResultDTO result = new IcNeighborHoodResultDTO();
result.setDataType(dataType);
if(StringUtils.isEmpty(dataType)|| NeighborhoodConstant.NEIGHBOR_HOOD.equals(dataType)){
//如果类型是neighbourHood 查小区
IPage<Map<String, Object>> resultMap = searchNeighborhood(formDTO);
result.setTotal(resultMap.getTotal());
result.setList(resultMap.getRecords());
}else if(NeighborhoodConstant.BUILDING.equals(dataType)){
//如果类型是building 查楼栋
IPage<Map<String, Object>> resultMap = searchBuilding(formDTO);
result.setTotal(resultMap.getTotal());
result.setList(resultMap.getRecords());
}else if(NeighborhoodConstant.HOUSE.equals(dataType)){
//如果类型是house 查房屋
IPage<Map<String, Object>> resultMap = searchHouse(formDTO);
result.setTotal(resultMap.getTotal());
result.setList(resultMap.getRecords());
}
return result;
}
return result;
private IPage<Map<String, Object>> searchHouse(ListIcNeighborHoodFormDTO formDTO) {
IPage<IcHouseEntity> page = new Page<IcHouseEntity>(formDTO.getPageNo(),formDTO.getPageSize());
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
// QueryWrapper<IcHouseEntity> houseEntityQueryWrapper = new QueryWrapper<>();
// houseEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getOwnerName()),IcHouseEntity::getOwnerName,formDTO.getOwnerName())
// .like(!StringUtils.isEmpty(formDTO.getOwnerPhone()),IcHouseEntity::getOwnerPhone,formDTO.getOwnerPhone());
// houseEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
house.setDelFlag("0");
return icHouseDao.searchHouseByPage(page,house);
}
private IPage<Map<String, Object>> searchBuilding(ListIcNeighborHoodFormDTO formDTO) {
IPage<IcBuildingEntity> page = new Page<IcBuildingEntity>(formDTO.getPageNo(),formDTO.getPageSize());
// IcNeighborHoodEntity neighbor = new IcNeighborHoodEntity();
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
building.setDelFlag("0");
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
//
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// buildingEntityQueryWrapper.eq("a.DEL_FLAG","0");
return icBuildingDao.searchBuildingByPage(page,building);
}
private IPage<Map<String,Object>> searchNeighborhood(ListIcNeighborHoodFormDTO formDTO) {
@ -201,8 +136,16 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
// neighborHoodEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
neighbor.setDelFlag("0");
return icNeighborHoodDao.searchNeighborhoodByPage(page, neighbor);
if(NeighborhoodConstant.GRID.equals(formDTO.getLevel())){
//根据网格过滤
neighbor.setGridId(formDTO.getId());
}else{
//根据组织过滤
neighbor.setAgencyId(formDTO.getId());
}
return icNeighborHoodDao.searchNeighborhoodByPage(page, neighbor,house);
}
/**
@ -274,38 +217,14 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
*/
@Override
public void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception {
String dataType = formDTO.getLevel();
if(StringUtils.isEmpty(dataType)|| NeighborhoodConstant.NEIGHBOR_HOOD.equals(dataType)){
//如果类型是neighbourHood 查小区
//导出小区
List<IcNeighborHoodExcel> icNeighborHoodExcels = searchAllNeighborhood(formDTO);
// ExcelUtils.exportExcelToTarget(response, "小区信息录入表", icNeighborHoodExcels, IcNeighborHoodExcel.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx");
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"小区信息录入表",response);
return ;
}else if(NeighborhoodConstant.BUILDING.equals(dataType)){
//如果类型是building 查楼栋
//导出楼栋
List<IcBuildingExcel> icBuildingExcels = searchAllBuilding(formDTO);
// ExcelUtils.exportExcelToTarget(response, "楼宇信息录入表", icBuildingExcels, IcBuildingExcel.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx");
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"楼宇信息录入表",response);
return ;
}else if(NeighborhoodConstant.HOUSE.equals(dataType)){
//如果类型是house 查房屋
//导出房屋
List<IcHouseExcel> icHouseExcels = searchAllHouse(formDTO);
// ExcelUtils.exportExcelToTarget(response, "房屋信息录入表", icHouseExcels, IcHouseExcel.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/house_template.xlsx");
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"房屋信息录入表",response);
return ;
}
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_export.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",icNeighborHoodExcels);
ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response);
}
@Override
@ -339,16 +258,18 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
entity.setId(uuid);
entity.setCustomerId(customerId);
entity.setNeighborHoodName(icNeighborHoodExcel.getNeighborHoodName());
entity.setAgencyId(agencyMap.get(icNeighborHoodExcel.getAgencyName()).getId());
entity.setParentAgencyId(agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPid());
entity.setAgencyPids(agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPids());
entity.setGridId(gridMap.get(icNeighborHoodExcel.getGridName()).getId());
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.setAddress(icNeighborHoodExcel.getAddress());
entity.setRemark(icNeighborHoodExcel.getRemark());
neighborHoodEntityList.add(entity);
IcNeighborHoodPropertyEntity entity1 = new IcNeighborHoodPropertyEntity();
entity1.setPropertyId(propertyMap.get(icNeighborHoodExcel.getPropertyName()).getId());
entity1.setPropertyId(Optional.ofNullable(propertyMap.get(icNeighborHoodExcel.getPropertyName())).map(u->u.getId()).orElse(""));
entity1.setNeighborHoodId(uuid);
icNeighborHoodPropertyEntityList.add(entity1);
}
@ -360,26 +281,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
}
private List<IcBuildingExcel> searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) {
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// buildingEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
building.setDelFlag("0");
return icBuildingDao.searchAllBuilding(building);
}
private List<IcNeighborHoodExcel> searchAllNeighborhood(ListIcNeighborHoodFormDTO formDTO) {
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
@ -391,22 +293,11 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
// neighborHoodEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
neighbor.setDelFlag("0");
return icNeighborHoodDao.searchAllNeighborhood(neighbor);
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
return icNeighborHoodDao.searchAllNeighborhood(neighbor,house);
}
private List<IcHouseExcel> searchAllHouse(ListIcNeighborHoodFormDTO 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");
return icHouseDao.searchAllHouse(neighbor,building,house);
}

67
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java

@ -0,0 +1,67 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.IcNeighborHoodPropertyDao;
import com.epmet.dao.IcPropertyManagementDao;
import com.epmet.dto.form.IcPropertyManagementFormDTO;
import com.epmet.dto.result.IcPropertyManagementResultDTO;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.entity.IcPropertyManagementEntity;
import com.epmet.service.PropertyManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
public class PropertyManagementServiceImpl implements PropertyManagementService {
@Resource
private IcPropertyManagementDao icPropertyManagementDao;
@Resource
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao;
@Override
public List<IcPropertyManagementResultDTO> getList() {
List<IcPropertyManagementEntity> propertyManagementEntityList = icPropertyManagementDao.selectList(null);
List<IcPropertyManagementResultDTO> list = new ArrayList<>();
propertyManagementEntityList.forEach(item->{
IcPropertyManagementResultDTO propertyManagementResultDTO = new IcPropertyManagementResultDTO();
propertyManagementResultDTO.setPropertyId(item.getId());
propertyManagementResultDTO.setPropertyName(item.getName());
list.add(propertyManagementResultDTO);
});
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void add(IcPropertyManagementFormDTO formDTO) {
IcPropertyManagementEntity icPropertyManagementEntity = ConvertUtils.sourceToTarget(formDTO, IcPropertyManagementEntity.class);
icPropertyManagementDao.insert(icPropertyManagementEntity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcPropertyManagementFormDTO formDTO) {
IcPropertyManagementEntity icPropertyManagementEntity = ConvertUtils.sourceToTarget(formDTO, IcPropertyManagementEntity.class);
icPropertyManagementDao.updateById(icPropertyManagementEntity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(IcPropertyManagementFormDTO formDTO) {
List<IcNeighborHoodPropertyEntity> list = icNeighborHoodPropertyDao.selectList(new QueryWrapper<IcNeighborHoodPropertyEntity>().lambda().eq(IcNeighborHoodPropertyEntity::getPropertyId, formDTO.getId()));
if(!CollectionUtils.isEmpty(list)){
throw new RenException("物业存在与小区关联,无法删除");
}
icPropertyManagementDao.deleteById(formDTO.getId());
}
}

16
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java

@ -169,7 +169,7 @@ public class ExcelPoiUtils {
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
params.setNeedSave(true);
params.setSaveUrl("/excel/");
params.setSaveUrl("/tmp/excel/");
try {
return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) {
@ -218,7 +218,7 @@ public class ExcelPoiUtils {
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
params.setSaveUrl("/excel/");
params.setSaveUrl("/tmp/excel/");
params.setNeedSave(true);
try {
return ExcelImportUtil.importExcel(inputStream, pojoClass, params);
@ -236,12 +236,12 @@ public class ExcelPoiUtils {
* @param <T>
* @return
*/
public static <T> ExcelImportResult<T> importExcelMore(MultipartFile file, Class<T> pojoClass) throws IOException {
public static <T> ExcelImportResult<T> importExcelMore(MultipartFile file,Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
if (file == null) {
return null;
}
try {
return importExcelMore(file.getInputStream(), pojoClass);
return importExcelMore(file.getInputStream(), titleRows, headerRows, pojoClass);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
@ -255,14 +255,14 @@ public class ExcelPoiUtils {
* @param <T>
* @return
*/
private static <T> ExcelImportResult<T> importExcelMore(InputStream inputStream, Class<T> pojoClass) throws IOException {
private static <T> ExcelImportResult<T> importExcelMore(InputStream inputStream,Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
if (inputStream == null) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(1);//表格内数据标题行
params.setHeadRows(1);//表头行
params.setSaveUrl("/excel/");
params.setTitleRows(titleRows);//表格内数据标题行
params.setHeadRows(headerRows);//表头行
params.setSaveUrl("/tmp/excel/");
params.setNeedSave(true);
params.setNeedVerify(true);
try {

31
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelVerifyInfo.java

@ -0,0 +1,31 @@
package com.epmet.util;
import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
public class ExcelVerifyInfo implements IExcelModel, IExcelDataModel {
private String errorMsg;
private int rowNum;
@Override
public Integer getRowNum() {
return rowNum;
}
@Override
public void setRowNum(Integer rowNum) {
this.rowNum = rowNum;
}
@Override
public String getErrorMsg() {
return errorMsg;
}
@Override
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}

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

Binary file not shown.

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

Binary file not shown.

114
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml

@ -48,24 +48,88 @@
<select id="searchBuildingByPage" resultType="map">
select
a.BUILDING_NAME as buildingName,
b.NEIGHBOR_HOOD_NAME as neighbourHoodName,
b.ID as neighborHoodId,
a.TOTAL_HOUSE_NUM as totalHouseNum,
a.TOTAL_FLOOR_NUM as totalFloorNum,
a.TOTAL_UNIT_NUM as totalUnitNum,
a.TYPE as buildingType,
a.ID as buildingId,
c.ID as agencyId,
c.ORGANIZATION_NAME as agencyName,
d.ID as gridId,
d.GRID_NAME as gridName,
a.SORT as sort,
a.LONGITUDE as longitude,
a.LATITUDE as latitude,
a.TYPE as buildingTypeKey
from ic_building a
LEFT JOIN ic_neighbor_hood b on a.NEIGHBOR_HOOD_ID = b.ID and b.DEL_FLAG='0'
left join customer_agency c on b.AGENCY_ID = c.ID and c.DEL_FLAG='0'
left join customer_grid d on b.GRID_ID = d.ID and d.DEL_FLAG='0'
<where>
<if test="building.neighborHoodId != null and building.neighborHoodId.trim() != ''">
AND a.NEIGHBOR_HOOD_ID = #{building.neighborHoodId}
</if>
<if test="(house.ownerName != null and house.ownerName.trim() != '') or (house.ownerPhone != null and house.ownerPhone.trim() != '')">
AND a.ID in (select distinct BUILDING_ID from ic_house e
<where>
<if test="house.ownerName != null and house.ownerName.trim() != ''">
AND e.OWNER_NAME = #{house.ownerName}
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND e.OWNER_PHONE = #{house.ownerPhone}
</if>
and e.DEL_FLAG='0'
</where>
)
</if>
<if test="building.delFlag != null and building.delFlag.trim() != ''">
AND a.DEL_FLAG = #{building.delFlag}
</if>
</where>
</select>
<select id="searchAllBuilding" resultType="com.epmet.excel.IcBuildingExcel">
select
a.ID as buildingId,
a.BUILDING_NAME as buildingName,
a.TOTAL_HOUSE_NUM as totalHouseNum,
a.TOTAL_FLOOR_NUM as totalFloorNum,
a.TOTAL_UNIT_NUM as totalUnitNum,
a.BUILDING_NAME as buildingType,
b.NEIGHBOR_HOOD_NAME as neighbourHoodName
a.TYPE as buildingType,
b.NEIGHBOR_HOOD_NAME as neighbourHoodName,
c.ORGANIZATION_NAME as agencyName,
d.GRID_NAME as gridName
from ic_building a
LEFT JOIN ic_neighbor_hood b on a.NEIGHBOR_HOOD_ID = b.ID
LEFT JOIN ic_neighbor_hood b on a.NEIGHBOR_HOOD_ID = b.ID and b.DEL_FLAG='0'
LEFT JOIN customer_agency c on b.AGENCY_ID = c.ID and c.DEL_FLAG='0'
LEFT JOIN customer_grid d on b.GRID_ID = d.ID and d.DEL_FLAG='0'
<where>
<if test="building.neighborHoodId != null and building.neighborHoodId.trim() != ''">
AND a.NEIGHBOR_HOOD_ID = #{building.neighborHoodId}
<if test="building.id != null and building.id.trim() != ''">
AND a.NEIGHBOR_HOOD_ID = #{building.id}
</if>
<if test="building.buildingName != null and building.buildingName.trim() != ''">
AND a.BUILDING_NAME like concat('%',trim(#{building.buildingName}),'%')
<if test="(house.ownerName != null and house.ownerName.trim() != '') or (house.ownerPhone != null and house.ownerPhone.trim() != '')">
AND a.ID in (select distinct BUILDING_ID from ic_house e
<where>
<if test="house.ownerName != null and house.ownerName.trim() != ''">
AND e.OWNER_NAME = #{house.ownerName}
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND e.OWNER_PHONE = #{house.ownerPhone}
</if>
and e.DEL_FLAG='0'
</where>
)
</if>
<if test="building.delFlag != null and building.delFlag.trim() != ''">
AND a.DEL_FLAG = #{building.delFlag}
@ -73,6 +137,7 @@
</where>
</select>
<!--<select id="searchBuildingByPage" resultType="map">
select
a.ID as buildingId,
@ -182,36 +247,7 @@
</if>
</where>
</select>-->
<select id="searchAllBuilding" resultType="com.epmet.excel.IcBuildingExcel">
select
a.ID as buildingId,
a.BUILDING_NAME as buildingName,
a.TOTAL_HOUSE_NUM as totalHouseNum,
a.TOTAL_FLOOR_NUM as totalFloorNum,
a.TOTAL_UNIT_NUM as totalUnitNum,
a.BUILDING_NAME as buildingType,
b.NEIGHBOR_HOOD_NAME as neighbourHoodName,
c.ORGANIZATION_NAME as agencyName,
d.GRID_NAME as gridName
from ic_building a
LEFT JOIN ic_neighbor_hood b on a.NEIGHBOR_HOOD_ID = b.ID
LEFT JOIN customer_agency c on b.AGENCY_ID = c.ID
LEFT JOIN customer_grid c on b.GRID_ID = d.ID
<where>
<if test="building.id != null and building.id.trim() != ''">
AND a.NEIGHBOR_HOOD_ID = #{building.id}
</if>
<if test="building.buildingName != null and building.buildingName.trim() != ''">
AND a.BUILDING_NAME like concat('%',trim(#{building.buildingName}),'%')
</if>
<if test="building.delFlag != null and building.delFlag.trim() != ''">
AND a.DEL_FLAG = #{building.delFlag}
</if>
</where>
</select>
<select id="selectAgencyChildrenList" resultType="com.epmet.entity.CustomerAgencyEntity">
@ -241,15 +277,15 @@
from ic_neighbor_hood a
INNER JOIN ic_building b on a.ID = b.NEIGHBOR_HOOD_ID and b.DEL_FLAG = '0' and b.BUILDING_NAME in
<foreach collection="buildingNameList" open="(" separator="," close=")" item="val">
${val}
#{val}
</foreach>
INNER JOIN ic_building_unit c on b.ID = c.BUILDING_ID and c.DEL_FLAG = '0' and c.UNIT_NUM in
<foreach collection="buildingUnitList" open="(" separator="," close=")" item="val">
${val}
#{val}
</foreach>
WHERE a.DEL_FLAG = '0' and a.NEIGHBOR_HOOD_NAME in
<foreach collection="neighborNameList" open="(" separator="," close=")" item="val">
${val}
#{val}
</foreach>
</select>

85
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml

@ -105,12 +105,52 @@
</select>-->
<select id="searchHouseByPage" resultType="map">
select
a.HOUSE_NAME as houseName,
c.NEIGHBOR_HOOD_NAME as neighbourHoodName,
b.BUILDING_NAME as buildingName,
d.UNIT_NUM as unitNum,
a.DOOR_NAME as doorName,
a.HOUSE_TYPE as houseType,
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,
a.ID as houseId,
c.ID as neighbourHoodId,
b.ID as buildingId,
a.BUILDING_UNIT_ID as unitNumKey,
a.HOUSE_TYPE as houseTypeKey,
a.PURPOSE as purposeKey
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'
<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 = #{house.ownerName}
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND a.OWNER_PHONE = #{house.ownerPhone}
</if>
<if test="house.delFlag != null and house.delFlag.trim() != ''">
AND a.DEL_FLAG = #{house.delFlag}
</if>
</where>
</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,
a.RENT_FLAG as rentFlag,
if(a.RENT_FLAG=1,'是','否') as rentFlag,
a.OWNER_NAME as ownerName,
a.OWNER_PHONE as ownerPhone,
a.OWNER_ID_CARD as ownerIdCard,
@ -118,13 +158,12 @@
c.NEIGHBOR_HOOD_NAME as neighbourHoodName,
d.UNIT_NUM as unitName
from ic_house a
INNER JOIN ic_building b on a.BUILDING_ID = b.ID
INNER JOIN ic_neighbor_hood c on a.NEIGHBOR_HOOD_ID = c.ID
LEFT JOIN ic_building_unit d on a.BUILDING_UNIT_ID = d.ID
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.id != null and house.id.trim() != ''">
AND a.BUILDING_ID = #{house.id}
<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 = #{house.ownerName}
@ -188,39 +227,7 @@
</where>
</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,
a.RENT_FLAG 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 neighbourHoodName,
d.UNIT_NUM as unitName
from ic_house a
INNER JOIN ic_building b on a.BUILDING_ID = b.ID
INNER JOIN ic_neighbor_hood c on a.NEIGHBOR_HOOD_ID = c.ID
LEFT JOIN ic_building_unit d on a.BUILDING_UNIT_ID = d.ID
<where>
<if test="house.id != null and house.id.trim() != ''">
AND a.BUILDING_ID = #{house.id}
</if>
<if test="house.ownerName != null and house.ownerName.trim() != ''">
AND a.OWNER_NAME = #{house.ownerName}
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND a.OWNER_PHONE = #{house.ownerPhone}
</if>
<if test="house.delFlag != null and house.delFlag.trim() != ''">
AND a.DEL_FLAG = #{house.delFlag}
</if>
</where>
</select>
</mapper>

79
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml

@ -61,20 +61,47 @@
select
a.id as neighborHoodId,
a.NEIGHBOR_HOOD_NAME as neighborHoodName,
b.ORGANIZATION_NAME as agencyName,
c.GRID_NAME as gridName,
a.ADDRESS as address,
a.REMARK as remark,
b.ID as agencyId,
c.ID as gridId,
d.PROPERTY_ID as propertyId ,
a.LOCATION as location,
a.LONGITUDE as longitude,
a.LATITUDE as latitude
b.ORGANIZATION_NAME as orgName,
c.GRID_NAME as gridName
from ic_neighbor_hood a
left join customer_agency b on a.AGENCY_ID = b.ID
left join customer_agency b on a.AGENCY_ID = b.ID and b.DEL_FLAG='0'
left join customer_grid c on a.GRID_ID = c.ID
left join customer_grid c on a.GRID_ID = c.ID and c.DEL_FLAG='0'
left join ic_neighbor_hood_property d on a.ID = d.NEIGHBOR_HOOD_ID and d.DEL_FLAG='0'
<where>
<if test="neighbor.id != null and neighbor.id.trim() != ''">
AND a.GRID_ID = #{neighbor.id}
<if test="neighbor.gridId != null and neighbor.gridId.trim() != ''">
AND a.GRID_ID = #{neighbor.gridId}
</if>
<if test="neighbor.agencyId != null and neighbor.agencyId.trim() != ''">
AND (a.AGENCY_ID = #{neighbor.agencyId} or CONCAT(':',a.AGENCY_PIDS, ':') like CONCAT('%:',#{neighbor.agencyId},':%'))
</if>
<if test="(house.ownerName != null and house.ownerName.trim() != '') or (house.ownerPhone != null and house.ownerPhone.trim() != '')">
AND a.ID in (select NEIGHBOR_HOOD_ID from ic_house e
<where>
<if test="house.ownerName != null and house.ownerName.trim() != ''">
AND e.OWNER_NAME = #{house.ownerName}
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND e.OWNER_PHONE = #{house.ownerPhone}
</if>
and e.DEL_FLAG='0'
</where>
)
</if>
<if test="neighbor.delFlag != null and neighbor.delFlag.trim() != ''">
AND a.DEL_FLAG = #{neighbor.delFlag}
</if>
@ -90,17 +117,35 @@
c.GRID_NAME as gridName
from ic_neighbor_hood a
left join customer_agency b on a.AGENCY_ID = b.ID
left join customer_agency b on a.AGENCY_ID = b.ID and b.DEL_FLAG='0'
left join customer_grid c on a.GRID_ID = c.ID
left join ic_neighbor_hood_property d on a.ID = d.NEIGHBOR_HOOD_ID
left join ic_property_management e on d.PROPERTY_ID = e.ID
left join customer_grid c on a.GRID_ID = c.ID and c.DEL_FLAG='0'
left join ic_neighbor_hood_property d on a.ID = d.NEIGHBOR_HOOD_ID and d.DEL_FLAG='0'
left join ic_property_management e on d.PROPERTY_ID = e.ID and e.DEL_FLAG='0'
<where>
<if test="neighbor.id != null and neighbor.id.trim() != ''">
AND a.GRID_ID = #{neighbor.id}
<if test="neighbor.gridId != null and neighbor.gridId.trim() != ''">
AND a.GRID_ID = #{neighbor.gridId}
</if>
<if test="neighbor.agencyId != null and neighbor.agencyId.trim() != ''">
AND (a.AGENCY_ID = #{neighbor.agencyId} or CONCAT(':',a.AGENCY_PIDS, ':') like CONCAT('%:',#{neighbor.agencyId},':%'))
</if>
<if test="(house.ownerName != null and house.ownerName.trim() != '') or (house.ownerPhone != null and house.ownerPhone.trim() != '')">
AND a.ID in (select distinct NEIGHBOR_HOOD_ID from ic_house e
<where>
<if test="house.ownerName != null and house.ownerName.trim() != ''">
AND e.OWNER_NAME = #{house.ownerName}
</if>
<if test="house.ownerPhone != null and house.ownerPhone.trim() != ''">
AND e.OWNER_PHONE = #{house.ownerPhone}
</if>
and e.DEL_FLAG='0'
</where>
)
</if>
<if test="neighbor.delFlag != null and neighbor.delFlag.trim() != ''">
AND a.DEL_FLAG = #{building.delFlag}
AND a.DEL_FLAG = #{neighbor.delFlag}
</if>
</where>
</select>
@ -142,15 +187,15 @@
ic_neighbor_hood a
INNER JOIN customer_agency b on a.AGENCY_ID = b.ID and b.ORGANIZATION_NAME in
<foreach collection="agencyNameList" open="(" separator="," close=")" item="val">
${val}
#{val}
</foreach>
INNER JOIN customer_grid c on a.GRID_ID = c.ID and c.PID = b.ID and b.GRID_NAME in
INNER JOIN customer_grid c on a.GRID_ID = c.ID and c.PID = b.ID and c.GRID_NAME in
<foreach collection="gridNameList" open="(" separator="," close=")" item="val">
${val}
#{val}
</foreach>
where a.DEL_FLAG= '0'and a.NEIGHBOR_HOOD_NAME in
<foreach collection="neighborNameList" open="(" separator="," close=")" item="val">
${val}
#{val}
</foreach>
</select>

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

@ -17,10 +17,11 @@
package com.epmet.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
@ -37,21 +38,21 @@ import com.epmet.dto.IcResiUserDTO;
import com.epmet.dto.form.CustomerFormQueryDTO;
import com.epmet.dto.form.IcResiUserFormDTO;
import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.dto.result.FormGroupDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.excel.IcResiUserExcel;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.handler.ExcelDiceAddressListHandlerImpl;
import com.epmet.service.IcResiUserService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
@ -63,6 +64,7 @@ import java.util.Map;
@RestController
@RequestMapping("icresiuser")
public class IcResiUserController {
private static final String BASE_TABLE_NAME = "ic_resi_user";
@Autowired
private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient;
@ -136,80 +138,145 @@ public class IcResiUserController {
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO();
queryDTO.setFormCode("resi_base_info");
queryDTO.setCustomerId(customerId);
Result<CustomerFormResultDTO> resultForm = operCustomizeOpenFeignClient.getCustomerForm(queryDTO);
if (resultForm == null || !resultForm.success() ||resultForm.getData() == null){
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
System.out.println(JSON.toJSONString(resultForm.getData()));
List<ExcelExportEntity> firstHeaderList = new ArrayList<>();
XSSFWorkbook workbook = new XSSFWorkbook();
Map<String, List<ExcelExportEntity>> sheetHeaderMap = buildHeaderByItem(resultForm);
//Workbook workbook = null;
for (Map.Entry<String, List<ExcelExportEntity>> entry : sheetHeaderMap.entrySet()) {
String sheetName = entry.getKey();
List<ExcelExportEntity> headers = entry.getValue();
ExportParams exportParams = new ExportParams();
exportParams.setSheetName(sheetName);
exportParams.setAutoSize(true);
new ExcelExportService().createSheetForMap(workbook, exportParams, headers,new ArrayList<>());
}
List<? extends Name> allNames = workbook.getAllNames();
System.out.println("======"+allNames);
resultForm.getData().getItemList().forEach(item->{
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getColumnName().concat(String.valueOf(item.getColumnNum())));
header.setNeedMerge(true);
firstHeaderList.add(header);
String baseTableName = "resi_base_info";
FileOutputStream fos = new FileOutputStream("//Users/liujianjun/Downloads/基础信息表/Dow.tt.xls");
workbook.write(fos);
fos.close();
}
@NotNull
private Map<String,List<ExcelExportEntity>> buildHeaderByItem(Result<CustomerFormResultDTO> resultForm) {
//form中的itemlist 为一级表头 但是要排除每个item中含有childGroup的
List<FormItem> itemList = resultForm.getData().getItemList();
List<FormGroupDTO> groupList = resultForm.getData().getGroupList();
Map<String,List<ExcelExportEntity>> everySheetHeaderMap = new LinkedHashMap<>();
List<ExcelExportEntity> firstSheetHeaderList = new ArrayList<>();
itemList.forEach(item->{
if (StringUtils.isBlank(item.getColumnName())){
return;
}
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getColumnName().concat(String.valueOf(item.getColumnNum())),30);
header.setNeedMerge(true);
if (item.getChildGroup() == null){
System.out.println(item.getLabel());
firstSheetHeaderList.add(header);
return;
}
everySheetHeaderMap.putIfAbsent(resultForm.getData().getFormName(),firstSheetHeaderList);
//这些是动态的 formGroup
if (item.getChildGroup() != null){
//baseTableName单独的一个sheet
if (baseTableName.equals(item.getTableName())){
System.out.println("childGroup:"+item.getLabel());
if (BASE_TABLE_NAME.equals(item.getTableName())){
header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName());
header.setNeedMerge(true);
}else{
header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName());
header.setNeedMerge(true);
}
if (item.getColumnName().equals("GENDER")){
header.setReplace(new String[]{"男_1","女_2"});
}
List<ExcelExportEntity> otherSheetHeaderList = new ArrayList<>();
List<ExcelExportEntity> secondHeaderList = new ArrayList<>();
//这里是设置除基础信息之外的sheet的表头
item.getChildGroup().getItemList().forEach(item2->{
if (!BASE_TABLE_NAME.equals(item2.getTableName())){
everySheetHeaderMap.putIfAbsent(item.getLabel(),otherSheetHeaderList);
}
ExcelExportEntity secondHeader = new ExcelExportEntity(item2.getLabel(),item2.getColumnName().concat(String.valueOf(item2.getColumnNum())));
secondHeader.setNeedMerge(true);
secondHeaderList.add(secondHeader);
if (CollectionUtils.isNotEmpty(item2.getOptions())){
if (!item2.getItemType().equals("radio") && com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(item2.getOptions())){
List<ExcelExportEntity> thirdHeaderList = new ArrayList<>();
item2.getOptions().forEach(child->{
ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel());
thirdHeader.setNeedMerge(true);
thirdHeaderList.add(thirdHeader);
});
secondHeader.setList(thirdHeaderList);
}
});
header.setList(secondHeaderList);
firstHeaderList.add(header);
otherSheetHeaderList.add(header);
}
}
});
//List<ExcelExportEntity> firstSheetHeaderList = new ArrayList<>();
groupList.forEach(item->{
/* if (!"兴趣爱好".equals(item.getLabel()) && !"宗教信仰".equals(item.getLabel())){
return;
}*/
if (!BASE_TABLE_NAME.equals(item.getTableName())){
System.out.println(item.getLabel()+"--"+item.getTableName());
return;
}
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getTableName());
header.setNeedMerge(true);
List<ExcelExportEntity> secondHeaderList = new ArrayList<>();
item.getItemList().forEach(item2->{
ExcelExportEntity secondHeader = new ExcelExportEntity(item2.getLabel(),item2.getColumnName().concat(String.valueOf(item2.getColumnNum())));
secondHeader.setNeedMerge(true);
secondHeaderList.add(secondHeader);
if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(item2.getOptions())){
List<ExcelExportEntity> thirdHeaderList = new ArrayList<>();
item2.getOptions().forEach(child->{
ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel(),child.getValue()+ new Random(1).nextInt(2));
thirdHeader.setNeedMerge(true);
thirdHeaderList.add(thirdHeader);
});
secondHeader.setList(thirdHeaderList);
}
/* ExcelExportEntity desginGroup = new ExcelExportEntity("表头名称","键");
desginGroup.setNeedMerge(true);
List<ExcelExportEntity> paramCols = new ArrayList<>();
List<String> headerList = Arrays.asList("头1","头2","头3");
headerList.forEach(e->{
paramCols.add(new ExcelExportEntity(e,e,30));
});
header.setList(secondHeaderList);
firstSheetHeaderList.add(header);
System.out.println(JSON.toJSONString(firstSheetHeaderList));
});
return everySheetHeaderMap;
}
desginGroup.setList(paramCols);
colList.add(desginGroup);*/
List<Map<String, String>> dataList =new ArrayList<>();
Map<String,String> dataMap = new HashMap<>();
dataMap.put("GENDER0","1");
dataMap.put("ID_CARD0","371888991");
private void buildHeader(Map<String, List<ExcelExportEntity>> everySheetHeaderMap, FormItem item, ExcelExportEntity header) {
List<ExcelExportEntity> firstSheetHeaderList = new ArrayList<>();
List<ExcelExportEntity> secondHeaderList = new ArrayList<>();
item.getChildGroup().getItemList().forEach(item2->{
if (!BASE_TABLE_NAME.equals(item2.getTableName())){
everySheetHeaderMap.putIfAbsent(item.getLabel(),firstSheetHeaderList);
}
ExcelExportEntity secondHeader = new ExcelExportEntity(item2.getLabel(),item2.getColumnName().concat(String.valueOf(item2.getColumnNum())));
secondHeader.setNeedMerge(true);
secondHeaderList.add(secondHeader);
if (CollectionUtils.isNotEmpty(item2.getOptions())){
List<ExcelExportEntity> thirdHeaderList = new ArrayList<>();
item2.getOptions().forEach(child->{
ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel());
thirdHeaderList.add(thirdHeader);
});
secondHeader.setList(thirdHeaderList);
}
dataList.add(dataMap);
ExportParams exportParams = new ExportParams();
exportParams.setDictHandler(new ExcelDiceAddressListHandlerImpl());
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, firstHeaderList, dataList);
//ExcelExportUtil.exportExcel
FileOutputStream fos = new FileOutputStream("//Users/liujianjun/Downloads/基础信息表/Dow.tt.xls");
workbook.write(fos);
fos.close();
});
header.setList(secondHeaderList);
firstSheetHeaderList.add(header);
everySheetHeaderMap.putIfAbsent(item.getLabel(),firstSheetHeaderList);
}
}

5
pom.xml

@ -97,6 +97,11 @@
</dependencyManagement>
<repositories>
<repository>
<id>mvnrepo</id>
<name>jianjun gitee</name>
<url>https://gitee.com/jianjun4833/easypoi.git/</url>
</repository>
<repository>
<id>public</id>
<name>aliyun nexus</name>

Loading…
Cancel
Save