|
@@ -3,7 +3,6 @@ package com.yh.saas.plugin.yiliangyiyun.util;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.oss.ServiceException;
|
|
import com.aliyun.oss.ServiceException;
|
|
-import com.baomidou.mybatisplus.MybatisSqlSessionTemplate;
|
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.HyCommonSysParameter;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.HyCommonSysParameter;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverCarInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverCarInfo;
|
|
@@ -17,34 +16,34 @@ import org.apache.http.NameValuePair;
|
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
-import org.apache.http.entity.FileEntity;
|
|
|
|
|
|
+import org.apache.http.entity.ContentType;
|
|
import org.apache.http.entity.StringEntity;
|
|
import org.apache.http.entity.StringEntity;
|
|
|
|
+import org.apache.http.entity.mime.HttpMultipartMode;
|
|
|
|
+import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
|
+import org.apache.http.entity.mime.content.FileBody;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
-import java.net.URLConnection;
|
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
public class EntityAnalyse {
|
|
public class EntityAnalyse {
|
|
|
|
|
|
- @Autowired
|
|
|
|
- public static ICommonSysParameterService commonSysParameterService;
|
|
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取交投系统token
|
|
* 获取交投系统token
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
@@ -65,7 +64,7 @@ public class EntityAnalyse {
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
- if(jsonObject.getString("status").equals("1001")){
|
|
|
|
|
|
+ if (jsonObject.getString("status").equals("1001")) {
|
|
String token = jsonObject.getJSONObject("result").getString("token");
|
|
String token = jsonObject.getJSONObject("result").getString("token");
|
|
System.out.println("token = " + token);
|
|
System.out.println("token = " + token);
|
|
return token;
|
|
return token;
|
|
@@ -82,18 +81,34 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件
|
|
* 上传文件
|
|
|
|
+ *
|
|
* @param image
|
|
* @param image
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public static String uploadImage(File image,String token) throws IOException {
|
|
|
|
|
|
+ public static String uploadImage(File image, String token) throws IOException {
|
|
String url = "http://116.182.4.67:50065/platform/file/uploadImage";
|
|
String url = "http://116.182.4.67:50065/platform/file/uploadImage";
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
// 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
// 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
- httpPost.setEntity(new FileEntity(image));
|
|
|
|
|
|
+ // 设置请求头 boundary边界不可重复,重复会导致提交失败
|
|
|
|
+ String boundary = "-------------------------" + UUID.randomUUID().toString();
|
|
|
|
+ httpPost.setHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
|
|
|
|
+ // 创建MultipartEntityBuilder
|
|
|
|
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
|
|
|
+ // 设置字符编码
|
|
|
|
+ builder.setCharset(StandardCharsets.UTF_8);
|
|
|
|
+ // 模拟浏览器
|
|
|
|
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
|
|
|
+ // 设置边界
|
|
|
|
+ builder.setBoundary(boundary);
|
|
|
|
+ // 设置multipart/form-data流文件
|
|
|
|
+ builder.addPart("multipartFile", new FileBody(image));
|
|
|
|
+ // application/octet-stream代表不知道是什么格式的文件
|
|
|
|
+ builder.addBinaryBody("image", image, ContentType.create("application/octet-stream"), "tmp.jpg");
|
|
|
|
+ HttpEntity entity = builder.build();
|
|
|
|
+ httpPost.setEntity(entity);
|
|
// 设置header信息
|
|
// 设置header信息
|
|
- httpPost.setHeader("Content-type", "application/json");
|
|
|
|
httpPost.setHeader("token", token);
|
|
httpPost.setHeader("token", token);
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
try {
|
|
try {
|
|
@@ -116,12 +131,14 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上报驾驶员信息
|
|
* 上报驾驶员信息
|
|
|
|
+ *
|
|
* @param hyDriverInfo
|
|
* @param hyDriverInfo
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public static String uploadDriverInfo(HyDriverInfo hyDriverInfo) throws IOException {
|
|
|
|
|
|
+ public static String uploadDriverInfo(HyDriverInfo hyDriverInfo) throws IOException, ParseException {
|
|
String url = "http://116.182.4.67:50065/platform/api/v1/driver";
|
|
String url = "http://116.182.4.67:50065/platform/api/v1/driver";
|
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
// 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
// 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
@@ -130,25 +147,33 @@ public class EntityAnalyse {
|
|
params.put("drivingLicense", hyDriverInfo.getNumberCard());
|
|
params.put("drivingLicense", hyDriverInfo.getNumberCard());
|
|
params.put("vehicleClass", hyDriverInfo.getQuasiDrivingVehicle());
|
|
params.put("vehicleClass", hyDriverInfo.getQuasiDrivingVehicle());
|
|
params.put("issuingOrganizations", hyDriverInfo.getLssuingAuthority());
|
|
params.put("issuingOrganizations", hyDriverInfo.getLssuingAuthority());
|
|
- params.put("validPeriodFrom", hyDriverInfo.getDriverLicenseValidityStartDate());
|
|
|
|
- params.put("validPeriodTo", hyDriverInfo.getDriverLicenseValidityDate());
|
|
|
|
|
|
+ params.put("validPeriodFrom", f.format(hyDriverInfo.getDriverLicenseValidityStartDate()));
|
|
|
|
+ params.put("validPeriodTo", f.format(hyDriverInfo.getDriverLicenseValidityDate()));
|
|
params.put("qualificationCertificate", hyDriverInfo.getQualificationCertificateNumber());
|
|
params.put("qualificationCertificate", hyDriverInfo.getQualificationCertificateNumber());
|
|
params.put("telephone", hyDriverInfo.getDriverPhone());
|
|
params.put("telephone", hyDriverInfo.getDriverPhone());
|
|
params.put("remark", hyDriverInfo.getDriverName() + hyDriverInfo.getDriverPhone());
|
|
params.put("remark", hyDriverInfo.getDriverName() + hyDriverInfo.getDriverPhone());
|
|
- 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())){
|
|
|
|
- params.put("driverSex", "1");
|
|
|
|
- }else {
|
|
|
|
- params.put("driverSex", "2");
|
|
|
|
|
|
+ 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()));
|
|
|
|
+ if ("长期".equals(hyDriverInfo.getCardValidityDate())) {
|
|
|
|
+ params.put("idCardValidPeriodTo", "2099-12-31");
|
|
|
|
+ } else {
|
|
|
|
+ params.put("idCardValidPeriodTo", hyDriverInfo.getCardValidityDate());
|
|
}
|
|
}
|
|
- params.put("driverBirthday", hyDriverInfo.getDriverBirthday());
|
|
|
|
- httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
|
|
|
|
|
|
+ params.put("transportCertificationValidPeriodTo", f.format(hyDriverInfo.getQualificationCertificateValidityDate()));
|
|
|
|
+ if ("男".equals(hyDriverInfo.getDriverSex())) {
|
|
|
|
+ params.put("driverSex", 1);
|
|
|
|
+ } else {
|
|
|
|
+ params.put("driverSex", 2);
|
|
|
|
+ }
|
|
|
|
+ String s = hyDriverInfo.getDriverBirthday().substring(0, hyDriverInfo.getDriverBirthday().length() - 1);
|
|
|
|
+ String s1 = s.replace("年", "-");
|
|
|
|
+ String s2 = s1.replace("月", "-");
|
|
|
|
+ Date date = f.parse(s2);
|
|
|
|
+ params.put("driverBirthday", f.format(date));
|
|
|
|
+ httpPost.setEntity(new StringEntity("[" + params.toString() + "]", StandardCharsets.UTF_8));
|
|
// 设置header信息
|
|
// 设置header信息
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("token", hyDriverInfo.getToken());
|
|
httpPost.setHeader("token", hyDriverInfo.getToken());
|
|
@@ -172,65 +197,75 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上报车辆信息
|
|
* 上报车辆信息
|
|
|
|
+ *
|
|
* @param hyDriverCarInfo
|
|
* @param hyDriverCarInfo
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
public static String uploadDriverCarInfo(HyDriverCarInfo hyDriverCarInfo) throws IOException {
|
|
public static String uploadDriverCarInfo(HyDriverCarInfo hyDriverCarInfo) throws IOException {
|
|
String url = "http://116.182.4.67:50065/platform/api/v1/vehicle";
|
|
String url = "http://116.182.4.67:50065/platform/api/v1/vehicle";
|
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
// 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
// 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
params.put("vehicleNumber", hyDriverCarInfo.getCarNumber());
|
|
params.put("vehicleNumber", hyDriverCarInfo.getCarNumber());
|
|
- if ("黄色".equals(hyDriverCarInfo.getCarNumberColour())){
|
|
|
|
- params.put("vehiclePlateColorCode", "2");
|
|
|
|
- }else if ("蓝色".equals(hyDriverCarInfo.getCarNumberColour())){
|
|
|
|
- params.put("vehiclePlateColorCode", "1");
|
|
|
|
|
|
+ if ("黄色".equals(hyDriverCarInfo.getCarNumberColour())) {
|
|
|
|
+ params.put("vehiclePlateColorCode", 2);
|
|
|
|
+ } else if ("蓝色".equals(hyDriverCarInfo.getCarNumberColour())) {
|
|
|
|
+ params.put("vehiclePlateColorCode", 1);
|
|
}
|
|
}
|
|
- HyCommonSysParameter hyCommonSysParameter = commonSysParameterService.selectOne(new EntityWrapper<HyCommonSysParameter>()
|
|
|
|
- .eq("const_id","CAR1").eq("const_value",hyDriverCarInfo.getVehicleType()));
|
|
|
|
- params.put("vehicleType", hyCommonSysParameter.getConstKey());
|
|
|
|
|
|
+ params.put("vehicleType", hyDriverCarInfo.getVehicleTypeKey());
|
|
params.put("owner", hyDriverCarInfo.getOwner());
|
|
params.put("owner", hyDriverCarInfo.getOwner());
|
|
params.put("useCharacter", hyDriverCarInfo.getUseNature());
|
|
params.put("useCharacter", hyDriverCarInfo.getUseNature());
|
|
params.put("vin", hyDriverCarInfo.getCarCode());
|
|
params.put("vin", hyDriverCarInfo.getCarCode());
|
|
params.put("issuingOrganizations", hyDriverCarInfo.getLssuingAuthority());
|
|
params.put("issuingOrganizations", hyDriverCarInfo.getLssuingAuthority());
|
|
- params.put("vehicleLength", hyDriverCarInfo.getCarLong());
|
|
|
|
- params.put("vehicleWidth", hyDriverCarInfo.getCarWidth());
|
|
|
|
- params.put("vehicleHeight", hyDriverCarInfo.getCarHeight());
|
|
|
|
- params.put("registerDate", hyDriverCarInfo.getDrivingLicenseRegistrationDate());
|
|
|
|
- params.put("issueDate", hyDriverCarInfo.getDrivingLicenseIssueDate());
|
|
|
|
- if ("汽油".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
|
|
+ params.put("vehicleLength", new Double(hyDriverCarInfo.getCarLong()).intValue());
|
|
|
|
+ params.put("vehicleWidth", new Double(hyDriverCarInfo.getCarWidth()).intValue());
|
|
|
|
+ params.put("vehicleHeight", new Double(hyDriverCarInfo.getCarHeight()).intValue());
|
|
|
|
+ params.put("registerDate", f.format(hyDriverCarInfo.getDrivingLicenseRegistrationDate()));
|
|
|
|
+ params.put("issueDate", f.format(hyDriverCarInfo.getDrivingLicenseIssueDate()));
|
|
|
|
+ if ("汽油".equals(hyDriverCarInfo.getEnergyType())) {
|
|
params.put("vehicleEnergyType", "A");
|
|
params.put("vehicleEnergyType", "A");
|
|
- }else if ("柴油".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
|
|
+ } else if ("柴油".equals(hyDriverCarInfo.getEnergyType())) {
|
|
params.put("vehicleEnergyType", "B");
|
|
params.put("vehicleEnergyType", "B");
|
|
- }else if ("油电混合".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
|
|
+ } else if ("油电混合".equals(hyDriverCarInfo.getEnergyType())) {
|
|
params.put("vehicleEnergyType", "O");
|
|
params.put("vehicleEnergyType", "O");
|
|
- }else if ("纯电动".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
|
|
+ } else if ("纯电动".equals(hyDriverCarInfo.getEnergyType())) {
|
|
params.put("vehicleEnergyType", "C");
|
|
params.put("vehicleEnergyType", "C");
|
|
- }else if ("插电式混合动力".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
|
|
+ } else if ("插电式混合动力".equals(hyDriverCarInfo.getEnergyType())) {
|
|
params.put("vehicleEnergyType", "O");
|
|
params.put("vehicleEnergyType", "O");
|
|
- }else if ("增程式".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
|
|
+ } else if ("增程式".equals(hyDriverCarInfo.getEnergyType())) {
|
|
params.put("vehicleEnergyType", "Z");
|
|
params.put("vehicleEnergyType", "Z");
|
|
}
|
|
}
|
|
- params.put("vehicleTonnage", new DecimalFormat("#.00").format(hyDriverCarInfo.getCarApprovedWeight()*100000));
|
|
|
|
- if ("非挂车".equals(hyDriverCarInfo.getCarCategory())){
|
|
|
|
- params.put("grossMass", new DecimalFormat("#.00").format(hyDriverCarInfo.getCarTotalWeight()*100000));
|
|
|
|
- }else {
|
|
|
|
- params.put("grossMass", new DecimalFormat("#.00").format(hyDriverCarInfo.getServicingWeight()*100000));
|
|
|
|
|
|
+ Double doubleValue = Double.parseDouble(new DecimalFormat("#.00").format(hyDriverCarInfo.getCarApprovedWeight())) / 10;
|
|
|
|
+ int intValue = doubleValue.intValue();
|
|
|
|
+ params.put("vehicleTonnage", intValue);
|
|
|
|
+ if ("非挂车".equals(hyDriverCarInfo.getCarCategory())) {
|
|
|
|
+ Double doubleValue1 = Double.parseDouble(new DecimalFormat("#.00").format(hyDriverCarInfo.getCarTotalWeight())) / 10;
|
|
|
|
+ int intValue1 = doubleValue1.intValue();
|
|
|
|
+ params.put("grossMass", intValue1);
|
|
|
|
+ } else {
|
|
|
|
+ Double doubleValue1 = Double.parseDouble(new DecimalFormat("#.00").format(hyDriverCarInfo.getServicingWeight())) / 10;
|
|
|
|
+ int intValue1 = doubleValue1.intValue();
|
|
|
|
+ params.put("grossMass", intValue1);
|
|
}
|
|
}
|
|
params.put("roadTransportCertificateNumber", hyDriverCarInfo.getOperationCertificateNumber());
|
|
params.put("roadTransportCertificateNumber", hyDriverCarInfo.getOperationCertificateNumber());
|
|
- if (hyDriverCarInfo.getGuaCarNumber() != null){
|
|
|
|
|
|
+ if (hyDriverCarInfo.getGuaCarNumber() != null) {
|
|
params.put("trailerVehiclePlateNumber", hyDriverCarInfo.getGuaCarNumber());
|
|
params.put("trailerVehiclePlateNumber", hyDriverCarInfo.getGuaCarNumber());
|
|
}
|
|
}
|
|
- params.put("licenseValidPeriodTo", hyDriverCarInfo.getDrivingLicenseValidityDate());
|
|
|
|
- params.put("transportValidPeriodTo", hyDriverCarInfo.getOperationCertificateValidityDate());
|
|
|
|
- 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()));
|
|
|
|
|
|
+ if ("长期".equals(hyDriverCarInfo.getDrivingLicenseValidityDate())) {
|
|
|
|
+ params.put("licenseValidPeriodTo", "2099-12-31");
|
|
|
|
+ } else {
|
|
|
|
+ params.put("licenseValidPeriodTo", f.format(hyDriverCarInfo.getDrivingLicenseValidityDate()));
|
|
|
|
+ }
|
|
|
|
+ params.put("transportValidPeriodTo", f.format(hyDriverCarInfo.getOperationCertificateValidityDate()));
|
|
|
|
+ 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));
|
|
|
|
|
|
+ httpPost.setEntity(new StringEntity("[" + params.toString() + "]", StandardCharsets.UTF_8));
|
|
// 设置header信息
|
|
// 设置header信息
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("token", hyDriverCarInfo.getToken());
|
|
httpPost.setHeader("token", hyDriverCarInfo.getToken());
|
|
@@ -254,6 +289,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 驾驶员信息校验结果查询
|
|
* 驾驶员信息校验结果查询
|
|
|
|
+ *
|
|
* @param hyDriverInfo
|
|
* @param hyDriverInfo
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
@@ -265,7 +301,7 @@ public class EntityAnalyse {
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
params.put("drivingLicense", hyDriverInfo.getNumberCard());
|
|
params.put("drivingLicense", hyDriverInfo.getNumberCard());
|
|
- httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
|
|
|
|
|
|
+ httpPost.setEntity(new StringEntity("[" + params.toString() + "]", StandardCharsets.UTF_8));
|
|
// 设置header信息
|
|
// 设置header信息
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("token", hyDriverInfo.getToken());
|
|
httpPost.setHeader("token", hyDriverInfo.getToken());
|
|
@@ -274,20 +310,24 @@ public class EntityAnalyse {
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
- if("异常".equals(jsonObject.getJSONObject("result").getString("validateStatus"))){
|
|
|
|
|
|
+ if ("异常".equals(jsonObject.getJSONObject("result").getString("validateStatus"))) {
|
|
JSONArray jsonArray = jsonObject.getJSONObject("result").getJSONArray("validateResult");
|
|
JSONArray jsonArray = jsonObject.getJSONObject("result").getJSONArray("validateResult");
|
|
String result = "";
|
|
String result = "";
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
- if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))){
|
|
|
|
|
|
+ if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
result = result + jsonArray.getJSONObject(i).getString("message");
|
|
result = result + jsonArray.getJSONObject(i).getString("message");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
System.out.println("result = " + result);
|
|
System.out.println("result = " + result);
|
|
return result;
|
|
return result;
|
|
- }else if ("待校验".equals(jsonObject.getJSONObject("result").getString("validateStatus"))){
|
|
|
|
|
|
+ } else if ("待校验".equals(jsonObject.getJSONObject("result").getString("validateStatus"))) {
|
|
String result = "待校验";
|
|
String result = "待校验";
|
|
System.out.println("result = " + result);
|
|
System.out.println("result = " + result);
|
|
return result;
|
|
return result;
|
|
|
|
+ } else if ("通过".equals(jsonObject.getJSONObject("result").getString("validateStatus"))) {
|
|
|
|
+ String result = jsonObject.getJSONObject("result").getString("validateStatus");
|
|
|
|
+ System.out.println("result = " + result);
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -301,6 +341,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 车辆信息校验结果查询
|
|
* 车辆信息校验结果查询
|
|
|
|
+ *
|
|
* @param hyDriverCarInfo
|
|
* @param hyDriverCarInfo
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
@@ -312,12 +353,12 @@ public class EntityAnalyse {
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
params.put("vehicleNumber", hyDriverCarInfo.getCarNumber());
|
|
params.put("vehicleNumber", hyDriverCarInfo.getCarNumber());
|
|
- if ("黄色".equals(hyDriverCarInfo.getCarNumberColour())){
|
|
|
|
|
|
+ if ("黄色".equals(hyDriverCarInfo.getCarNumberColour())) {
|
|
params.put("vehiclePlateColorCode", "2");
|
|
params.put("vehiclePlateColorCode", "2");
|
|
- }else if ("蓝色".equals(hyDriverCarInfo.getCarNumberColour())){
|
|
|
|
|
|
+ } else if ("蓝色".equals(hyDriverCarInfo.getCarNumberColour())) {
|
|
params.put("vehiclePlateColorCode", "1");
|
|
params.put("vehiclePlateColorCode", "1");
|
|
}
|
|
}
|
|
- httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
|
|
|
|
|
|
+ httpPost.setEntity(new StringEntity("[" + params.toString() + "]", StandardCharsets.UTF_8));
|
|
// 设置header信息
|
|
// 设置header信息
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("Content-type", "application/json");
|
|
httpPost.setHeader("token", hyDriverCarInfo.getToken());
|
|
httpPost.setHeader("token", hyDriverCarInfo.getToken());
|
|
@@ -326,20 +367,24 @@ public class EntityAnalyse {
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
// 执行请求操作,并拿到结果(同步阻塞)
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
- if("异常".equals(jsonObject.getJSONObject("result").getString("validateStatus"))){
|
|
|
|
|
|
+ if ("异常".equals(jsonObject.getJSONObject("result").getString("validateStatus"))) {
|
|
JSONArray jsonArray = jsonObject.getJSONObject("result").getJSONArray("validateResult");
|
|
JSONArray jsonArray = jsonObject.getJSONObject("result").getJSONArray("validateResult");
|
|
String result = "";
|
|
String result = "";
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
- if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))){
|
|
|
|
|
|
+ if ("异常".equals(jsonArray.getJSONObject(i).getString("flag"))) {
|
|
result = result + jsonArray.getJSONObject(i).getString("message");
|
|
result = result + jsonArray.getJSONObject(i).getString("message");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
System.out.println("result = " + result);
|
|
System.out.println("result = " + result);
|
|
return result;
|
|
return result;
|
|
- }else if ("待校验".equals(jsonObject.getJSONObject("result").getString("validateStatus"))){
|
|
|
|
|
|
+ } else if ("待校验".equals(jsonObject.getJSONObject("result").getString("validateStatus"))) {
|
|
String result = "待校验";
|
|
String result = "待校验";
|
|
System.out.println("result = " + result);
|
|
System.out.println("result = " + result);
|
|
return result;
|
|
return result;
|
|
|
|
+ } else if ("通过".equals(jsonObject.getJSONObject("result").getString("validateStatus"))) {
|
|
|
|
+ String result = jsonObject.getJSONObject("result").getString("validateStatus");
|
|
|
|
+ System.out.println("result = " + result);
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -353,6 +398,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 银行卡识别
|
|
* 银行卡识别
|
|
|
|
+ *
|
|
* @param bankImg
|
|
* @param bankImg
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
@@ -376,7 +422,7 @@ public class EntityAnalyse {
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
System.out.println(body);
|
|
System.out.println(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
- if(jsonObject.getString("ret").equals("200")){
|
|
|
|
|
|
+ if (jsonObject.getString("ret").equals("200")) {
|
|
JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
|
|
JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
distinguishView.setBankNo(data.getString("number"));
|
|
distinguishView.setBankNo(data.getString("number"));
|
|
@@ -395,14 +441,14 @@ public class EntityAnalyse {
|
|
body = EntityUtils.toString(response.getEntity());
|
|
body = EntityUtils.toString(response.getEntity());
|
|
System.out.println(body);
|
|
System.out.println(body);
|
|
jsonObject = JSONObject.parseObject(body);
|
|
jsonObject = JSONObject.parseObject(body);
|
|
- if(jsonObject.getString("code").equals("0")){
|
|
|
|
|
|
+ if (jsonObject.getString("code").equals("0")) {
|
|
data = JSONObject.parseObject(jsonObject.getString("data"));
|
|
data = JSONObject.parseObject(jsonObject.getString("data"));
|
|
JSONObject detail = JSONObject.parseObject(data.getString("detail"));
|
|
JSONObject detail = JSONObject.parseObject(data.getString("detail"));
|
|
distinguishView.setBankName(detail.getString("bankName"));
|
|
distinguishView.setBankName(detail.getString("bankName"));
|
|
String[] area = detail.getString("area").split(" - ");
|
|
String[] area = detail.getString("area").split(" - ");
|
|
String province = "";
|
|
String province = "";
|
|
String city = "";
|
|
String city = "";
|
|
- if(area.length > 1){
|
|
|
|
|
|
+ if (area.length > 1) {
|
|
province = area[0];
|
|
province = area[0];
|
|
city = area[1];
|
|
city = area[1];
|
|
}
|
|
}
|
|
@@ -427,10 +473,10 @@ public class EntityAnalyse {
|
|
jsonObject = JSONObject.parseObject(body);
|
|
jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonData = jsonObject.getJSONObject("data");
|
|
JSONObject jsonData = jsonObject.getJSONObject("data");
|
|
JSONObject res = jsonObject.getJSONObject("resp");
|
|
JSONObject res = jsonObject.getJSONObject("resp");
|
|
- if(res.get("RespCode").equals("200")){
|
|
|
|
|
|
+ if (res.get("RespCode").equals("200")) {
|
|
JSONArray jsonArray = jsonData.getJSONArray("record");
|
|
JSONArray jsonArray = jsonData.getJSONArray("record");
|
|
List<String> bankList = new ArrayList<>();
|
|
List<String> bankList = new ArrayList<>();
|
|
- for(int i=0;i<jsonArray.size();i++) {
|
|
|
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
bankList.add(jsonArray.getJSONObject(i).get("lName").toString());
|
|
bankList.add(jsonArray.getJSONObject(i).get("lName").toString());
|
|
}
|
|
}
|
|
distinguishView.setBankNameZhihang(bankList);
|
|
distinguishView.setBankNameZhihang(bankList);
|
|
@@ -443,8 +489,7 @@ public class EntityAnalyse {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return distinguishView;
|
|
return distinguishView;
|
|
- }
|
|
|
|
- else{
|
|
|
|
|
|
+ } else {
|
|
System.out.println(jsonObject.getString("msg"));
|
|
System.out.println(jsonObject.getString("msg"));
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -453,14 +498,14 @@ public class EntityAnalyse {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- public static DistinguishView personShibie(String personImg,String flag) throws ServiceException {
|
|
|
|
|
|
+ public static DistinguishView personShibie(String personImg, String flag) throws ServiceException {
|
|
String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
|
|
String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
|
|
//API产品路径
|
|
//API产品路径
|
|
String requestUrl = "https://personcard.market.alicloudapi.com/ai_market/ai_ocr_universal/shen_fen_zheng/ch/v1";
|
|
String requestUrl = "https://personcard.market.alicloudapi.com/ai_market/ai_ocr_universal/shen_fen_zheng/ch/v1";
|
|
//阿里云APPCODE
|
|
//阿里云APPCODE
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
CloseableHttpClient httpClient = null;
|
|
CloseableHttpClient httpClient = null;
|
|
- try{
|
|
|
|
|
|
+ try {
|
|
httpClient = HttpClients.createDefault();
|
|
httpClient = HttpClients.createDefault();
|
|
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
//启用URL方式进行识别
|
|
//启用URL方式进行识别
|
|
@@ -470,7 +515,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
// 创建一个HttpPost实例
|
|
// 创建一个HttpPost实例
|
|
HttpPost httpPost = new HttpPost(requestUrl);
|
|
HttpPost httpPost = new HttpPost(requestUrl);
|
|
- httpPost.addHeader("Authorization","APPCODE " + appcode);
|
|
|
|
|
|
+ httpPost.addHeader("Authorization", "APPCODE " + appcode);
|
|
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
|
|
|
// 设置请求参数
|
|
// 设置请求参数
|
|
@@ -488,16 +533,13 @@ public class EntityAnalyse {
|
|
String body = EntityUtils.toString(entity);
|
|
String body = EntityUtils.toString(entity);
|
|
System.out.println(body);
|
|
System.out.println(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
- if("1".equals(flag))
|
|
|
|
- {
|
|
|
|
|
|
+ if ("1".equals(flag)) {
|
|
//身份证正面
|
|
//身份证正面
|
|
distinguishView.setRecPerson(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("姓名"));
|
|
distinguishView.setRecPerson(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("姓名"));
|
|
distinguishView.setRecPersonNo(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("身份证号"));
|
|
distinguishView.setRecPersonNo(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("身份证号"));
|
|
distinguishView.setRecPersonAddr(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("住址"));
|
|
distinguishView.setRecPersonAddr(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("住址"));
|
|
distinguishView.setRecPersonBrithday(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("出生日期"));
|
|
distinguishView.setRecPersonBrithday(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("出生日期"));
|
|
- }
|
|
|
|
- else if("2".equals(flag))
|
|
|
|
- {
|
|
|
|
|
|
+ } else if ("2".equals(flag)) {
|
|
//身份证反面
|
|
//身份证反面
|
|
distinguishView.setIdCardValidity(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证国徽面实体信息").getString("有效期限"));
|
|
distinguishView.setIdCardValidity(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证国徽面实体信息").getString("有效期限"));
|
|
}
|
|
}
|
|
@@ -510,6 +552,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 营业执照识别
|
|
* 营业执照识别
|
|
|
|
+ *
|
|
* @param licenseImg
|
|
* @param licenseImg
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
@@ -526,7 +569,7 @@ public class EntityAnalyse {
|
|
//根据API的要求,定义相对应的Content-Type
|
|
//根据API的要求,定义相对应的Content-Type
|
|
headers.put("Content-Type", "application/json; charset=UTF-8");
|
|
headers.put("Content-Type", "application/json; charset=UTF-8");
|
|
Map<String, String> querys = new HashMap<String, String>();
|
|
Map<String, String> querys = new HashMap<String, String>();
|
|
- String bodys = "{\"image\":\""+licenseImg+"\"}";
|
|
|
|
|
|
+ String bodys = "{\"image\":\"" + licenseImg + "\"}";
|
|
//阿里云APPCODE
|
|
//阿里云APPCODE
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
try {
|
|
try {
|
|
@@ -556,6 +599,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 驾驶证识别
|
|
* 驾驶证识别
|
|
|
|
+ *
|
|
* @param image
|
|
* @param image
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
@@ -573,7 +617,7 @@ public class EntityAnalyse {
|
|
headers.put("Content-Type", "application/json; charset=UTF-8");
|
|
headers.put("Content-Type", "application/json; charset=UTF-8");
|
|
Map<String, String> querys = new HashMap<String, String>();
|
|
Map<String, String> querys = new HashMap<String, String>();
|
|
String bodys = "";
|
|
String bodys = "";
|
|
- bodys = "{\"image\":\""+image+"\", \"configure\": {\"side\":\"face\"}}";
|
|
|
|
|
|
+ bodys = "{\"image\":\"" + image + "\", \"configure\": {\"side\":\"face\"}}";
|
|
|
|
|
|
//阿里云APPCODE
|
|
//阿里云APPCODE
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
@@ -593,7 +637,7 @@ public class EntityAnalyse {
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
distinguishView.setDriverEndDate(jsonObject.getString("end_date"));
|
|
distinguishView.setDriverEndDate(jsonObject.getString("end_date"));
|
|
String s = jsonObject.getString("vehicle_type");
|
|
String s = jsonObject.getString("vehicle_type");
|
|
- if (s == "A2" || s == "B2"){
|
|
|
|
|
|
+ if (s == "A2" || s == "B2") {
|
|
distinguishView.setAllowCar(s);
|
|
distinguishView.setAllowCar(s);
|
|
}
|
|
}
|
|
distinguishView.setIssuingAuthority(jsonObject.getString("issue_organization"));
|
|
distinguishView.setIssuingAuthority(jsonObject.getString("issue_organization"));
|
|
@@ -606,11 +650,12 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 行驶证识别
|
|
* 行驶证识别
|
|
|
|
+ *
|
|
* @param image
|
|
* @param image
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
*/
|
|
*/
|
|
- public static DistinguishView driveringLicenseShibie(String image,String flag) throws ServiceException {
|
|
|
|
|
|
+ public static DistinguishView driveringLicenseShibie(String image, String flag) throws ServiceException {
|
|
|
|
|
|
String host = "https://dm-53.data.aliyun.com";
|
|
String host = "https://dm-53.data.aliyun.com";
|
|
String path = "/rest/160601/ocr/ocr_vehicle.json";
|
|
String path = "/rest/160601/ocr/ocr_vehicle.json";
|
|
@@ -624,12 +669,12 @@ public class EntityAnalyse {
|
|
Map<String, String> querys = new HashMap<String, String>();
|
|
Map<String, String> querys = new HashMap<String, String>();
|
|
String bodys = "";
|
|
String bodys = "";
|
|
//正面
|
|
//正面
|
|
- if ("1".equals(flag)){
|
|
|
|
- bodys = "{\"image\":\""+image+"\", \"configure\": {\"side\":\"face\"}}";
|
|
|
|
|
|
+ if ("1".equals(flag)) {
|
|
|
|
+ bodys = "{\"image\":\"" + image + "\", \"configure\": {\"side\":\"face\"}}";
|
|
}
|
|
}
|
|
//反面
|
|
//反面
|
|
else {
|
|
else {
|
|
- bodys = "{\"image\":\""+image+"\", \"configure\": {\"side\":\"back\"}}";
|
|
|
|
|
|
+ bodys = "{\"image\":\"" + image + "\", \"configure\": {\"side\":\"back\"}}";
|
|
}
|
|
}
|
|
|
|
|
|
//阿里云APPCODE
|
|
//阿里云APPCODE
|
|
@@ -648,26 +693,26 @@ public class EntityAnalyse {
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
String body = EntityUtils.toString(response.getEntity());
|
|
System.out.println(body);
|
|
System.out.println(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
- if("1".equals(flag)){
|
|
|
|
|
|
+ if ("1".equals(flag)) {
|
|
distinguishView.setCarNum(jsonObject.getString("plate_num"));
|
|
distinguishView.setCarNum(jsonObject.getString("plate_num"));
|
|
distinguishView.setOwner(jsonObject.getString("owner"));
|
|
distinguishView.setOwner(jsonObject.getString("owner"));
|
|
String s = jsonObject.getString("register_date");
|
|
String s = jsonObject.getString("register_date");
|
|
- String s1 = s.substring(0,4);
|
|
|
|
- String s2 = s.substring(4,6);
|
|
|
|
- String s3 = s.substring(6,8);
|
|
|
|
|
|
+ String s1 = s.substring(0, 4);
|
|
|
|
+ String s2 = s.substring(4, 6);
|
|
|
|
+ String s3 = s.substring(6, 8);
|
|
distinguishView.setLicenseRegistrationDate(s1 + "-" + s2 + "-" + s3);
|
|
distinguishView.setLicenseRegistrationDate(s1 + "-" + s2 + "-" + s3);
|
|
String t = jsonObject.getString("issue_date");
|
|
String t = jsonObject.getString("issue_date");
|
|
- String t1 = t.substring(0,4);
|
|
|
|
- String t2 = t.substring(4,6);
|
|
|
|
- String t3 = t.substring(6,8);
|
|
|
|
|
|
+ String t1 = t.substring(0, 4);
|
|
|
|
+ String t2 = t.substring(4, 6);
|
|
|
|
+ String t3 = t.substring(6, 8);
|
|
distinguishView.setLicenseIssueDate(t1 + "-" + t2 + "-" + t3);
|
|
distinguishView.setLicenseIssueDate(t1 + "-" + t2 + "-" + t3);
|
|
distinguishView.setLssuingAuthority(jsonObject.getString("issue_organization"));
|
|
distinguishView.setLssuingAuthority(jsonObject.getString("issue_organization"));
|
|
distinguishView.setVehicleType(jsonObject.getString("vehicle_type"));
|
|
distinguishView.setVehicleType(jsonObject.getString("vehicle_type"));
|
|
distinguishView.setCarCode(jsonObject.getString("vin"));
|
|
distinguishView.setCarCode(jsonObject.getString("vin"));
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
String s = jsonObject.getString("inspection_record");
|
|
String s = jsonObject.getString("inspection_record");
|
|
- String s3 = s.substring(6,13);
|
|
|
|
- String s1 = s3.replace("年","-");
|
|
|
|
|
|
+ String s3 = s.substring(6, 13);
|
|
|
|
+ String s1 = s3.replace("年", "-");
|
|
distinguishView.setDriveringEndDate(s1 + "-01");
|
|
distinguishView.setDriveringEndDate(s1 + "-01");
|
|
distinguishView.setDriveringNum(jsonObject.getString("file_no"));
|
|
distinguishView.setDriveringNum(jsonObject.getString("file_no"));
|
|
distinguishView.setSize(jsonObject.getString("overall_dimension"));
|
|
distinguishView.setSize(jsonObject.getString("overall_dimension"));
|
|
@@ -684,6 +729,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 道路运输证证识别
|
|
* 道路运输证证识别
|
|
|
|
+ *
|
|
* @param image
|
|
* @param image
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
@@ -722,9 +768,9 @@ public class EntityAnalyse {
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
distinguishView.setTranNumber(jsonObject.getJSONObject("道路运输经营许可证实体信息").getString("道路运输经营许可证编号"));
|
|
distinguishView.setTranNumber(jsonObject.getJSONObject("道路运输经营许可证实体信息").getString("道路运输经营许可证编号"));
|
|
String s = jsonObject.getJSONObject("道路运输经营许可证实体信息").getString("有效期限至");
|
|
String s = jsonObject.getJSONObject("道路运输经营许可证实体信息").getString("有效期限至");
|
|
- String s1 = s.replace("年","-");
|
|
|
|
- String s2 = s1.replace("月","-");
|
|
|
|
- String s3 = s2.replace("日","-");
|
|
|
|
|
|
+ String s1 = s.replace("年", "-");
|
|
|
|
+ String s2 = s1.replace("月", "-");
|
|
|
|
+ String s3 = s2.replace("日", "-");
|
|
distinguishView.setTranEndDate(s3);
|
|
distinguishView.setTranEndDate(s3);
|
|
return distinguishView;
|
|
return distinguishView;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -735,6 +781,7 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 从业资格证识别
|
|
* 从业资格证识别
|
|
|
|
+ *
|
|
* @param image
|
|
* @param image
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
@@ -777,7 +824,7 @@ public class EntityAnalyse {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- if(distinguishView.getQualificationCertificate() == null || distinguishView.getQualificationCertificate().isEmpty()){
|
|
|
|
|
|
+ if (distinguishView.getQualificationCertificate() == null || distinguishView.getQualificationCertificate().isEmpty()) {
|
|
String host1 = "https://dlyzcy.market.alicloudapi.com";
|
|
String host1 = "https://dlyzcy.market.alicloudapi.com";
|
|
String path1 = "/ai_ocr/dao_lu_xin_ban_new/v1";
|
|
String path1 = "/ai_ocr/dao_lu_xin_ban_new/v1";
|
|
Map<String, String> headers1 = new HashMap<String, String>();
|
|
Map<String, String> headers1 = new HashMap<String, String>();
|
|
@@ -812,8 +859,7 @@ public class EntityAnalyse {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else{
|
|
|
|
|
|
+ } else {
|
|
return distinguishView;
|
|
return distinguishView;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
@@ -821,11 +867,12 @@ public class EntityAnalyse {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 银行卡三要素识别
|
|
* 银行卡三要素识别
|
|
|
|
+ *
|
|
* @param
|
|
* @param
|
|
* @return
|
|
* @return
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
*/
|
|
*/
|
|
- public static DistinguishView bankCradShibie(String name,String idCard,String accountNo) throws ServiceException {
|
|
|
|
|
|
+ public static DistinguishView bankCradShibie(String name, String idCard, String accountNo) throws ServiceException {
|
|
|
|
|
|
String host = "https://bcard3and4.market.alicloudapi.com";
|
|
String host = "https://bcard3and4.market.alicloudapi.com";
|
|
String path = "/bank3CheckNew";
|
|
String path = "/bank3CheckNew";
|
|
@@ -833,7 +880,7 @@ public class EntityAnalyse {
|
|
//阿里云APPCODE
|
|
//阿里云APPCODE
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
DistinguishView distinguishView = new DistinguishView();
|
|
try {
|
|
try {
|
|
- String urlSend = host + path + "?idCard=" + idCard + "&name="+ URLEncoder.encode(name, "UTF-8") + "&accountNo="+ accountNo; //
|
|
|
|
|
|
+ String urlSend = host + path + "?idCard=" + idCard + "&name=" + URLEncoder.encode(name, "UTF-8") + "&accountNo=" + accountNo; //
|
|
URL url = new URL(urlSend);
|
|
URL url = new URL(urlSend);
|
|
HttpURLConnection httpURLCon = (HttpURLConnection) url.openConnection();
|
|
HttpURLConnection httpURLCon = (HttpURLConnection) url.openConnection();
|
|
httpURLCon.setRequestProperty("Authorization", "APPCODE " + appcode);// 格式Authorization:APPCODE (中间是英文空格)
|
|
httpURLCon.setRequestProperty("Authorization", "APPCODE " + appcode);// 格式Authorization:APPCODE (中间是英文空格)
|
|
@@ -865,44 +912,110 @@ public class EntityAnalyse {
|
|
br.close();
|
|
br.close();
|
|
return sb.toString();
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* url资源转化为file流
|
|
* url资源转化为file流
|
|
|
|
+ *
|
|
* @param url
|
|
* @param url
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static File urlToFile(URL url) {
|
|
public static File urlToFile(URL url) {
|
|
- InputStream is = null;
|
|
|
|
- File file = null;
|
|
|
|
- FileOutputStream fos = null;
|
|
|
|
|
|
+ return writeImageToDisk(getImageFromNetByUrl(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) {
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 将获取的字节数组保存为文件写入硬盘
|
|
|
|
+ *
|
|
|
|
+ * @param data
|
|
|
|
+ */
|
|
|
|
+ public static File writeImageToDisk(byte[] data) {
|
|
try {
|
|
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);
|
|
|
|
|
|
+ File file = new File("templates" + File.separator + "tmp.jpg"); // 本地目录
|
|
|
|
+ File fileParent = file.getParentFile();
|
|
|
|
+ if (!fileParent.exists()) {
|
|
|
|
+ fileParent.mkdirs();
|
|
|
|
+ file.createNewFile();
|
|
}
|
|
}
|
|
|
|
+ FileOutputStream fops = new FileOutputStream(file);
|
|
|
|
+ fops.write(data);
|
|
|
|
+ fops.flush();
|
|
|
|
+ fops.close();
|
|
return file;
|
|
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) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取远程http地址视图片
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static byte[] getImageFromNetByUrl(URL url) {
|
|
|
|
+ try {
|
|
|
|
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
|
+ conn.setRequestMethod("GET");
|
|
|
|
+ conn.setConnectTimeout(5 * 1000);
|
|
|
|
+ InputStream inStream = conn.getInputStream();
|
|
|
|
+ byte[] btData = readInputStream(inStream);
|
|
|
|
+ return btData;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 读取流
|
|
|
|
+ *
|
|
|
|
+ * @param inStream
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static byte[] readInputStream(InputStream inStream) throws Exception {
|
|
|
|
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
|
+ int len = 0;
|
|
|
|
+ while ((len = inStream.read(buffer)) != -1) {
|
|
|
|
+ outStream.write(buffer, 0, len);
|
|
|
|
+ }
|
|
|
|
+ inStream.close();
|
|
|
|
+ return outStream.toByteArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|