From 52569c7d6304ef4cd93542a08a6edbe02a3e1bcb Mon Sep 17 00:00:00 2001 From: payne <bzrlw2012@163.com> Date: 周四, 25 4月 2024 10:46:19 +0800 Subject: [PATCH] 客户档案 调整 --- iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/BaseCustomer/BaseCustomerService.cs | 114 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 57 insertions(+), 57 deletions(-) diff --git a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/BaseCustomer/BaseCustomerService.cs b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/BaseCustomer/BaseCustomerService.cs index c4da487..377dc53 100644 --- a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/BaseCustomer/BaseCustomerService.cs +++ b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/BaseCustomer/BaseCustomerService.cs @@ -404,78 +404,78 @@ /// <param name="input"></param> /// <param name="isEdit"></param> /// <returns></returns> - private async Task CheckExisit( BaseCustomer input,bool isEdit=false) + private async Task CheckExisit(BaseCustomer input, bool isEdit = false) { - - - bool isExist = false; - if (!isEdit)//鏂板 - { - //鏁版嵁鏄惁瀛樺湪閲嶅 - isExist = await _baseCustomerRep.AnyAsync(u => - u.CustChinaName.Equals(input.CustChinaName) - ,false); - } - else//缂栬緫 - { - - - //褰撳墠缂栬緫鏁版嵁浠ュ鏄惁瀛樺湪閲嶅 - isExist = await _baseCustomerRep.AnyAsync(u => - u.Id != input.Id - &&u.CustChinaName.Equals(input.CustChinaName) - ,false); - } - - + + bool isExist = false; + if (!isEdit)//鏂板 + { + //鏁版嵁鏄惁瀛樺湪閲嶅 + isExist = await _baseCustomerRep.AnyAsync(u => + u.CustChinaName.Equals(input.CustChinaName) + , false); + } + else//缂栬緫 + { + + + + //褰撳墠缂栬緫鏁版嵁浠ュ鏄惁瀛樺湪閲嶅 + isExist = await _baseCustomerRep.AnyAsync(u => + u.Id != input.Id + && u.CustChinaName.Equals(input.CustChinaName) + , false); + } + + if (isExist) throw Oops.Oh(ErrorCode.E0001); - } - + } + /// <summary> /// 鏍规嵁鑱斿悎涓婚敭楠岃瘉鏁版嵁鏄惁宸插瓨鍦�-瀵煎叆鏃堕獙璇� /// </summary> /// <param name="inputs"></param> /// <returns></returns> private async Task CheckExisitForImport(List<BaseCustomer> inputs) - { + { //鏍规嵁鑱斿悎涓婚敭楠岃瘉琛ㄦ牸涓腑鏄惁宸插瓨鍦ㄧ浉鍚屾暟鎹� - if (inputs?.Count <= 0) - { - throw Oops.Oh($"瀵煎叆鏁版嵁涓嶈兘涓虹┖"); - } - //鏁版嵁鏄惁閲嶅 - var existExcelItem = inputs.GroupBy(g => new { - g.CustChinaName - }) - .Where(g => g.Count() > 1) - .Select(s => new { - s.Key.CustChinaName - }).FirstOrDefault(); - if (existExcelItem != null) - { - var item= existExcelItem.Adapt<BaseCustomer>(); - throw Oops.Oh($"瀵煎叆鐨勮〃鏍间腑,瀹㈡埛涓枃鍚嶇О[{item.CustChinaName}]宸插瓨鍦�"); - } - + if (inputs?.Count <= 0) + { + throw Oops.Oh($"瀵煎叆鏁版嵁涓嶈兘涓虹┖"); + } + //鏁版嵁鏄惁閲嶅 + var existExcelItem = inputs.GroupBy(g => new { + g.CustChinaName + }) + .Where(g => g.Count() > 1) + .Select(s => new { + s.Key.CustChinaName + }).FirstOrDefault(); + if (existExcelItem != null) + { + var item = existExcelItem.Adapt<BaseCustomer>(); + throw Oops.Oh($"瀵煎叆鐨勮〃鏍间腑,瀹㈡埛涓枃鍚嶇О[{item.CustChinaName}]宸插瓨鍦�"); + } - //鏍规嵁鑱斿悎涓婚敭楠岃瘉鏁版嵁搴撲腑鏄惁宸插瓨鍦ㄧ浉鍚屾暟鎹� - var existDBItem = await _baseCustomerRep.DetachedEntities.FirstOrDefaultAsync(w=> - inputs.Select(s=>"" - +s.CustChinaName - ) - .Contains("" - +w.CustChinaName - )); - if (existDBItem != null) - { - var item= existDBItem.Adapt<BaseCustomer>(); - throw Oops.Oh($"绯荤粺涓�,瀹㈡埛涓枃鍚嶇О[{item.CustChinaName}]宸插瓨鍦�"); - } + + //鏍规嵁鑱斿悎涓婚敭楠岃瘉鏁版嵁搴撲腑鏄惁宸插瓨鍦ㄧ浉鍚屾暟鎹� + var existDBItem = await _baseCustomerRep.DetachedEntities.FirstOrDefaultAsync(w => + inputs.Select(s => "" + + s.CustChinaName + ) + .Contains("" + + w.CustChinaName + )); + if (existDBItem != null) + { + var item = existDBItem.Adapt<BaseCustomer>(); + throw Oops.Oh($"绯荤粺涓�,瀹㈡埛涓枃鍚嶇О[{item.CustChinaName}]宸插瓨鍦�"); + } } #endregion -- Gitblit v1.9.3