| | |
| | | using Tiger.Business.MES.WorkAction; |
| | | using Tiger.Model.MES.Yada; |
| | | using System.Data; |
| | | using System.Diagnostics; |
| | | |
| | | namespace Tiger.Business.MES.Transaction |
| | | { |
| | |
| | | public PackingAction TempPkgAction { get; set; } |
| | | public bool IsPrintCustomerLabel { get; set; } |
| | | public string ShippingOrder { get; set; } |
| | | public DbClient U9CDB { get; set; } |
| | | public Model.TraceDebug debug { get; set; } |
| | | public DateTime curtime = DateTime.Now; |
| | | public DateTime prevtime = DateTime.Now; |
| | | |
| | | public DbClient U9CDB { get; set; } |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<SubmitOutput>> Submit(SubmitInput input) |
| | | { |
| | | curtime = prevtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug = new(new StackFrame(true)); |
| | | debug.Log(new StackFrame(true), "***** 1", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | try |
| | | { |
| | |
| | | var wosns = MainDB.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(); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 2 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 2", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //å
夿å½åå·¥åä¸ä¸ºç©ºä¸å½åå²ä½å¨å½å工忝䏿¯é¦ç«ï¼å¦ææ¯åä¸å
è®¸åæ´å½åå·¥åï¼å°è¯ææ¡ç ç»å®å°å½åå·¥å |
| | | if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode)) |
| | | { |
| | | //æ´æ°CurBatch |
| | | CurBatch?.Update(); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 3 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 3", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | 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); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 4 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 4", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //æ´æ°å·¥åºä¿¡æ¯ |
| | | if (!action.IsSuccessed) |
| | | { |
| | |
| | | { |
| | | //æ´æ°CurBatch |
| | | CurBatch?.Update(); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 5 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 5", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault(); |
| | | //妿客æ·ç«¯è¿åçå½åå·¥æ¥IDæ¾ä¸å°æªå®æçè¡ä¸ºå·¥æ¥ï¼åç´æ¥å¼å§ä¸ä¸ä¸ªè¡ä¸ºå·¥æ¥ |
| | | if (submitStep.IsNullOrEmpty()) |
| | | { |
| | | action = BeginNextActionStep(input); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 6 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 6", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | } |
| | | else |
| | | { |
| | | action = submitStep.Submit(input); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 7 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 7", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //妿å½åå·¥æ¥å·²å®æï¼å¼å§æ§è¡ä¸ä¸å·¥æ¥ |
| | | if (action.IsSuccessed && submitStep.IsFinished) |
| | | { |
| | | action = BeginNextActionStep(input); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 8 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 8", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | } |
| | | //妿å½åå·¥æ¥æªå®æ |
| | | else |
| | |
| | | //action.CatchExceptionWithLog(ex, $"å
è£
å·¥åºï¼æäº¤æä½æ°æ®å¼å¸¸"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException")); |
| | | } |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 9 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 9", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> NodeSubmit(ApiAction<SubmitOutput> action, SubmitInput input) |
| | | { |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 10 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 10", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | var curNode = CurBatch.GetNode(PostCode); |
| | | try |
| | | { |
| | |
| | | |
| | | //设置å½åæä»¤ä¸ºæ£å¸¸äº§åè¿ç« |
| | | NodeCmd = "NodeSubmit"; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 11 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 11", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | |
| | | //è·ååºè´§ç¶æ |
| | | var ship = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First(); |
| | | int CurShipQty = 0; |
| | | int WaitShipmentCarton = 0; |
| | | int WaitShipment = 0; |
| | | if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; } else |
| | | if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; } |
| | | else |
| | | { |
| | | CurShipQty = ship.ShipQty; |
| | | IsPrintCustomerLabel = true; |
| | |
| | | // Context.Add("CurWaitShipmentCarton", WaitShipmentCarton); |
| | | //} |
| | | |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 12", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //ç»å®æ¡ç å°å·¥å |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | |
| | | var _curNodeSetting = curNodeSetting.Clone(); |
| | | var _Batch = CurBatch.Batch.Clone(); |
| | | |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 13 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 13", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //åå§åå·¥æ¥å表 |
| | | 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)); |
| | | } |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 13.1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 13.1", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | return action; |
| | | } |
| | | |
| | |
| | | var curPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null; |
| | | var operInfo = SetOperNodeInfo(CurOperInfo(locale)); |
| | | Action endAction = null; |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 14 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 14", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | |
| | | //妿å½åæ¡ç å·²ç»èµ°å°æµç¨ç»ç¹åè®°å½æ¡ç å®å·¥ |
| | | if (operInfo.IsReachedEndNode) |
| | |
| | | |
| | | //éç½®å·¥åº |
| | | ResetNode(); |
| | | curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 15 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; |
| | | debug.Log(new StackFrame(true), "***** 15", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | return action; |
| | | } |
| | | |
| | |
| | | var action = new ApiAction<ShipingInfo>(); |
| | | try |
| | | { |
| | | action.Data = new ShipingInfo() { |
| | | action.Data = new ShipingInfo() |
| | | { |
| | | IsPrintCustomerLabel= IsPrintCustomerLabel, |
| | | ShipQty =Context.GetOrDefault("CurWaitShipment").ToInt32()>= Context.GetOrDefault("CurShipQty").ToInt32()? CurBatch.Batch.PLAN_QTY - Context.GetOrDefault("CurShipQty").ToInt32(): Context.GetOrDefault("CurShipQty").ToInt32() }; |
| | | ShipQty = Context.GetOrDefault("CurWaitShipment").ToInt32() >= Context.GetOrDefault("CurShipQty").ToInt32() ? CurBatch.Batch.PLAN_QTY - Context.GetOrDefault("CurShipQty").ToInt32() : Context.GetOrDefault("CurShipQty").ToInt32() |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |