|
@@ -0,0 +1,667 @@
|
|
|
|
+package com.yh.saas.plugin.yiliangyiyun.util;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
|
+import com.aliyun.oss.ServiceException;
|
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.view.DistinguishView;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.view.DriverInfo;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.ICommonSysParameterService;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverInfoService;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IHyCarCaptainInfoService;
|
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
|
+import org.apache.http.NameValuePair;
|
|
|
|
+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.conn.ssl.SSLConnectionSocketFactory;
|
|
|
|
+import org.apache.http.entity.ContentType;
|
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
|
+import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
|
+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 javax.annotation.PostConstruct;
|
|
|
|
+import javax.crypto.Mac;
|
|
|
|
+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;
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@Component
|
|
|
|
+public class UplodeUtil {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonSysParameterService commonSysParameterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IDriverInfoService driverInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHyCarCaptainInfoService carCaptainInfoService;
|
|
|
|
+
|
|
|
|
+ public static UplodeUtil uplodeUtil;
|
|
|
|
+ @PostConstruct
|
|
|
|
+ public void init(){
|
|
|
|
+ uplodeUtil=this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String charSet = "UTF-8";
|
|
|
|
+ private static String appid = "khy21062900750001";
|
|
|
|
+ private static String secret = "638328d345a04f4f9aa8af6b0c79f536";
|
|
|
|
+ private static String baseUrl = "https://tosb-gateway.wlhyos.pre.xiaokuaikeji.com/tosb/";
|
|
|
|
+
|
|
|
|
+// public static void main(String[] args) throws Exception {
|
|
|
|
+// Driver driver = new Driver();
|
|
|
|
+// driver.setName("张三");
|
|
|
|
+// driver.setPhone("13500000000");
|
|
|
|
+// driver.setIdCard("450902193607014875");
|
|
|
|
+// // 身份证照片,先上传然后获取文件名之后再填充
|
|
|
|
+// String idCardFrontFilename = postFile(getFileInputStream(), "身份证.jpeg");
|
|
|
|
+// driver.setIdCardFrontFilename(idCardFrontFilename);
|
|
|
|
+//
|
|
|
|
+// String driverJson = JSON.toJSONString(driver);
|
|
|
|
+//
|
|
|
|
+// String result = postJson("driver/create", driverJson);
|
|
|
|
+//
|
|
|
|
+// System.out.println(result);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 司机信息上报
|
|
|
|
+ * @param hyDriverInfo
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String uploadDriver(HyDriverInfo hyDriverInfo) throws Exception {
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd");
|
|
|
|
+ SimpleDateFormat formatter2 = new SimpleDateFormat( "yyyy.MM.dd");
|
|
|
|
+ SimpleDateFormat formatter1 = new SimpleDateFormat( "yyyy年MM月dd日");
|
|
|
|
+ DriverUtil driverUtil = new DriverUtil();
|
|
|
|
+ driverUtil.setName(hyDriverInfo.getDriverName());
|
|
|
|
+ driverUtil.setPhone(hyDriverInfo.getDriverPhone());
|
|
|
|
+ driverUtil.setIdCard(hyDriverInfo.getNumberCard());
|
|
|
|
+ driverUtil.setAddress(hyDriverInfo.getCardAddress());
|
|
|
|
+ //身份证截止日期
|
|
|
|
+ Date date=formatter.parse(hyDriverInfo.getCardValidityDate());
|
|
|
|
+ String endDate=formatter1.format(date);
|
|
|
|
+// //获取有效期止前二十年
|
|
|
|
+// Calendar calendar = Calendar.getInstance();
|
|
|
|
+// calendar.setTime(date);
|
|
|
|
+// calendar.add(Calendar.YEAR,-20);
|
|
|
|
+// Date newDate=calendar.getTime();
|
|
|
|
+// String startDate=formatter1.format(newDate);
|
|
|
|
+ DistinguishView distinguishView=UplodeUtil.personShibie(hyDriverInfo.getCardBackAddressUrl(),"2");
|
|
|
|
+ String time = distinguishView.getIdCardValidity().substring(0, distinguishView.getIdCardValidity().indexOf('-'));
|
|
|
|
+ Date date2=formatter2.parse(time);
|
|
|
|
+ //身份证起始日期
|
|
|
|
+ String startDate=formatter1.format(date2);
|
|
|
|
+ driverUtil.setIdCardStartDate(formatter1.parse(startDate).getTime());
|
|
|
|
+ driverUtil.setIdCardEndDate(formatter1.parse(endDate).getTime());
|
|
|
|
+ driverUtil.setDriverLicenseNumber(hyDriverInfo.getNumberCard());
|
|
|
|
+ driverUtil.setDriveType(hyDriverInfo.getQuasiDrivingVehicle());
|
|
|
|
+ driverUtil.setDriverLicenseStartDate(hyDriverInfo.getDriverLicenseValidityStartDate().getTime());
|
|
|
|
+ Date date1=formatter.parse(hyDriverInfo.getDriverLicenseValidityDate());
|
|
|
|
+ String now1=formatter1.format(date1);
|
|
|
|
+ driverUtil.setDriverLicenseEndDate(formatter1.parse(now1).getTime());
|
|
|
|
+ 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.setQualificationLicenceSideFilename("");
|
|
|
|
+ String driverJson = JSON.toJSONString(driverUtil);
|
|
|
|
+
|
|
|
|
+ String result = postJson("driver/create", driverJson);
|
|
|
|
+
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 车辆信息上报
|
|
|
|
+ * @param hyDriverCarInfo
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String uploadDriverCar(HyDriverCarInfo hyDriverCarInfo) throws Exception {
|
|
|
|
+ DriverCarUtil driverCarUtil = new DriverCarUtil();
|
|
|
|
+ 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.setTransportLicenseSideFilename("");
|
|
|
|
+ if (hyDriverCarInfo.getVehicleType()!=null){
|
|
|
|
+ HyCommonSysParameter hyCommonSysParameter = uplodeUtil.commonSysParameterService.selectOne(new EntityWrapper<HyCommonSysParameter>()
|
|
|
|
+ .eq("const_id", "CAR1").eq("const_value", hyDriverCarInfo.getVehicleType()));
|
|
|
|
+ if (hyCommonSysParameter!=null) {
|
|
|
|
+ driverCarUtil.setTruckTypeCode(hyCommonSysParameter.getConstKey());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (hyDriverCarInfo.getCarNumberColour()!=null){
|
|
|
|
+ HyCommonSysParameter hyCommonSysParameter = uplodeUtil.commonSysParameterService.selectOne(new EntityWrapper<HyCommonSysParameter>()
|
|
|
|
+ .eq("const_id", "COLOR1").eq("const_value", hyDriverCarInfo.getCarNumberColour()));
|
|
|
|
+ if (hyCommonSysParameter!=null) {
|
|
|
|
+ driverCarUtil.setPlateColor(Integer.valueOf(hyCommonSysParameter.getConstKey()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ("汽油".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
+ driverCarUtil.setEnergyType("A");
|
|
|
|
+ }
|
|
|
|
+ else if ("柴油".equals(hyDriverCarInfo.getEnergyType())){
|
|
|
|
+ driverCarUtil.setEnergyType("B");
|
|
|
|
+ }
|
|
|
|
+ else if (hyDriverCarInfo.getEnergyType().contains("电")){
|
|
|
|
+ driverCarUtil.setEnergyType("C");
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ driverCarUtil.setEnergyType("Z");
|
|
|
|
+ }
|
|
|
|
+ driverCarUtil.setRegisterDate(hyDriverCarInfo.getDrivingLicenseRegistrationDate().getTime());
|
|
|
|
+ driverCarUtil.setExpireDate(hyDriverCarInfo.getDrivingLicenseValidityDate().getTime());
|
|
|
|
+ driverCarUtil.setIssueDate(hyDriverCarInfo.getDrivingLicenseIssueDate().getTime());
|
|
|
|
+ driverCarUtil.setIssueOrganization(hyDriverCarInfo.getLssuingAuthority());
|
|
|
|
+ driverCarUtil.setUseNature(hyDriverCarInfo.getUseNature());
|
|
|
|
+ driverCarUtil.setLoadWeight((int)(hyDriverCarInfo.getCarApprovedWeight()!=null?hyDriverCarInfo.getCarApprovedWeight()*1000:hyDriverCarInfo.getCarTotalWeight()*0.9*1000));
|
|
|
|
+ driverCarUtil.setTotalWeight((int)(hyDriverCarInfo.getCarTotalWeight()*1000));
|
|
|
|
+ driverCarUtil.setFileNumber(hyDriverCarInfo.getDrivingLicenseNumber());
|
|
|
|
+ driverCarUtil.setOutlineDimensionLength((int)Math.round(hyDriverCarInfo.getCarLong()));
|
|
|
|
+ driverCarUtil.setOutlineDimensionWidth((int)Math.round(hyDriverCarInfo.getCarWidth()));
|
|
|
|
+ driverCarUtil.setOutlineDimensionHeight((int)Math.round(hyDriverCarInfo.getCarHeight()));
|
|
|
|
+ driverCarUtil.setTrailerPlateNumber(hyDriverCarInfo.getGuaCarNumber());
|
|
|
|
+ driverCarUtil.setBusinessName(hyDriverCarInfo.getOwner());
|
|
|
|
+ driverCarUtil.setRoadTransportNumber(hyDriverCarInfo.getOperationCertificateNumber());
|
|
|
|
+ driverCarUtil.setRoadTransportPermitNumber(hyDriverCarInfo.getOperationCertificateNumber());
|
|
|
|
+ String driverCarJson = JSON.toJSONString(driverCarUtil);
|
|
|
|
+
|
|
|
|
+ String result = postJson("truck/create", driverCarJson);
|
|
|
|
+
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 流水单上报
|
|
|
|
+ * @param hyFreightSettlementInfo
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String uploadSettlement(HyFreightSettlementInfo hyFreightSettlementInfo) throws Exception {
|
|
|
|
+ SettlementUtil settlementUtil = new SettlementUtil();
|
|
|
|
+ settlementUtil.setName(hyFreightSettlementInfo.getPayeeName());
|
|
|
|
+ settlementUtil.setPhone("");
|
|
|
|
+ settlementUtil.setIdCard(hyFreightSettlementInfo.getPayeeIdCard());
|
|
|
|
+ //默认为1-银行账户
|
|
|
|
+ settlementUtil.setType(1);
|
|
|
|
+ settlementUtil.setBankCardNumber(hyFreightSettlementInfo.getBankCard());
|
|
|
|
+ settlementUtil.setBankDeposit(hyFreightSettlementInfo.getBankDeposit());
|
|
|
|
+ String settlementJson = JSON.toJSONString(settlementUtil);
|
|
|
|
+
|
|
|
|
+ String result = postJson("payee/create", settlementJson);
|
|
|
|
+
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 装卸货SDK
|
|
|
|
+ * @param hyCarrierInfo
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String uploadLoad(HyCarrierInfo hyCarrierInfo) throws Exception {
|
|
|
|
+ LoadUtil loadUtil = new LoadUtil();
|
|
|
|
+ loadUtil.setShippingNoteNumber(hyCarrierInfo.getOrderNo());
|
|
|
|
+ loadUtil.setSerialNumber("0000");
|
|
|
|
+ //装车标识
|
|
|
|
+ if ("1".equals(hyCarrierInfo.getLoadingFlag())){
|
|
|
|
+ loadUtil.setLongitude(hyCarrierInfo.getLoadingLongitude());
|
|
|
|
+ loadUtil.setLatitude(hyCarrierInfo.getLoadingLatitude());
|
|
|
|
+ loadUtil.setType(1);
|
|
|
|
+ }
|
|
|
|
+ //卸车
|
|
|
|
+ else{
|
|
|
|
+ loadUtil.setLongitude(hyCarrierInfo.getUnloadingLongitude());
|
|
|
|
+ loadUtil.setLatitude(hyCarrierInfo.getUnloadingLatitude());
|
|
|
|
+ loadUtil.setType(2);
|
|
|
|
+ }
|
|
|
|
+ loadUtil.setState(3);
|
|
|
|
+ loadUtil.setErrorCode("");
|
|
|
|
+ loadUtil.setErrorMsg("");
|
|
|
|
+ List<LoadUtil> list = new ArrayList<>();
|
|
|
|
+ list.add(loadUtil);
|
|
|
|
+ String loadJson = JSON.toJSONString(list);
|
|
|
|
+
|
|
|
|
+ String result = postJson("transport/bill/loadAndUnloadSdkPosition", loadJson);
|
|
|
|
+
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 承运人上报
|
|
|
|
+ * @param orderInfo
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String uploadCarrier(OrderInfo orderInfo) throws Exception {
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd");
|
|
|
|
+ SimpleDateFormat formatter2 = new SimpleDateFormat( "yyyy.MM.dd");
|
|
|
|
+ SimpleDateFormat formatter1 = new SimpleDateFormat( "yyyy年MM月dd日");
|
|
|
|
+ CarrierUtil carrierUtil = new CarrierUtil();
|
|
|
|
+ //承运人取车队长信息
|
|
|
|
+ if (orderInfo.getCarCaptainCommonId()!=null){
|
|
|
|
+ HyCarCaptainInfo carCaptainInfo=uplodeUtil.carCaptainInfoService.selectOne(new EntityWrapper<HyCarCaptainInfo>()
|
|
|
|
+ .eq("common_id",orderInfo.getCarCaptainCommonId()));
|
|
|
|
+ if (carCaptainInfo!=null){
|
|
|
|
+ carrierUtil.setName(carCaptainInfo.getName());
|
|
|
|
+ carrierUtil.setIdCard(carCaptainInfo.getIdCard());
|
|
|
|
+ carrierUtil.setPhone(orderInfo.getContactPersonPhone());
|
|
|
|
+ carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
|
+ carrierUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
|
+ //身份证起始日期
|
|
|
|
+ String startDate=formatter1.format(carCaptainInfo.getCardValidityStartDate());
|
|
|
|
+ //身份证截止日期
|
|
|
|
+ Date date=formatter.parse(carCaptainInfo.getCardValidityEndDate());
|
|
|
|
+ String endDate=formatter1.format(date);
|
|
|
|
+ carrierUtil.setIdCardBeginTime(formatter1.parse(startDate).getTime());
|
|
|
|
+ carrierUtil.setIdCardEndTime(formatter1.parse(endDate).getTime());
|
|
|
|
+ DistinguishView distinguishView=UplodeUtil.personShibie(carCaptainInfo.getCardAddressUrl(),"1");
|
|
|
|
+ carrierUtil.setAddress(distinguishView.getRecPersonAddr());
|
|
|
|
+ carrierUtil.setType(20);
|
|
|
|
+ carrierUtil.setBusinessLicenseFilename("");
|
|
|
|
+ carrierUtil.setBankDeposit(orderInfo.getBankDeposit());
|
|
|
|
+ carrierUtil.setBankCardNumber(orderInfo.getBankCard());
|
|
|
|
+ carrierUtil.setBranch(orderInfo.getBankDepositBranch());
|
|
|
|
+ carrierUtil.setLegalName("");
|
|
|
|
+ carrierUtil.setTransportBusinessLicenseFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getRoadTransportOperationLicense().getBytes()), "道路运输许可证.jpeg"));
|
|
|
|
+ carrierUtil.setTransportBusinessLicenseOtherFilename("");
|
|
|
|
+ carrierUtil.setTransportBusinessLicense(carCaptainInfo.getRoadTransportOperationLicenseNo());
|
|
|
|
+ carrierUtil.setBusinessHouseholdsName("");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //承运人取司机信息
|
|
|
|
+ else{
|
|
|
|
+ HyDriverInfo hyDriverInfo=uplodeUtil.driverInfoService.selectOne(new EntityWrapper<HyDriverInfo>()
|
|
|
|
+ .eq("common_id",orderInfo.getCommonId()));
|
|
|
|
+ if (hyDriverInfo!=null){
|
|
|
|
+ carrierUtil.setName(hyDriverInfo.getDriverName());
|
|
|
|
+ carrierUtil.setIdCard(hyDriverInfo.getNumberCard());
|
|
|
|
+ carrierUtil.setPhone(orderInfo.getDriverPhone());
|
|
|
|
+ carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
|
|
|
|
+ carrierUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
|
|
|
|
+ DistinguishView distinguishView=UplodeUtil.personShibie(hyDriverInfo.getCardBackAddressUrl(),"2");
|
|
|
|
+ String time = distinguishView.getIdCardValidity().substring(0, distinguishView.getIdCardValidity().indexOf('-'));
|
|
|
|
+ Date date1=formatter2.parse(time);
|
|
|
|
+ //身份证起始日期
|
|
|
|
+ String startDate=formatter1.format(date1);
|
|
|
|
+ //身份证截止日期
|
|
|
|
+ Date date=formatter.parse(hyDriverInfo.getCardValidityDate());
|
|
|
|
+ String endDate=formatter1.format(date);
|
|
|
|
+ carrierUtil.setIdCardBeginTime(formatter1.parse(startDate).getTime());
|
|
|
|
+ carrierUtil.setIdCardEndTime(formatter1.parse(endDate).getTime());
|
|
|
|
+ carrierUtil.setAddress(hyDriverInfo.getCardAddress());
|
|
|
|
+ carrierUtil.setType(20);
|
|
|
|
+ carrierUtil.setBusinessLicenseFilename("");
|
|
|
|
+ carrierUtil.setBankDeposit(orderInfo.getBankDeposit());
|
|
|
|
+ carrierUtil.setBankCardNumber(orderInfo.getBankCard());
|
|
|
|
+ carrierUtil.setBranch(orderInfo.getBankDepositBranch());
|
|
|
|
+ carrierUtil.setLegalName("");
|
|
|
|
+ carrierUtil.setTransportBusinessLicenseFilename("");
|
|
|
|
+ carrierUtil.setTransportBusinessLicenseOtherFilename("");
|
|
|
|
+ carrierUtil.setTransportBusinessLicense(hyDriverInfo.getActualCarrierBusinessLicense());
|
|
|
|
+ carrierUtil.setBusinessHouseholdsName("");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String carrierJson = JSON.toJSONString(carrierUtil);
|
|
|
|
+
|
|
|
|
+ String result = postJson("open_middleman/create", carrierJson);
|
|
|
|
+
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 运单上报
|
|
|
|
+ * @param orderInfo
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String uploadOrder(OrderInfo orderInfo) throws Exception {
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0");
|
|
|
|
+ DecimalFormat df1 = new DecimalFormat("0");
|
|
|
|
+
|
|
|
|
+ OrderUtil orderUtil = new OrderUtil();
|
|
|
|
+ orderUtil.setTransportBillTime(orderInfo.getCreateDate().getTime());
|
|
|
|
+ orderUtil.setLoadingDateTimestamp(orderInfo.getTranStartDate().getTime());
|
|
|
|
+ orderUtil.setUnloadingDateTimestamp(orderInfo.getTranEndDate().getTime());
|
|
|
|
+ orderUtil.setProjectName("");
|
|
|
|
+ orderUtil.setRouteName("");
|
|
|
|
+ orderUtil.setShipperTransportBillNumber(orderInfo.getOrderNo());
|
|
|
|
+ orderUtil.setTransportBusinessType(1003999);
|
|
|
|
+ orderUtil.setInsuranceCompany(orderInfo.getInsuranceCompanyCode());
|
|
|
|
+ orderUtil.setPolicyNumber(orderInfo.getPolicyNo());
|
|
|
|
+ orderUtil.setRemark(orderInfo.getRemark());
|
|
|
|
+
|
|
|
|
+ //货物信息
|
|
|
|
+ JSONObject goodsInfoDTO = new JSONObject();
|
|
|
|
+ goodsInfoDTO.put("goodsName", orderInfo.getGoodsName());
|
|
|
|
+ goodsInfoDTO.put("goodsType", orderInfo.getGoodsTypeKey());
|
|
|
|
+ goodsInfoDTO.put("weight", Integer.valueOf(df.format(orderInfo.getWeight() * 1000000)));
|
|
|
|
+ //todo 体积,件数
|
|
|
|
+ if (orderInfo.getVolume() != null) {
|
|
|
|
+ goodsInfoDTO.put("volume", Integer.valueOf(df1.format(orderInfo.getVolume() * 10000)));
|
|
|
|
+ }
|
|
|
|
+ if (orderInfo.getPackageNumber() != null) {
|
|
|
|
+ goodsInfoDTO.put("number", Integer.valueOf(orderInfo.getPackageNumber()));
|
|
|
|
+ }
|
|
|
|
+ orderUtil.setGoodsInfoDTO(goodsInfoDTO);
|
|
|
|
+
|
|
|
|
+ //托运方信息
|
|
|
|
+ JSONObject shipperInfoDTO = new JSONObject();
|
|
|
|
+ shipperInfoDTO.put("payType", 0);
|
|
|
|
+ shipperInfoDTO.put("shipperName", orderInfo.getConsignorName());
|
|
|
|
+ shipperInfoDTO.put("shipperPhone", orderInfo.getDriverPhone());
|
|
|
|
+ shipperInfoDTO.put("shipperIdCard", orderInfo.getConsignorID());
|
|
|
|
+ shipperInfoDTO.put("shipperTransportCost", orderInfo.getFreight());
|
|
|
|
+ orderUtil.setShipperInfoDTO(shipperInfoDTO);
|
|
|
|
+
|
|
|
|
+ //发货方收货方信息
|
|
|
|
+ JSONObject addressInfoDTO = new JSONObject();
|
|
|
|
+ addressInfoDTO.put("senderName", orderInfo.getCargoOwner());
|
|
|
|
+ addressInfoDTO.put("senderPhone", orderInfo.getCargoOwnerPhone());
|
|
|
|
+ addressInfoDTO.put("senderProvince", orderInfo.getSendPrivate());
|
|
|
|
+ addressInfoDTO.put("senderCity", orderInfo.getSendCity());
|
|
|
|
+ addressInfoDTO.put("senderDistrict", orderInfo.getSendArea());
|
|
|
|
+ addressInfoDTO.put("senderLocation", orderInfo.getSendDetailedAddress());
|
|
|
|
+ addressInfoDTO.put("senderLng", orderInfo.getSendLongitude());
|
|
|
|
+ addressInfoDTO.put("senderLat", orderInfo.getSendLatitude());
|
|
|
|
+ addressInfoDTO.put("receiverName", orderInfo.getShipToName());
|
|
|
|
+ addressInfoDTO.put("receiverPhone", "");
|
|
|
|
+ addressInfoDTO.put("receiverProvince", orderInfo.getUnloadPrivate());
|
|
|
|
+ addressInfoDTO.put("receiverCity", orderInfo.getUnloadCity());
|
|
|
|
+ addressInfoDTO.put("receiverDistrict", orderInfo.getUnloadArea());
|
|
|
|
+ addressInfoDTO.put("receiverLocation", orderInfo.getUnloadDetailedAddress());
|
|
|
|
+ addressInfoDTO.put("treceiverLng", orderInfo.getUnsendLongitude());
|
|
|
|
+ addressInfoDTO.put("treceiverLat", orderInfo.getUnsendLatitude());
|
|
|
|
+ orderUtil.setAddressInfoDTO(addressInfoDTO);
|
|
|
|
+
|
|
|
|
+ //承运方信息
|
|
|
|
+ JSONObject carrierInfoDTO = new JSONObject();
|
|
|
|
+ carrierInfoDTO.put("carrierName", orderInfo.getDriverName());
|
|
|
|
+ carrierInfoDTO.put("carrierPhone", orderInfo.getDriverPhone());
|
|
|
|
+ carrierInfoDTO.put("driverName", orderInfo.getDriverName());
|
|
|
|
+ carrierInfoDTO.put("driverPhone", orderInfo.getDriverPhone());
|
|
|
|
+ if (orderInfo.getCommonId()!=null){
|
|
|
|
+ HyDriverInfo hyDriverInfo=uplodeUtil.driverInfoService.selectOne(new EntityWrapper<HyDriverInfo>()
|
|
|
|
+ .eq("common_id",orderInfo.getCommonId()));
|
|
|
|
+ if (hyDriverInfo!=null){
|
|
|
|
+ carrierInfoDTO.put("driverIdCard", hyDriverInfo.getNumberCard());
|
|
|
|
+ carrierInfoDTO.put("carrierIdCard", orderInfo.getSendPrivate());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ carrierInfoDTO.put("carLicensePlate", orderInfo.getCarNumber());
|
|
|
|
+ carrierInfoDTO.put("carrierTransportCost", orderInfo.getFreight());
|
|
|
|
+ carrierInfoDTO.put("oilCardPayment", 0);
|
|
|
|
+ carrierInfoDTO.put("prePayment", orderInfo.getAdvanceCharge());
|
|
|
|
+ carrierInfoDTO.put("arrivePayment",0);
|
|
|
|
+ carrierInfoDTO.put("receiptPayment", 0);
|
|
|
|
+ carrierInfoDTO.put("informationPayment", 0);
|
|
|
|
+ carrierInfoDTO.put("bankAccountName", orderInfo.getPayeeName());
|
|
|
|
+ carrierInfoDTO.put("bankCardNumber", orderInfo.getBankCard());
|
|
|
|
+ carrierInfoDTO.put("bankDeposit", orderInfo.getBankDeposit());
|
|
|
|
+ carrierInfoDTO.put("payeeIdCard", orderInfo.getPayeeIdCard());
|
|
|
|
+ carrierInfoDTO.put("bankCardNumberType", 1);
|
|
|
|
+ carrierInfoDTO.put("informationPaymentBankAccountName","");
|
|
|
|
+ carrierInfoDTO.put("informationPaymentBankCardNumber", "");
|
|
|
|
+ carrierInfoDTO.put("informationPaymentBankDeposit", "");
|
|
|
|
+ carrierInfoDTO.put("informationPaymentPayeeIdCard", "");
|
|
|
|
+ carrierInfoDTO.put("informationPaymentBankCardNumberType", 1);
|
|
|
|
+ orderUtil.setCarrierInfoDTO(carrierInfoDTO);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String orderJson = JSON.toJSONString(orderUtil);
|
|
|
|
+
|
|
|
|
+ String result = postJson("transport/bill/add", orderJson);
|
|
|
|
+
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 上传json数据
|
|
|
|
+ *
|
|
|
|
+ * @param method
|
|
|
|
+ * @param jsonStr
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String postJson(String method, String jsonStr) throws Exception {
|
|
|
|
+ CloseableHttpClient sslClient = sslClient();
|
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
|
+ try {
|
|
|
|
+ HttpPost httpPost = new HttpPost(baseUrl + method);
|
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
|
+ httpPost.setHeader("appid", appid);
|
|
|
|
+ httpPost.setHeader("sign", getHmacSign(jsonStr, secret));
|
|
|
|
+
|
|
|
|
+ StringEntity se = new StringEntity(jsonStr, "UTF-8");
|
|
|
|
+ httpPost.setEntity(se);
|
|
|
|
+
|
|
|
|
+ response = sslClient.execute(httpPost);
|
|
|
|
+ if (response != null) {
|
|
|
|
+ HttpEntity resEntity = response.getEntity();
|
|
|
|
+ if (resEntity != null) {
|
|
|
|
+ return EntityUtils.toString(resEntity, charSet);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ throw new RuntimeException(ex);
|
|
|
|
+ } finally {
|
|
|
|
+ if (sslClient != null) {
|
|
|
|
+ sslClient.close();
|
|
|
|
+ }
|
|
|
|
+ if (response != null) {
|
|
|
|
+ response.close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传文件
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static String postFile(InputStream fileInputStream, String uploadFilename) throws Exception{
|
|
|
|
+ HttpPost httpPost = new HttpPost("https://tosb-gateway.wlhyos.pre.xiaokuaikeji.com/tosb/file/uploadFile");
|
|
|
|
+ CloseableHttpClient httpClient = sslClient();
|
|
|
|
+
|
|
|
|
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
|
|
|
+ httpPost.addHeader("appid", appid);
|
|
|
|
+ httpPost.addHeader("sign", getHmacSign("{}", secret));
|
|
|
|
+
|
|
|
|
+ builder.addBinaryBody("file", fileInputStream, ContentType.MULTIPART_FORM_DATA, uploadFilename);
|
|
|
|
+ HttpEntity multipart = builder.build();
|
|
|
|
+ httpPost.setEntity(multipart);
|
|
|
|
+
|
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+
|
|
|
|
+ String returnStr = EntityUtils.toString(response.getEntity(), "utf-8");
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+
|
|
|
|
+ Result<String> result = JSON.parseObject(returnStr, new TypeReference<Result<String>>() {
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (!result.getCode().equals("00000")) {
|
|
|
|
+ throw new RuntimeException("上传失败, 结果:" + returnStr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result.getData();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static CloseableHttpClient sslClient() {
|
|
|
|
+ SSLContext ctx = SSLContexts.createDefault();
|
|
|
|
+ X509TrustManager tm = new X509TrustManager() {
|
|
|
|
+ @Override
|
|
|
|
+ public X509Certificate[] getAcceptedIssuers() {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void checkClientTrusted(X509Certificate[] xcs, String str) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void checkServerTrusted(X509Certificate[] xcs, String str) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ try {
|
|
|
|
+ ctx.init(null, new TrustManager[]{tm}, new SecureRandom());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(ctx);
|
|
|
|
+ return HttpClients.custom().setSSLSocketFactory(factory).build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static InputStream getFileInputStream() throws Exception {
|
|
|
|
+
|
|
|
|
+ // 本地文件
|
|
|
|
+ File f = new File("/Users/little/Desktop/wecom-temp-fc587837dbaccc339ef249d2765f3749.jpg");
|
|
|
|
+ return new FileInputStream(f);
|
|
|
|
+
|
|
|
|
+ // 网络文件
|
|
|
|
+ /*
|
|
|
|
+ HttpClient client = HttpClients.createDefault();
|
|
|
|
+ HttpGet httpget = new HttpGet("url");
|
|
|
|
+ HttpResponse response = client.execute(httpget);
|
|
|
|
+
|
|
|
|
+ HttpEntity entity = response.getEntity();
|
|
|
|
+
|
|
|
|
+ return entity.getContent();*/
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 数据签名
|
|
|
|
+ *
|
|
|
|
+ * @param content
|
|
|
|
+ * @param secret
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private static String getHmacSign(String content, String secret){
|
|
|
|
+ byte[] result = null;
|
|
|
|
+ try {
|
|
|
|
+ SecretKeySpec signinKey = new SecretKeySpec(secret.getBytes(), "HmacSHA1");
|
|
|
|
+ Mac mac = Mac.getInstance("HmacSHA1");
|
|
|
|
+ mac.init(signinKey);
|
|
|
|
+ byte[] rawHmac;
|
|
|
|
+ rawHmac = mac.doFinal(content.getBytes(StandardCharsets.UTF_8));
|
|
|
|
+ result = Base64.getEncoder().encode(rawHmac);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ if (null != result) {
|
|
|
|
+ return new String(result);
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static DistinguishView personShibie(String personImg,String flag) throws ServiceException {
|
|
|
|
+ String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
|
|
|
|
+ //API产品路径
|
|
|
|
+ String requestUrl = "https://personcard.market.alicloudapi.com/ai_market/ai_ocr_universal/shen_fen_zheng/ch/v1";
|
|
|
|
+ //阿里云APPCODE
|
|
|
|
+ CloseableHttpClient httpClient = null;
|
|
|
|
+ DistinguishView distinguishView=new DistinguishView();
|
|
|
|
+ try {
|
|
|
|
+ httpClient = HttpClients.createDefault();
|
|
|
|
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
|
+ //启用URL方式进行识别
|
|
|
|
+ //内容数据类型是图像文件URL链接
|
|
|
|
+ params.add(new BasicNameValuePair("IMAGE", personImg));
|
|
|
|
+ params.add(new BasicNameValuePair("IMAGE_TYPE", "1"));
|
|
|
|
+
|
|
|
|
+ // 创建一个HttpPost实例
|
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl);
|
|
|
|
+ httpPost.addHeader("Authorization", "APPCODE " + appcode);
|
|
|
|
+ httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
|
+
|
|
|
|
+ // 设置请求参数
|
|
|
|
+ httpPost.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
|
|
|
|
+
|
|
|
|
+ // 发送POST请求
|
|
|
|
+ HttpResponse execute = httpClient.execute(httpPost);
|
|
|
|
+
|
|
|
|
+ // 获取状态码
|
|
|
|
+ int statusCode = execute.getStatusLine().getStatusCode();
|
|
|
|
+ System.out.println(statusCode);
|
|
|
|
+
|
|
|
|
+ // 获取结果
|
|
|
|
+ HttpEntity entity = execute.getEntity();
|
|
|
|
+ String body = EntityUtils.toString(entity);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
+ if ("1".equals(flag)) {
|
|
|
|
+ //身份证正面
|
|
|
|
+ distinguishView.setRecPersonAddr(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("住址"));
|
|
|
|
+ } else if ("2".equals(flag)) {
|
|
|
|
+ //身份证反面
|
|
|
|
+ distinguishView.setIdCardValidity(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证国徽面实体信息").getString("有效期限"));
|
|
|
|
+ }
|
|
|
|
+ return distinguishView;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 接口返回结果
|
|
|
|
+ *
|
|
|
|
+ * @param <T>
|
|
|
|
+ */
|
|
|
|
+ public static class Result<T> {
|
|
|
|
+ private String code;
|
|
|
|
+ private T data;
|
|
|
|
+ private String message;
|
|
|
|
+
|
|
|
|
+ public String getCode() {
|
|
|
|
+ return code;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setCode(String code) {
|
|
|
|
+ this.code = code;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public T getData() {
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setData(T data) {
|
|
|
|
+ this.data = data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getMessage() {
|
|
|
|
+ return message;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setMessage(String message) {
|
|
|
|
+ this.message = message;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|