booking_auth_dev
wet 2 years ago
commit ca94d57c1f

@ -0,0 +1,43 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱关系人
/// </summary>
[SugarTable("booking_order_contact")]
[Description("订舱关系人")]
public class BookingOrderContact : DBEntityTenant
{
/// <summary>
/// 订舱Id
/// </summary>
public long? BookingId { get; set; }
/// <summary>
/// 角色代码
/// </summary>
public string RoleCode { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int? Sort { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

@ -109,6 +109,18 @@ namespace Myshipping.Application.Enum
[ErrorCodeItemMetadata("提箱小票链接生成失败:{0}")]
BOOK124,
/// <summary>
/// 船公司网站账号未配置
/// </summary>
[ErrorCodeItemMetadata("船公司网站账号未配置")]
BOOK125,
/// <summary>
/// vgm链接生成失败
/// </summary>
[ErrorCodeItemMetadata("vgm链接生成失败{0}")]
BOOK126,
/// <summary>
/// 附件不存在

@ -2290,6 +2290,46 @@
主单ID
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingOrderContact">
<summary>
订舱关系人
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.BookingId">
<summary>
订舱Id
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.RoleCode">
<summary>
角色代码
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.Name">
<summary>
名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.Tel">
<summary>
电话
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.Email">
<summary>
邮箱
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.Sort">
<summary>
排序号
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingOrderContact.Remark">
<summary>
备注
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingOrderUrl">
<summary>
订舱链接
@ -2591,6 +2631,16 @@
提箱小票链接生成失败
</summary>
</member>
<member name="F:Myshipping.Application.Enum.BookingErrorCode.BOOK125">
<summary>
船公司网站账号未配置
</summary>
</member>
<member name="F:Myshipping.Application.Enum.BookingErrorCode.BOOK126">
<summary>
vgm链接生成失败
</summary>
</member>
<member name="F:Myshipping.Application.Enum.BookingErrorCode.BOOK200">
<summary>
附件不存在
@ -3455,6 +3505,7 @@
<param name="bookingId"></param>
<returns></returns>
</member>
<!-- Badly formed XML comment ignored for member "M:Myshipping.Application.BookingOrderService.VgmLink(System.Int64)" -->
<member name="M:Myshipping.Application.BookingOrderService.GenReportJson(System.Int64)">
<summary>
获取用户报表的json
@ -5150,6 +5201,17 @@
订舱主表输出参数
</summary>
</member>
<member name="P:Myshipping.Application.BookingOrderUrlOutput.LinkUrlTxxp">
<summary>
提箱小票链接
</summary>
</member>
<member name="P:Myshipping.Application.BookingOrderUrlOutput.LinkUrlVgm">
<summary>
vgm链接
</summary>
</member>
<!-- Badly formed XML comment ignored for member "P:Myshipping.Application.BookingOrderUrlOutput.LinkUrlVmgSi" -->
<member name="T:Myshipping.Application.BookingPrintTemplateService">
<summary>
订舱打印模板服务

@ -52,7 +52,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingLogDetail> _bookinglogdetail;
private readonly SqlSugarRepository<BookingRemark> _bookingremark;
private readonly SqlSugarRepository<BookingFile> _bookingfile;
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _webconfig;
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _repWebAcc;
private readonly SqlSugarRepository<SysDictData> _dicdata;
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrint;
private readonly ILogger<BookingOrderService> _logger;
@ -63,6 +63,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingLetteryard> _repLetterYard;
private readonly SqlSugarRepository<SysUser> _repUser;
private readonly SqlSugarRepository<BookingOrderUrl> _repOrderUrl;
private readonly SqlSugarRepository<BookingOrderContact> _repOrderContact;
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep,
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, SqlSugarRepository<BookingRemark> bookingremark,
@ -70,7 +71,7 @@ namespace Myshipping.Application
SqlSugarRepository<SysDictData> dicdata, SqlSugarRepository<BookingStatusLog> statuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail,
ILogger<BookingOrderService> logger, ISysCacheService cache,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
SqlSugarRepository<BookingOrderUrl> repOrderUrl)
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact)
{
this._logger = logger;
this._rep = rep;
@ -80,7 +81,7 @@ namespace Myshipping.Application
this._bookinglogdetail = bookinglogdetail;
this._bookingremark = bookingremark;
this._bookingfile = bookingfile;
this._webconfig = webconfig;
this._repWebAcc = webconfig;
this._repPrint = repPrint;
this._dicdata = dicdata;
this._cache = cache;
@ -90,6 +91,7 @@ namespace Myshipping.Application
this._repLetterYard = repLetterYard;
this._repUser = repUser;
this._repOrderUrl = repOrderUrl;
this._repOrderContact = repOrderContact;
}
#region 主表和箱信息
@ -157,7 +159,7 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(input.HUMIDITY), u => u.HUMIDITY == input.HUMIDITY)
.WhereIF(!string.IsNullOrWhiteSpace(input.TEMPMIN), u => u.TEMPMIN == input.TEMPMIN)
.WhereIF(!string.IsNullOrWhiteSpace(input.TEMPMAX), u => u.TEMPMAX == input.TEMPMAX)
.WhereIF(input.ISCONTAINERSOC!=null, u => u.ISCONTAINERSOC == input.ISCONTAINERSOC)
.WhereIF(input.ISCONTAINERSOC != null, u => u.ISCONTAINERSOC == input.ISCONTAINERSOC)
.WhereIF(!string.IsNullOrWhiteSpace(input.SOREMARK), u => u.SOREMARK.Contains(input.SOREMARK))
.WhereIF(!string.IsNullOrWhiteSpace(input.SIREMARK), u => u.SIREMARK.Contains(input.SIREMARK))
.WhereIF(!string.IsNullOrWhiteSpace(input.YARDREMARK), u => u.YARDREMARK.Contains(input.YARDREMARK))
@ -194,7 +196,7 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICEID), u => u.CUSTSERVICEID == input.CUSTSERVICEID)
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICE), u => u.CUSTSERVICE.Contains(input.CUSTSERVICE))
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMERNAME), u => u.CUSTOMERNAME.Contains(input.CUSTOMERNAME))
.WhereIF(input.CUSTOMERID !=null, u => u.CUSTOMERID == input.CUSTOMERID)
.WhereIF(input.CUSTOMERID != null, u => u.CUSTOMERID == input.CUSTOMERID)
.WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDER), u => u.FORWARDER.Contains(input.FORWARDER))
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICE), u => u.CUSTSERVICE == input.CUSTSERVICE)
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMERNAME), u => u.CUSTOMERNAME == input.CUSTOMERNAME)
@ -399,11 +401,11 @@ namespace Myshipping.Application
[HttpGet("/BookingOrder/get")]
public async Task<BookingOrderOutput> Get(long Id)
{
BookingOrderOutput list = new BookingOrderOutput();
BookingOrderOutput ordOut = new BookingOrderOutput();
var main = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
if (main != null)
{
list = main.Adapt<BookingOrderOutput>();
ordOut = main.Adapt<BookingOrderOutput>();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var item in ctninput)
@ -411,9 +413,20 @@ namespace Myshipping.Application
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == item.Id).ToListAsync();
item.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
list.ctnInputs = ctninput;
ordOut.ctnInputs = ctninput;
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == Id);
if (ordUrl != null)
{
ordOut.Link = new BookingOrderUrlOutput()
{
LinkUrlTxxp = ordUrl.UrlTxxp,
LinkUrlVgm = ordUrl.UrlVgm,
LinkUrlVmgSi = ordUrl.UrlVgmSi,
};
}
}
return list;
return ordOut;
}
#endregion
@ -562,7 +575,7 @@ namespace Myshipping.Application
public async Task SendTrace(string BusinessId, string YARDID, string YARD, string MBLNO)
{
_logger.LogInformation("提单号:" + MBLNO + " 调用运踪接口");
var key = _webconfig.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl");
var key = _repWebAcc.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl");
var url = _cache.GetAllDictData().Result;
BillTraceDto billdto = new BillTraceDto();
List<BillTraceList> billTraceList = new List<BillTraceList>();
@ -849,7 +862,7 @@ namespace Myshipping.Application
}
//亿通账号
var ytAcc = _webconfig.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.TypeCode == "YitongWeb");
var ytAcc = _repWebAcc.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.TypeCode == "YitongWeb");
if (ytAcc == null)
{
throw Oops.Oh(BookingErrorCode.BOOK119);
@ -939,7 +952,155 @@ namespace Myshipping.Application
#endregion
#region VGM及VMG链接
/// <summary>
/// 获取VGM、VGM&SI链接
/// </summary>
/// <param name="bookingId"></param>
/// <returns></returns>
[HttpGet("/BookingOrder/vgmlink")]
public async Task<string[]> VgmLink(long bookingId)
{
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
if (order == null)
{
throw Oops.Oh(BookingErrorCode.BOOK001);
}
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == bookingId);
if (ordUrl == null)
{
ordUrl = new BookingOrderUrl();
ordUrl.BookingId = bookingId;
await _repOrderUrl.InsertAsync(ordUrl);
}
if (!string.IsNullOrEmpty(ordUrl.UrlVgm))
{
return new string[] { ordUrl.UrlVgm, ordUrl.UrlVgmSi };
}
//校验船公司
if (string.IsNullOrEmpty(order.CARRIERID))
{
throw Oops.Oh(BookingErrorCode.BOOK118);
}
//判断船公司是否支持
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList();
if (!allowCarrier.Contains(order.CARRIERID))
{
throw Oops.Oh(BookingErrorCode.BOOK117);
}
//船公司网站账号
var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.CARRIERID);
var webacc = _repWebAcc.FirstOrDefault(x => x.TypeCode == carrWebAccMap.Value && x.CreatedUserId == UserManager.UserId);
if (webacc == null)
{
throw Oops.Oh(BookingErrorCode.BOOK125);
}
//场站转换
var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingVgm");
if (yardset == null)
{
throw Oops.Oh(BookingErrorCode.BOOK120, order.YARDID);
}
var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync();
//校验箱子数据录入
if (ctns.Where(c => string.IsNullOrEmpty(c.CTNALL) || !c.CTNNUM.HasValue).Count() > 0)
{
throw Oops.Oh(BookingErrorCode.BOOK121);
}
//箱型映射
var ctnMapping = await _cache.GetAllMappingCtn();
ctnMapping = ctnMapping.Where(x => x.Module == "BookingVgm").ToList();
if (ctnMapping.Count == 0)
{
throw Oops.Oh(BookingErrorCode.BOOK122);
}
var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
if (expCode.Count > 0)
{
throw Oops.Oh(BookingErrorCode.BOOK123, string.Join(',', expCode));
}
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
//调用小票服务
var dicUrlTxxp = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "vgm_link_service");
var postObj = 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 = yardset.MapCode,
depotName = order.YARD,
linkName = UserManager.Name,
linkMobile = user.Tel,
linkEmail = user.Email,
userId = UserManager.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,
returnOkUrl = "",
SiReturnUrl = "",
DataInfoJson = new
{
order.SHIPPER,
order.CONSIGNEE,
order.NOTIFYPARTY,
order.MARKS,
order.DESCRIPTION,
order.BLFRT,
order.SERVICE,
order.ISSUETYPE,
order.TRANSPORT,
order.TRANSPORTID,
order.DESTINATION,
order.DESTINATIONID,
order.KINDPKGS,
order.THIRDPAYADDR,
order.PORTLOAD,
order.PORTLOADID,
order.PORTDISCHARGE,
order.PORTDISCHARGEID
}
};
string strPostObj = postObj.ToJsonString();
_logger.LogInformation($"调用VGM链接接口传递数据{strPostObj}");
var strResp = await dicUrlTxxp.Value.SetBody(postObj).PostAsStringAsync();
_logger.LogInformation($"调用VGM链接接口返回{strResp}");
var jobjResp = JObject.Parse(strResp);
int respCode = jobjResp.GetIntValue("code");
if (respCode != 200)
{
throw Oops.Oh(BookingErrorCode.BOOK126, jobjResp.GetStringValue("message"));
}
//保存url
var memoData = jobjResp.GetJObjectValue("memoData");
ordUrl.UrlVgm = memoData.GetStringValue("vgmUrl");
ordUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
await _repOrderUrl.UpdateAsync(ordUrl);
return new string[] { ordUrl.UrlVgm, ordUrl.UrlVgmSi };
}
#endregion
#region 订舱、截单EDI

@ -5,9 +5,26 @@ namespace Myshipping.Application
/// <summary>
/// 订舱主表输出参数
/// </summary>
public class BookingOrderOutput:BookingOrderDto
public class BookingOrderOutput : BookingOrderDto
{
public BookingOrderUrlOutput Link { get; set; }
}
public class BookingOrderUrlOutput
{
/// <summary>
/// 提箱小票链接
/// </summary>
public string LinkUrlTxxp { get; set; }
/// <summary>
/// vgm链接
/// </summary>
public string LinkUrlVgm { get; set; }
/// <summary>
/// vgm&si链接
/// </summary>
public string LinkUrlVmgSi { get; set; }
}
}

Loading…
Cancel
Save