From 7642a3e183b5a584d1da5eb6b48e0f9cb2b5c68c Mon Sep 17 00:00:00 2001
From: chengsc <11752@DESKTOP-DS49RCP>
Date: 星期一, 17 三月 2025 10:39:13 +0800
Subject: [PATCH] 修改问题

---
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs |   85 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index 2c3e986..96924c1 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -1,8 +1,10 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Security.Cryptography.X509Certificates;
 using System.Text;
 using System.Threading.Tasks;
+using Dm;
 using Model.ModelDto.BllCheckDto;
 using Model.ModelDto.PdaDto;
 using SqlSugar;
@@ -1164,5 +1166,88 @@
             }
         }
         #endregion
+
+        #region 绠辩爜鎷嗙璐存爣
+        /// <summary>
+        /// 鎷嗙娣诲姞鏍囩
+        /// </summary>
+        /// <param name="boxNo"></param>
+        /// <param name="devanQty"></param>
+        /// <param name="userId"></param>
+        public void AddLableByDevanning(string boxNo, decimal devanQty, int userId)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(boxNo))
+                {
+                    throw new Exception("绠辩爜涓嶈兘涓虹┖");
+                }
+                //寮�鍚簨鍔�
+                Db.BeginTran();
+                
+                //搴撳瓨绠辨敮鏄庣粏淇℃伅
+                var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.BoxNo == boxNo).ToList();
+                if (boxList.Count != 1)
+                {
+                    throw new Exception("璇ョ鐮佷俊鎭敊璇紝瀛樺湪澶氫釜姝ょ鐮佷俊鎭�");
+                }
+                var boxInfo = boxList.First();
+                if (boxInfo.Qty<=devanQty)
+                {
+                    throw new Exception("鎷嗙鏁伴噺澶х瓑浜庡綋鍓嶇鍐呮暟閲�");
+                }
+                
+                boxInfo.Qty -= devanQty;
+                boxInfo.BitBoxMark = "1";
+                //鏇存柊绠辩爜搴撳瓨琛�
+                Db.Updateable(boxInfo).ExecuteCommand();
+
+                var boxStr = boxInfo.BoxNo.Substring(0, boxInfo.BoxNo.Length - 6);//鑾峰彇绠辩爜鍓嶇紑-闄ゅ悗鍏綅娴佹按澶�
+                var maxBoxCode = Db.Queryable<BllBoxInfo>().Where(m => m.BoxNo.Contains(boxStr) && m.IsDel == "0" && m.Origin == "WMS鐢熸垚").Max(a => a.BoxNo);
+                var boxNoNew = maxBoxCode.Substring(0, maxBoxCode.Length - 6) + (int.Parse(maxBoxCode.Substring(maxBoxCode.Length - 6, 6)) + 1).ToString().PadLeft(6, '0');
+
+                // 娣诲姞鏂扮鐮佷俊鎭�
+                var boxModel = new DataBoxInfo()
+                {
+                    StockDetailId = boxInfo.StockDetailId,
+                    PalletNo = boxInfo.PalletNo,
+                    BoxNo = boxNoNew,
+                    Qty = devanQty,
+                    FullQty = boxInfo.FullQty,
+                    
+                    Status = "2",//0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
+                    LotNo = boxInfo.LotNo,
+                    LotText = boxInfo.LotText,
+                    SkuNo = boxInfo.SkuNo,
+                    SkuName = boxInfo.SkuName,
+                    Standard = boxInfo.Standard,
+                    
+                    SupplierLot = boxInfo.SupplierLot,
+                    InspectStatus = boxInfo.InspectStatus,
+                    InspectMark = boxInfo.InspectMark,
+                    BitBoxMark = "1",
+                    ProductionTime = boxInfo.ProductionTime,
+                    ExpirationTime = boxInfo.ExpirationTime,
+
+                    CreateUser = 0,
+                    CreateTime = DateTime.Now
+                };
+
+                Db.Insertable(boxModel).ExecuteCommand();
+
+                //娣诲姞鎿嶄綔鏃ュ織
+                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鎷嗙璐存爣锛氬師绠辩爜锛歿boxNo}鎷嗙锛屾坊鍔犳柊绠辩爜{boxNoNew}", userId);
+                //鎻愪氦浜嬪姟
+                Db.CommitTran();
+            }
+            catch (Exception e)
+            {
+                //鍥炴粴浜嬪姟
+                Db.RollbackTran();
+                throw new Exception(e.Message);
+            }
+        }
+        #endregion
+
     }
 }

--
Gitblit v1.8.0