|
|
@@ -48,8 +48,10 @@ import com.jzg.quotation.huatai.crawler.util.CryptoUtil;
|
|
|
import com.jzg.quotation.huatai.crawler.util.UploadUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
@@ -865,15 +867,16 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
|
|
|
|
|
|
private UnderwritingResultsVo handlePassedUnderwriting(HtCrawlerOrder order, HtCrawlerConfigureParameters params, UnderwritingVo vo, Map<String, Object> map) {
|
|
|
HtCrawlerPaymentLinkResponse pl = queryPaymentLink(order, params, new PaymentLinkVo());
|
|
|
- log.info("paymentLinkResponse: {}", JSONObject.toJSONString(pl));
|
|
|
- vo.getInsOrders().setPayLink(pl.getImg());
|
|
|
- vo.getInsOrders().setAuditTime(LocalDateTime.now());
|
|
|
- vo.getInsOrders().setCompanyOrderNo(order.getQuotationRelaNo());
|
|
|
+ log.info("handlePassedUnderwriting_paymentLinkResponse: {}", JSONObject.toJSONString(pl));
|
|
|
UnderwritingResultsVo r = new UnderwritingResultsVo();
|
|
|
r.setPaymentLink(pl.getImg());
|
|
|
r.setJqPolicyno(map.get("jqProposalno") == null ? "" : map.get("jqProposalno").toString());
|
|
|
r.setSyPolicyno(map.get("syProposalno") == null ? "" : map.get("syProposalno").toString());
|
|
|
r.setUnderwritingStatus(InsOrderStatusEnum.PAY_PENDING);
|
|
|
+
|
|
|
+ order.setJqPolicyno(r.getJqPolicyno());
|
|
|
+ order.setSyPolicyno(r.getSyPolicyno());
|
|
|
+ orderService.update(order);
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
@@ -887,6 +890,8 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
|
|
|
HtCrawlerConfigureParameters.class, attr.getConfigInfo());
|
|
|
HtCrawlerPaymentLinkResponse pl = queryPaymentLink(order, params, vo);
|
|
|
log.info("paymentLinkResponse: {}", JSONObject.toJSONString(pl));
|
|
|
+ order.setPaymentLink(pl.getImg());
|
|
|
+ orderService.update(order);
|
|
|
return new PaymentLinkResultsVo(true, pl.getImg(), pl.getErrorInfo());
|
|
|
}
|
|
|
|
|
|
@@ -975,9 +980,9 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
|
|
|
AttributionInformationVo attr = vo.getOrder().getAttributionInformationVo();
|
|
|
doLoginCookie(attr);
|
|
|
String productId = vo.getOrder().getProductId();
|
|
|
- String companyOrderNo = vo.getOrder().getCompanyOrderNo();
|
|
|
+ HtCrawlerOrder order = orderService.findByOrdersNo(vo.getOrder().getOrdersNo());
|
|
|
return ProductsType.PT_0330.getCode().equals(productId)
|
|
|
- ? downloadPolicy(companyOrderNo, true) : downloadPolicy(companyOrderNo, false);
|
|
|
+ ? downloadPolicy(order.getJqPolicyno(), true) : downloadPolicy(order.getSyPolicyno(), false);
|
|
|
}
|
|
|
|
|
|
private DownloadPolicyResultVo downloadPolicy(String no, boolean jq) {
|
|
|
@@ -996,10 +1001,16 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
|
|
|
HtCrawlerDownloadPolicyResponse res = JSONObject.parseObject(body, HtCrawlerDownloadPolicyResponse.class);
|
|
|
log.info("下载保单响应结果,{}", JSONObject.toJSONString(res));
|
|
|
DownloadPolicyResultVo r = new DownloadPolicyResultVo();
|
|
|
- for (var ftp : res.getFtpdownloadJson()) {
|
|
|
- if (jq) { r.setJqUrl(ftp.getDownurl()); r.setJqFlagUrl(ftp.getBzdownurl()); }
|
|
|
- else { r.setSyUrl(ftp.getDownurl()); }
|
|
|
- log.info("下载{}保单地址:{}", jq ? "交强" : "商业", ftp.getDownurl());
|
|
|
+ List<HtCrawlerDownloadPolicyResponse.FtpdownloadJson> ftpdownloadJson = res.getFtpdownloadJson();
|
|
|
+ if(!ftpdownloadJson.isEmpty()) {
|
|
|
+ if (jq) {
|
|
|
+ r.setJqUrl(ftpdownloadJson.get(0).getDownurl());
|
|
|
+ r.setJqFlagUrl(ftpdownloadJson.get(1).getBzdownurl());
|
|
|
+ log.info("下载交强保单地址:{}", r.getJqUrl());
|
|
|
+ } else {
|
|
|
+ r.setSyUrl(ftpdownloadJson.get(0).getDownurl());
|
|
|
+ log.info("下载商业保单地址:{}", r.getSyUrl());
|
|
|
+ }
|
|
|
}
|
|
|
return r;
|
|
|
}
|
|
|
@@ -1008,26 +1019,88 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
|
|
|
@Override
|
|
|
public OrderStatusResultVo queryOrderState(OrderStatusVo vo) {
|
|
|
AttributionInformationVo attr = vo.getOrder().getAttributionInformationVo();
|
|
|
+ doLoginCookie(attr);
|
|
|
HtCrawlerConfigureParameters params = ConfigureParametersConversion.conversionEntity(
|
|
|
HtCrawlerConfigureParameters.class, attr.getConfigInfo());
|
|
|
HtCrawlerOrder order = orderService.findByOrdersNo(vo.getOrder().getOrdersNo());
|
|
|
- String orderStatus = req.queryOrderStatus(new HtCrawlerOrderStateRequest(params, order.getQuotationRelaNo()), req.getHeaders());
|
|
|
+ String html = req.queryOrderStatus(new HtCrawlerOrderStateRequest(params, order.getQuotationRelaNo()), req.getHeaders());
|
|
|
String regex = "<div style=\"display: inline-block;width:50px;text-align: center; \">(.*?)</div>";
|
|
|
Pattern pattern = Pattern.compile(regex);
|
|
|
- Matcher matcher = pattern.matcher(orderStatus);
|
|
|
+ Matcher matcher = pattern.matcher(html);
|
|
|
+ String orderStatus = null;
|
|
|
if (matcher.find()) orderStatus = matcher.group(1);
|
|
|
InsOrderStatusEnum orderStatusEnum = null;
|
|
|
+ String syApplication = "";
|
|
|
+ String jqApplication = "";
|
|
|
+ String fcxApplication = "";
|
|
|
if ("已通过核保已实收".equals(orderStatus)) {
|
|
|
orderStatusEnum = InsOrderStatusEnum.valueOf("QUOTE_ING");
|
|
|
orderStatus = orderStatusEnum.getCode();
|
|
|
+ List<Map<String, String>> fcxList = new ArrayList<>();
|
|
|
+ // 1. 构建请求头 headers
|
|
|
+ HttpHeaders headers = getHttpHeaders();
|
|
|
+
|
|
|
+ // 2. 拼接URL + GET参数 params
|
|
|
+ String baseUrl = "https://cspxp.pc.ehuatai.com/htcsp/DocumentPrintAction.do";
|
|
|
+ MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
|
|
+ map.add("cmd", "queryDocumentPrintList");
|
|
|
+ map.add("printType", "1");
|
|
|
+ map.add("quotationno", order.getQuotationRelaNo());
|
|
|
+ map.add("licenseno", vo.getCarInfo().getLicenseNo());
|
|
|
+
|
|
|
+ // 3. 发起GET请求(复用项目已有cookieUtils工具,跳过证书校验同verify=False)
|
|
|
+ String htmlResp = get(baseUrl, headers, map);
|
|
|
+
|
|
|
+ // 4. Jsoup解析HTML,查找所有type=checkbox的input
|
|
|
+ Document soup = Jsoup.parse(htmlResp);
|
|
|
+ Elements inputElements = soup.select("input[type=checkbox]");
|
|
|
+
|
|
|
+ // 循环遍历input标签
|
|
|
+ for (Element item : inputElements) {
|
|
|
+ String businessno = item.attr("businessno");
|
|
|
+ String riskcode = item.attr("riskcode");
|
|
|
+ log.info("riskcode: {}, businessno: {}", riskcode, businessno);
|
|
|
+
|
|
|
+ if ("1251".equals(riskcode)) {
|
|
|
+ syApplication = businessno;
|
|
|
+ } else if ("1002".equals(riskcode)) {
|
|
|
+ jqApplication = businessno;
|
|
|
+ } else {
|
|
|
+ fcxApplication = businessno;
|
|
|
+ Map<String, String> fcxItem = new HashMap<>();
|
|
|
+ fcxItem.put("policy", "");
|
|
|
+ fcxItem.put("application", businessno);
|
|
|
+ fcxList.add(fcxItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
OrderStatusResultVo orderStatusResultVo = new OrderStatusResultVo();
|
|
|
//将订单状态转换为枚举类型
|
|
|
orderStatusResultVo.setOrderStatus(orderStatusEnum);
|
|
|
orderStatusResultVo.setOrderStatusStr(orderStatus);
|
|
|
+
|
|
|
+ orderStatusResultVo.setJqPolicyno( StringUtils.isBlank(jqApplication) ? order.getJqPolicyno() : jqApplication);
|
|
|
+ orderStatusResultVo.setSyPolicyno( StringUtils.isBlank(syApplication) ? order.getSyPolicyno() : syApplication);
|
|
|
+ orderStatusResultVo.setJyPolicyno( StringUtils.isBlank(fcxApplication) ? order.getJyPolicyno() : fcxApplication);
|
|
|
+ orderStatusResultVo.setPaymentLink(order.getPaymentLink());
|
|
|
return orderStatusResultVo;
|
|
|
}
|
|
|
|
|
|
+ @NotNull
|
|
|
+ private HttpHeaders getHttpHeaders() {
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7");
|
|
|
+ headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
|
|
|
+ headers.set("Cache-Control", "no-cache");
|
|
|
+ headers.set("Connection", "keep-alive");
|
|
|
+ headers.set("Pragma", "no-cache");
|
|
|
+ headers.set("Referer", "https://cspxp.pc.ehuatai.com/htcsp/QuotationQueryAction.do?cmd=quotationListAll");
|
|
|
+ headers.set("Upgrade-Insecure-Requests", "1");
|
|
|
+ headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36");
|
|
|
+ headers.set("Cookie", req.getCookie()); // 塞入cookie
|
|
|
+ return headers;
|
|
|
+ }
|
|
|
+
|
|
|
// ====================== Headers 统一构建 ======================
|
|
|
private HttpHeaders header(Consumer<HttpHeaders> customizer) {
|
|
|
HttpHeaders h = new HttpHeaders();
|