From c789e51bbf0dc8eea2689918c7c8cdb4309d3c6c Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期五, 05 十二月 2025 13:58:28 +0800
Subject: [PATCH] 11

---
 StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs b/StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs
new file mode 100644
index 0000000..801c57a
--- /dev/null
+++ b/StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs
@@ -0,0 +1,113 @@
+using MES.Service.Dto.service;
+using MES.Service.Modes;
+using MES.Service.service;
+using MES.Service.service.Warehouse;
+using MES.Service.util;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+
+namespace MESApplication.Controllers.Warehouse
+{
+    [ApiController]
+    [Route("api/[controller]")]
+    public class MesPalletBinding1Controller : ControllerBase
+    {
+        private readonly MessageCenterManager _manager = new();
+        private readonly MesPalletBinding1Manager m = new();
+        private readonly string METHOD = "POST";
+        private readonly string TableName = "mespalletbinding1";
+
+        private readonly string URL =
+            "http://localhost:10054/api/mespalletbinding1/";
+
+        /// <summary>
+        /// 浠庡閮ㄦ帴鍙h幏鍙栨爤鏉跨粦瀹氫俊鎭苟淇濆瓨鍒版暟鎹簱
+        /// </summary>
+        /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+        /// <returns></returns>
+        [HttpPost("SavePalletBindingData")]
+        public ResponseResult SavePalletBindingData([FromBody] MesPalletBinding palletBinding)
+        {
+            try
+            {
+                // 璋冪敤涓氬姟閫昏緫灞傛柟娉曞皢鏁版嵁淇濆瓨鍒版暟鎹簱
+                int insertedCount = m.InsertPalletBindingData(palletBinding);
+
+                if (insertedCount > 0)
+                {
+                    return new ResponseResult
+                    {
+                        status = 0,
+                        message = $"鎴愬姛鎻掑叆 {insertedCount} 鏉℃爤鏉跨粦瀹氭暟鎹�",
+                        data = insertedCount
+                    };
+                }
+                else
+                {
+                    return new ResponseResult
+                    {
+                        status = 1,
+                        message = "鏈彃鍏ヤ换浣曟暟鎹紝鍙兘鏄洜涓烘帴鍙h繑鍥炵殑鏁版嵁涓虹┖",
+                        data = null
+                    };
+                }
+            }
+            catch (Exception ex)
+            {
+                return ResponseResult.ResponseError(ex);
+            }
+        }
+
+        /// <summary>
+        /// 妫�鏌ユ爤鏉跨爜鍦ㄦ暟鎹簱涓槸鍚﹀瓨鍦�
+        /// </summary>
+        /// <param name="stackCode">鏍堟澘鐮�</param>
+        /// <returns></returns>
+        [HttpPost("CheckStackCodeExists")]
+        public ResponseResult CheckStackCodeExists([FromBody] dynamic request)
+        {
+            try
+            {
+                string stackCode = request.stackCode;
+                bool exists = m.CheckStackCodeExists(stackCode);
+
+                return new ResponseResult
+                {
+                    status = 0,
+                    message = exists ? "鏍堟澘鐮佸凡瀛樺湪" : "鏍堟澘鐮佷笉瀛樺湪",
+                    data = exists
+                };
+            }
+            catch (Exception ex)
+            {
+                return ResponseResult.ResponseError(ex);
+            }
+        }
+
+        /// <summary>
+        /// 浠庡閮ㄦ帴鍙h幏鍙栨爤鏉跨粦瀹氫俊鎭苟淇濆瓨鍒版暟鎹簱锛堝甫瀛樺湪鎬ф鏌ワ級
+        /// </summary>
+        /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+        /// <returns></returns>
+        [HttpPost("SavePalletBindingDataWithCheck")]
+        public async Task<ResponseResult> SavePalletBindingDataWithCheck([FromBody] MesPalletBinding palletBinding)
+        {
+            try
+            {
+                // 璋冪敤涓氬姟閫昏緫灞傛柟娉曞皢鏁版嵁淇濆瓨鍒版暟鎹簱锛堝甫瀛樺湪鎬ф鏌ワ級
+                int result = await m.InsertPalletBindingDataWithCheckAsync(palletBinding);
+
+                return new ResponseResult
+                {
+                    status = 0,
+                    message = result > 0 ? $"鎴愬姛澶勭悊 {result} 鏉℃爤鏉跨粦瀹氭暟鎹�" : "鏈鐞嗕换浣曟暟鎹紝鍙兘鏄洜涓烘帴鍙h繑鍥炵殑鏁版嵁涓虹┖",
+                    data = result
+                };
+            }
+            catch (Exception ex)
+            {
+                return ResponseResult.ResponseError(ex);
+            }
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3