haungfuli 1 год назад
Родитель
Сommit
3c61c82140

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

@@ -299,6 +299,12 @@ public class DriverCarInfoServiceImpl extends ServiceImpl<DriverCarInfoMapper, H
                     HyCommonSysParameter hyCommonSysParameter = commonSysParameterService.selectOne(new EntityWrapper<HyCommonSysParameter>()
                             .eq("const_id", "CAR1").eq("const_value", hyDriverCarInfo1.getVehicleType()));
                     hyDriverCarInfo1.setVehicleTypeKey(hyCommonSysParameter.getConstKey());
+                    if (hyDriverCarInfo1.getTrailerVehicleType() != null && !hyDriverCarInfo1.getTrailerVehicleType().isEmpty()) {
+                        //查询挂车车辆类型key值
+                        HyCommonSysParameter hyCommonSysParameter3 = commonSysParameterService.selectOne(new EntityWrapper<HyCommonSysParameter>()
+                                .eq("const_id", "CAR1").eq("const_value", hyDriverCarInfo1.getTrailerVehicleType()));
+                        hyDriverCarInfo1.setTrailerVehicleTypeKey(hyCommonSysParameter3.getConstKey());
+                    }
                     //园区上报
                     hyDriverCarInfo1.setToken(token);
                     new Thread(new Runnable() {
@@ -322,6 +328,27 @@ public class DriverCarInfoServiceImpl extends ServiceImpl<DriverCarInfoMapper, H
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
+                            if(hyDriverCarInfo1.getTrailerVehicleType() != null && !hyDriverCarInfo1.getTrailerVehicleType().isEmpty()){
+                                //挂车园区上报
+                                try {
+                                    String result = EntityAnalyse.uploadTrailerCarInfo(hyDriverCarInfo1,ENV);
+                                    //发送成功
+                                    if ("1001".equals(result)){
+                                        //更改上报状态
+                                        hyDriverCarInfo1.setEscalationDate(new Date());
+                                        hyDriverCarInfo1.setEscalationStatusKey(StatusEnum.PARK_UNDER_REVIEW.getFlag());
+                                        hyDriverCarInfo1.setEscalationStatus(StatusEnum.PARK_UNDER_REVIEW.getName());
+                                    }else {
+                                        hyDriverCarInfo1.setEscalationDate(new Date());
+                                        hyDriverCarInfo1.setEscalationStatusKey(StatusEnum.FAIL.getFlag());
+                                        hyDriverCarInfo1.setEscalationStatus(StatusEnum.FAIL.getName());
+                                        hyDriverCarInfo1.setEscalationFailureReason(result);
+                                    }
+                                    driverCarInfoService.updateById(hyDriverCarInfo1);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
                         }
                     }).start();
                 }

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

@@ -306,6 +306,94 @@ public class EntityAnalyse {
         }
     }
 
