瀏覽代碼

渤海代码修改

wks 2 年之前
父節點
當前提交
25e71b2c3f

+ 16 - 0
src/main/java/com/ydtech/config/LocalDateTimeConfig.java

@@ -1,11 +1,17 @@
 package com.ydtech.config;
 
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
 import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
 import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
 import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 
@@ -45,6 +51,16 @@ public class LocalDateTimeConfig {
         return builder -> {
             builder.serializerByType(LocalDateTime.class, localDateTimeSerializer());
             builder.deserializerByType(LocalDateTime.class, localDateTimeDeserializer());
+            builder.deserializerByType(String.class,
+                    new StdScalarDeserializer<String>(String.class) {
+                        private static final long serialVersionUID = 8744775952505486332L;
+
+                        @Override
+                        public String deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException {
+                            String res = StringUtils.trimWhitespace(jsonParser.getValueAsString());
+                            return StrUtil.isBlank(res) ? null : res;
+                        }
+                    });
         };
     }
 

+ 44 - 0
src/main/java/com/ydtech/config/WebMvcStringTrimAutoConfiguration.java

@@ -0,0 +1,44 @@
+package com.ydtech.config;
+
+
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
+import org.springframework.beans.propertyeditors.StringTrimmerEditor;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.servlet.DispatcherServlet;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.servlet.Servlet;
+import java.io.IOException;
+
+@Configuration
+@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
+@ConditionalOnClass({Servlet.class, DispatcherServlet.class, WebMvcConfigurer.class})
+@AutoConfigureAfter(WebMvcAutoConfiguration.class)
+public class WebMvcStringTrimAutoConfiguration {
+
+    @ControllerAdvice
+    public static class ControllerStringParamTrimConfig {
+
+        @InitBinder
+        public void initBinder(WebDataBinder binder) {
+            // 参数:去除两端空格后 空串是否转换为 null   true:null   false:""
+            StringTrimmerEditor stringTrimmerEditor = new StringTrimmerEditor(true);
+            // 为 String 类对象注册编辑器
+            binder.registerCustomEditor(String.class, stringTrimmerEditor);
+        }
+    }
+
+}

+ 4 - 0
src/main/java/com/ydtech/modules/order/entity/api/bohai/response/ElectronicPolicyResponse.java

@@ -29,5 +29,9 @@ public class ElectronicPolicyResponse extends BoHaiBaseResponse {
         @JsonProperty("businessEPolicyUrl")
         private String businessEPolicyUrl;
 
+        // 非车保单
+        @JsonProperty("acciEPolicyUrl")
+        private String acciEPolicyUrl;
+
     }
 }

+ 9 - 1
src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java

@@ -20,7 +20,6 @@ import com.ydtech.modules.order.entity.api.bohai.response.*;
 import com.ydtech.modules.order.entity.config.BoHaiConfigureParameters;
 import com.ydtech.modules.order.entity.crawler.vo.CrawlerPolicyPrintVo;
 import com.ydtech.modules.order.entity.dto.DrivingInsuranceDto;
-import com.ydtech.modules.order.entity.filter.CarModelsFilterUtils;
 import com.ydtech.modules.order.entity.po.InsTaskImagesBase64;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
@@ -258,6 +257,15 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
                     licenseno + "-" + insAreaCompany.getSypolicyno() + "-商业险保单.pdf", licenseno, customerInfoVo.getIdentifyNumber()));
         }
 
+        if (StringUtils.isNotEmpty(data.getAcciEPolicyUrl())) {
+            List<CrawlerPolicyPrintVo.JyxInfoListDTO> jyxInfoListDTOS = new ArrayList<>();
+            CrawlerPolicyPrintVo.JyxInfoListDTO jyxInfoListDTO = new CrawlerPolicyPrintVo.JyxInfoListDTO();
+            jyxInfoListDTO.setJyxPolicyUrl(fileComponents.gainCarInsPolicy(data.getAcciEPolicyUrl(),
+                    licenseno + "-" + insAreaCompany.getSypolicyno() + "-非车险保单.pdf", licenseno, customerInfoVo.getIdentifyNumber()));
+            jyxInfoListDTOS.add(jyxInfoListDTO);
+            crawlerPolicyPrintVo.setJyxInfoList(jyxInfoListDTOS);
+        }
+
         return HttpResult.ok(crawlerPolicyPrintVo);
     }