服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2025-01-02 f2fb67bf0cf463eb020599342f5e0476356821d8
Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -70,10 +70,10 @@
                //    //action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.QtyError", input.Qty);
                //    return SetOutPutMqttMsg(action, input.Locale);
                //}
                if (input.Options.ContainsKey("IsPrintCustomerLabel"))
                {
                    IsPrintCustomerLabel = input.Options["IsPrintCustomerLabel"].ToBoolean();
                }
                //if (input.Options.ContainsKey("IsPrintCustomerLabel"))
                //{
                //    IsPrintCustomerLabel = input.Options["IsPrintCustomerLabel"].ToBoolean();
                //}
                //if (input.Options.ContainsKey("ShippingOrder"))
                //{
@@ -298,8 +298,11 @@
            {
                action.Data.ShortMsg = new("工序异常", ShortMessage.Types.Error);
                action.Data.OperInfo = CurOperInfo(input.Locale);
                RemoveCurSnFromCurPackage(Context.ContainsKey("CurPackage") ? (Context["CurPackage"] as WipPkg).Item : null);
                ResetNode();
                //action.CatchExceptionWithLog(ex, $"包装工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException"));
            }
            debug.Log(new StackFrame(true), "***** 9", info => { ConsoleExt.WriteLine(info.ToString()); });
            return SetOutPutMqttMsg(action, input.Locale);
@@ -401,7 +404,7 @@
                    //获取出货状态
                    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;
                    decimal CurShipQty = 0;
                    int WaitShipmentCarton = 0;
                    int WaitShipment = 0;
                    if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; }
@@ -422,25 +425,9 @@
                    ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : "";
                    //缓存出货数量
                    Context.SetOrAdd("CurShipQty", CurShipQty);
                    //if (Context.ContainsKey("CurShipQty"))
                    //{
                    //    Context["CurShipQty"] = CurShipQty;
                    //}
                    //else
                    //{
                    //    Context.Add("CurShipQty", CurShipQty);
                    //}
                    //缓存出货箱数
                    Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton);
                    Context.SetOrAdd("CurWaitShipment", WaitShipment);
                    //if (Context.ContainsKey("CurWaitShipmentCarton"))
                    //{
                    //    Context["CurWaitShipmentCarton"] = WaitShipmentCarton;
                    //}
                    //else
                    //{
                    //    Context.Add("CurWaitShipmentCarton", WaitShipmentCarton);
                    //}
                    debug.Log(new StackFrame(true), "***** 12", info => { ConsoleExt.WriteLine(info.ToString()); });
                    //绑定条码到工单
@@ -706,6 +693,7 @@
            catch (Exception ex)
            {
                action.Data.ShortMsg = new("工步异常", ShortMessage.Types.Error);
                RemoveCurSnFromCurPackage(Context.ContainsKey("CurPackage") ? (Context["CurPackage"] as WipPkg).Item : null);
                ResetNode();
                //action.CatchExceptionWithLog(ex, $"{curNode.NODE_NAME}:工序节点工步提交数据异常,请检查工序节点设置");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.NodeSubmitException", curNode.NODE_NAME));
@@ -789,7 +777,7 @@
                    }
                };
            }
            //throw new Exception("哈");
            //保存数据库
            SaveStepsCommitActionToDB(endAction);
@@ -956,7 +944,7 @@
            try
            {
                var CurPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null;
                var LabelPV = MainDB.Queryable<BAS_LABEL_PV>().ToList();
                var LabelPV = MainDB.Queryable<BAS_PROCESS_VAR>().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()
@@ -1006,6 +994,26 @@
            NodeCmd = null;
        }
        public void RemoveCurSnFromCurPackage(WipPkgItem pkgItem)
        {
            if (!pkgItem.IsNullOrEmpty())
            {
                var delItem = pkgItem.Items.Where(q => CurWipSNs.Any(sn => q.WipSNs.ContainsKey(sn.ID))).ToList();
                if (delItem.Any())
                {
                    pkgItem.Items.RemoveAll(q => CurWipSNs.Any(sn => q.WipSNs.ContainsKey(sn.ID)));
                    pkgItem.IsFinished = false;
                }
                else
                {
                    foreach (var item in pkgItem.Items)
                    {
                        RemoveCurSnFromCurPackage(item);
                    }
                }
            }
        }
        public override bool Close(bool needSaveHistoryLog = false)
        {
            //needSaveHistoryLog = true;