| | |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<SubmitOutput>> Submit(SubmitInput input) |
| | | { |
| | | ConsoleExt.WriteLine($"{curtime = prevtime = DateTime.Now:HH:mm:ss} ***** 1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = prevtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | try |
| | | { |
| | |
| | | var wosns = Biz.Db.Queryable<BIZ_MES_WO_BATCH, BIZ_MES_WO_SN>((q, s) => new JoinQueryInfos(JoinType.Inner, q.ORDER_NO == s.WORK_ORDER && q.BATCH_NO == s.BATCH_NO)) |
| | | .ByAuth(input.AuthOption)//.Where((q, s) => s.STATUS < BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) |
| | | .Where((q, s) => s.SN == input.SN || s.FLOW_SN == input.SN || s.TRAY_SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).ToList(); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 2 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 2 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | //先判断当前工单不为空且当前岗位在当前工单是不是首站,如果是则不允许变更当前工单,尝试把条码绑定到当前工单 |
| | | if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode)) |
| | | { |
| | | //更新CurBatch |
| | | CurBatch?.Update(); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 3 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 3 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | var wosn = wosns.FirstOrDefault(q => q.Batch.ORDER_NO == CurBatch.WO.ORDER_NO && (q.SN.STATUS == BIZ_MES_WO_SN.STATUSs.Finished.GetValue() || q.SN.STATUS == BIZ_MES_WO_SN.STATUSs.Scrap.GetValue())); |
| | | if (!wosn.IsNullOrEmpty()) |
| | | { |
| | |
| | | { |
| | | //提交数据 |
| | | action = NodeSubmit(action, input); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 4 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 4 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | //更新工序信息 |
| | | if (!action.IsSuccessed) |
| | | { |
| | |
| | | { |
| | | //更新CurBatch |
| | | CurBatch?.Update(); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 5 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 5 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault(); |
| | | //如果客户端返回的当前工步ID找不到未完成的行为工步,则直接开始下一个行为工步 |
| | | if (submitStep.IsNullOrEmpty()) |
| | | { |
| | | action = BeginNextActionStep(input); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 6 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 6 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | } |
| | | else |
| | | { |
| | | action = submitStep.Submit(input); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 7 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 7 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | //如果当前工步已完成,开始执行下一工步 |
| | | if (action.IsSuccessed && submitStep.IsFinished) |
| | | { |
| | | action = BeginNextActionStep(input); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 8 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 8 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | } |
| | | //如果当前工步未完成 |
| | | else |
| | |
| | | //action.CatchExceptionWithLog(ex, $"包装工序:提交操作数据异常"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException")); |
| | | } |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 9 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 9 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | return action; |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> NodeSubmit(ApiAction<SubmitOutput> action, SubmitInput input) |
| | | { |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 10 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 10 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | var curNode = CurBatch.GetNode(PostCode); |
| | | try |
| | | { |
| | |
| | | |
| | | //设置当前指令为正常产品过站 |
| | | NodeCmd = "NodeSubmit"; |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 11 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 11 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | //获取出货状态 |
| | | DbClient db = Biz.DataSource["YadaU9C"].Client; |
| | | var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First(); |
| | |
| | | } |
| | | } |
| | | ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : ""; |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | //绑定条码到工单 |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | |
| | | var _curNodeSetting = curNodeSetting.Clone(); |
| | | var _Batch = CurBatch.Batch.Clone(); |
| | | |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 13 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 13 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | //初始化工步列表 |
| | | Steps.Clear(); |
| | | var curStep = new WorkStep(IWorkStep.NodeTypes.Node, this) |
| | |
| | | //action.CatchExceptionWithLog(ex, $"{curNode.NODE_NAME}:工序节点工步提交数据异常,请检查工序节点设置"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.NodeSubmitException", curNode.NODE_NAME)); |
| | | } |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 13.1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 13.1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | return action; |
| | | } |
| | | |
| | |
| | | var curPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null; |
| | | var operInfo = SetOperNodeInfo(CurOperInfo(locale)); |
| | | Action endAction = null; |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 14 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 14 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | |
| | | //如果当前条码已经走到流程终点则记录条码完工 |
| | | if (operInfo.IsReachedEndNode) |
| | |
| | | |
| | | //保存数据库 |
| | | SaveStepsCommitActionToDB(endAction); |
| | | ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 15 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | |
| | | |
| | | //保存成功,返回过站消息 |
| | | operInfo.InputQty += CurWipSNs.Count; |
| | | action.Data.Data = new PackingActionOutput() { PkgInfo = curPkg }; |
| | |
| | | |
| | | //重置工序 |
| | | ResetNode(); |
| | | |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 15 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | return action; |
| | | } |
| | | |