|
|
@@ -1,6 +1,7 @@
|
|
|
package com.jzg.quotation.huanong.crawler.service.impl;
|
|
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
+import com.alibaba.nacos.shaded.com.google.common.collect.ImmutableMap;
|
|
|
import com.jzg.commons.entity.quote.vo.image.InsuranceImageVo;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.quotation.commons.component.DistributedLockComponent;
|
|
|
@@ -41,6 +42,17 @@ public class HuaNongCrawlerQuoteProcessServiceImpl implements HuaNongCrawlerQuot
|
|
|
|
|
|
// 登录循环次数
|
|
|
private final static int LOGIN_RETRY_COUNT = 5;
|
|
|
+ // 登录机构类型map
|
|
|
+ private static final Map<String, String> BUSINESS_TYPE_MAP;
|
|
|
+ static {
|
|
|
+ Map<String, String> m = new HashMap<>();
|
|
|
+ m.put("传统直销", "11");
|
|
|
+ m.put("个人代理", "51");
|
|
|
+ m.put("专业代理", "53");
|
|
|
+ m.put("经纪业务", "54");
|
|
|
+ m.put("车商业务", "521");
|
|
|
+ BUSINESS_TYPE_MAP = Collections.unmodifiableMap(m);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -168,14 +180,14 @@ public class HuaNongCrawlerQuoteProcessServiceImpl implements HuaNongCrawlerQuot
|
|
|
return redissonComponent.cacheJson(HuaNongCrawlerCacheComponent.SALE_INFO + agreementId, () -> {
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
// 归属机构
|
|
|
- HuaNongCrawlerComInfoQueryRequestRequest huaNongCrawlerComInfoQueryRequest = new HuaNongCrawlerComInfoQueryRequestRequest(loginComCode, token);
|
|
|
+ HuaNongCrawlerComInfoQueryRequestRequest huaNongCrawlerComInfoQueryRequest = new HuaNongCrawlerComInfoQueryRequestRequest(parameters.getComCode(), token);
|
|
|
HuaNongCrawlerComInfoQueryResponse huaNongCrawlerComInfoQueryResponse = huaNongCrawlerRequestComponent.comInfoQuery(huaNongCrawlerComInfoQueryRequest, httpHeaders);
|
|
|
List<HuaNongCrawlerComInfoQueryResponse.ComListDTO> comList = huaNongCrawlerComInfoQueryResponse.getComList();
|
|
|
Map<String, HuaNongCrawlerComInfoQueryResponse.ComListDTO> com = comList.stream()
|
|
|
.collect(Collectors.toMap(HuaNongCrawlerComInfoQueryResponse.ComListDTO::getComCode, x -> x));
|
|
|
|
|
|
// 代理人信息
|
|
|
- HuaNongCrawlerUserTypeAndProxyInfoQueryRequestRequest userTypeAndProxyInfoQueryRequest = new HuaNongCrawlerUserTypeAndProxyInfoQueryRequestRequest(username, token, loginComCode, parameters.getComCode(),parameters.getProducerCode());
|
|
|
+ HuaNongCrawlerUserTypeAndProxyInfoQueryRequestRequest userTypeAndProxyInfoQueryRequest = new HuaNongCrawlerUserTypeAndProxyInfoQueryRequestRequest(username, token, loginComCode, parameters.getComCode(),BUSINESS_TYPE_MAP.get(parameters.getProducer()));
|
|
|
HuaNongCrawlerUserTypeAndProxyInfoQueryResponse userTypeAndProxyInfoQueryResponse = huaNongCrawlerRequestComponent.userTypeAndProxyInfoQuery(userTypeAndProxyInfoQueryRequest, httpHeaders);
|
|
|
|
|
|
//代理人
|
|
|
@@ -191,10 +203,10 @@ public class HuaNongCrawlerQuoteProcessServiceImpl implements HuaNongCrawlerQuot
|
|
|
x -> x
|
|
|
));
|
|
|
// 协议号
|
|
|
- List<HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgreementListDTO> agreementList = userTypeAndProxyInfoQueryResponse.getAgreementList();
|
|
|
- /*Map<String, String> map = agreementList.stream()
|
|
|
+ /*List<HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgreementListDTO> agreementList = userTypeAndProxyInfoQueryResponse.getAgreementList();
|
|
|
+ *//*Map<String, String> map = agreementList.stream()
|
|
|
.collect(Collectors.toMap(HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgreementListDTO::getAgreementNo, HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgreementListDTO::getAgentCode));
|
|
|
-*/
|
|
|
+*//*
|
|
|
Map<String, String> map = Optional.ofNullable(agreementList)
|
|
|
.orElseGet(Collections::emptyList)
|
|
|
.stream()
|
|
|
@@ -203,7 +215,7 @@ public class HuaNongCrawlerQuoteProcessServiceImpl implements HuaNongCrawlerQuot
|
|
|
HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgreementListDTO::getAgreementNo,
|
|
|
HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgreementListDTO::getAgentCode,
|
|
|
(existing, replacement) -> existing // 重复键保留第一个
|
|
|
- ));
|
|
|
+ ));*/
|
|
|
// 业务员
|
|
|
List<HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.HandlerListDTO> handlerList = userTypeAndProxyInfoQueryResponse.getHandlerList();
|
|
|
Map<String, HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.HandlerListDTO> handler = handlerList.stream()
|
|
|
@@ -225,7 +237,12 @@ public class HuaNongCrawlerQuoteProcessServiceImpl implements HuaNongCrawlerQuot
|
|
|
|
|
|
HuaNongCrawlerComInfoQueryResponse.ComListDTO comListDTO = com.get(parameters.getComCode());
|
|
|
HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.HandlerListDTO handlerListDTO = Optional.ofNullable(handlerList).filter(CollectionUtils::isNotEmpty).map(list -> list.get(0)).orElse(null);
|
|
|
- HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgentInfoListDTO agentInfoListDTO = agentInfoListDTOMap.get(map.get(parameters.getAgreementNo())) == null?new HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgentInfoListDTO() : agentInfoListDTOMap.get(map.get(parameters.getAgreementNo()));
|
|
|
+ HuaNongCrawlerUserTypeAndProxyInfoQueryResponse.AgentInfoListDTO agentInfoListDTO = agentInfoListDTOMap.values().stream()
|
|
|
+ .filter(dto -> dto.getAgentName() != null && dto.getAgentName().equals(parameters.getHandlerCode()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+
|
|
|
+
|
|
|
return new HuaNongCrawlerQuotedPriceRequestRequest.BusinessDataDTO.SaleInfoDTO(comListDTO, handlerListDTO, agentInfoListDTO, producerListDTO, baseInfoDTO, parameters.getCallerName());
|
|
|
}, HuaNongCrawlerQuotedPriceRequestRequest.BusinessDataDTO.SaleInfoDTO.class, Duration.ofHours(HuaNongCrawlerCacheComponent.SALE_INFO_TIME));
|
|
|
}
|