diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/BuildingTreeLevelDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/BuildingTreeLevelDTO.java new file mode 100644 index 0000000000..3d7da25047 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/BuildingTreeLevelDTO.java @@ -0,0 +1,52 @@ +/** + * 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; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +/** + * 楼栋信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +@Data +public class BuildingTreeLevelDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + + private String id; + + private String pId; + + private String label; + + + private String level; + + private List children; + + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcBuildingDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcBuildingDTO.java index 61eba8fd2e..4d9aa11d17 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcBuildingDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcBuildingDTO.java @@ -59,6 +59,7 @@ public class IcBuildingDTO implements Serializable { */ private String buildingName; + /** * 楼栋类型,这里存储字典编码就可以 */ 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 new file mode 100644 index 0000000000..da2b08fc09 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java @@ -0,0 +1,119 @@ +/** + * 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 IcBulidingFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + public interface DeleteGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "楼栋ID不能为空", groups = { UpdateGroup.class,DeleteGroup.class}) + private String buildingId; + + /** + * 组织id + */ + @NotBlank(message = "组织id不能为空", groups = {AddGroup.class}) + private String agencyId; + + + /** + * 网格id + */ + + private String gridId; + + + /** + * 小区id + */ + @NotBlank(message = "小区id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String neighborHoodId; + + /** + * 楼栋名称 + */ + @NotBlank(message = "楼栋名称不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @Length(max=10,message = "楼栋名称不能超过10个字", groups = {AddGroup.class, UpdateGroup.class}) + private String buildingName; + + /** + * 客户id + */ + /* @NotBlank(message = "客户id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String customerId;*/ + + /** + * 排序 + */ + @NotBlank(message = "排序不能为空", groups = { UpdateGroup.class}) + private Integer sort = 0; + + /** + * 总单元数 + */ + @NotBlank(message = "总单元数不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private Integer totalUnitNum=1; + + /** + * 总楼层总数 + */ + @NotBlank(message = "总楼层总数不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private Integer totalFloorNum; + + /** + * 总户数 + */ + @NotBlank(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; + + + + +} \ No newline at end of file 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 new file mode 100644 index 0000000000..022a34ad6e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java @@ -0,0 +1,101 @@ +/** + * 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 IcHouseFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + public interface DeleteGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "房屋ID不能为空", groups = { UpdateGroup.class,DeleteGroup.class}) + private String houseId; + + + /** + * 小区id + */ + @NotBlank(message = "小区id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String neighborHoodId; + + @NotBlank(message = "所属楼栋ID不能为空", groups = { UpdateGroup.class}) + private String belongBuildingId; + + /** + * 所属单元id + */ + @NotBlank(message = "所属单元id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String buildingUnitId; + + + + /** + * 门牌号 + */ + @NotBlank(message = "门牌号不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String doorName; + + /** + * 房屋类型,这里存储字典value就可以 + */ + @NotBlank(message = "房屋类型不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String houseType; + + /** + * 存储字典value + */ + @NotBlank(message = "房屋用途不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String purpose; + + /** + * 1出租;0未出租 + */ + @NotBlank(message = "是否出租不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private Boolean rentFlag; + + /** + * 房主姓名 + */ + @NotBlank(message = "房主姓名不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String ownerName; + + /** + * 房主电话 + */ + @NotBlank(message = "房主电话不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String ownerPhone; + + /** + * 房主身份证号 + */ + @NotBlank(message = "房主身份证号不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String ownerIdCard; + +} \ 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 49839dfe4a..3e7eecf9b8 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 @@ -31,22 +31,29 @@ public class ListIcNeighborHoodFormDTO implements Serializable{ * */ private Integer pageSize = 20; + /** + * 组织类别 + */ + private String level ; + + private String id; + /** * 组织ID */ - private String agencyId; +// private String agencyId; /** * 网格ID */ - private String gridId; +// private String gridId; /** * 小区名字 */ - private String neighborHoodName; +// private String neighborHoodName; /** * 楼栋名字 */ - private String buildingName; +// private String buildingName; /** * 房主姓名 */ @@ -59,15 +66,15 @@ public class ListIcNeighborHoodFormDTO implements Serializable{ * 数据类型【小区:neighbourHood,楼栋:building,房屋:house】 */ // @Pattern(regexp = "^(neighbourHood|building|house)?$",message = "数据类型选择错误") - private String dataType; +// private String dataType; /** * 楼栋ID */ - private String buildingId; +// private String buildingId; /** * 小区ID */ - private String neighborHoodId; +// private String neighborHoodId; } diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 13561a58a3..ccbc334ede 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -129,8 +129,19 @@ true + + org.apache.maven.plugins + maven-resources-plugin + + + xls + xlsx + + + + ${project.basedir}/src/main/java 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 new file mode 100644 index 0000000000..632f57fd3f --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -0,0 +1,115 @@ +/** + * 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.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.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.IcNeighborHoodExcel; +import com.epmet.service.BuildingService; +import com.epmet.service.IcBuildingService; +import com.epmet.service.IcNeighborHoodService; +import com.epmet.service.NeighborHoodService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 楼栋信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +@Slf4j +@RestController +@RequestMapping("building") +public class BuildingController { + + + @Autowired + private NeighborHoodService neighborHoodService; + + @Autowired + private IcBuildingService icBuildingService; + @Autowired + private BuildingService buildingService; + + + + @PostMapping("buildinglist") + public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO); + return new Result().ok(icNeighborHoodResultDTO); + + } + + @PostMapping("buildingadd") + public Result buildingAdd(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, AddGroup.class); + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + + buildingService.AddBuilding(customerId,formDTO); + return new Result().ok("保存成功"); + } + + @PostMapping("buildingupdate") + public Result buildingUpdate(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + buildingService.UpdateBuilding(customerId,formDTO); + return new Result().ok("修改成功"); + } + + @PostMapping("buildingdel") + public Result buildingDel(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, IcBulidingFormDTO.DeleteGroup.class); + String buildingId = formDTO.getBuildingId(); + buildingService.DelBuilding(buildingId); + return new Result(); + } + + @PostMapping("treelist") + public Result treeList(@LoginUser TokenDto tokenDTO){ + List buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getUserId()); + return new Result().ok(buildingTreeLevelDTOS); + } + + +} \ 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 new file mode 100644 index 0000000000..82eb115b44 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -0,0 +1,97 @@ +/** + * 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.IcHouseFormDTO; +import com.epmet.dto.form.IcNeighborHoodFormDTO; +import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.service.HouseService; +import com.epmet.service.NeighborHoodService; +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; + + +/** + * 房屋表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +@Slf4j +@RestController +@RequestMapping("house") +public class HouseController { + + + @Autowired + private NeighborHoodService neighborHoodService; + + @Autowired + private HouseService houseService; + + + @PostMapping("houselist") + public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO); + return new Result().ok(icNeighborHoodResultDTO); + + } + + @PostMapping("houseadd") + public Result houseAdd(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, AddGroup.class); + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + + houseService.addHouse(customerId,formDTO); + return new Result(); + } + + @PostMapping("houseupdate") + public Result houseUpdate(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; + houseService.updateHouse(customerId,formDTO); + return new Result(); + } + + @PostMapping("housedel") + public Result houseDel(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, IcNeighborHoodFormDTO.DeleteGroup.class); + houseService.delHouse(formDTO.getHouseId()); + return new Result(); + } + +} \ 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 bde7b11c0c..97aa10b5b8 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,24 +17,40 @@ package com.epmet.controller; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.epmet.commons.tools.annotation.LoginUser; -import com.epmet.commons.tools.page.PageData; +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.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.constant.NeighborhoodConstant; 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.HouseService; 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.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.net.URLEncoder; +import java.util.HashMap; +import java.util.List; import java.util.Map; @@ -44,6 +60,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2021-10-25 */ +@Slf4j @RestController @RequestMapping("neighborhood") public class NeighborHoodController { @@ -52,6 +69,10 @@ public class NeighborHoodController { private IcNeighborHoodService icNeighborHoodService; @Autowired private NeighborHoodService neighborHoodService; + @Autowired + private BuildingService buildingService; + @Autowired + private HouseService houseService; @@ -70,6 +91,7 @@ public class NeighborHoodController { //效验数据 ValidatorUtils.validateEntity(formDTO, AddGroup.class); String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; neighborHoodService.AddNeighborhood(customerId,formDTO); return new Result(); @@ -80,6 +102,7 @@ public class NeighborHoodController { //效验数据 ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); String customerId = tokenDTO.getCustomerId(); +// String customerId = "123123"; neighborHoodService.UpdateNeighborhood(customerId,formDTO); return new Result(); } @@ -94,40 +117,62 @@ public class NeighborHoodController { } - @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = icNeighborHoodService.page(params); - return new Result>().ok(page); - } + /** + * 导出 + * @param formDTO + * @param response + * @throws Exception + */ + @RequestMapping("exportneighborhoodinfo") + public void exportneighborhoodinfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { + ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + neighborHoodService.exportNeighborhoodinfo(formDTO,response); - @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - IcNeighborHoodDTO data = icNeighborHoodService.get(id); - return new Result().ok(data); } - @PostMapping - public Result save(@RequestBody IcNeighborHoodDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - icNeighborHoodService.save(dto); - return new Result(); - } - @PutMapping - public Result update(@RequestBody IcNeighborHoodDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - icNeighborHoodService.update(dto); - return new Result(); - } - @DeleteMapping - public Result delete(@RequestBody String[] ids){ - //效验数据 - AssertUtils.isArrayEmpty(ids, "id"); - icNeighborHoodService.delete(ids); - return new Result(); +// /** +// * 导入 +// * @param params +// * @param response +// * @throws Exception +// */ +// @PostMapping("importneighborhoodinfo") +// public void importneighborhoodinfo(@RequestParam Map params, HttpServletResponse response) throws Exception { +// List list = icNeighborHoodService.list(params); +// ExcelUtils.exportExcelToTarget(response, "小区信息录入表", list, IcNeighborHoodExcel.class); +//// ExcelUtils.expor +// } + + /** + * 导入数据 + * @param file + * @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); + } + 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); + } + 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/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java index d800bb6761..becb5ad1b8 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 @@ -17,9 +17,20 @@ package com.epmet.dao; +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.CustomerAgencyEntity; import com.epmet.entity.IcBuildingEntity; +import com.epmet.entity.IcNeighborHoodEntity; +import com.epmet.excel.IcBuildingExcel; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** * 楼栋信息 @@ -29,5 +40,23 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcBuildingDao extends BaseDao { - + +// IPage> searchBuildingByPage(IPage page, +// @Param("neighbor") IcNeighborHoodEntity neighbor, +// @Param("building")IcBuildingEntity building); + IPage> searchBuildingByPage(IPage page, + @Param("building")IcBuildingEntity building); + +// 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); + + List selectAgencyChildrenList(@Param("agencyId") String agencyId); + + List> selectListByName(@Param("neighborNameList")ArrayList strings, + @Param("buildingNameList") ArrayList strings1, + @Param("buildingUnitList") ArrayList integers); } \ No newline at end of file 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 e8c196935d..929a8ab570 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 @@ -17,9 +17,19 @@ package com.epmet.dao; +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.IcBuildingEntity; import com.epmet.entity.IcHouseEntity; +import com.epmet.entity.IcNeighborHoodEntity; +import com.epmet.excel.IcHouseExcel; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * 房屋信息 @@ -29,5 +39,19 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcHouseDao extends BaseDao { - + +// IPage> searchHouseByPage(IPage page, +// @Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper, +// @Param("ew1") QueryWrapper buildingEntityQueryWrapper, +// @Param("ew2") QueryWrapper houseEntityQueryWrapper); +// IPage> searchHouseByPage(IPage page, +// @Param("neighbor") IcNeighborHoodEntity neighbor, +// @Param("building") IcBuildingEntity building, +// @Param("house") IcHouseEntity house); + IPage> searchHouseByPage(IPage page, + @Param("house") IcHouseEntity house); + + List searchAllHouse(@Param("neighbor") IcNeighborHoodEntity neighbor, + @Param("building") IcBuildingEntity building, + @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 9616584401..919cd34707 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 @@ -22,10 +22,13 @@ 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.IcNeighborHoodEntity; +import com.epmet.excel.IcNeighborHoodExcel; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; import java.util.Map; +import java.util.Set; /** * 小区表 @@ -36,5 +39,13 @@ import java.util.Map; @Mapper public interface IcNeighborHoodDao extends BaseDao { - IPage> searchNeighborhoodByPage(IPage page,@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); +// IPage> searchNeighborhoodByPage(IPage page,@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); + IPage> searchNeighborhoodByPage(IPage page,@Param("neighbor") IcNeighborHoodEntity neighbor); + +// List searchAllNeighborhood(@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); + List searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor); + + List selectListByName(@Param("neighborNameList")List neighborNameList, + @Param("agencyNameList") List agencyNameList, + @Param("gridNameList") List gridNameList); } \ No newline at end of file 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 new file mode 100644 index 0000000000..230f8d26e0 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcBuildingExcel.java @@ -0,0 +1,121 @@ +/** + * 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.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * 楼栋信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-27 + */ +@Data +public class IcBuildingExcel { + + /*@Excel(name = "楼栋主键") + private String id; + + @Excel(name = "客户id") + private String customerId; + + @Excel(name = "小区id") + private String neighborHoodId; + + @Excel(name = "片区id,neighbor_hood_part.id,可为空。") + private String partId; + + @Excel(name = "楼栋名称") + private String buildingName; + + @Excel(name = "楼栋类型,这里存储字典编码就可以") + private String type; + + @Excel(name = "排序") + private Integer sort; + + @Excel(name = "总单元数") + private Integer totalUnitNum; + + @Excel(name = "总楼层总数") + private Integer totalFloorNum; + + @Excel(name = "总户数") + private Integer totalHouseNum; + + @Excel(name = "中心点位:经度") + private String longitude; + + @Excel(name = "中心点位:纬度") + private String latitude; + + @Excel(name = "坐标位置") + private String coordinatePosition; + + @Excel(name = "删除标识 0未删除、1已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime;*/ + + @Excel(name = "所属组织") + @NotBlank(message = "所属组织不能位空") + private String agencyName; + + @Excel(name = "所属网格") + @NotBlank(message = "所属网格不能位空") + private String gridName; + + @Excel(name = "小区名称") + @NotBlank(message = "小区名称不能位空") + @Length(max=50,message = "小区名称不能超过50个字") + private String neighborHoodName; + + @Excel(name = "楼栋名称") + @NotBlank(message = "楼栋名称不能位空") + private String buildingName; + + @Excel(name = "单元数") + @NotBlank(message = "单元数不能位空") + private Integer totalUnitNum; + + @Excel(name = "层数") + @NotBlank(message = "层数不能位空") + private Integer totalFloorNum; + + @Excel(name = "户数") + @NotBlank(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 new file mode 100644 index 0000000000..d51725fd6e --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcHouseExcel.java @@ -0,0 +1,139 @@ +/** + * 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.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * 房屋信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-27 + */ +@Data +public class IcHouseExcel { + + /*@Excel(name = "房屋主键") + private String id; + + @Excel(name = "客户id") + private String customerId; + + @Excel(name = "小区id") + private String neighborHoodId; + + @Excel(name = "片区id,neighbor_hood_part.id,可为空。") + private String partId; + + @Excel(name = "所属楼栋id") + private String buildingId; + + @Excel(name = "所属单元id") + private String buildingUnitId; + + @Excel(name = "房屋名字后台插入时生成") + private String houseName; + + @Excel(name = "门牌号") + private String doorName; + + @Excel(name = "房屋类型,这里存储字典value就可以") + private String houseType; + + @Excel(name = "存储字典value") + private String purpose; + + @Excel(name = "1出租;0未出租") + private Integer rentFlag; + + @Excel(name = "房主姓名") + private String ownerName; + + @Excel(name = "房主电话") + private String ownerPhone; + + @Excel(name = "房主身份证号") + private String ownerIdCard; + + @Excel(name = "删除标识 0未删除、1已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime;*/ + + + + @Excel(name = "小区名称") + @NotBlank(message = "小区名称不能位空") + @Length(max=50,message = "小区名称不能超过50个字") + private String neighborHoodName; + + @Excel(name = "楼栋名称") + @NotBlank(message = "楼栋名称不能位空") + private String buildingName; + + @Excel(name = "单元号") + @NotBlank(message = "单元号不能位空") + private Integer buildingUnit; + + @Excel(name = "门牌号") + @NotBlank(message = "门牌号不能位空") + private String doorName; + + @Excel(name = "房屋类型") + @NotBlank(message = "房屋类型不能位空") + private String houseType; + + @Excel(name = "房屋用途") + @NotBlank(message = "房屋用途不能位空") + private String purpose; + + @Excel(name = "出租") + @NotBlank(message = "出租不能位空") + private String rentFlag; + + @Excel(name = "房主姓名") + @NotBlank(message = "房主姓名不能位空") + private String ownerName; + + @Excel(name = "房主电话") + @NotBlank(message = "房主电话不能位空") + private String ownerPhone; + + @Excel(name = "房主身份证号") + @NotBlank(message = "房主身份证号不能位空") + private String ownerIdCard; + +} \ No newline at end of file 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 new file mode 100644 index 0000000000..2926485139 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java @@ -0,0 +1,123 @@ +/** + * 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.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 lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * 小区表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-26 + */ +@Data +public class IcNeighborHoodExcel { + + /*@Excel(name = "小区主键") + private String id; + + @Excel(name = "客户id") + private String customerId; + + @Excel(name = "小区名称") + private String neighborHoodName; + + @Excel(name = "组织id") + private String agencyId; + + @Excel(name = "上级组织id") + private String parentAgencyId; + + @Excel(name = "组织的所有上级组织id") + private String agencyPids; + + @Excel(name = "网格id") + private String gridId; + + @Excel(name = "详细地址") + private String address; + + @Excel(name = "备注") + private String remark; + + @Excel(name = "中心点位:经度") + private String longitude; + + @Excel(name = "中心点位:纬度") + private String latitude; + + @Excel(name = "坐标区域") + private String coordinates; + + @Excel(name = "坐标位置") + private String location; + + @Excel(name = "删除标识 0未删除、1已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime;*/ + + + + + @Excel(name = "所属组织") + @NotBlank(message = "所属组织不能位空") + private String agencyName; + + @Excel(name = "所属网格") + @NotBlank(message = "所属网格不能位空") + private String gridName; + + @Excel(name = "小区名称") + @NotBlank(message = "小区名称不能位空") + @Length(max=50,message = "小区名称不能超过50个字") + private String neighborHoodName; + + @Excel(name = "关联物业") + + private String propertyName; + + @Excel(name = "详细地址") + @NotBlank(message = "详细地址不能位空") + private String address; + + @Excel(name = "备注") + @Length(max=500,message = "备注不能超过500个字") + private String remark; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcBuildingRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcBuildingRedis.java new file mode 100644 index 0000000000..976590a3ae --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcBuildingRedis.java @@ -0,0 +1,47 @@ +/** + * 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.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 楼栋信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-27 + */ +@Component +public class IcBuildingRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java new file mode 100644 index 0000000000..9159c6eb88 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java @@ -0,0 +1,47 @@ +/** + * 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.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 房屋信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-27 + */ +@Component +public class IcHouseRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcNeighborHoodRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcNeighborHoodRedis.java new file mode 100644 index 0000000000..9de1516e7f --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcNeighborHoodRedis.java @@ -0,0 +1,47 @@ +/** + * 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.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 小区表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-26 + */ +@Component +public class IcNeighborHoodRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file 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 new file mode 100644 index 0000000000..8cdad17d3e --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java @@ -0,0 +1,53 @@ +/** + * 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.dto.BuildingTreeLevelDTO; +import com.epmet.dto.form.IcBulidingFormDTO; +import com.epmet.excel.IcBuildingExcel; +import com.epmet.excel.IcNeighborHoodExcel; + +import java.util.List; + +/** + * 楼栋 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +public interface BuildingService { + + + + + + void UpdateBuilding(String customerId, IcBulidingFormDTO formDTO); + + /** + * 删除小区 + * @param buildingId + */ + void DelBuilding(String buildingId); + + + void AddBuilding(String customerId, IcBulidingFormDTO formDTO); + + List treeList(String customerId); + + void importExcel(String customerId, List list); +} \ 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 new file mode 100644 index 0000000000..258c8c020d --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -0,0 +1,47 @@ +/** + * 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.dto.form.IcHouseFormDTO; +import com.epmet.excel.IcHouseExcel; +import com.epmet.excel.IcNeighborHoodExcel; + +import java.util.List; + +/** + * 小区表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +public interface HouseService { + + void addHouse(String customerId, IcHouseFormDTO formDTO); + + + void updateHouse(String customerId, IcHouseFormDTO formDTO); + + /** + * 删除小区 + * @param houseId + */ + void delHouse(String houseId); + + + void importExcel(String customerId, List list); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java index 7b25482b6a..f4c612a2b4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java @@ -20,6 +20,10 @@ package com.epmet.service; import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.excel.IcNeighborHoodExcel; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 小区表 @@ -40,4 +44,13 @@ public interface NeighborHoodService{ * @param neighborHoodId */ void DelNeighborhood(String neighborHoodId); + + /** + * 导出数据 + * @param formDTO + * @param response + */ + void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ; + + void importExcel(String customerId,List list); } \ 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 new file mode 100644 index 0000000000..2ae7a5ac42 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -0,0 +1,296 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +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.result.ExtStaffPermissionResultDTO; +import com.epmet.entity.*; +import com.epmet.excel.IcBuildingExcel; +import com.epmet.excel.IcNeighborHoodExcel; +import com.epmet.service.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class BuildingServiceImpl implements BuildingService { + + + @Autowired + private IcBuildingService icBuildingService; + @Resource + private IcBuildingDao icBuildingDao; + + @Autowired + private IcBuildingUnitService icBuildingUnitService; + + @Resource + private IcHouseDao icHouseDao; + @Autowired + private IcHouseService icHouseService; + + @Resource + private CustomerAgencyDao customerAgencyDao; + @Resource + private CustomerGridDao customerGridDao; + @Resource + private IcNeighborHoodDao icNeighborHoodDao; + @Resource + private CustomerStaffAgencyDao customerStaffAgencyDao; + + @Override + @Transactional(rollbackFor = Exception.class) + public void AddBuilding(String customerId, IcBulidingFormDTO formDTO) { + IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); + icBuildingDTO.setCustomerId(customerId); + IcBuildingEntity entity = ConvertUtils.sourceToTarget(icBuildingDTO, IcBuildingEntity.class); + icBuildingDao.insert(entity); + + //设置楼宇单元 + Integer totalUnitNum = formDTO.getTotalUnitNum(); + List unitList = new ArrayList<>(); + for(int i =0 ;i treeList(String staffId) { + CustomerStaffAgencyDTO agency = customerStaffAgencyDao.selectLatestCustomerByStaff(staffId); + if(null == agency || StringUtils.isBlank(agency.getAgencyId())){ + log.error("com.epmet.service.impl.BuildingServiceImpl.treeList,没有找到工作人员所属的机关信息,用户Id:{}",staffId); + return new ArrayList<>(); + } + //1.获取所在组织及下级组织 + CustomerAgencyEntity customerAgency = customerAgencyDao.selectById(agency.getAgencyId()); + List customerAgencyList = icBuildingDao.selectAgencyChildrenList(agency.getAgencyId()); + customerAgencyList.add(customerAgency); + + if(CollectionUtils.isEmpty(customerAgencyList)){ + return new ArrayList<>(); + } + + List agencyList = customerAgencyList.stream().map(item -> { + BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); + buildingTreeLevelDTO.setId(item.getId()); + buildingTreeLevelDTO.setPId(item.getPid()); + buildingTreeLevelDTO.setLabel(item.getOrganizationName()); + buildingTreeLevelDTO.setLevel(item.getLevel()); + buildingTreeLevelDTO.setChildren(new ArrayList<>()); + return buildingTreeLevelDTO; + }).collect(Collectors.toList()); + + + + //2.获取组织所在网格 + List agencyIdList = customerAgencyList.stream().map(a->a.getId()).collect(Collectors.toList()); +// agencyIdList.add(customerAgency.getId()); + List customerGridList = customerGridDao.selectList(new QueryWrapper().lambda().in(CustomerGridEntity::getPid, agencyIdList)); + + if(CollectionUtils.isEmpty(customerGridList)){ + return covertToTree(customerAgency,agencyList); + } + + List gridList = customerGridList.stream().map(item -> { + BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); + buildingTreeLevelDTO.setId(item.getId()); + buildingTreeLevelDTO.setLabel(item.getGridName()); + buildingTreeLevelDTO.setLevel("grid"); + buildingTreeLevelDTO.setPId(item.getPid()); + buildingTreeLevelDTO.setChildren(new ArrayList<>()); + return buildingTreeLevelDTO; + }).collect(Collectors.toList()); + + + //3.获取网格下的所有小区 + List gridIdList = customerGridList.stream().map(a->a.getId()).collect(Collectors.toList()); + List icNeighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper().lambda().in(IcNeighborHoodEntity::getGridId, gridIdList)); + if(CollectionUtils.isEmpty(customerGridList)){ + agencyList.addAll(gridList); + return covertToTree(customerAgency,agencyList); + } + List neighbourHoodList = icNeighborHoodList.stream().map(item -> { + BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); + buildingTreeLevelDTO.setId(item.getId()); + buildingTreeLevelDTO.setPId(item.getGridId()); + buildingTreeLevelDTO.setLabel(item.getNeighborHoodName()); + buildingTreeLevelDTO.setLevel("neighbourHood"); + buildingTreeLevelDTO.setChildren(new ArrayList<>()); + return buildingTreeLevelDTO; + }).collect(Collectors.toList()); + + //3.获取小区下的所有楼宇 + List neighborHoodIdList = icNeighborHoodList.stream().map(a->a.getId()).collect(Collectors.toList()); + List icBuildingList = icBuildingDao.selectList(new QueryWrapper().lambda().in(IcBuildingEntity::getNeighborHoodId, neighborHoodIdList)); + + if(CollectionUtils.isEmpty(neighborHoodIdList)){ + agencyList.addAll(gridList); + agencyList.addAll(neighbourHoodList); + return covertToTree(customerAgency,agencyList); + } + //组合封装 + + List buildingList = icBuildingList.stream().map(item -> { + BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); + buildingTreeLevelDTO.setId(item.getId()); + buildingTreeLevelDTO.setPId(item.getNeighborHoodId()); + buildingTreeLevelDTO.setLabel(item.getBuildingName()); + buildingTreeLevelDTO.setLevel("building"); + buildingTreeLevelDTO.setChildren(new ArrayList<>()); + return buildingTreeLevelDTO; + }).collect(Collectors.toList()); + + + + + //组织 +// gridList.stream() +// Map> gridMap = gridList.stream().collect(Collectors.groupingBy(e -> e.getPId())); +// List allList = agencyList.addAll(gridList) + + agencyList.addAll(gridList); + agencyList.addAll(neighbourHoodList); + agencyList.addAll(buildingList); + return covertToTree(customerAgency,agencyList); + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void importExcel(String customerId, List list) { + //导入 + if(CollectionUtils.isEmpty(list)){ + return ; + } + //查询所有组织和网格根据名字 + + + + //获取所有小区 list 根据组织和网格 + Set neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); + Set agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toSet()); + Set gridNameList = list.stream().map(item -> item.getGridName()).collect(Collectors.toSet()); + List neighborHoodList = icNeighborHoodDao.selectListByName(new ArrayList(neighborNameList),new ArrayList(agencyNameList),new ArrayList(gridNameList)); +// List neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList)); + Map neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1)); + + + //2.获取小区数据 + //封装数据 + List buildingEntityList = new ArrayList<>(); + List icBuildingUnitEntityList = new ArrayList<>(); + for (IcBuildingExcel icBuildingExcel : list) { + IcBuildingEntity entity = new IcBuildingEntity(); + String uuid = UUID.randomUUID().toString().replace("-", ""); + entity.setId(uuid); + entity.setCustomerId(customerId); + entity.setNeighborHoodId(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()); + entity.setBuildingName(icBuildingExcel.getBuildingName()); + entity.setTotalUnitNum(icBuildingExcel.getTotalUnitNum()); + entity.setTotalFloorNum(icBuildingExcel.getTotalFloorNum()); + entity.setTotalHouseNum(icBuildingExcel.getTotalHouseNum()); + buildingEntityList.add(entity); + + Integer totalUnitNum = icBuildingExcel.getTotalUnitNum(); + //设置楼宇单元 + List unitList = new ArrayList<>(); + for(int i =0 ;i covertToTree(CustomerAgencyEntity customerAgency,List agencyList) { + BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); + buildingTreeLevelDTO.setId(customerAgency.getId()); + buildingTreeLevelDTO.setLabel(customerAgency.getOrganizationName()); + buildingTreeLevelDTO.setLevel(customerAgency.getLevel()); + buildingTreeLevelDTO.setChildren(new ArrayList<>()); + recursionCovertToTree(buildingTreeLevelDTO,agencyList); + List result = new ArrayList<>(); + result.add(buildingTreeLevelDTO); + return result; + } + + private void recursionCovertToTree(BuildingTreeLevelDTO parent, List customerAgencyList) { + //获取子节点 + List subList = customerAgencyList.stream().filter(item -> item.getPId().equals(parent.getId())).collect(Collectors.toList()); + + for(BuildingTreeLevelDTO agencyEntity :subList){ + recursionCovertToTree(agencyEntity,customerAgencyList); + } + parent.setChildren(subList); + + } + + + + /** + * 更新 + * @param customerId + * @param formDTO + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void UpdateBuilding(String customerId, IcBulidingFormDTO formDTO) { + IcBuildingDTO icBuilding= icBuildingService.get(formDTO.getBuildingId()); + + if(!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())){ + //更新对应房屋小区名 + List icHouseEntities = icHouseDao.selectList(new QueryWrapper().lambda().eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId())); + icHouseEntities.forEach(item->{ + item.setNeighborHoodId(formDTO.getNeighborHoodId()); + }); + icHouseService.updateBatchById(icHouseEntities); + } + IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); + icBuildingDTO.setId(formDTO.getBuildingId()); + icBuildingDTO.setCustomerId(customerId); + icBuildingService.update(icBuildingDTO); + //更新楼宇单元 + //如果楼宇单元大于之前的楼宇单元,新增单元 + //如果小于,判断是否存在房屋,如果存在就提示不能更改 + + + } + + /** + * 删除 + * @param buildingId + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void DelBuilding(String buildingId) { + //删除小区 + icBuildingService.deleteById(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 new file mode 100644 index 0000000000..724a35b032 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -0,0 +1,152 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.IcBuildingDao; +import com.epmet.dao.IcBuildingUnitDao; +import com.epmet.dao.IcHouseDao; +import com.epmet.dao.IcNeighborHoodDao; +import com.epmet.dto.IcBuildingDTO; +import com.epmet.dto.IcBuildingUnitDTO; +import com.epmet.dto.IcHouseDTO; +import com.epmet.dto.form.IcHouseFormDTO; +import com.epmet.entity.IcHouseEntity; +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 lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class HouseServiceImpl implements HouseService { + + + + @Autowired + private IcHouseService icHouseService; + @Autowired + private IcBuildingService icBuildingService; + @Autowired + private IcBuildingUnitService icBuildingUnitService; + @Resource + private IcNeighborHoodDao icNeighborHoodDao; + @Resource + private IcBuildingDao icBuildingDao; + @Resource + private IcBuildingUnitDao icBuildingUnitDao; + @Resource + private IcHouseDao icHouseDao; + + @Override + @Transactional(rollbackFor = Exception.class) + public void addHouse(String customerId, IcHouseFormDTO formDTO) { + IcHouseDTO icHouseDTO= ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); + icHouseDTO.setCustomerId(customerId); + icHouseDTO.setRentFlag(formDTO.getRentFlag()?1:0); + + icHouseDTO.setHouseName(getHouseName(formDTO)); + icHouseService.save(icHouseDTO); + } + + private String getHouseName(IcHouseFormDTO formDTO){ + //设置房间名 楼栋-单元号-门牌号 + IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingUnitId()); + IcBuildingUnitDTO icBuildingUnit = icBuildingUnitService.get(formDTO.getBuildingUnitId()); + String doorName = formDTO.getDoorName(); + String buildingName = Optional.ofNullable(icBuilding).map(u->u.getBuildingName()).orElse(""); + String unitName = Optional.ofNullable(icBuildingUnit).map(u->u.getUnitNum()).orElse(""); + return new StringBuilder().append(buildingName).append("-").append(unitName).append("-").append(doorName).toString(); + } + + /** + * 更新 + * @param customerId + * @param formDTO + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateHouse(String customerId, IcHouseFormDTO formDTO) { + IcHouseDTO icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); + icHouseDTO.setId(formDTO.getHouseId()); + icHouseDTO.setCustomerId(customerId); + icHouseDTO.setRentFlag(formDTO.getRentFlag()?1:0); + //设置 + icHouseDTO.setHouseName(getHouseName(formDTO)); + icHouseService.update(icHouseDTO); + } + + /** + * 删除 + * @param houseId + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delHouse(String houseId) { + //删除小区 + icHouseService.deleteById(houseId); + } + + @Override + public void importExcel(String customerId, List list) { + //导入 + if(CollectionUtils.isEmpty(list)){ + return ; + } + //获取所有小区 list +// List neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList()); +// List neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList)); +// Map neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1)); + + //获取所有楼宇 list +// List buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toList()); + +// icBuildingDao.selectList(new QueryWrapper().lambda().in(IcBuildingEntity::getBuildingName, buildingNameList).in(); + Set neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); + Set buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet()); + Set buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet()); + List> buildMapList = icBuildingDao.selectListByName(new ArrayList(neighborNameList),new ArrayList(buildingNameList),new ArrayList(buildingUnitList)); + //转Map + Map> buildMap = new HashMap<>(); + buildMapList.forEach(item->{ + buildMap.put(item.get("neighborName")+","+item.get("buildingName")+","+item.get("unitNum"),item); + }); + //封装数据 + List houseEntityList = new ArrayList<>(); + for (IcHouseExcel icHouseExcel : list) { + IcHouseEntity entity = new IcHouseEntity(); + String uuid = UUID.randomUUID().toString().replace("-", ""); + entity.setId(uuid); + entity.setCustomerId(customerId); + Map item = buildMap.get(icHouseExcel.getNeighborHoodName()+","+icHouseExcel.getBuildingName()+","+icHouseExcel.getBuildingUnit()); + 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.setDoorName(icHouseExcel.getDoorName()); + entity.setHouseType(icHouseExcel.getHouseType()); + entity.setPurpose(icHouseExcel.getPurpose()); + entity.setRentFlag("是".equals(icHouseExcel.getRentFlag())?1:0); + entity.setOwnerName(icHouseExcel.getOwnerName()); + entity.setOwnerPhone(icHouseExcel.getOwnerPhone()); + entity.setOwnerIdCard(icHouseExcel.getOwnerIdCard()); + houseEntityList.add(entity); + } + //3.保存 + //4.新增单元 + icHouseService.insertBatch(houseEntityList); + + } + + +} 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 b6c2a4347c..fff8156f11 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 @@ -1,37 +1,43 @@ 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.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.NeighborhoodConstant; -import com.epmet.dao.IcNeighborHoodDao; -import com.epmet.dao.IcNeighborHoodPropertyDao; +import com.epmet.dao.*; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.IcNeighborHoodPropertyDTO; import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; -import com.epmet.entity.IcNeighborHoodEntity; -import com.epmet.entity.IcNeighborHoodPropertyEntity; +import com.epmet.entity.*; +import com.epmet.excel.IcBuildingExcel; +import com.epmet.excel.IcHouseExcel; +import com.epmet.excel.IcNeighborHoodExcel; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.IcNeighborHoodPropertyService; 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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; +import javax.servlet.http.HttpServletResponse; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; @Slf4j @Service @@ -52,6 +58,16 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { @Resource private IcNeighborHoodDao icNeighborHoodDao; + @Resource + private IcBuildingDao icBuildingDao; + @Resource + private IcHouseDao icHouseDao; + @Resource + private CustomerAgencyDao customerAgencyDao; + @Resource + private CustomerGridDao customerGridDao; + @Resource + private IcPropertyManagementDao icPropertyManagementDao; @Override @Transactional(rollbackFor = Exception.class) @@ -66,14 +82,15 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { CustomerAgencyDTO customerAgencyDTO = Optional.ofNullable(customerAgencyResult.getData()).orElse(new CustomerAgencyDTO()); icNeighborHoodDTO.setParentAgencyId(customerAgencyDTO.getPid()); icNeighborHoodDTO.setAgencyPids(customerAgencyDTO.getPids()); - icNeighborHoodService.save(icNeighborHoodDTO); - + IcNeighborHoodEntity entity = ConvertUtils.sourceToTarget(icNeighborHoodDTO, IcNeighborHoodEntity.class); +// icNeighborHoodService.save(icNeighborHoodDTO); + icNeighborHoodDao.insert(entity); //设置物业关联 String propertyId = formDTO.getPropertyId(); if(!StringUtils.isEmpty(propertyId)){ //保存物业关系表 IcNeighborHoodPropertyDTO icNeighborHoodPropertyDTO = new IcNeighborHoodPropertyDTO(); - icNeighborHoodPropertyDTO.setNeighborHoodId(icNeighborHoodDTO.getId()); + icNeighborHoodPropertyDTO.setNeighborHoodId(entity.getId()); icNeighborHoodPropertyDTO.setPropertyId(propertyId); icNeighborHoodPropertyService.save(icNeighborHoodPropertyDTO); } @@ -85,7 +102,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { */ @Override public IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO) { - String dataType = formDTO.getDataType(); + String dataType = formDTO.getLevel(); Integer pageNo = formDTO.getPageNo(); Integer pageSize = formDTO.getPageSize(); @@ -101,14 +118,93 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { result.setList(resultMap.getRecords()); }else if(NeighborhoodConstant.BUILDING.equals(dataType)){ //如果类型是building 查楼栋 - IPage> resultMap = searchNeighborhood(formDTO); + IPage> resultMap = searchBuilding(formDTO); + result.setTotal(resultMap.getTotal()); + result.setList(resultMap.getRecords()); }else if(NeighborhoodConstant.HOUSE.equals(dataType)){ //如果类型是house 查房屋 - IPage> resultMap = searchNeighborhood(formDTO); + 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); + + +// 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); + } + 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) { + + 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()); +// neighborHoodEntityQueryWrapper.eq("a.DEL_FLAG","0"); + + IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); + neighbor.setDelFlag("0"); + return icNeighborHoodDao.searchNeighborhoodByPage(page, neighbor); + } + /** * 更新 * @param customerId @@ -171,16 +267,148 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { } - private IPage> searchNeighborhood(ListIcNeighborHoodFormDTO formDTO) { + /** + * 导出数据 + * @param formDTO + * @param response + */ + @Override + public void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { + String dataType = formDTO.getLevel(); - IPage page = new Page(formDTO.getPageNo(),formDTO.getPageSize()); + if(StringUtils.isEmpty(dataType)|| NeighborhoodConstant.NEIGHBOR_HOOD.equals(dataType)){ + //如果类型是neighbourHood 查小区 + //导出小区 + 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 ; + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void importExcel(String customerId,List list) { + //导入 + if(CollectionUtils.isEmpty(list)){ + return ; + } + //获取所有组织 list + List agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toList()); + //获取所有网格 list + List gridNameList = list.stream().map(item->item.getGridName()).collect(Collectors.toList()); + //获取所有物业 list + List propertyNameList = list.stream().map(item->item.getPropertyName()).collect(Collectors.toList()); + //查询对应的id + List customerAgencyList = customerAgencyDao.selectList(new QueryWrapper().lambda().in(CustomerAgencyEntity::getOrganizationName, agencyNameList)); + List customerGridList = customerGridDao.selectList(new QueryWrapper().lambda().in(CustomerGridEntity::getGridName, gridNameList)); + List icPropertyManagementList = icPropertyManagementDao.selectList(new QueryWrapper().lambda().in(IcPropertyManagementEntity::getName, propertyNameList)); + + Map agencyMap = customerAgencyList.stream().collect(Collectors.toMap(CustomerAgencyEntity::getOrganizationName, Function.identity(),(key1, key2)->key1)); + Map gridMap = customerGridList.stream().collect(Collectors.toMap(CustomerGridEntity::getGridName,Function.identity(),(key1,key2)->key1)); + Map propertyMap = icPropertyManagementList.stream().collect(Collectors.toMap(IcPropertyManagementEntity::getName,Function.identity(),(key1,key2)->key1)); + + //封装数据 + List neighborHoodEntityList = new ArrayList<>(); + List icNeighborHoodPropertyEntityList = new ArrayList<>(); + for (IcNeighborHoodExcel icNeighborHoodExcel : list) { + IcNeighborHoodEntity entity = new IcNeighborHoodEntity(); + String uuid =UUID.randomUUID().toString().replace("-", ""); + 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.setAddress(icNeighborHoodExcel.getAddress()); + entity.setRemark(icNeighborHoodExcel.getRemark()); + neighborHoodEntityList.add(entity); - QueryWrapper neighborHoodEntityQueryWrapper = new QueryWrapper<>(); - neighborHoodEntityQueryWrapper.lambda() - .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId()) - .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName()); + IcNeighborHoodPropertyEntity entity1 = new IcNeighborHoodPropertyEntity(); + entity1.setPropertyId(propertyMap.get(icNeighborHoodExcel.getPropertyName()).getId()); + entity1.setNeighborHoodId(uuid); + icNeighborHoodPropertyEntityList.add(entity1); + } + +// icNeighborHoodDao. + //保存 + icNeighborHoodService.insertBatch(neighborHoodEntityList); + icNeighborHoodPropertyService.insertBatch(icNeighborHoodPropertyEntityList); + + } + + 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<>(); +// 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()); +// neighborHoodEntityQueryWrapper.eq("a.DEL_FLAG","0"); + IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); + neighbor.setDelFlag("0"); + + return icNeighborHoodDao.searchAllNeighborhood(neighbor); + } + + private List searchAllHouse(ListIcNeighborHoodFormDTO formDTO) { + + IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); + + IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class); - return icNeighborHoodDao.searchNeighborhoodByPage(page, neighborHoodEntityQueryWrapper); + 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/util/ExcelPoiUtils.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java new file mode 100644 index 0000000000..fa03b631d1 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ExcelPoiUtils.java @@ -0,0 +1,276 @@ +package com.epmet.util; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import org.apache.commons.lang.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +public class ExcelPoiUtils { + /** + * excel 导出 + * + * @param list 数据列表 + * @param fileName 导出时的excel名称 + * @param response + */ + public static void exportExcel(List> list, String fileName, HttpServletResponse response) throws IOException { + defaultExport(list, fileName, response); + } + + /** + * 默认的 excel 导出 + * + * @param list 数据列表 + * @param fileName 导出时的excel名称 + * @param response + */ + private static void defaultExport(List> list, String fileName, HttpServletResponse response) throws IOException { + //把数据添加到excel表格中 + Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF); + downLoadExcel(fileName, response, workbook); + } + + /** + * excel 导出 + * + * @param list 数据列表 + * @param pojoClass pojo类型 + * @param fileName 导出时的excel名称 + * @param response + * @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型) + */ + private static void defaultExport(List list, Class pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) throws IOException { + //把数据添加到excel表格中 + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list); + downLoadExcel(fileName, response, workbook); + } + + /** + * excel 导出 + * + * @param list 数据列表 + * @param pojoClass pojo类型 + * @param fileName 导出时的excel名称 + * @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型) + * @param response + */ + public static void exportExcel(List list, Class pojoClass, String fileName, ExportParams exportParams, HttpServletResponse response) throws IOException { + defaultExport(list, pojoClass, fileName, response, exportParams); + } + + /** + * excel 导出 + * + * @param list 数据列表 + * @param title 表格内数据标题 + * @param sheetName sheet名称 + * @param pojoClass pojo类型 + * @param fileName 导出时的excel名称 + * @param response + */ + public static void exportExcel(List list, String title, String sheetName, Class pojoClass, String fileName, HttpServletResponse response) throws IOException { + defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF)); + } + + + + /** + * excel 导出 + * + * @param list 数据列表 + * @param title 表格内数据标题 + * @param sheetName sheet名称 + * @param pojoClass pojo类型 + * @param fileName 导出时的excel名称 + * @param isCreateHeader 是否创建表头 + * @param response + */ + public static void exportExcel(List list, String title, String sheetName, Class pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response) throws IOException { + ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF); + exportParams.setCreateHeadRows(isCreateHeader); + defaultExport(list, pojoClass, fileName, response, exportParams); + } + /** + * 根据模板生成excel后导出 + * @param templatePath 模板路径 + * @param map 数据集合 + * @param fileName 文件名 + * @param response + * @throws IOException + */ + public static void exportExcel(TemplateExportParams templatePath, Map map, String fileName, HttpServletResponse response) throws IOException { + Workbook workbook = ExcelExportUtil.exportExcel(templatePath, map); + downLoadExcel(fileName, response, workbook); + } + + + /** + * excel下载 + * + * @param fileName 下载时的文件名称 + * @param response + * @param workbook excel数据 + */ + private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException { + try { + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-Type", "application/vnd.ms-excel"); + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8")); + workbook.write(response.getOutputStream()); + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } + + + + /** + * excel 导入 + * + * @param file excel文件 + * @param pojoClass pojo类型 + * @param + * @return + */ + public static List importExcel(MultipartFile file, Class pojoClass) throws IOException { + return importExcel(file, 1, 1, pojoClass); + } + + /** + * excel 导入 + * + * @param filePath excel文件路径 + * @param titleRows 表格内数据标题行 + * @param headerRows 表头行 + * @param pojoClass pojo类型 + * @param + * @return + */ + public static List importExcel(String filePath, Integer titleRows, Integer headerRows, Class pojoClass) throws IOException { + if (StringUtils.isBlank(filePath)) { + return null; + } + ImportParams params = new ImportParams(); + params.setTitleRows(titleRows); + params.setHeadRows(headerRows); + params.setNeedSave(true); + params.setSaveUrl("/excel/"); + try { + return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params); + } catch (NoSuchElementException e) { + throw new IOException("模板不能为空"); + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } + + + /** + * excel 导入 + * + * @param file 上传的文件 + * @param titleRows 表格内数据标题行 + * @param headerRows 表头行 + * @param pojoClass pojo类型 + * @param + * @return + */ + public static List importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class pojoClass) throws IOException { + if (file == null) { + return null; + } + try { + return importExcel(file.getInputStream(), titleRows, headerRows, pojoClass); + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } + + /** + * excel 导入 + * + * @param inputStream 文件输入流 + * @param titleRows 表格内数据标题行 + * @param headerRows 表头行 + * @param pojoClass pojo类型 + * @param + * @return + */ + public static List importExcel(InputStream inputStream, Integer titleRows, Integer headerRows, Class pojoClass) throws IOException { + if (inputStream == null) { + return null; + } + ImportParams params = new ImportParams(); + params.setTitleRows(titleRows); + params.setHeadRows(headerRows); + params.setSaveUrl("/excel/"); + params.setNeedSave(true); + try { + return ExcelImportUtil.importExcel(inputStream, pojoClass, params); + } catch (NoSuchElementException e) { + throw new IOException("excel文件不能为空"); + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } + /** + * excel 导入,有错误信息 + * + * @param file 上传的文件 + * @param pojoClass pojo类型 + * @param + * @return + */ + public static ExcelImportResult importExcelMore(MultipartFile file, Class pojoClass) throws IOException { + if (file == null) { + return null; + } + try { + return importExcelMore(file.getInputStream(), pojoClass); + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } + + /** + * excel 导入 + * + * @param inputStream 文件输入流 + * @param pojoClass pojo类型 + * @param + * @return + */ + private static ExcelImportResult importExcelMore(InputStream inputStream, Class pojoClass) throws IOException { + if (inputStream == null) { + return null; + } + ImportParams params = new ImportParams(); + params.setTitleRows(1);//表格内数据标题行 + params.setHeadRows(1);//表头行 + params.setSaveUrl("/excel/"); + params.setNeedSave(true); + params.setNeedVerify(true); + try { + return ExcelImportUtil.importExcelMore(inputStream, pojoClass, params); + } catch (NoSuchElementException e) { + throw new IOException("excel文件不能为空"); + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml b/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml index dc1c51b285..dc2f9674ba 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml @@ -108,6 +108,8 @@ mybatis-plus: cache-enabled: false call-setters-on-nulls: true jdbc-type-for-null: 'null' + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + feign: hystrix: diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template.xlsx new file mode 100644 index 0000000000..1334d9dcd9 Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/building_template.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx new file mode 100644 index 0000000000..a095e3e0f5 Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/house_template.xlsx differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template.xlsx b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template.xlsx new file mode 100644 index 0000000000..36297ea510 Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/src/main/resources/excel/neighbor_template.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 8d9249b655..0cb73c45a8 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 @@ -25,5 +25,233 @@ + + + + + + + + + + + + + + + \ No newline at end of file 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 25df6ce4a6..e62cb42010 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 @@ -26,5 +26,201 @@ + + + + + + \ 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 8a057c3a9f..b1d6f0c7e3 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 @@ -25,7 +25,7 @@ - + select + a.id as neighborHoodId, + a.NEIGHBOR_HOOD_NAME as neighborHoodName, + a.ADDRESS as address, + a.REMARK as remark, + + 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_grid c on a.GRID_ID = c.ID + + + AND a.GRID_ID = #{neighbor.id} + + + AND a.DEL_FLAG = #{neighbor.delFlag} + + + + + + + \ No newline at end of file