diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 78f65f2e..3fc51009 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -333,21 +333,29 @@ namespace Myshipping.Application var ctnentity = item.Adapt(); ctnentity.BILLID = entity.Id; await _repCtn.InsertAsync(ctnentity); - foreach (var it in item.ctnDetailInputs) + + //这里保存有可能没有添加多品名,所有箱下没有货物信息 + if (item.ctnDetailInputs != null) { - var ctndetail = it.Adapt(); - ctndetail.CTNID = ctnentity.Id; - await _ctndetailrep.InsertAsync(ctndetail); + foreach (var it in item.ctnDetailInputs) + { + var ctndetail = it.Adapt(); + ctndetail.CTNID = ctnentity.Id; + await _ctndetailrep.InsertAsync(ctndetail); + } } } } - //写入EDI扩展 - var ediExtEntity = input.BookingEDIExt.Adapt(); + if (input.BookingEDIExt != null) + { + //写入EDI扩展 + var ediExtEntity = input.BookingEDIExt.Adapt(); - ediExtEntity.BookingId = entity.Id; + ediExtEntity.BookingId = entity.Id; - await _bookingEDIExt.InsertAsync(ediExtEntity); + await _bookingEDIExt.InsertAsync(ediExtEntity); + } ////添加booking日志 await _bookinglog.InsertAsync(new BookingLog @@ -444,27 +452,30 @@ namespace Myshipping.Application } } - //检索EDI扩展 - var ediExtEntity = await _bookingEDIExt.FirstOrDefaultAsync(u => u.BookingId == input.Id); - - if(ediExtEntity == null) + if (input.BookingEDIExt != null) { - //写入EDI扩展 - ediExtEntity = input.BookingEDIExt.Adapt(); - ediExtEntity.BookingId = entity.Id; + //检索EDI扩展 + var ediExtEntity = await _bookingEDIExt.FirstOrDefaultAsync(u => u.BookingId == input.Id); - await _bookingEDIExt.InsertAsync(ediExtEntity); - } - else - { - //更新EDI扩展 - var currEdiExtEntity = input.BookingEDIExt.Adapt(); + if (ediExtEntity == null) + { + //写入EDI扩展 + ediExtEntity = input.BookingEDIExt.Adapt(); + ediExtEntity.BookingId = entity.Id; + + await _bookingEDIExt.InsertAsync(ediExtEntity); + } + else + { + //更新EDI扩展 + var currEdiExtEntity = input.BookingEDIExt.Adapt(); - currEdiExtEntity.Id = ediExtEntity.Id; - currEdiExtEntity.BookingId = ediExtEntity.BookingId; + currEdiExtEntity.Id = ediExtEntity.Id; + currEdiExtEntity.BookingId = ediExtEntity.BookingId; - await _bookingEDIExt.AsUpdateable(ediExtEntity).IgnoreColumns(new string[] { nameof(ediExtEntity.Id), + await _bookingEDIExt.AsUpdateable(ediExtEntity).IgnoreColumns(new string[] { nameof(ediExtEntity.Id), nameof(ediExtEntity.BookingId) }).ExecuteCommandAsync(); + } }