| 
						
						
						
					 | 
				
				 | 
				
					@ -1,5 +1,6 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					package com.epmet.service.impl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.EpmetException; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -13,11 +14,15 @@ import com.epmet.entity.IcResiCollectEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.IcResiMemberEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.feign.GovOrgOpenFeignClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.IcResiCollectService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.collections4.MapUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.transaction.annotation.Transactional; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.List; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Map; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.function.Function; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * 居民信息采集表 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -54,13 +59,12 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl<IcResiCollectDao, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //更新主表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            baseDao.updateRec(origin.getId(),formDTO.getHouseType(),formDTO.getHouseHolderName(),formDTO.getTotalResi()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //查询成员表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            baseDao.updateRec(origin.getId(), formDTO.getHouseType(), formDTO.getHouseHolderName(), formDTO.getTotalResi()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<IcResiMemberEntity> newMemberList = ConvertUtils.sourceToTarget(formDTO.getMemberList(), IcResiMemberEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //查询之前录入的成员表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, IcResiMemberEntity> memMap = queryOriginMem(origin.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            saveOrUpdateMem(newMemberList, memMap,origin.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // IcResiCollectEntity entity = ConvertUtils.sourceToTarget(dto, IcResiCollectEntity.class);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // insert(entity);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -72,4 +76,25 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl<IcResiCollectDao, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return res.getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private Map<String, IcResiMemberEntity> queryOriginMem(String icResiCollectId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        LambdaQueryWrapper<IcResiMemberEntity> query = new LambdaQueryWrapper<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        query.eq(IcResiMemberEntity::getIcResiCollectId, icResiCollectId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcResiMemberEntity> originMemberList = icResiMemberDao.selectList(query); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, IcResiMemberEntity> memMap = originMemberList.stream().collect(Collectors.toMap(IcResiMemberEntity::getIdNum, Function.identity())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return memMap; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void saveOrUpdateMem(List<IcResiMemberEntity> newMemberList, Map<String, IcResiMemberEntity> memMap, String originIcResiCollectId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (IcResiMemberEntity entity : newMemberList) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (MapUtils.isNotEmpty(memMap) && memMap.containsKey(entity.getIdNum())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setIcResiCollectId(originIcResiCollectId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setCustomerId(memMap.get(entity.getIdNum()).getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                icResiMemberDao.updateById(entity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                continue; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //没有插入
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            entity.setIcResiCollectId(originIcResiCollectId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            icResiMemberDao.insert(entity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |