From 0116b5d2ed16a0825da9e7474fc786ee06b2d60c Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期三, 04 九月 2024 08:40:31 +0800 Subject: [PATCH] 增加公布提示信息和状态 --- Tiger.Business.MES/WorkAction/PackingAction.cs | 434 ++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 326 insertions(+), 108 deletions(-) diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs index 58008e4..5172731 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 { @@ -23,6 +25,7 @@ public MES_WO_ACTION Setting { get; set; } #endregion public BAS_PKG_RULE PkgRule { get; set; } + public BAS_PKG_PROD PkgProd { get; set; } public WipPkg CurPkg { get; set; } public WipPkgItem CurPkgItem { get; set; } public PackingActionOutput CurCmd { get; set; } @@ -30,6 +33,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 @@ -62,6 +66,11 @@ var label = code.LABEL_CODE.IsNullOrEmpty() ? null : Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == code.LABEL_CODE).IncludesAllFirstLayer().First(); LabelDic.Add(code.PKG_LEVEL, label); } + LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); + //鑾峰彇鏄惁鍖呰瀹屽悗闇�瑕佺О閲� + NeedWeighing = Setting.OPTION_2 == "Y"; + //鑾峰彇鍖呰瑙勫垯鐨勭О閲嶈寖鍥� + PkgProd = Biz.Db.Queryable<BAS_PKG_PROD>().Where(q => q.PKG_RULE_ID == PkgRule.ID && q.ITEM_CODE == CurPosition.WorkBatch.WO.ITEM_CODE).First(); //濡傛灉宸ュ簭涓婁笅鏂囦腑娌℃湁鍖呰璁板綍鍒欐柊寤轰竴涓紝鏈夊垯鑾峰彇褰撳墠鐨勫寘瑁呰褰� if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty()) { @@ -168,7 +177,10 @@ data.PrintLable = LabelDic[min.PKG_LEVEL]; CurCmd = data; PrintTimes++; + CurStep.Message = Biz.L("鎵撳嵃鏍囩"); + CurStep.Status = StepStatus.Normal; 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); } @@ -193,21 +205,39 @@ case "Scan": if (CurCmd.IsNullOrEmpty() || CurCmd.ExecCode == "Scan" || (CurCmd.ExecCode == "Print" && CurCmd.PkgLevel == pInput.PkgLevel)) { - //瀹㈡埛绔壂鎻忔垚鍔� - if (pInput.IsFinish) - { - CurCmd = null; - PrintTimes = 0; - action = SavePkgData(input, action); - } //瀹㈡埛绔壂鎻忓け璐� - else + if (!pInput.IsFinish || pInput.PkgSN.IsNullOrEmpty()) { var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); + CurStep.Message = Biz.L("鎵弿閿欒"); + CurStep.Status = StepStatus.Error; + 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); return action; + } + //楠岃瘉褰撳墠鍖呰鏉$爜鏄惁宸茬粡琚壂鎻忚繃 + if (GetPackageList(CurPkg.Item).Any(q => q.SN == pInput.PkgSN)) + { + var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); + CurStep.Message = Biz.L("鎵弿閿欒"); + CurStep.Status = StepStatus.Error; + 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); + return action; + } + //瀹㈡埛绔壂鎻忔垚鍔� + CurCmd = null; + PrintTimes = 0; + action = SavePkgData(input, action); + if (action.IsSuccessed) + { + CurStep.Message = Biz.L("鎵弿鎴愬姛"); + CurStep.Status = StepStatus.Success; + action.Data.ShortMsg = new("鎵弿鎴愬姛", ShortMessage.Types.Success); } } break; @@ -225,7 +255,10 @@ data.ExecCode = "Scan"; data.PkgLevel = dtl.PKG_LEVEL; CurCmd = data; + CurStep.Message = Biz.L("鎵弿鏍囩"); + CurStep.Status = StepStatus.Normal; 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); } @@ -236,7 +269,10 @@ if (PrintTimes < 3 && !CurCmd.IsNullOrEmpty()) { PrintTimes++; + CurStep.Message = Biz.L("閲嶆柊鎵撳嵃"); + CurStep.Status = StepStatus.Normal; 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); } @@ -244,11 +280,98 @@ { CurCmd = null; PrintTimes = 0; + CurStep.Message = Biz.L("鎵撳嵃澶辫触"); + CurStep.Status = StepStatus.Error; + 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); CurPosition.ResetNode(); } + } + } + break; + // Weighing锛氱О閲嶏紝瀹屾垚鍖呰鍚庡鏁翠釜鍖呰鎴愮О閲� + case "Weighing": + if (CurCmd.ExecCode == "Weighing") + { + if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0) + { + //楠岃瘉閲嶉噺鏁版嵁鏄惁绗﹀悎璁剧疆濂界殑閲嶉噺鑼冨洿 + if (!PkgProd.IsNullOrEmpty() && (pInput.WeightInfo.Weight < PkgProd.MIN_WEIGHT || PkgProd.MIN_WEIGHT < pInput.WeightInfo.Weight)) + { + action.IsSuccessed = false; + CurStep.Message = Biz.L("閲嶉噺瓒呴檺"); + CurStep.Status = StepStatus.Error; + action.Data.Data = CurCmd; + action.Data.ShortMsg = new("閲嶉噺瓒呴檺", ShortMessage.Types.Failed); + //action.LocaleMsg = new($"澶栧寘瑁呴噸閲廩{0}]瓒呭嚭浜у搧[{1}]鍦ㄥ寘瑁呰鍒橻{2}]涓殑棰勮鑼冨洿[{3} - {4}]锛岃澶勭悊鍚庨噸鏂颁笂绉扮О閲�"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageOverWeight", pInput.WeightInfo.Weight + pInput.WeightInfo.Unit.IsNullOrEmpty("", " " + pInput.WeightInfo.Unit), CurPosition.WorkBatch.WO.ITEM_CODE, PkgRule.RULE_NAME, PkgProd.MIN_WEIGHT + PkgProd.MIN_UNIT.IsNullOrEmpty("", " " + PkgProd.MIN_UNIT), PkgProd.MAX_WEIGHT + PkgProd.MAX_UNIT.IsNullOrEmpty("", " " + PkgProd.MAX_UNIT)); + return action; + } + + CurCmd = null; + PrintTimes = 0; + CurPkg.WeightInfo.Weight = pInput.WeightInfo.Weight; + CurPkg.WeightInfo.Unit = pInput.WeightInfo.Unit; + NeedWeighing = false; + + //绉伴噸鎴愬姛锛岀户缁涓� + var dtl = PkgRule.Details.FirstOrDefault(q => q.PKG_LEVEL == FinishLevel + 1); + //鏈�澶栧眰鍖呰宸插鐞嗗畬鎴愬垯鐩存帴缁撴潫琛屼负 + if (CurPkg.Item.PKG_LEVEL == FinishLevel) + { + action = End(input); + } + //鏈�澶栧眰鍖呰鏈墦鍗版壂鎻忓垯缁х画 + else + { + //濡傛灉涓虹┖鍒欎笉闇�瑕佹墦鍗� + if (LabelDic[dtl.PKG_LEVEL].IsNullOrEmpty()) + { + var data = new PackingActionOutput() { PkgInfo = CurPkg }; + data.ExecCode = "Scan"; + data.PkgLevel = dtl.PKG_LEVEL; + CurCmd = data; + CurStep.Message = Biz.L("鎵弿鏍囩"); + CurStep.Status = StepStatus.Normal; + 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); + } + else + { + //璁剧疆鎵撳嵃鍙橀噺鍊� + LabelDic[dtl.PKG_LEVEL] = CurPosition.SetLabelVariables(LabelPV, LabelDic[dtl.PKG_LEVEL]); + + var data = new PackingActionOutput() { PkgInfo = CurPkg }; + data.ExecCode = "Print"; + data.PkgLevel = dtl.PKG_LEVEL; + data.PrintLable = LabelDic[dtl.PKG_LEVEL]; + CurCmd = data; + PrintTimes++; + CurStep.Message = Biz.L("鎵撳嵃鏍囩"); + CurStep.Status = StepStatus.Normal; + action.Data.Data = data; + 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); + } + } + + + } + else + { + action.IsSuccessed = false; + CurStep.Message = Biz.L("绉伴噸澶辫触"); + CurStep.Status = StepStatus.Error; + action.Data.Data = CurCmd; + action.Data.ShortMsg = new("绉伴噸澶辫触", ShortMessage.Types.Failed); + //action.LocaleMsg = new($"澶栧寘瑁呯О閲嶆暟鎹紓甯革紝璇烽噸鏂颁笂绉扮О閲�"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain"); + return action; } } break; @@ -258,7 +381,24 @@ { CurCmd = null; PrintTimes = 0; - action = End(); + //鎵撳嵃鍚庣О閲� + if (NeedWeighing) + { + var data = new PackingActionOutput() { PkgInfo = CurPkg }; + data.ExecCode = "Weighing"; + data.PkgLevel = CurPkgItem.PKG_LEVEL; + CurCmd = data; + CurStep.Message = Biz.L("鍖呰鎴愬姛"); + CurStep.Status = StepStatus.Success; + 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(input); + } } break; // 鎵嬪姩缁撴潫鍖呰锛屼繚瀛樻殏瀛樼殑鍖呰鏁版嵁 @@ -284,7 +424,10 @@ data.ExecCode = "Scan"; data.PkgLevel = dtl.PKG_LEVEL; CurCmd = data; + CurStep.Message = Biz.L("鎵弿鏍囩"); + CurStep.Status = StepStatus.Normal; 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); } @@ -299,7 +442,10 @@ data.PrintLable = LabelDic[dtl.PKG_LEVEL]; CurCmd = data; PrintTimes++; + CurStep.Message = Biz.L("鎵撳嵃鏍囩"); + CurStep.Status = StepStatus.Normal; 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); } @@ -338,28 +484,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, - 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); } @@ -401,7 +549,7 @@ //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屼繚瀛樺寘瑁呮暟鎹埌鏁版嵁搴� else { - action = SaveToDB(); + action = CompletePkg(); } } //褰撳墠澶勭悊鐨勫寘瑁呭眰绾у凡缁忓鐞嗗畬锛岀户缁線涓婁繚瀛� @@ -438,42 +586,68 @@ //娣诲姞鏄庣粏鍚庡垽鏂綋鍓嶅寘瑁呭眰绾х殑鏄庣粏鏁伴噺鏄惁绛変簬鍖呰鏁伴噺锛岃嫢鐩哥瓑鍒欐爣璁板綋鍓嶅寘瑁呭眰绾т负瀹屾垚骞跺皾璇曟墦鍗版爣绛� if (CurPkgItem.Items.Count(q => q.IsFinished) == CurPkgItem.PKG_QTY || CurStep.IsNullOrEmpty()) { - //琛屼负璁惧畾鐨凮PTION_1-9鏄寘瑁呬笉鍚屽眰绾х殑鏍囩妯℃澘浠g爜锛屽鏋滀负绌哄垯涓嶉渶瑕佹墦鍗� - if (LabelDic[dtl.PKG_LEVEL].IsNullOrEmpty()) + //鎵撳嵃鍓嶇О閲嶏細濡傛灉褰撳墠鐨勫寘瑁呮槑缁嗙殑涓婁竴灞傚寘瑁呭璞℃槸鏈�澶栧眰鍖呰涓旈渶瑕佺О閲嶆椂锛屽厛绉伴噸锛屽悎鏍煎悗鍦ㄥ彂鍗版垨鑰呮壂鎻忔渶澶栧眰鍖呰鏍囩 + if (CurPkgItem.PKG_LEVEL == CurPkg.Item.PKG_LEVEL && NeedWeighing) { var data = new PackingActionOutput() { PkgInfo = CurPkg }; - data.ExecCode = "Scan"; - data.PkgLevel = dtl.PKG_LEVEL; + data.ExecCode = "Weighing"; + data.PkgLevel = CurPkgItem.PKG_LEVEL; CurCmd = data; + CurStep.Message = Biz.L("涓婄О绉伴噸"); + CurStep.Status = StepStatus.Normal; action.Data.Data = data; - //action.LocaleMsg = new($"璇锋壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�"); - action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); - } + action.Data.ShortMsg = new("涓婄О绉伴噸", ShortMessage.Types.Success); + //action.LocaleMsg = new($"璇锋妸澶栧寘瑁呬笂绉扮О閲�"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing"); + } else { - //璁剧疆鎵撳嵃鍙橀噺鍊� - LabelDic[dtl.PKG_LEVEL] = CurPosition.SetLabelVariables(LabelPV, LabelDic[dtl.PKG_LEVEL]); - - var data = new PackingActionOutput() { PkgInfo = CurPkg }; - data.ExecCode = "Print"; - data.PkgLevel = dtl.PKG_LEVEL; - data.PrintLable = LabelDic[dtl.PKG_LEVEL]; - CurCmd = data; - PrintTimes++; - action.Data.Data = data; - //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); + //濡傛灉涓虹┖鍒欎笉闇�瑕佹墦鍗� + if (LabelDic[dtl.PKG_LEVEL].IsNullOrEmpty()) + { + var data = new PackingActionOutput() { PkgInfo = CurPkg }; + data.ExecCode = "Scan"; + data.PkgLevel = dtl.PKG_LEVEL; + CurCmd = data; + CurStep.Message = Biz.L("鎵弿鏍囩"); + CurStep.Status = StepStatus.Normal; + 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); + } + else + { + //璁剧疆鎵撳嵃鍙橀噺鍊� + LabelDic[dtl.PKG_LEVEL] = CurPosition.SetLabelVariables(LabelPV, LabelDic[dtl.PKG_LEVEL]); + + var data = new PackingActionOutput() { PkgInfo = CurPkg }; + data.ExecCode = "Print"; + data.PkgLevel = dtl.PKG_LEVEL; + data.PrintLable = LabelDic[dtl.PKG_LEVEL]; + CurCmd = data; + PrintTimes++; + CurStep.Message = Biz.L("鎵撳嵃鏍囩"); + CurStep.Status = StepStatus.Normal; + action.Data.Data = data; + 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); + } } } //褰撳墠鍖呰灞傜骇鐨勬槑缁嗘暟閲忔湭杈惧埌鍖呰鏁伴噺锛屽垯瀹屾垚鏈鎵弿锛岀瓑寰呬笅涓骇鍝佽繘绔� else { - action = End(); + action = End(input); } } //鏁版嵁寮傚父 else { + CurStep.Message = Biz.L("鍖呰閿欒"); + CurStep.Status = StepStatus.Error; + 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})锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜"); @@ -484,6 +658,9 @@ } catch (System.Exception ex) { + CurStep.Message = Biz.L("鍖呰寮傚父"); + CurStep.Status = StepStatus.Error; + 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; @@ -496,45 +673,39 @@ private List<MES_WIP_PKG> GetPackageList(WipPkgItem parent) { - List<MES_WIP_PKG> list = new() { parent.Package }; + List<MES_WIP_PKG> list = new(); + if (!parent.Package.IsNullOrEmpty()) + { + list.Add(parent.Package); + } foreach (var item in parent.Items) { - item.Package.PARENT_SN = parent.Package.SN; + item.Package.PARENT_SN = parent.Package?.SN; list.AddRange(GetPackageList(item)); } return list; } - public ApiAction<SubmitOutput> SaveToDB() + public ApiAction<SubmitOutput> CompletePkg() { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); - - var pkgList = GetPackageList(CurPkg.Item); - - //淇濆瓨鏁版嵁搴� - var db = Biz.Db; - var dbTran = db.UseTran(() => - { - db.Insertable(pkgList, CurPosition.UserCode).ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - throw dbTran.ErrorException; - } var data = new PackingActionOutput() { PkgInfo = CurPkg }; data.ExecCode = "Complete"; data.PkgLevel = CurPkg.Item.PKG_LEVEL; CurCmd = data; + CurStep.Message = Biz.L("淇濆瓨鍖呰鏁版嵁"); + CurStep.Status = StepStatus.Normal; 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; } @@ -543,53 +714,94 @@ /// 缁撴潫鎵ц宸ュ簭琛屼负 /// </summary> /// <returns></returns> - public ApiAction<SubmitOutput> End() + public ApiAction<SubmitOutput> End(SubmitInput input) { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); //璁板綍琛屼负鎿嶄綔璁板綍 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, - 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, - TRAY_SN = wipSn.TRAY_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); + } + } + //璁板綍澶栧寘瑁呯殑绉伴噸鏁版嵁 + if (CurPkg.IsFinished) + { + CurPkg.Item.Package.WEIGHT = CurPkg.WeightInfo.Weight; + CurPkg.Item.Package.WEIGHT_UNIT = CurPkg.WeightInfo.Unit; } + //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊� + var _wipActs = wipActs.Clone(); + var _pkgList = CurPkg.IsFinished ? GetPackageList(CurPkg.Item) : new(); //淇濆瓨鏁版嵁 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.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand(); + foreach (var pkg in _pkgList) + { + //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛� + db.Updateable<MES_WIP_DATA>() + .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 == pkg.WORK_ORDER && q.SN == pkg.SN) + .ExecuteCommand(); + //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃 + db.Updateable<BIZ_MES_WO_SN>() + .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN) + .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN) + .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN) + .ExecuteCommand(); + } + } }; if (CurPkg.IsFinished) @@ -598,6 +810,8 @@ CurPosition.NeedTemporaryStoreDBCommitAction = false; //鍒犻櫎宸ュ簭涓婁笅鏂囦腑鐨勫寘瑁呰褰� CurPosition.Context.Remove("CurPackage"); + //action.LocaleMsg = new($"鏉$爜[{CurPkg.Item.Package?.SN}]鍖呰瀹屾垚"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPkg.Item.Package.SN); } else { @@ -612,11 +826,15 @@ { CurPosition.Context.Add("CurPackage", CurPkg); } + //action.LocaleMsg = new($"鏉$爜[{CurPosition.CurSN}]鍖呰瀹屾垚"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN); } IsFinished = true; - action.LocaleMsg = new($"浜у搧鏉$爜[{CurPosition.CurSN}]鍖呰瀹屾垚"); - action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN); + CurStep.Message = Biz.L("鍖呰瀹屾垚"); + CurStep.Status = StepStatus.Finished; + action.Data.ShortMsg = new("鍖呰瀹屾垚", ShortMessage.Types.Success); + return action; } -- Gitblit v1.9.3