From 1bcc9f898b1cb745bda50ac3b177de86f7b661bc Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期一, 26 八月 2024 16:51:51 +0800 Subject: [PATCH] 包装行为增加称重按预设范围来判断称重是否成功 增加专门验证用的行为 --- Tiger.Business.MES/WorkAction/VerifyItem.cs | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++ Tiger.Api/Language.db | 0 Tiger.Business.MES/WorkAction/PackingAction.cs | 14 +++ Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs | 12 +++ 4 files changed, 229 insertions(+), 0 deletions(-) diff --git a/Tiger.Api/Language.db b/Tiger.Api/Language.db index 5860058..b8ce9f6 100644 --- a/Tiger.Api/Language.db +++ b/Tiger.Api/Language.db Binary files differ diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs index 272119f..7a1566f 100644 --- a/Tiger.Business.MES/WorkAction/PackingAction.cs +++ b/Tiger.Business.MES/WorkAction/PackingAction.cs @@ -25,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; } @@ -68,6 +69,8 @@ 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()) { @@ -280,6 +283,17 @@ { 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; + 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; diff --git a/Tiger.Business.MES/WorkAction/VerifyItem.cs b/Tiger.Business.MES/WorkAction/VerifyItem.cs new file mode 100644 index 0000000..2abb1b8 --- /dev/null +++ b/Tiger.Business.MES/WorkAction/VerifyItem.cs @@ -0,0 +1,203 @@ +锘縰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; + +namespace Tiger.Business.MES.WorkAction +{ + public class VerifyItem : IVerifyItem + { + #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 + + #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 + + + } + + /// <summary> + /// 鑾峰彇琛屼负寮�濮嬬殑鎻愮ず淇℃伅 + /// </summary> + /// <returns></returns> + public Locale GetBeginMsg() + { + var msg = new Locale("MES.WorkAction.VerifyItem.BeginMsg"); + //var msg = new Locale($"寮�濮嬮獙璇佷骇鍝乕{CurPosition.CurWipSN.SN}]"); + return msg; + } + + /// <summary> + /// 灏濊瘯寮�濮嬫墽琛屽伐搴忚涓� + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> TryBegin(SubmitInput input) + { + var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + + action = Submit(input); + + //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触 + //action.IsSuccessed = true; + //action.Data.ShortMsg = new("楠岃瘉寮�濮�", ShortMessage.Types.Success); + return action; + } + + /// <summary> + /// 宸ュ簭琛屼负鎻愪氦鏁版嵁 + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> Submit(SubmitInput input) + { + var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + + action = Verify(input, action); + //涓婃枡鏁版嵁淇濆瓨澶辫触 + if (!action.IsSuccessed) + { + //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣� + if (NodeAct.NEED_RESET == "Y") + { + CurPosition.ResetNode(); + } + } + return action; + } + + public ApiAction<SubmitOutput> Verify(SubmitInput input, ApiAction<SubmitOutput> action) + { + try + { + var isOK = true; + //楠岃瘉閫昏緫 + //if (input.SN.IsNullOrEmpty()) + { + action.Data.ShortMsg = new("楠岃瘉澶辫触", ShortMessage.Types.Failed); + action.IsSuccessed = isOK = false; + //action.LocaleMsg = new Locale($"閿欒锛歔{ExtInfo.FIELD_NAME}]鏍囩鏉$爜涓嶈兘涓虹┖锛岃閲嶆柊鎵弿"); + //action.LocaleMsg = new Locale("MES.WorkAction.VerifyItem.SnEmptyError", ExtInfo.FIELD_NAME); + } + //if (CurPosition.CurWipSNs.Any(w => w.SN == input.SN)) + { + action.Data.ShortMsg = new("楠岃瘉澶辫触", ShortMessage.Types.Failed); + action.IsSuccessed = isOK = false; + //action.LocaleMsg = new Locale($"閿欒锛氭壂鎻忓埌浜у搧鏉$爜[{input.SN}]锛岃閲嶆柊鎵弿[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜"); + //action.LocaleMsg = new Locale("MES.WorkAction.VerifyItem.ScanProdSnError", input.SN, ExtInfo.FIELD_NAME); + } + + //楠岃瘉閫氳繃鍒欎繚瀛� + if (isOK) + { + action = End(); + } + + //閮芥病鏈夌墿鏂欓獙璇侀�氳繃锛屽垯杩斿洖閿欒淇℃伅 + } + catch (System.Exception ex) + { + action.Data.ShortMsg = new("楠岃瘉寮傚父", ShortMessage.Types.Exception); + action.CatchExceptionWithLog(ex, $"楠岃瘉寮傚父"); + action.IsSuccessed = false; + //action.LocaleMsg = new($"浜у搧[{CurPosition.CurSN}]楠岃瘉寮傚父锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜"); + //action.LocaleMsg = new("MES.WorkAction.VerifyItem.SaveExtInfoException", CurPosition.CurSN); + CurPosition.ResetNode(); + } + return action; + } + + /// <summary> + /// 缁撴潫鎵ц宸ュ簭琛屼负 + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> End() + { + var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + + //璁板綍琛屼负鎿嶄綔璁板綍 + var wipActs = new List<MES_WIP_ACT>(); + 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 = $"浜у搧[{CurPosition.CurSN}]楠岃瘉閫氳繃", + }; + wipActs.Add(wipAct); + } + + //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊� + var _wipActs = wipActs.Clone(); + //淇濆瓨鏁版嵁 + CurStep.DBSubmitAction = () => + { + var db = CurPosition.GetCommitDB(); + db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); + }; + + IsFinished = true; + action.Data.ShortMsg = new("楠岃瘉閫氳繃", ShortMessage.Types.Success); + //action.LocaleMsg = new($"浜у搧[{CurPosition.CurSN}]楠岃瘉閫氳繃"); + action.LocaleMsg = new("MES.WorkAction.VerifyItem.VerifySuccess", CurPosition.CurSN); + return action; + } + + #endregion Functions + } +} diff --git a/Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs b/Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs new file mode 100644 index 0000000..a927f9a --- /dev/null +++ b/Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs @@ -0,0 +1,12 @@ +锘縰sing Newtonsoft.Json; +using Rhea.Common; +using System; +using Tiger.Model; + +namespace Tiger.IBusiness.MES.WorkAction +{ + public interface IVerifyItem : IWorkAction + { + + } +} -- Gitblit v1.9.3