From 96294e88135f07c1c3794c9dc2224bd7ca3ab986 Mon Sep 17 00:00:00 2001
From: liuying <1427574514@qq.com>
Date: 周二, 23 4月 2024 21:01:38 +0800
Subject: [PATCH] 物料信息

---
 iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsContainerPackaging/WmsContainerPackagingService.cs |   86 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 1 deletions(-)

diff --git a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsContainerPackaging/WmsContainerPackagingService.cs b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsContainerPackaging/WmsContainerPackagingService.cs
index c2759c1..75de536 100644
--- a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsContainerPackaging/WmsContainerPackagingService.cs
+++ b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsContainerPackaging/WmsContainerPackagingService.cs
@@ -253,6 +253,12 @@
                           
                           
                           #region 楠岃瘉
+                          
+                          if (string.IsNullOrEmpty(_ContainerTypeId))
+                          {
+                            throw Oops.Oh($"绗瑊index}琛孾瀹瑰櫒绫诲瀷ID]{_ContainerTypeId}涓嶈兘涓虹┖锛�");
+                          }
+                          
                           if(!string.IsNullOrEmpty(_ContainerTypeId))
                           {
                               if (!long.TryParse(_ContainerTypeId, out long outContainerTypeId)&&!string.IsNullOrEmpty(_ContainerTypeId))
@@ -269,10 +275,22 @@
                               }
                           
                           }
+                          
+                          if (string.IsNullOrEmpty(_ContainerTypeName))
+                          {
+                            throw Oops.Oh($"绗瑊index}琛孾瀹瑰櫒绫诲瀷鍚嶇О]{_ContainerTypeName}涓嶈兘涓虹┖锛�");
+                          }
+                          
                           if(!string.IsNullOrEmpty(_ContainerTypeName))
                           {
                                 addItem.ContainerTypeName = (string)_ContainerTypeName;
                            }
+                          
+                          if (string.IsNullOrEmpty(_MaterialTypeId))
+                          {
+                            throw Oops.Oh($"绗瑊index}琛孾鐗╂枡绫诲瀷ID]{_MaterialTypeId}涓嶈兘涓虹┖锛�");
+                          }
+                          
                           if(!string.IsNullOrEmpty(_MaterialTypeId))
                           {
                               if (!long.TryParse(_MaterialTypeId, out long outMaterialTypeId)&&!string.IsNullOrEmpty(_MaterialTypeId))
@@ -289,14 +307,32 @@
                               }
                           
                           }
+                          
+                          if (string.IsNullOrEmpty(_MaterialTypeCode))
+                          {
+                            throw Oops.Oh($"绗瑊index}琛孾鐗╂枡绫诲瀷缂栧彿]{_MaterialTypeCode}涓嶈兘涓虹┖锛�");
+                          }
+                          
                           if(!string.IsNullOrEmpty(_MaterialTypeCode))
                           {
                                 addItem.MaterialTypeCode = (string)_MaterialTypeCode;
                            }
+                          
+                          if (string.IsNullOrEmpty(_MaterialTypeName))
+                          {
+                            throw Oops.Oh($"绗瑊index}琛孾鐗╂枡绫诲瀷鍚嶇О]{_MaterialTypeName}涓嶈兘涓虹┖锛�");
+                          }
+                          
                           if(!string.IsNullOrEmpty(_MaterialTypeName))
                           {
                                 addItem.MaterialTypeName = (string)_MaterialTypeName;
                            }
+                          
+                          if (string.IsNullOrEmpty(_BoxQty))
+                          {
+                            throw Oops.Oh($"绗瑊index}琛孾鐗╂枡瀹瑰櫒瀹归噺]{_BoxQty}涓嶈兘涓虹┖锛�");
+                          }
+                          
                           if(!string.IsNullOrEmpty(_BoxQty))
                           {
                               if (!decimal.TryParse(_BoxQty, out decimal outBoxQty)&&!string.IsNullOrEmpty(_BoxQty))
@@ -369,13 +405,29 @@
            
 
            
+           bool isExist = false;
+           if (!isEdit)//鏂板
+           {
+                   //鏁版嵁鏄惁瀛樺湪閲嶅
+                   isExist = await _wmsContainerPackagingRep.AnyAsync(u =>
+                                   u.ContainerTypeId.Equals(input.ContainerTypeId)
+                   ,false);
+          }
+           else//缂栬緫 
+          {
 
           
                 
+                 //褰撳墠缂栬緫鏁版嵁浠ュ鏄惁瀛樺湪閲嶅
+                  isExist = await _wmsContainerPackagingRep.AnyAsync(u => 
+                                    u.Id != input.Id
+                                    &&u.ContainerTypeId.Equals(input.ContainerTypeId)
+                    ,false);
+               }
                
         
 
-            //娌℃湁閰嶇疆鑱斿悎涓婚敭锛屼笉闇�瑕侀獙閲�
+            if (isExist) throw Oops.Oh(ErrorCode.E0001);
        }
         
         /// <summary>
@@ -386,10 +438,42 @@
         private async Task CheckExisitForImport(List<WmsContainerPackaging> inputs)
         { 
             //鏍规嵁鑱斿悎涓婚敭楠岃瘉琛ㄦ牸涓腑鏄惁宸插瓨鍦ㄧ浉鍚屾暟鎹�  
+                 if (inputs?.Count <= 0)
+                 {
+                     throw Oops.Oh($"瀵煎叆鏁版嵁涓嶈兘涓虹┖");
+                 }
+                 //鏁版嵁鏄惁閲嶅
+                 var existExcelItem = inputs.GroupBy(g => new {
+                                               g.ContainerTypeId
+                                               })
+                                               .Where(g => g.Count() > 1)
+                                               .Select(s => new {
+                                               s.Key.ContainerTypeId
+                                               }).FirstOrDefault();
+                 if (existExcelItem != null)
+                 {
+                   var wmsContainerPackaging = existExcelItem.Adapt<WmsContainerPackaging>();
+                   var item= existExcelItem.Adapt<WmsContainerPackaging>();
+                   throw Oops.Oh($"瀵煎叆鐨勮〃鏍间腑,瀹瑰櫒绫诲瀷ID[{item.ContainerTypeId}]宸插瓨鍦�");
+                 }
                       
 
 
 
+    //鏍规嵁鑱斿悎涓婚敭楠岃瘉鏁版嵁搴撲腑鏄惁宸插瓨鍦ㄧ浉鍚屾暟鎹�
+                 var existDBItem = await _wmsContainerPackagingRep.DetachedEntities.FirstOrDefaultAsync(w=> 
+                                                                         inputs.Select(s=>""
+                                                                           +s.ContainerTypeId
+                                                                        )
+                                                                        .Contains(""
+                                                                         +w.ContainerTypeId
+                  ));
+                  if (existDBItem != null)
+                 {
+                   var wmsContainerPackaging = existExcelItem.Adapt<WmsContainerPackaging>();
+                   var item= existExcelItem.Adapt<WmsContainerPackaging>();
+                   throw Oops.Oh($"绯荤粺涓�,瀹瑰櫒绫诲瀷ID[{item.ContainerTypeId}]宸插瓨鍦�");
+                 }
         }
 
         #endregion

--
Gitblit v1.9.3