+    /**
+     * 上报挂车信息
+     *
+     * @param hyDriverCarInfo
+     * @return
+     * @throws IOException
+     */
+    public static String uploadTrailerCarInfo(HyDriverCarInfo hyDriverCarInfo, String ENV) throws IOException {
+        String url = "";
+        if ("3".equals(ENV)) {
+            url = "http://116.182.4.67:50033/platform/api/v1/vehicle";
+        } else {
+            url = "http://116.182.4.67:50065/platform/api/v1/vehicle";
+        }
+        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
+        HttpPost httpPost = new HttpPost(url);
+        JSONObject params = new JSONObject();
+        params.put("vehicleNumber", hyDriverCarInfo.getGuaCarNumber());
+        params.put("vehiclePlateColorCode", "2");
+        params.put("vehicleType", hyDriverCarInfo.getTrailerVehicleTypeKey());
+        params.put("owner", hyDriverCarInfo.getGuaOwner());
+        params.put("useCharacter", hyDriverCarInfo.getGuaUseNature());
+        params.put("vin", hyDriverCarInfo.getTrailerCarCode());
+        params.put("issuingOrganizations", hyDriverCarInfo.getGuaLssuingAuthority());
+        params.put("vehicleLength", new Double(hyDriverCarInfo.getGuaCarLong()).intValue());
+        params.put("vehicleWidth", new Double(hyDriverCarInfo.getGuaCarWidth()).intValue());
+        params.put("vehicleHeight", new Double(hyDriverCarInfo.getGuaCarHeight()).intValue());
+        params.put("registerDate", f.format(hyDriverCarInfo.getTrailerLicenseRegistrationDate()));
+        params.put("issueDate", f.format(hyDriverCarInfo.getTrailerLicenseIssueDate()));
+        if ("汽油".equals(hyDriverCarInfo.getEnergyType())) {
+            params.put("vehicleEnergyType", "A");
+        } else if ("柴油".equals(hyDriverCarInfo.getEnergyType())) {
+            params.put("vehicleEnergyType", "B");
+        } else if ("油电混合".equals(hyDriverCarInfo.getEnergyType())) {
+            params.put("vehicleEnergyType", "O");
+        } else if ("纯电动".equals(hyDriverCarInfo.getEnergyType())) {
+            params.put("vehicleEnergyType", "C");
+        } else if ("插电式混合动力".equals(hyDriverCarInfo.getEnergyType())) {
+            params.put("vehicleEnergyType", "O");
+        } else if ("增程式".equals(hyDriverCarInfo.getEnergyType())) {
+            params.put("vehicleEnergyType", "Z");
+        }
+        DecimalFormat df = new DecimalFormat("0");
+        String approvedWeight = df.format(hyDriverCarInfo.getGuaCarApprovedWeight());
+        Double doubleValue = Double.parseDouble(approvedWeight) / 10;
+        int intValue = doubleValue.intValue();
+        params.put("vehicleTonnage", intValue);
+        String totalWeight = df.format(hyDriverCarInfo.getCarTotalWeight());
+        Double doubleValue1 = Double.parseDouble(totalWeight) / 10;
+        int intValue1 = doubleValue1.intValue();
+        params.put("grossMass", intValue1);
+        params.put("roadTransportCertificateNumber", hyDriverCarInfo.getTrailerOperationCertificateNumber());
+        if (hyDriverCarInfo.getGuaCarNumber() != null) {
+            params.put("trailerVehiclePlateNumber", hyDriverCarInfo.getGuaCarNumber());
+        }
+        if ("长期".equals(hyDriverCarInfo.getTrailerLicenseValidityDate())) {
+            params.put("licenseValidPeriodTo", "2099-12-31");
+        } else {
+            params.put("licenseValidPeriodTo", f.format(hyDriverCarInfo.getTrailerLicenseValidityDate()));
+        }
+        params.put("transportValidPeriodTo", f.format(hyDriverCarInfo.getTrailerOperationCertificateValidityDate()));
+        params.put("vehicleLicenseFirstSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getTrailerLicenseHomePage())), hyDriverCarInfo.getToken(), ENV));
+        params.put("vehicleLicenseSecondSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getTrailerLicenseBackPage())), hyDriverCarInfo.getToken(), ENV));
+        params.put("transportLicenseFirstSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getTrailerOperationCertificate())), hyDriverCarInfo.getToken(), ENV));
+        params.put("transportLicenseSecondSheetImg", EntityAnalyse.uploadImage(EntityAnalyse.urlToFile(new URL(hyDriverCarInfo.getTrailerOperationCertificate())), hyDriverCarInfo.getToken(), ENV));
+
+        httpPost.setEntity(new StringEntity("[" + params.toString() + "]", StandardCharsets.UTF_8));
+        // 设置header信息
+        httpPost.setHeader("Content-type", "application/json");
+        httpPost.setHeader("token", hyDriverCarInfo.getToken());
+        CloseableHttpResponse response = null;
+        try {
+            // 执行请求操作,并拿到结果(同步阻塞)
+            String body = EntityUtils.toString(httpClient.execute(httpPost).getEntity());
+            JSONObject jsonObject = JSONObject.parseObject(body);
+            String result = jsonObject.getString("status");
+            System.out.println("result = " + jsonObject);
+            return result;
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            // 释放链接
+            httpClient.close();
+        }
+    }
+
     /**
      * 上报运单信息
      *

+ 3 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/DriverCarInfoMapper.xml

@@ -204,6 +204,9 @@
         c.car_long as carLong,
         c.car_width as carWidth,
         c.car_height as carHeight,
+        c.gua_car_long as guaCarLong,
+        c.gua_car_width as guaCarWidth,
+        c.gua_car_height as guaCarHeight,
         c.car_approved_weight as carApprovedWeight,
         c.car_total_weight as carTotalWeight,
         c.servicing_weight as servicingWeight,