From 57bcad6ca99febdb4ac88da43360c54551aaa922 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 26 十月 2024 18:40:27 +0800
Subject: [PATCH] Merge branch 'master' into master_ben

---
 Tiger.Controllers.MES/Controllers/MESController.YadaPacking.cs |  281 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 281 insertions(+), 0 deletions(-)

diff --git a/Tiger.Controllers.MES/Controllers/MESController.YadaPacking.cs b/Tiger.Controllers.MES/Controllers/MESController.YadaPacking.cs
new file mode 100644
index 0000000..42477bd
--- /dev/null
+++ b/Tiger.Controllers.MES/Controllers/MESController.YadaPacking.cs
@@ -0,0 +1,281 @@
+锘縰sing Autofac;
+using Microsoft.AspNetCore.Mvc;
+using Rhea.Common;
+using SqlSugar;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using Tiger.IBusiness;
+using Tiger.Model;
+using Tiger.Model.Entitys.MES.Position;
+
+namespace Tiger.Api.Controllers.MES
+{
+    public partial class MESController : ControllerBase
+    {
+        /// <summary>
+        /// GetTransaction(ApiAction(Data:NewPositionInput))
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/YadaPacking/GetTransaction")]
+        public IActionResult YadaPacking_GetTransaction([FromBody] ApiAction<NewPositionInput> action)
+        {
+            ApiAction response;
+            IYadaPacking trans = null;
+            try
+            {
+                if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID))
+                {
+                    trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking;
+                }
+                else
+                {
+                    trans = AutoFacContainer.Instance.Resolve<IYadaPacking>().Init(action.ID, Request.Host.Value, action.Data?.USER_CODE, action.Data?.POST_CODE);
+                    iBiz.MES.Context.NewTransaction(HttpContext, trans);
+                }
+
+                response = action.GetResponse();
+            }
+            catch (System.IO.InvalidDataException ex)
+            {
+                response = action.GetResponse();
+                response.IsSuccessed = false;
+                response.LocaleMsg = new(ex.Message, ex.InnerException.Message.Split('|', System.StringSplitOptions.RemoveEmptyEntries));
+            }
+            catch (System.Exception ex)
+            {
+                response = action.GetResponse().CatchExceptionWithLog(ex);
+            }
+            trans?.AddHistory(Request, action);
+            return Ok(response);
+        }
+
+        /// <summary>
+        /// CloseTransaction(ApiAction)
+        /// 鍏抽棴浜嬪姟
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/YadaPacking/CloseTransaction")]
+        public IActionResult YadaPacking_CloseTransaction([FromBody] ApiAction action)
+        {
+            ApiAction response;
+            IYadaPacking trans = null;
+            try
+            {
+                if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID))
+                {
+                    trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking;
+                    if (!trans.IsFinished)
+                    {
+                        if (action.IsAsync)
+                        {
+                            response = action.GetResponse(trans.Close());
+                        }
+                        else
+                        {
+                            lock (trans.TransLock) { response = action.GetResponse(trans.Close()); }
+                        }
+                        response.Message = $"宀椾綅[{trans.PostCode}]鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]鍏抽棴{(response.IsSuccessed ? "鎴愬姛" : "澶辫触")}";
+                    }
+                    else
+                    {
+                        response = action.GetResponse($"Transaction Error: 宀椾綅[{trans.PostCode}]鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡鍏抽棴", false);
+                    }
+                }
+                else
+                {
+                    response = action.GetResponse($"Transaction Error: 宀椾綅鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡琚叧闂�", false);
+                }
+            }
+            catch (System.Exception ex)
+            {
+                response = action.GetResponse().CatchExceptionWithLog(ex);
+            }
+            trans?.AddHistory(Request, action);
+            return Ok(response);
+        }
+
+
+        /// <summary>
+        /// Reset(ApiAction)
+        /// 閲嶇疆宸ュ簭鎿嶄綔
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/YadaPacking/Reset")]
+        public async Task<IActionResult> YadaPacking_ResetAsync([FromBody] ApiAction action)
+        {
+            ApiAction response;
+            IYadaPacking trans = null;
+            try
+            {
+                if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID))
+                {
+                    trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking;
+                    if (!trans.IsFinished)
+                    {
+                        lock (trans.TransLock) { response = action.GetResponse(trans.Reset()); }
+                    }
+                    else
+                    {
+                        response = action.GetResponse($"Transaction Error: 宀椾綅[{trans.PostCode}]鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡鍏抽棴", false);
+                    }
+                }
+                else
+                {
+                    response = action.GetResponse($"Transaction Error: 宀椾綅鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡琚叧闂�", false);
+                }
+            }
+            catch (System.Exception ex)
+            {
+                response = action.GetResponse().CatchExceptionWithLog(ex);
+            }
+            trans?.AddHistory(Request, action);
+            return Ok(response);
+        }
+
+        /// <summary>
+        /// SelectWO(ApiAction(Data:{WoInput}))
+        /// 闆呰揪瑁呯宸ュ簭锛氶�夋嫨宸ュ崟
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/YadaPacking/SelectWO")]
+        public async Task<IActionResult> YadaPacking_SelectWOAsync([FromBody] ApiAction<WoInput> action)
+        {
+            ApiAction response;
+            IYadaPacking trans = null;
+            try
+            {
+                if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID))
+                {
+                    trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking;
+                    if (!trans.IsFinished)
+                    {
+                        if (action.IsAsync)
+                        {
+                            response = action.GetResponse(await trans.SelectOrder(action.Data));
+                        }
+                        else
+                        {
+                            lock (trans.TransLock) { response = action.GetResponse(trans.SelectOrder(action.Data).Result); }
+                        }
+                    }
+                    else
+                    {
+                        response = action.GetResponse($"Transaction Error: 宀椾綅[{trans.PostCode}]鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡鍏抽棴", false);
+                    }
+                }
+                else
+                {
+                    response = action.GetResponse($"Transaction Error: 宀椾綅鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡琚叧闂�", false);
+                }
+            }
+            catch (System.Exception ex)
+            {
+                response = action.GetResponse().CatchExceptionWithLog(ex);
+            }
+            trans?.AddHistory(Request, action);
+            return Ok(response);
+        }
+
+        /// <summary>
+        /// Submit(ApiAction(Data:{SubmitInput}))
+        /// 闆呰揪瑁呯宸ュ簭锛氭彁浜ゆ搷浣滄暟鎹�
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/YadaPacking/Submit")]
+        public async Task<IActionResult> YadaPacking_SubmitAsync([FromBody] ApiAction<SubmitInput> action)
+        {
+            ApiAction response;
+            IYadaPacking trans = null;
+            try
+            {
+                if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID))
+                {
+                    trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking;
+                    if (!trans.IsFinished)
+                    {
+                        if (action.IsAsync)
+                        {
+                            response = action.GetResponse(await trans.Submit(action.Data));
+                        }
+                        else
+                        {
+                            lock (trans.TransLock) { response = action.GetResponse(trans.Submit(action.Data).Result); }
+                        }
+                    }
+                    else
+                    {
+                        response = action.GetResponse($"Transaction Error: 宀椾綅[{trans.PostCode}]鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡鍏抽棴", false);
+                    }
+                }
+                else
+                {
+                    response = action.GetResponse($"Transaction Error: 宀椾綅鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡琚叧闂�", false);
+                }
+            }
+            catch (System.Exception ex)
+            {
+                response = action.GetResponse().CatchExceptionWithLog(ex);
+            }
+            trans?.AddHistory(Request, action);
+            return Ok(response);
+        }
+
+        /// <summary>
+        /// CompletePkg(ApiAction)
+        /// 闆呰揪瑁呯宸ュ簭锛氭墜鍔ㄧ粨鏉熷寘瑁�
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/YadaPacking/CompletePkg")]
+        public async Task<IActionResult> YadaPacking_CompletePkgAsync([FromBody] ApiAction action)
+        {
+            ApiAction response;
+            IYadaPacking trans = null;
+            try
+            {
+                if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID))
+                {
+                    trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking;
+                    if (!trans.IsFinished)
+                    {
+                        if (action.IsAsync)
+                        {
+                            response = action.GetResponse(await trans.CompletePkg(action));
+                        }
+                        else
+                        {
+                            lock (trans.TransLock) { response = action.GetResponse(trans.CompletePkg(action).Result); }
+                        }
+                    }
+                    else
+                    {
+                        response = action.GetResponse($"Transaction Error: 宀椾綅[{trans.PostCode}]鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡鍏抽棴", false);
+                    }
+                }
+                else
+                {
+                    response = action.GetResponse($"Transaction Error: 宀椾綅鐨勯泤杈捐绠卞伐搴忎簨鍔ID:{action.ID}]宸茬粡琚叧闂�", false);
+                }
+            }
+            catch (System.Exception ex)
+            {
+                response = action.GetResponse().CatchExceptionWithLog(ex);
+            }
+            trans?.AddHistory(Request, action);
+            return Ok(response);
+        }
+
+    }
+}

--
Gitblit v1.9.3