liub 4 месяцев назад
Родитель
Сommit
ba9b50bbdc

+ 14 - 3
tenant/insurance/quotation-zhongan/src/main/java/com/jzg/quotation/zhongan/crawler/service/Impl/ZhongAnCrawlerRequestImpl.java

@@ -110,10 +110,21 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
 
     @Override
     public boolean detectLogin(DetectLoginRequest detectLoginRequest) {
-        String username = detectLoginRequest.getUsername();
-        String password = detectLoginRequest.getPassword();
-        return true;
+        // 先从缓存取
+        Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + zhongAnId);
+        if (cacheMap != null && !cacheMap.isEmpty()) {
+            System.out.println("[" + zhongAnId + "] 从 Redisson 缓存读取登录信息");
+            return true;
+        }
+
+        // 缓存没有 执行登录
+        LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(zhongAnId, productId);
 
+        // 登录成功 存缓存
+        if (result.getCode() == 200) {
+            zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), zhongAnId);
+        }
+        return result.getCode() == 200;
     }