From 0aa630ac8c349b35da1f87c4cf1af7151d13d5c5 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期五, 10 一月 2025 10:13:43 +0800 Subject: [PATCH] 重命名类和接口,新增API端点 --- Tiger.IBusiness.WMS/Transaction/IRePrintLabel.cs | 4 Tiger.Business.WMS/Transaction/ReprintLabel.cs | 4 Tiger.Controllers.WMS/Controllers/WMSController.RePrintLabel.cs | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 4 deletions(-) diff --git a/Tiger.Business.WMS/Transaction/ReprintBarcode.cs b/Tiger.Business.WMS/Transaction/ReprintLabel.cs similarity index 94% rename from Tiger.Business.WMS/Transaction/ReprintBarcode.cs rename to Tiger.Business.WMS/Transaction/ReprintLabel.cs index fadc30b..b47277a 100644 --- a/Tiger.Business.WMS/Transaction/ReprintBarcode.cs +++ b/Tiger.Business.WMS/Transaction/ReprintLabel.cs @@ -20,9 +20,9 @@ /// <summary> /// 鏌ュ偍浣嶈ˉ鍗版潯鐮佷簨鍔� /// </summary> - public class ReprintBarcode : WMSTransactionBase, IReprintBarcode + public class RePrintLabel : WMSTransactionBase, IRePrintLabel { - public IReprintBarcode Init(string id, string userCode, string apiHost, string orgCode) + public IRePrintLabel Init(string id, string userCode, string apiHost, string orgCode) { TransID = id; UserCode = userCode; diff --git a/Tiger.Controllers.WMS/Controllers/WMSController.RePrintLabel.cs b/Tiger.Controllers.WMS/Controllers/WMSController.RePrintLabel.cs new file mode 100644 index 0000000..10e6f72 --- /dev/null +++ b/Tiger.Controllers.WMS/Controllers/WMSController.RePrintLabel.cs @@ -0,0 +1,141 @@ +锘縰sing System; +using System.Threading.Tasks; +using Rhea.Common; +using Tiger.Model; +using Tiger.IBusiness; +using Microsoft.AspNetCore.Mvc; +using Tiger.Model.Minsun; +using Autofac; + +namespace Tiger.Api.Controllers.WMS +{ + public partial class WMSController : ControllerBase + { + /// <summary> + /// GetTransaction(ApiAction(Data:UserId)) + /// 鏍规嵁ApiAction鐨刬d杩斿洖涓�涓煡璇㈠偍浣嶈ˉ鍗版潯鐮佷簨鍔� + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/RePrintLabel/GetTransaction")] + public IActionResult RePrintLabel_GetTransaction([FromBody] ApiAction<USER> action) + { + ApiAction response; + IRePrintLabel trans = null; + try + { + if (iBiz.WMS.Context.GetTransDic().ContainsKey(action.ID)) + { + trans = iBiz.WMS.Context.GetTransDic()[action.ID] as IRePrintLabel; + } + else + { + trans = AutoFacContainer.Instance.Resolve<IRePrintLabel>().Init(action.ID, action.Data?.USER_CODE, Request.Host.Value, action.Data?.ORG_CODE); + iBiz.WMS.Context.NewTransaction(HttpContext, trans); + } + + response = action.GetResponse(); + } + 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]/RePrintLabel/CloseTransaction")] + public IActionResult RePrintLabel_CloseTransaction([FromBody] ApiAction action) + { + ApiAction response; + IRePrintLabel trans = null; + try + { + if (iBiz.WMS.Context.GetTransDic().ContainsKey(action.ID)) + { + trans = iBiz.WMS.Context.GetTransDic()[action.ID] as IRePrintLabel; + if (!trans.IsFinished) + { + if (action.IsAsync) + { + response = action.GetResponse(trans.Close()); + } + else + { + lock (trans.TransLock) { response = action.GetResponse(trans.Close()); } + } + response.Message = $"鏌ヨ鍌ㄤ綅琛ュ嵃鏉$爜浜嬪姟[ID:{action.ID}]鍏抽棴{(response.IsSuccessed ? "鎴愬姛" : "澶辫触")}"; + } + else + { + response = action.GetResponse($"Transaction Error: 鏌ヨ鍌ㄤ綅琛ュ嵃鏉$爜浜嬪姟[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> + /// 鎵弿鍏ュ簱 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/RePrintLabel/ScanItem")] + public async Task<IActionResult> RePrintLabel_ScanItemAsync([FromBody] ApiAction<BaseInput> action) + { + ApiAction response; + IRePrintLabel trans = null; + try + { + if (iBiz.WMS.Context.GetTransDic().ContainsKey(action.ID)) + { + trans = iBiz.WMS.Context.GetTransDic()[action.ID] as IRePrintLabel; + if (!trans.IsFinished) + { + if (action.IsAsync) + { + response = action.GetResponse(await trans.Scan(action.Data)); + } + else + { + lock (trans.TransLock) { response = action.GetResponse(trans.Scan(action.Data).Result); } + } + } + else + { + response = action.GetResponse($"Transaction Error: 鏌ヨ鍌ㄤ綅琛ュ嵃鏉$爜浜嬪姟[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); + } + + } +} \ No newline at end of file diff --git a/Tiger.IBusiness.WMS/Transaction/IReprintBarcode.cs b/Tiger.IBusiness.WMS/Transaction/IRePrintLabel.cs similarity index 72% rename from Tiger.IBusiness.WMS/Transaction/IReprintBarcode.cs rename to Tiger.IBusiness.WMS/Transaction/IRePrintLabel.cs index 0d6b7f1..a9740b4 100644 --- a/Tiger.IBusiness.WMS/Transaction/IReprintBarcode.cs +++ b/Tiger.IBusiness.WMS/Transaction/IRePrintLabel.cs @@ -11,9 +11,9 @@ namespace Tiger.IBusiness { - public interface IReprintBarcode : IWMSTransaction + public interface IRePrintLabel : IWMSTransaction { - public IReprintBarcode Init(string id, string userCode, string apiHost, string orgCode); + public IRePrintLabel Init(string id, string userCode, string apiHost, string orgCode); public Task<ApiAction<ScanOutput>> Scan(BaseInput input); -- Gitblit v1.9.3