| | |
| | | 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 |
| | |
| | | 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") |
| | |
| | | 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() |
| | |
| | | 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()) |
| | | { |
| | |
| | | { |
| | | 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); |
| | | } |
| | | |
| | | //工单开工 |
| | |
| | | //条码完工 |
| | | 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; |
| | |
| | | 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(); |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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> |