From b478031d19c13092dc5f86e6d4f7fc114ea9a85d Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@DESKTOP-5BIMHQ3>
Date: 星期一, 11 三月 2024 13:28:29 +0800
Subject: [PATCH] Merge branch 'wxw'

---
 Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs |   75 +++++++++++++++++++++++++------------
 1 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
index 9c0ad7a..26c7d4e 100644
--- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
@@ -264,7 +264,7 @@
                   .AndIF(!string.IsNullOrWhiteSpace(model.ProductionTime), it => it.ProductionTime >= Convert.ToDateTime(model.ProductionTime))
                   .AndIF(!string.IsNullOrWhiteSpace(model.InspectMark), it => it.InspectMark == model.InspectMark.Trim())
                   .AndIF(!string.IsNullOrWhiteSpace(model.BitBoxMark), it => it.BitBoxMark == model.BitBoxMark.Trim())
-                  .AndIF(!string.IsNullOrWhiteSpace(model.Origin), it => it.Origin == model.Origin.Trim())
+                  .AndIF(!string.IsNullOrWhiteSpace(model.Origin), it => model.Origin.Trim().Contains(it.Origin))
                   .And(m => m.SkuNo != "100099" && m.IsDel == "0" && m.Status == "0")
                   .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
                 var total = 0;
@@ -605,7 +605,7 @@
                     zNum = Convert.ToInt32(pack.L1Num);
                 }
 
-                if (packLevel <= 1)//鍖呰绛夌骇灏忎簬1锛屾寜鐓�1绾ф爣绛炬墦鍗�
+                if (packLevel < 1)//鍖呰绛夌骇灏忎簬1锛屾寜鐓�1绾ф爣绛炬墦鍗�
                 {
                     throw new Exception("鍖呰淇℃伅鏈夎锛屽皬浜庝竴绾�");
                 }
@@ -614,11 +614,11 @@
                 var modelList = new List<BllBoxInfo>();
 
                 var addLotNo = "";
-                if (arriveQty < 0)
+                if (arriveQty <= 0)
                 {
-                    throw new Exception("鍒拌揣鏁伴噺涓嶈兘灏忎簬0!");
+                    throw new Exception("鍒拌揣鏁伴噺涓嶈兘灏忎簬绛変簬0!");
                 }
-
+                Db.BeginTran();
                 if (packLevel == 1)
                 {
                     #region 涓�绾у寘瑁�
@@ -664,17 +664,31 @@
                     
                     if (isReset == "0")
                     {
-                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
-                        if (labelCount.Count <=0)
+                        //鍒ゆ柇鍗曟嵁鏄惁鏄綑鏂欓��鍥炲崟
+                        if (asn.Type == "4")
                         {
-                            throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            maxLotNoStr = asnList.LotNo;
+                            maxBoxCode = label.Where(m=>m.LotNo == maxLotNoStr).Max(a => a.BoxNo);
+                            if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                            {
+                                throw new Exception("杞﹂棿浣欐枡閫�鍥炲崟鎹壒娆′笉鑳戒负绌�");
+                            }
                         }
-                        maxLotNoStr = label.Max(a => a.LotNo);
-                        maxBoxCode = label.Max(a => a.BoxNo);
-                        if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                        else
                         {
-                            maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                            var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
+                            if (labelCount.Count <= 0)
+                            {
+                                throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            }
+                            maxLotNoStr = label.Max(a => a.LotNo);
+                            maxBoxCode = label.Max(a => a.BoxNo);
+                            if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                            {
+                                maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                            }
                         }
+                        
                     }
                     else
                     {
@@ -814,21 +828,33 @@
                     string toDayTime2 = DateTime.Now.ToString("yyyyMMdd");
                     if (isReset == "0")
                     {
-                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
-                        if (labelCount.Count <= 0)
+                        //鍒ゆ柇鍗曟嵁鏄惁鏄綑鏂欓��鍥炲崟
+                        if (asn.Type == "4")
                         {
-                            throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            maxCodestr2 = asnList.LotNo;
+                            maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo);
+                            maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//鏀彿
+                            if (string.IsNullOrWhiteSpace(maxCodestr2))
+                            {
+                                throw new Exception("杞﹂棿浣欐枡閫�鍥炲崟鎹壒娆′笉鑳戒负绌�");
+                            }
                         }
-                        var maxCode = label.Max(a => a.LotNo);
-                        var boxCode1 = label.Max(a => a.BoxNo);//绠卞彿
-                        var boxCode2 = label.Max(a => a.BoxNo3);//鏀彿
-                        maxCodestr2 = maxCode;
-                        maxboxcode2 = boxCode1;
-                        maxboxcode3 = boxCode2;
-                        if (string.IsNullOrWhiteSpace(maxCodestr2))
+                        else
                         {
-                            maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                            var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
+                            if (labelCount.Count <= 0)
+                            {
+                                throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            }
+                            maxCodestr2 = label.Max(a => a.LotNo); ;
+                            maxboxcode2 = label.Max(a => a.BoxNo);//绠卞彿;
+                            maxboxcode3 = label.Max(a => a.BoxNo3);//鏀彿;
+                            if (string.IsNullOrWhiteSpace(maxCodestr2))
+                            {
+                                maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                            }
                         }
+                        
                     }
                     else
                     {
@@ -988,7 +1014,7 @@
                         Db.Updateable(asnList).ExecuteCommand();
                     } 
                 }
-                
+                Db.CommitTran();
                 return modelList;
 
 
@@ -996,6 +1022,7 @@
             }
             catch (Exception e)
             {
+                Db.RollbackTran();
                 throw new Exception(e.Message);
             }
         }

--
Gitblit v1.8.0