|
@@ -28,6 +28,10 @@ import org.apache.http.ssl.SSLContexts;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -37,10 +41,6 @@ import javax.crypto.spec.SecretKeySpec;
|
|
|
import javax.net.ssl.SSLContext;
|
|
|
import javax.net.ssl.TrustManager;
|
|
|
import javax.net.ssl.X509TrustManager;
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.InputStream;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.security.cert.X509Certificate;
|
|
@@ -126,10 +126,16 @@ public class UplodeUtil {
|
|
|
driverUtil.setDriverLicenseIssueOrganization(hyDriverInfo.getLssuingAuthority());
|
|
|
driverUtil.setIdCardIssueOrganization("");
|
|
|
driverUtil.setQualificationNumber(hyDriverInfo.getQualificationCertificateNumber());
|
|
|
- driverUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
- driverUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
- driverUtil.setLicenseFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getDriverLicenseHomePage().getBytes()), "驾驶证主页.jpeg"));
|
|
|
- driverUtil.setQualificationLicenceMainFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getQualificationCertificate().getBytes()), "从业资格证主页.jpeg"));
|
|
|
+ driverUtil.setIdCardFrontFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardAddressUrl(),"testImg.png")), "身份证正面照.jpeg"));
|
|
|
+ driverUtil.setIdCardBackFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardBackAddressUrl(),"testImg.png")), "身份证背面照.jpeg"));
|
|
|
+ driverUtil.setLicenseFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getDriverLicenseHomePage(),"testImg.png")), "驾驶证主页.jpeg"));
|
|
|
+ driverUtil.setQualificationLicenceMainFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getQualificationCertificate(),"testImg.png")), "从业资格证主页.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(hyDriverInfo.getQualificationCertificate(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
driverUtil.setQualificationLicenceSideFilename("");
|
|
|
String driverJson = JSON.toJSONString(driverUtil);
|
|
|
|
|
@@ -150,9 +156,15 @@ public class UplodeUtil {
|
|
|
driverCarUtil.setCarLicensePlate(hyDriverCarInfo.getCarNumber());
|
|
|
driverCarUtil.setOwner(hyDriverCarInfo.getOwner());
|
|
|
driverCarUtil.setIdentifyCode(hyDriverCarInfo.getCarCode());
|
|
|
- driverCarUtil.setDrivingLicenseMainFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverCarInfo.getDrivingLicenseHomePage().getBytes()), "行驶证主页.jpeg"));
|
|
|
- driverCarUtil.setDrivingLicenseSideFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverCarInfo.getDrivingLicenseBackPage().getBytes()), "行驶证其它页.jpeg"));
|
|
|
- driverCarUtil.setTransportLicenseMainFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverCarInfo.getOperationCertificate().getBytes()), "运输许可证主页.jpeg"));
|
|
|
+ driverCarUtil.setDrivingLicenseMainFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverCarInfo.getDrivingLicenseHomePage(),"testImg.png")), "行驶证主页.jpeg"));
|
|
|
+ driverCarUtil.setDrivingLicenseSideFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverCarInfo.getDrivingLicenseBackPage(),"testImg.png")), "行驶证其它页.jpeg"));
|
|
|
+ driverCarUtil.setTransportLicenseMainFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverCarInfo.getOperationCertificate(),"testImg.png")), "运输许可证主页.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(hyDriverCarInfo.getOperationCertificate(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
driverCarUtil.setTransportLicenseSideFilename("");
|
|
|
if (hyDriverCarInfo.getVehicleType()!=null){
|
|
|
HyCommonSysParameter hyCommonSysParameter = uplodeUtil.commonSysParameterService.selectOne(new EntityWrapper<HyCommonSysParameter>()
|
|
@@ -231,9 +243,15 @@ public class UplodeUtil {
|
|
|
customerUtil.setLegalName(hyCompanyInfo.getLegalPersonName());
|
|
|
customerUtil.setPhone(hyCompanyInfo.getPhone());
|
|
|
customerUtil.setIdCard(hyCompanyInfo.getCardNumber());
|
|
|
- customerUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyCompanyInfo.getCardAddressUrl().getBytes()), "身份证正面.jpeg"));
|
|
|
- customerUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyCompanyInfo.getCardBackAddressUrl().getBytes()), "身份证反面.jpeg"));
|
|
|
- customerUtil.setBusinessLicenseFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyCompanyInfo.getBusinessLicenseAddressUrl().getBytes()), "营业执照.jpeg"));
|
|
|
+ customerUtil.setIdCardFrontFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyCompanyInfo.getCardAddressUrl(),"testImg.png")), "身份证正面.jpeg"));
|
|
|
+ customerUtil.setIdCardBackFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyCompanyInfo.getCardBackAddressUrl(),"testImg.png")), "身份证反面.jpeg"));
|
|
|
+ customerUtil.setBusinessLicenseFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyCompanyInfo.getBusinessLicenseAddressUrl(),"testImg.png")), "营业执照.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(hyCompanyInfo.getBusinessLicenseAddressUrl(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
List<Map<String,String>> table=UplodeUtil.addressResolution(hyCompanyInfo.getMailingAddress());
|
|
|
customerUtil.setProvinceName(table.get(0).get("province"));
|
|
|
customerUtil.setCityName(table.get(0).get("city"));
|
|
@@ -358,8 +376,8 @@ public class UplodeUtil {
|
|
|
if((jsonObject.getJSONArray("data")).size()==0) {
|
|
|
carrierUtil.setName(carCaptainInfo.getName());
|
|
|
carrierUtil.setPhone(orderInfo.getContactPersonPhone());
|
|
|
- carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
- carrierUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
+ carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(carCaptainInfo.getCardAddressUrl(),"testImg.png")), "身份证正面照.jpeg"));
|
|
|
+ carrierUtil.setIdCardBackFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(carCaptainInfo.getCardBackAddressUrl(),"testImg.png")), "身份证背面照.jpeg"));
|
|
|
//身份证起始日期
|
|
|
String startDate = formatter1.format(carCaptainInfo.getCardValidityStartDate());
|
|
|
//身份证截止日期
|
|
@@ -375,7 +393,13 @@ public class UplodeUtil {
|
|
|
carrierUtil.setBankCardNumber(orderInfo.getBankCard());
|
|
|
carrierUtil.setBranch(orderInfo.getBankDepositBranch());
|
|
|
carrierUtil.setLegalName("");
|
|
|
- carrierUtil.setTransportBusinessLicenseFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getRoadTransportOperationLicense().getBytes()), "道路运输许可证.jpeg"));
|
|
|
+ carrierUtil.setTransportBusinessLicenseFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(carCaptainInfo.getRoadTransportOperationLicense(),"testImg.png")), "道路运输许可证.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(carCaptainInfo.getRoadTransportOperationLicense(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
carrierUtil.setTransportBusinessLicenseOtherFilename("");
|
|
|
carrierUtil.setTransportBusinessLicense(carCaptainInfo.getRoadTransportOperationLicenseNo());
|
|
|
carrierUtil.setBusinessHouseholdsName("");
|
|
@@ -398,8 +422,14 @@ public class UplodeUtil {
|
|
|
if((jsonObject.getJSONArray("data")).size()==0) {
|
|
|
carrierUtil.setName(hyDriverInfo.getDriverName());
|
|
|
carrierUtil.setPhone(orderInfo.getDriverPhone());
|
|
|
- carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
- carrierUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
+ carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardAddressUrl(),"testImg.png")), "身份证正面照.jpeg"));
|
|
|
+ carrierUtil.setIdCardBackFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardBackAddressUrl(),"testImg.png")), "身份证背面照.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardBackAddressUrl(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
DistinguishView distinguishView = UplodeUtil.personShibie(hyDriverInfo.getCardBackAddressUrl(), "2");
|
|
|
String time = distinguishView.getIdCardValidity().substring(0, distinguishView.getIdCardValidity().indexOf('-'));
|
|
|
Date date1 = formatter2.parse(time);
|
|
@@ -458,8 +488,8 @@ public class UplodeUtil {
|
|
|
if((jsonObject.getJSONArray("data")).size()==0) {
|
|
|
realUtil.setRealName(carCaptainInfo.getName());
|
|
|
realUtil.setIdCard(carCaptainInfo.getIdCard());
|
|
|
- realUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
- realUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
+ realUtil.setIdCardFrontFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(carCaptainInfo.getCardAddressUrl(),"testImg.png")), "身份证正面照.jpeg"));
|
|
|
+ realUtil.setIdCardBackFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(carCaptainInfo.getCardBackAddressUrl(),"testImg.png")), "身份证背面照.jpeg"));
|
|
|
//身份证起始日期
|
|
|
String startDate = formatter1.format(carCaptainInfo.getCardValidityStartDate());
|
|
|
//身份证截止日期
|
|
@@ -473,7 +503,13 @@ public class UplodeUtil {
|
|
|
// realUtil.setGender();
|
|
|
// realUtil.setBirthday("");
|
|
|
// realUtil.setIdCardIssueOrganization(orderInfo.getBankDeposit());
|
|
|
- realUtil.setSelfImageFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getSelfPhoto().getBytes()), "自拍照片.jpeg"));
|
|
|
+ realUtil.setSelfImageFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(carCaptainInfo.getSelfPhoto(),"testImg.png")), "自拍照片.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(carCaptainInfo.getSelfPhoto(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
realJson = JSON.toJSONString(realUtil);
|
|
|
|
|
|
result = postJson("realName/submit", realJson);
|
|
@@ -495,8 +531,8 @@ public class UplodeUtil {
|
|
|
if((jsonObject.getJSONArray("data")).size()==0) {
|
|
|
realUtil.setRealName(hyDriverInfo.getDriverName());
|
|
|
realUtil.setIdCard(hyDriverInfo.getNumberCard());
|
|
|
- realUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
- realUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
+ realUtil.setIdCardFrontFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardAddressUrl(),"testImg.png")), "身份证正面照.jpeg"));
|
|
|
+ realUtil.setIdCardBackFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getCardBackAddressUrl(),"testImg.png")), "身份证背面照.jpeg"));
|
|
|
DistinguishView distinguishView = UplodeUtil.personShibie(hyDriverInfo.getCardBackAddressUrl(), "2");
|
|
|
String time = distinguishView.getIdCardValidity().substring(0, distinguishView.getIdCardValidity().indexOf('-'));
|
|
|
Date date1 = formatter2.parse(time);
|
|
@@ -512,7 +548,13 @@ public class UplodeUtil {
|
|
|
// realUtil.setGender();
|
|
|
// realUtil.setBirthday("");
|
|
|
// realUtil.setIdCardIssueOrganization(orderInfo.getBankDeposit());
|
|
|
- realUtil.setSelfImageFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getSelfPhoto().getBytes()), "自拍照片.jpeg"));
|
|
|
+ realUtil.setSelfImageFilename(UplodeUtil.postFile(getFileInputStream(UplodeUtil.downLoadByUrl(hyDriverInfo.getSelfPhoto(),"testImg.png")), "自拍照片.jpeg"));
|
|
|
+ File file = new File(UplodeUtil.downLoadByUrl(hyDriverInfo.getSelfPhoto(),"testImg.png"));
|
|
|
+ // 路径为文件且不为空则进行删除
|
|
|
+ if (file.isFile() && file.exists())
|
|
|
+ {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
realJson = JSON.toJSONString(realUtil);
|
|
|
|
|
|
result = postJson("realName/submit", realJson);
|
|
@@ -756,10 +798,62 @@ public class UplodeUtil {
|
|
|
return HttpClients.custom().setSSLSocketFactory(factory).build();
|
|
|
}
|
|
|
|
|
|
- public static InputStream getFileInputStream() throws Exception {
|
|
|
+ /**
|
|
|
+ * 从网络Url中下载文件
|
|
|
+ * @param urlStr
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public static String downLoadByUrl(String urlStr,String fileName) throws IOException {
|
|
|
+ URL url = new URL(urlStr);
|
|
|
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
|
|
+ //设置超时间为3秒
|
|
|
+ conn.setConnectTimeout(5*1000);
|
|
|
+ //防止屏蔽程序抓取而返回403错误
|
|
|
+ conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
|
+ //得到输入流
|
|
|
+ InputStream inputStream = conn.getInputStream();
|
|
|
+ //获取自己数组
|
|
|
+ byte[] getData = readInputStream(inputStream);
|
|
|
+ //获取项目根目录地址
|
|
|
+ String propertiesFile = System.getProperty("user.dir");
|
|
|
+ //文件保存位置
|
|
|
+ File saveDir = new File(propertiesFile);
|
|
|
+ if(!saveDir.exists()){
|
|
|
+ saveDir.mkdir();
|
|
|
+ }
|
|
|
+ File file = new File(saveDir+ File.separator+fileName);
|
|
|
+ FileOutputStream fos = new FileOutputStream(file);
|
|
|
+ fos.write(getData);
|
|
|
+ if(fos!=null){
|
|
|
+ fos.close();
|
|
|
+ }
|
|
|
+ if(inputStream!=null){
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ return propertiesFile+"/"+fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从输入流中获取字节数组
|
|
|
+ * @param inputStream
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public static byte[] readInputStream(InputStream inputStream) throws IOException {
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int len = 0;
|
|
|
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
+ while((len = inputStream.read(buffer)) != -1) {
|
|
|
+ bos.write(buffer, 0, len);
|
|
|
+ }
|
|
|
+ bos.close();
|
|
|
+ return bos.toByteArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static InputStream getFileInputStream(String url) throws Exception {
|
|
|
|
|
|
// 本地文件
|
|
|
- File f = new File("/Users/little/Desktop/wecom-temp-fc587837dbaccc339ef249d2765f3749.jpg");
|
|
|
+ File f = new File(url);
|
|
|
return new FileInputStream(f);
|
|
|
|
|
|
// 网络文件
|