From 0c9661af88f5533ac73fbab82da39ea78d42853b Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期一, 09 九月 2024 14:10:03 +0800
Subject: [PATCH] 修改托盘码生成规则

---
 Wms/Wms/Controllers/SysController.cs |  151 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 144 insertions(+), 7 deletions(-)

diff --git a/Wms/Wms/Controllers/SysController.cs b/Wms/Wms/Controllers/SysController.cs
index 94988f0..a77e393 100644
--- a/Wms/Wms/Controllers/SysController.cs
+++ b/Wms/Wms/Controllers/SysController.cs
@@ -735,6 +735,50 @@
                 return Ok(new { code = 1, msg = e.Message });
             }
         }
+
+        /// <summary>
+        /// 娣诲姞鍖哄煙淇℃伅
+        /// </summary>
+        /// <param name="model">妯″瀷</param>
+        /// <returns></returns> 
+        [HttpPost]
+        public IActionResult InsertStorageArea(SysStorageArea model)
+        {
+            try
+            {
+                //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D
+                var claimsIdentity = this.User.Identity as ClaimsIdentity;
+                if (claimsIdentity == null)
+                {
+                    return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+                }
+                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
+                if (string.IsNullOrWhiteSpace(userId))
+                {
+                    return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+                }
+                model.CreateUser = int.Parse(userId);
+                string bolls = _areaSvc.InsertStorageArea(model);
+                var arr = bolls.Split(":");
+                if (arr[0] != "-1")
+                {
+                    SysStorageArea area = _areaSvc.GetStorageMaxArea();
+                    _operation.InsertOperation("浠撳簱璁剧疆", "鍖哄煙绠$悊", area.AreaNo, "娣诲姞", "娣诲姞鍖哄煙淇℃伅 鍖哄煙鍙凤細" + area.AreaNo, Convert.ToInt32(userId));
+                    return Ok(new { code = 0, msg = bolls, data = "" });
+                }
+                else
+                {
+                    return Ok(new { code = 1, msg = bolls, data = "" });
+                }
+
+            }
+            catch (Exception e)
+            {
+                return Ok(new { code = 1, msg = e.Message });
+            }
+
+        }
+
         /// <summary>
         /// 淇敼鍖哄煙淇℃伅
         /// </summary>
@@ -1012,7 +1056,7 @@
             }
         }
         /// <summary>
-        /// 娣诲姞鍌ㄤ綅淇℃伅
+        /// 娣诲姞绔嬩綋搴撳偍浣嶄俊鎭�
         /// </summary>
         /// <param name="model">妯″瀷</param>
         /// <returns></returns> 
@@ -1057,6 +1101,54 @@
                 return Ok(new { code = 400, ErrorMsg = "鏁版嵁鏍煎紡閿欒" });
             }
         }
+
+        /// <summary>
+        /// 娣诲姞骞冲簱鍌ㄤ綅淇℃伅
+        /// </summary>
+        /// <param name="model">妯″瀷</param>
+        /// <returns></returns> 
+        [AllowAnonymous]
+        [HttpPost]
+        public async Task<IActionResult> AddPkStorageLocat(AddLocateVm model)
+        {
+            if (ModelState.IsValid)
+            {
+                try
+                {
+                    //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D
+                    //var claimsIdentity = this.User.Identity as ClaimsIdentity;
+                    //if (claimsIdentity == null)
+                    //{
+                    //    return Ok(new { code = 400, ErrorMsg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+                    //}
+                    //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
+                    //if (string.IsNullOrWhiteSpace(userId))
+                    //{
+                    //    return Ok(new { code = 400, ErrorMsg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+                    //}
+                    var bolls = await _locatSvc.AddPkStorageLocat(model, 1);
+                    if (bolls > 0)
+                    {
+                        await _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", model.RoadwayNo, "娣诲姞", "娣诲姞鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + model.RoadwayNo, 1);
+                        return Ok(new { code = 200, ErrorMsg = "娣诲姞鎴愬姛", data = bolls });
+                    }
+                    else
+                    {
+                        return Ok(new { code = 400, ErrorMsg = "娣诲姞澶辫触", data = "" });
+                    }
+
+                }
+                catch (Exception e)
+                {
+                    return Ok(new { code = 400, ErrorMsg = "璇疯仈绯荤鐞嗗憳/" + e.Message });
+                }
+            }
+            else //鏁版嵁鏍煎紡閿欒
+            {
+                return Ok(new { code = 400, ErrorMsg = "鏁版嵁鏍煎紡閿欒" });
+            }
+        }
+
         /// <summary>
         /// 淇敼鍌ㄤ綅淇℃伅
         /// </summary>
