From eae3206966414c64ed971f25a6139410f19596e9 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Fri, 4 Nov 2022 16:06:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E8=88=B1=E6=98=8E=E7=BB=86=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 4ec5c538..27432140 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -204,24 +204,29 @@ namespace Myshipping.Application { JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail"); JsonUtil.TrimFields(input); - ////// - var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}"); - input.CNTRTOTAL = string.Join(" / ", groupList); + if (input.ctnInputs!=null) { + var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}"); + input.CNTRTOTAL = string.Join(" / ", groupList); + } + var entity = input.Adapt(); await _rep.InsertAsync(entity); - foreach (var item in input.ctnInputs) - { - var ctnentity = item.Adapt(); - ctnentity.BILLID = entity.Id; - await _repCtn.InsertAsync(ctnentity); - foreach (var it in item.ctnDetailInputs) + if (input.ctnInputs != null) { + foreach (var item in input.ctnInputs) { - var ctndetail = it.Adapt(); - ctndetail.CTNID = ctnentity.Id; - await _ctndetailrep.InsertAsync(ctndetail); + var ctnentity = item.Adapt(); + ctnentity.BILLID = entity.Id; + await _repCtn.InsertAsync(ctnentity); + foreach (var it in item.ctnDetailInputs) + { + var ctndetail = it.Adapt(); + ctndetail.CTNID = ctnentity.Id; + await _ctndetailrep.InsertAsync(ctndetail); + } } } + ////添加booking日志 await _bookinglog.InsertAsync(new BookingLog { @@ -261,26 +266,32 @@ namespace Myshipping.Application JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail"); JsonUtil.TrimFields(input); - var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}"); - input.CNTRTOTAL = string.Join(" / ", groupList); + if (input.ctnInputs!=null) { + var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}"); + input.CNTRTOTAL = string.Join(" / ", groupList); + + } var main = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync(); await _repCtn.DeleteAsync(x => x.BILLID == input.Id); await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID)); - foreach (var item in input.ctnInputs) - { - var ctnentity = item.Adapt(); - ctnentity.BILLID = entity.Id; - await _repCtn.InsertAsync(ctnentity); - foreach (var it in item.ctnDetailInputs) + if (input.ctnInputs != null) { + foreach (var item in input.ctnInputs) { - var ctndetail = it.Adapt(); - ctndetail.CTNID = ctnentity.Id; - await _ctndetailrep.InsertAsync(ctndetail); + var ctnentity = item.Adapt(); + ctnentity.BILLID = entity.Id; + await _repCtn.InsertAsync(ctnentity); + foreach (var it in item.ctnDetailInputs) + { + var ctndetail = it.Adapt(); + ctndetail.CTNID = ctnentity.Id; + await _ctndetailrep.InsertAsync(ctndetail); + } } } + bool flag = true; long bid = 0; foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))