|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 上报运单信息
|
|
|
*
|