From eec9f268552af1d0ce8c95312930770669f1cc18 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期五, 16 八月 2024 22:40:16 +0800 Subject: [PATCH] 增加客户端需要的工序信息和短消息 --- Tiger.Business.MES/WorkAction/PackingAction.cs | 201 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 133 insertions(+), 68 deletions(-) diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs index 2c0b098..88f623c 100644 --- a/Tiger.Business.MES/WorkAction/PackingAction.cs +++ b/Tiger.Business.MES/WorkAction/PackingAction.cs @@ -9,6 +9,8 @@ using Tiger.IBusiness.MES.WorkAction; using Tiger.Model; using Tiger.Model.Entitys.MES.Position; +using static Tiger.Model.WMS_ITEM_PKG; +using Tiger.Model.Minsun; namespace Tiger.Business.MES.WorkAction { @@ -30,6 +32,7 @@ public Dictionary<int, BAS_LABEL_TEMP> LabelDic { get; set; } = new(); public List<BAS_LABEL_PV> LabelPV { get; set; } = new(); public int FinishLevel = 0; + public bool NeedWeighing { get; set; } = false; #endregion Propertys & Variables #region Functions @@ -63,6 +66,8 @@ LabelDic.Add(code.PKG_LEVEL, label); } LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); + //鑾峰彇鏄惁鍖呰瀹屽悗闇�瑕佺О閲� + NeedWeighing = Setting.OPTION_2 == "Y"; //濡傛灉宸ュ簭涓婁笅鏂囦腑娌℃湁鍖呰璁板綍鍒欐柊寤轰竴涓紝鏈夊垯鑾峰彇褰撳墠鐨勫寘瑁呰褰� if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty()) { @@ -170,6 +175,7 @@ CurCmd = data; PrintTimes++; action.Data.Data = data; + action.Data.ShortMsg = new("鎵撳嵃鏍囩", ShortMessage.Types.Normal); //action.LocaleMsg = new Locale($"寮�濮嬬{PrintTimes}娆℃墦鍗扮{min.PKG_LEVEL}灞傚寘瑁匸{min.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[min.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[min.PKG_LEVEL].LABEL_NAME}]"); action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, min.PKG_LEVEL, min.PkgType.PKG_NAME, LabelDic[min.PKG_LEVEL]?.LABEL_CODE, LabelDic[min.PKG_LEVEL].LABEL_NAME); } @@ -198,6 +204,7 @@ if (!pInput.IsFinish || pInput.PkgSN.IsNullOrEmpty()) { var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); + action.Data.ShortMsg = new("鎵弿閿欒", ShortMessage.Types.Error); action.IsSuccessed = false; //action.LocaleMsg = new($"鏉$爜鎵弿澶辫触锛岃閲嶆柊鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�"); action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanFail", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); @@ -207,6 +214,7 @@ if (GetPackageList(CurPkg.Item).Any(q => q.SN == pInput.PkgSN)) { var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); + action.Data.ShortMsg = new("鎵弿閿欒", ShortMessage.Types.Error); action.IsSuccessed = false; //action.LocaleMsg = new($"鏉$爜[{pInput.PkgSN}]鏃犻渶閲嶅鎵弿锛岃鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�"); action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanRepeat", pInput.PkgSN, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); @@ -216,6 +224,10 @@ CurCmd = null; PrintTimes = 0; action = SavePkgData(input, action); + if (action.IsSuccessed) + { + action.Data.ShortMsg = new("鎵弿鎴愬姛", ShortMessage.Types.Success); + } } break; //Print锛氭墦鍗帮紝鎵撳嵃褰撳墠鍖呰灞傜骇鐨勬爣绛� @@ -233,6 +245,7 @@ data.PkgLevel = dtl.PKG_LEVEL; CurCmd = data; action.Data.Data = data; + action.Data.ShortMsg = new("鎵弿鏍囩", ShortMessage.Types.Normal); //action.LocaleMsg = new($"璇锋壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�"); action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); } @@ -244,6 +257,7 @@ { PrintTimes++; action.Data.Data = CurCmd; + action.Data.ShortMsg = new("閲嶆柊鎵撳嵃", ShortMessage.Types.Normal); //action.LocaleMsg = new Locale($"寮�濮媨PrintTimes}娆℃墦鍗扮{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[dtl.PKG_LEVEL].LABEL_NAME}]"); action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME); } @@ -251,6 +265,7 @@ { CurCmd = null; PrintTimes = 0; + action.Data.ShortMsg = new("鎵撳嵃澶辫触", ShortMessage.Types.Failed); action.IsSuccessed = false; //action.LocaleMsg = new($"灏濊瘯绗瑊PrintTimes}娆℃墦鍗扮{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[dtl.PKG_LEVEL].LABEL_NAME}]澶辫触锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜"); action.LocaleMsg = new("MES.WorkAction.PackingAction.PrintFail3Times", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME); @@ -265,7 +280,43 @@ { CurCmd = null; PrintTimes = 0; - action = End(); + if (NeedWeighing) + { + var data = new PackingActionOutput() { PkgInfo = CurPkg }; + data.ExecCode = "Weighing"; + data.PkgLevel = CurPkgItem.PKG_LEVEL; + CurCmd = data; + action.Data.Data = data; + action.Data.ShortMsg = new("鍖呰鎴愬姛", ShortMessage.Types.Success); + //action.LocaleMsg = new($"璇锋妸鍖呰[{CurPkgItem.Package.SN}]涓婄О绉伴噸"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing", CurPkgItem.Package.SN); + } + else + { + action = End(); + } + } + break; + // Complete锛氬畬鎴愶紝瀹屾垚鍏ㄩ儴鍖呰鍚庣粨鏉熻涓� + case "Weighing": + if (CurCmd.ExecCode == "Weighing") + { + if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0) + { + CurCmd = null; + PrintTimes = 0; + CurPkgItem.Package.WEIGHT = pInput.WeightInfo.Weight; + CurPkgItem.Package.WEIGHT_UNIT = pInput.WeightInfo.Unit; + action = End(); + } + else + { + action.IsSuccessed = false; + action.Data.ShortMsg = new("绉伴噸澶辫触", ShortMessage.Types.Failed); + //action.LocaleMsg = new($"鍖呰[{CurPkgItem.Package.SN}]绉伴噸鏁版嵁寮傚父锛岃閲嶆柊涓婄О绉伴噸"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain", CurPkgItem.Package.SN); + return action; + } } break; // 鎵嬪姩缁撴潫鍖呰锛屼繚瀛樻殏瀛樼殑鍖呰鏁版嵁 @@ -292,6 +343,7 @@ data.PkgLevel = dtl.PKG_LEVEL; CurCmd = data; action.Data.Data = data; + action.Data.ShortMsg = new("鎵弿鏍囩", ShortMessage.Types.Normal); //action.LocaleMsg = new($"璇锋壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�"); action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); } @@ -307,6 +359,7 @@ CurCmd = data; PrintTimes++; action.Data.Data = data; + action.Data.ShortMsg = new("鎵撳嵃鏍囩", ShortMessage.Types.Normal); //action.LocaleMsg = new Locale($"寮�濮嬬{PrintTimes}娆℃墦鍗扮{min.PKG_LEVEL}灞傚寘瑁匸{min.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[min.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[min.PKG_LEVEL].LABEL_NAME}]"); action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME); } @@ -345,29 +398,30 @@ PKG_QTY = dtl.PKG_QTY, LABEL_CODE = LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, IsFinished = true, - Package = new() - { - AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, - AUTH_PROD = CurPosition.CurLine.LINE_CODE, - SN = pInput.PkgSN, - WIP_ID = CurPosition.CurWipSNs.Count == 1 ? CurPosition.CurWipSNs.First().ID : null, - PKG_TYPE = dtl.PkgType.PKG_NAME, - ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE, - QTY = CurPosition.CurWipSNs.First().QTY, - UNIT = dtl.PkgType.PKG_NAME, - WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER, - BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO, - ROT_CODE = CurPosition.CurWipSNs.First().ROT_CODE, - NODE_ID = CurPosition.CurWipSNs.First().NODE_ID, - NODE_NAME = CurPosition.CurWipSNs.First().NODE_NAME, - FTY_CODE = CurPosition.CurWipSNs.First().FTY_CODE, - WS_CODE = CurPosition.CurWipSNs.First().WS_CODE, - LINE_CODE = CurPosition.CurWipSNs.First().LINE_CODE, - POST_CODE = CurPosition.CurWipSNs.First().POST_CODE, - OPER_CODE = CurPosition.CurWipSNs.First().OPER_CODE, - SEGMENT = CurPosition.CurWipSNs.First().SEGMENT, - } }; + + CurPkgItem.Package = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == pInput.PkgSN && q.AUTH_ORG == CurPosition.WorkBatch.WO.AUTH_ORG).First() ?? new() + { + AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, + AUTH_PROD = CurPosition.CurLine.LINE_CODE, + SN = pInput.PkgSN, + }; + CurPkgItem.Package.WIP_ID = CurPosition.CurWipSNs.Count == 1 ? CurPosition.CurWipSNs.First().ID : null; + CurPkgItem.Package.PKG_TYPE = dtl.PkgType.PKG_NAME; + CurPkgItem.Package.ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE; + CurPkgItem.Package.QTY = CurPosition.CurWipSNs.First().QTY; + CurPkgItem.Package.UNIT = dtl.PkgType.PKG_NAME; + CurPkgItem.Package.WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER; + CurPkgItem.Package.BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO; + CurPkgItem.Package.ROT_CODE = CurPosition.CurWipSNs.First().ROT_CODE; + CurPkgItem.Package.NODE_ID = CurPosition.CurWipSNs.First().NODE_ID; + CurPkgItem.Package.NODE_NAME = CurPosition.CurWipSNs.First().NODE_NAME; + CurPkgItem.Package.FTY_CODE = CurPosition.CurWipSNs.First().FTY_CODE; + CurPkgItem.Package.WS_CODE = CurPosition.CurWipSNs.First().WS_CODE; + CurPkgItem.Package.LINE_CODE = CurPosition.CurWipSNs.First().LINE_CODE; + CurPkgItem.Package.POST_CODE = CurPosition.CurWipSNs.First().POST_CODE; + CurPkgItem.Package.OPER_CODE = CurPosition.CurWipSNs.First().OPER_CODE; + CurPkgItem.Package.SEGMENT = CurPosition.CurWipSNs.First().SEGMENT; FinishLevel++; action = SavePkgData(input, action); } @@ -482,6 +536,7 @@ //鏁版嵁寮傚父 else { + action.Data.ShortMsg = new("鍖呰閿欒", ShortMessage.Types.Error); var pdtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); action.IsSuccessed = false; //action.LocaleMsg = new($"瀹㈡埛绔彁浜ょ殑鍖呰灞傜骇[{pdtl.PKG_LEVEL}]({pdtl.PkgType.PKG_NAME})鏁版嵁涓嶆槸姝e湪澶勭悊鐨勫寘瑁呭眰绾{dtl.PKG_LEVEL}]({dtl.PkgType.PKG_NAME})锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜"); @@ -492,6 +547,7 @@ } catch (System.Exception ex) { + action.Data.ShortMsg = new("鍖呰寮傚父", ShortMessage.Types.Exception); var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); action.CatchExceptionWithLog(ex, $"鍖呰琛屼负锛氭壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮乕{input.SN}]鍚庝繚瀛樻暟鎹け璐�"); action.IsSuccessed = false; @@ -522,14 +578,15 @@ data.PkgLevel = CurPkg.Item.PKG_LEVEL; CurCmd = data; action.Data.Data = data; + action.Data.ShortMsg = new("淇濆瓨鍖呰鏁版嵁", ShortMessage.Types.Normal); //action.LocaleMsg = new($"绗瑊CurPkg.Item.PKG_LEVEL}灞傚寘瑁匸{CurPkg.Item.PKG_NAME}]宸茬粡鍏ㄩ儴瀹屾垚锛屼繚瀛樺寘瑁呮暟鎹�"); action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageComplete", CurPkg.Item.PKG_LEVEL, CurPkg.Item.PKG_NAME); //鎵嬪姩缁撴潫鍖呰鍒欐爣璁拌涓哄畬鎴� - if (CurStep.IsNullOrEmpty()) - { - IsFinished = true; - } + //if (CurStep.IsNullOrEmpty()) + //{ + // IsFinished = true; + //} return action; } @@ -544,45 +601,49 @@ //璁板綍琛屼负鎿嶄綔璁板綍 var wipActs = new List<MES_WIP_ACT>(); - foreach (var wipSn in CurPosition.CurWipSNs) + //涓嶆槸鎵嬪姩缁撴潫鍖呰鍒欎繚瀛樿涓烘搷浣滆褰� + if (!CurStep.IsNullOrEmpty()) { - var wipAct = new MES_WIP_ACT() - { - AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, - AUTH_PROD = CurPosition.CurLine.LINE_CODE, - WIP_ID = wipSn.ID, - HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, - SN = wipSn.SN, - STATUS = wipSn.STATUS, - ITEM_CODE = wipSn.ITEM_CODE, - WORK_ORDER = wipSn.WORK_ORDER, - BATCH_NO = wipSn.BATCH_NO, - ROT_CODE = wipSn.ROT_CODE, - NODE_ID = wipSn.NODE_ID, - NODE_NAME = wipSn.NODE_NAME, - ACT_ID = NodeAct.ID, - ACT_NAME = NodeAct.ACT_NAME, - FTY_CODE = wipSn.FTY_CODE, - WS_CODE = wipSn.WS_CODE, - LINE_CODE = wipSn.LINE_CODE, - POST_CODE = wipSn.POST_CODE, - OPER_CODE = wipSn.OPER_CODE, - SEGMENT = wipSn.SEGMENT, - FLOW_SN = wipSn.FLOW_SN, - TRAY_SN = wipSn.TRAY_SN, - INNER_SN = wipSn.INNER_SN, - CARTON_SN = wipSn.CARTON_SN, - PALLET_SN = wipSn.PALLET_SN, - OPERATION_TIME = DateTime.Now, - SFTS_CODE = wipSn.SFTS_CODE, - SFT_CODE = wipSn.SFT_CODE, - PRD_CODE = wipSn.PRD_CODE, - ACT_TYPE = NodeAct.ACT_TYPE, - ACT_SN = wipSn.SN, - ACT_RESULT = "Y", - TRACE_INFO = $"浜у搧鏉$爜[{string.Join("锛�", CurPosition.CurSN)}]鍖呰瀹屾垚", - }; - wipActs.Add(wipAct); + foreach (var wipSn in CurPosition.CurWipSNs) + { + var wipAct = new MES_WIP_ACT() + { + AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, + AUTH_PROD = CurPosition.CurLine.LINE_CODE, + WIP_ID = wipSn.ID, + HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, + SN = wipSn.SN, + STATUS = wipSn.STATUS, + ITEM_CODE = wipSn.ITEM_CODE, + WORK_ORDER = wipSn.WORK_ORDER, + BATCH_NO = wipSn.BATCH_NO, + ROT_CODE = wipSn.ROT_CODE, + NODE_ID = wipSn.NODE_ID, + NODE_NAME = wipSn.NODE_NAME, + ACT_ID = NodeAct.ID, + ACT_NAME = NodeAct.ACT_NAME, + FTY_CODE = wipSn.FTY_CODE, + WS_CODE = wipSn.WS_CODE, + LINE_CODE = wipSn.LINE_CODE, + POST_CODE = wipSn.POST_CODE, + OPER_CODE = wipSn.OPER_CODE, + SEGMENT = wipSn.SEGMENT, + FLOW_SN = wipSn.FLOW_SN, + TRAY_SN = wipSn.TRAY_SN, + INNER_SN = wipSn.INNER_SN, + CARTON_SN = wipSn.CARTON_SN, + PALLET_SN = wipSn.PALLET_SN, + OPERATION_TIME = DateTime.Now, + SFTS_CODE = wipSn.SFTS_CODE, + SFT_CODE = wipSn.SFT_CODE, + PRD_CODE = wipSn.PRD_CODE, + ACT_TYPE = NodeAct.ACT_TYPE, + ACT_SN = wipSn.SN, + ACT_RESULT = "Y", + TRACE_INFO = $"浜у搧鏉$爜[{string.Join("锛�", CurPosition.CurSN)}]鍖呰瀹屾垚", + }; + wipActs.Add(wipAct); + } } //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊� @@ -592,7 +653,10 @@ CurStep.DBSubmitAction = () => { var db = CurPosition.GetCommitDB(); - db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); + if (_wipActs.Any()) + { + db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); + } if (_pkgList.Any()) { db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand(); @@ -638,8 +702,9 @@ } IsFinished = true; - action.LocaleMsg = new($"浜у搧鏉$爜[{CurPosition.CurSN}]鍖呰瀹屾垚"); - action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN); + action.Data.ShortMsg = new("鍖呰瀹屾垚", ShortMessage.Types.Success); + action.LocaleMsg = new($"鏉$爜[{CurPkg.Item.Package.SN}]鍖呰瀹屾垚"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPkg.Item.Package.SN); return action; } -- Gitblit v1.9.3