|
|
|
@ -517,7 +517,6 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 客户端操作与接口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提交订舱
|
|
|
|
@ -1763,6 +1762,12 @@ namespace Myshipping.Application
|
|
|
|
|
[HttpPost("/BookingCustomerOrder/ReceiveCustomerOrder"), AllowAnonymous, ApiUser]
|
|
|
|
|
public async Task ReceiveCustomerOrder([FromForm] BookingCustomerApiSaveInput input, IFormFile[] files)
|
|
|
|
|
{
|
|
|
|
|
var carrList = await _cache.GetAllCodeCarrier();
|
|
|
|
|
var portLoadList = await _cache.GetAllCodePortLoad();
|
|
|
|
|
var portDestList = await _cache.GetAllCodePort();
|
|
|
|
|
var serviceList = await _cache.GetAllCodeService();
|
|
|
|
|
var frtList = await _cache.GetAllCodeFrt();
|
|
|
|
|
var ctnList = await _cache.GetAllCodeCtn();
|
|
|
|
|
|
|
|
|
|
#region 校验
|
|
|
|
|
/*
|
|
|
|
@ -1792,34 +1797,77 @@ namespace Myshipping.Application
|
|
|
|
|
// throw Oops.Bah("订舱密码不能为空");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.CARRIERID) || string.IsNullOrEmpty(input.CARRIER))
|
|
|
|
|
//2024-4-2,为保证后面自动化订舱需要,船司、港口、箱型等信息改为传公共库中的唯一代码
|
|
|
|
|
if (string.IsNullOrEmpty(input.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("船司代码不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var carr = carrList.FirstOrDefault(x => x.Code == input.CARRIERID);
|
|
|
|
|
if (carr == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("船司代码和名称不能为空");
|
|
|
|
|
throw Oops.Bah($"未找到匹配的船司代码:{input.CARRIERID}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!input.ETD.HasValue)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("开船日期不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.PORTLOADID) || string.IsNullOrEmpty(input.PORTLOAD))
|
|
|
|
|
//2024-4-2,为保证后面自动化订舱需要,船司、港口、箱型等信息改为传公共库中的唯一代码,名称和五字码根据唯一代码匹配写入,无需传递
|
|
|
|
|
//if (string.IsNullOrEmpty(input.PORTLOADID) || string.IsNullOrEmpty(input.PORTLOAD))
|
|
|
|
|
//{
|
|
|
|
|
// throw Oops.Bah("起运港代码和名称不能为空");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//if (string.IsNullOrEmpty(input.PORTDISCHARGEID) || string.IsNullOrEmpty(input.PORTDISCHARGE))
|
|
|
|
|
//{
|
|
|
|
|
// throw Oops.Bah("目的港代码和名称不能为空");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.PORTLOADCODE))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("起运港代码不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var portLoad = portLoadList.FirstOrDefault(x => x.Code == input.PORTLOADCODE);
|
|
|
|
|
if (portLoad == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("起运港代码和名称不能为空");
|
|
|
|
|
throw Oops.Bah($"未找到匹配的起运港:{input.PORTLOADCODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.PORTDISCHARGEID) || string.IsNullOrEmpty(input.PORTDISCHARGE))
|
|
|
|
|
if (string.IsNullOrEmpty(input.PORTDISCHARGECODE))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("目的港代码和名称不能为空");
|
|
|
|
|
throw Oops.Bah("目的港代码不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.SERVICE))
|
|
|
|
|
var portDest = portDestList.FirstOrDefault(x => x.Code == input.PORTDISCHARGECODE);
|
|
|
|
|
if (portDest == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("运输条款不能为空");
|
|
|
|
|
throw Oops.Bah($"未找到匹配的目的港:{input.PORTDISCHARGECODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.BLFRT))
|
|
|
|
|
if (string.IsNullOrEmpty(input.SERVICECODE))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("付费方式不能为空");
|
|
|
|
|
throw Oops.Bah("运输条款代码不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var service = serviceList.FirstOrDefault(x => x.Code == input.SERVICECODE);
|
|
|
|
|
if (service == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到匹配的运输条款:{input.SERVICECODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(input.FRTCODE))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("付费方式代码不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var frt = frtList.FirstOrDefault(x => x.Code == input.FRTCODE);
|
|
|
|
|
if (frt == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到匹配的付费方式:{input.FRTCODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!input.KGS.HasValue)
|
|
|
|
@ -1848,6 +1896,7 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Bah("货物标识为冻柜的情况下,湿度不能为空");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (input.CARGOID == "D")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(input.DUNNO))
|
|
|
|
@ -1875,13 +1924,20 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
if (input.CtnList == null || input.CtnList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("箱型箱量不能为空");
|
|
|
|
|
throw Oops.Bah("箱信息不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var notExistCode = input.CtnList.Where(x => ctnList.Count(y => y.Code == x.CTNCODE) == 0).Select(x => x.CTNCODE).ToList();
|
|
|
|
|
if (notExistCode.Any())
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到箱型:{string.Join(",", notExistCode)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.ServiceItemList == null || input.ServiceItemList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("服务项目不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var custOrder = await _rep.AsQueryable().Filter(null, true).FirstAsync(x => x.TenantId == UserManager.TENANT_ID && x.BSNO == input.BSNO);
|
|
|
|
@ -1909,6 +1965,15 @@ namespace Myshipping.Application
|
|
|
|
|
ins = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//赋值根据唯一代码匹配后的代码、名称等信息
|
|
|
|
|
custOrder.CARRIER = carr.EnName;
|
|
|
|
|
custOrder.PORTLOAD = portLoad.EnName;
|
|
|
|
|
custOrder.PORTLOADID = portLoad.EdiCode;
|
|
|
|
|
custOrder.PORTDISCHARGE = portDest.EnName;
|
|
|
|
|
custOrder.PORTDISCHARGEID = portDest.EdiCode;
|
|
|
|
|
custOrder.SERVICE = service.Name;
|
|
|
|
|
custOrder.BLFRT = frt.EnName;
|
|
|
|
|
|
|
|
|
|
//订舱账号、密码
|
|
|
|
|
var jobj = new JObject();
|
|
|
|
|
if (!string.IsNullOrEmpty(custOrder.ExtendData))
|
|
|
|
@ -1916,13 +1981,17 @@ namespace Myshipping.Application
|
|
|
|
|
jobj = JObject.Parse(custOrder.ExtendData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var jobjBookAcc=new JObject();
|
|
|
|
|
var jobjBookAcc = new JObject();
|
|
|
|
|
jobjBookAcc["Account"] = input.BOOKINGACCOUNT;
|
|
|
|
|
jobjBookAcc["Password"] = input.BOOKINGPASSWORD;
|
|
|
|
|
jobj["BookingAccount"] = jobjBookAcc;
|
|
|
|
|
custOrder.ExtendData = jobjBookAcc.ToJsonString();
|
|
|
|
|
|
|
|
|
|
var ctns = input.CtnList.Adapt<List<BookingCtn>>();
|
|
|
|
|
foreach(var ctn in ctns)
|
|
|
|
|
{
|
|
|
|
|
ctn.CTNALL = ctnList.First(x => x.Code == ctn.CTNCODE).Name;
|
|
|
|
|
}
|
|
|
|
|
var servList = input.ServiceItemList.Adapt<List<BookingServiceItem>>();
|
|
|
|
|
|
|
|
|
|
await SaveData(custOrder, ctns, servList, ins);
|
|
|
|
|