| | |
| | | Logger.Scheduler.Info(context.Trigger.ConvertToMonitor()); |
| | | try |
| | | { |
| | | var _lastRunTime = Cache.SysParam["GetWo_LastRun", "Interface_LastRun"].PARAM_VALUE; |
| | | var _lastRunTime = Cache.SysParam["GetWo_LastRun", "Interface_LastRun"].PARAM_VALUE; |
| | | var LastRunTime = string.IsNullOrEmpty(_lastRunTime) ? DateTime.Now.AddMinutes(-10) : Convert.ToDateTime(_lastRunTime); |
| | | if ((DateTime.Now - LastRunTime).TotalMinutes > 10) |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | #region 提交前通用方法 |
| | | public async Task<ApiAction> CheckCode(string code) { |
| | | var action = new ApiAction(); |
| | | /// <summary> |
| | | /// 提交前检查是否岗位、工单和不良代码 |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<CheckCodeOutput>> CheckCode(string code) { |
| | | var action = new ApiAction<CheckCodeOutput>($"检查条码{code}成功", new CheckCodeOutput()); |
| | | try |
| | | { |
| | | |
| | | action.Data.Position = DbCache.Cache.Position[code]; |
| | | action.Data.WorkOrder = await MainDB.Queryable<BIZ_MES_WO>().Where(q=>q.ORDER_NO == code).FirstAsync(); |
| | | action.Data.Defect = DbCache.Cache.Defect[code]; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | return Ok(response); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 提交前检查是否岗位、工单和不良代码 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/CollectNode/CheckCode")] |
| | | public async Task<IActionResult> CollectNode_CheckCodeAsync([FromBody] ApiAction action) |
| | | { |
| | | ApiAction response; |
| | | ICollectNode trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as ICollectNode; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.CheckCode(action.Data?.ToString())); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.CheckCode(action.Data?.ToString()).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); |
| | | } |
| | | } |
| | | } |
| | |
| | | return Ok(response); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 提交前检查是否岗位、工单和不良代码 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/PackingNode/CheckCode")] |
| | | public async Task<IActionResult> PackingNode_CheckCodeAsync([FromBody] ApiAction action) |
| | | { |
| | | ApiAction response; |
| | | IPackingNode trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as IPackingNode; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.CheckCode(action.Data?.ToString())); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.CheckCode(action.Data?.ToString()).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); |
| | | } |
| | | } |
| | | } |
| | |
| | | return Ok(response); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 提交前检查是否岗位、工单和不良代码 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("api/[controller]/TestNode/CheckCode")] |
| | | public async Task<IActionResult> TestNode_CheckCodeAsync([FromBody] ApiAction action) |
| | | { |
| | | ApiAction response; |
| | | ITestNode trans = null; |
| | | try |
| | | { |
| | | if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) |
| | | { |
| | | trans = iBiz.MES.Context.GetTransDic()[action.ID] as ITestNode; |
| | | if (!trans.IsFinished) |
| | | { |
| | | if (action.IsAsync) |
| | | { |
| | | response = action.GetResponse(await trans.CheckCode(action.Data?.ToString())); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.CheckCode(action.Data?.ToString()).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); |
| | | } |
| | | |
| | | }//endClass |
| | | } |
| | |
| | | trans?.AddHistory(Request, action); |
| | | return Ok(response); |
| | | } |
| | | |
| | | [HttpPost] |
| | | [Route("api/[controller]/YadaPacking/CheckCode")] |
| | | public async Task<IActionResult> YadaPacking_CheckCodeAsync([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.CheckCode(action.Data?.ToString())); |
| | | } |
| | | else |
| | | { |
| | | lock (trans.TransLock) { response = action.GetResponse(trans.CheckCode(action.Data?.ToString()).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); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="curAction"></param> |
| | | /// <returns></returns> |
| | | public string GenerateSN(string ruleCode, IWorkAction curAction); |
| | | public Task<ApiAction<CheckCodeOutput>> CheckCode(string code); |
| | | #endregion Functions |
| | | } |
| | | } |
| | |
| | | public int ShipQty { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 提交前检查输出参数 |
| | | /// </summary> |
| | | public class CheckCodeOutput |
| | | { |
| | | public MES_POSITION Position { get; set; } |
| | | public BIZ_MES_WO WorkOrder { get; set; } |
| | | public BAS_DEFECT Defect { get; set; } |
| | | } |
| | | |
| | | } |