haungfuli 2 lat temu
rodzic
commit
fb7b1cc46f

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/DriverCarInfoController.java

@@ -58,7 +58,7 @@ public class DriverCarInfoController {
      * 编辑信息
      */
     @PostMapping("/api/editInfo")
-    public String editInfo(@RequestBody HyDriverCarInfo hyDriverCarInfo) {
+    public String editInfo(@RequestBody HyDriverCarInfo hyDriverCarInfo) throws IOException {
         return driverCarInfoService.editInfo(hyDriverCarInfo);
     }
 

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/DriverInfoController.java

@@ -59,7 +59,7 @@ public class DriverInfoController {
      * 编辑信息
      */
     @PostMapping("/api/editInfo")
-    public String editInfo(@RequestBody HyDriverInfo hyDriverInfo) {
+    public String editInfo(@RequestBody HyDriverInfo hyDriverInfo) throws IOException {
         return driverInfoService.editInfo(hyDriverInfo);
     }
 

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/HyOrderTravelPathController.java

@@ -58,7 +58,7 @@ public class HyOrderTravelPathController {
      * @throws Exception
      */
     @PostMapping("/orderPath")
-    public HyOrderTravelPath orderPath(HyOrderTravelPath hyOrderTravelPath) throws Exception {
+    public HyOrderTravelPath orderPath(@RequestBody HyOrderTravelPath hyOrderTravelPath) throws Exception {
         return hyOrderTravelPathService.orderPath(hyOrderTravelPath);
     }
 }

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IDriverCarInfoService.java

@@ -43,7 +43,7 @@ public interface IDriverCarInfoService extends IService<HyDriverCarInfo> {
      * @param hyDriverCarInfo
      * @return
      */
-    String editInfo(HyDriverCarInfo hyDriverCarInfo);
+    String editInfo(HyDriverCarInfo hyDriverCarInfo) throws IOException;
 
     /**
      * 删除货车信息

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IDriverInfoService.java

@@ -42,7 +42,7 @@ public interface IDriverInfoService extends IService<HyDriverInfo> {
      * @param hyDriverInfo
      * @return
      */
-    String editInfo(HyDriverInfo hyDriverInfo);
+    String editInfo(HyDriverInfo hyDriverInfo) throws IOException;
 
     /**
      * 编辑垫付比例

+ 5 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/DriverCarInfoServiceImpl.java

@@ -105,10 +105,14 @@ public class DriverCarInfoServiceImpl extends ServiceImpl<DriverCarInfoMapper, H
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String editInfo(HyDriverCarInfo hyDriverCarInfo) {
+    public String editInfo(HyDriverCarInfo hyDriverCarInfo) throws IOException {
         //信息编辑
         hyDriverCarInfo.setStatus(StatusEnum.IDENTITY_REVIEWED.getName());
         hyDriverCarInfo.setStatusKey(StatusEnum.IDENTITY_REVIEWED.getFlag());
+
+        String token = EntityAnalyse.GetJTToken();
+        hyDriverCarInfo.setToken(token);
+        EntityAnalyse.uploadDriverCarInfo(hyDriverCarInfo);
         this.updateById(hyDriverCarInfo);
         return "OK";
     }

+ 6 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/DriverInfoServiceImpl.java

@@ -185,11 +185,16 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, HyDrive
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String editInfo(HyDriverInfo hyDriverInfo) {
+    public String editInfo(HyDriverInfo hyDriverInfo) throws IOException {
         hyDriverInfo.setAuthenticationStatusKey(StatusEnum.IDENTITY_REVIEWED.getFlag());
         hyDriverInfo.setAuthenticationStatus(StatusEnum.IDENTITY_REVIEWED.getName());
         hyDriverInfo.setBackStageStatusKey(StatusEnum.TO_BE_REVIEWED.getFlag());
         hyDriverInfo.setBackStageStatus(StatusEnum.TO_BE_REVIEWED.getName());
+
+        String token = EntityAnalyse.GetJTToken();
+        hyDriverInfo.setToken(token);
+        EntityAnalyse.uploadDriverInfo(hyDriverInfo);
+
         //主表信息编辑
         this.updateById(hyDriverInfo);
         //收款人账户信息编辑

+ 39 - 38
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/HyOrderTravelPathServiceImpl.java

@@ -84,10 +84,10 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
     public void login() {
         try {
             Map<String, String> map = new HashMap<String, String>(4);
-            map.put("user", "e8a253b1-12ee-46a4-aebe-58b55df34301");
-            map.put("pwd", "o1v78Rwje3U297j0owa7F2591174d5");
-            map.put("srt", "dfd28720-6c40-4029-8f3f-88e7e0ceec74");
-            map.put("cid", "26f33235-dff0-43d6-871b-9d1682996c12");
+            map.put("user", "ec841c89-4550-4dae-a377-0bda27185932");
+            map.put("pwd", "z6ZJcF32T28EF9Tkn8923uDT42609w");
+            map.put("srt", "762ea319-5f05-4810-aa28-5f92c99485ae");
+            map.put("cid", "871a05fd-a098-49af-9760-27ce9ecf61e3");
             String url = "https://openapi-test.sinoiov.cn/save/apis/login";
             // 设置 http 读写超时
             DataExchangeService des = new DataExchangeService(5000, 8000);
@@ -210,42 +210,43 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
 //                login();
 //                orderPath(hyOrderTravelPath);
 //            }
-        }
-        //获取当前年月日
-        String date = f.format(new Date(System.currentTimeMillis()));
-        map.put("qryEtm", date);
-
-        String url = "https://openapi-test.sinoiov.cn/save/apis/routerPath";
-        // 设置 http 读写超时
-        DataExchangeService des = new DataExchangeService(5000, 8000);
-        System.out.println("请求地址:" + url);
-        // 通过 https 方式调用,此方法内部会使用私钥生成签名参数 sign,私钥不会发送
-        String res = des.postHttps(url, map);
-        if (res.contains("1016")) {
+        }else {
+            //获取当前年月日
+            String date = f.format(new Date(System.currentTimeMillis()));
+            map.put("qryEtm", date);
 
-        }
-        JSONObject jsonObject = JSONObject.parseObject(res);
-        JSONObject jsonData = jsonObject.getJSONObject("result");
-        if (jsonObject.get("status").toString().equals("1001")) {
-            JSONArray jsonArray = jsonData.getJSONArray("trackArray");
-            JSONArray result = new JSONArray();
-            for (int i = 0; i < jsonArray.size(); i++) {
-                BigDecimal lonResult = jsonArray.getJSONObject(i).getBigDecimal("lon");
-                Double lon = lonResult.doubleValue() / 600000;
-                BigDecimal latResult = jsonArray.getJSONObject(i).getBigDecimal("lat");
-                Double lat = latResult.doubleValue() / 600000;
-                GpsView gpsView = PositionUtil.gps84_To_Gcj02(lon, lat);
-                JSONObject data = new JSONObject();
-                data.put("lon", gpsView.getMgLon());
-                data.put("lat", gpsView.getMgLat());
-                result.add(data);
+            String url = "https://openapi-test.sinoiov.cn/save/apis/routerPath";
+            // 设置 http 读写超时
+            DataExchangeService des = new DataExchangeService(5000, 8000);
+            System.out.println("请求地址:" + url);
+            // 通过 https 方式调用,此方法内部会使用私钥生成签名参数 sign,私钥不会发送
+            String res = des.postHttps(url, map);
+            if (res.contains("1016")) {
+
+            }
+            JSONObject jsonObject = JSONObject.parseObject(res);
+            JSONObject jsonData = jsonObject.getJSONObject("result");
+            if (jsonObject.get("status").toString().equals("1001")) {
+                JSONArray jsonArray = jsonData.getJSONArray("trackArray");
+                JSONArray result = new JSONArray();
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    BigDecimal lonResult = jsonArray.getJSONObject(i).getBigDecimal("lon");
+                    Double lon = lonResult.doubleValue() / 600000;
+                    BigDecimal latResult = jsonArray.getJSONObject(i).getBigDecimal("lat");
+                    Double lat = latResult.doubleValue() / 600000;
+                    GpsView gpsView = PositionUtil.gps84_To_Gcj02(lon, lat);
+                    JSONObject data = new JSONObject();
+                    data.put("lon", gpsView.getMgLon());
+                    data.put("lat", gpsView.getMgLat());
+                    result.add(data);
+                }
+                //返回当前北斗导航轨迹
+                HyOrderTravelPath hyOrderTravelPath2 = new HyOrderTravelPath();
+                hyOrderTravelPath2.setOrderId(hyOrderTravelPath.getOrderId());
+                hyOrderTravelPath2.setType("2");
+                hyOrderTravelPath2.setLongitudeLatitude(result.toJSONString());
+                return hyOrderTravelPath2;
             }
-            //返回当前北斗导航轨迹
-            HyOrderTravelPath hyOrderTravelPath2 = new HyOrderTravelPath();
-            hyOrderTravelPath2.setOrderId(hyOrderTravelPath.getOrderId());
-            hyOrderTravelPath2.setType("2");
-            hyOrderTravelPath2.setLongitudeLatitude(result.toJSONString());
-            return hyOrderTravelPath2;
         }
         HyOrderTravelPath hyOrderTravelPath2 = new HyOrderTravelPath();
         return hyOrderTravelPath2;

+ 54 - 15
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/EntityAnalyse.java

@@ -17,6 +17,7 @@ import org.apache.http.NameValuePair;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.FileEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
@@ -27,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import java.io.*;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLConnection;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.text.DecimalFormat;
@@ -84,18 +86,14 @@ public class EntityAnalyse {
      * @return
      * @throws IOException
      */
-    public static String uploadImage(File image) throws IOException {
+    public static String uploadImage(File image,String token) throws IOException {
         String url = "http://116.182.4.67:50065/platform/file/uploadImage";
         CloseableHttpClient httpClient = HttpClients.createDefault();
         // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
         HttpPost httpPost = new HttpPost(url);
-        JSONObject params = new JSONObject();
-        params.put("image", image);
-
-        httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
+        httpPost.setEntity(new FileEntity(image));
         // 设置header信息
         httpPost.setHeader("Content-type", "application/json");
-        String token = EntityAnalyse.GetJTToken();
         httpPost.setHeader("token", token);
         CloseableHttpResponse response = httpClient.execute(httpPost);
         try {
@@ -111,6 +109,7 @@ public class EntityAnalyse {
             // 释放链接
             response.close();
             httpClient.close();
+            image.delete();
         }
         return "";
     }
@@ -136,11 +135,11 @@ public class EntityAnalyse {
         params.put("qualificationCertificate", hyDriverInfo.getQualificationCertificateNumber());
         params.put("telephone", hyDriverInfo.getDriverPhone());
         params.put("remark", hyDriverInfo.getDriverName() + hyDriverInfo.getDriverPhone());
-        params.put("idCardFrontImg", EntityAnalyse.uploadImage(new File(hyDriverInfo.getCardAddressUrl())));
-        params.put("idCardBackImg", EntityAnalyse.uploadImage(new File(hyDriverInfo.getCardBackAddressUrl())));
-        params.put("driverLicenseFirstSheetImg", EntityAnalyse.uploadImage(new File(hyDriverInfo.getDriverLicenseHomePage())));
-        params.put("driverLicenseSecondSheetImg", EntityAnalyse.uploadImage(new File(hyDriverInfo.getDriverLicenseBackPage())));
-        params.put("transportCertificationImg", EntityAnalyse.uploadImage(new File(hyDriverInfo.getQualificationCertificate())));
+        params.put("idCardFrontImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverInfo.getCardAddressUrl())),hyDriverInfo.getToken()));
+        params.put("idCardBackImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverInfo.getCardBackAddressUrl())),hyDriverInfo.getToken()));
+        params.put("driverLicenseFirstSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverInfo.getDriverLicenseHomePage())),hyDriverInfo.getToken()));
+        params.put("driverLicenseSecondSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverInfo.getDriverLicenseBackPage())),hyDriverInfo.getToken()));
+        params.put("transportCertificationImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverInfo.getQualificationCertificate())),hyDriverInfo.getToken()));
         params.put("idCardValidPeriodTo", hyDriverInfo.getCardValidityDate());
         params.put("transportCertificationValidPeriodTo", hyDriverInfo.getQualificationCertificateValidityDate());
         if ("男".equals(hyDriverInfo.getDriverSex())){
@@ -226,10 +225,10 @@ public class EntityAnalyse {
         }
         params.put("licenseValidPeriodTo", hyDriverCarInfo.getDrivingLicenseValidityDate());
         params.put("transportValidPeriodTo", hyDriverCarInfo.getOperationCertificateValidityDate());
-        params.put("vehicleLicenseFirstSheetImg", EntityAnalyse.uploadImage(new File(hyDriverCarInfo.getDrivingLicenseHomePage())));
-        params.put("vehicleLicenseSecondSheetImg", EntityAnalyse.uploadImage(new File(hyDriverCarInfo.getDrivingLicenseBackPage())));
-        params.put("transportLicenseFirstSheetImg", EntityAnalyse.uploadImage(new File(hyDriverCarInfo.getOperationCertificate())));
-        params.put("vehicleDriverImg", EntityAnalyse.uploadImage(new File(hyDriverCarInfo.getAddressUrl())));
+        params.put("vehicleLicenseFirstSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getDrivingLicenseHomePage())),hyDriverCarInfo.getToken()));
+        params.put("vehicleLicenseSecondSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getDrivingLicenseBackPage())),hyDriverCarInfo.getToken()));
+        params.put("transportLicenseFirstSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getOperationCertificate())),hyDriverCarInfo.getToken()));
+        params.put("vehicleDriverImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getAddressUrl())),hyDriverCarInfo.getToken()));
 
         httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
         // 设置header信息
@@ -866,4 +865,44 @@ public class EntityAnalyse {
         br.close();
         return sb.toString();
     }
+    /**
+     * url资源转化为file流
+     * @param url
+     * @return
+     */
+    public static File urlToFile(URL url) {
+        InputStream is = null;
+        File file = null;
+        FileOutputStream fos = null;
+        try {
+            String tmp = "templates" + File.separator + "tmp.jpg";
+            file = new File( new String(tmp.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8));
+//            file = File.createTempFile("tmp", null);
+            URLConnection urlConn = null;
+            urlConn = url.openConnection();
+            is = urlConn.getInputStream();
+            fos = new FileOutputStream(file);
+            byte[] buffer = new byte[4096];
+            int length;
+            while ((length = is.read(buffer)) > 0) {
+                fos.write(buffer, 0, length);
+            }
+            return file;
+        } catch (IOException e) {
+            return null;
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+    }
 }

+ 2 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/PublishTaskInfoMapper.xml

@@ -64,6 +64,8 @@
         p.sender_phone as senderPhone,
         p.receiver,
         p.receiver_phone as receiverPhone,
+        p.receiver_idcard as receiverIdcard,
+        p.receiver_credit_code as receiverCreditCode,
         p.weight,
         p.loading_date_start as loadingDateStart,
         p.loading_date_end as loadingDateEnd,