From 83b9213dc893bec8f94e04cad121abb6649886dd Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期日, 13 十月 2024 17:55:04 +0800
Subject: [PATCH] 修改业务需求问题

---
 Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs |   99 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 72 insertions(+), 27 deletions(-)

diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
index d1d0140..de6e0ad 100644
--- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
@@ -15,6 +15,7 @@
 using WMS.Entity.Context;
 using WMS.Entity.SysEntity;
 using WMS.IBLL.IBllAsnServer;
+using ZXing;
 
 namespace WMS.BLL.BllAsnServer
 {
@@ -532,14 +533,47 @@
         public List<BllBoxInfo> AddLabelBox(int imId, string isReset, decimal arriveQty, string productionTime, string expirationTime, string storeTime,string supplierLot, int userId)
         {
             try
-            { 
+            {
 
                 #region 鍗曟嵁銆佺墿鏂欍�佸寘瑁呫�佹爣绛句俊鎭幏鍙�
-
+                if (string.IsNullOrWhiteSpace(productionTime))
+                {
+                    throw new Exception("鐢熶骇鏃ユ湡涓嶈兘涓虹┖");
+                }
+                if (!string.IsNullOrWhiteSpace(expirationTime) && !string.IsNullOrWhiteSpace(storeTime))
+                {
+                    throw new Exception("鏈夋晥鏈熷拰鍌ㄥ瓨鏈熶笉鑳藉悓鏃跺~鍐�");
+                }
+                if (isReset != "0")
+                {
+                    throw new Exception("涓嶅彲閲嶇疆鎵规");
+                }
+                DateTime proTime;
+                DateTime expTime;
+                DateTime stoTime;
+                var bl1= DateTime.TryParse(productionTime, out proTime);
+                var bl2= DateTime.TryParse(expirationTime, out expTime);
+                var bl3= DateTime.TryParse(storeTime, out stoTime);
+                if (!bl1)
+                {
+                    throw new Exception("鐢熶骇鏃ユ湡杞崲澶辫触");
+                }
+                if (!bl2 && !string.IsNullOrWhiteSpace(expirationTime))
+                {
+                    throw new Exception("鏈夋晥鏈熻浆鎹㈠け璐�");
+                }
+                if (!bl3 && !string.IsNullOrWhiteSpace(storeTime))
+                {
+                    throw new Exception("鍌ㄥ瓨鏈熻浆鎹㈠け璐�");
+                }
                 var asnList = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.Id == imId && m.IsDel == "0");
                 if (asnList == null)
                 {
                     throw new Exception("鏈煡璇㈠埌鍗曟嵁鏄庣粏淇℃伅");
+                }
+                if (asnList.LotNo.Length != 10)
+                {
+                    throw new Exception("鍗曟嵁杩涘巶缂栧彿浣嶆暟闀垮害閿欒");
                 }
                 var asn = Db.Queryable<BllArrivalNotice>().First(m => m.ASNNo == asnList.ASNNo && m.IsDel == "0");
                 if (asn == null)
@@ -681,19 +715,19 @@
                             {
                                 throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
                             }
-                            maxLotNoStr = labelCount.Max(a => a.LotNo);
-                            
-                            if (string.IsNullOrWhiteSpace(maxLotNoStr))
-                            {
-                                maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
-                            }
-                            maxBoxCode = label.Where(m => m.LotNo == maxLotNoStr).Max(a => a.BoxNo);
+                            //maxLotNoStr = labelCount.Max(a => a.LotNo);
+                            maxLotNoStr = asnList.LotNo;
+                            //if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                            //{
+                            //    maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                            //}
+                            //maxBoxCode = label.Where(m => m.LotNo == maxLotNoStr).Max(a => a.BoxNo);
                         }
                         
                     }
                     else
                     {
-                        var maxCode = Db.Queryable<BllBoxInfo>().Where(m=>m.Origin == "WMS鐢熸垚").Max(a => a.LotNo);                        // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿
+                        var maxCode = Db.Queryable<BllBoxInfo>().Where(m=>m.Origin == "WMS鐢熸垚").Max(a => a.LotNo); // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿 20241013
                         if (string.IsNullOrWhiteSpace(maxCode))
                         {
                             maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
@@ -770,15 +804,20 @@
                             BitBoxMark = bNum > boxQty ? "1":"0",
                             InspectStatus = "0",
 
-                            ProductionTime = DateTime.Parse(productionTime),
-                            StoreTime = DateTime.Parse(storeTime),
-                            ExpirationTime = DateTime.Parse(expirationTime),
-
+                            ProductionTime = proTime,
+                            
                             Origin = "WMS鐢熸垚",
                             CreateUser = userId,
                             CreateTime = DateTime.Now,
                         };
-
+                        if (bl2)
+                        {
+                            labelModel.ExpirationTime = expTime;
+                        }
+                        if (bl3)
+                        {
+                            labelModel.StoreTime = stoTime;
+                        }
                         Db.Insertable(labelModel).ExecuteCommand();
                         modelList.Add(labelModel);
                     }
@@ -847,14 +886,15 @@
                             {
                                 throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
                             }
-                            maxCodestr2 = labelCount.Max(a => a.LotNo); ;
+                            //maxCodestr2 = labelCount.Max(a => a.LotNo); ;
+                            maxCodestr2 = asnList.LotNo;
                             
-                            if (string.IsNullOrWhiteSpace(maxCodestr2))
-                            {
-                                maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
-                            }
-                            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))
+                            //{
+                            //    maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                            //}
+                            //maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo);//绠卞彿;
+                            //maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//鏀彿;
                         }
                         
                     }
@@ -985,15 +1025,20 @@
                                 BitBoxMark = bNum > boxQty ? "1" : "0",
                                 InspectStatus = "0",
 
-                                ProductionTime = DateTime.Parse(productionTime),
-                                StoreTime = DateTime.Parse(storeTime),
-                                ExpirationTime = DateTime.Parse(expirationTime),
-
+                                ProductionTime = proTime,
+                                
                                 Origin = "WMS鐢熸垚",
                                 CreateUser = userId,
                                 CreateTime = DateTime.Now,
                             };
-
+                            if (bl2)
+                            {
+                                labelModel.ExpirationTime = expTime;
+                            }
+                            if (bl3)
+                            {
+                                labelModel.StoreTime = stoTime;
+                            }
                             Db.Insertable(labelModel).ExecuteCommand();
                             modelList.Add(labelModel);
                         }

--
Gitblit v1.8.0