From bf915c71f7ab3fcd9a7f81ed18f3a10c68d50dc0 Mon Sep 17 00:00:00 2001 From: payne <bzrlw2012@163.com> Date: 周四, 25 4月 2024 10:35:45 +0800 Subject: [PATCH] 客户档案调整 --- iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/BaseCustomer/BaseCustomerService.cs | 89 +++++++++++++------------------------------- 1 files changed, 26 insertions(+), 63 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 b8be889..c4da487 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 @@ -51,11 +51,10 @@ { var baseCustomers = await _baseCustomerRep.DetachedEntities .Where(!string.IsNullOrEmpty(input.CustCode), u => u.CustCode == input.CustCode) - .Where(!string.IsNullOrEmpty(input.CustChinaName), u => EF.Functions.Like(u.CustChinaName, $"%{input.CustChinaName.Trim()}%")) + .Where(!string.IsNullOrEmpty(input.CustChinaName), u => u.CustChinaName == input.CustChinaName) .Where(!string.IsNullOrEmpty(input.CustEnglishName), u => u.CustEnglishName == input.CustEnglishName) .Where(!string.IsNullOrEmpty(input.MnemonicCode), u => u.MnemonicCode == input.MnemonicCode) .Where(input.CustType != null, u => u.CustType == input.CustType) - .Where(!string.IsNullOrEmpty(input.CustTypeName), u => u.CustTypeName == input.CustTypeName) .Where(!string.IsNullOrEmpty(input.LinkMan), u => u.LinkMan == input.LinkMan) .Where(!string.IsNullOrEmpty(input.Phone), u => u.Phone == input.Phone) .Where(!string.IsNullOrEmpty(input.Email), u => u.Email == input.Email) @@ -87,7 +86,6 @@ var pCustEnglishName = input.CustEnglishName?.Trim() ?? ""; var pMnemonicCode = input.MnemonicCode?.Trim() ?? ""; var pCustType = input.CustType; - var pCustTypeName = input.CustTypeName?.Trim() ?? ""; var pLinkMan = input.LinkMan?.Trim() ?? ""; var pPhone = input.Phone?.Trim() ?? ""; var pEmail = input.Email?.Trim() ?? ""; @@ -102,11 +100,10 @@ var pUpdatedUserName = input.UpdatedUserName?.Trim() ?? ""; var baseCustomers = await _baseCustomerRep.DetachedEntities .Where(!string.IsNullOrEmpty(pCustCode), u => u.CustCode == pCustCode) - .Where(!string.IsNullOrEmpty(pCustChinaName), u => EF.Functions.Like(u.CustChinaName, $"%{pCustChinaName}%")) + .Where(!string.IsNullOrEmpty(pCustChinaName), u => u.CustChinaName == pCustChinaName) .Where(!string.IsNullOrEmpty(pCustEnglishName), u => u.CustEnglishName == pCustEnglishName) .Where(!string.IsNullOrEmpty(pMnemonicCode), u => u.MnemonicCode == pMnemonicCode) .Where(pCustType != null, u => u.CustType == pCustType) - .Where(!string.IsNullOrEmpty(pCustTypeName), u => u.CustTypeName == pCustTypeName) .Where(!string.IsNullOrEmpty(pLinkMan), u => u.LinkMan == pLinkMan) .Where(!string.IsNullOrEmpty(pPhone), u => u.Phone == pPhone) .Where(!string.IsNullOrEmpty(pEmail), u => u.Email == pEmail) @@ -158,9 +155,11 @@ public async Task Add(AddBaseCustomerInput input) { var baseCustomer = input.Adapt<BaseCustomer>(); - //楠岃瘉 - await CheckExisit(baseCustomer); + baseCustomer.CustCode = Yitter.IdGenerator.YitIdHelper.NextId().ToString();//TODO 瑕佽皟鐢ㄧ敓鎴� 缂栧彿鐨勬柟娉� 鍏堢敤闆姳ID + baseCustomer.CustTypeName = baseCustomer.CustType.ToString(); + //楠岃瘉 + await CheckExisit(baseCustomer); baseCustomer.CreatedUserId = baseCustomer.UpdatedUserId = SysHelper.GetUserId(); baseCustomer.CreatedUserName = baseCustomer.UpdatedUserName = SysHelper.GetUserName(); baseCustomer.CreatedTime = baseCustomer.UpdatedTime = SysHelper.GetNowTime(); @@ -247,20 +246,20 @@ var addItem = new BaseCustomer() { + CustCode = Yitter.IdGenerator.YitIdHelper.NextId().ToString(),//TODO 瑕佽皟鐢ㄧ敓鎴� 缂栧彿鐨勬柟娉� 鍏堢敤闆姳ID CreatedTime = SysHelper.GetNowTime(), CreatedUserId = SysHelper.GetUserId(), CreatedUserName = SysHelper.GetUserName(), UpdatedTime = SysHelper.GetNowTime(), UpdatedUserId = SysHelper.GetUserId(), UpdatedUserName = SysHelper.GetUserName() + }; #region 瀹氫箟鍙橀噺 - var _CustCode = "";//瀹㈡埛缂栧彿 var _CustChinaName = "";//瀹㈡埛涓枃鍚嶇О var _CustEnglishName = "";//瀹㈡埛鑻辨枃鍚嶇О var _MnemonicCode = "";//鍔╄鐮� var _CustType = "";//绫诲瀷 - var _CustTypeName = "";//绫诲瀷鍚嶇О var _LinkMan = "";//鑱旂郴浜� var _Phone = "";//鐢佃瘽 var _Email = "";//鐢靛瓙閭欢 @@ -269,17 +268,14 @@ var _City = "";//鍩庡競 var _Address = "";//鍦板潃 var _IsDisabled = "";//鏄惁绂佺敤 - var _Id = "";//Id涓婚敭 #endregion #region 鍙栧�� - _CustCode = row["瀹㈡埛缂栧彿"]?.ToString() ; _CustChinaName = row["瀹㈡埛涓枃鍚嶇О"]?.ToString() ; _CustEnglishName = row["瀹㈡埛鑻辨枃鍚嶇О"]?.ToString() ; _MnemonicCode = row["鍔╄鐮�"]?.ToString() ; _CustType = row["绫诲瀷"]?.ToString() ; - _CustTypeName = row["绫诲瀷鍚嶇О"]?.ToString() ; _LinkMan = row["鑱旂郴浜�"]?.ToString() ; _Phone = row["鐢佃瘽"]?.ToString() ; _Email = row["鐢靛瓙閭欢"]?.ToString() ; @@ -287,22 +283,11 @@ _Province = row["鐪佷唤"]?.ToString() ; _City = row["鍩庡競"]?.ToString() ; _Address = row["鍦板潃"]?.ToString() ; - _IsDisabled = row["鏄惁绂佺敤"]?.ToString() ; - _Id = row["Id涓婚敭"]?.ToString() ; + #endregion #region 楠岃瘉 - - if (string.IsNullOrEmpty(_CustCode)) - { - throw Oops.Oh($"绗瑊index}琛孾瀹㈡埛缂栧彿]{_CustCode}涓嶈兘涓虹┖锛�"); - } - - if(!string.IsNullOrEmpty(_CustCode)) - { - addItem.CustCode = (string)_CustCode; - } if (string.IsNullOrEmpty(_CustChinaName)) { @@ -329,23 +314,18 @@ if(!string.IsNullOrEmpty(_CustType)) { - if (!int.TryParse(_CustType, out int outCustType)&&!string.IsNullOrEmpty(_CustType)) + Admin.NET.Core.BaseCustomerTypeEnum enumCustType = default(Admin.NET.Core.BaseCustomerTypeEnum); + + if(!Enum.TryParse<Admin.NET.Core.BaseCustomerTypeEnum>(_CustType, out enumCustType)&&!string.IsNullOrEmpty(_CustType)) { - throw Oops.Oh($"绗瑊index}琛孾绫诲瀷]{_CustType}鍊间笉姝g‘锛�"); - } - if (outCustType <= 0&&!string.IsNullOrEmpty(_CustType)) - { - throw Oops.Oh($"绗瑊index}琛孾绫诲瀷]{_CustType}鍊间笉鑳藉皬浜庣瓑浜�0锛�"); + throw Oops.Oh($"绗瑊index}琛孾绫诲瀷]{_CustType}鍊间笉姝g‘锛�"); } else { - addItem.CustType = outCustType; + addItem.CustType = enumCustType; + addItem.CustTypeName = addItem.CustType.ToString(); } - } - if(!string.IsNullOrEmpty(_CustTypeName)) - { - addItem.CustTypeName = (string)_CustTypeName; } if(!string.IsNullOrEmpty(_LinkMan)) { @@ -386,24 +366,9 @@ bool outIsDisabled = _IsDisabled.Equals("鏄�") ? true : false; addItem.IsDisabled = outIsDisabled; } - } + } - if(!string.IsNullOrEmpty(_Id)) - { - if (!long.TryParse(_Id, out long outId)&&!string.IsNullOrEmpty(_Id)) - { - throw Oops.Oh($"绗瑊index}琛孾Id涓婚敭]{_Id}鍊间笉姝g‘锛�"); - } - if (outId <= 0&&!string.IsNullOrEmpty(_Id)) - { - throw Oops.Oh($"绗瑊index}琛孾Id涓婚敭]{_Id}鍊间笉鑳藉皬浜庣瓑浜�0锛�"); - } - else - { - addItem.Id = outId; - } - - } + #endregion @@ -449,7 +414,7 @@ { //鏁版嵁鏄惁瀛樺湪閲嶅 isExist = await _baseCustomerRep.AnyAsync(u => - u.CustCode.Equals(input.CustCode) + u.CustChinaName.Equals(input.CustChinaName) ,false); } else//缂栬緫 @@ -460,7 +425,7 @@ //褰撳墠缂栬緫鏁版嵁浠ュ鏄惁瀛樺湪閲嶅 isExist = await _baseCustomerRep.AnyAsync(u => u.Id != input.Id - &&u.CustCode.Equals(input.CustCode) + &&u.CustChinaName.Equals(input.CustChinaName) ,false); } @@ -483,17 +448,16 @@ } //鏁版嵁鏄惁閲嶅 var existExcelItem = inputs.GroupBy(g => new { - g.CustCode + g.CustChinaName }) .Where(g => g.Count() > 1) .Select(s => new { - s.Key.CustCode + s.Key.CustChinaName }).FirstOrDefault(); if (existExcelItem != null) { - var baseCustomer = existExcelItem.Adapt<BaseCustomer>(); var item= existExcelItem.Adapt<BaseCustomer>(); - throw Oops.Oh($"瀵煎叆鐨勮〃鏍间腑,瀹㈡埛缂栧彿[{item.CustCode}]宸插瓨鍦�"); + throw Oops.Oh($"瀵煎叆鐨勮〃鏍间腑,瀹㈡埛涓枃鍚嶇О[{item.CustChinaName}]宸插瓨鍦�"); } @@ -502,16 +466,15 @@ //鏍规嵁鑱斿悎涓婚敭楠岃瘉鏁版嵁搴撲腑鏄惁宸插瓨鍦ㄧ浉鍚屾暟鎹� var existDBItem = await _baseCustomerRep.DetachedEntities.FirstOrDefaultAsync(w=> inputs.Select(s=>"" - +s.CustCode + +s.CustChinaName ) .Contains("" - +w.CustCode + +w.CustChinaName )); if (existDBItem != null) { - var baseCustomer = existExcelItem.Adapt<BaseCustomer>(); - var item= existExcelItem.Adapt<BaseCustomer>(); - throw Oops.Oh($"绯荤粺涓�,瀹㈡埛缂栧彿[{item.CustCode}]宸插瓨鍦�"); + var item= existDBItem.Adapt<BaseCustomer>(); + throw Oops.Oh($"绯荤粺涓�,瀹㈡埛涓枃鍚嶇О[{item.CustChinaName}]宸插瓨鍦�"); } } -- Gitblit v1.9.3