¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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çidè¿åä¸ä¸ªæ¥è¯¢å¨ä½è¡¥å°æ¡ç äºå¡ |
| | | /// </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); |
| | | } |
| | | |
| | | } |
| | | } |