|  |  | @ -6,11 +6,14 @@ import com.epmet.commons.tools.constant.StrConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.dto.result.YtDataSyncResDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.dto.result.YtHscyResDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.dto.result.YtHsjcResDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.google.common.util.concurrent.RateLimiter; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.HashMap; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.ConcurrentHashMap; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.TimeUnit; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * @Description | 
			
		
	
	
		
			
				
					|  |  | @ -24,6 +27,11 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |     private static final String CARD_NO = "card_no"; | 
			
		
	
		
			
				
					|  |  |  |     private static final String ROW_NUM = "ROWNUM"; | 
			
		
	
		
			
				
					|  |  |  |     private static final String PAGE_SIZE = "PAGESIZE"; | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * rate is "2 permits per second" | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private static final Map<String,RateLimiter> rateLimiterMap = new ConcurrentHashMap<>(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:核酸采样查询 | 
			
		
	
	
		
			
				
					|  |  | @ -32,6 +40,8 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public static YtHscyResDTO hscy(String cardNo, Integer rowNum, Integer pageSize) { | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             tryAcquire("hscy"); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Map<String, Object> param = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |             param.put(APP_KEY, "tz45j4kuWcnnjoJOVSlzGWJgI"); | 
			
		
	
		
			
				
					|  |  |  |             param.put(CARD_NO, cardNo); | 
			
		
	
	
		
			
				
					|  |  | @ -53,13 +63,19 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台核酸检测结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台核酸检测结果查询异常cardNo:%s", cardNo), e); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         YtHscyResDTO resultResult = new YtHscyResDTO(); | 
			
		
	
		
			
				
					|  |  |  |         resultResult.setData(new ArrayList<>()); | 
			
		
	
		
			
				
					|  |  |  |         return resultResult; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private static void tryAcquire(String hscy) { | 
			
		
	
		
			
				
					|  |  |  |         RateLimiter rateLimiter = rateLimiterMap.getOrDefault(hscy, RateLimiter.create(2.0)); | 
			
		
	
		
			
				
					|  |  |  |         rateLimiterMap.putIfAbsent(hscy,rateLimiter); | 
			
		
	
		
			
				
					|  |  |  |         rateLimiter.tryAcquire(1, TimeUnit.SECONDS); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:核酸结果查询 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  | @ -67,6 +83,8 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public static YtHsjcResDTO hsjc(String cardNo, Integer rowNum, Integer pageSize) { | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             tryAcquire("hsjc"); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Map<String, Object> param = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |             param.put(APP_KEY, "DR4jF5Be7sCsqDmCamq2tmYCl"); | 
			
		
	
		
			
				
					|  |  |  |             param.put(CARD_NO, cardNo); | 
			
		
	
	
		
			
				
					|  |  | @ -88,7 +106,7 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台核酸检测结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台核酸检测结果查询异常cardNo:%s", cardNo), e); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         YtHsjcResDTO resultResult = new YtHsjcResDTO(); | 
			
		
	
		
			
				
					|  |  |  |         resultResult.setData(new ArrayList<>()); | 
			
		
	
	
		
			
				
					|  |  | @ -102,6 +120,7 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public static YtDataSyncResDTO siWang(String cardNo, String userName) { | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             tryAcquire("siWang"); | 
			
		
	
		
			
				
					|  |  |  | //            1)appkey秘钥
 | 
			
		
	
		
			
				
					|  |  |  | //            2)name姓名 必填
 | 
			
		
	
		
			
				
					|  |  |  | //            3)idcard身份证号 必填
 | 
			
		
	
	
		
			
				
					|  |  | @ -135,7 +154,7 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |                     //第一层
 | 
			
		
	
		
			
				
					|  |  |  |                     JSONObject secondData = JSON.parseObject(firstData.getString("data")); | 
			
		
	
		
			
				
					|  |  |  |                     Object thirdData = ""; | 
			
		
	
		
			
				
					|  |  |  |                     if (secondData != null && secondData.getJSONArray("data") != null) { | 
			
		
	
		
			
				
					|  |  |  |                     if (secondData != null && secondData.getJSONArray("data") != null && secondData.getJSONArray("data").size() >0 ) { | 
			
		
	
		
			
				
					|  |  |  |                         //第二层 data
 | 
			
		
	
		
			
				
					|  |  |  |                         thirdData = secondData.getJSONArray("data").get(0); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
	
		
			
				
					|  |  | @ -147,7 +166,7 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |                 log.warn("siWang 调用蓝图接口败"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台siWang结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台siWang结果查询异常cardNo:%s", cardNo), e); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return new YtDataSyncResDTO(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -159,6 +178,7 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  |      * @remark:默认失败 因为一旦成功没有数据 会影响残疾人的数据 接口失败数据不做任何处理 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public static YtDataSyncResDTO canji(String idCard, String userName) { | 
			
		
	
		
			
				
					|  |  |  |         tryAcquire("canji"); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         YtDataSyncResDTO failResult = new YtDataSyncResDTO(); | 
			
		
	
		
			
				
					|  |  |  |         failResult.setCode(500); | 
			
		
	
	
		
			
				
					|  |  | @ -201,15 +221,15 @@ public class YtHsResUtils { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台canji结果查询异常cardNo:%s,异常信息:%s", idCard, e.getMessage())); | 
			
		
	
		
			
				
					|  |  |  |             log.error(String.format("烟台canji结果查询异常cardNo:%s,异常信息:%s", idCard), e); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return failResult; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     public static void main(String[] args) { | 
			
		
	
		
			
				
					|  |  |  |         YtDataSyncResDTO canji = canji("123", "123"); | 
			
		
	
		
			
				
					|  |  |  |         System.out.println("残疾结果:" + JSON.toJSON(canji)); | 
			
		
	
		
			
				
					|  |  |  |         //YtDataSyncResDTO canji = canji("123", "123");
 | 
			
		
	
		
			
				
					|  |  |  |         //System.out.println("残疾结果:" + JSON.toJSON(canji));
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         YtDataSyncResDTO siwang = siWang("1213", "!23"); | 
			
		
	
	
		
			
				
					|  |  | 
 |