Browse Source

解决保单无法下载问题

wks 2 years ago
parent
commit
a164b4cba5

+ 3 - 0
src/main/java/com/ydtech/modules/ins/model/vo/QuoteRespVo.java

@@ -29,6 +29,9 @@ public class QuoteRespVo {
     @ApiModelProperty("评分")
     private String iLogPreUdwMess;
 
+    @ApiModelProperty("提示信息")
+    private String tips;
+
     @ApiModelProperty("商业险险种")
     private List<QuoteKindRespVo> kindList;
 

+ 2 - 2
src/main/java/com/ydtech/modules/order/entity/crawler/response/CrawlerPolicyPrintResponse.java

@@ -19,13 +19,13 @@ public class CrawlerPolicyPrintResponse extends CrawlerBaseResponse {
     private String jqxPolicyUrl;
 
     /**
-     * 交强险标志地址
+     * 商业险标志地址
      */
     @JsonProperty("syx_policy_url")
     private String syxPolicyUrl;
 
     /**
-     * 商业险保单地址
+     * 交强险标志地址
      */
     @JsonProperty("jqx_flag_url")
     private String jqxFlagUrl;

+ 17 - 3
src/main/java/com/ydtech/modules/order/entity/crawler/response/CrawlerQuoteResponse.java

@@ -1,9 +1,7 @@
 package com.ydtech.modules.order.entity.crawler.response;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
+import lombok.*;
 import org.springframework.util.ObjectUtils;
 
 import java.io.Serializable;
@@ -148,10 +146,26 @@ public class CrawlerQuoteResponse extends CrawlerBaseResponse {
         private String syDiscount;
 
         /**
+         * 返回1需要验车,返回0不验车。
          * 是否需要验车
          */
         @JsonProperty("isQuoteGreenWay")
         private String isQuoteGreenWay;
     }
 
+    @Getter
+    @AllArgsConstructor
+    public enum QuoteGreenWayEnum {
+
+        Q_0("0", "不验车"),
+        Q_1("1", "需要验车");
+
+        private final String code;
+
+        private final String desc;
+
+
+    }
+
+
 }

+ 2 - 6
src/main/java/com/ydtech/modules/order/entity/crawler/vo/CrawlerPolicyPrintVo.java

@@ -4,11 +4,13 @@ import com.ydtech.modules.order.entity.crawler.response.CrawlerPolicyPrintRespon
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
 
 @Data
 @ApiModel("保单地址")
+@NoArgsConstructor
 public class CrawlerPolicyPrintVo implements Serializable {
 
     private static final long serialVersionUID = -1760478430310950471L;
@@ -25,11 +27,5 @@ public class CrawlerPolicyPrintVo implements Serializable {
     @ApiModelProperty("驾意险保单地址")
     private String jyxPolicyUrl;
 
-    public CrawlerPolicyPrintVo(CrawlerPolicyPrintResponse crawlerPolicyPrintResponse) {
-        this.jqxPolicyUrl = crawlerPolicyPrintResponse.getJqxPolicyUrl();
-        this.syxPolicyUrl = crawlerPolicyPrintResponse.getSyxPolicyUrl();
-        this.jqxFlagUrl = crawlerPolicyPrintResponse.getJqxFlagUrl();
-        this.jyxPolicyUrl = crawlerPolicyPrintResponse.getJyxPolicyUrl();
-    }
 
 }

+ 35 - 4
src/main/java/com/ydtech/modules/order/service/impl/InsCrawlerOrderServiceImpl.java

@@ -8,6 +8,7 @@ import com.ydtech.exception.SystemException;
 import com.ydtech.modules.ins.model.vo.*;
 import com.ydtech.modules.order.components.InsCrawlerOrderComponents;
 import com.ydtech.modules.order.entity.InsAreaCompany;
+import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.TaxArrears;
 import com.ydtech.modules.order.entity.crawler.constants.CrawlerVerifyPaymentConstants;
 import com.ydtech.modules.order.entity.crawler.request.*;
@@ -18,6 +19,7 @@ import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
 import com.ydtech.modules.order.service.InsAreaCompanyService;
 import com.ydtech.modules.order.service.InsCrawlerOrderService;
+import com.ydtech.modules.order.service.InsOrdersService;
 import com.ydtech.modules.order.service.InsTaskImagesService;
 import com.ydtech.modules.protocol.entity.constants.PtlCrawlerApiType;
 import com.ydtech.modules.protocol.entity.dto.PtlAgreementAttributionDto;
@@ -26,7 +28,9 @@ import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
 import com.ydtech.modules.protocol.service.PtlCrawlerApiService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.CalculateUtils;
+import com.ydtech.utils.baidu.FileUtil;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
@@ -47,16 +51,26 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
     private final InsAreaCompanyService insAreaCompanyService;
 
     private final InsTaskImagesService insTaskImagesService;
+    private final InsOrdersService insOrdersService;
 
-    public InsCrawlerOrderServiceImpl(PtlCrawlerApiService ptlCrawlerApiService, InsCrawlerOrderComponents insCrawlerOrderComponents, PtlAgreementAttributionService ptlAgreementAttributionService, InsAreaCompanyService insAreaCompanyService, InsTaskImagesService insTaskImagesService) {
+    @Value("${upload.file.path}")
+    private String uploadFilePath;
+
+    @Value("${upload.file.url}")
+    private String showFileUrl;
+
+    @Value("${api.url}")
+    private String apiUrl;
+
+    public InsCrawlerOrderServiceImpl(PtlCrawlerApiService ptlCrawlerApiService, InsCrawlerOrderComponents insCrawlerOrderComponents, PtlAgreementAttributionService ptlAgreementAttributionService, InsAreaCompanyService insAreaCompanyService, InsTaskImagesService insTaskImagesService, InsOrdersService insOrdersService) {
         this.ptlCrawlerApiService = ptlCrawlerApiService;
         this.insCrawlerOrderComponents = insCrawlerOrderComponents;
         this.ptlAgreementAttributionService = ptlAgreementAttributionService;
         this.insAreaCompanyService = insAreaCompanyService;
         this.insTaskImagesService = insTaskImagesService;
+        this.insOrdersService = insOrdersService;
     }
 
-
     @Override
     public void isLogin(PtlAgreementAttributionDto attribution, String companyId, String insCompanyName) {
 
@@ -156,6 +170,10 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
     @Override
     public HttpResult<CrawlerPolicyPrintVo> getPolicyPrint(String subOrderNo) {
         InsAreaCompany insAreaCompany = insAreaCompanyService.getById(subOrderNo);
+        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+        // 车牌号
+        String licensePlate = insOrders.getLicenseno();
+
         // 请求地址
         String apiUrl = ptlCrawlerApiService.getApiUrl(insAreaCompany.getAgreementId(), PtlCrawlerApiType.API_6);
         //组装参数
@@ -166,10 +184,19 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
             throw new SystemException(request.getMessage());
         }
 
-        CrawlerPolicyPrintVo crawlerPolicyPrintVo = new CrawlerPolicyPrintVo(request);
+        CrawlerPolicyPrintVo crawlerPolicyPrintVo = new CrawlerPolicyPrintVo();
+        crawlerPolicyPrintVo.setJqxFlagUrl(gainCarInsPolicy(request.getJqxFlagUrl(), licensePlate + "-交强险标志.pdf", licensePlate));
+        crawlerPolicyPrintVo.setJqxPolicyUrl(gainCarInsPolicy(request.getJqxPolicyUrl(), licensePlate + "-交强险保单.pdf", licensePlate));
+        crawlerPolicyPrintVo.setSyxPolicyUrl(gainCarInsPolicy(request.getSyxPolicyUrl(), licensePlate + "-商业险保单.pdf", licensePlate));
         return HttpResult.ok(crawlerPolicyPrintVo);
     }
 
+    private String gainCarInsPolicy(String url, String fileName, String licensePlate) {
+        String dir = "carInsPolicy/" + licensePlate + "/";
+        return FileUtil.netUrlToFile(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl);
+    }
+
+
     public QuoteRespVo getQuoteRespVo(CrawlerQuoteResponse response, BaseQuoteInfoVo yaQuoteInfoVo) {
         String orderNo = yaQuoteInfoVo.getOrderNo();
         double jqPremium = response.getForceCarInsureRisk();
@@ -233,10 +260,14 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
         InsAreaCompany insAreaCompany = new InsAreaCompany(quoteRespVo, ptlAgreementAttribution);
         insAreaCompany.setTaxArrears(JSON.parseArray(JSON.toJSONString(quoteRespVo.getTaxArrears())));
 
+        // 此单是否需要验车
+        if (CrawlerQuoteResponse.QuoteGreenWayEnum.Q_1.getCode().equals(response.getOther().getIsQuoteGreenWay())) {
+            quoteRespVo.setTips(CrawlerQuoteResponse.QuoteGreenWayEnum.Q_1.getDesc());
+        }
+
         // 保险公司订单号
         insAreaCompany.setInsOrderNo(response.getOrderNo());
         insAreaCompanyService.insertCompanyAndOrders(insAreaCompany);
-        // 插入轨迹表 报价中
         quoteRespVo.setCompanyId(insAreaCompany.getId());
         return HttpResult.ok("成功", quoteRespVo);
     }