diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index e73e2b5e6f..31e2276fc4 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -89,6 +89,8 @@ cn.afterturn easypoi-base ${easypoi.version} + cn.afterturn diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java index a7b77e0b90..49a21f262e 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java +++ b/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"; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java index da2b08fc09..592c5a4776 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java +++ b/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; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java index 022a34ad6e..2f28b22eee 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java +++ b/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; /** * 房主姓名 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java index 5e6aebef29..98a6ad0fde 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java +++ b/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; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcPropertyManagementFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcPropertyManagementFormDTO.java new file mode 100644 index 0000000000..ae5f2f9903 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java index 3e7eecf9b8..80b95263b6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java +++ b/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; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java index 77358255e1..ca53315d02 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java +++ b/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; /** * 结果集 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcPropertyManagementResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcPropertyManagementResultDTO.java new file mode 100644 index 0000000000..6f2e058206 --- /dev/null +++ b/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; + + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index 632f57fd3f..81fccb5087 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/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 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 map = new HashMap<>(); + map.put("maplist",new ArrayList()); + 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 importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcBuildingExcel.class); + + List 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 result =importResult.getList(); + + buildingService.importExcel(customerId,result); + return new Result().ok("导入成功"); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 82eb115b44..3e96997238 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -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 map = new HashMap<>(); + map.put("maplist",new ArrayList()); + 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 importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcHouseExcel.class); + + List 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 result =importResult.getList(); + + houseService.importExcel(customerId,result); + return new Result().ok("导入成功"); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java index 97aa10b5b8..8d98ad3c8a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java +++ b/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 icBuildingEntities = icBuildingDao.selectList(new QueryWrapper().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 map = new HashMap<>(); + map.put("maplist",new ArrayList()); + 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 map = new HashMap<>(); + map.put("maplist",new ArrayList()); + 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 result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class); - neighborHoodService.importExcel(customerId,result); - }else if(NeighborhoodConstant.BUILDING.equals(dataType)){ - List result = ExcelPoiUtils.importExcel(file, 0, 1, IcBuildingExcel.class); - buildingService.importExcel(customerId,result); - }else if(NeighborhoodConstant.HOUSE.equals(dataType)){ - List result = ExcelPoiUtils.importExcel(file, 0, 1, IcHouseExcel.class); - houseService.importExcel(customerId,result); + ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcNeighborHoodExcel.class); +// List result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class); + List 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 result =importResult.getList(); +// log.info(JSON.toJSONString(result)); + neighborHoodService.importExcel(customerId,result); + return new Result(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PropertyManagementController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PropertyManagementController.java new file mode 100644 index 0000000000..6d35f9af68 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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(){ + return new Result>().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(); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java index becb5ad1b8..511daa2fad 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java +++ b/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 { // @Param("neighbor") IcNeighborHoodEntity neighbor, // @Param("building")IcBuildingEntity building); IPage> searchBuildingByPage(IPage page, - @Param("building")IcBuildingEntity building); + @Param("building")IcBuildingEntity building, @Param("house") IcHouseEntity house); // List searchAllBuilding(@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper, // @Param("ew1") QueryWrapper buildingEntityQueryWrapper); // List searchAllBuilding(@Param("neighbor") IcNeighborHoodEntity neighbor, // @Param("building")IcBuildingEntity building); List searchAllBuilding( - @Param("building")IcBuildingEntity building); + @Param("building")IcBuildingEntity building, @Param("house")IcHouseEntity house); List selectAgencyChildrenList(@Param("agencyId") String agencyId); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index 929a8ab570..e82789db12 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -51,7 +51,5 @@ public interface IcHouseDao extends BaseDao { IPage> searchHouseByPage(IPage page, @Param("house") IcHouseEntity house); - List searchAllHouse(@Param("neighbor") IcNeighborHoodEntity neighbor, - @Param("building") IcBuildingEntity building, - @Param("house") IcHouseEntity house); + List searchAllHouse(@Param("house") IcHouseEntity house); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java index 919cd34707..4da3423f9d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java +++ b/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 { // IPage> searchNeighborhoodByPage(IPage page,@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); - IPage> searchNeighborhoodByPage(IPage page,@Param("neighbor") IcNeighborHoodEntity neighbor); + IPage> searchNeighborhoodByPage(IPage page, @Param("neighbor") IcNeighborHoodEntity neighbor, @Param("house")IcHouseEntity house); // List searchAllNeighborhood(@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); - List searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor); + List searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor, @Param("house")IcHouseEntity house); List selectListByName(@Param("neighborNameList")List neighborNameList, @Param("agencyNameList") List agencyNameList, diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java index 230f8d26e0..d29a14942e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java +++ b/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; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java index d51725fd6e..c606388a25 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java +++ b/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; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java index 2926485139..71fcec8379 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java +++ b/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 = "详细地址") diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java index 8cdad17d3e..39df4d14df 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java +++ b/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 treeList(String customerId); void importExcel(String customerId, List list); + + IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO); + + void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index 258c8c020d..20978c60b2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -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 list); + + IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO); + + void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PropertyManagementService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PropertyManagementService.java new file mode 100644 index 0000000000..5fe43468e9 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 getList(); + + void add(IcPropertyManagementFormDTO formDTO); + + void update(IcPropertyManagementFormDTO formDTO); + void delete(IcPropertyManagementFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 2ae7a5ac42..d6b989fbd0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/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 unitList = new ArrayList<>(); for(int i =0 ;iu.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> 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 icBuildingExcels = searchAllBuilding(formDTO); + TemplateExportParams templatePath = new TemplateExportParams("excel/building_export.xlsx"); + Map map = new HashMap<>(); + map.put("maplist",icBuildingExcels); + ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"楼宇信息录入表",response); + return ; + } + private List searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) { + +// QueryWrapper 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 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> searchBuilding(ListIcNeighborHoodFormDTO formDTO) { + IPage page = new Page(formDTO.getPageNo(),formDTO.getPageSize()); + +// IcNeighborHoodEntity neighbor = new IcNeighborHoodEntity(); +// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); + +// QueryWrapper 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 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 covertToTree(CustomerAgencyEntity customerAgency,List 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 icHouseEntities = icHouseDao.selectList(new QueryWrapper().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 unitList = new ArrayList<>(); + for(int i =unit ;i icHouseEntities = icHouseDao.selectList(new QueryWrapper().lambda().eq(IcHouseEntity::getBuildingId, buildingId)); + if(!CollectionUtils.isEmpty(icHouseEntities)){ + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法删除"); + } + //删除楼宇 icBuildingService.deleteById(buildingId); + //删除楼宇单元 + icBuildingUnitDao.delete(new QueryWrapper().lambda().eq(IcBuildingUnitEntity::getBuildingId,buildingId)); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 724a35b032..ce495c0ebc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -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 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.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName()); - } + + 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> 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 icHouseExcels = searchAllHouse(formDTO); + TemplateExportParams templatePath = new TemplateExportParams("excel/house_export.xlsx"); + Map map = new HashMap<>(); + map.put("maplist",icHouseExcels); + ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"房屋信息录入表",response); + + return ; + } + private List 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> searchHouse(ListIcNeighborHoodFormDTO formDTO) { + IPage page = new Page(formDTO.getPageNo(),formDTO.getPageSize()); + +// QueryWrapper 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 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 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); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java index fff8156f11..dc96ce0dd8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java +++ b/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> resultMap = searchNeighborhood(formDTO); - result.setTotal(resultMap.getTotal()); - result.setList(resultMap.getRecords()); - }else if(NeighborhoodConstant.BUILDING.equals(dataType)){ - //如果类型是building 查楼栋 - IPage> resultMap = searchBuilding(formDTO); - result.setTotal(resultMap.getTotal()); - result.setList(resultMap.getRecords()); - }else if(NeighborhoodConstant.HOUSE.equals(dataType)){ - //如果类型是house 查房屋 - IPage> resultMap = searchHouse(formDTO); - result.setTotal(resultMap.getTotal()); - result.setList(resultMap.getRecords()); - } - return result; - - } - - - - private IPage> searchHouse(ListIcNeighborHoodFormDTO formDTO) { - IPage page = new Page(formDTO.getPageNo(),formDTO.getPageSize()); - -// QueryWrapper 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); + IPage> resultMap = searchNeighborhood(formDTO); + result.setTotal(resultMap.getTotal()); + result.setList(resultMap.getRecords()); -// QueryWrapper 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 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 result; - return icHouseDao.searchHouseByPage(page,house); } - private IPage> searchBuilding(ListIcNeighborHoodFormDTO formDTO) { - IPage page = new Page(formDTO.getPageNo(),formDTO.getPageSize()); -// IcNeighborHoodEntity neighbor = new IcNeighborHoodEntity(); -// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); -// QueryWrapper 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 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> 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 icNeighborHoodExcels = searchAllNeighborhood(formDTO); + //导出小区 + List 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 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 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 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 searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) { - -// QueryWrapper 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 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 searchAllNeighborhood(ListIcNeighborHoodFormDTO formDTO) { // QueryWrapper 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 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); - } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PropertyManagementServiceImpl.java new file mode 100644 index 0000000000..4068fb710d --- /dev/null +++ b/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 getList() { + List propertyManagementEntityList = icPropertyManagementDao.selectList(null); + List 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 list = icNeighborHoodPropertyDao.selectList(new QueryWrapper().lambda().eq(IcNeighborHoodPropertyEntity::getPropertyId, formDTO.getId())); + if(!CollectionUtils.isEmpty(list)){ + throw new RenException("物业存在与小区关联,无法删除"); + } + icPropertyManagementDao.deleteById(formDTO.getId()); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java index fa03b631d1..38ea2c597c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java +++ b/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 * @return */ - public static ExcelImportResult importExcelMore(MultipartFile file, Class pojoClass) throws IOException { + public static ExcelImportResult importExcelMore(MultipartFile file,Integer titleRows, Integer headerRows, Class 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 * @return */ - private static ExcelImportResult importExcelMore(InputStream inputStream, Class pojoClass) throws IOException { + private static ExcelImportResult importExcelMore(InputStream inputStream,Integer titleRows, Integer headerRows, Class 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 { diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelVerifyInfo.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelVerifyInfo.java new file mode 100644 index 0000000000..42be514c98 --- /dev/null +++ b/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; + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export.xlsx new file mode 100644 index 0000000000..2e2fbd53a4 Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_export.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx new file mode 100644 index 0000000000..9460a651da Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_export.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export.xlsx new file mode 100644 index 0000000000..2a1b3237d9 Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_export.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml index 0cb73c45a8..1226c7ec74 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml @@ -48,24 +48,88 @@ + + - diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index e62cb42010..01764d05ad 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -104,39 +104,78 @@ --> + - \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index b1d6f0c7e3..8c00a943d6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/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 and c.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 and d.DEL_FLAG='0' - - AND a.GRID_ID = #{neighbor.id} + + AND a.GRID_ID = #{neighbor.gridId} + + AND (a.AGENCY_ID = #{neighbor.agencyId} or CONCAT(':',a.AGENCY_PIDS, ':') like CONCAT('%:',#{neighbor.agencyId},':%')) + + + + AND a.ID in (select NEIGHBOR_HOOD_ID from ic_house e + + + AND e.OWNER_NAME = #{house.ownerName} + + + AND e.OWNER_PHONE = #{house.ownerPhone} + + and e.DEL_FLAG='0' + + ) + + + AND a.DEL_FLAG = #{neighbor.delFlag} @@ -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' - - AND a.GRID_ID = #{neighbor.id} + + AND a.GRID_ID = #{neighbor.gridId} + + + AND (a.AGENCY_ID = #{neighbor.agencyId} or CONCAT(':',a.AGENCY_PIDS, ':') like CONCAT('%:',#{neighbor.agencyId},':%')) + + + AND a.ID in (select distinct NEIGHBOR_HOOD_ID from ic_house e + + + AND e.OWNER_NAME = #{house.ownerName} + + + AND e.OWNER_PHONE = #{house.ownerPhone} + + and e.DEL_FLAG='0' + + ) + + - AND a.DEL_FLAG = #{building.delFlag} + AND a.DEL_FLAG = #{neighbor.delFlag} @@ -142,15 +187,15 @@ ic_neighbor_hood a INNER JOIN customer_agency b on a.AGENCY_ID = b.ID and b.ORGANIZATION_NAME in - ${val} + #{val} - 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 - ${val} + #{val} where a.DEL_FLAG= '0'and a.NEIGHBOR_HOOD_NAME in - ${val} + #{val} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 4e49766a21..753b3e5fe4 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/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 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 firstHeaderList = new ArrayList<>(); + XSSFWorkbook workbook = new XSSFWorkbook(); + Map> sheetHeaderMap = buildHeaderByItem(resultForm); + //Workbook workbook = null; + for (Map.Entry> entry : sheetHeaderMap.entrySet()) { + String sheetName = entry.getKey(); + List headers = entry.getValue(); + ExportParams exportParams = new ExportParams(); + exportParams.setSheetName(sheetName); + exportParams.setAutoSize(true); + new ExcelExportService().createSheetForMap(workbook, exportParams, headers,new ArrayList<>()); + } + List 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> buildHeaderByItem(Result resultForm) { + //form中的itemlist 为一级表头 但是要排除每个item中含有childGroup的 + + List itemList = resultForm.getData().getItemList(); + List groupList = resultForm.getData().getGroupList(); + + Map> everySheetHeaderMap = new LinkedHashMap<>(); + + List 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())){ - header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName()); - header.setNeedMerge(true); - }else{ + 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); + List otherSheetHeaderList = new ArrayList<>(); + List 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 (!item2.getItemType().equals("radio") && com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(item2.getOptions())){ + List thirdHeaderList = new ArrayList<>(); + item2.getOptions().forEach(child->{ + ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel()); + thirdHeaderList.add(thirdHeader); + }); + secondHeader.setList(thirdHeaderList); + } + + }); + header.setList(secondHeaderList); + otherSheetHeaderList.add(header); } - if (item.getColumnName().equals("GENDER")){ - header.setReplace(new String[]{"男_1","女_2"}); - } - List secondHeaderList = new ArrayList<>(); - item.getChildGroup().getItemList().forEach(item2->{ - 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 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); } }); + //List 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 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 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); + } + }); + header.setList(secondHeaderList); + firstSheetHeaderList.add(header); + System.out.println(JSON.toJSONString(firstSheetHeaderList)); + }); + return everySheetHeaderMap; + } + private void buildHeader(Map> everySheetHeaderMap, FormItem item, ExcelExportEntity header) { + List firstSheetHeaderList = new ArrayList<>(); + List 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 thirdHeaderList = new ArrayList<>(); + item2.getOptions().forEach(child->{ + ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel()); + thirdHeaderList.add(thirdHeader); + }); + secondHeader.setList(thirdHeaderList); + } - - - /* ExcelExportEntity desginGroup = new ExcelExportEntity("表头名称","键"); - desginGroup.setNeedMerge(true); - List paramCols = new ArrayList<>(); - List headerList = Arrays.asList("头1","头2","头3"); - headerList.forEach(e->{ - paramCols.add(new ExcelExportEntity(e,e,30)); }); - - desginGroup.setList(paramCols); - colList.add(desginGroup);*/ - List> dataList =new ArrayList<>(); - Map dataMap = new HashMap<>(); - dataMap.put("GENDER0","1"); - dataMap.put("ID_CARD0","371888991"); - - 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); } } diff --git a/pom.xml b/pom.xml index 8e34094ca6..0cbc5c73fa 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,11 @@ + + mvnrepo + jianjun gitee + https://gitee.com/jianjun4833/easypoi.git/ + public aliyun nexus