添加接口:1.修改订舱台账前,验证箱信息的件尺重、封号是否会被覆盖 2. 订舱箱信息查询接口

optimize
zhangxiaofeng 9 months ago
parent 5406c55b47
commit 3ae6adeee4

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Myshipping.Application
{
/// <summary>
/// 验证箱信息是否会被覆盖Dto类
/// </summary>
public class CheckCtnCoverDto
{
public long BookingOrderId { get; set; }
public List<BookingCtnDto> CtnInputs { get; set; }
}
}

@ -2492,16 +2492,9 @@ namespace Myshipping.Application
if (main != null) if (main != null)
{ {
ordOut = main.Adapt<BookingOrderOutput>(); ordOut = main.Adapt<BookingOrderOutput>();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>(); List<BookingCtnDto> ctnDtoList = await GetBookingCtnDtoList(Id);
var ctnIdlist = ctnlist.Select(x => x.Id).ToList(); ordOut.ctnInputs = ctnDtoList;
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => ctnIdlist.Contains((long)x.CTNID)).ToListAsync();
foreach (var item in ctninput)
{
var _ctndetaillist = ctndetaillist.Where(x => x.CTNID == item.Id).ToList();
item.ctnDetailInputs = _ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
ordOut.ctnInputs = ctninput;
// 返回关联的舱位信息 // 返回关联的舱位信息
var slotList = await _repSlotAllocation.AsQueryable() var slotList = await _repSlotAllocation.AsQueryable()
@ -2537,16 +2530,9 @@ namespace Myshipping.Application
HbList = _hblist.Adapt<List<BookingOrderDto>>(); HbList = _hblist.Adapt<List<BookingOrderDto>>();
foreach (var item in HbList) foreach (var item in HbList)
{ {
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == item.Id).ToListAsync(); List<BookingCtnDto> ctnDtoList = await GetBookingCtnDtoList(item.Id);
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>(); ordOut.ctnInputs = ctnDtoList;
var ctnIdlist = ctnlist.Select(x => x.Id).ToList();
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => ctnIdlist.Contains((long)x.CTNID)).ToListAsync();
foreach (var it in ctninput)
{
var _ctndetaillist = ctndetaillist.Where(x => x.CTNID == item.Id).ToList();
it.ctnDetailInputs = _ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
item.ctnInputs = ctninput;
//检索EDI扩展 //检索EDI扩展
var ediExt = _bookingEDIExt.FirstOrDefault(u => u.BookingId == item.Id); var ediExt = _bookingEDIExt.FirstOrDefault(u => u.BookingId == item.Id);
@ -2568,6 +2554,67 @@ namespace Myshipping.Application
return ordOut; return ordOut;
} }
/// <summary>
/// 根据订舱记录主键获取箱信息Dto列表
/// </summary>
/// <param name="orderId">订舱记录主键</param>
/// <returns>箱信息Dto列表</returns>
[HttpGet("/BookingOrder/GetCtnList")]
public async Task<List<BookingCtnDto>> GetBookingCtnDtoList(long orderId)
{
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == orderId).ToListAsync();
var ctnDtoList = ctnlist.Adapt<List<BookingCtnDto>>();
var ctnIdlist = ctnlist.Select(x => x.Id).ToList();
var ctnDetaiList = await _ctndetailrep.AsQueryable().Where(x => ctnIdlist.Contains((long)x.CTNID)).ToListAsync();
foreach (var item in ctnDtoList)
{
var _ctndetaillist = ctnDetaiList.Where(x => x.CTNID == item.Id).ToList();
item.ctnDetailInputs = _ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
return ctnDtoList;
}
/// <summary>
/// 修改订舱台账前,验证箱信息的件尺重、封号是否会被覆盖
/// </summary>
/// <returns>true:会被覆盖false:不会被覆盖</returns>
[HttpGet("/BookingOrder/CheckCtnCover")]
public async Task<bool> CheckCtnCover(CheckCtnCoverDto checkCtnDto)
{
// 如果保存时没有箱信息,则不认为会被覆盖
if (checkCtnDto.CtnInputs?.Any() != true)
{
return false;
}
List<BookingCtnDto> ctnDtoList = await GetBookingCtnDtoList(checkCtnDto.BookingOrderId);
// 如果之前没有箱信息,则不认为会被覆盖
if (ctnDtoList?.Any() != true)
{
return false;
}
var oldIdList = ctnDtoList.Select(c => c.Id);
var newIdList = checkCtnDto.CtnInputs.Select(c => c.Id);
var existsIdList = oldIdList.Intersect(newIdList);
var existsCtnList = ctnDtoList.Where(c => existsIdList.Contains(c.Id));
foreach (var oldCtn in existsCtnList)
{
var newCtn = checkCtnDto.CtnInputs.First(c => c.Id == oldCtn.Id);
if (oldCtn.SEALNO != newCtn.SEALNO
|| oldCtn.PKGS != newCtn.PKGS
|| oldCtn.KGS != newCtn.KGS
|| oldCtn.CBM != newCtn.CBM)
{
return true;
}
}
return false;
}
#endregion #endregion
#region 批量编辑相关 #region 批量编辑相关

Loading…
Cancel
Save