Browse Source

同一小区下楼栋不重名

dev
zhaoqifeng 3 years ago
parent
commit
3e140df253
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 1
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java
  3. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
  4. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java
  5. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
  6. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  7. 35
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -85,6 +85,7 @@ public enum EpmetErrorCode {
BUILDING_NAME_EXITED(8215,"楼栋名称已存在"), BUILDING_NAME_EXITED(8215,"楼栋名称已存在"),
DOOR_NAME_EXITED(8216,"门牌号已存在"), DOOR_NAME_EXITED(8216,"门牌号已存在"),
NEIGHBOOR_NAME_EXITED(8217,"小区名称已存在"), NEIGHBOOR_NAME_EXITED(8217,"小区名称已存在"),
BUILDING_NAME_EXITED_IN_GRID(8218,"小区下该楼栋已存在于其他网格"),
REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"),
THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"),

1
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java

@ -25,5 +25,6 @@ public interface ImportErrorMsgConstants {
String HOUSE_ERROR_NAME = "导入失败的列表-房屋"; String HOUSE_ERROR_NAME = "导入失败的列表-房屋";
String BUILDING_ERROR_NAME = "导入失败的列表-楼栋"; String BUILDING_ERROR_NAME = "导入失败的列表-楼栋";
String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区"; String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区";
String BUILDING_NAME_EXITED_IN_GRID = "小区下该楼栋已存在于其他网格";
} }

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

