|  |  |  | @ -380,83 +380,84 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode | 
			
		
	
		
			
				
					|  |  |  |  |             if(syncDataSetEntity == null || StrUtil.isEmpty(syncDataSetEntity.getSyncIp())){ | 
			
		
	
		
			
				
					|  |  |  |  |                 return; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCodeTempEntity> ioCodeTempEntities = ioCodeTempDao.selectList(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getCode, parentCode)); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isNotEmpty(ioCodeTempEntities)) { | 
			
		
	
		
			
				
					|  |  |  |  |             IoCodeTempEntity codeTempEntity = ioCodeTempEntities.get(0); | 
			
		
	
		
			
				
					|  |  |  |  |             //1、排除掉层级是1的
 | 
			
		
	
		
			
				
					|  |  |  |  |             UdiEntity udi = FilterUdiUtils.getUdi(parentCode); | 
			
		
	
		
			
				
					|  |  |  |  |             if (udi == null) | 
			
		
	
		
			
				
					|  |  |  |  |                 return; | 
			
		
	
		
			
				
					|  |  |  |  |             String udi1 = udi.getUdi(); | 
			
		
	
		
			
				
					|  |  |  |  |             UdiProductEntity udiProductEntity = udiProductService.findByNameCode(udi1); | 
			
		
	
		
			
				
					|  |  |  |  |             if (udiProductEntity == null) | 
			
		
	
		
			
				
					|  |  |  |  |                 return; | 
			
		
	
		
			
				
					|  |  |  |  |             List<RelCodeBatch> navList = this.list(new LambdaQueryWrapper<RelCodeBatch>() | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq(RelCodeBatch::getCurCode, parentCode)); | 
			
		
	
		
			
				
					|  |  |  |  |         ThreadUtil.execAsync(() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             List<IoCodeTempEntity> ioCodeTempEntities = ioCodeTempDao.selectList(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getCode, parentCode)); | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollUtil.isNotEmpty(ioCodeTempEntities)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 IoCodeTempEntity codeTempEntity = ioCodeTempEntities.get(0); | 
			
		
	
		
			
				
					|  |  |  |  |                 //1、排除掉层级是1的
 | 
			
		
	
		
			
				
					|  |  |  |  |                 UdiEntity udi = FilterUdiUtils.getUdi(parentCode); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (udi == null) | 
			
		
	
		
			
				
					|  |  |  |  |                     return; | 
			
		
	
		
			
				
					|  |  |  |  |                 String udi1 = udi.getUdi(); | 
			
		
	
		
			
				
					|  |  |  |  |                 UdiProductEntity udiProductEntity = udiProductService.findByNameCode(udi1); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (udiProductEntity == null) | 
			
		
	
		
			
				
					|  |  |  |  |                     return; | 
			
		
	
		
			
				
					|  |  |  |  |                 List<RelCodeBatch> navList = this.list(new LambdaQueryWrapper<RelCodeBatch>() | 
			
		
	
		
			
				
					|  |  |  |  |                         .eq(RelCodeBatch::getCurCode, parentCode)); | 
			
		
	
		
			
				
					|  |  |  |  | //            codeTempEntity.getSupId()
 | 
			
		
	
		
			
				
					|  |  |  |  |             //todo  if(navList)是空的  1.查供应商key;2:根据parentCode查阿里接口;3:根据返回结果,再次查询
 | 
			
		
	
		
			
				
					|  |  |  |  |             if(navList == null || navList.size() == 0 ){ | 
			
		
	
		
			
				
					|  |  |  |  |                         CustomerInfoEntity customerInfoEntity = customerInfoService.selectById(codeTempEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust= new AlihealthRelCodeInsertReqeust(); | 
			
		
	
		
			
				
					|  |  |  |  |                 alihealthRelCodeInsertReqeust.setAppKey(customerInfoEntity.getAppKey()); | 
			
		
	
		
			
				
					|  |  |  |  |                 alihealthRelCodeInsertReqeust.setAppSecret(customerInfoEntity.getAppSecret()); | 
			
		
	
		
			
				
					|  |  |  |  |                 alihealthRelCodeInsertReqeust.setCustomerId(codeTempEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 alihealthRelCodeInsertReqeust.setCode(parentCode); | 
			
		
	
		
			
				
					|  |  |  |  |                 alihealthRelCodeInsertReqeust.setRefEntId(customerInfoEntity.getRefEntId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 BaseResponse<AlihealthKytSinglerelationResponse> baseResponse = alihealthUtils.relCodeInsert(alihealthRelCodeInsertReqeust); | 
			
		
	
		
			
				
					|  |  |  |  |                 if(baseResponse.getCode() == 20000){ | 
			
		
	
		
			
				
					|  |  |  |  |                     AlihealthKytSinglerelationResponse alihealthKytSinglerelationResponse = baseResponse.getData(); | 
			
		
	
		
			
				
					|  |  |  |  |                     // 返回的码关联关系进行插入
 | 
			
		
	
		
			
				
					|  |  |  |  |                     RelCodeBatch relCodeBatch =  alihealthKytSinglerelationResponse.disposeRelCodeBatch( alihealthRelCodeInsertReqeust.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     RelCodeBatch relCodeBatchOne  = relCodeBatchService.getOne(new QueryWrapper<RelCodeBatch>().eq("productCode",relCodeBatch.getProductCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .last("limit 1") | 
			
		
	
		
			
				
					|  |  |  |  |                     ); | 
			
		
	
		
			
				
					|  |  |  |  |                     if(Objects.isNull(relCodeBatchOne)){ | 
			
		
	
		
			
				
					|  |  |  |  |                         relCodeBatch.setCreateUser(alihealthRelCodeInsertReqeust.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |  |                         relCodeBatch.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |                         relCodeBatchService.save(relCodeBatch); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     }else { | 
			
		
	
		
			
				
					|  |  |  |  |                         relCodeBatchService.update(relCodeBatch,new QueryWrapper<RelCodeBatch>().eq("productCode",relCodeBatch.getProductCode())); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     Integer  id = Objects.isNull(relCodeBatch.getId()) ? relCodeBatchOne.getId() :relCodeBatch.getId(); | 
			
		
	
		
			
				
					|  |  |  |  |                     // 进行查询
 | 
			
		
	
		
			
				
					|  |  |  |  |                     List<RelCodeDetail> list  = alihealthKytSinglerelationResponse.disposeRelRodeDetailList(id); | 
			
		
	
		
			
				
					|  |  |  |  |                     if(list!=null && list.size()>0){ | 
			
		
	
		
			
				
					|  |  |  |  |                         List curCodeList = new ArrayList(); | 
			
		
	
		
			
				
					|  |  |  |  |                         for (RelCodeDetail relCodeDetail : list) { | 
			
		
	
		
			
				
					|  |  |  |  |                             curCodeList.add(relCodeDetail.getCurCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 //todo  if(navList)是空的  1.查供应商key;2:根据parentCode查阿里接口;3:根据返回结果,再次查询
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (navList == null || navList.size() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     CustomerInfoEntity customerInfoEntity = customerInfoService.selectById(codeTempEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust = new AlihealthRelCodeInsertReqeust(); | 
			
		
	
		
			
				
					|  |  |  |  |                     alihealthRelCodeInsertReqeust.setAppKey(customerInfoEntity.getAppKey()); | 
			
		
	
		
			
				
					|  |  |  |  |                     alihealthRelCodeInsertReqeust.setAppSecret(customerInfoEntity.getAppSecret()); | 
			
		
	
		
			
				
					|  |  |  |  |                     alihealthRelCodeInsertReqeust.setCustomerId(codeTempEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     alihealthRelCodeInsertReqeust.setCode(parentCode); | 
			
		
	
		
			
				
					|  |  |  |  |                     alihealthRelCodeInsertReqeust.setRefEntId(customerInfoEntity.getRefEntId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     BaseResponse<AlihealthKytSinglerelationResponse> baseResponse = alihealthUtils.relCodeInsert(alihealthRelCodeInsertReqeust); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (baseResponse.getCode() == 20000) { | 
			
		
	
		
			
				
					|  |  |  |  |                         AlihealthKytSinglerelationResponse alihealthKytSinglerelationResponse = baseResponse.getData(); | 
			
		
	
		
			
				
					|  |  |  |  |                         // 返回的码关联关系进行插入
 | 
			
		
	
		
			
				
					|  |  |  |  |                         RelCodeBatch relCodeBatch = alihealthKytSinglerelationResponse.disposeRelCodeBatch(alihealthRelCodeInsertReqeust.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |  |                         RelCodeBatch relCodeBatchOne = relCodeBatchService.getOne(new QueryWrapper<RelCodeBatch>().eq("productCode", relCodeBatch.getProductCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .last("limit 1") | 
			
		
	
		
			
				
					|  |  |  |  |                         ); | 
			
		
	
		
			
				
					|  |  |  |  |                         if (Objects.isNull(relCodeBatchOne)) { | 
			
		
	
		
			
				
					|  |  |  |  |                             relCodeBatch.setCreateUser(alihealthRelCodeInsertReqeust.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |  |                             relCodeBatch.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |                             relCodeBatchService.save(relCodeBatch); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         } else { | 
			
		
	
		
			
				
					|  |  |  |  |                             relCodeBatchService.update(relCodeBatch, new QueryWrapper<RelCodeBatch>().eq("productCode", relCodeBatch.getProductCode())); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                         relCodeDetailService.remove(new QueryWrapper<RelCodeDetail>().in("curCode",curCodeList)); | 
			
		
	
		
			
				
					|  |  |  |  |                         Integer id = Objects.isNull(relCodeBatch.getId()) ? relCodeBatchOne.getId() : relCodeBatch.getId(); | 
			
		
	
		
			
				
					|  |  |  |  |                         // 进行查询
 | 
			
		
	
		
			
				
					|  |  |  |  |                         List<RelCodeDetail> list = alihealthKytSinglerelationResponse.disposeRelRodeDetailList(id); | 
			
		
	
		
			
				
					|  |  |  |  |                         if (list != null && list.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                             List curCodeList = new ArrayList(); | 
			
		
	
		
			
				
					|  |  |  |  |                             for (RelCodeDetail relCodeDetail : list) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 curCodeList.add(relCodeDetail.getCurCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  |                             relCodeDetailService.remove(new QueryWrapper<RelCodeDetail>().in("curCode", curCodeList)); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         relCodeDetailService.saveBatch(list); | 
			
		
	
		
			
				
					|  |  |  |  |                             relCodeDetailService.saveBatch(list); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                         // 插入成功就重新查询一下
 | 
			
		
	
		
			
				
					|  |  |  |  |                         navList = this.list(new LambdaQueryWrapper<RelCodeBatch>() | 
			
		
	
		
			
				
					|  |  |  |  |                                 .eq(RelCodeBatch::getCurCode, parentCode)); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         log.error(baseResponse.getMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     // 插入成功就重新查询一下
 | 
			
		
	
		
			
				
					|  |  |  |  |                     navList = this.list(new LambdaQueryWrapper<RelCodeBatch>() | 
			
		
	
		
			
				
					|  |  |  |  |                             .eq(RelCodeBatch::getCurCode, parentCode)); | 
			
		
	
		
			
				
					|  |  |  |  |                 }else { | 
			
		
	
		
			
				
					|  |  |  |  |                     log.error(baseResponse.getMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if ((udiProductEntity != null && "1".equals(udiProductEntity.getPackLevel())) | 
			
		
	
		
			
				
					|  |  |  |  |                     || (CollUtil.isNotEmpty(navList)) | 
			
		
	
		
			
				
					|  |  |  |  |             ) { | 
			
		
	
		
			
				
					|  |  |  |  |                 //打上匹配到了药品关联关系的标记
 | 
			
		
	
		
			
				
					|  |  |  |  |                 for (int i = 0; i < ioCodeTempEntities.size(); i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                     IoCodeTempEntity ioCodeTempEntity = ioCodeTempEntities.get(i); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioCodeTempEntity.setDrugLink(1); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioCodeTempDao.updateById(ioCodeTempEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 if ((udiProductEntity != null && "1".equals(udiProductEntity.getPackLevel())) | 
			
		
	
		
			
				
					|  |  |  |  |                         || (CollUtil.isNotEmpty(navList)) | 
			
		
	
		
			
				
					|  |  |  |  |                 ) { | 
			
		
	
		
			
				
					|  |  |  |  |                     //打上匹配到了药品关联关系的标记
 | 
			
		
	
		
			
				
					|  |  |  |  |                     for (int i = 0; i < ioCodeTempEntities.size(); i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                         IoCodeTempEntity ioCodeTempEntity = ioCodeTempEntities.get(i); | 
			
		
	
		
			
				
					|  |  |  |  |                         ioCodeTempEntity.setDrugLink(1); | 
			
		
	
		
			
				
					|  |  |  |  |                         ioCodeTempDao.updateById(ioCodeTempEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     ThreadUtil.execAsync(() -> { | 
			
		
	
		
			
				
					|  |  |  |  |                         asynThreadUpdateIoCodeTempEntity(parentCode, ioCodeTempEntities); | 
			
		
	
		
			
				
					|  |  |  |  |                     }); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 ThreadUtil.execAsync(() -> { | 
			
		
	
		
			
				
					|  |  |  |  |                     asynThreadUpdateIoCodeTempEntity(parentCode, ioCodeTempEntities); | 
			
		
	
		
			
				
					|  |  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |