| | |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.BizPrintInstoreDoc; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Tiger.Model.Entitys.MES.U9C; |
| | | |
| | | namespace Tiger.Api.Controllers.MES |
| | | { |
| | |
| | | { |
| | | trans = AutoFacContainer.Instance.Resolve<IInStoreOrderNo>().Init(action.ID, Request.Host.Value, action.Data); |
| | | iBiz.MES.Context.NewTransaction(HttpContext, trans); |
| | | |
| | | } |
| | | |
| | | response = action.GetResponse(); |
| | | response = action.GetResponse(trans.GetInStoreInfos()); |
| | | } |
| | | catch (System.IO.InvalidDataException ex) |
| | | { |
| | |
| | | return Ok(response); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 调用U9C接口生成入库单 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/InStoreOrderNo/GenerateInStoreOrder")] |
| | | public async Task<IActionResult> InStoreOrderNo_GenerateInStoreOrderAsync([FromBody] ApiAction<RcvRptDocCreateInput> action) |
| | | { |
| | | ApiAction response; |
| | | IInStoreOrderNo trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as IInStoreOrderNo; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.GenerateInStoreOrder()); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.GenerateInStoreOrder().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); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询对应的条码 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/InStoreOrderNo/GetScannedList")] |
| | | public async Task<IActionResult> InStoreOrderNo_GetScannedListAsync([FromBody] ApiAction action) |
| | | { |
| | | ApiAction response; |
| | | IInStoreOrderNo trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as IInStoreOrderNo; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.GetScannedList()); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.GetScannedList().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); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 清除 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/InStoreOrderNo/Clear")] |
| | | public async Task<IActionResult> InStoreOrderNo_ClearAsync([FromBody] ApiAction action) |
| | | { |
| | | ApiAction response; |
| | | IInStoreOrderNo trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as IInStoreOrderNo; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.Clear()); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.Clear().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); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/InStoreOrderNo/Delete")] |
| | | public async Task<IActionResult> InStoreOrderNo_DeleteAsync([FromBody] ApiAction action) |
| | | { |
| | | ApiAction response; |
| | | IInStoreOrderNo trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as IInStoreOrderNo; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.Delete(action.Data?.ToString())); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.Delete(action.Data?.ToString()).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); |
| | | } |
| | | } |
| | | } |