@@ -1134,11 +1226,16 @@
                         string msg = "鍌ㄤ綅鐘舵�� 鍌ㄤ綅鍙凤細" + storage.RoadwayNo;
                         if (model.Id.Count > 1)
                         {
-                            foreach (var item in model.Id)
+                            var sstorage = _locatSvc.GetStorageLocat(model.Id);
+                            foreach (var item in sstorage)
                             {
-                                storage = _locatSvc.GetStorageLocat(item);
-                                _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", storage.LocatNo, "鎵归噺缂栬緫", "鎵归噺淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + storage.LocatNo, Convert.ToInt32(userId));
+                                _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", item.LocatNo, "鎵归噺缂栬緫", "鎵归噺淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + item.LocatNo, Convert.ToInt32(userId));
                             }
+                            //foreach (var item in model.Id)
+                            //{
+                            //    storage = _locatSvc.GetStorageLocat(item);
+                            //    _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", storage.LocatNo, "鎵归噺缂栬緫", "鎵归噺淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + storage.LocatNo, Convert.ToInt32(userId));
+                            //}
                         }
                         else
                         {
@@ -1277,17 +1374,21 @@
                 {
                     throw new Exception("褰撳墠鏄剧ず鐨勬潯鐮佷笉鏄渶鏂版潯鐮侊紝璇烽噸鏂版坊鍔�");
                 }
-                string str = model.PalletNo.Substring(3, 5);
-                string remove = model.PalletNo.Substring(0, 3);
+                string str = model.PalletNo.Substring(2, 6);
+                string remove = model.PalletNo.Substring(0, 2);
                 int sibelius = Convert.ToInt16(str);
                 for (int i = 0; i < model.GroupCount; i++)
                 {
+                    if (sibelius>999999)
+                    {
+                        throw new Exception("鎵樼洏缁勪腑宸叉湁鎵樼洏鐮佷綅鏁板凡杈句笂绾�");
+                    }
                     if (i != 0)
                     {
                         sibelius += 1;
                     }
 
-                    string code = remove + Convert.ToString(sibelius).PadLeft(5, '0');
+                    string code = remove + Convert.ToString(sibelius).PadLeft(6, '0');
                     for (int j = 0; j < model.SameCount; j++)
                     {
                         var re = BarcodeHelper.GetCodeBarBase64(code, 80, 50);
@@ -1444,6 +1545,7 @@
 
         #region 鍌ㄤ綅鍥句緥
 
+        #region 绔嬪簱
         /// <summary>
         /// 鏍规嵁浠撳簱 鎺�
         /// </summary>
@@ -1560,6 +1662,41 @@
             });
         }
 
+
+
+        #endregion
+
+        #region 骞冲簱
+
+        /// <summary>
+        /// 鏍规嵁浠撳簱 鎺�
+        /// </summary>
+        /// <param name="wareHouseNo">浠撳簱</param>
+        /// <param name="row">鎺�</param>
+        /// <param name="depth">娣卞害</param>
+        /// <returns></returns>
+        [HttpGet]
+        public IActionResult GetFlatLibraryLegend(string wareHouseNo, string row)
+        {
+            //鑾峰彇鍌ㄤ綅淇℃伅
+            List<SysStorageLocat> storagelist = _locatSvc.GetFlatLibraryLegend(wareHouseNo, row);
+
+            //Dictionary<string, int> dic = new Dictionary<string, int>()
+            //{
+            //    "B01"
+            //};
+
+            return Ok(new
+            {
+                data = storagelist,
+                //dic,
+                code = 0,
+                msg = ""
+            });
+        }
+
+        #endregion
+
         /// <summary>
         /// 鏍规嵁鍌ㄤ綅鍦板潃鑾峰彇鍌ㄤ綅涓婄殑鎵樼洏鍜岀墿鍝佷俊鎭�
         /// </summary>

--
Gitblit v1.8.0