|
|
|
@ -31,6 +31,11 @@ using System.Net.Http;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using System.Reflection.Emit;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrderSeaeEdi.Dto;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -43,13 +48,19 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly ILogger<BookingOrderSeaeEdiService> _logger;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderSeaeEdi> _seaeedi;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderSeaeEdiCtn> _seaeedictn;
|
|
|
|
|
|
|
|
|
|
public BookingOrderSeaeEdiService(ILogger<BookingOrderSeaeEdiService> logger, SqlSugarRepository<BookingOrderSeaeEdi> seaeedi, SqlSugarRepository<BookingOrderSeaeEdiCtn> seaeedictn)
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatusLog> _repStatuslog;
|
|
|
|
|
private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
|
|
|
|
|
public BookingOrderSeaeEdiService(ILogger<BookingOrderSeaeEdiService> logger, SqlSugarRepository<BookingOrderSeaeEdi> seaeedi,
|
|
|
|
|
SqlSugarRepository<BookingOrderSeaeEdiCtn> seaeedictn, ISysCacheService cache, SqlSugarRepository<BookingStatusLog> repStatuslog,
|
|
|
|
|
IDjyWebsiteAccountConfigService webAccountConfig)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._seaeedi = seaeedi;
|
|
|
|
|
this._seaeedictn = seaeedictn;
|
|
|
|
|
|
|
|
|
|
this._cache = cache;
|
|
|
|
|
this._repStatuslog = repStatuslog;
|
|
|
|
|
this._webAccountConfig = webAccountConfig;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
@ -172,128 +183,76 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
#region 舱单
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 舱单
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="bookingId"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//[HttpPost("/BookingOrderSeaeEdi/CustEDI")]
|
|
|
|
|
//public async Task CustEDI(long bookingId)
|
|
|
|
|
//{
|
|
|
|
|
// var order = _seaeedi.FirstOrDefault(x => x.BookingId == bookingId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var ctns = _seaeedictn.Where(x => x.BILLID == bookingId).ToList();
|
|
|
|
|
|
|
|
|
|
// //船公司
|
|
|
|
|
// if (string.IsNullOrEmpty(order.CARRIERID))
|
|
|
|
|
// {
|
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK118);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //提单号不能为空
|
|
|
|
|
// if (string.IsNullOrEmpty(order.MBLNO))
|
|
|
|
|
// {
|
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK127);
|
|
|
|
|
// }
|
|
|
|
|
// if (string.IsNullOrEmpty(order.YARDID))
|
|
|
|
|
// {
|
|
|
|
|
// throw Oops.Bah("场站未正确选择");
|
|
|
|
|
// }
|
|
|
|
|
// List<CustEDIDto> custEDIDtos = new List<CustEDIDto>();
|
|
|
|
|
// MDATA mDATA = new MDATA();
|
|
|
|
|
|
|
|
|
|
// mDATA.MBLNO = order.MBLNO;
|
|
|
|
|
// mDATA.HBLNO = order.HBLNO;
|
|
|
|
|
// mDATA.ETD = order.ETD == null ? "" : Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd");
|
|
|
|
|
// mDATA.FORWARDER = order.SHIPAGENCY;
|
|
|
|
|
// mDATA.VESSEL = order.VESSEL;
|
|
|
|
|
// mDATA.VOYNO = order.VOYNO;
|
|
|
|
|
// mDATA.CARRIER = order.CARRIERID;
|
|
|
|
|
// mDATA.SHIPPERNAME = order.SHIPPER;
|
|
|
|
|
// mDATA.SHIPPERADDR1 = order.SHIPPERADDR1;
|
|
|
|
|
// mDATA.SHIPPERCOUNTRY = order.SHIPPERCOUNTRY;
|
|
|
|
|
// mDATA.SHIPPERTEL = order.SHIPPERTEL;
|
|
|
|
|
// mDATA.CONSIGNEENAME = order.CONSIGNEE;
|
|
|
|
|
// mDATA.CONSIGNEEADDR1 = order.CONSIGNEEADDR1;
|
|
|
|
|
// mDATA.CONSIGNEECOUNTRY = order.CONSIGNEERCOUNTRY;
|
|
|
|
|
// mDATA.CONSIGNEETEL = order.CONSIGNEETEL;
|
|
|
|
|
// mDATA.NOTIFYPARTYNAME = order.NOTIFYPARTY;
|
|
|
|
|
// mDATA.NOTIFYPARTYADDR1 = order.NOTIFYPARTYADDR1;
|
|
|
|
|
// mDATA.NOTIFYPARTYCOUNTRY = order.NOTIFYPARTYCOUNTRY;
|
|
|
|
|
// mDATA.NOTIFYPARTYTEL = order.NOTIFYPARTYTEL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
|
|
|
|
|
|
|
|
|
|
// // int idx = 1;
|
|
|
|
|
// // //调用接口
|
|
|
|
|
// // var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "request_emf");
|
|
|
|
|
// // var sendObj = new
|
|
|
|
|
// // {
|
|
|
|
|
// // SystemCode = "djy_hechuan",
|
|
|
|
|
// // billOrderId = order.Id.ToString(),
|
|
|
|
|
// // sendOrderCode = order.MBLNO,
|
|
|
|
|
// // customerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
|
|
|
|
|
// // customerId = order.CUSTOMERID.ToString(),
|
|
|
|
|
// // agentName = string.IsNullOrEmpty(order.FORWARDER) ? UserManager.TENANT_NAME : order.FORWARDER,
|
|
|
|
|
// // carrierCode = order.CARRIERID,
|
|
|
|
|
// // userName = webacc.Account,
|
|
|
|
|
// // userPassword = webacc.Password,
|
|
|
|
|
// // depotCode = order.YARDID,
|
|
|
|
|
// // depotName = order.YARD,
|
|
|
|
|
// // linkName = UserManager.Name,
|
|
|
|
|
// // linkMobile = user.Phone,
|
|
|
|
|
// // linkEmail = user.Email,
|
|
|
|
|
// // userId = user.DjyUserId,
|
|
|
|
|
// // returnUrl = "",
|
|
|
|
|
// // shipName = order.VESSEL,
|
|
|
|
|
// // voyNo = order.VOYNO,
|
|
|
|
|
// // etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
|
// // potrSend = order.PORTLOAD,
|
|
|
|
|
// // potrGoal = order.PORTDISCHARGE,
|
|
|
|
|
// // boxinfoStr = order.CNTRTOTAL,
|
|
|
|
|
// // vgmEndTimeStr = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
|
// // BoxInfo = ctns.Select(c => new
|
|
|
|
|
// // {
|
|
|
|
|
// // index = idx++,
|
|
|
|
|
// // boxType = c.CTNALL,
|
|
|
|
|
// // boxcount = c.CTNNUM.HasValue ? c.CTNNUM.Value : 0,
|
|
|
|
|
// // code = c.CNTRNO,
|
|
|
|
|
// // sealCode = c.SEALNO,
|
|
|
|
|
// // weigth = c.KGS,
|
|
|
|
|
// // weigthTare = c.TAREWEIGHT,
|
|
|
|
|
// // weigthTotal = c.WEIGHKGS,
|
|
|
|
|
// // weigthType = c.WEIGHTYPE == "累加" ? "SM2" : "SM1"
|
|
|
|
|
// // }).ToList(),
|
|
|
|
|
// // returnOkUrl = ""
|
|
|
|
|
// // };
|
|
|
|
|
|
|
|
|
|
// // string strPostObj = sendObj.ToJsonString();
|
|
|
|
|
// // _logger.LogInformation($"调用VGM直发接口 {dicUrl.Value} 传递数据:{strPostObj}");
|
|
|
|
|
// // var strResp = await dicUrl.Value.SetBody(sendObj).PostAsStringAsync();
|
|
|
|
|
// // _logger.LogInformation($"调用VGM直发接口返回:{strResp}");
|
|
|
|
|
|
|
|
|
|
// // var jobjResp = JObject.Parse(strResp);
|
|
|
|
|
// // int respCode = jobjResp.GetIntValue("code");
|
|
|
|
|
// // if (respCode != 200)
|
|
|
|
|
// // {
|
|
|
|
|
// // throw Oops.Bah(BookingErrorCode.BOOK128, jobjResp.GetStringValue("message"));
|
|
|
|
|
// // }
|
|
|
|
|
// // //货运动态
|
|
|
|
|
// // var bsl = new BookingStatusLog();
|
|
|
|
|
// // bsl.BookingId = bookingId;
|
|
|
|
|
// // bsl.Status = $"直发VGM";
|
|
|
|
|
// // bsl.OpTime = DateTime.Now;
|
|
|
|
|
// // bsl.Category = "ship";
|
|
|
|
|
// // bsl.MBLNO = order.MBLNO;
|
|
|
|
|
// // await _repStatuslog.InsertAsync(bsl);
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 舱单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderSeaeEdi/CustEDI")]
|
|
|
|
|
public async Task CustEDI(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var order = await _seaeedi.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId).FirstAsync();
|
|
|
|
|
var ctns = await _seaeedictn.AsQueryable().Filter(null, true).Where(x => x.PId == order.Id).ToListAsync();
|
|
|
|
|
//船公司
|
|
|
|
|
if (string.IsNullOrEmpty(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK118);
|
|
|
|
|
}
|
|
|
|
|
//提单号不能为空
|
|
|
|
|
if (string.IsNullOrEmpty(order.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK127);
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(order.YARDID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("场站未正确选择");
|
|
|
|
|
}
|
|
|
|
|
var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "request_emf");
|
|
|
|
|
var key = _webAccountConfig.GetAccountConfig("DjyCangDan", UserManager.UserId).Result;
|
|
|
|
|
List<CustEDIDto> custEDIDtos = new List<CustEDIDto>();
|
|
|
|
|
MDATA mDATA = new MDATA();
|
|
|
|
|
List<CTNDATAItem> CTNDATA = new List<CTNDATAItem>();
|
|
|
|
|
mDATA = order.Adapt<MDATA>();
|
|
|
|
|
CTNDATA = ctns.Adapt<List<CTNDATAItem>>();
|
|
|
|
|
|
|
|
|
|
custEDIDtos.Add(
|
|
|
|
|
new CustEDIDto
|
|
|
|
|
{
|
|
|
|
|
MDATA = mDATA,
|
|
|
|
|
CTNDATA = CTNDATA
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
string strPostObj = custEDIDtos.ToJsonString();
|
|
|
|
|
|
|
|
|
|
var sendObj = new
|
|
|
|
|
{
|
|
|
|
|
ac = "emf",
|
|
|
|
|
uid = UserManager.DjyUserId,
|
|
|
|
|
skey = key.Password,
|
|
|
|
|
optype = "3",
|
|
|
|
|
data = strPostObj
|
|
|
|
|
};
|
|
|
|
|
_logger.LogInformation($"调用舱单接口 {dicUrl.Value} 传递数据:{strPostObj}");
|
|
|
|
|
var strResp = await dicUrl.Value.SetContentType("multipart/form-data").SetBody(sendObj).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation($"调用舱单接口返回:{strResp}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jobjResp = JObject.Parse(strResp);
|
|
|
|
|
int respCode = jobjResp.GetIntValue("code");
|
|
|
|
|
if (respCode != 200)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK129, jobjResp.GetStringValue("message"));
|
|
|
|
|
}
|
|
|
|
|
//货运动态
|
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
|
bsl.BookingId = bookingId;
|
|
|
|
|
bsl.Status = $"保存舱单";
|
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
|
bsl.Category = "ship";
|
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|