| | |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Tiger.Business.MES.WorkAction; |
| | | using Tiger.Model.MES.Yada; |
| | | using System.Data; |
| | | using System.Diagnostics; |
| | | |
| | | namespace Tiger.Business.MES.Transaction |
| | | { |
| | |
| | | public new IYadaPacking Init(string id, string apiHost, string userCode, string postCode) |
| | | { |
| | | base.Init(id, apiHost, userCode, postCode); |
| | | U9CDB = Biz.DataSource["YadaU9C"].Client; |
| | | Logger.Console.Info($"User[{userCode}] start a {this.GetType().Name}[{postCode}] Transaction[ID: {TransID}]"); |
| | | return this; |
| | | } |
| | |
| | | public string NodeCmd { get; set; } |
| | | 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; |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<SubmitOutput>> Submit(SubmitInput input) |
| | | { |
| | | debug = new(new StackFrame(true)); |
| | | debug.Log(new StackFrame(true), "***** 1", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | 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.Options.ContainsKey("IsPrintCustomerLabel")) |
| | | { |
| | | IsPrintCustomerLabel = input.Options["IsPrintCustomerLabel"].ToBoolean(); |
| | | } |
| | | //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 SetOutPutMqttMsg(action, input.Locale); |
| | | //} |
| | | //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") |
| | | { |
| | |
| | | //工步列表为空或者工序节点工步有未完成时,优先完成工序节点工步 |
| | | if (Steps.IsNullOrEmpty() || !IsFinishNodeSteps) |
| | | { |
| | | 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(); |
| | | debug.Log(new StackFrame(true), "***** 2", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //先判断当前工单不为空且当前岗位在当前工单是不是首站,如果是则不允许变更当前工单,尝试把条码绑定到当前工单 |
| | | if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode)) |
| | | { |
| | | //更新CurBatch |
| | | CurBatch?.Update(); |
| | | //提交数据 |
| | | action = NodeSubmit(action, input); |
| | | //更新工序信息 |
| | | if (!action.IsSuccessed) |
| | | 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()) |
| | | { |
| | | var info = WoContext.GetSnOperInfo(input.SN).Data; |
| | | info.InputQty = CurOperInfo(input.Locale).InputQty; |
| | | action.Data.OperInfo = info; |
| | | action.Data.ShortMsg = new($"产品{wosn.SN.STATUS.GetEnumDesc<BIZ_MES_WO_SN.STATUSs>()}", ShortMessage.Types.Error); |
| | | action.Data.OperInfo = new(); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"进站扫描错误,条码[{0}]{1}", input.SN); |
| | | action.LocaleMsg = new("MES.Transaction.CollectNode.Submit.SnStatusError", input.SN, wosn.SN.STATUS.GetEnumDesc<BIZ_MES_WO_SN.STATUSs>()); |
| | | } |
| | | else if (Steps.Any() && !IsFinishAllSteps) |
| | | else |
| | | { |
| | | action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale)); |
| | | //提交数据 |
| | | action = NodeSubmit(action, input); |
| | | debug.Log(new StackFrame(true), "***** 4", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //更新工序信息 |
| | | if (!action.IsSuccessed) |
| | | { |
| | | var info = WoContext.GetSnOperInfo(input.SN).Data; |
| | | info.InputQty = CurOperInfo(input.Locale).InputQty; |
| | | action.Data.OperInfo = info; |
| | | } |
| | | else if (Steps.Any() && !IsFinishAllSteps) |
| | | { |
| | | action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale)); |
| | | } |
| | | } |
| | | } |
| | | //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单 |
| | | else |
| | | { |
| | | 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(); |
| | | |
| | | //查找到条码已绑定的工单 |
| | | if (wosns.Any(q => q.SN.STATUS < BIZ_MES_WO_SN.STATUSs.Finished.GetValue())) |
| | | { |
| | |
| | | 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) |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"正在包装工单批次[{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) |
| | | { |
| | |
| | | action.Data.OperInfo = new(); |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | } |
| | | //更新CurBatch |
| | |
| | | { |
| | | //更新CurBatch |
| | | CurBatch?.Update(); |
| | | |
| | | 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); |
| | | debug.Log(new StackFrame(true), "***** 6", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | } |
| | | else |
| | | { |
| | | action = submitStep.Submit(input); |
| | | debug.Log(new StackFrame(true), "***** 7", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | //如果当前工步已完成,开始执行下一工步 |
| | | if (action.IsSuccessed && submitStep.IsFinished) |
| | | { |
| | | action = BeginNextActionStep(input); |
| | | debug.Log(new StackFrame(true), "***** 8", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | } |
| | | //如果当前工步未完成 |
| | | else |
| | |
| | | //action.CatchExceptionWithLog(ex, $"包装工序:提交操作数据异常"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException")); |
| | | } |
| | | return action; |
| | | debug.Log(new StackFrame(true), "***** 9", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> NodeSubmit(ApiAction<SubmitOutput> action, SubmitInput input) |
| | | { |
| | | debug.Log(new StackFrame(true), "***** 10", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | var curNode = CurBatch.GetNode(PostCode); |
| | | try |
| | | { |
| | |
| | | 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).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() |
| | |
| | | |
| | | //设置当前指令为正常产品过站 |
| | | NodeCmd = "NodeSubmit"; |
| | | 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 |
| | | { |
| | | CurShipQty = ship.ShipQty; |
| | | 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["WaitShipmentCarton"].ToInt32(); |
| | | WaitShipment = batchCount["WaitShipment"].ToInt32(); |
| | | IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true; |
| | | } |
| | | } |
| | | 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()); }); |
| | | //绑定条码到工单 |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | |
| | | wipSN.OPER_CODE = curNode.OPER_CODE; |
| | | wipSN.SEGMENT = curNode.SEGMENT; |
| | | wipSN.OPERATION_TIME = DateTime.Now; |
| | | wipSN.SHIPPING_ORDER = ShippingOrder; |
| | | wipSN.UNBIND_FLAG = "N"; |
| | | var curShiftPeriod = GetShiftPeriodForNow(); |
| | | if (!curShiftPeriod.IsNullOrEmpty()) |
| | | { |
| | |
| | | { |
| | | 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; |
| | | } |
| | | //如果有提交不良 |
| | |
| | | OBA_BATCH = wipSN.OBA_BATCH, |
| | | LOCK_BATCH = wipSN.LOCK_BATCH, |
| | | }; |
| | | wipSN.Defects.Add(defect); |
| | | CurDefects.Add(defect); |
| | | } |
| | | } |
| | | |
| | | //产品被判断不良后下线,并从工单中移除正在生产的条码 |
| | | if (CurDefects.Any() && curNodeSetting.IF_DFT_OFFLINE == "Y") |
| | | { |
| | | woStatus.Data.ShortMsg = new("产品下线", ShortMessage.Types.Error); |
| | | return OfflineIfDefect(action, wipSNs, input.Locale); |
| | | } |
| | | |
| | | //工单开工 |
| | |
| | | var _curNodeSetting = curNodeSetting.Clone(); |
| | | var _Batch = CurBatch.Batch.Clone(); |
| | | |
| | | 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)); |
| | | } |
| | | 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; |
| | | debug.Log(new StackFrame(true), "***** 14", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | |
| | | //如果当前条码已经走到流程终点则记录条码完工 |
| | | if (operInfo.IsReachedEndNode) |
| | |
| | | //条码完工 |
| | | 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; |
| | |
| | | var _woSns = woSNs.Clone(); |
| | | var _wipSns = CurWipSNs.Clone(); |
| | | var _wipHiss = wipHiss.Clone(); |
| | | var _pkgList = curPkg?.IsFinished == true ? GetPackageList(curPkg.Item) : new(); |
| | | var _pkgList = curPkg?.IsFinished == true ? GetPackageList(curPkg.Item).Clone() : new(); |
| | | var _wipIDs = curPkg?.IsFinished == true ? curPkg.Item.GetWipSnList().Select(q => q.Key).ToList().Clone() : new(); |
| | | //保存数据 |
| | | endAction = () => |
| | | { |
| | |
| | | db.Storageable(_wipHiss, UserCode).ExecuteCommand(); |
| | | if (_pkgList.Any()) |
| | | { |
| | | var wipIDs = _pkgList.Where(q => !q.WIP_ID.IsNullOrEmpty()).Select(q => q.WIP_ID).ToList(); |
| | | //var wipIDs = _pkgList.Where(q => !q.WIP_ID.IsNullOrEmpty()).Select(q => q.WIP_ID).ToList(); |
| | | var wo = _pkgList.First().WORK_ORDER; |
| | | //包装信息保存到生产过程记录 |
| | | db.Updateable<MES_WIP_HIS>(UserCode) |
| | | .SetColumns(q => q.TRAY_SN == curPkg.Item.Package.SN) |
| | | .SetColumns(q => q.INNER_SN == q.CARTON_SN) |
| | | .SetColumns(q => q.CARTON_SN == curPkg.Item.Package.SN) |
| | | .Where(q => q.WORK_ORDER == wo && q.OPER_CODE == "EndNode" && wipIDs.Contains(q.WIP_ID)) |
| | | .Where(q => q.WORK_ORDER == wo && q.OPER_CODE == "EndNode" && _wipIDs.Contains(q.WIP_ID)) |
| | | .ExecuteCommand(); |
| | | } |
| | | }; |
| | |
| | | SaveStepsCommitActionToDB(endAction); |
| | | |
| | | //保存成功,返回过站消息 |
| | | CurOperInfo(locale).InputQty += CurWipSNs.Count; |
| | | operInfo.InputQty += CurWipSNs.Count; |
| | | action.Data.Data = new PackingActionOutput() { PkgInfo = curPkg }; |
| | | action.Data.OperInfo = operInfo; |
| | | action.Data.ShortMsg = new(CurWipSNs.Any(q => q.DFT_FLAG == "Y") ? "不良过站" : "良品过站", ShortMessage.Types.Success); |
| | |
| | | |
| | | //重置工序 |
| | | ResetNode(); |
| | | debug.Log(new StackFrame(true), "***** 15", info => { ConsoleExt.WriteLine(info.ToString()); }); |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 产品被判断不良后下线 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> OfflineIfDefect(ApiAction<SubmitOutput> action, List<MES_WIP_DATA> wipSNs, string locale) |
| | | { |
| | | var operInfo = SetOperNodeInfo(CurOperInfo(locale)); |
| | | operInfo.CurNode = wipSNs.FirstOrDefault()?.NODE_NAME; |
| | | operInfo.NextNode = "下线退库"; |
| | | |
| | | //更新工单条码明细信息 |
| | | var woSNs = CurBatch.WoSNs.Where(q => wipSNs.Any(w => q.WIP_ID == w.ID)).ToList(); |
| | | foreach (var woSN in woSNs) |
| | | { |
| | | woSN.STATUS = BIZ_MES_WO_SN.STATUSs.Offline.GetValue(); |
| | | } |
| | | |
| | | //条码下线 |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.Offline.GetValue(); |
| | | wipSN.UNBIND_FLAG = "Y"; |
| | | } |
| | | |
| | | var wipHiss = new List<MES_WIP_HIS>(); |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | | var his = new MES_WIP_HIS(wipSN, $"工单[{wipSN.WORK_ORDER}]条码[{wipSN.SN}]在岗位[{wipSN.POST_CODE}]工序[{wipSN.NODE_NAME}]因不良[{wipSN.Defects.FirstOrDefault()?.DFT_NAME}]下线(TransId: {TransID} )"); |
| | | wipSN.History.Add(his); |
| | | wipHiss.Add(his); |
| | | } |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _woSns = woSNs.Clone(); |
| | | var _wipSns = wipSNs.Clone(); |
| | | var _wipHiss = wipHiss.Clone(); |
| | | var _defect = CurDefects.Clone(); |
| | | //使用统一的事务DB对象 |
| | | var db = GetCommitDB(); |
| | | //保存数据库 |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | //数据保存逻辑 |
| | | db.Storageable(_woSns, UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipSns, UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipHiss, UserCode).ExecuteCommand(); |
| | | db.Storageable(_defect, UserCode).ExecuteCommand(); |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | //抛出异常 |
| | | throw dbTran.ErrorException; |
| | | } |
| | | |
| | | //从工单中移除正在生产的条码 |
| | | CurBatch.RemoveWipSn(wipSNs, UserCode); |
| | | |
| | | //保存成功,返回过站消息 |
| | | action.Data.OperInfo = operInfo; |
| | | action.Data.ShortMsg = new("下线退库", ShortMessage.Types.Warning); |
| | | //action.LocaleMsg = new($"工单[0]的条码[1]在岗位[2]工序[3]因不良[4]下线,状态[5]"); |
| | | action.LocaleMsg = new("MES.Transaction.TestNode.OfflineIfDefect", wipSNs.First().WORK_ORDER, CurSN, wipSNs.First().POST_CODE, wipSNs.First().NODE_NAME, wipSNs.First().Defects.FirstOrDefault()?.DFT_NAME, wipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()); |
| | | |
| | | //重置工序 |
| | | ResetNode(); |
| | | return action; |
| | | } |
| | | |
| | |
| | | TempPkgAction.Init(this); |
| | | |
| | | int shipQty = input.Data.ToInt32(); |
| | | int curQty = CurPkg.Item.TotalQty; |
| | | double curQty = CurPkg.Item.TotalQty; |
| | | int ruleQty = TempPkgAction.PkgRule.GetTotalQty(); |
| | | //有填出货数量则验证当前包装数量必须等于(出货数量/包装规则数量)的余数 |
| | | if (shipQty > 0 && curQty != shipQty % ruleQty) |
| | |
| | | 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"; |
| | |
| | | action.CatchExceptionWithLog(ex, $"包装工序:手动结束包装异常"); |
| | | NodeCmd = null; |
| | | } |
| | | return SetOutPutMqttMsg(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 = 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() |
| | | { |
| | | ExecCode = "PrintTest", |
| | | PkgInfo = CurPkg, |
| | | PrintLable = printLb, |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | action.CatchExceptionWithLog(ex, $"包装工序:打印测试标签异常"); |
| | | } |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取是否打印客户标签还是入库标签 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<ShipingInfo>> GetIsCustomerLabelAndShipQty() |
| | | { |
| | | var action = new ApiAction<ShipingInfo>(); |
| | | try |
| | | { |
| | | 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) |
| | | { |
| | | action.CatchExceptionWithLog(ex, $"包装工序:获取是否打印客户标签还是入库标签异常"); |
| | | } |
| | | return action; |
| | | } |
| | | |