|
@@ -0,0 +1,538 @@
|
|
|
+package com.yh.saas.plugin.yiliangyiyun.util;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverCarInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.HyFreightSettlementInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.view.*;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.Waybill;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+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.HttpClients;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+public class MonitoringSystemReporting {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户列表
|
|
|
+ */
|
|
|
+ // 账号,密码,社会信用代码
|
|
|
+ public static String[][] usersArr = {
|
|
|
+ {"23106960", "h108796l", "91210804MA10FPAM2G"}
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测试
|
|
|
+ */
|
|
|
+ public static final String debugStr = Constants.DEBUG_SYSTEM_CODE;
|
|
|
+ public static final String sendUrl = "https://heilongjiang.wlhy.org.cn/wlhy-exchange-adjust/adjustMessage/send";
|
|
|
+
|
|
|
+ public static void sendTest() {
|
|
|
+ System.out.println("start");
|
|
|
+ for (int i = 0; i < 1; i++) {
|
|
|
+ System.out.println(i);
|
|
|
+ try {
|
|
|
+ List<Root> roots = new ArrayList<>();
|
|
|
+// roots.add(getFinancialRoot());
|
|
|
+// roots.add(testDispatch());
|
|
|
+// roots.add(testDriverRoot(null));
|
|
|
+// roots.add(testVehicleRoot(null));
|
|
|
+ for (Root root : roots) {
|
|
|
+ System.out.println("================================消息分割线================================");
|
|
|
+ String messageJson = JSON.toJSONString(root);
|
|
|
+ System.out.println("发送报文的内容:" + messageJson);
|
|
|
+ String result = PostUtils.post(sendUrl, messageJson);
|
|
|
+ System.out.println("服务器返回消息:" + result);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取监测系统公钥
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public static String GetJCPublicKey() throws IOException {
|
|
|
+ String url = "https://heilongjiang.wlhy.org.cn/wlhy-user/RsaController/getPubKey";
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+ // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ 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("code").equals("0")) {
|
|
|
+ String pubKey = jsonObject.getJSONObject("data").getString("publicKey");
|
|
|
+ System.out.println("pubKey = " + pubKey);
|
|
|
+ return pubKey;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ // 释放链接
|
|
|
+ response.close();
|
|
|
+ httpClient.close();
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取监测系统token
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public static Map<String, String> login(String userName, String password, String debug) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ String getpublicKeyPost = PostUtils.post("https://heilongjiang.wlhy.org.cn/wlhy-user/RsaController/getPubKey", "{}");
|
|
|
+ System.out.println("申请公钥接口:" + getpublicKeyPost);
|
|
|
+ Map<String, Object> resultPublicKeyMap = JSON.parseObject(getpublicKeyPost, Map.class);
|
|
|
+ String publicKey = (String) ((Map) resultPublicKeyMap.get("data")).get("publicKey");
|
|
|
+ System.out.println("获取到的公钥:" + publicKey);
|
|
|
+
|
|
|
+ HashMap<String, String> stringStringHashMap = new HashMap<>();
|
|
|
+ stringStringHashMap.put(Constants.PUBLIC_KEY_NAME, publicKey);
|
|
|
+// String encryptPassword = RsaEncryptUtil.encryptByPublicKey(password, stringStringHashMap);
|
|
|
+ String encryptPassword = SM2Utils.encrypt(Util.hexToByte(publicKey), password.getBytes());
|
|
|
+ System.out.println("加密后的密码:" + encryptPassword);
|
|
|
+
|
|
|
+ Map<String, String> loginParam = new HashMap<>();
|
|
|
+ loginParam.put("account", userName);
|
|
|
+ loginParam.put("passwd", encryptPassword);
|
|
|
+ loginParam.put("publicRsa", publicKey);
|
|
|
+ loginParam.put("systemCode", debug);
|
|
|
+ System.out.println(JSON.toJSONString(loginParam));
|
|
|
+ String loginPost = PostUtils.post("https://heilongjiang.wlhy.org.cn/wlhy-user/user/exgLogin", JSON.toJSONString(loginParam));
|
|
|
+ Map<String, Object> loginResultMap = JSON.parseObject(loginPost, Map.class);
|
|
|
+ System.out.println("登录post接口返回:" + loginResultMap);
|
|
|
+
|
|
|
+ String token = (String) ((Map) loginResultMap.get("data")).get("token");
|
|
|
+ String msgPublicKey = (String) ((Map) loginResultMap.get("data")).get("PUBLIC_KEY");
|
|
|
+ System.out.println("登录成功token:" + token);
|
|
|
+ map.put("token", token);
|
|
|
+ map.put("account", userName);
|
|
|
+ map.put("msgPublicKey", msgPublicKey);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Root loginRoot(String userName, String password, String uscc, String debug) {
|
|
|
+ Map<String, String> token = login(userName, password, debug);
|
|
|
+ Root edmRoot = new Root();
|
|
|
+ edmRoot.setToken(token.get("token"));
|
|
|
+ edmRoot.setUserName(token.get("account"));
|
|
|
+ edmRoot.setSenderCode(token.get("account"));
|
|
|
+ edmRoot.setPublicKey(token.get("msgPublicKey"));
|
|
|
+ edmRoot.setUscc(uscc);
|
|
|
+ return edmRoot;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Root getRoot(Waybill waybill, String name) throws Exception {
|
|
|
+ return getRoot(waybill, name, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Root getRoot(Waybill waybill, String name, Root edmRoot) throws Exception {
|
|
|
+ if (edmRoot == null) {
|
|
|
+ edmRoot = roots.get(r.nextInt(roots.size()));
|
|
|
+ }
|
|
|
+ Map<String, String> rsaKeys = new HashMap<String, String>();
|
|
|
+ rsaKeys.put("PUBLIC_KEY", edmRoot.getPublicKey());
|
|
|
+ String aesKey = MyStrUtil.uuid().substring(0, 16);
|
|
|
+ String dispatchJson = JSON.toJSONString(waybill);
|
|
|
+ System.out.println("dispatchJson:" + dispatchJson);
|
|
|
+
|
|
|
+ SM4Utils sm4 = new SM4Utils();
|
|
|
+ sm4.secretKey = aesKey;
|
|
|
+ sm4.hexString = false;
|
|
|
+ System.out.println("ECB模式加密");
|
|
|
+ String encryptedContent = sm4.encryptData_ECB(dispatchJson);
|
|
|
+ String encryptedCode = SM2Utils.encrypt(Util.hexToByte(rsaKeys.get("PUBLIC_KEY")), aesKey.getBytes());
|
|
|
+
|
|
|
+ Root root = new Root();
|
|
|
+ root.setUserName(edmRoot.getUserName());
|
|
|
+ root.setDocumentName(name);
|
|
|
+ root.setDocumentVersionNumber("1.0");
|
|
|
+ root.setSenderCode(edmRoot.getSenderCode());
|
|
|
+ root.setRecipientCode("wlhymot");
|
|
|
+ root.setMessageSendingDateTime("20190909130158");
|
|
|
+ root.setToken(edmRoot.getToken());
|
|
|
+ root.setSenderCode(edmRoot.getSenderCode());
|
|
|
+ root.setEncryptedCode(encryptedCode);
|
|
|
+ root.setEncryptedContent(encryptedContent);
|
|
|
+ root.setMessageReferenceNumber(MyStrUtil.uuid());
|
|
|
+ String ipcType = "";
|
|
|
+ if ("车辆信息单".equals(name)) {
|
|
|
+ ipcType = Constants.IPC_TYPE_CL;
|
|
|
+ }
|
|
|
+ if ("驾驶员信息单".equals(name)) {
|
|
|
+ ipcType = Constants.IPC_TYPE_JSY;
|
|
|
+ }
|
|
|
+ if ("位置信息单".equals(name)) {
|
|
|
+ ipcType = Constants.IPC_TYPE_WZ;
|
|
|
+ }
|
|
|
+ if ("资金流水单".equals(name)) {
|
|
|
+ ipcType = Constants.IPC_TYPE_ZJ;
|
|
|
+ }
|
|
|
+ if ("电子运单".equals(name)) {
|
|
|
+ ipcType = Constants.IPC_TYPE_YD;
|
|
|
+ }
|
|
|
+ root.setIpcType(ipcType);
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 驾驶员信息单
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static Root testDriverRoot(HyDriverInfo hyDriverInfo) throws Exception {
|
|
|
+ String name = "驾驶员信息单";
|
|
|
+ DriverInfo driver = testDriver(hyDriverInfo);
|
|
|
+ //roots.get(0)
|
|
|
+ Root root = getRoot(driver, name, loginRoot("23106960", "h108796l", "91210804MA10FPAM2G","debugSystem"));
|
|
|
+ String messageJson = JSON.toJSONString(root);
|
|
|
+ System.out.println("发送报文的内容:" + messageJson);
|
|
|
+ String result = PostUtils.post(sendUrl, messageJson);
|
|
|
+ System.out.println("服务器返回消息:" + result);
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+// public static Root testDriverRoot(Root root1) throws Exception{
|
|
|
+// return testDriverRoot(root1,null);
|
|
|
+// }
|
|
|
+
|
|
|
+ public static DriverInfo testDriver(HyDriverInfo hyDriverInfo) throws Exception {
|
|
|
+ String name = "驾驶员信息单";
|
|
|
+ DriverInfo driver = new DriverInfo();
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
|
|
|
+ driver.setDriverName(hyDriverInfo.getDriverName());
|
|
|
+ driver.setDrivingLicense(hyDriverInfo.getNumberCard());
|
|
|
+ driver.setVehicleClass(hyDriverInfo.getQuasiDrivingVehicle());
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add(hyDriverInfo.getLssuingAuthority());
|
|
|
+ driver.setIssuingOrganizations(list);
|
|
|
+ driver.setValidPeriodFrom(f.format(hyDriverInfo.getDriverLicenseValidityStartDate()));
|
|
|
+ String str = hyDriverInfo.getDriverLicenseValidityDate().replace("-", "");
|
|
|
+ driver.setValidPeriodTo(str);
|
|
|
+ driver.setQualificationCertificate(hyDriverInfo.getQualificationCertificate());
|
|
|
+ driver.setTelephone(hyDriverInfo.getDriverPhone());
|
|
|
+ driver.setRemark("备注");
|
|
|
+ return driver;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验未通过{"vehicle.GrossMass":"vehicle.GrossMass 为浮点数,最大长度不得超过 9,浮点位2位,不足补0",
|
|
|
+ * "vehicle.RoadTransportCertificateNumber":"vehicle.RoadTransportCertificateNumber 是存数组,长度等于12,总质量4.5吨及以下普通货运车辆的,可填“车籍地6位行政区域代码+000000”",
|
|
|
+ * "vehicle.TrailerVehiclePlateNumber":"vehicle.TrailerVehiclePlateNumber 不是标准车牌号",
|
|
|
+ * "vehicle.VehicleEnergyType":"vehicle.VehicleEnergyType 不能为空,现值只允许出现[E01, E02, E03, E04, E99]","
|
|
|
+ * vehicle.VehicleTonnage":"vehicle.VehicleTonnage 为浮点数,最大长度不得超过 9,浮点位2位,不足补0"}
|
|
|
+ * <p>
|
|
|
+ * 校验未通过{"vehicle.RoadTransportCertificateNumber":"vehicle.RoadTransportCertificateNumber 是存数组,长度等于12,域代码+000000”"}
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception 车辆信息单
|
|
|
+ */
|
|
|
+ public static Root testVehicleRoot(HyDriverCarInfo hyDriverCarInfo) throws Exception {
|
|
|
+ String name = "车辆信息单";
|
|
|
+ Vehicle vehicle = new Vehicle();
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
|
|
|
+ vehicle.setVehicleNumber(hyDriverCarInfo.getCarNumber());
|
|
|
+ if ("黄色".equals(hyDriverCarInfo.getCarNumberColour())) {
|
|
|
+ vehicle.setVehiclePlateColorCode("2");
|
|
|
+ } else if ("蓝色".equals(hyDriverCarInfo.getCarNumberColour())) {
|
|
|
+ vehicle.setVehiclePlateColorCode("1");
|
|
|
+ }
|
|
|
+ vehicle.setVehicleType(hyDriverCarInfo.getVehicleTypeKey());
|
|
|
+ vehicle.setOwner(hyDriverCarInfo.getOwner());
|
|
|
+ vehicle.setUseCharacter(hyDriverCarInfo.getUseNature());
|
|
|
+ vehicle.setVin(hyDriverCarInfo.getCarCode());
|
|
|
+ vehicle.setIssuingOrganizations(hyDriverCarInfo.getLssuingAuthority());
|
|
|
+ vehicle.setRegisterDate(f.format(hyDriverCarInfo.getDrivingLicenseRegistrationDate()));
|
|
|
+ vehicle.setIssueDate(f.format(hyDriverCarInfo.getDrivingLicenseIssueDate()));
|
|
|
+ if ("汽油".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("A");
|
|
|
+ } else if ("柴油".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("B");
|
|
|
+ } else if ("油电混合".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("O");
|
|
|
+ } else if ("纯电动".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("C");
|
|
|
+ } else if ("插电式混合动力".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("O");
|
|
|
+ } else if ("增程式".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("Z");
|
|
|
+ } else if ("天然气".equals(hyDriverCarInfo.getEnergyType())) {
|
|
|
+ vehicle.setVehicleEnergyType("E");
|
|
|
+ }
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ if ("非挂车".equals(hyDriverCarInfo.getCarCategory())) {
|
|
|
+ Double doubleValue = hyDriverCarInfo.getCarApprovedWeight() / 1000;
|
|
|
+ String approvedWeight = df.format(doubleValue);
|
|
|
+ vehicle.setVehicleTonnage(approvedWeight);
|
|
|
+ Double doubleValue1 = hyDriverCarInfo.getCarTotalWeight() / 1000;
|
|
|
+ String totalWeight = df.format(doubleValue1);
|
|
|
+ vehicle.setGrossMass(totalWeight);
|
|
|
+ } else {
|
|
|
+ Double doubleValue = hyDriverCarInfo.getGuaCarApprovedWeight() / 1000;
|
|
|
+ String approvedWeight = df.format(doubleValue);
|
|
|
+ vehicle.setVehicleTonnage(approvedWeight);
|
|
|
+ Double doubleValue1 = hyDriverCarInfo.getServicingWeight() / 1000;
|
|
|
+ String servicingWeight = df.format(doubleValue1);
|
|
|
+ vehicle.setGrossMass(servicingWeight);
|
|
|
+ }
|
|
|
+ vehicle.setRoadTransportCertificateNumber(hyDriverCarInfo.getOperationCertificateNumber());
|
|
|
+ vehicle.setRemark("备注");
|
|
|
+ Root root = getRoot(vehicle, name, roots.get(0));
|
|
|
+ String messageJson = JSON.toJSONString(root);
|
|
|
+ System.out.println("发送报文的内容:" + messageJson);
|
|
|
+ String result = PostUtils.post(sendUrl, messageJson);
|
|
|
+ System.out.println("服务器返回消息:" + result);
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 资金流水单
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static Root getFinancialRoot(HyFreightSettlementInfo hyFreightSettlementInfo) throws Exception {
|
|
|
+ String name = "资金流水单";
|
|
|
+ FinancialRoot financialRoot = new FinancialRoot();
|
|
|
+ SimpleDateFormat f1 = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
|
|
|
+
|
|
|
+ financialRoot.setDocumentNumber(hyFreightSettlementInfo.getDocumentNo());
|
|
|
+ financialRoot.setSendToProDateTime(f1.format(new Date()));
|
|
|
+ financialRoot.setCarrier(hyFreightSettlementInfo.getDriverName());
|
|
|
+ financialRoot.setActualCarrierID(hyFreightSettlementInfo.getDriverIdCard());
|
|
|
+ financialRoot.setVehicleNumber(hyFreightSettlementInfo.getCarNumber());
|
|
|
+ if ("黄色".equals(hyFreightSettlementInfo.getCarNumberColour())) {
|
|
|
+ financialRoot.setVehiclePlateColorCode("2");
|
|
|
+ } else if ("蓝色".equals(hyFreightSettlementInfo.getCarNumberColour())) {
|
|
|
+ financialRoot.setVehiclePlateColorCode("1");
|
|
|
+ }
|
|
|
+ //运单列表
|
|
|
+ List<ShippingNote> shippingNoteList = new ArrayList<>();
|
|
|
+ ShippingNote shippingNote1 = new ShippingNote();
|
|
|
+ shippingNote1.setShippingNoteNumber(hyFreightSettlementInfo.getOrderNo());
|
|
|
+ shippingNote1.setSerialNumber("0000");
|
|
|
+ shippingNote1.setTotalMonetaryAmount(String.valueOf(hyFreightSettlementInfo.getAmountMoney()));
|
|
|
+ shippingNoteList.add(shippingNote1);
|
|
|
+ financialRoot.setShippingNoteList(shippingNoteList);
|
|
|
+ //财务列表
|
|
|
+ List<Financial> financiallist = new ArrayList<>();
|
|
|
+ Financial financial1 = new Financial();
|
|
|
+ financial1.setPaymentMeansCode("32");
|
|
|
+ financial1.setRecipient(hyFreightSettlementInfo.getDriverName());
|
|
|
+ financial1.setReceiptAccount(hyFreightSettlementInfo.getBankCard());
|
|
|
+ financial1.setBankCode(hyFreightSettlementInfo.getBankKey());
|
|
|
+ financial1.setSequenceCode(hyFreightSettlementInfo.getSerialNumber());
|
|
|
+ Double doubleValue1 = Double.parseDouble(new DecimalFormat("0.000").format(hyFreightSettlementInfo.getAmountMoney()));
|
|
|
+ financial1.setMonetaryAmount(String.valueOf(doubleValue1));
|
|
|
+ financial1.setDateTime(f1.format(hyFreightSettlementInfo.getPaymentDate()));
|
|
|
+ financiallist.add(financial1);
|
|
|
+ financialRoot.setFinanciallist(financiallist);
|
|
|
+ Root root = getRoot(financialRoot, name);
|
|
|
+ String messageJson = JSON.toJSONString(root);
|
|
|
+ System.out.println("发送报文的内容:" + messageJson);
|
|
|
+ String result = PostUtils.post(sendUrl, messageJson);
|
|
|
+ System.out.println("服务器返回消息:" + result);
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 电子运单
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Root testDispatch(OrderInfo orderInfo) {
|
|
|
+ Root root = null;
|
|
|
+ try {
|
|
|
+ Root edmRoot = roots.get(r.nextInt(roots.size()));
|
|
|
+ String name = "电子运单";
|
|
|
+ Dispatch dispatch = getDispatch(orderInfo);
|
|
|
+// dispatch.setUnifiedSocialCreditIdentifier(edmRoot.getUscc());
|
|
|
+ root = getRoot(dispatch, name, edmRoot);
|
|
|
+ String messageJson = JSON.toJSONString(root);
|
|
|
+ System.out.println("发送报文的内容:" + messageJson);
|
|
|
+ String result = PostUtils.post(sendUrl, messageJson);
|
|
|
+ System.out.println("服务器返回消息:" + result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 运单信息
|
|
|
+ *
|
|
|
+ * @param orderInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Dispatch getDispatch(OrderInfo orderInfo) {
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
|
|
|
+ Dispatch dispatch = new Dispatch();
|
|
|
+ dispatch.setOriginalDocumentNumber(orderInfo.getOrderNo());
|
|
|
+ dispatch.setShippingNoteNumber(orderInfo.getOrderNo());
|
|
|
+ dispatch.setSerialNumber("0000");
|
|
|
+ dispatch.setVehicleAmount("1");
|
|
|
+ dispatch.setTransportTypeCode("1");
|
|
|
+ dispatch.setSendToProDateTime(f.format(new Date()));
|
|
|
+ dispatch.setCarrier("黑龙江畅运通物流供应链有限公司");
|
|
|
+ dispatch.setUnifiedSocialCreditIdentifier("91210804MA10FPAM2G");
|
|
|
+ dispatch.setPermitNumber("testDebug");
|
|
|
+ dispatch.setConsignmentDateTime(f.format(orderInfo.getCreateDate()));
|
|
|
+ dispatch.setBusinessTypeCode(orderInfo.getBusinessTypeCode());
|
|
|
+ dispatch.setDespatchActualDateTime(f.format(orderInfo.getDeliveryTime()));
|
|
|
+ dispatch.setGoodsReceiptDateTime(f.format(orderInfo.getReceivingTime()));
|
|
|
+ dispatch.setRemark("备注");
|
|
|
+ Double doubleValue1 = Double.parseDouble(new DecimalFormat("0.000").format(orderInfo.getActualFreight()));
|
|
|
+ dispatch.setTotalMonetaryAmount(String.valueOf(doubleValue1));
|
|
|
+ setConsignorInfo(dispatch, orderInfo);
|
|
|
+ setConsigneeInfo(dispatch, orderInfo);
|
|
|
+ setInsuranceInformation(dispatch, orderInfo);
|
|
|
+ setVehicleInfo(dispatch, orderInfo);
|
|
|
+ //实际承运人信息
|
|
|
+ ActualCarrierInfo actual = new ActualCarrierInfo();
|
|
|
+ actual.setActualCarrierName(orderInfo.getDriverName());
|
|
|
+ actual.setActualCarrierBusinessLicense(orderInfo.getRoadTransportBusinessLicenseNo());
|
|
|
+ actual.setActualCarrierID(orderInfo.getDriverIdCard());
|
|
|
+ List<ActualCarrierInfo> actualList = new ArrayList<>();
|
|
|
+ actualList.add(actual);
|
|
|
+ dispatch.setActualCarrierInfo(actualList);
|
|
|
+
|
|
|
+ return dispatch;
|
|
|
+ }
|
|
|
+
|
|
|
+ //托运人信息
|
|
|
+ public static void setConsignorInfo(Dispatch dispatch, OrderInfo orderInfo) {
|
|
|
+ List<ConsignorInfo> consignorInfos = new ArrayList<>();
|
|
|
+ ConsignorInfo consignorInfo = new ConsignorInfo();
|
|
|
+ consignorInfo.setConsignor(orderInfo.getConsignorName());
|
|
|
+ consignorInfo.setConsignorID(orderInfo.getConsignorID());
|
|
|
+ consignorInfo.setPlaceOfLoading(orderInfo.getSendPrivate() + orderInfo.getSendCity() + orderInfo.getSendArea() + orderInfo.getSendDetailedAddress());
|
|
|
+ consignorInfo.setCountrySubdivisionCode(orderInfo.getNationalCode());
|
|
|
+ consignorInfos.add(consignorInfo);
|
|
|
+ dispatch.setConsignorInfo(consignorInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ //收货方信息
|
|
|
+ public static void setConsigneeInfo(Dispatch dispatch, OrderInfo orderInfo) {
|
|
|
+ List<ConsigneeInfo> consigneeInfos = new ArrayList<>();
|
|
|
+ ConsigneeInfo consigneeInfo = new ConsigneeInfo();
|
|
|
+ consigneeInfo.setConsignee(orderInfo.getShipToName());
|
|
|
+ consigneeInfo.setConsigneeID(orderInfo.getShipToID());
|
|
|
+ consigneeInfo.setGoodsReceiptPlace(orderInfo.getUnloadPrivate() + orderInfo.getUnloadCity() + orderInfo.getUnloadArea() + orderInfo.getUnloadDetailedAddress());
|
|
|
+ consigneeInfo.setCountrySubdivisionCode(orderInfo.getShipToNationalCode());
|
|
|
+ consigneeInfos.add(consigneeInfo);
|
|
|
+ dispatch.setConsigneeInfo(consigneeInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ //保险信息
|
|
|
+ public static void setInsuranceInformation(Dispatch dispatch, OrderInfo orderInfo) {
|
|
|
+ List<InsuranceInformation> insuranceInformations = new ArrayList<>();
|
|
|
+ InsuranceInformation insuranceInformation = new InsuranceInformation();
|
|
|
+ insuranceInformation.setPolicyNumber("none");
|
|
|
+ insuranceInformation.setInsuranceCompanyCode("none");
|
|
|
+ insuranceInformations.add(insuranceInformation);
|
|
|
+ dispatch.setInsuranceInformation(insuranceInformations);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void setVehicleInfo(Dispatch dispatch, OrderInfo orderInfo) {
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
|
|
|
+ List<VehicleInfo> vehicleInfos = new ArrayList<>();
|
|
|
+ //车辆信息
|
|
|
+ VehicleInfo vehicleInfo = new VehicleInfo();
|
|
|
+ vehicleInfo.setVehicleNumber(orderInfo.getCarNumber());
|
|
|
+ if ("黄色".equals(orderInfo.getCarNumberColour())) {
|
|
|
+ vehicleInfo.setVehiclePlateColorCode("2");
|
|
|
+ } else if ("蓝色".equals(orderInfo.getCarNumberColour())) {
|
|
|
+ vehicleInfo.setVehiclePlateColorCode("1");
|
|
|
+ }
|
|
|
+ if (orderInfo.getTrailerNumber() != null) {
|
|
|
+ vehicleInfo.setTrailerVehiclePlateNumber(orderInfo.getTrailerNumber());
|
|
|
+ vehicleInfo.setTrailerVehiclePlateColorCode("2");
|
|
|
+ }
|
|
|
+ vehicleInfo.setDespatchActualDateTime(f.format(orderInfo.getDeliveryTime()));
|
|
|
+ vehicleInfo.setGoodsReceiptDateTime(f.format(orderInfo.getReceivingTime()));
|
|
|
+ vehicleInfo.setPlaceOfLoading(orderInfo.getSendPrivate() + orderInfo.getSendCity() + orderInfo.getSendArea() + orderInfo.getSendDetailedAddress());
|
|
|
+ vehicleInfo.setLoadingCountrySubdivisionCode(orderInfo.getNationalCode());
|
|
|
+ vehicleInfo.setGoodsReceiptPlace(orderInfo.getUnloadPrivate() + orderInfo.getUnloadCity() + orderInfo.getUnloadArea() + orderInfo.getUnloadDetailedAddress());
|
|
|
+ vehicleInfo.setReceiptCountrySubdivisionCode(orderInfo.getShipToNationalCode());
|
|
|
+ //驾驶员信息
|
|
|
+ List<Driver> drivers = new ArrayList<Driver>();
|
|
|
+ Driver driver1 = new Driver();
|
|
|
+ driver1.setDriverName(orderInfo.getDriverName());
|
|
|
+ driver1.setDrivingLicense(orderInfo.getDriverIdCard());
|
|
|
+ drivers.add(driver1);
|
|
|
+ vehicleInfo.setDriver(drivers);
|
|
|
+ //货物信息
|
|
|
+ List<GoodsInfo> goodsInfos = new ArrayList<GoodsInfo>();
|
|
|
+ GoodsInfo goodsInfo1 = new GoodsInfo();
|
|
|
+ goodsInfo1.setDescriptionOfGoods(orderInfo.getGoodsName());
|
|
|
+ goodsInfo1.setCargoTypeClassificationCode(orderInfo.getGoodsTypeKey());
|
|
|
+ Double doubleValue1 = Double.parseDouble(new DecimalFormat("0.000").format(orderInfo.getGrossWeight() * 1000));
|
|
|
+ goodsInfo1.setGoodsItemGrossWeight(String.valueOf(doubleValue1));
|
|
|
+ goodsInfos.add(goodsInfo1);
|
|
|
+ vehicleInfo.setGoodsInfo(goodsInfos);
|
|
|
+ vehicleInfos.add(vehicleInfo);
|
|
|
+ dispatch.setVehicleInfo(vehicleInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ static Random r = new Random();
|
|
|
+
|
|
|
+ static String[] names = new String[20];
|
|
|
+
|
|
|
+ static String[] vehicleoffices = new String[10];
|
|
|
+
|
|
|
+ static String[] goodsNames = new String[20];
|
|
|
+
|
|
|
+ static String[] company = new String[10];
|
|
|
+
|
|
|
+ static String[] addrs = new String[20];
|
|
|
+
|
|
|
+ static List<String> carriers = new ArrayList<>();
|
|
|
+
|
|
|
+ static List<String> vehicleTypes = new ArrayList<>();
|
|
|
+
|
|
|
+ static List<String> classTypes = new ArrayList<>();
|
|
|
+
|
|
|
+ static List<Root> roots = new ArrayList<>();
|
|
|
+
|
|
|
+ static List<String[]> users = new ArrayList<>();
|
|
|
+
|
|
|
+ static {
|
|
|
+
|
|
|
+ for (String[] user1 : usersArr) {
|
|
|
+ users.add(user1);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < users.size(); i++) {
|
|
|
+ roots.add(loginRoot(users.get(i)[0], users.get(i)[1], users.get(i)[2], debugStr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|