|  | @ -1,4 +1,5 @@ | 
			
		
	
		
		
			
				
					|  |  | package com.epmet.service.impl; |  |  | package com.epmet.service.impl; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.FieldConstant; |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
	
		
		
			
				
					|  | @ -25,12 +26,14 @@ import com.epmet.entity.DataSyncConfigEntity; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.DataSyncScopeEntity; |  |  | import com.epmet.entity.DataSyncScopeEntity; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.IcNatEntity; |  |  | import com.epmet.entity.IcNatEntity; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.IcNatRelationEntity; |  |  | import com.epmet.entity.IcNatRelationEntity; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.enums.DataSyncEnum; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.DataSyncConfigService; |  |  | import com.epmet.service.DataSyncConfigService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.DataSyncScopeService; |  |  | import com.epmet.service.DataSyncScopeService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.IcNatRelationService; |  |  | import com.epmet.service.IcNatRelationService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.IcNatService; |  |  | import com.epmet.service.IcNatService; | 
			
		
	
		
		
			
				
					|  |  | import com.github.pagehelper.PageHelper; |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
		
			
				
					|  |  | import com.github.pagehelper.PageInfo; |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					|  |  | import org.apache.commons.collections4.CollectionUtils; |  |  | import org.apache.commons.collections4.CollectionUtils; | 
			
		
	
		
		
			
				
					|  |  | import org.apache.commons.collections4.ListUtils; |  |  | import org.apache.commons.collections4.ListUtils; | 
			
		
	
		
		
			
				
					|  |  | import org.apache.commons.lang3.StringUtils; |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
	
		
		
			
				
					|  | @ -50,6 +53,7 @@ import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					|  |  |  * @author generator generator@elink-cn.com |  |  |  * @author generator generator@elink-cn.com | 
			
		
	
		
		
			
				
					|  |  |  * @since v1.0.0 2022-09-26 |  |  |  * @since v1.0.0 2022-09-26 | 
			
		
	
		
		
			
				
					|  |  |  */ |  |  |  */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  | @Slf4j | 
			
		
	
		
		
			
				
					|  |  | @Service |  |  | @Service | 
			
		
	
		
		
			
				
					|  |  | public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao, DataSyncConfigEntity> implements DataSyncConfigService { |  |  | public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao, DataSyncConfigEntity> implements DataSyncConfigService { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -119,10 +123,11 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public PageData list(TokenDto tokenDto, PageFormDTO formDTO) { |  |  |     public PageData list(TokenDto tokenDto, PageFormDTO formDTO) { | 
			
		
	
		
		
			
				
					|  |  |         PageData<DataSyncConfigDTO> result = new PageData<>(new ArrayList<>(), NumConstant.ZERO_L); |  |  |         PageData<DataSyncConfigDTO> result = new PageData<>(new ArrayList<>(), NumConstant.ZERO_L); | 
			
		
	
		
		
			
				
					
					|  |  |         PageInfo<DataSyncConfigDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.list(tokenDto.getCustomerId())); |  |  |         PageInfo<DataSyncConfigDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                 .doSelectPageInfo(() -> baseDao.list(tokenDto.getCustomerId(), null)); | 
			
		
	
		
		
			
				
					|  |  |         if (CollectionUtils.isNotEmpty(pageInfo.getList())){ |  |  |         if (CollectionUtils.isNotEmpty(pageInfo.getList())){ | 
			
		
	
		
		
			
				
					|  |  |             result.setList(pageInfo.getList()); |  |  |             result.setList(pageInfo.getList()); | 
			
		
	
		
		
			
				
					
					|  |  |             result.setTotal(Integer.valueOf(String.valueOf(pageInfo.getTotal()))); |  |  |             result.setTotal(Integer.parseInt(String.valueOf(pageInfo.getTotal()))); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         return result; |  |  |         return result; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
	
		
		
			
				
					|  | @ -171,40 +176,78 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao | 
			
		
	
		
		
			
				
					|  |  |      * @date 2022/9/26 17:16 |  |  |      * @date 2022/9/26 17:16 | 
			
		
	
		
		
			
				
					|  |  |      */ |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |     public void natInfoScanTask(NatInfoScanTaskFormDTO formDTO) { |  |  |     public void dataSyncForYanTaiTask(NatInfoScanTaskFormDTO formDTO) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (CollectionUtils.isNotEmpty(formDTO.getIdCards())){ |  |  |         List<DataSyncConfigDTO> allConfigList = baseDao.list(formDTO.getCustomerId() ,"open"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             List<NatUserInfoResultDTO> userIdByIdCard = baseDao.getUserIdByIdCard(formDTO.getIdCards()); |  |  |         if (CollectionUtils.isEmpty(allConfigList)){ | 
			
				
				
			
		
	
		
		
			
				
					|  |  |             List<NatUserInfoResultDTO> collect = formDTO.getIdCards().stream().map(id -> { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 NatUserInfoResultDTO e = new NatUserInfoResultDTO(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 e.setIdCard(id); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 e.setUserId(""); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 return e; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             }).collect(Collectors.toList()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             collect.forEach(c -> userIdByIdCard.stream().filter(u -> u.getIdCard().equals(c.getIdCard())).forEach(u -> c.setUserId(u.getUserId()))); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             hsjc(collect,formDTO.getCustomerId()); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |             return; |  |  |             return; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |         List<DataSyncConfigDTO> allConfigList = baseDao.list(StringUtils.isNotBlank(formDTO.getCustomerId()) ? formDTO.getCustomerId() : null); |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (CollectionUtils.isEmpty(allConfigList)){ |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         //TODO 根据dataCode 调用不同的方法 抽取数据
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (CollectionUtils.isNotEmpty(allConfigList)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             log.warn("dataSyncForYanTaiTask don't have any resi data to pull data form YanTai interface"); | 
			
		
	
		
		
			
				
					|  |  |             return; |  |  |             return; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |         List<DataSyncConfigDTO> configList = allConfigList.stream().filter(l -> l.getDeptCode().equals("dsjj") && l.getSwitchStatus().equals("open")).collect(Collectors.toList()); |  |  |         for (DataSyncConfigDTO config : allConfigList) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (CollectionUtils.isNotEmpty(configList)){ |  |  |             //没有配置 数据拉取范围 继续下次循环
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             configList.forEach(c -> { |  |  |             if (CollectionUtils.isEmpty(config.getScopeList())){ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 if (CollectionUtils.isNotEmpty(c.getScopeList())){ |  |  |                 continue; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     Integer no = NumConstant.ONE; |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     Integer size; |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     do { |  |  |             //如果传了身份证号 则按照身份证号查询 并同步记录, userId如果为空则是 手动录入的 此人没有录入居民库 但是也可以同步
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         PageInfo<NatUserInfoResultDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_THOUSAND).doSelectPageInfo(() -> baseDao.getIdCardsByScope(c.getScopeList())); |  |  |             if (CollectionUtils.isNotEmpty(formDTO.getIdCards())){ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         size = pageInfo.getList().size(); |  |  |                 List<NatUserInfoResultDTO> userIdByIdCard = baseDao.getIdCardsByScope(config.getScopeList(),formDTO.getIdCards()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         hsjc(pageInfo.getList(),c.getCustomerId()); |  |  |                 List<NatUserInfoResultDTO> collect = formDTO.getIdCards().stream().map(id -> { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         no++; |  |  |                     NatUserInfoResultDTO e = new NatUserInfoResultDTO(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     }while (size.compareTo(NumConstant.ONE_THOUSAND) == NumConstant.ZERO); |  |  |                     e.setIdCard(id); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 } |  |  |                     e.setUserId(""); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             }); |  |  |                     return e; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                 }).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 collect.forEach(c -> userIdByIdCard.stream().filter(u -> u.getIdCard().equals(c.getIdCard())).forEach(u -> c.setUserId(u.getUserId()))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 executeSyncData(config, collect); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 return; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 //没传具体参数 则 按照
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int pageNo = NumConstant.ONE; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int pageSize = NumConstant.ONE_THOUSAND; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 PageInfo<NatUserInfoResultDTO> pageInfo = null; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     //根据 组织 分页获取 居民数据
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     pageInfo = PageHelper.startPage(pageNo, pageSize, false) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             .doSelectPageInfo(() -> baseDao.getIdCardsByScope(config.getScopeList(),formDTO.getIdCards())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     executeSyncData(config, pageInfo.getList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     pageNo++; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } while (pageInfo != null && pageInfo.getSize() == pageSize); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * desc:根据居民身份证号 从蓝图api接口 获取数据到本地 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param config | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param resiList | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private void executeSyncData(DataSyncConfigDTO config, List<NatUserInfoResultDTO> resiList) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         DataSyncEnum anEnum = DataSyncEnum.getEnum(config.getDataCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         switch (anEnum) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             case HE_SUAN: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 hsjc(resiList, config.getCustomerId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             case CAN_JI: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 //todo
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             case SI_WANG: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 //todo
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             default: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 log.warn("没有要处理的数据"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * Desc: 根据证件号 查询nat 存在 ? 不处理 : 新增 |  |  |      * Desc: 根据证件号 查询nat 存在 ? 不处理 : 新增 | 
			
		
	
		
		
			
				
					|  |  |      * @param idCards |  |  |      * @param idCards | 
			
		
	
	
		
		
			
				
					|  | 
 |