|
@@ -3,29 +3,33 @@ 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.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.view.ConfigDO;
|
|
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.HyCommonSysParameter;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverCarInfo;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.view.DistinguishView;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.view.DistinguishView;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.ICommonSysParameterService;
|
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.NameValuePair;
|
|
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.HttpPost;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
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 java.io.BufferedReader;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.io.InputStreamReader;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
-import java.text.DateFormat;
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.text.DecimalFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -33,7 +37,230 @@ import java.util.Map;
|
|
|
|
|
|
public class EntityAnalyse {
|
|
public class EntityAnalyse {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ public static ICommonSysParameterService commonSysParameterService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取交投系统token
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public static String GetJTToken() throws IOException {
|
|
|
|
+ String pwd = DigestUtils.sha1Hex("Ccj841968545");
|
|
|
|
+ String url = "http://116.182.4.67:50065/platform/login/login";
|
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("loginAccount", "18241771147");
|
|
|
|
+ params.put("loginPwd", pwd);
|
|
|
|
+ httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
|
|
|
|
+ // 设置header信息
|
|
|
|
+ httpPost.setHeader("Content-type", "application/json");
|
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+ try {
|
|
|
|
+ // 执行请求操作,并拿到结果(同步阻塞)
|
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
+ if(jsonObject.getString("status").equals("1001")){
|
|
|
|
+ String token = jsonObject.getJSONObject("result").getString("token");
|
|
|
|
+ System.out.println("token = " + token);
|
|
|
|
+ return token;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ // 释放链接
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传文件
|
|
|
|
+ * @param image
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public static String uploadImage(File image) 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));
|
|
|
|
+ // 设置header信息
|
|
|
|
+ httpPost.setHeader("Content-type", "application/json");
|
|
|
|
+ String token = EntityAnalyse.GetJTToken();
|
|
|
|
+ httpPost.setHeader("token", token);
|
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+ try {
|
|
|
|
+ // 执行请求操作,并拿到结果(同步阻塞)
|
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
+ String result = jsonObject.getString("result");
|
|
|
|
+ System.out.println("result = " + result);
|
|
|
|
+ return result;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ // 释放链接
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上报驾驶员信息
|
|
|
|
+ * @param hyDriverInfo
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public static String uploadDriverInfo(HyDriverInfo hyDriverInfo) throws IOException {
|
|
|
|
+ String url = "http://116.182.4.67:50065/platform/api/v1/driver";
|
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("driverName", hyDriverInfo.getDriverName());
|
|
|
|
+ params.put("drivingLicense", hyDriverInfo.getNumberCard());
|
|
|
|
+ params.put("vehicleClass", hyDriverInfo.getQuasiDrivingVehicle());
|
|
|
|
+ params.put("issuingOrganizations", hyDriverInfo.getLssuingAuthority());
|
|
|
|
+ params.put("validPeriodFrom", hyDriverInfo.getDriverLicenseValidityStartDate());
|
|
|
|
+ params.put("validPeriodTo", hyDriverInfo.getDriverLicenseValidityDate());
|
|
|
|
+ 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("idCardValidPeriodTo", hyDriverInfo.getCardValidityDate());
|
|
|
|
+ params.put("transportCertificationValidPeriodTo", hyDriverInfo.getQualificationCertificateValidityDate());
|
|
|
|
+ if ("男".equals(hyDriverInfo.getDriverSex())){
|
|
|
|
+ params.put("driverSex", "1");
|
|
|
|
+ }else {
|
|
|
|
+ params.put("driverSex", "2");
|
|
|
|
+ }
|
|
|
|
+ params.put("driverBirthday", hyDriverInfo.getDriverBirthday());
|
|
|
|
+ httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
|
|
|
|
+ // 设置header信息
|
|
|
|
+ httpPost.setHeader("Content-type", "application/json");
|
|
|
|
+ httpPost.setHeader("token", hyDriverInfo.getToken());
|
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+ try {
|
|
|
|
+ // 执行请求操作,并拿到结果(同步阻塞)
|
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
+ String result = jsonObject.getString("result");
|
|
|
|
+ System.out.println("result = " + result);
|
|
|
|
+ return result;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ // 释放链接
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上报车辆信息
|
|
|
|
+ * @param hyDriverCarInfo
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public static String uploadDriverCarInfo(HyDriverCarInfo hyDriverCarInfo) throws IOException {
|
|
|
|
+ String url = "http://116.182.4.67:50065/platform/api/v1//vehicle";
|
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("vehicleNumber", hyDriverCarInfo.getCarNumber());
|
|
|
|
+ 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("owner", hyDriverCarInfo.getOwner());
|
|
|
|
+ params.put("useCharacter", hyDriverCarInfo.getUseNature());
|
|
|
|
+ params.put("vin", hyDriverCarInfo.getCarCode());
|
|
|
|
+ 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("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");
|
|
|
|
+ }
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ params.put("roadTransportCertificateNumber", hyDriverCarInfo.getOperationCertificateNumber());
|
|
|
|
+ if (hyDriverCarInfo.getGuaCarNumber() != null){
|
|
|
|
+ params.put("trailerVehiclePlateNumber", hyDriverCarInfo.getGuaCarNumber());
|
|
|
|
+ }
|
|
|
|
+ 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())));
|
|
|
|
+
|
|
|
|
+ httpPost.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));
|
|
|
|
+ // 设置header信息
|
|
|
|
+ httpPost.setHeader("Content-type", "application/json");
|
|
|
|
+ httpPost.setHeader("token", hyDriverCarInfo.getToken());
|
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+ try {
|
|
|
|
+ // 执行请求操作,并拿到结果(同步阻塞)
|
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
+ String result = jsonObject.getString("result");
|
|
|
|
+ System.out.println("result = " + result);
|
|
|
|
+ return result;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ // 释放链接
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 银行卡识别
|
|
|
|
+ * @param bankImg
|
|
|
|
+ * @return
|
|
|
|
+ * @throws ServiceException
|
|
|
|
+ */
|
|
public static DistinguishView bankShibie(String bankImg) throws ServiceException {
|
|
public static DistinguishView bankShibie(String bankImg) throws ServiceException {
|
|
|
|
+
|
|
String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
|
|
String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
|
|
String host = "https://api06.aliyun.venuscn.com";
|
|
String host = "https://api06.aliyun.venuscn.com";
|
|
String path = "/ocr/bank-card";
|
|
String path = "/ocr/bank-card";
|
|
@@ -169,6 +396,7 @@ public class EntityAnalyse {
|
|
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("出生日期"));
|
|
}
|
|
}
|
|
else if("2".equals(flag))
|
|
else if("2".equals(flag))
|
|
{
|
|
{
|
|
@@ -336,6 +564,8 @@ public class EntityAnalyse {
|
|
String t3 = t.substring(6,8);
|
|
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.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 s3 = s.substring(6,13);
|