From 01aac4ae9180661380b15f46f6e38c7d90e4fa4c Mon Sep 17 00:00:00 2001 From: lzh Date: Mon, 1 Nov 2021 21:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A5=BC=E5=AE=87=E5=8D=95=E5=85=83=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 5 ++- .../epmet/dto/form/IcBulidingUnitFormDTO.java | 42 +++++++++++++++++++ .../epmet/controller/BuildingController.java | 40 ++++++++++++++---- .../com/epmet/controller/HouseController.java | 11 +++-- .../controller/NeighborHoodController.java | 13 +++--- .../service/impl/BuildingServiceImpl.java | 17 ++++---- .../service/impl/NeighborHoodServiceImpl.java | 3 -- 7 files changed, 100 insertions(+), 31 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingUnitFormDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index fa30ff3a3c..92c190c7ec 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -214,8 +214,11 @@ public enum EpmetErrorCode { SAME_RULE_NAME(8916,"该积分事件已存在,请重新调整保存"), UP_LIMIT_POINT(8917,"积分上限需为单位积分倍数,请重新调整保存"), - BADGE_CHECK(8918,""); + BADGE_CHECK(8918,""), + ORG_ADD_FAILED(8919,"添加失败"), + ORG_EDIT_FAILED(8920,"编辑失败"), + ORG_DEL_FAILED(8921,"删除失败"); private int code; private String msg; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingUnitFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingUnitFormDTO.java new file mode 100644 index 0000000000..74a38b8e2b --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingUnitFormDTO.java @@ -0,0 +1,42 @@ +/** + * 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 javax.validation.constraints.NotNull; +import java.io.Serializable; + + +@Data +public class IcBulidingUnitFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @NotBlank(message = "楼栋ID不能为空") + private String buildingId; + + + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index fa78b6f791..2e65729cab 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -19,6 +19,8 @@ package com.epmet.controller; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.security.dto.TokenDto; @@ -28,12 +30,15 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.constant.NeighborhoodConstant; +import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.form.IcBulidingFormDTO; +import com.epmet.dto.form.IcBulidingUnitFormDTO; import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.excel.IcBuildingExcel; import com.epmet.excel.IcHouseExcel; import com.epmet.excel.IcNeighborHoodExcel; @@ -77,13 +82,15 @@ public class BuildingController { private IcBuildingService icBuildingService; @Autowired private BuildingService buildingService; + @Autowired + private IcBuildingUnitDao icBuildingUnitDao; @PostMapping("buildinglist") public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); IcNeighborHoodResultDTO icNeighborHoodResultDTO = buildingService.listBuilding(formDTO); return new Result().ok(icNeighborHoodResultDTO); @@ -126,13 +133,12 @@ public class BuildingController { } /** * 导出模板 - * @param formDTO * @param response * @throws Exception */ @PostMapping("exporttemplate") - public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + public void exportTemplate( HttpServletResponse response) throws Exception { + TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx"); Map map = new HashMap<>(); map.put("maplist",new ArrayList()); @@ -147,7 +153,7 @@ public class BuildingController { */ @RequestMapping("exportbuildinginfo") public void exportbuildinginfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); buildingService.exportBuildinginfo(formDTO,response); } @@ -161,7 +167,7 @@ public class BuildingController { @GetMapping("export") public void export(HttpServletResponse response) throws Exception { ListIcNeighborHoodFormDTO formDTO = new ListIcNeighborHoodFormDTO(); - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); buildingService.exportBuildinginfo(formDTO,response); } @@ -186,7 +192,7 @@ public class BuildingController { for ( IcBuildingExcel entity : failList) { log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息 } - return new Result().error(8000,failList.get(0).getErrorMsg()); + return new Result().error(8001,failList.get(0).getErrorMsg()); } List result =importResult.getList(); @@ -194,5 +200,25 @@ public class BuildingController { return new Result().ok("导入成功"); } + /** + * 查看楼宇单元列表 + * @param tokenDTO + * @return + * @throws IOException + */ + @PostMapping("buildingunitlist") + public Result buildingunitlist(@LoginUser TokenDto tokenDTO,@RequestBody IcBulidingUnitFormDTO icBulidingUnitFormDTO ){ + ValidatorUtils.validateEntity(icBulidingUnitFormDTO); + List icBuildingUnitEntityList = icBuildingUnitDao.selectList(new QueryWrapper().lambda().eq(IcBuildingUnitEntity::getBuildingId, icBulidingUnitFormDTO.getBuildingId())); + List result = new ArrayList<>(); + icBuildingUnitEntityList.forEach(item->{ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id",item.getId()); + jsonObject.put("unitName",item.getUnitName()); + jsonObject.put("unitNum",item.getUnitNum()); + result.add(jsonObject); + }); + return new Result().ok(result); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 9f8f92188a..8bc4378e8f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -67,7 +67,7 @@ public class HouseController { @PostMapping("houselist") public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); IcNeighborHoodResultDTO icNeighborHoodResultDTO = houseService.listNeighborhood(formDTO); return new Result().ok(icNeighborHoodResultDTO); @@ -103,13 +103,12 @@ public class HouseController { } /** * 导出模板 - * @param formDTO * @param response * @throws Exception */ @PostMapping("exporttemplate") - public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + public void exportTemplate(HttpServletResponse response) throws Exception { +// ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); TemplateExportParams templatePath = new TemplateExportParams("excel/house_template.xlsx"); Map map = new HashMap<>(); map.put("maplist",new ArrayList()); @@ -124,7 +123,7 @@ public class HouseController { */ @RequestMapping("exporthouseinfo") public void exporthouseinfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); houseService.exportBuildinginfo(formDTO,response); } @@ -149,7 +148,7 @@ public class HouseController { for ( IcHouseExcel entity : failList) { log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息 } - return new Result().error(8000,failList.get(0).getErrorMsg()); + return new Result().error(8001,failList.get(0).getErrorMsg()); } List result =importResult.getList(); 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 8d98ad3c8a..823363814a 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 @@ -80,7 +80,7 @@ public class NeighborHoodController { @PostMapping("neighborhoodlist") public Result neighborhoodlist(@RequestBody ListIcNeighborHoodFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO); return new Result().ok(icNeighborHoodResultDTO); @@ -115,7 +115,7 @@ public class NeighborHoodController { //判断是否存在楼宇,如果存在不能删除 List icBuildingEntities = icBuildingDao.selectList(new QueryWrapper().lambda().eq(IcBuildingEntity::getNeighborHoodId, neighborHoodId)); if(!CollectionUtils.isEmpty(icBuildingEntities)){ - return new Result().error(8000,"小区下已存在楼宇,无法删除"); + return new Result().error(8001,"小区下已存在楼宇,无法删除"); } neighborHoodService.DelNeighborhood(neighborHoodId); return new Result().ok("删除成功"); @@ -130,19 +130,18 @@ public class NeighborHoodController { */ @PostMapping("exportneighborhoodinfo") public void exportneighborhoodinfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + ValidatorUtils.validateEntity(formDTO); neighborHoodService.exportNeighborhoodinfo(formDTO,response); } /** * 导出模板 - * @param formDTO * @param response * @throws Exception */ @PostMapping("exporttemplate") - public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { - ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + public void exportTemplate( HttpServletResponse response) throws Exception { +// ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx"); Map map = new HashMap<>(); map.put("maplist",new ArrayList()); @@ -211,7 +210,7 @@ public class NeighborHoodController { for ( IcNeighborHoodExcel entity : failList) { log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息 } - return new Result().error(8000,failList.get(0).getErrorMsg()); + return new Result().error(8001,failList.get(0).getErrorMsg()); } List result =importResult.getList(); // log.info(JSON.toJSONString(result)); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 7842454149..10371e3369 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -8,16 +8,19 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.*; -import com.epmet.dto.*; +import com.epmet.dto.BuildingTreeLevelDTO; +import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.form.IcBulidingFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; -import com.epmet.dto.result.ExtStaffPermissionResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; -import com.epmet.excel.IcNeighborHoodExcel; -import com.epmet.service.*; +import com.epmet.service.BuildingService; +import com.epmet.service.IcBuildingService; +import com.epmet.service.IcBuildingUnitService; +import com.epmet.service.IcHouseService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -374,7 +377,7 @@ public class BuildingServiceImpl implements BuildingService { List icHouseEntities = icHouseDao.selectList(new QueryWrapper().lambda().eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId())); if(!CollectionUtils.isEmpty(icHouseEntities)){ // - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法更新"); + throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(),"楼宇单元下存在房屋,无法更新"); // icHouseEntities.forEach(item->{ // item.setNeighborHoodId(formDTO.getNeighborHoodId()); // }); @@ -403,7 +406,7 @@ public class BuildingServiceImpl implements BuildingService { icBuildingUnitService.insertBatch(unitList); }else{ //如果小于,判断是否存在房屋,如果存在就提示不能更改 - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法更新"); + throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(),"楼宇单元下存在房屋,无法更新"); } @@ -420,7 +423,7 @@ public class BuildingServiceImpl implements BuildingService { //如果存在房屋,无法删除 List icHouseEntities = icHouseDao.selectList(new QueryWrapper().lambda().eq(IcHouseEntity::getBuildingId, buildingId)); if(!CollectionUtils.isEmpty(icHouseEntities)){ - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),"楼宇单元下存在房屋,无法删除"); + throw new RenException(EpmetErrorCode.ORG_DEL_FAILED.getCode(),"楼宇单元下存在房屋,无法删除"); } //删除楼宇 icBuildingService.deleteById(buildingId); 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 2d41fdc8fb..00d96f74f6 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 @@ -7,7 +7,6 @@ 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.*; @@ -18,8 +17,6 @@ import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; 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;