Sfoglia il codice sorgente

1. 永诚影像修改。

ligang134 3 anni fa
parent
commit
dbecc13760

+ 0 - 30
src/main/java/com/ydtech/modules/ins/controller/InsAlltrustApiController.java

@@ -55,12 +55,6 @@ public class InsAlltrustApiController {
     @Autowired
     EsmInsAttachInsureDetailsMapper esmInsAttachInsureDetailsMapper;
 
-    @ApiOperation(value = "车型查询", notes = "只需要vin码、发动机号、注册日期例:20120512")
-    @PostMapping("/modelQuery")
-    public HttpResult modelQueryAPI(@RequestBody CarModel_Req carModelReq) {
-
-        return insYongchengApiService.modelsQueryApi(carModelReq);
-    }
 
     @ApiResponses({
             @ApiResponse(code = 500, message = "出现异常"),
@@ -90,13 +84,6 @@ public class InsAlltrustApiController {
     }
 
 
-//    @ApiOperation(value = "永诚API方式 - 获取支付链接")
-//    @PostMapping("/getPayUrl")
-//    public HttpResult getPayUrl(@RequestSingleParam(value = "companyId") String companyId) {
-//        return insYongchengApiService.getPayUrlApi(companyId);
-//    }
-
-
     @ApiOperation(value = "永诚API方式 - 补传回调及订单信息查询接口")
     @PostMapping("/callbackAnOrder")
     public HttpResult callbackAnOrder(@RequestSingleParam(value = "companyId") String companyId) {
@@ -122,10 +109,8 @@ public class InsAlltrustApiController {
             }
         }
 
-
         return HttpResult.error("失败");
 
-
     }
 
     /*
@@ -202,20 +187,5 @@ public class InsAlltrustApiController {
     }
 
 
-//    /**
-//     * 测试获取redis
-//     * @
-//     */
-//    @ApiOperation(value = "测试获取redis")
-//    @GetMapping("/testRedis")
-//    public HttpResult testRedis() {
-//        log.info("this is a info log");
-//        log.warn("this is a warn log");
-//        log.error("this is a error log");
-//        log.debug("ddddddddddddddd");
-//        return HttpResult.ok(RedisUtils.exists("aaa"));
-//
-//    }
-
 
 }

+ 31 - 16
src/main/java/com/ydtech/modules/ins/model/yc/imageUp/ImageUp.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.ins.model.yc.imageUp;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.ydtech.components.InsAlltrustRequestApiComponents;
+import com.ydtech.constants.InsuranceImageEnum;
 import com.ydtech.modules.ins.model.yc.AuthorityDataXml;
 import com.ydtech.modules.ins.model.yc.YcConfigureParameters;
 import com.ydtech.modules.order.entity.InsOrders;
@@ -118,23 +119,37 @@ public class ImageUp {
         rb.setOprCde(ycConfigureParameters.getSalesmanNo());
 
         String fileName = "";
-        //C01车辆影像,C02车主身份证,C03投保人身份证,C04被保人身份证,C05验车照
-        if (StringUtils.isNotEmpty(imgType) && imgType.equals("C01")) {
-            fileName = "车辆影像" + ".jpg";
-            rb.setImgtype("UW01008");
-        } else if (StringUtils.isNotEmpty(imgType) && imgType.equals("C02")) {
-            fileName = "车主身份证" + ".jpg";
-            rb.setImgtype("UW01008");
-        } else if (StringUtils.isNotEmpty(imgType) && imgType.equals("C03")) {
-            fileName = "投保人身份证" + ".jpg";
-            rb.setImgtype("UW01008");
-        } else if (StringUtils.isNotEmpty(imgType) && imgType.equals("C04")) {
-            fileName = "被保人身份证" + ".jpg";
-            rb.setImgtype("UW01008");
-        } else if (StringUtils.isNotEmpty(imgType) && imgType.equals("C05")) {
-            fileName = "验车照" + ".jpg";
-            rb.setImgtype("UW01016");
+
+        if(StringUtils.isNotEmpty(imgType)){
+            //行驶证
+            if (imgType.equals(InsuranceImageEnum.C01.getCode())) {
+                fileName = "行驶证" + "(正面)" + ".jpg";
+                rb.setImgtype("UW01007");
+            }else if (imgType.equals(InsuranceImageEnum.D01.getCode())) {
+                fileName = "行驶证" + "(反面)" + ".jpg";
+                rb.setImgtype("UW01007");
+            }else if (imgType.equals(InsuranceImageEnum.C02.getCode())) {
+                fileName = "车主身份证" + "(正面)" + ".jpg";
+                rb.setImgtype("UW01008");
+            }else if (imgType.equals(InsuranceImageEnum.D02.getCode())) {
+                fileName = "车主身份证" + "(反面)" + ".jpg";
+                rb.setImgtype("UW01008");
+            }else if (imgType.equals(InsuranceImageEnum.C03.getCode())) {
+                fileName = "投保人身份证" + "(正面)" + ".jpg";
+                rb.setImgtype("UW01008");
+            }else if (imgType.equals(InsuranceImageEnum.D03.getCode())) {
+                fileName = "投保人身份证" + "(反面)" + ".jpg";
+                rb.setImgtype("UW01008");
+            }else if (imgType.equals(InsuranceImageEnum.C04.getCode())) {
+                fileName = "被保人身份证" + "(正面)" + ".jpg";
+                rb.setImgtype("UW01008");
+            }else if (imgType.equals(InsuranceImageEnum.D04.getCode())) {
+                fileName = "被保人身份证" + "(反面)" + ".jpg";
+                rb.setImgtype("UW01008");
+            }
+
         }
+
         rb.setPicTureName(fileName);
 
 

+ 0 - 10
src/main/java/com/ydtech/modules/ins/service/InsAlltrustApiService.java

@@ -1,7 +1,6 @@
 package com.ydtech.modules.ins.service;
 
 import com.ydtech.core.page.HttpResult;
-import com.ydtech.modules.ins.model.ya.CarModelDTO;
 import com.ydtech.modules.ins.model.ya.CarModel_Req;
 import com.ydtech.modules.ins.model.yc.CallBackRequest;
 import com.ydtech.modules.ins.model.yc.modelsQuery.ModelsQueryResponse;
@@ -17,15 +16,6 @@ public interface InsAlltrustApiService {
 
     //=================API 方式=================
 
-    /**
-     * 1 车型查询接口
-     */
-    HttpResult modelsQueryApi(CarModel_Req carModelReq);
-    /**
-     * 车型查询接口
-     */
-    List<ModelsQueryResponse.VehicleInfo> modelsQuery(CarModel_Req carModelReq);
-//    List<CarModelDTO> modelsQuery(CarModel_Req carModelReq);
 
     /**
      * 2 报价

+ 49 - 110
src/main/java/com/ydtech/modules/ins/service/impl/InsAlltrustApiServiceImpl.java

@@ -184,65 +184,6 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
     //==============================API 方式
     //
 
-    /**
-     * 1 车型查询接口
-     */
-    @Override
-    public HttpResult modelsQueryApi(CarModel_Req carModelReq) {
-
-//        if (org.springframework.util.StringUtils.isEmpty(carModelReq.getFrameNo()) || org.springframework.util.StringUtils.isEmpty(carModelReq.getEnrollDate()) || org.springframework.util.StringUtils.isEmpty(carModelReq.getModelName())) {
-//            return HttpResult.error("frameNo, enrollDate, modelName 这些参数不能为空!");
-//        }
-
-
-//        gainAuthorityDataXml(), apiComponents.gainAgent()
-
-
-        // 获取协议配置信息
-        YcConfigureParameters ycConfigureParameters = gainYcConfigParams(carModelReq.getAgreementId());
-
-
-        ModelsQueryXml m = buildModelsQueryParam(carModelReq, ycConfigureParameters);
-        ObjectMapper xmlMapper = this.gainXmlMapper();
-
-        log.info("===永诚--车型查询接口请求开始===");
-        InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
-        String responseData = apiLog.getResponseData();
-        log.info("===永诚--车型查询接口请求结束===");
-        try {
-            String cleanStr = YcBuildData.cleanResponseStr(responseData);
-            ModelsQueryResponse rd = xmlMapper.readValue(cleanStr, ModelsQueryResponse.class);
-            if (rd.getReturnCode().equals("E0001")) {
-                return HttpResult.ok(rd.getMsg());
-            }
-            return HttpResult.ok(buildCarModel(rd));
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    @Override
-    public List<ModelsQueryResponse.VehicleInfo> modelsQuery(CarModel_Req carModelReq) {
-//    public List<CarModelDTO> modelsQuery(CarModel_Req carModelReq) {
-        // 获取协议配置信息
-        YcConfigureParameters ycConfigureParameters = gainYcConfigParams(carModelReq.getAgreementId());
-
-
-        ModelsQueryXml m = buildModelsQueryParam(carModelReq, ycConfigureParameters);
-        ObjectMapper xmlMapper = this.gainXmlMapper();
-
-        log.info("===永诚--车型查询接口请求开始===");
-        InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
-        String responseData = apiLog.getResponseData();
-        log.info("===永诚--车型查询接口请求结束===");
-        try {
-            String cleanStr = YcBuildData.cleanResponseStr(responseData);
-            ModelsQueryResponse rd = xmlMapper.readValue(cleanStr, ModelsQueryResponse.class);
-            return buildCarModel(rd);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
 
 
     public void gainVehicleModel(YcConfigureParameters ycConfigureParameters, CarInfoVo carInfo) {
@@ -257,8 +198,9 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
         ObjectMapper xmlMapper = this.gainXmlMapper();
 
         log.info("===永诚--车型查询接口请求开始--" + carInfo.getLicenseNo() + "===");
-        InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
-        String responseData = apiLog.getResponseData();
+//        InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
+        String responseData = httpPostResultLog(xmlMapper, m, YcBuildData.API_MODEL,"永诚API方式 - 车型查询 - ");
+//        String responseData = apiLog.getResponseData();
         log.info("===永诚--车型查询接口请求结束--" + carInfo.getLicenseNo() + "===");
         ModelsQueryResponse rd = null;
         try {
@@ -335,8 +277,10 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
 
         BaseQuoteInfoVo yaQuoteInfoVo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo());
 
+        CarInfoVo carInfo = yaQuoteInfoVo.getCarInfo();
+
         //构造车辆信息
-        gainVehicleModel(ycConfigureParameters, yaQuoteInfoVo.getCarInfo());
+        gainVehicleModel(ycConfigureParameters, carInfo);
 
 
         HttpResult httpResult = new HttpResult();
@@ -356,21 +300,11 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
         //构造地区
         buildRegion(m);
 
-//        //请求转保处理
-//        if (StringUtils.isNotEmpty(quoteVo.getRenewalCodeJq()) || StringUtils.isNotEmpty(quoteVo.getRenewalCodeSy())) {
-//            m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(quoteVo.getRenewalCodeJq());
-//            m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY(quoteVo.getRenewalCodeSy());
-//            m.getRequestLabel().getCondition().getVhl().setCBusType("2");
-//            m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(quoteVo.getCQryCdeJq());
-//            m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(quoteVo.getCQryCdeSy());
-//
-//        }
-
         RuoteResponse rr = null;
         boolean boo = false;
         boolean isRenewal = true;
         boolean isBiRepeat = true;
-        String textHead = "==========永城API方式 - 报价 ";
+        String textHead = "==========永诚API方式 - 车架号:"+carInfo.getVinNo()+" - 报价 ";
         while (!boo) {
             rr = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0,textHead);
             //处理返回信息
@@ -680,10 +614,11 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
 
             log.debug("=========永诚API方式 - xml请求 - 核保开始======");
             //接口请求
-            InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_AUDIT);
+//            InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_AUDIT);
+            String responseData = httpPostResultLog(xmlMapper, m, YcBuildData.API_AUDIT,"永诚API方式 - 核保 - ");
             log.debug("=========永诚API方式 - xml请求 - 核保结束!======");
-            verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_1);
-            String responseData = apiLog.getResponseData();
+//            verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_1);
+//            String responseData = apiLog.getResponseData();
 
             String cleanStr = YcBuildData.cleanResponseStr(responseData);
             AuditResponse rd = xmlMapper.readValue(cleanStr, AuditResponse.class);
@@ -766,16 +701,15 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
         insTaskImages.stream().forEach(a -> {
             InsApiLog apiLog = null;
             //组装参数
-            log.debug("=========永诚API方式 - xml请求 - 影像上传开始======");
             //接口请求
             ImageUp iUp = ImageUp.buildImageUpParam(order, ycConfigureParameters, a.getImage(), a.getImgtype());
-            log.debug("=========永诚API方式 - xml请求 - 影像上传结束!======");
             ObjectMapper xmlMapper = gainXmlMapper();
             //接口请求
-            apiLog = httpPost(xmlMapper, iUp, YcBuildData.API_UPLOAD);
+//            apiLog = httpPost(xmlMapper, iUp, YcBuildData.API_UPLOAD);
+            String responseData = httpPostResultLog(xmlMapper, iUp, YcBuildData.API_UPLOAD,"永诚API方式 - 影像上传 - ");
             verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_2);
             try {
-                String responseData = apiLog.getResponseData();
+//                String responseData = apiLog.getResponseData();
                 String cleanStr = YcBuildData.cleanResponseStr(responseData);
                 log.error("===永诚API方式--上传影像清洗返回参数:" + cleanStr);
                 ImageUpResponse iur = xmlMapper.readValue(cleanStr, ImageUpResponse.class);
@@ -807,10 +741,11 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
             ObjectMapper xmlMapper = gainXmlMapper();
             //接口请求
             log.debug("=========永诚API方式 - xml请求 - 获取缴费链接开始======");
-            InsApiLog apiLog = httpPost(xmlMapper, pay, YcBuildData.API_PAY);
+            String responseData = httpPostResultLog(xmlMapper, pay, YcBuildData.API_PAY,"永诚API方式 - 获取缴费链接 - ");
+//            InsApiLog apiLog = httpPost(xmlMapper, pay, YcBuildData.API_PAY);
             log.debug("=========永诚API方式 - xml请求 - 获取缴费链接结束!======");
-            verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_3);
-            String responseData = apiLog.getResponseData();
+//            verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_3);
+//            String responseData = apiLog.getResponseData();
 
 
             String cleanStr = YcBuildData.cleanResponseStr(responseData);
@@ -966,10 +901,12 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
             ObjectMapper xmlMapper = gainXmlMapper();
             //接口请求
             log.debug("=========永诚API方式 - xml请求 - 获取保单开始======");
-            InsApiLog apiLog = httpPost(xmlMapper, p, YcBuildData.API_GUARANTEE_SLIP);
+            String responseData = httpPostResultLog(xmlMapper, p, YcBuildData.API_GUARANTEE_SLIP,"永诚API方式 - 获取保单 - ");
+
+//            InsApiLog apiLog = httpPost(xmlMapper, p, YcBuildData.API_GUARANTEE_SLIP);
             log.debug("=========永诚API方式 - xml请求 - 获取保单结束!======");
-            verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_4);
-            String responseData = apiLog.getResponseData();
+//            verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_4);
+//            String responseData = apiLog.getResponseData();
 
             String cleanStr = YcBuildData.cleanResponseStr(responseData);
             PolicyResponse pResp = xmlMapper.readValue(cleanStr, PolicyResponse.class);
@@ -1026,10 +963,11 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
             ObjectMapper xmlMapper = gainXmlMapper();
             //接口请求
             log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询开始======");
-            InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
+            String responseData = httpPostResultLog(xmlMapper, accident, YcBuildData.API_ACCIDENT,"永诚API方式 - 获取意健险方案及险种 - ");
+//            InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
             log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询结束!======");
 //            verifyRequest(apiLog, iac,InsQuoteFlow.);
-            String responseData = apiLog.getResponseData();
+//            String responseData = apiLog.getResponseData();
 
 
             String cleanStr = YcBuildData.cleanResponseStr(responseData);
@@ -1176,10 +1114,11 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
         ObjectMapper xmlMapper = gainXmlMapper();
         //接口请求
         log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询开始======");
-        InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
+        String responseData = httpPostResultLog(xmlMapper, accident, YcBuildData.API_ACCIDENT,"永诚API方式 - 获取意健险方案及险种 - ");
+//        InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
         log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询结束!======");
 //            verifyRequest(apiLog, iac,InsQuoteFlow.);
-        String responseData = apiLog.getResponseData();
+//        String responseData = apiLog.getResponseData();
 
 
         String cleanStr = YcBuildData.cleanResponseStr(responseData);
@@ -1322,26 +1261,26 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
     }
 
 
-    private <T> InsApiLog httpPost(ObjectMapper mapper, T requestData, String apiName) {
-
-        String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
-        xmlString += "<soapenv:Body>";
-        try {
-            mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
-            xmlString += mapper.writeValueAsString(requestData);
-
-            xmlString += "</soapenv:Body>\n" +
-                    "</soapenv:Envelope>";
-
-        } catch (JsonProcessingException e) {
-            throw new RuntimeException("永诚API方式-xml转换失败");
-        }
-        InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
-//        log.info("永诚API方式 - xml请求 - 参数:" + iplog.getRequestData());
-//        log.info("永诚API方式 - xml请求 ------------分割线----------------");
-//        log.info("永诚API方式 - xml请求 - 响应:" + iplog.getResponseData());
-        return iplog;
-    }
+//    private <T> InsApiLog httpPost(ObjectMapper mapper, T requestData, String apiName) {
+//
+//        String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
+//        xmlString += "<soapenv:Body>";
+//        try {
+//            mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+//            xmlString += mapper.writeValueAsString(requestData);
+//
+//            xmlString += "</soapenv:Body>\n" +
+//                    "</soapenv:Envelope>";
+//
+//        } catch (JsonProcessingException e) {
+//            throw new RuntimeException("永诚API方式-xml转换失败");
+//        }
+//        InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
+////        log.info("永诚API方式 - xml请求 - 参数:" + iplog.getRequestData());
+////        log.info("永诚API方式 - xml请求 ------------分割线----------------");
+////        log.info("永诚API方式 - xml请求 - 响应:" + iplog.getResponseData());
+//        return iplog;
+//    }
 
     /**
      * 日志返回处理

+ 126 - 12
src/main/java/com/ydtech/utils/HttpUtil.java

@@ -5,7 +5,14 @@ import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
 import org.slf4j.Logger;
 
 
@@ -103,7 +110,7 @@ public class HttpUtil {
      * @date: 2023年08月14日 0014
      */
     public static String sendPost(String url,String bodyStr,Logger log,String apiName){
-        log.info(apiName+"请求[post、json、body]参数:"+bodyStr);
+        log.debug(apiName+"请求[post、json、body]参数:"+bodyStr);
         HttpRequest request = HttpRequest.post(url)
                 .header("Content-Type", "application/json")//以json的方式传递
 //     .header("authorization","Bearer abcdefghijklmnopqrstuvwxyz")
@@ -111,7 +118,30 @@ public class HttpUtil {
 
         HttpResponse response = request.execute();
         String respStr = response.body();
-        log.info(apiName+"返回[post、json、body]参数:"+respStr);
+        log.debug(apiName+"返回[post、json、body]参数:"+respStr);
+
+        return respStr;
+    }
+
+
+    /**
+     *   带header和json作为body的post
+     * @param url
+     * @param bodyStr   body传的json
+     * @param params   form传的参数
+     *
+     * @author: lig
+     * @date: 2023年08月14日 0014
+     */
+    public static String sendPost(String url,String bodyStr,Map params){
+        HttpRequest request = HttpRequest.post(url)
+                .header("Content-Type", "application/json")//以json的方式传递
+//     .header("authorization","Bearer abcdefghijklmnopqrstuvwxyz")
+                .body(bodyStr);
+        request.form(params);
+
+        HttpResponse response = request.execute();
+        String respStr = response.body();
 
         return respStr;
     }
@@ -179,23 +209,107 @@ public class HttpUtil {
 
 
     }
+    /**
+     *   post  from
+     * @param url
+     * @param formMap   附件需要传的类型FilePart
+     *
+     * @author: lig
+     * @date: 2023-08-21
+     */
+    public static String sendPostFromFile(Part[] parts,String url){
+        HttpClient httpClient = new HttpClient();
+        PostMethod postMethod = new PostMethod(url);
+//        postMethod.setParameter();
 
-    public static void main(String[] args) {
-        String url = "https://devyun.guorenpcic.com/api/grecar/photo/upload";
-        Map<String, Object> formMap = new HashMap<>();
-        formMap.put("businessNo","2322");
-        formMap.put("operatorCode","32323");
-        formMap.put("comCode","22323");
-        formMap.put("fileGroup","DZ");
+        String response = "";
 
         try {
-            FilePart file1 = new FilePart("file1", new File("D:/Desktop/123.png"));
-            formMap.put("file",file1);
+//            Part[] parts = new Part[]{ new FilePart("file111", file) };
+            postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
+            int statusCode = httpClient.executeMethod(postMethod);
+            if (statusCode == HttpStatus.SC_OK) {
+                response = postMethod.getResponseBodyAsString();
+                System.out.println("Upload successful. Response: " + response);
+                return response;
+            } else {
+                System.out.println("Upload failed. Status code: " + statusCode);
+            }
         } catch (FileNotFoundException e) {
             throw new RuntimeException(e);
+        } catch (HttpException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         }
 
-        sendPostFrom(url,formMap);
+        return response;
+
+
+
+
+    }
+
+//    public static void main(String[] args) {
+//        String url = "https://devyun.guorenpcic.com/api/grecar/photo/upload";
+//        Map<String, Object> formMap = new HashMap<>();
+//        formMap.put("businessNo","2322");
+//        formMap.put("operatorCode","32323");
+//        formMap.put("comCode","22323");
+//        formMap.put("fileGroup","DZ");
+//
+//        try {
+//            FilePart file1 = new FilePart("file1", new File("D:/Desktop/123.png"));
+//            formMap.put("file",file1);
+//        } catch (FileNotFoundException e) {
+//            throw new RuntimeException(e);
+//        }
+//
+//        sendPostFrom(url,formMap);
+//    }
+
+
+    public static void main(String[] args) {
+        HttpClient httpClient = new HttpClient();
+        String url = "https://devyun.guorenpcic.com/api/grecar/photo/upload";
+        PostMethod postMethod = new PostMethod(url);
+        postMethod.getParams().setContentCharset("UTF-8");
+
+//        postMethod.getParams().setParameter("businessNo", "T233075000507000205");
+//        postMethod.getParams().setParameter("operatorCode", "S3000032");
+//        postMethod.getParams().setParameter("comCode", "307500A3");
+//        postMethod.getParams().setParameter("fileGroup", "DZ");
+        ;
+
+
+        File file = new File("D:/upload/image/2023/09/12/f27b4fe4e1fd4f2bfa57b5a560dc792d.jpg");
+
+        try {
+
+//            Part[] parts = { new FilePart("file", file) };
+
+
+            Part[] parts = { new FilePart("file", file)
+                    ,new StringPart("businessNo","T233075000507000205")
+                    ,new StringPart("operatorCode","S3000032")
+                    ,new StringPart("comCode","307500A3")
+                    ,new StringPart("fileGroup","DZ")
+            };
+            postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
+//            postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
+            int statusCode = httpClient.executeMethod(postMethod);
+
+            if (statusCode == HttpStatus.SC_OK) {
+                String response = postMethod.getResponseBodyAsString();
+                System.out.println("Upload successful. Response: " + response);
+            } else {
+                System.out.println("Upload failed. Status code: " + statusCode);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            postMethod.releaseConnection();
+        }
     }
 
 }

+ 1 - 1
src/main/java/com/ydtech/utils/HttpXmlUtil.java

@@ -167,7 +167,7 @@ public class HttpXmlUtil {
     public static String sendXmlPostReq(String url, String xmlString, Logger log,String textHead) {
 
 //        System.out.println("请求参数=" + xmlString);
-        if(null != log) log.debug(textHead + "XML请求url:{},请求参数:{}", url, xmlString);
+        if(null != log) log.debug(textHead + "XML请求url:{},\n请求参数:{}", url, xmlString);
 
         Response response;
         String responseString = null;

+ 2 - 2
src/main/resources/logback-spring.xml

@@ -203,7 +203,7 @@
 
     <!--开发环境:打印控制台-->
     <springProfile name="dev,test,prod">
-        <root level="debug">
+        <root level="info">
             <appender-ref ref="console"/>
             <appender-ref ref="file_console"/>
             <appender-ref ref="file_info"/>
@@ -229,7 +229,7 @@
         <appender-ref ref="custom_alltrust"/>
     </logger>
 
-    <!-- 添加永诚信息 -->
+    <!-- 添加国任信息 -->
     <logger name="guoRen" additivity="false" level="debug">
         <appender-ref ref="custom_guoRen"/>
     </logger>