|  |  | @ -5,6 +5,7 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.dto.form.PageFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.dto.result.YtHsjcResDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.EpmetException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.page.PageData; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.redis.common.CustomerOrgRedis; | 
			
		
	
	
		
			
				
					|  |  | @ -12,14 +13,21 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; | 
			
		
	
		
			
				
					|  |  |  | 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.YtHsResUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.DataSyncConfigDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.IcNatDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.DataSyncConfigDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.ConfigSwitchFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.NatInfoScanTaskFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.ScopeSaveFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.NatUserInfoResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.DataSyncConfigEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.DataSyncScopeEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.IcNatEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.DataSyncConfigService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.DataSyncScopeService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.IcNatService; | 
			
		
	
		
			
				
					|  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.collections4.CollectionUtils; | 
			
		
	
	
		
			
				
					|  |  | @ -30,7 +38,9 @@ import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * 数据更新配置表 | 
			
		
	
	
		
			
				
					|  |  | @ -43,6 +53,10 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private DataSyncScopeService dataSyncScopeService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private IcNatDao icNatDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private IcNatService icNatService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private QueryWrapper<DataSyncConfigEntity> getWrapper(Map<String, Object> params){ | 
			
		
	
		
			
				
					|  |  |  |         String id = (String)params.get(FieldConstant.ID_HUMP); | 
			
		
	
	
		
			
				
					|  |  | @ -142,4 +156,88 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao | 
			
		
	
		
			
				
					|  |  |  |             dataSyncScopeService.insertBatch(ConvertUtils.sourceToTarget(formDTO.getScopeList(), DataSyncScopeEntity.class)); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * Desc: | 
			
		
	
		
			
				
					|  |  |  |      * 大数据局部门配置on | 
			
		
	
		
			
				
					|  |  |  |      * 根据范围搜索居民,调接口查询最近一次核酸检测记录 | 
			
		
	
		
			
				
					|  |  |  |      * 检测时间 + 身份证 不存在就插入 | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2022/9/26 17:16 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void natInfoScanTask(NatInfoScanTaskFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isNotEmpty(formDTO.getIdCards())){ | 
			
		
	
		
			
				
					|  |  |  |             List<NatUserInfoResultDTO> userIdByIdCard = baseDao.getUserIdByIdCard(formDTO.getIdCards()); | 
			
		
	
		
			
				
					|  |  |  |             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; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<DataSyncConfigDTO> allConfigList = baseDao.list(StringUtils.isNotBlank(formDTO.getCustomerId()) ? formDTO.getCustomerId() : null); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(allConfigList)){ | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<DataSyncConfigDTO> configList = allConfigList.stream().filter(l -> l.getDeptCode().equals("dsjj") && l.getSwitchStatus().equals("open")).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isNotEmpty(configList)){ | 
			
		
	
		
			
				
					|  |  |  |             configList.forEach(c -> { | 
			
		
	
		
			
				
					|  |  |  |                 if (CollectionUtils.isNotEmpty(c.getScopeList())){ | 
			
		
	
		
			
				
					|  |  |  |                     Integer no = NumConstant.ONE; | 
			
		
	
		
			
				
					|  |  |  |                     Integer size; | 
			
		
	
		
			
				
					|  |  |  |                     do { | 
			
		
	
		
			
				
					|  |  |  |                         PageInfo<NatUserInfoResultDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_THOUSAND).doSelectPageInfo(() -> baseDao.getIdCardsByScope(c.getScopeList())); | 
			
		
	
		
			
				
					|  |  |  |                         size = pageInfo.getList().size(); | 
			
		
	
		
			
				
					|  |  |  |                         hsjc(pageInfo.getList(),c.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                         no++; | 
			
		
	
		
			
				
					|  |  |  |                     }while (size.compareTo(NumConstant.ONE_THOUSAND) == NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * Desc: 根据证件号 查询nat 存在 ? 不处理 : 新增 | 
			
		
	
		
			
				
					|  |  |  |      * @param idCards | 
			
		
	
		
			
				
					|  |  |  |      * @param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2022/9/27 11:08 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private void hsjc(List<NatUserInfoResultDTO> idCards,String customerId){ | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isNotEmpty(idCards)){ | 
			
		
	
		
			
				
					|  |  |  |             List<IcNatEntity> entities = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |             idCards.forEach(idCard -> { | 
			
		
	
		
			
				
					|  |  |  |                 YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  |                 if (CollectionUtils.isNotEmpty(natInfoResult.getData())){ | 
			
		
	
		
			
				
					|  |  |  |                     natInfoResult.getData().forEach(natInfo -> { | 
			
		
	
		
			
				
					|  |  |  |                         IcNatEntity e = new IcNatEntity(); | 
			
		
	
		
			
				
					|  |  |  |                         e.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |                         e.setIsResiUser(StringUtils.isBlank(idCard.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  |                         e.setUserId(idCard.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |                         e.setUserType("sync"); | 
			
		
	
		
			
				
					|  |  |  |                         e.setName(natInfo.getName()); | 
			
		
	
		
			
				
					|  |  |  |                         e.setMobile(natInfo.getTelephone()); | 
			
		
	
		
			
				
					|  |  |  |                         e.setIdCard(natInfo.getCard_no()); | 
			
		
	
		
			
				
					|  |  |  |                         e.setNatTime(DateUtils.parseDate(natInfo.getTest_time(),DateUtils.DATE_TIME_PATTERN)); | 
			
		
	
		
			
				
					|  |  |  |                         e.setNatResult(natInfo.getSample_result_pcr()); | 
			
		
	
		
			
				
					|  |  |  |                         e.setNatAddress(natInfo.getSampling_org_pcr()); | 
			
		
	
		
			
				
					|  |  |  |                         entities.add(e); | 
			
		
	
		
			
				
					|  |  |  |                     }); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |             if (CollectionUtils.isNotEmpty(entities)){ | 
			
		
	
		
			
				
					|  |  |  |                 List<NatUserInfoResultDTO> existNatInfos = icNatDao.getExistNatInfo(entities); | 
			
		
	
		
			
				
					|  |  |  |                 entities.forEach(e -> existNatInfos.stream().filter(i -> i.getUserId().equals(e.getUserId()) && i.getIdCard().equals(e.getIdCard())).forEach(i -> e.setExistStatus(true))); | 
			
		
	
		
			
				
					|  |  |  |                 Map<Boolean, List<IcNatEntity>> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); | 
			
		
	
		
			
				
					|  |  |  |                 if (CollectionUtils.isNotEmpty(groupByStatus.get(false))){ | 
			
		
	
		
			
				
					|  |  |  |                     icNatService.insertBatch(groupByStatus.get(false)); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } |