Browse Source

小区导入修改

dev
zxc 3 years ago
parent
commit
dd301aabdf
  1. 18
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
  2. 41
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java
  3. 17
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
  4. 30
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  5. 43
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml

18
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java

@ -18,6 +18,8 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.NeighborHoodAndManagementDTO;
import com.epmet.dto.form.IcNeighborHoodListFormDTO; import com.epmet.dto.form.IcNeighborHoodListFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.entity.IcHouseEntity; import com.epmet.entity.IcHouseEntity;
@ -59,4 +61,20 @@ public interface IcNeighborHoodDao extends BaseDao<IcNeighborHoodEntity> {
*/ */
List<String> selectNeighborhoodNameByNames(@Param("names")List<String> names,@Param("customerId") String customerId); List<String> selectNeighborhoodNameByNames(@Param("names")List<String> names,@Param("customerId") String customerId);
/**
* Desc: 更新小区详细地址和备注
* @param needUpdateList
* @author zxc
* @date 2022/4/27 09:59
*/
void updateNeighborHood(@Param("list") List<ImportGeneralDTO> needUpdateList);
/**
* Desc: 更新小区关系表
* @param updateNeighborHoodAndManagement
* @author zxc
* @date 2022/4/27 10:33
*/
void neighborHoodPropertyUpdate(@Param("list")List<NeighborHoodAndManagementDTO> updateNeighborHoodAndManagement);
} }

41
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java

@ -51,6 +51,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); List<ImportGeneralDTO> needDisposeList = new ArrayList<>();
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); List<ImportGeneralDTO> needInsertList = new ArrayList<>();
List<ImportGeneralDTO> needUpdateList = new ArrayList<>();
String gridName = null; String gridName = null;
String agencyName = null; String agencyName = null;
@ -128,7 +129,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
} }
public void finalDispose(){ public void finalDispose(){
if (CollectionUtils.isEmpty(needDisposeList)){ if (CollectionUtils.isEmpty(needDisposeList) && CollectionUtils.isEmpty(needUpdateList)){
return; return;
} }
Map<String, Long> groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( Map<String, Long> groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy(
@ -151,8 +152,11 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
}); });
Map<Boolean, List<ImportGeneralDTO>> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); Map<Boolean, List<ImportGeneralDTO>> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus));
List<ImportGeneralDTO> importGeneralDTOS = groupByStatus.get(false); List<ImportGeneralDTO> importGeneralDTOS = groupByStatus.get(false);
if (!CollectionUtils.isEmpty(importGeneralDTOS) || !CollectionUtils.isEmpty(needUpdateList)){
List<ImportGeneralDTO> importInfo = new ArrayList<>();
if (!CollectionUtils.isEmpty(importGeneralDTOS)){ if (!CollectionUtils.isEmpty(importGeneralDTOS)){
List<ImportGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS);
}
Map<Boolean, List<ImportGeneralDTO>> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getNeighborHoodExistStatus)); Map<Boolean, List<ImportGeneralDTO>> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getNeighborHoodExistStatus));
List<ImportGeneralDTO> existList = groupByBuildingExistStatus.get(true); List<ImportGeneralDTO> existList = groupByBuildingExistStatus.get(true);
if (!CollectionUtils.isEmpty(existList)){ if (!CollectionUtils.isEmpty(existList)){
@ -165,7 +169,16 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
} }
}); });
} }
List<ImportGeneralDTO> notExistList = groupByBuildingExistStatus.get(false); List<ImportGeneralDTO> notExistList = new ArrayList<>();
List<ImportGeneralDTO> notExistListFalse = groupByBuildingExistStatus.get(false);
if (!CollectionUtils.isEmpty(notExistListFalse)){
notExistList.addAll(notExistListFalse);
}
if (!CollectionUtils.isEmpty(needUpdateList)){
notExistList.addAll(needUpdateList);
// 更新详细地址和备注
neighborHoodService.updateNeighborHood(needUpdateList);
}
if (!CollectionUtils.isEmpty(notExistList)){ if (!CollectionUtils.isEmpty(notExistList)){
// 物业表插入 // 物业表插入
List<String> propertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); List<String> propertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList());
@ -184,15 +197,26 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
neighborHoodService.insertPropertyManagement(propertyManagementEntities); neighborHoodService.insertPropertyManagement(propertyManagementEntities);
// 小区物业关系表插入 // 小区物业关系表插入
List<NeighborHoodAndManagementDTO> neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(notExistList, NeighborHoodAndManagementDTO.class); List<NeighborHoodAndManagementDTO> neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(notExistListFalse, NeighborHoodAndManagementDTO.class);
List<NeighborHoodAndManagementDTO> updateNeighborHoodAndManagement = ConvertUtils.sourceToTarget(needUpdateList, NeighborHoodAndManagementDTO.class);
List<IcPropertyManagementEntity> propertyManagementInfos = propertyManagementDao.selectIdByName(propertyNames); List<IcPropertyManagementEntity> propertyManagementInfos = propertyManagementDao.selectIdByName(propertyNames);
if (!CollectionUtils.isEmpty(neighborHoodAndManagementDTOS)){
neighborHoodAndManagementDTOS.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName())) neighborHoodAndManagementDTOS.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName()))
.forEach(p -> { .forEach(p -> {
n.setPropertyId(p.getId()); n.setPropertyId(p.getId());
n.setNeighborHoodId(n.getNeighborHoodId()); n.setNeighborHoodId(n.getNeighborHoodId());
})); }));
}
if (!CollectionUtils.isEmpty(updateNeighborHoodAndManagement)){
updateNeighborHoodAndManagement.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName()))
.forEach(p -> {
n.setPropertyId(p.getId());
n.setNeighborHoodId(n.getNeighborHoodId());
}));
}
List<IcNeighborHoodPropertyEntity> icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class); List<IcNeighborHoodPropertyEntity> icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class);
neighborHoodService.neighborHoodPropertyInsert(icNeighborHoodPropertyEntities); neighborHoodService.neighborHoodPropertyInsert(icNeighborHoodPropertyEntities);
neighborHoodService.neighborHoodPropertyUpdate(updateNeighborHoodAndManagement);
} }
} }
} }
@ -200,6 +224,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
// 清除 // 清除
needDisposeList = new ArrayList<>(); needDisposeList = new ArrayList<>();
needInsertList = new ArrayList<>(); needInsertList = new ArrayList<>();
needUpdateList = new ArrayList<>();
gridName = null; gridName = null;
agencyName = null; agencyName = null;
gridInfos = null; gridInfos = null;
@ -297,9 +322,13 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
// 赋值小区ID // 赋值小区ID
dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString());
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ if (StringUtils.isNotBlank(dto.getNeighborHoodId())){
/**
* 2022-04-27 新增需求存在小区进行更改 更新物业详细地址备注信息
*/
// 小区已存在 // 小区已存在
nums.add(dto.getNum()); /*nums.add(dto.getNum());
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);*/
needUpdateList.add(dto);
}else { }else {
needDisposeList.add(dto); needDisposeList.add(dto);
} }

