From 4343fb8aeb62512f2b00b95ceeb65ddb21be90cd Mon Sep 17 00:00:00 2001
From: wanghaomei <86whm@163.com>
Date: Tue, 11 Jun 2024 16:06:52 +0800
Subject: [PATCH] =?UTF-8?q?EMC=E8=AE=A2=E8=88=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Myshipping.Application/EDI/EMCSoApiHelper.cs | 169 ++++++++----------
.../Entity/BookingCustomerOrder.cs | 7 +
.../BookingCustomerOrderService.cs | 4 +-
.../Service/BookingCustomerOrder/Dto/Dtos.cs | 5 +
4 files changed, 86 insertions(+), 99 deletions(-)
diff --git a/Myshipping.Application/EDI/EMCSoApiHelper.cs b/Myshipping.Application/EDI/EMCSoApiHelper.cs
index ada6360c..3df7b7ec 100644
--- a/Myshipping.Application/EDI/EMCSoApiHelper.cs
+++ b/Myshipping.Application/EDI/EMCSoApiHelper.cs
@@ -11,9 +11,12 @@ using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.Diagnostics.Contracts;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
+using System.Text.Encodings.Web;
+using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -190,7 +193,8 @@ namespace Myshipping.Application.EDI
number = ctn.PKGS,
packageUnit = ctn.KINDPKGS,
measurements = ctn.CBM,
- measurementUnit = "CBM"
+ measurementUnit = "CBM",
+ commodityName = custOrder.DESCRIPTION
};
postModel.cargoInfos.Add(apiBox);
@@ -199,9 +203,12 @@ namespace Myshipping.Application.EDI
//合约信息
postModel.contractInfo = new EMCSoApiContractInfo()
{
- bookingOffice = template.BookingAddress,
+ bookingOffice = custOrder.BookingAddr,
issuePlace = custOrder.BillSignLoc,
- billNum = custOrder.BillCount
+ billNum = custOrder.BillCount,
+ contractNo = custOrder.CONTRACTNO,
+ contractSelect = custOrder.ContractType,
+ contractParty = custOrder.SignType
};
//船期数据
@@ -216,8 +223,8 @@ namespace Myshipping.Application.EDI
//订舱公司详情
postModel.companyInfo = new EMCSoApiCompanyInfo()
{
- receiveBookingNotice = template.NotifyNext ? "YES" : "NO",
- referenceNO = template.CustomerInnerCode
+ receiveBookingNotice = custOrder.AcceptNotify ? "Yes" : "No",
+ referenceNO = custOrder.CustomerInnerCode
};
#region 收发通及货代
@@ -227,20 +234,10 @@ namespace Myshipping.Application.EDI
var telNumber = "";
//发货人
- if (string.IsNullOrEmpty(template.ShipperName))
- {
- companyName = custOrder.ShipperName;
- telCountryCode = custOrder.ShipperPhoneCountryCode;
- telAreaCode = custOrder.ShipperPhoneCode;
- telNumber = custOrder.ShipperPhone;
- }
- else
- {
- companyName = template.ShipperName;
- telCountryCode = template.ShipperPhoneCountryCode;
- telAreaCode = template.ShipperPhoneCode;
- telNumber = template.ShipperPhone;
- }
+ companyName = custOrder.ShipperName;
+ telCountryCode = custOrder.ShipperPhoneCountryCode;
+ telAreaCode = custOrder.ShipperPhoneCode;
+ telNumber = custOrder.ShipperPhone;
var bcMail = "";
if (!string.IsNullOrEmpty(custOrder.OpMail)) //优先使用东胜上传的邮箱
@@ -259,99 +256,75 @@ namespace Myshipping.Application.EDI
postModel.shipperInfo = new EMCSoApiSFTInfo()
{
companyName = companyName,
- contactTitle = template.ShipperSex,
- contactLName = string.IsNullOrEmpty(template.ShipperFirstName) ? custOrder.ShipperFirstName : template.ShipperFirstName,
- contactFName = string.IsNullOrEmpty(template.ShipperLastName) ? custOrder.ShipperLastName : template.ShipperLastName,
+ contactTitle = custOrder.ShipperSex,
+ contactLName = custOrder.ShipperFirstName,
+ contactFName = custOrder.ShipperLastName,
tel1 = telCountryCode,
tel2 = telAreaCode,
tel3 = telNumber,
- referenceNO = template.ShipperInnerCode,
+ referenceNO = custOrder.ShipperInnerCode,
email = bcMail
};
//收货人
- if (string.IsNullOrEmpty(template.ConsigneeName))
- {
- companyName = custOrder.ConsigneeName;
- telCountryCode = custOrder.ConsigneePhoneCountryCode;
- telAreaCode = custOrder.ConsigneePhoneCode;
- telNumber = custOrder.ConsigneePhone;
- }
- else
- {
- companyName = template.ConsigneeName;
- telCountryCode = template.ConsigneePhoneCountryCode;
- telAreaCode = template.ConsigneePhoneCode;
- telNumber = template.ConsigneePhone;
- }
+ companyName = custOrder.ConsigneeName;
+ telCountryCode = custOrder.ConsigneePhoneCountryCode;
+ telAreaCode = custOrder.ConsigneePhoneCode;
+ telNumber = custOrder.ConsigneePhone;
- postModel.consigneeInfo = new EMCSoApiSFTInfo()
+ if (!string.IsNullOrEmpty(companyName))
{
- companyName = companyName,
- contactTitle = template.ConsigneeSex,
- contactLName = string.IsNullOrEmpty(template.ConsigneeFirstName) ? custOrder.ConsigneeFirstName : template.ConsigneeFirstName,
- contactFName = string.IsNullOrEmpty(template.ConsigneeLastName) ? custOrder.ConsigneeLastName : template.ConsigneeLastName,
- tel1 = telCountryCode,
- tel2 = telAreaCode,
- tel3 = telNumber,
- referenceNO = template.ConsigneeInnerCode
- };
+ postModel.consigneeInfo = new EMCSoApiSFTInfo()
+ {
+ companyName = companyName,
+ contactTitle = custOrder.ConsigneeSex,
+ contactLName = custOrder.ConsigneeFirstName,
+ contactFName = custOrder.ConsigneeLastName,
+ tel1 = telCountryCode,
+ tel2 = telAreaCode,
+ tel3 = telNumber,
+ referenceNO = custOrder.ConsigneeInnerCode
+ };
+ }
//通知人
- if (string.IsNullOrEmpty(template.NotifypartName))
- {
- companyName = custOrder.NotifypartName;
- telCountryCode = custOrder.NotifypartPhoneCountryCode;
- telAreaCode = custOrder.NotifypartPhoneCode;
- telNumber = custOrder.NotifypartPhone;
- }
- else
- {
- companyName = template.NotifypartName;
- telCountryCode = template.NotifypartPhoneCountryCode;
- telAreaCode = template.NotifypartPhoneCode;
- telNumber = template.NotifypartPhone;
- }
+ companyName = custOrder.NotifypartName;
+ telCountryCode = custOrder.NotifypartPhoneCountryCode;
+ telAreaCode = custOrder.NotifypartPhoneCode;
+ telNumber = custOrder.NotifypartPhone;
- postModel.notifyInfo = new EMCSoApiSFTInfo()
+ if (!string.IsNullOrEmpty(companyName))
{
- companyName = companyName,
- contactTitle = template.NotifypartSex,
- contactLName = string.IsNullOrEmpty(template.NotifypartFirstName) ? custOrder.NotifypartFirstName : template.NotifypartFirstName,
- contactFName = string.IsNullOrEmpty(template.NotifypartLastName) ? custOrder.NotifypartLastName : template.NotifypartLastName,
- tel1 = telCountryCode,
- tel2 = telAreaCode,
- tel3 = telNumber,
- referenceNO = template.NotifypartInnerCode
- };
+ postModel.notifyInfo = new EMCSoApiSFTInfo()
+ {
+ companyName = companyName,
+ contactTitle = custOrder.NotifypartSex,
+ contactLName = custOrder.NotifypartFirstName,
+ contactFName = custOrder.NotifypartLastName,
+ tel1 = telCountryCode,
+ tel2 = telAreaCode,
+ tel3 = telNumber,
+ referenceNO = custOrder.NotifypartInnerCode
+ };
+ }
//货代
- if (string.IsNullOrEmpty(template.BookingName))
- {
- companyName = custOrder.BookingName;
- telCountryCode = custOrder.BookingPhoneCountryCode;
- telAreaCode = custOrder.BookingPhoneCode;
- telNumber = custOrder.BookingPhone;
- }
- else
- {
- companyName = template.BookingName;
- telCountryCode = template.BookingPhoneCountryCode;
- telAreaCode = template.BookingPhoneCode;
- telNumber = template.BookingPhone;
- }
+ companyName = custOrder.BookingName;
+ telCountryCode = custOrder.BookingPhoneCountryCode;
+ telAreaCode = custOrder.BookingPhoneCode;
+ telNumber = custOrder.BookingPhone;
var djyBookMail = sysConfigList.FirstOrDefault(x => x.Code == "DjyCustomerBookReceiveBcMail");
postModel.forwarderInfo = new EMCSoApiSFTInfo()
{
companyName = companyName,
- contactTitle = template.BookingSex,
- contactLName = string.IsNullOrEmpty(template.BookingFirstName) ? custOrder.BookingFirstName : template.BookingFirstName,
- contactFName = string.IsNullOrEmpty(template.BookingLastName) ? custOrder.BookingLastName : template.BookingLastName,
+ contactTitle = custOrder.BookingSex,
+ contactLName = custOrder.BookingFirstName,
+ contactFName = custOrder.BookingLastName,
tel1 = telCountryCode,
tel2 = telAreaCode,
tel3 = telNumber,
- referenceNO = template.BookingInnerCode,
+ referenceNO = custOrder.BookingInnerCode,
email = djyBookMail.Value
};
#endregion
@@ -363,8 +336,10 @@ namespace Myshipping.Application.EDI
}
apiUrl += "v1/emc/booking/auto";
- Log.Information($"发送API数据给爬虫({apiUrl}):{postModel.ToJsonString()}");
- var rtn = await apiUrl.SetBody(postModel)
+ var jsonStr = JsonConvert.SerializeObject(postModel, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
+
+ Log.Information($"发送API数据给爬虫({apiUrl}):{jsonStr}");
+ var rtn = await apiUrl.SetBody(jsonStr, "application/json")
.PostAsStringAsync();
Log.Information($"爬虫返回:{rtn}");
@@ -537,10 +512,10 @@ namespace Myshipping.Application.EDI
///
public string containerType { get; set; }
- ///
- /// 称重方式 E: 每个, T: 总和
- ///
- public string containerWeightMode { get; set; }
+ /////
+ ///// 称重方式 E: 每个, T: 总和
+ /////
+ //public string containerWeightMode { get; set; }
///
/// 重量 最多两位小数
@@ -599,13 +574,13 @@ namespace Myshipping.Application.EDI
/// 当合约类型为SC时, 这个参数生效,且合约号生效, 默认SC
/// SC, HT, LT, SQ, RS, HV, LM, HM, TV, LV, EM
///
- public string contractSelect { get; set; } = "SC";
+ public string contractSelect { get; set; }
///
/// 合约类型
/// 当类型为TR时,合约号不生效
/// SC, TR
///
- public string contractType { get; set; }
+ public string contractType { get; set; } = "SC";
///
/// 合约号
///
diff --git a/Myshipping.Application/Entity/BookingCustomerOrder.cs b/Myshipping.Application/Entity/BookingCustomerOrder.cs
index 13b429fd..d6ffaee4 100644
--- a/Myshipping.Application/Entity/BookingCustomerOrder.cs
+++ b/Myshipping.Application/Entity/BookingCustomerOrder.cs
@@ -891,6 +891,13 @@ namespace Myshipping.Application.Entity
[SugarColumn(ColumnName = "BookingEmail")]
[Description("订舱公司邮箱")]
public string BookingEmail { get; set; }
+
+ ///
+ /// 签约方
+ ///
+ [SugarColumn(ColumnName = "SignType")]
+ [Description("签约方")]
+ public string SignType { get; set; }
}
///
diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs
index e6adc241..5cdcd346 100644
--- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs
+++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs
@@ -2894,11 +2894,11 @@ namespace Myshipping.Application
var order = await _rep.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id);
KeyValuePair rtn = new KeyValuePair(false, "不支持的船司");
- if (order.CARGOID == "COSCO")
+ if (order.CARRIERID == "COSCO")
{
rtn = await ZhongYuanSoApiHelper.DoPost(id);
}
- else if (order.CARGOID == "EMC")
+ else if (order.CARRIERID == "EMC")
{
rtn = await EMCSoApiHelper.DoPost(id);
}
diff --git a/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs b/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs
index 642453d5..57387ef9 100644
--- a/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs
+++ b/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs
@@ -765,6 +765,11 @@ namespace Myshipping.Application
/// 订舱公司邮箱
///
public string BookingEmail { get; set; }
+
+ ///
+ /// 签约方
+ ///
+ public string SignType { get; set; }
}
//保存dto