修改舱位合票的校验功能

master
jianghaiqing 5 months ago
parent c05de49334
commit 71f568acba

@ -3970,24 +3970,89 @@ namespace Myshipping.Application
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("/BookingSlot/GetMergeList")] [HttpPost("/BookingSlot/GetMergeList")]
public async Task<List<BookingSlotBaseWithCtnDto>> GetMergeList(QueryMergeSlotDto model) public async Task<BookingSlotMergeResultDto> GetMergeList(QueryMergeSlotDto model)
{ {
List<BookingGenerateMergeDetailDto> list = new List<BookingGenerateMergeDetailDto>(); BookingSlotMergeResultDto rlt = new BookingSlotMergeResultDto();
List<BookingSlotBase> slotList = new List<BookingSlotBase>();
if (model != null) if (model != null)
{ {
//var slotList = _repBase.AsQueryable().Where(a => model.MergeList.Contains(a.Id)).ToList(); /*
*/
//船公司、船名场次、合约号、承运方式(直达、中转)、订舱方式(合约订舱)、装货地、卸货地
slotList = _repBase.AsQueryable().Where(a => model.MergeList.Contains(a.Id) && a.IsDeleted == false).ToList();
//var importSlots = slotList.Select(a=> a.Adapt<BookingSlotBaseWithCtnDto>()).ToList(); //校验查询结果
//var checkResult = await CheckImportSlots(importSlots, 0); if (model.MergeList.Count != slotList.Count)
//if (!checkResult.isEnough) {
//{ var lostArg = model.MergeList.GroupJoin(slotList, l => l, r => r.Id, (l, r) =>
// throw Oops.Oh(checkResult.message); {
//} var currList = r.ToList();
if (currList.Count == 0)
return 0;
return l;
}).Where(a => a > 0).ToArray();
throw Oops.Oh($"部分舱位信息提取失败,请确认舱位是否存在或已作废");
}
if (slotList.Any(a => string.IsNullOrWhiteSpace(a.CARRIERID)
|| string.IsNullOrWhiteSpace(a.VESSEL) || string.IsNullOrWhiteSpace(a.VOYNO) || string.IsNullOrWhiteSpace(a.CONTRACT_NO)
|| string.IsNullOrWhiteSpace(a.CARRIAGE_TYPE) || string.IsNullOrWhiteSpace(a.BOOKING_SLOT_TYPE)
|| string.IsNullOrWhiteSpace(a.PORTLOADID) || string.IsNullOrWhiteSpace(a.PORTDISCHARGEID)))
{
throw Oops.Oh($"舱位合票校验失败,部分舱位的以下信息船公司、船名场次、合约号、承运方式、订舱方式、装货地、卸货地有空值情况");
}
var checkList = slotList.Select(a => new
{
key = $"{a.CARRIERID}_{a.VESSEL}_{a.VOYNO}_{a.CONTRACT_NO}_{a.CARRIAGE_TYPE}_{a.BOOKING_SLOT_TYPE}_{a.PORTLOADID}_{a.PORTDISCHARGEID}",
obj = a
}).ToList();
//如果汇总去重不惟一,不能进行合票操作
if (checkList.GroupBy(a => a.key).Count() > 1)
{
throw Oops.Oh($"舱位合票校验失败,船公司、船名场次、合约号、承运方式、订舱方式、装货地、卸货地不统一不能合票");
}
}
var list = await GetAvailableSlots(null, model.MergeList, null);
if(list.Count == 0)
throw Oops.Oh($"舱位合票失败,校验库存为不可用,请确认正确的库存");
//这里取完库存后,在跟请求的舱位做匹配,如果舱位没有库存了,提示错误终止合票
var stockCheckList = slotList.GroupJoin(list, l => l.Id, r => r.Id, (l, r) =>
{
var currList = r.ToList();
if (currList.Count == 0)
return new { Succ = false, No = l.SLOT_BOOKING_NO };
return new { Succ = true, No = l.SLOT_BOOKING_NO };
}).Where(a => !a.Succ).ToList();
if (stockCheckList.Count > 0)
{
throw Oops.Oh($"舱位合票失败,舱位提单号:{string.Join(",", stockCheckList.Select(a => a.No).ToArray())} 缺少库存");
}
rlt.slotDetailList = list;
string ctnStat = string.Empty;
if (list.Count > 0)
{
rlt.ctnStat = string.Join(",", list.SelectMany(a => a.CtnList).OrderBy(a=>a.CTNALL).GroupBy(a => a.CTNALL)
.Select(a => $"{a.Key}*{a.Sum(b => b.CTNNUM)}").ToArray());
} }
// 查询可用舱位及箱子列表 // 查询可用舱位及箱子列表
return await GetAvailableSlots(null, model.MergeList, null); return rlt;
} }
#endregion #endregion

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingSlot.Dto
{
/// <summary>
/// 舱位合并请求结果
/// </summary>
public class BookingSlotMergeResultDto
{
/// <summary>
/// 舱位明细
/// </summary>
public List<BookingSlotBaseWithCtnDto> slotDetailList { get; set; }
/// <summary>
/// 集装箱合计统计
/// </summary>
public string ctnStat { get; set; }
}
}

@ -166,7 +166,7 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
Task<List<BookingSlotBaseWithCtnDto>> GetMergeList(QueryMergeSlotDto model); Task<BookingSlotMergeResultDto> GetMergeList(QueryMergeSlotDto model);
/// <summary> /// <summary>
/// 生成合票订舱订单 /// 生成合票订舱订单

Loading…
Cancel
Save