diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java index 965869be12..0bc1a8f7a0 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java @@ -3,6 +3,7 @@ package com.epmet.service.impl; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; @@ -45,6 +46,8 @@ public class GovWebServiceImpl implements GovWebService { private CpUserDetailRedis cpUserDetailRedis; @Autowired private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private ThirdLoginServiceImpl thirdLoginService; /** * @param formDTO @@ -105,7 +108,11 @@ public class GovWebServiceImpl implements GovWebService { String token = jwtTokenUtils.createToken(map); logger.info("app:" + formDTO.getApp() + ";client:" + formDTO.getClient() + ";userId:" + userId + ";生成token[" + token + "]"); int expire = jwtTokenProperties.getExpire(); - TokenDto tokenDto = new TokenDto(); + + String orgIdPath = thirdLoginService.getOrgIdPath(userId); + String[] orgIdPathParts = orgIdPath.split(":"); + + GovTokenDto tokenDto = new GovTokenDto(); tokenDto.setCustomerId(formDTO.getCustomerId()); tokenDto.setApp(formDTO.getApp()); tokenDto.setClient(formDTO.getClient()); @@ -113,6 +120,13 @@ public class GovWebServiceImpl implements GovWebService { tokenDto.setToken(token); tokenDto.setUpdateTime(System.currentTimeMillis()); tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + tokenDto.setAgencyId(orgIdPathParts[orgIdPathParts.length - 1]); + tokenDto.setRootAgencyId(orgIdPathParts[0]); + tokenDto.setDeptIdList(thirdLoginService.getDeptartmentIdList(userId)); + tokenDto.setGridIdList(thirdLoginService.getGridIdList(userId)); + tokenDto.setRoleList(thirdLoginService.queryGovStaffRoles(userId, orgIdPathParts[orgIdPathParts.length - 1])); + tokenDto.setOrgIdPath(orgIdPath); + cpUserDetailRedis.set(tokenDto, expire); logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); return token; 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 a38091fa60..b57a5c8584 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 @@ -79,7 +79,9 @@ public enum EpmetErrorCode { GUIDE_CATEGORY_NAME_EXITS(8212,"分类已存在"), CUSTOMER_FORM_NOT_EXITS(8213,"客户未配置表单"), RESI_NOT_FOUND(8214,"居民信息找不到"), - + BUILDING_NAME_EXITED(8215,"楼栋名称已存在"), + DOOR_NAME_EXITED(8216,"门牌号已存在"), + NEIGHBOOR_NAME_EXITED(8217,"小区名称已存在"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 687c01b462..7a0ae49569 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -97,7 +97,7 @@ com.alibaba easyexcel - 2.2.10 + 3.0.3 poi diff --git a/epmet-module/epmet-demo/epmet-demo-server/pom.xml b/epmet-module/epmet-demo/epmet-demo-server/pom.xml index 4f6c0b6021..2a2ee9e597 100644 --- a/epmet-module/epmet-demo/epmet-demo-server/pom.xml +++ b/epmet-module/epmet-demo/epmet-demo-server/pom.xml @@ -16,7 +16,7 @@ com.alibaba easyexcel - 2.2.10 + 3.0.3 poi diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java index 8ce4e063b9..b14c58b47c 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcBulidingFormDTO.java @@ -17,9 +17,7 @@ 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; @@ -36,70 +34,75 @@ public class IcBulidingFormDTO implements Serializable { public interface DeleteGroup extends CustomerClientShowGroup { } - @NotBlank(message = "楼栋ID不能为空", groups = { UpdateGroup.class,DeleteGroup.class}) + public interface AddShowGroup extends CustomerClientShowGroup { + } + + public interface UpdateShowGroup extends CustomerClientShowGroup { + } + @NotBlank(message = "楼栋ID不能为空", groups = { UpdateShowGroup.class,DeleteGroup.class}) private String buildingId; /** * 组织id */ - @NotBlank(message = "组织id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "组织id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String agencyId; /** * 网格id */ - @NotBlank(message = "网格不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "网格不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String gridId; /** * 小区id */ - @NotBlank(message = "小区id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "小区id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String neighborHoodId; /** * 楼栋名称 */ - @NotBlank(message = "楼栋名称不能为空", groups = {AddGroup.class, UpdateGroup.class}) - @Length(max=10,message = "楼栋名称不能超过10个字", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "楼栋名称不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) + @Length(max=10,message = "楼栋名称不能超过10个字", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String buildingName; /** * 楼栋类型 */ - @NotBlank(message = "楼栋类型不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "楼栋类型不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String type=""; /** * 客户id */ - /* @NotBlank(message = "客户id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + /* @NotBlank(message = "客户id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String customerId;*/ /** * 排序 */ - @NotNull(message = "排序不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotNull(message = "排序不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private Integer sort = 0; /** * 总单元数 */ - @NotNull(message = "总单元数不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotNull(message = "总单元数不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private Integer totalUnitNum=1; /** * 总楼层总数 */ - @NotNull(message = "总楼层总数不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotNull(message = "总楼层总数不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private Integer totalFloorNum; /** * 总户数 */ - @NotNull(message = "总户数不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotNull(message = "总户数不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private Integer totalHouseNum; /** * 坐标位置 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java index cb557aa572..58376e2032 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseFormDTO.java @@ -17,9 +17,7 @@ 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 javax.validation.constraints.NotBlank; @@ -35,23 +33,29 @@ public class IcHouseFormDTO implements Serializable { public interface DeleteGroup extends CustomerClientShowGroup { } - @NotBlank(message = "房屋ID不能为空", groups = { UpdateGroup.class,DeleteGroup.class}) + public interface AddShowGroup extends CustomerClientShowGroup { + } + + public interface UpdateShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "房屋ID不能为空", groups = { UpdateShowGroup.class,DeleteGroup.class}) private String houseId; /** * 小区id */ - @NotBlank(message = "小区id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "小区id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String neighborHoodId; - @NotBlank(message = "所属楼栋ID不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "所属楼栋ID不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String buildingId; /** * 所属单元id */ - @NotBlank(message = "所属单元id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "所属单元id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String buildingUnitId; @@ -59,43 +63,43 @@ public class IcHouseFormDTO implements Serializable { /** * 门牌号 */ - @NotBlank(message = "门牌号不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "门牌号不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String doorName; /** * 房屋类型,这里存储字典value就可以 */ - @NotBlank(message = "房屋类型不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "房屋类型不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String houseType; /** * 存储字典value */ - @NotBlank(message = "房屋用途不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "房屋用途不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String purpose; /** * 1出租;0未出租 */ - @NotNull(message = "是否出租不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotNull(message = "是否出租不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private Integer rentFlag; /** * 房主姓名 */ - @NotBlank(message = "房主姓名不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "房主姓名不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String ownerName; /** * 房主电话 */ - @NotBlank(message = "房主电话不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "房主电话不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String ownerPhone; /** * 房主身份证号 */ - @NotBlank(message = "房主身份证号不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "房主身份证号不能为空", groups = {AddShowGroup.class, UpdateShowGroup.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/IcNeighborHoodFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java index 98a6ad0fde..97d196e60d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java @@ -17,9 +17,7 @@ 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; @@ -35,59 +33,56 @@ public class IcNeighborHoodFormDTO implements Serializable { public interface DeleteGroup extends CustomerClientShowGroup { } + + public interface AddShowGroup extends CustomerClientShowGroup { + } + public interface UpdateShowGroup extends CustomerClientShowGroup { + } /** * 小区id */ - @NotBlank(message = "小区id不能为空", groups = {UpdateGroup.class,DeleteGroup.class}) + @NotBlank(message = "小区id不能为空", groups = {UpdateShowGroup.class,DeleteGroup.class}) private String neighborHoodId; /** * 小区名称 */ - @NotBlank(message = "小区名称不能为空", groups = {AddGroup.class, UpdateGroup.class}) - @Length(max=50,message = "小区名称不能超过50个字", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "小区名称不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) + @Length(max=50,message = "小区名称不能超过50个字", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String neighborHoodName; - /** - * 客户id - */ - /* @NotBlank(message = "客户id不能为空", groups = {AddGroup.class, UpdateGroup.class}) - private String customerId;*/ - /** * 组织id */ - @NotBlank(message = "组织id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "组织id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String agencyId; /** * 网格id */ - @NotBlank(message = "网格id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "网格id不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String gridId; /** * 关联物业id */ - @NotBlank(message = "关联物业ID不能为空", groups = {UpdateGroup.class}) + @NotBlank(message = "关联物业ID不能为空", groups = {AddShowGroup.class,UpdateShowGroup.class}) private String propertyId; /** * 详细地址 */ - @NotBlank(message = "详细地址不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "详细地址不能为空", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String address; /** * 备注 */ - @NotBlank(message = "备注不能为空", groups = {UpdateGroup.class}) - @Length(max=500,message = "备注不能超过500个字", groups = {AddGroup.class, UpdateGroup.class}) + @Length(max=500,message = "备注不能超过500个字", groups = {AddShowGroup.class, UpdateShowGroup.class}) private String remark; /** * 坐标位置 */ - //@NotBlank(message = "坐标位置不能为空", groups = {AddGroup.class, UpdateGroup.class}) private String location; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java index 3221ee3647..5077e99a33 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java @@ -57,4 +57,6 @@ public class HouseInfoDTO implements Serializable { * 房屋类型,1楼房,2平房,3别墅 */ private String houseType; -} \ No newline at end of file + + private String houseName; +} 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 c3222f2ad4..f3edc781e1 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 @@ -22,40 +22,29 @@ 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; -import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.constant.NeighborhoodConstant; import com.epmet.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.BuildingResultDTO; 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; import com.epmet.service.BuildingService; import com.epmet.service.IcBuildingService; -import com.epmet.service.IcNeighborHoodService; import com.epmet.service.NeighborHoodService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; @@ -100,7 +89,7 @@ public class BuildingController { @PostMapping("buildingadd") public Result buildingAdd(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(formDTO, AddGroup.class); + ValidatorUtils.validateEntity(formDTO, IcBulidingFormDTO.AddShowGroup.class); String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; @@ -111,7 +100,7 @@ public class BuildingController { @PostMapping("buildingupdate") public Result buildingUpdate(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + ValidatorUtils.validateEntity(formDTO, IcBulidingFormDTO.UpdateShowGroup.class); String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; buildingService.UpdateBuilding(customerId,formDTO); @@ -207,7 +196,7 @@ public class BuildingController { * @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()).orderByAsc(IcBuildingUnitEntity::getUnitNum)); 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 8bc4378e8f..12295301a1 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 @@ -23,8 +23,6 @@ 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; @@ -76,7 +74,7 @@ public class HouseController { @PostMapping("houseadd") public Result houseAdd(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(formDTO, AddGroup.class); + ValidatorUtils.validateEntity(formDTO, IcHouseFormDTO.AddShowGroup.class); String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; @@ -87,7 +85,7 @@ public class HouseController { @PostMapping("houseupdate") public Result houseUpdate(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + ValidatorUtils.validateEntity(formDTO, IcHouseFormDTO.UpdateShowGroup.class); String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; houseService.updateHouse(customerId,formDTO); 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 823363814a..6bbab45e12 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 @@ -24,8 +24,6 @@ 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.dao.IcBuildingDao; import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; @@ -89,7 +87,7 @@ public class NeighborHoodController { @PostMapping("neighborhoodadd") public Result neighborhoodadd(@LoginUser TokenDto tokenDTO, @RequestBody IcNeighborHoodFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(formDTO, AddGroup.class); + ValidatorUtils.validateEntity(formDTO, IcNeighborHoodFormDTO.AddShowGroup.class); String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; @@ -100,7 +98,7 @@ public class NeighborHoodController { @PostMapping("neighborhoodupdate") public Result neighborhoodupdate(@LoginUser TokenDto tokenDTO, @RequestBody IcNeighborHoodFormDTO formDTO){ //效验数据 - ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + ValidatorUtils.validateEntity(formDTO, IcNeighborHoodFormDTO.UpdateShowGroup.class); String customerId = tokenDTO.getCustomerId(); // String customerId = "123123"; neighborHoodService.UpdateNeighborhood(customerId,formDTO); 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 accf59bb87..e0fce5c740 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,16 +17,13 @@ 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.dto.result.BaseInfoFamilyBuildingResultDTO; import com.epmet.dto.result.BuildingResultDTO; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.IcBuildingEntity; import com.epmet.entity.IcHouseEntity; -import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.excel.IcBuildingExcel; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -71,5 +68,6 @@ public interface IcBuildingDao extends BaseDao { */ List baseInfoFamilyBuilding(@Param("neighborHoodId")String neighborHoodId); + Integer checkBuildName(@Param("neighborHoodId") String neighborHoodId,@Param("buildingName")String buildingName, @Param("buildingId")String buildingId); List buildingListByIds(@Param("buildingIdList") List buildingIdList); } \ 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 07ca76c21c..1553cccc9d 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 @@ -61,4 +61,9 @@ public interface IcHouseDao extends BaseDao { */ List selectHouseInfoByIdCard(@Param("idCard") String idCard); + Integer checkDoorNameUq(@Param("neighborHoodId") String neighborHoodId, + @Param("buildingId")String buildingId, + @Param("buildingUnitId")String buildingUnitId, + @Param("doorName")String doorName, + @Param("houseId")String houseId); } \ 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 4da3423f9d..19e30210ae 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 @@ -17,9 +17,7 @@ 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.IcHouseEntity; import com.epmet.entity.IcNeighborHoodEntity; @@ -29,7 +27,6 @@ import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; -import java.util.Set; /** * 小区表 @@ -49,4 +46,8 @@ public interface IcNeighborHoodDao extends BaseDao { List selectListByName(@Param("neighborNameList")List neighborNameList, @Param("agencyNameList") List agencyNameList, @Param("gridNameList") List gridNameList); + + Integer checkNameUq(@Param("customerId") String customerId, + @Param("neighborHoodName")String neighborHoodName, + @Param("neighborId")String neighborId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index ef09973b53..61ad0ba641 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 @@ -68,6 +68,11 @@ public class BuildingServiceImpl implements BuildingService { @Override @Transactional(rollbackFor = Exception.class) public void AddBuilding(String customerId, IcBulidingFormDTO formDTO) { + //同一小区下不能存在楼栋名字一样的 + Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(),formDTO.getBuildingName(),null); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(),EpmetErrorCode.BUILDING_NAME_EXITED.getMsg()); + } IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); icBuildingDTO.setCustomerId(customerId); IcBuildingEntity entity = ConvertUtils.sourceToTarget(icBuildingDTO, IcBuildingEntity.class); @@ -249,6 +254,11 @@ public class BuildingServiceImpl implements BuildingService { icBuildingUnit.setUnitNum(String.valueOf(i+1)); unitList.add(icBuildingUnit); } + //同一小区下不能存在楼栋名字一样的 + Integer count = icBuildingDao.checkBuildName(entity.getNeighborHoodId(),entity.getBuildingName(),null); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(),EpmetErrorCode.BUILDING_NAME_EXITED.getMsg()); + } icBuildingUnitEntityList.addAll(unitList); } //3.保存 @@ -279,12 +289,10 @@ public class BuildingServiceImpl implements BuildingService { ExcelPoiUtils.exportExcel(templatePath ,map,"楼宇信息录入表",response); return ; } - @Override public List buildingListByIds(List buildingIdList) { return icBuildingDao.buildingListByIds(buildingIdList); } - private List searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) { // QueryWrapper neighborHoodEntityQueryWrapper = new QueryWrapper<>(); @@ -377,6 +385,12 @@ public class BuildingServiceImpl implements BuildingService { @Override @Transactional(rollbackFor = Exception.class) public void UpdateBuilding(String customerId, IcBulidingFormDTO formDTO) { + //同一小区下不能存在楼栋名字一样的 + Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(),formDTO.getBuildingName(),formDTO.getBuildingId()); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(),EpmetErrorCode.BUILDING_NAME_EXITED.getMsg()); + } + IcBuildingDTO icBuilding= icBuildingService.get(formDTO.getBuildingId()); if(!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())){ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index b481f048e0..b1930df4b4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -3,7 +3,8 @@ package com.epmet.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.epmet.commons.tools.enums.HouseTypeEnum; +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.IcBuildingDao; import com.epmet.dao.IcBuildingUnitDao; @@ -63,6 +64,11 @@ public class HouseServiceImpl implements HouseService { @Override @Transactional(rollbackFor = Exception.class) public void addHouse(String customerId, IcHouseFormDTO formDTO) { + //同一楼栋,单元内,房屋名称唯一 + Integer count = icHouseDao.checkDoorNameUq(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(), formDTO.getDoorName(),null); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); + } IcHouseDTO icHouseDTO= ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); icHouseDTO.setCustomerId(customerId); // icHouseDTO.setRentFlag(formDTO.getRentFlag()); @@ -89,6 +95,11 @@ public class HouseServiceImpl implements HouseService { @Override @Transactional(rollbackFor = Exception.class) public void updateHouse(String customerId, IcHouseFormDTO formDTO) { + //同一楼栋,单元内,房屋名称唯一 + Integer count = icHouseDao.checkDoorNameUq(formDTO.getNeighborHoodId(), formDTO.getBuildingId(), formDTO.getBuildingUnitId(),formDTO.getDoorName(), formDTO.getHouseId()); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); + } IcHouseDTO icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); icHouseDTO.setId(formDTO.getHouseId()); icHouseDTO.setCustomerId(customerId); @@ -154,6 +165,11 @@ public class HouseServiceImpl implements HouseService { entity.setOwnerName(icHouseExcel.getOwnerName()); entity.setOwnerPhone(icHouseExcel.getOwnerPhone()); entity.setOwnerIdCard(icHouseExcel.getOwnerIdCard()); + //同一楼栋,单元内,房屋名称唯一 + Integer count = icHouseDao.checkDoorNameUq(entity.getNeighborHoodId(), entity.getBuildingId(), entity.getBuildingUnitId(), entity.getDoorName(),null); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); + } houseEntityList.add(entity); } //3.保存 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java index 2858eb6d31..0dbfa5796a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java @@ -191,21 +191,21 @@ public class IcHouseServiceImpl extends BaseServiceImpl>> resultMap = epmetUserOpenFeignClient.getHomeUserCategoryCount(userDTO); + Result>> resultMap = epmetUserOpenFeignClient.getHomeUserCategoryCount(userDTO); if (!resultMap.success()) { throw new RenException(resultMap.getCode(), resultMap.getMsg()); } - Map> map = resultMap.getData(); + Map> map = resultMap.getData(); return list.stream().map(item -> { - Map countMap = map.get(item.getId()); + Map countMap = map.get(item.getId()); HouseListResultDTO dto = new HouseListResultDTO(); dto.setHouseId(item.getId()); dto.setHouseName(item.getHouseName()); List categories = new ArrayList<>(); if (null != countMap && CollectionUtils.isNotEmpty(categoryList)) { for (IcResiCategoryStatsConfigDTO category : categoryList) { - if (null == countMap.get(category.getColumnName()) || countMap.get(category.getColumnName()) == NumConstant.ZERO) { + if (null == countMap.get(category.getColumnName()) || NumConstant.ZERO_STR.equals(countMap.get(category.getColumnName()))) { continue; } HouseListResultDTO.CategoryListBean bean = new HouseListResultDTO.CategoryListBean(); 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 00d96f74f6..ad24ef5ab8 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 @@ -4,6 +4,7 @@ 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.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; @@ -69,6 +70,11 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { @Override @Transactional(rollbackFor = Exception.class) public void AddNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { + //同一客户下,小区名称唯一 + Integer count = icNeighborHoodDao.checkNameUq(customerId,formDTO.getNeighborHoodName(),null); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); + } IcNeighborHoodDTO icNeighborHoodDTO = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodDTO.class); icNeighborHoodDTO.setCustomerId(customerId); Result customerAgencyResult = govOrgOpenFeignClient.getAgencyById(icNeighborHoodDTO.getAgencyId()); @@ -153,6 +159,12 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { @Override @Transactional(rollbackFor = Exception.class) public void UpdateNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { + //同一客户下,小区名称唯一 + Integer count = icNeighborHoodDao.checkNameUq(customerId,formDTO.getNeighborHoodName(),formDTO.getNeighborHoodId()); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); + } + IcNeighborHoodDTO icNeighborHoodDTO = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodDTO.class); icNeighborHoodDTO.setId(formDTO.getNeighborHoodId()); icNeighborHoodDTO.setCustomerId(customerId); @@ -250,6 +262,12 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { List neighborHoodEntityList = new ArrayList<>(); List icNeighborHoodPropertyEntityList = new ArrayList<>(); for (IcNeighborHoodExcel icNeighborHoodExcel : list) { + //同一客户下,小区名称唯一 + Integer count = icNeighborHoodDao.checkNameUq(customerId,icNeighborHoodExcel.getNeighborHoodName(),null); + if (null != count && count > 0) { + throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); + } + IcNeighborHoodEntity entity = new IcNeighborHoodEntity(); String uuid =UUID.randomUUID().toString().replace("-", ""); entity.setId(uuid); @@ -290,6 +308,11 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { // neighborHoodEntityQueryWrapper.eq("a.DEL_FLAG","0"); IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); neighbor.setDelFlag("0"); + if(OrgTypeEnum.GRID.getCode().equals(formDTO.getLevel())){ + neighbor.setGridId(formDTO.getId()); + }else{ + neighbor.setAgencyId(formDTO.getId()); + } IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class); return icNeighborHoodDao.searchAllNeighborhood(neighbor,house); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml index 6c2d82a05b..24d44d88f9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml @@ -128,14 +128,14 @@ 15 - + 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 6be098c62c..3c4022ea6f 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 @@ -300,6 +300,16 @@ AND b.NEIGHBOR_HOOD_ID = #{neighborHoodId} + + - \ 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 e150566f8a..0857166540 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 @@ -240,7 +240,8 @@ ih.BUILDING_UNIT_ID as buildingUnitId, u.UNIT_NAME as unitName, ih.DOOR_NAME as doorName, - ih.house_type + ih.house_type, + ih.HOUSE_NAME FROM ic_house ih left JOIN ic_neighbor_hood n ON ( ih.NEIGHBOR_HOOD_ID = n.id ) @@ -264,4 +265,17 @@ WHERE ih.DEL_FLAG = '0' AND ih.OWNER_ID_CARD = #{idCard} - \ 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 342b567ba7..dba659f38c 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 @@ -200,5 +200,15 @@ - + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index f1ffabeb14..278d0be422 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -652,5 +652,5 @@ public interface EpmetUserOpenFeignClient { Result> getDemandOptions(); @PostMapping("/epmetuser/icresiuser/categorycount") - Result>> getHomeUserCategoryCount(@RequestBody IcResiUserDTO formDTO); + Result>> getHomeUserCategoryCount(@RequestBody IcResiUserDTO formDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 681a067692..ccc971de19 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -471,7 +471,7 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien } @Override - public Result>> getHomeUserCategoryCount(IcResiUserDTO formDTO) { + public Result>> getHomeUserCategoryCount(IcResiUserDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getHomeUserCategoryCount", formDTO); } } diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 790d22ecf2..dcd727ce13 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -21,7 +21,7 @@ com.alibaba easyexcel - 2.2.10 + 3.0.3 poi diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index d1fa95e43a..044e03f476 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -19,6 +19,12 @@ package com.epmet.controller; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.converters.date.DateDateConverter; +import com.alibaba.excel.converters.date.DateStringConverter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -35,6 +41,7 @@ import com.epmet.dto.result.*; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; +import com.epmet.util.TestFileUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; @@ -48,6 +55,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; @@ -221,6 +229,7 @@ public class IcResiUserController { Map> sheetMap = new HashMap<>(); Map mapData = new HashMap<>(); mapData.put("list", resiMainList.values()); + System.out.println("========="+JSON.toJSONString(resiMainList.values())); sheetMap.put(0, mapData); AtomicInteger n = new AtomicInteger(); for (FormItem item : resiFormItems.getItemList()) { @@ -233,6 +242,7 @@ public class IcResiUserController { Map mapData2 = new HashMap<>(); mapData2.put("list", resiChildMap.values()); + System.out.println("========="+JSON.toJSONString(mapData2)); sheetMap.put(n.incrementAndGet(), mapData2); } } @@ -247,6 +257,152 @@ public class IcResiUserController { workbook.write(response.getOutputStream()); } + @RequestMapping(value = "/exportExcel2") + public void exportExcelByEasyExcel(@RequestHeader String customerId, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { + pageFormDTO.setCustomerId(customerId); + pageFormDTO.setPageFlag(false); + CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId()); + + Map> otherSheetItems = new HashMap<>(); + + //主表的 + for (FormItem formItem : resiFormItems.getItemList()) { + if (StringUtils.isBlank(formItem.getColumnName())) { + continue; + } + + Map itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>()); + otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap); + if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) { + itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem); + } + if (formItem.getChildGroup() != null) { + itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>()); + otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap); + for (FormItem2 item2 : formItem.getChildGroup().getItemList()) { + if (StringUtils.isBlank(item2.getColumnName())) { + continue; + } + + if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { + itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class)); + } + } + + } + } + //其他sheet + + for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { + if (groupItem.getItemList() == null) { + continue; + } + Map itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); + otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); + for (FormItem2 formItem2 : groupItem.getItemList()) { + if (StringUtils.isBlank(formItem2.getColumnName())) { + continue; + } + if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) { + itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class)); + } + } + } + + Map> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions()); + + //========================================= + + + // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替 + // {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list + +// String templatePath = "/excel/ic_resi_info_cid_for_easy_excel.xls"; +// String s1 = this.getClass().getResource(templatePath).getPath(); +// System.out.println("模版路径:"+s1); +// +// String templateFileName = s1; +// System.out.println("=templateFileName=="+templateFileName); +// String fileName = TestFileUtil.getPath() + "/excel/ic_resi_info_cid_for_easy_excel0000.xls"; +// System.out.println(fileName); +// ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build(); +// WriteSheet writeSheet = EasyExcel.writerSheet(0).build(); +// WriteSheet build = EasyExcel.writerSheet(1).build(); +// // 如果有多个list 模板上必须有{前缀.} 这里的前缀就是 data1,然后多个list必须用 FillWrapper包裹 +// excelWriter.fill(new FillWrapper("t1", resiMainList.values()), writeSheet); +// excelWriter.fill(new FillWrapper("t2", resiMainList.values()), build); + + // 别忘记关闭流 + //excelWriter.finish(); + //EasyExcel.write(new File(fileName)); + //========================================= + //resiMainList = (List>)JSON.parse("[{\"IS_BDHJ\":\"1\",\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest2\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":null,\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":null,\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":null,\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"},{\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":\"心理咨询\",\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":\"2021-10-28 00:00:00\",\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":\"10180002\",\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"}]"); + String originValue = JSON.toJSONString(resiMainList.values()); + System.out.println("========="+ originValue); + String templatePath = "/excel/ic_resi_info_cid_for_easy_excel.xls"; + String s1 = this.getClass().getResource(templatePath).getPath(); + System.out.println("模版路径:"+s1); + //TemplateExportParams params = new TemplateExportParams(templatePath, true); + String fileName = TestFileUtil.getPath() + "compositeFill" + "ic_resi_info_cid_for_easy_excel.xls"; + fileName = "/Users/liujianjun/Downloads/ic_resi_info_cid_for_easy_excel2.xls"; + System.out.println("fileName======="+fileName); + //String fileName = "居民基本信息.xls"; + ExcelWriter excelWriter = EasyExcel.write(getOutputStream(fileName,response)).registerConverter(new DateStringConverter()).registerConverter(new DateDateConverter()).withTemplate(s1).build(); + //ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(s1).build(); + WriteSheet fistSheet = EasyExcel.writerSheet(0).build(); + try { + excelWriter.fill(new FillWrapper("t1", resiMainList.values()), fistSheet); + } catch (Exception e) { + e.printStackTrace(); + } + + //======================================= + + /* Map> sheetMap = new HashMap<>(); + Map mapData = new HashMap<>(); + mapData.put("list", resiMainList.values()); + System.out.println("========="+JSON.toJSONString(resiMainList.values())); + sheetMap.put(0, mapData);*/ + AtomicInteger n = new AtomicInteger(); + for (FormItem item : resiFormItems.getItemList()) { + + if (item.getChildGroup() != null) { + if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) { + Map itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName()); + Map> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions()); + resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key))); + + /*Map mapData2 = new HashMap<>(); + mapData2.put("list", resiChildMap.values()); + System.out.println("========="+JSON.toJSONString(mapData2)); + sheetMap.put(n.incrementAndGet(), mapData2);*/ + int sheetNo = n.incrementAndGet(); + WriteSheet writeSheet = EasyExcel.writerSheet(sheetNo).build(); + System.out.println("======"+JSON.toJSONString(resiChildMap.values())); + excelWriter.fill(new FillWrapper("t"+(sheetNo+1), resiChildMap.values()), writeSheet); + } + } + } + + /* Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params); + workbook.setActiveSheet(0);*/ + excelWriter.finish(); + + + /* response.setHeader("content-Type", "application/vnd.ms-excel"); + response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8")); + workbook.write(response.getOutputStream());*/ + } + private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception { + fileName = URLEncoder.encode(fileName, "UTF-8"); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf8"); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls"); + response.addHeader("Access-Control-Expose-Headers", "Content-disposition"); + + return response.getOutputStream(); + } + /** * excel导入居民基本信息 * @@ -346,13 +502,13 @@ public class IcResiUserController { /** * @Description 获取一栋楼每个房间人员分类的数量 * @Param formDTO - * @Return {@link Result< Map< String, Map< String, Integer>>>} + * @Return {@link Result< Map< String, Map< String, String>>>} * @Author zhaoqifeng * @Date 2021/11/5 15:10 */ @PostMapping("categorycount") - public Result>> getHomeUserCategoryCount(@RequestBody IcResiUserDTO formDTO) { - return new Result>>().ok(icResiUserService.getHomeUserCategoryCount(formDTO.getBuildId())); + public Result>> getHomeUserCategoryCount(@RequestBody IcResiUserDTO formDTO) { + return new Result>>().ok(icResiUserService.getHomeUserCategoryCount(formDTO.getBuildId())); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index c3ed3df1f9..db7344b6ea 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -123,7 +123,7 @@ public interface IcResiUserDao extends BaseDao { String selectCategoryNames(@Param("customerId") String customerId,@Param("codeSet") Set codeSet); @MapKey("HOME_ID") - Map> getHomeUserCategoryCount(@Param("buildId") String buildId); + Map> getHomeUserCategoryCount(@Param("buildId") String buildId); /** * @Description 根据userId查询志愿者 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index 76a6a24618..0f82258bf0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -125,9 +125,9 @@ public interface IcResiUserService extends BaseService { /** * @Description 获取一栋楼每个房间人员分类的数量 * @Param buildId - * @Return {@link Map< String, Map< String, Integer>>} + * @Return {@link Map< String, Map< String, String>>} * @Author zhaoqifeng * @Date 2021/11/5 14:40 */ - Map> getHomeUserCategoryCount(String buildId); + Map> getHomeUserCategoryCount(String buildId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 0ad386f461..4b2a407e7e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -17,7 +17,6 @@ package com.epmet.service.impl; -import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -37,16 +36,13 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.IcPlatformConstant; import com.epmet.constant.SystemMessageType; import com.epmet.constant.UserConstant; import com.epmet.dao.IcResiUserDao; -import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.IcHouseDTO; -import com.epmet.dto.IcResiCategoryStatsConfigDTO; -import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.IcResiUserEntity; @@ -59,11 +55,12 @@ import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.sql.Date; +import java.sql.Timestamp; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -623,6 +620,15 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> mapList = this.dynamicQuery(customerId, formCode, baseTableName, conditions); Map> result = new LinkedHashMap<>(); mapList.stream().filter(Objects::nonNull).forEach(map -> { + map.forEach((k,o) -> { + if (o instanceof java.sql.Date){ + o = DateUtils.format(((Date) o),DateUtils.DATE_PATTERN); + } + if (o instanceof java.sql.Timestamp){ + o = DateUtils.format(new Date(((Timestamp) o).getTime()),DateUtils.DATE_TIME_PATTERN); + } + map.put(k,o); + }); String resiId = (String) map.getOrDefault(UserConstant.IC_RESI_USER, ""); if ("ic_resi_user".equals(baseTableName)) { @@ -707,7 +713,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl>} + * @Return {@link Map>} * @Author zhaoqifeng * @Date 2021/11/5 14:40 */ @Override - public Map> getHomeUserCategoryCount(String buildId) { + public Map> getHomeUserCategoryCount(String buildId) { return baseDao.getHomeUserCategoryCount(buildId); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/util/TestFileUtil.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/util/TestFileUtil.java new file mode 100644 index 0000000000..74e39697a0 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/util/TestFileUtil.java @@ -0,0 +1,36 @@ +package com.epmet.util; + +import java.io.File; +import java.io.InputStream; + +public class TestFileUtil { + + + public static InputStream getResourcesFileInputStream(String fileName) { + return Thread.currentThread().getContextClassLoader().getResourceAsStream("" + fileName); + } + + public static String getPath() { + return TestFileUtil.class.getResource("/").getPath(); + } + + public static File createNewFile(String pathName) { + File file = new File(getPath() + pathName); + if (file.exists()) { + file.delete(); + } else { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + } + return file; + } + + public static File readFile(String pathName) { + return new File(getPath() + pathName); + } + + public static File readUserHomeFile(String pathName) { + return new File(System.getProperty("user.home") + File.separator + pathName); + } +} diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls b/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls index 6e2934b55b..41f5796a53 100644 Binary files a/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid.xls differ diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xls b/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xls new file mode 100644 index 0000000000..01ec6893d3 Binary files /dev/null and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_cid_for_easy_excel.xls differ diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 427665134c..569880f604 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -179,9 +179,7 @@