From 3f364634b79a0f97a550c54f67313dfc0cfd4cb5 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期三, 27 十一月 2024 22:16:01 +0800 Subject: [PATCH] 一大波签入来了 --- Tiger.Business.MES/Transaction/YadaPacking.cs | 72 ++++++++++++++++++++---------------- 1 files changed, 40 insertions(+), 32 deletions(-) diff --git a/Tiger.Business.MES/Transaction/YadaPacking.cs b/Tiger.Business.MES/Transaction/YadaPacking.cs index 5f40414..ee9a561 100644 --- a/Tiger.Business.MES/Transaction/YadaPacking.cs +++ b/Tiger.Business.MES/Transaction/YadaPacking.cs @@ -63,7 +63,7 @@ // action.IsSuccessed = false; // action.LocaleMsg = new($"鍖呰鏁伴噺[{input.Qty}]涓嶆纭紝璇烽噸鏂拌緭鍏ユ暟閲忓悗缁х画鍖呰鎿嶄綔"); // //action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.QtyError", input.Qty); - // return action; + // return SetOutPutMqttMsg(action, input.Locale); //} if (input.Options.ContainsKey("IsPrintCustomerLabel")) { @@ -91,7 +91,7 @@ //宸ユ鍒楄〃涓虹┖鎴栬�呭伐搴忚妭鐐瑰伐姝ユ湁鏈畬鎴愭椂锛屼紭鍏堝畬鎴愬伐搴忚妭鐐瑰伐姝� if (Steps.IsNullOrEmpty() || !IsFinishNodeSteps) { - 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)) + 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; @@ -142,7 +142,7 @@ action.IsSuccessed = false; //action.LocaleMsg = new($"鏉$爜[{0}]鏄浇鍏锋潯鐮侊紝璇锋壂鎻忚浇鍏蜂腑鐨勪骇鍝佹潯鐮佺户缁寘瑁呮搷浣�"); action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.OnlyMinPackage", input.SN); - return action; + return SetOutPutMqttMsg(action, input.Locale); } var curPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null; if (!curPkg.IsNullOrEmpty() && !curPkg.IsFinished && curPkg.WorkBatch != curSNs.First().Batch.BATCH_NO) @@ -152,7 +152,7 @@ action.IsSuccessed = false; //action.LocaleMsg = new($"姝e湪鍖呰宸ュ崟鎵规[{0}]鐨勪骇鍝侊紝璇峰厛瀹屾垚褰撳墠鍖呰鍚庡啀鎵弿鍏朵粬鎵规[{1}]鐨勪骇鍝乕{2}]"); action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.BatchError", curPkg.WorkBatch, curSNs.First().Batch.BATCH_NO, input.SN); - return action; + return SetOutPutMqttMsg(action, input.Locale); } if (curSNs.First().Batch.ACT_LINE != CurLine.LINE_CODE) { @@ -174,7 +174,7 @@ action.Data.OperInfo = new(); action.IsSuccessed = result.IsSuccessed; action.LocaleMsg = result.LocaleMsg; - return action; + return SetOutPutMqttMsg(action, input.Locale); } } //鏇存柊CurBatch @@ -297,7 +297,7 @@ 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; - return action; + return SetOutPutMqttMsg(action, input.Locale); } /// <summary> @@ -335,7 +335,7 @@ return woStatus; } - var wipSNs = Biz.Db.Queryable<MES_WIP_DATA>().IncludesAllFirstLayer().Where(q => q.SN == input.SN || q.FLOW_SN == input.SN || q.TRAY_SN == input.SN).Where(q => q.FINISHED_FLAG != "Y").ToList(); + var wipSNs = MainDB.Queryable<MES_WIP_DATA>().IncludesAllFirstLayer().Where(q => q.SN == input.SN || q.FLOW_SN == input.SN || q.TRAY_SN == input.SN).Where(q => q.FINISHED_FLAG != "Y").ToList(); if (wipSNs.IsNullOrEmpty()) { var wipSN = new MES_WIP_DATA() @@ -399,37 +399,43 @@ var ship = db.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 { CurShipQty = ship.ShipQty; - SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { BATCH = CurBatch.Batch.BATCH_NO, NodeIdOrName = curNode.NODE_NAME }); - var list = Biz.Db.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars).AsEnumerable().ToList(); + IsPrintCustomerLabel = true; + SugarParameter[] pars = MainDB.Ado.GetParameters(new { BATCH = CurBatch.Batch.BATCH_NO, NodeIdOrName = curNode.NODE_NAME }); + var list = MainDB.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars).AsEnumerable().ToList(); if (!list.IsNullOrEmpty()) { var batchCount = list.Where(q => q["ProdDate"].ToString() == "Whole").FirstOrDefault(); - WaitShipmentCarton = batchCount["WaitShipment"].ToInt32(); - IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? false : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true; + WaitShipmentCarton = batchCount["WaitShipmentCarton"].ToInt32(); + WaitShipment = batchCount["WaitShipment"].ToInt32(); + IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true; } } ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : ""; //缂撳瓨鍑鸿揣鏁伴噺 - if (Context.ContainsKey("CurShipQty")) - { - Context["CurShipQty"] = CurShipQty; - } - else - { - Context.Add("CurShipQty", CurShipQty); - } + Context.SetOrAdd("CurShipQty", CurShipQty); + //if (Context.ContainsKey("CurShipQty")) + //{ + // Context["CurShipQty"] = CurShipQty; + //} + //else + //{ + // Context.Add("CurShipQty", CurShipQty); + //} //缂撳瓨鍑鸿揣绠辨暟 - if (Context.ContainsKey("CurWaitShipmentCarton")) - { - Context["CurWaitShipmentCarton"] = WaitShipmentCarton; - } - else - { - Context.Add("CurWaitShipmentCarton", WaitShipmentCarton); - } + Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton); + Context.SetOrAdd("CurWaitShipment", WaitShipment); + //if (Context.ContainsKey("CurWaitShipmentCarton")) + //{ + // Context["CurWaitShipmentCarton"] = WaitShipmentCarton; + //} + //else + //{ + // Context.Add("CurWaitShipmentCarton", WaitShipmentCarton); + //} curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //缁戝畾鏉$爜鍒板伐鍗� @@ -898,7 +904,7 @@ action.IsSuccessed = false; //action.LocaleMsg = new($"鍑鸿揣鏁伴噺璁惧畾涓篬{0}]锛岀洰鍓嶅寘瑁呬簡[{1}]锛屽寘瑁呭熬鏁扮殑鏁伴噺蹇呴渶鏄痆{2}]锛岃瑁呭鏁伴噺鍚庡啀缁撴潫鍖呰"); action.LocaleMsg = new("MES.Transaction.PackingNode.NotMatchShipQty", shipQty, curQty, shipQty % ruleQty); - return action; + return SetOutPutMqttMsg(action); } NodeCmd = "PkgSubmit"; @@ -931,7 +937,7 @@ action.CatchExceptionWithLog(ex, $"鍖呰宸ュ簭锛氭墜鍔ㄧ粨鏉熷寘瑁呭紓甯�"); NodeCmd = null; } - return action; + return SetOutPutMqttMsg(action); } /// <summary> @@ -945,8 +951,8 @@ try { var CurPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null; - var LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); - var label = CurPkg.Item.LABEL_CODE.IsNullOrEmpty() ? null : Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == CurPkg.Item.LABEL_CODE).IncludesAllFirstLayer().First(); + var LabelPV = MainDB.Queryable<BAS_LABEL_PV>().ToList(); + var label = CurPkg.Item.LABEL_CODE.IsNullOrEmpty() ? null : MainDB.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == CurPkg.Item.LABEL_CODE).IncludesAllFirstLayer().First(); var printLb = SetLabelVariables(LabelPV, label, new PackingAction(), CurPkg); action.Data = new PackingActionOutput() { @@ -971,7 +977,9 @@ var action = new ApiAction<ShipingInfo>(); try { - action.Data = new ShipingInfo() { IsPrintCustomerLabel= IsPrintCustomerLabel,ShipQty = Context["CurShipQty"].ToInt32() }; + 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() }; } catch (Exception ex) { -- Gitblit v1.9.3