From 420ec0dec8cd0c17eb18ce6ecd5d03eed0266541 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期一, 23 九月 2024 01:14:07 +0800 Subject: [PATCH] 优化三码合一行为,增加包装工单首站投入验证行为 --- Tiger.Business.MES/WorkAction/ThreeInOne.cs | 301 +++++++++++++++++--------- Tiger.Api/Language.db | 0 Tiger.Model.Net/Entitys/MES/MES_CUST_SN.cs | 17 + Tiger.Business.MES/WorkAction/PackageInputCheck.cs | 273 ++++++++++++++++++++++++ Tiger.IBusiness/MES/WorkAction/IPackageInputCheck.cs | 13 + 5 files changed, 496 insertions(+), 108 deletions(-) diff --git a/Tiger.Api/Language.db b/Tiger.Api/Language.db index 38f0ec0..6db317b 100644 --- a/Tiger.Api/Language.db +++ b/Tiger.Api/Language.db Binary files differ diff --git a/Tiger.Business.MES/WorkAction/PackageInputCheck.cs b/Tiger.Business.MES/WorkAction/PackageInputCheck.cs new file mode 100644 index 0000000..70117ae --- /dev/null +++ b/Tiger.Business.MES/WorkAction/PackageInputCheck.cs @@ -0,0 +1,273 @@ +锘縰sing Rhea.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.IBusiness.MES.WorkAction; +using Tiger.Model; +using Tiger.Model.Entitys.MES.Position; +using Tiger.Model.MES.Yada; + +namespace Tiger.Business.MES.WorkAction +{ + public class PackageInputCheck : IPackageInputCheck + { + #region Propertys & Variables + #region 鍥哄畾鍐欐硶锛屽伐搴忎腑鐨勫繀瑕佷俊鎭� + public bool IsFinished { get; set; } = false; + public IWorkStep CurStep { get; set; } + public IPosition CurPosition { get; set; } + public MES_WO_NODE_ACT NodeAct { get; set; } + public MES_WO_ACTION Setting { get; set; } + #endregion + public MES_CUST_SN FlowCSN { get; set; } + public BAS_LABEL_TEMP Label { get; set; } + public List<BAS_LABEL_PV> LabelPV { get; set; } + public List<mes_MOPickList> MoPickList { get; set; } + public BAS_ITEM_CUST CustInfo { get; set; } + #endregion Propertys & Variables + + #region Functions + /// <summary> + /// 鍒濆鍖栧伐搴忚涓� + /// </summary> + /// <returns></returns> + public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting) + { + #region 鍥哄畾鍐欐硶锛岀粰榛樿鍙橀噺璧嬪�� + CurStep = curStep; + CurPosition = position; + NodeAct = nodeAct; + Setting = setting; + #endregion + + //鑾峰彇鎵撳嵃妯℃澘 + Label = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First(); + LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); + + //鑾峰彇褰撳墠浜у搧鍦ㄥ綋鍓嶅鎴风殑鍏崇郴 + CustInfo = Biz.Db.Queryable<BAS_ITEM_CUST>().Where(q => q.ITEM_ID == CurPosition.WorkBatch.WO.ItemInfo.ID && q.CUST_CODE == CurPosition.WorkBatch.WO.CUST_CODE).First(); + + CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜鎴栧鎴锋潯鐮�"); + CurStep.Status = StepStatus.Normal; + } + + /// <summary> + /// 鑾峰彇琛屼负寮�濮嬬殑鎻愮ず淇℃伅 + /// </summary> + /// <returns></returns> + public Locale GetBeginMsg() + { + var msg = new Locale("MES.WorkAction.PackageInputCheck.BeginMsg", CurPosition.CurSN, CurPosition.WorkBatch.WO.ORDER_NO); + //var msg = new Locale($"寮�濮嬫鏌ユ潯鐮乕{0}]鏄惁鍙互鍦ㄥ伐鍗昜{1}]鎶曟枡鐢熶骇"); + return msg; + } + + /// <summary> + /// 灏濊瘯寮�濮嬫墽琛屽伐搴忚涓� + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> TryBegin(SubmitInput input) + { + var action = Submit(input); + + //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触 + //action.IsSuccessed = true; + + return action; + } + + /// <summary> + /// 宸ュ簭琛屼负鎻愪氦鏁版嵁 + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> Submit(SubmitInput input) + { + var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + + //鑾峰彇宸ュ崟澶囨枡淇℃伅 + MoPickList = Biz.DataSource["YadaU9C"].Client.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == CurPosition.WorkBatch.WO.ORDER_NO).ToList(); + + //鍙厑璁稿崟涓骇鍝佽繘琛屽鎴锋潯鐮佺粦瀹� + if (CurPosition.CurWipSNs.Count > 1) + { + CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜鎴栧鎴锋潯鐮�"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎵弿鍘傚唴鏉$爜鎴栧鎴锋潯鐮�", ShortMessage.Types.Error); + action.IsSuccessed = false; + //action.LocaleMsg = new($"鏉$爜[{0}]鏄寘瑁�/杞藉叿鏉$爜锛岃閲嶆柊鎵弿鍗曚釜鍘傚唴鏉$爜杩涜瀹㈡埛鏉$爜缁戝畾"); + action.LocaleMsg = new("MES.WorkAction.PackageInputCheck.NotProductSN", CurPosition.CurSN); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + + return action; + } + + var wipSn = CurPosition.CurWipSNs.First(); + FlowCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == wipSn.SN || q.CUST_SN == wipSn.SN).First(); + //鎵句笉鍒扮敓浜ц褰曪紝璁や负鎵弿閿欒 + if (FlowCSN.IsNullOrEmpty()) + { + CurStep.Message = Biz.L("鎶曟枡閿欒"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎶曟枡閿欒", ShortMessage.Types.Failed); + action.IsSuccessed = false; + //action.LocaleMsg = new($"鎶曟枡閿欒锛屾壘涓嶅埌鏉$爜[{0}]鐨勭敓浜ц褰�"); + action.LocaleMsg = new("MES.WorkAction.PackageInputCheck.InputSnError", wipSn.SN); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + return action; + } + else + { + //鍘傚唴鏉$爜宸茬粦瀹� + if (FlowCSN.IsBound || FlowCSN.IsFlowSn) + { + //鐗╂枡鏂欏彿鏄綋鍓嶅伐鍗曟枡鍙锋垨鑰呭湪宸ュ崟澶囨枡琛ㄤ腑锛岀洿鎺ョ粨鏉熻涓� + if (FlowCSN.ITEM_CODE == CurPosition.WorkBatch.WO.ITEM_CODE || MoPickList.Any(q => q.Code == FlowCSN.ITEM_CODE)) + { + action = End(input); + return action; + } + else + { + CurStep.Message = Biz.L("鎶曟枡閿欒"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎶曟枡閿欒", ShortMessage.Types.Failed); + action.IsSuccessed = false; + //action.LocaleMsg = new($"浜у搧(鍘傚唴鏉$爜[{0}])涓嶉�傜敤浜庡綋鍓嶅伐鍗昜{1}]鐨勭敓浜�"); + action.LocaleMsg = new("MES.WorkAction.PackageInputCheck.InputSnOrderError", FlowCSN.FLOW_SN, CurPosition.WorkBatch.WO.ORDER_NO); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + return action; + } + } + //鍘傚唴鏉$爜鏈粦瀹氬鎴锋潯鐮� + else + { + action.Data.Data = new + { + NeedPrint = false, + NeedScan = false, + Label = "", + }; + CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎵弿鍘傚唴鏉$爜", ShortMessage.Types.Failed); + action.IsSuccessed = false; + //action.LocaleMsg = new($"瀹㈡埛鏉$爜[{0}]鏈缁戝畾锛岃鍏堟壂鎻忓巶鍐呮潯鐮�"); + action.LocaleMsg = new("MES.WorkAction.PackageInputCheck.PleaseScanFlowSn", wipSn.SN); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + return action; + } + + } + + return action; + } + /// <summary> + /// 缁撴潫鎵ц宸ュ簭琛屼负 + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> End(SubmitInput input) + { + var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + + //鏇存柊鍘傚唴娴佺▼鐮� + FlowCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE; + FlowCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; + FlowCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; + + //璁板綍琛屼负鎿嶄綔璁板綍 + var wipActs = new List<MES_WIP_ACT>(); + var woSns = new List<BIZ_MES_WO_SN>(); + var snHiss = new List<MES_WIP_HIS>(); + foreach (var wipSn in CurPosition.CurWipSNs) + { + //鏇存柊鍦ㄥ埗鍝佷俊鎭疭N涓哄鎴锋潯鐮� + wipSn.SN = FlowCSN.CUST_SN; + wipSn.FLOW_SN = FlowCSN.FLOW_SN; + //鏇存柊鍦ㄥ埗鍝佷俊鎭巻鍙插緱SN涓哄鎴锋潯鐮� + var his = CurPosition.CurWipSNHiss.First(q => q.WIP_ID == wipSn.ID); + his.SN = FlowCSN.CUST_SN; + his.FLOW_SN = FlowCSN.FLOW_SN; + snHiss.Add(his); + //鏇存柊宸ュ崟鏉$爜琛ㄧ殑 + var woSn = CurPosition.WorkBatch.WoSNs.First(q => q.WIP_ID == wipSn.ID); + woSn.SN = FlowCSN.CUST_SN; + woSn.FLOW_SN = FlowCSN.FLOW_SN; + woSns.Add(woSn); + 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, + WIP_ID = wipSn.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_VALUE_1 = Label.LABEL_CODE, + ACT_VALUE_2 = Label.Variables.ToJson(), + ACT_RESULT = "Y", + TRACE_INFO = $"鏉$爜[{wipSn.SN}]鍙互鍦ㄥ伐鍗昜{wipSn.WORK_ORDER}]鎶曟枡鐢熶骇", + }; + wipActs.Add(wipAct); + } + + //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊� + var _wipSns = CurPosition.CurWipSNs.Clone(); + var _snHiss = snHiss.Clone(); + var _woSns = woSns.Clone(); + var _wipActs = wipActs.Clone(); + var _FlowCSN = FlowCSN.Clone(); + //淇濆瓨鏁版嵁 + CurStep.DBSubmitAction = () => + { + var db = CurPosition.GetCommitDB(); + db.Storageable(_wipSns, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_snHiss, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_woSns, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_FlowCSN, CurPosition.UserCode).ExecuteCommand(); + }; + + IsFinished = true; + CurStep.Message = Biz.L("鎶曟枡妫�鏌ユ垚鍔�"); + CurStep.Status = StepStatus.Finished; + action.Data.ShortMsg = new("鎶曟枡妫�鏌ユ垚鍔�", ShortMessage.Types.Success); + //action.LocaleMsg = new($"鏉$爜[{0}]鍙互鍦ㄥ伐鍗昜{1}]鎶曞叆鐢熶骇"); + action.LocaleMsg = new("MES.WorkAction.PackageInputCheck.BindingComplete", FlowCSN.FLOW_SN, FlowCSN.WORK_ORDER); + return action; + } + + #endregion Functions + } +} diff --git a/Tiger.Business.MES/WorkAction/ThreeInOne.cs b/Tiger.Business.MES/WorkAction/ThreeInOne.cs index 4d2a068..a20e632 100644 --- a/Tiger.Business.MES/WorkAction/ThreeInOne.cs +++ b/Tiger.Business.MES/WorkAction/ThreeInOne.cs @@ -23,7 +23,8 @@ public MES_WO_NODE_ACT NodeAct { get; set; } public MES_WO_ACTION Setting { get; set; } #endregion - public MES_CUST_SN CurCSN { get; set; } + public MES_CUST_SN FlowCSN { get; set; } + public MES_CUST_SN CustCSN { get; set; } public BAS_LABEL_TEMP Label { get; set; } public List<BAS_LABEL_PV> LabelPV { get; set; } public List<mes_MOPickList> MoPickList { get; set; } @@ -47,12 +48,11 @@ //鑾峰彇鎵撳嵃妯℃澘 Label = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First(); LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); - //鑾峰彇宸ュ崟澶囨枡淇℃伅 - MoPickList = Biz.DataSource["YadaU9C"].Client.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == CurPosition.WorkBatch.WO.ORDER_NO).ToList(); + //鑾峰彇褰撳墠浜у搧鍦ㄥ綋鍓嶅鎴风殑鍏崇郴 CustInfo = Biz.Db.Queryable<BAS_ITEM_CUST>().Where(q => q.ITEM_ID == CurPosition.WorkBatch.WO.ItemInfo.ID && q.CUST_CODE == CurPosition.WorkBatch.WO.CUST_CODE).First(); - CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜"); + CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜鎴栧鎴锋潯鐮�"); CurStep.Status = StepStatus.Normal; } @@ -75,95 +75,178 @@ { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + //鑾峰彇宸ュ崟澶囨枡淇℃伅 + MoPickList = Biz.DataSource["YadaU9C"].Client.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == CurPosition.WorkBatch.WO.ORDER_NO).ToList(); + //鍙厑璁稿崟涓骇鍝佽繘琛屽鎴锋潯鐮佺粦瀹� if (CurPosition.CurWipSNs.Count > 1) { - CurStep.Message = Biz.L("璇锋壂鎻忓崟涓骇鍝�"); + action.Data.Data = new + { + NeedPrint = false, + NeedScan = false, + Label = "", + }; + CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜鎴栧鎴锋潯鐮�"); CurStep.Status = StepStatus.Error; - action.Data.ShortMsg = new("璇锋壂鎻忓崟涓骇鍝�", ShortMessage.Types.Error); + action.Data.ShortMsg = new("鎵弿鍘傚唴鏉$爜鎴栧鎴锋潯鐮�", ShortMessage.Types.Error); + action.IsSuccessed = false; //action.LocaleMsg = new($"鏉$爜[{0}]鏄寘瑁�/杞藉叿鏉$爜锛岃閲嶆柊鎵弿鍗曚釜鍘傚唴鏉$爜杩涜瀹㈡埛鏉$爜缁戝畾"); action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotProductSN", CurPosition.CurSN); //閲嶇疆宸ュ簭鎿嶄綔 CurPosition.ResetNode(); - action.IsSuccessed = false; return action; } var wipSn = CurPosition.CurWipSNs.First(); - CurCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == wipSn.SN).First(); - //鍘傚唴鏉$爜宸茬粦瀹氬鎴锋潯鐮侊紝鐩存帴缁撴潫琛屼负 - if (!CurCSN.IsNullOrEmpty()) + FlowCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == wipSn.SN || q.CUST_SN == wipSn.SN).First(); + //鎵句笉鍒扮敓浜ц褰曪紝璁や负鎵弿閿欒 + if (FlowCSN.IsNullOrEmpty()) { - //瀹㈡埛鏉$爜宸茬粦瀹氬綋鍓嶅伐鍗曟垨鑰呭叾鎵规灞炰簬褰撳墠宸ュ崟涓婃枡鐗╂枡鐨勬帹鑽愭壒娆� - if (CurCSN.WORK_ORDER == CurPosition.WorkBatch.WO.ORDER_NO || MoPickList.Any(q => q.Code == CurCSN.ITEM_CODE && q.SuggestedBatch == CurCSN.WORK_ORDER)) + action.Data.Data = new { - CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; - CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; - action.Data.Data = new - { - NeedPrint = false, - NeedScan = false, - Label = "", - }; - action = End(input); - } - else - { - action.Data.Data = new - { - NeedPrint = false, - NeedScan = false, - Label = "", - }; - CurStep.Message = Biz.L("鎶曟枡閿欒"); - CurStep.Status = StepStatus.Error; - action.Data.ShortMsg = new("鎶曟枡閿欒", ShortMessage.Types.Failed); - action.IsSuccessed = false; - //action.LocaleMsg = new($"浜у搧鐨勫鎴锋潯鐮乕{0}]灞炰簬宸ュ崟[{1}]涓嶉�傜敤浜庡綋鍓嶅伐鍗昜{2}]鐨勭敓浜�"); - action.LocaleMsg = new("MES.WorkAction.ThreeInOne.InputSnError", CurCSN.CUST_SN, CurCSN.WORK_ORDER, CurPosition.WorkBatch.WO.ORDER_NO); - //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣� - if (NodeAct.NEED_RESET == "Y") - { - CurPosition.ResetNode(); - } - return action; - } + NeedPrint = false, + NeedScan = false, + Label = "", + }; + CurStep.Message = Biz.L("鎶曟枡閿欒"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎶曟枡閿欒", ShortMessage.Types.Failed); + action.IsSuccessed = false; + //action.LocaleMsg = new($"鎶曟枡閿欒锛屾壘涓嶅埌鏉$爜[{0}]鐨勭敓浜ц褰�"); + action.LocaleMsg = new("MES.WorkAction.ThreeInOne.InputSnError", wipSn.SN); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + return action; } - //鍘傚唴鏉$爜鏈粦瀹氬鎴锋潯鐮� else { - //濡傛灉瀹㈡埛鏉$爜鏍囩妯℃澘涓虹┖鍒欎笉闇�瑕佹墦鍗帮紝绛夊緟鎵弿瀹㈡埛鏉$爜杩涜缁戝畾 - if (Label.IsNullOrEmpty()) - { - action.Data.Data = new - { - NeedPrint = false, - NeedScan = true, - Label = "", - }; - CurStep.Message = Biz.L("鎵弿瀹㈡埛鏍囩"); - CurStep.Status = StepStatus.Normal; - action.Data.ShortMsg = new("鎵弿瀹㈡埛鏍囩", ShortMessage.Types.Normal); - //action.LocaleMsg = new Locale($"璇锋壂鎻忓巶鍐呮潯鐮乕{0}]闇�瑕佺粦瀹氬鎴锋潯鐮�"); - action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginScan", wipSn.SN); - } - else - { - //璁剧疆鎵撳嵃鍙橀噺鍊� - Label = CurPosition.SetLabelVariables(LabelPV, Label, this); - action.Data.Data = new - { - NeedPrint = true, - NeedScan = true, - Label, - }; - CurStep.Message = Biz.L("鎵弿宸叉墦鍗扮殑瀹㈡埛鏍囩"); - CurStep.Status = StepStatus.Normal; - action.Data.ShortMsg = new("鎵弿宸叉墦鍗扮殑瀹㈡埛鏍囩", ShortMessage.Types.Normal); - //action.LocaleMsg = new Locale($"寮�濮嬫墦鍗板巶鍐呮潯鐮乕{0}]瀵瑰簲鐨勫鎴锋潯鐮�"); - action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginPrint", wipSn.SN); + //鍘傚唴鏉$爜宸茬粦瀹� + if (FlowCSN.IsBound) + { + //鐗╂枡鏂欏彿鏄綋鍓嶅伐鍗曟枡鍙锋垨鑰呭湪宸ュ崟澶囨枡琛ㄤ腑锛岀洿鎺ョ粨鏉熻涓� + if (FlowCSN.ITEM_CODE == CurPosition.WorkBatch.WO.ITEM_CODE || MoPickList.Any(q => q.Code == FlowCSN.ITEM_CODE)) + { + action = End(input); + action.Data.Data = new + { + NeedPrint = false, + NeedScan = false, + Label = "", + }; + return action; + } + else + { + action.Data.Data = new + { + NeedPrint = false, + NeedScan = false, + Label = "", + }; + CurStep.Message = Biz.L("鎶曟枡閿欒"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎶曟枡閿欒", ShortMessage.Types.Failed); + action.IsSuccessed = false; + //action.LocaleMsg = new($"浜у搧(鍘傚唴鏉$爜[{0}])涓嶉�傜敤浜庡綋鍓嶅伐鍗昜{1}]鐨勭敓浜�"); + action.LocaleMsg = new("MES.WorkAction.ThreeInOne.InputSnOrderError", FlowCSN.FLOW_SN, CurPosition.WorkBatch.WO.ORDER_NO); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + return action; + } } + //鍘傚唴鏉$爜鏈粦瀹氬鎴锋潯鐮� + else + { + if (FlowCSN.IsFlowSn) + { + //濡傛灉瀹㈡埛鏉$爜鏍囩妯℃澘涓虹┖鍒欎笉闇�瑕佹墦鍗帮紝绛夊緟鎵弿瀹㈡埛鏉$爜杩涜缁戝畾 + if (Label.IsNullOrEmpty()) + { + action.Data.Data = new + { + NeedPrint = false, + NeedScan = true, + Label = "", + }; + CurStep.Message = Biz.L("鎵弿瀹㈡埛鏍囩"); + CurStep.Status = StepStatus.Normal; + action.Data.ShortMsg = new("鎵弿瀹㈡埛鏍囩", ShortMessage.Types.Normal); + //action.LocaleMsg = new Locale($"璇锋壂鎻忓巶鍐呮潯鐮乕{0}]闇�瑕佺粦瀹氬鎴锋潯鐮�"); + action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginScan", wipSn.SN); + } + else + { + //璁剧疆鎵撳嵃鍙橀噺鍊� + Label = CurPosition.SetLabelVariables(LabelPV, Label, this); + action.Data.Data = new + { + NeedPrint = true, + NeedScan = true, + Label, + }; + CurStep.Message = Biz.L("鎵弿宸叉墦鍗扮殑瀹㈡埛鏍囩"); + CurStep.Status = StepStatus.Normal; + action.Data.ShortMsg = new("鎵弿宸叉墦鍗扮殑瀹㈡埛鏍囩", ShortMessage.Types.Normal); + //action.LocaleMsg = new Locale($"寮�濮嬫墦鍗板巶鍐呮潯鐮乕{0}]瀵瑰簲鐨勫鎴锋潯鐮�"); + action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginPrint", wipSn.SN); + } + } + else + { + action.Data.Data = new + { + NeedPrint = false, + NeedScan = false, + Label = "", + }; + CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜"); + CurStep.Status = StepStatus.Error; + action.Data.ShortMsg = new("鎵弿鍘傚唴鏉$爜", ShortMessage.Types.Failed); + action.IsSuccessed = false; + //action.LocaleMsg = new($"瀹㈡埛鏉$爜[{0}]鏈缁戝畾锛岃鍏堟壂鎻忓巶鍐呮潯鐮�"); + action.LocaleMsg = new("MES.WorkAction.ThreeInOne.PleaseScanFlowSn", wipSn.SN); + //閲嶇疆宸ュ簭鎿嶄綔 + CurPosition.ResetNode(); + return action; + } + } + + //瀹㈡埛鏉$爜宸茬粦瀹氬綋鍓嶅伐鍗曟垨鑰呭叾鎵规灞炰簬褰撳墠宸ュ崟涓婃枡鐗╂枡鐨勬帹鑽愭壒娆★紝鐩存帴缁撴潫琛屼负 + //if (FlowCSN.WORK_ORDER == CurPosition.WorkBatch.WO.ORDER_NO || MoPickList.Any(q => q.Code == FlowCSN.ITEM_CODE && q.SuggestedBatch == FlowCSN.WORK_ORDER)) + //{ + // FlowCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; + // FlowCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; + // action.Data.Data = new + // { + // NeedPrint = false, + // NeedScan = false, + // Label = "", + // }; + // action = End(input); + //} + //else + //{ + // action.Data.Data = new + // { + // NeedPrint = false, + // NeedScan = false, + // Label = "", + // }; + // CurStep.Message = Biz.L("鎶曟枡閿欒"); + // CurStep.Status = StepStatus.Error; + // action.Data.ShortMsg = new("鎶曟枡閿欒", ShortMessage.Types.Failed); + // action.IsSuccessed = false; + // //action.LocaleMsg = new($"浜у搧鐨勫鎴锋潯鐮乕{0}]灞炰簬宸ュ崟[{1}]涓嶉�傜敤浜庡綋鍓嶅伐鍗昜{2}]鐨勭敓浜�"); + // action.LocaleMsg = new("MES.WorkAction.ThreeInOne.InputSnOrderError", FlowCSN.CUST_SN, FlowCSN.WORK_ORDER, CurPosition.WorkBatch.WO.ORDER_NO); + // //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣� + // if (NodeAct.NEED_RESET == "Y") + // { + // CurPosition.ResetNode(); + // } + // return action; + //} } //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触 @@ -179,53 +262,47 @@ public ApiAction<SubmitOutput> Submit(SubmitInput input) { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); - var csn = input.Data; - CurCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.CUST_SN == input.Data).First() ?? new() - { - CUST_SN = input.Data, - }; + //鏌ヨ鏄惁瀛樺湪宸插鍏ョ殑瀹㈡埛鏉$爜 + CustCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.CUST_SN == input.Data).First(); var isOK = true; //瀹㈡埛鏉$爜宸茬粦瀹氬叾浠栧巶鍐呮潯鐮� - if (!CurCSN.FLOW_SN.IsNullOrEmpty() && CurCSN.FLOW_SN != CurPosition.CurWipSNs.First().SN) + if (!CustCSN.IsNullOrEmpty() && !CustCSN.FLOW_SN.IsNullOrEmpty() && CustCSN.FLOW_SN != FlowCSN.FLOW_SN) { - CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩缁戝畾澶辫触")); - action.Data.ShortMsg = new("瀹㈡埛鏍囩缁戝畾澶辫触", ShortMessage.Types.Failed); + CurStep.SetStatusMessage(StepStatus.Error, Biz.L("璇锋壂鎻忔纭殑瀹㈡埛鏍囩")); + action.Data.ShortMsg = new("璇锋壂鎻忔纭殑瀹㈡埛鏍囩", ShortMessage.Types.Failed); action.IsSuccessed = isOK = false; - //action.LocaleMsg = new($"鍘傚唴鏉$爜[{0}]缁戝畾瀹㈡埛鏉$爜[{1}]澶辫触锛屽鎴锋潯鐮佸凡缁戝畾鍘傚唴鏉$爜[{2}]"); - action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingOtherSN", CurPosition.CurWipSNs.First().SN, CurCSN.CUST_SN, CurCSN.FLOW_SN); + //action.LocaleMsg = new($"鍘傚唴鏉$爜[{0}]缁戝畾瀹㈡埛鏉$爜[{1}]澶辫触锛屽鎴锋潯鐮佸凡缁戝畾鍘傚唴鏉$爜[{2}]锛岃鎵弿姝g‘鐨勫鎴锋爣绛�"); + action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingOtherSN", CurPosition.CurWipSNs.First().SN, CustCSN.CUST_SN, CustCSN.FLOW_SN); } //瀹㈡埛鏉$爜涓嶅睘浜庡綋鍓嶅伐鍗曠殑瀹㈡埛 - if (CurCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE) + if (!CustCSN.IsNullOrEmpty() && CustCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE) { - CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩缁戝畾澶辫触")); - action.Data.ShortMsg = new("瀹㈡埛鏍囩缁戝畾澶辫触", ShortMessage.Types.Failed); + CurStep.SetStatusMessage(StepStatus.Error, Biz.L("璇锋壂鎻忔纭殑瀹㈡埛鏍囩")); + action.Data.ShortMsg = new("璇锋壂鎻忔纭殑瀹㈡埛鏍囩", ShortMessage.Types.Failed); action.IsSuccessed = isOK = false; - //action.LocaleMsg = new($"瀹㈡埛鏉$爜[{0}]灞炰簬瀹㈡埛[{1}]锛屼笌褰撳墠宸ュ崟鐨勫鎴穂{2}]涓嶄竴鑷�"); - action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotSameCustomer", CurCSN.CUST_SN, CurCSN.CUST_CODE, CurPosition.WorkBatch.WO.CUST_CODE); + //action.LocaleMsg = new($"瀹㈡埛鏉$爜[{0}]灞炰簬瀹㈡埛[{1}]锛屼笌褰撳墠宸ュ崟鐨勫鎴穂{2}]涓嶄竴鑷达紝璇锋壂鎻忔纭殑瀹㈡埛鏍囩"); + action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotSameCustomer", CustCSN.CUST_SN, CustCSN.CUST_CODE, CurPosition.WorkBatch.WO.CUST_CODE); } //楠岃瘉浜у搧瀹㈡埛鏍囩鏉$爜瑙勫垯 if (!CustInfo.RULE_CODE.IsNullOrEmpty() && !Biz.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty()) { - var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CurCSN.CUST_SN); + var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CustCSN.CUST_SN); if (!result.IsSuccessed) { - CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩缁戝畾澶辫触")); - action.Data.ShortMsg = new("瀹㈡埛鏍囩缁戝畾澶辫触", ShortMessage.Types.Failed); + CurStep.SetStatusMessage(StepStatus.Error, Biz.L("璇锋壂鎻忔纭殑瀹㈡埛鏍囩")); + action.Data.ShortMsg = new("璇锋壂鎻忔纭殑瀹㈡埛鏍囩", ShortMessage.Types.Failed); action.IsSuccessed = isOK = false; - //action.LocaleMsg = new Locale($"鏍囩鏉$爜[{0}]鏈�氳繃瀹㈡埛鏍囩瑙勫垯[{1}]楠岃瘉"); - action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.CustSnVerifyError", CurCSN.CUST_SN, CustInfo.RULE_CODE); + //action.LocaleMsg = new Locale($"鏍囩鏉$爜[{0}]鏈�氳繃瀹㈡埛鏍囩瑙勫垯[{1}]楠岃瘉锛岃鎵弿姝g‘鐨勫鎴锋爣绛�"); + action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.CustSnVerifyError", CustCSN.CUST_SN, CustInfo.RULE_CODE); } } //楠岃瘉閫氳繃鍒欎繚瀛� if (isOK) { - CurCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE; - CurCSN.FLOW_SN = CurPosition.CurWipSNs.First().SN; - CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; - CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; + FlowCSN.CUST_SN = input.Data; action = End(input); } else @@ -247,6 +324,11 @@ { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + //鏇存柊鍘傚唴娴佺▼鐮� + FlowCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE; + FlowCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; + FlowCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; + //璁板綍琛屼负鎿嶄綔璁板綍 var wipActs = new List<MES_WIP_ACT>(); var woSns = new List<BIZ_MES_WO_SN>(); @@ -254,14 +336,14 @@ foreach (var wipSn in CurPosition.CurWipSNs) { //鏇存柊鍦ㄥ埗鍝佷俊鎭疭N涓哄鎴锋潯鐮� - wipSn.SN = CurCSN.CUST_SN; + wipSn.SN = FlowCSN.CUST_SN; //鏇存柊鍦ㄥ埗鍝佷俊鎭巻鍙插緱SN涓哄鎴锋潯鐮� var his = CurPosition.CurWipSNHiss.First(q => q.WIP_ID == wipSn.ID); - his.SN = CurCSN.CUST_SN; + his.SN = FlowCSN.CUST_SN; snHiss.Add(his); //鏇存柊宸ュ崟鏉$爜琛ㄧ殑 var woSn = CurPosition.WorkBatch.WoSNs.First(q => q.WIP_ID == wipSn.ID); - woSn.SN = CurCSN.CUST_SN; + woSn.SN = FlowCSN.CUST_SN; woSns.Add(woSn); var wipAct = new MES_WIP_ACT() { @@ -299,7 +381,7 @@ ACT_VALUE_1 = Label.LABEL_CODE, ACT_VALUE_2 = Label.Variables.ToJson(), ACT_RESULT = "Y", - TRACE_INFO = $"鍘傚唴鏉$爜[{0}]宸茬粦瀹氬鎴锋潯鐮乕{1}]鎴愬姛", + TRACE_INFO = $"鍘傚唴鏉$爜[{FlowCSN.FLOW_SN}]缁戝畾瀹㈡埛鏉$爜[{FlowCSN.CUST_SN}]鎴愬姛", }; wipActs.Add(wipAct); } @@ -309,7 +391,8 @@ var _snHiss = snHiss.Clone(); var _woSns = woSns.Clone(); var _wipActs = wipActs.Clone(); - var _CurCSN = CurCSN.Clone(); + var _FlowCSN = FlowCSN.Clone(); + var _CustCSN = CustCSN.Clone(); //淇濆瓨鏁版嵁 CurStep.DBSubmitAction = () => { @@ -318,15 +401,19 @@ db.Storageable(_snHiss, CurPosition.UserCode).ExecuteCommand(); db.Storageable(_woSns, CurPosition.UserCode).ExecuteCommand(); db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); - db.Storageable(_CurCSN, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_FlowCSN, CurPosition.UserCode).ExecuteCommand(); + if (!_CustCSN.IsNullOrEmpty()) + { + db.Deleteable(_CustCSN).ExecuteCommand(); + } }; IsFinished = true; - CurStep.Message = Biz.L("瀹㈡埛鏉$爜宸茬粦瀹�"); + CurStep.Message = Biz.L("瀹㈡埛鏉$爜缁戝畾鎴愬姛"); CurStep.Status = StepStatus.Finished; - action.Data.ShortMsg = new("瀹㈡埛鏉$爜宸茬粦瀹�", ShortMessage.Types.Success); + action.Data.ShortMsg = new("瀹㈡埛鏉$爜缁戝畾鎴愬姛", ShortMessage.Types.Success); //action.LocaleMsg = new($"鍘傚唴鏉$爜[{0}]宸茬粦瀹氬鎴锋潯鐮乕{1}]瀹屾垚", Label.LABEL_NAME); - action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingComplete", CurCSN.FLOW_SN, CurCSN.CUST_SN); + action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingComplete", FlowCSN.FLOW_SN, FlowCSN.CUST_SN); return action; } diff --git a/Tiger.IBusiness/MES/WorkAction/IPackageInputCheck.cs b/Tiger.IBusiness/MES/WorkAction/IPackageInputCheck.cs new file mode 100644 index 0000000..f0e7be4 --- /dev/null +++ b/Tiger.IBusiness/MES/WorkAction/IPackageInputCheck.cs @@ -0,0 +1,13 @@ +锘縰sing Newtonsoft.Json; +using Rhea.Common; +using System; +using Tiger.Model; +using Tiger.Model.Entitys.MES.Position; + +namespace Tiger.IBusiness.MES.WorkAction +{ + public interface IPackageInputCheck : IWorkAction + { + + } +} diff --git a/Tiger.Model.Net/Entitys/MES/MES_CUST_SN.cs b/Tiger.Model.Net/Entitys/MES/MES_CUST_SN.cs index 8f359e7..195b65a 100644 --- a/Tiger.Model.Net/Entitys/MES/MES_CUST_SN.cs +++ b/Tiger.Model.Net/Entitys/MES/MES_CUST_SN.cs @@ -34,7 +34,7 @@ [DisplayName("瀹㈡埛鏉$爜")] public string CUST_SN { get; set; } /// <summary> - /// 鍘傚唴娴佽浆鏉$爜 + /// 鍘傚唴娴佽浆鏉$爜(鑻ユ槸瀵煎叆鐨勬湭缁戝畾瀹㈡埛鏉$爜锛屾瀛楁涓虹┖) /// </summary> [DisplayName("鍘傚唴娴佽浆鏉$爜")] public string FLOW_SN { get; set; } @@ -60,6 +60,21 @@ [SugarColumn(IsIgnore = true)] public string FieldName { get; set; } */ + /// <summary> + /// 鏄惁宸茬粡缁戝畾 + /// </summary> + [SugarColumn(IsIgnore = true)] + public bool IsBound => !string.IsNullOrEmpty(FLOW_SN) && !string.IsNullOrEmpty(CUST_SN) && FLOW_SN != CUST_SN; + /// <summary> + /// 鏄惁鍘傚唴娴佽浆鏉$爜 + /// </summary> + [SugarColumn(IsIgnore = true)] + public bool IsFlowSn => !string.IsNullOrEmpty(FLOW_SN) && !string.IsNullOrEmpty(CUST_SN) && FLOW_SN == CUST_SN; + /// <summary> + /// 鏄惁瀹㈡埛缂栫爜 + /// </summary> + [SugarColumn(IsIgnore = true)] + public bool IsCustSn => string.IsNullOrEmpty(FLOW_SN) && !string.IsNullOrEmpty(CUST_SN); #endregion #region 澶栭敭灞炴�� -- Gitblit v1.9.3