服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-11-20 a96b665105c57a4ae67d286b2bb6897988ca590e
Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -36,6 +36,7 @@
        public string NodeCmd { get; set; }
        public PackingAction TempPkgAction { get; set; }
        public bool IsPrintCustomerLabel { get; set; }
        public string ShippingOrder { get; set; }
        #endregion Propertys & Variables
        #region Functions
@@ -49,19 +50,23 @@
            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
            try
            {
                if (input.Qty.ToInt32() <= 0)
                {
                    action.Data.ShortMsg = new("请输入包装数量", ShortMessage.Types.Error);
                    action.Data.OperInfo = new();
                    action.Data.Data = "QtyError";
                    action.IsSuccessed = false;
                    action.LocaleMsg = new($"包装数量[{input.Qty}]不正确,请重新输入数量后继续包装操作");
                    //action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.QtyError", input.Qty);
                    return action;
                }
                //if (input.Qty.ToInt32() <= 0)
                //{
                //    action.Data.ShortMsg = new("请输入包装数量", ShortMessage.Types.Error);
                //    action.Data.OperInfo = new();
                //    action.Data.Data = "QtyError";
                //    action.IsSuccessed = false;
                //    action.LocaleMsg = new($"包装数量[{input.Qty}]不正确,请重新输入数量后继续包装操作");
                //    //action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.QtyError", input.Qty);
                //    return action;
                //}
                if (input.Options.ContainsKey("IsPrintCustomerLabel"))
                {
                    IsPrintCustomerLabel = input.Options["IsPrintCustomerLabel"].ToBoolean();
                }
                if (input.Options.ContainsKey("ShippingOrder"))
                {
                    ShippingOrder = IsPrintCustomerLabel ? input.Options["ShippingOrder"].ToString() : "";
                }
                //PkgSubmit:手动结束包装,手动保存暂存的包装数据
                if (NodeCmd == "PkgSubmit")
@@ -318,7 +323,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.STATUS < MES_WIP_DATA.STATUSs.Finished.GetValue()).ToList();
                    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();
                    if (wipSNs.IsNullOrEmpty())
                    {
                        var wipSN = new MES_WIP_DATA()
@@ -418,6 +423,7 @@
                        wipSN.OPER_CODE = curNode.OPER_CODE;
                        wipSN.SEGMENT = curNode.SEGMENT;
                        wipSN.OPERATION_TIME = DateTime.Now;
                        wipSN.SHIPPING_ORDER = ShippingOrder;
                        var curShiftPeriod = GetShiftPeriodForNow();
                        if (!curShiftPeriod.IsNullOrEmpty())
                        {
@@ -438,7 +444,7 @@
                        {
                            var woSN = woSNs.First(q => q.WIP_ID == wipSN.ID);
                            woSN.STATUS = BIZ_MES_WO_SN.STATUSs.Finished.GetValue();
                            wipSN.STATUS = MES_WIP_DATA.STATUSs.Finished.GetValue();
                            wipSN.STATUS = MES_WIP_DATA.STATUSs.Output.GetValue();
                            wipSN.OUTLINE_DATE = DateTime.Now;
                        }
                        //如果有提交不良
@@ -672,7 +678,7 @@
                //条码完工
                foreach (var wipSN in CurWipSNs)
                {
                    wipSN.STATUS = MES_WIP_DATA.STATUSs.Finished.GetValue();
                    wipSN.FINISHED_FLAG = "Y";
                    wipSN.NODE_ID = curNode.ID;
                    wipSN.NODE_NAME = curNode.NODE_NAME;
                    wipSN.OPER_CODE = curNode.OPER_CODE;
@@ -872,6 +878,34 @@
            return action;
        }
        /// <summary>
        /// 打印测试标签
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<PackingActionOutput>> TestPrint()
        {
            var action = new ApiAction<PackingActionOutput>();
            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 printLb =  SetLabelVariables(LabelPV, label, new PackingAction(), CurPkg);
                action.Data = new PackingActionOutput()
                {
                    ExecCode = "PrintTest",
                    PkgInfo = CurPkg,
                    PrintLable = printLb,
                };
            }
            catch (Exception ex)
            {
                action.CatchExceptionWithLog(ex, $"包装工序:打印测试标签异常");
            }
            return action;
        }
        #endregion Functions
        /// <summary>