@ -67,6 +67,15 @@ public interface IcBuildingDao extends BaseDao<IcBuildingEntity> {
List<BaseInfoFamilyBuildingResultDTO> baseInfoFamilyBuilding(@Param("neighborHoodId")String neighborHoodId); List<BaseInfoFamilyBuildingResultDTO> baseInfoFamilyBuilding(@Param("neighborHoodId")String neighborHoodId);
Integer checkBuildName(@Param("neighborHoodId") String neighborHoodId,@Param("buildingName")String buildingName, @Param("buildingId")String buildingId); Integer checkBuildName(@Param("neighborHoodId") String neighborHoodId,@Param("buildingName")String buildingName, @Param("buildingId")String buildingId);
Integer checkBuildNameV2(@Param("agencyId") String agencyId,
@Param("neighborHoodName") String neighborHoodName,
@Param("buildingName")String buildingName,
@Param("buildingId")String buildingId);
Integer checkBuildNameV3(@Param("agencyId") String agencyId,
@Param("gridId") String gridId,
@Param("neighborHoodName") String neighborHoodName,
@Param("buildingName")String buildingName,
@Param("buildingId")String buildingId);
List<BuildingResultDTO> buildingListByIds(@Param("buildingIdList") List<String> buildingIdList); List<BuildingResultDTO> buildingListByIds(@Param("buildingIdList") List<String> buildingIdList);
IPage<BuildingResultDTO> buildingListByIds(IPage<IcBuildingEntity> page,@Param("buildingIdList") List<String> buildingIdList); IPage<BuildingResultDTO> buildingListByIds(IPage<IcBuildingEntity> page,@Param("buildingIdList") List<String> buildingIdList);

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java

@ -210,6 +210,12 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
} }
public void fillData(ImportGeneralDTO dto, String orgType){ public void fillData(ImportGeneralDTO dto, String orgType){
int count = icBuildingDao.checkBuildNameV3(dto.getAgencyId(), dto.getGridId(), dto.getNeighborHoodName(), dto.getBuildingName(), null);
if (count > 0){
// 说明数据库已存在此楼栋,不需添加
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_NAME_EXITED_IN_GRID);
}
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){
List<String> gridIds = new ArrayList<>(); List<String> gridIds = new ArrayList<>();
if (orgType.equals(CustomerGridConstant.GRID)){ if (orgType.equals(CustomerGridConstant.GRID)){

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java

@ -3,12 +3,12 @@ package com.epmet.model;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.CustomerGridConstant; import com.epmet.constant.CustomerGridConstant;
import com.epmet.constant.ImportErrorMsgConstants;
import com.epmet.constants.ImportTaskConstants; import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingDao;
import com.epmet.dto.IcHouseDTO; import com.epmet.dto.IcHouseDTO;
@ -489,6 +489,12 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
} }
public void fillData(ImportGeneralDTO dto, String orgType){ public void fillData(ImportGeneralDTO dto, String orgType){
int count = icBuildingDao.checkBuildNameV3(dto.getAgencyId(), dto.getGridId(), dto.getNeighborHoodName(), dto.getBuildingName(), null);
if (count > 0){
// 说明数据库已存在此楼栋,不需添加
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_NAME_EXITED_IN_GRID);
}
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){
List<String> gridIds = new ArrayList<>(); List<String> gridIds = new ArrayList<>();
if (orgType.equals(CustomerGridConstant.GRID)){ if (orgType.equals(CustomerGridConstant.GRID)){

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

@ -102,9 +102,15 @@ public class BuildingServiceImpl implements BuildingService {
public void addBuilding(String customerId, IcBulidingAddFormDTO formDTO) { public void addBuilding(String customerId, IcBulidingAddFormDTO formDTO) {
//同一小区下不能存在楼栋名字一样的 //同一小区下不能存在楼栋名字一样的
Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(), formDTO.getBuildingName(), null); Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(), formDTO.getBuildingName(), null);
if (null != count && count > 0) { if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(), EpmetErrorCode.BUILDING_NAME_EXITED.getMsg()); throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(), EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
} }
IcNeighborHoodEntity neighborHood = icNeighborHoodDao.selectById(formDTO.getNeighborHoodId());
count = icBuildingDao.checkBuildNameV2(formDTO.getAgencyId(), neighborHood.getNeighborHoodName(), formDTO.getBuildingName(), null);
if (null != count && count > 0) {
throw new EpmetException(EpmetErrorCode.BUILDING_NAME_EXITED_IN_GRID.getCode());
}
//楼栋编码不可重复 //楼栋编码不可重复
if(org.apache.commons.lang3.StringUtils.isNotBlank(formDTO.getCoding())){ if(org.apache.commons.lang3.StringUtils.isNotBlank(formDTO.getCoding())){
IcBuildingEntity isHaveCoding = icBuildingDao.selectByCoding(formDTO.getCoding(),null); IcBuildingEntity isHaveCoding = icBuildingDao.selectByCoding(formDTO.getCoding(),null);
@ -475,6 +481,11 @@ public class BuildingServiceImpl implements BuildingService {
if (null != count && count > 0) { if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(), EpmetErrorCode.BUILDING_NAME_EXITED.getMsg()); throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(), EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
} }
IcNeighborHoodEntity neighborHood = icNeighborHoodDao.selectById(formDTO.getNeighborHoodId());
count = icBuildingDao.checkBuildNameV2(formDTO.getAgencyId(), neighborHood.getNeighborHoodName(), formDTO.getBuildingName(), formDTO.getBuildingId());
if (null != count && count > 0) {
throw new EpmetException(EpmetErrorCode.BUILDING_NAME_EXITED_IN_GRID.getCode());
}
IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingId()); IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingId());
if (!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())) { if (!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())) {
//更新对应房屋小区id //更新对应房屋小区id

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

@ -247,6 +247,41 @@
</if> </if>
</select> </select>
<select id="checkBuildNameV2" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT( a.ID )
FROM
ic_building a
INNER JOIN ic_neighbor_hood b ON a.NEIGHBOR_HOOD_ID = b.ID
AND b.DEL_FLAG = '0'
AND b.AGENCY_ID = #{agencyId}
AND b.NEIGHBOR_HOOD_NAME = #{neighborHoodName}
WHERE
a.DEL_FLAG = '0'
AND a.BUILDING_NAME = #{buildingName}
<if test=" null != buildingId and buildingId.trim() != ''">
and a.ID !=#{buildingId}
</if>
</select>
<select id="checkBuildNameV3" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT( a.ID )
FROM
ic_building a
INNER JOIN ic_neighbor_hood b ON a.NEIGHBOR_HOOD_ID = b.ID
AND b.DEL_FLAG = '0'
AND b.AGENCY_ID = #{agencyId}
AND b.GRID_ID != #{gridId}
AND b.NEIGHBOR_HOOD_NAME = #{neighborHoodName}
WHERE
a.DEL_FLAG = '0'
AND a.BUILDING_NAME = #{buildingName}
<if test=" null != buildingId and buildingId.trim() != ''">
and a.ID !=#{buildingId}
</if>
</select>
<select id="buildingListByIds" resultType="com.epmet.dto.result.BuildingResultDTO"> <select id="buildingListByIds" resultType="com.epmet.dto.result.BuildingResultDTO">
select select
a.ID as buildingId, a.ID as buildingId,

Loading…
Cancel
Save