17
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java

@ -23,6 +23,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.NeighborHoodAndManagementDTO;
import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.IcNeighborHoodAddFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO;
@ -155,4 +156,20 @@ public interface IcNeighborHoodService extends BaseService<IcNeighborHoodEntity>
* @return * @return
*/ */
PageData<IcNeighborHoodDTO> openPage(IcNeighborHoodAddFormDTO params); PageData<IcNeighborHoodDTO> openPage(IcNeighborHoodAddFormDTO params);
/**
* Desc: 更新小区
* @param needUpdateList
* @author zxc
* @date 2022/4/27 09:59
*/
void updateNeighborHood(List<ImportGeneralDTO> needUpdateList);
/**
* Desc: 更新小区关系表
* @param updateNeighborHoodAndManagement
* @author zxc
* @date 2022/4/27 10:33
*/
void neighborHoodPropertyUpdate(List<NeighborHoodAndManagementDTO> updateNeighborHoodAndManagement);
} }

30
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java

@ -496,11 +496,13 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void neighborHoodPropertyInsert(List<IcNeighborHoodPropertyEntity> entities){ public void neighborHoodPropertyInsert(List<IcNeighborHoodPropertyEntity> entities){
if (CollectionUtils.isNotEmpty(entities)){
List<List<IcNeighborHoodPropertyEntity>> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); List<List<IcNeighborHoodPropertyEntity>> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED);
partition.forEach(p -> { partition.forEach(p -> {
neighborHoodPropertyService.insertBatch(p); neighborHoodPropertyService.insertBatch(p);
}); });
} }
}
/** /**
* 获取导入小区楼栋单元ID * 获取导入小区楼栋单元ID
@ -708,4 +710,32 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
return result; return result;
} }
/**
* Desc: 更新小区
* @param needUpdateList
* @author zxc
* @date 2022/4/27 09:59
*/
@Override
@Transactional
public void updateNeighborHood(List<ImportGeneralDTO> needUpdateList) {
if (CollectionUtils.isNotEmpty(needUpdateList)){
baseDao.updateNeighborHood(needUpdateList);
}
}
/**
* Desc: 更新小区关系表
* @param updateNeighborHoodAndManagement
* @author zxc
* @date 2022/4/27 10:33
*/
@Override
@Transactional
public void neighborHoodPropertyUpdate(List<NeighborHoodAndManagementDTO> updateNeighborHoodAndManagement) {
if (CollectionUtils.isNotEmpty(updateNeighborHoodAndManagement)){
baseDao.neighborHoodPropertyUpdate(updateNeighborHoodAndManagement);
}
}
} }

43
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml

@ -25,6 +25,49 @@
<result property="updatedTime" column="UPDATED_TIME"/> <result property="updatedTime" column="UPDATED_TIME"/>
</resultMap> </resultMap>
<!-- 更新小区详细地址和备注 -->
<update id="updateNeighborHood">
update ic_neighbor_hood
<trim prefix="set" suffixOverrides=",">
<trim prefix="ADDRESS =(case" suffix="end),">
<foreach collection="list" item="l">
when id = #{l.neighborHoodId} then #{l.address}
</foreach>
</trim>
<trim prefix="REMARK =(case" suffix="end),">
<foreach collection="list" item="l">
when id = #{l.neighborHoodId} then #{l.remark}
</foreach>
</trim>
UPDATED_TIME = NOW()
</trim>
WHERE DEL_FLAG = '0'
AND ID IN (
<foreach collection="list" item="l" separator=",">
#{l.neighborHoodId}
</foreach>
)
</update>
<!-- 更新小区关系表 -->
<update id="neighborHoodPropertyUpdate">
update ic_neighbor_hood_property
<trim prefix="set" suffixOverrides=",">
<trim prefix="PROPERTY_ID =(case" suffix="end),">
<foreach collection="list" item="l">
when NEIGHBOR_HOOD_ID = #{l.neighborHoodId} then #{l.propertyId}
</foreach>
</trim>
UPDATED_TIME = NOW()
</trim>
WHERE DEL_FLAG = '0'
AND NEIGHBOR_HOOD_ID IN (
<foreach collection="list" item="l" separator=",">
#{l.neighborHoodId}
</foreach>
)
</update>
<!--<select id="searchNeighborhoodByPage" resultType="map"> <!--<select id="searchNeighborhoodByPage" resultType="map">
select select
a.id as neighborHoodId, a.id as neighborHoodId,

Loading…
Cancel
Save