From b4a315a8d773e1a8a82b0bd99e63b01a1f1d6dc4 Mon Sep 17 00:00:00 2001 From: cjy Date: Fri, 16 Aug 2024 18:53:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=B1=E5=8D=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Op/Method/ShippingBillService.cs | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/ShippingBillService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/ShippingBillService.cs index 12e8d94a..3fee84c6 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/ShippingBillService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/ShippingBillService.cs @@ -22,6 +22,7 @@ using Logger = NLog.Logger; using Newtonsoft.Json.Linq; using DS.Module.Core.Helpers; using Org.BouncyCastle.Ocsp; +using static AnyDiff.DifferenceLines; namespace DS.WMS.Core.Op.Method { @@ -164,7 +165,7 @@ namespace DS.WMS.Core.Op.Method data.DangerNo = string.Empty; } var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); - if (req.CtnInfo.Count > 0) + if (req.CtnInfo.IsNotNull() && req.CtnInfo.Count > 0) { foreach (var item in req.CtnInfo) @@ -211,7 +212,7 @@ namespace DS.WMS.Core.Op.Method it.BusinessId, }).ExecuteCommand(); - if (req.CtnInfo.Count > 0) + if (req.CtnInfo.IsNotNull() && req.CtnInfo.Count > 0) { var ctnList = tenantDb.Queryable().Where(x => x.Pid == req.Id).ToList(); foreach (var item in req.CtnInfo) @@ -250,6 +251,20 @@ namespace DS.WMS.Core.Op.Method { return await Task.FromResult(DataResult.Failed("数据不能为空!")); } + foreach (var item in list) + { + if (!string.IsNullOrEmpty(item.MBLNO) && !item.IsPart && tenantDb.Queryable().Where(x => x.MBLNO == item.MBLNO && x.Id!= item.Id).Any()) + { + return await Task.FromResult(DataResult.Failed("当前主单主提单号已存在,请勿重复录入!")); + } + + + if (!string.IsNullOrEmpty(item.HBLNO) && item.IsPart && tenantDb.Queryable().Where(x => x.MBLNO == item.MBLNO && x.HBLNO == item.HBLNO && x.Id != item.Id).Any()) + { + return await Task.FromResult(DataResult.Failed("当前分提单号已存在,请勿重复录入!")); + } + } + try { //开启事务 @@ -258,12 +273,7 @@ namespace DS.WMS.Core.Op.Method { if (item.Id == 0) - { - - if (!string.IsNullOrEmpty(item.MBLNO) && tenantDb.Queryable().Where(x => x.MBLNO == item.MBLNO && x.HBLNO == item.HBLNO).Any()) - { - return await Task.FromResult(DataResult.Failed("当前提单号已存在,请勿重复录入!")); - } + { var data = item.Adapt(); data.State = "已录入"; @@ -278,7 +288,7 @@ namespace DS.WMS.Core.Op.Method data.DangerNo = string.Empty; } var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); - if (item.CtnInfo.Count > 0) + if (item.CtnInfo.IsNotNull() && item.CtnInfo.Count > 0) { foreach (var item1 in item.CtnInfo) @@ -292,10 +302,7 @@ namespace DS.WMS.Core.Op.Method } else { - if (!string.IsNullOrEmpty(item.MBLNO) && tenantDb.Queryable().Where(x => x.Id != item.Id && x.MBLNO == item.MBLNO && x.HBLNO == item.HBLNO).Any()) - { - return await Task.FromResult(DataResult.Failed("当前提单号已存在,请勿重复录入!")); - } + var info = await tenantDb.Queryable().Where(x => x.Id == item.Id).FirstAsync(); if (info.State != "已录入") @@ -328,7 +335,7 @@ namespace DS.WMS.Core.Op.Method it.BusinessId, }).ExecuteCommandAsync(); - if (item.CtnInfo.Count > 0) + if (item.CtnInfo.IsNotNull() && item.CtnInfo.Count > 0) { var ctnList = tenantDb.Queryable().Where(x => x.Pid == item.Id).ToList(); foreach (var item1 in item.CtnInfo)