| | |
| | | using Rhea.Common; |
| | | |
| | | using Rhea.Common; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | |
| | | namespace Tiger.Business.MES.WorkAction |
| | | { |
| | | public class VerifyCustomSN : IVerifyItem |
| | | public class VerifyCustomSN : IVerifyCustomSN |
| | | { |
| | | #region Propertys & Variables |
| | | #region 固定写法,工序中的必要信息 |
| | | public DbClient MainDB { get; set; } |
| | | 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 BAS_ITEM_CUST CustInfo { get; set; } |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting) |
| | | { |
| | | #region 固定写法,给默认变量赋值 |
| | | MainDB = position.MainDB; |
| | | CurStep = curStep; |
| | | CurPosition = position; |
| | | NodeAct = nodeAct; |
| | | Setting = setting; |
| | | #endregion |
| | | |
| | | CurStep.Message = Biz.L("验证产品数据"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | //获取当前产品在当前客户的关系 |
| | | CustInfo = MainDB.Queryable<BAS_ITEM_CUST>().Where(q => q.ITEM_ID == CurPosition.WorkBatch.WO.ItemInfo.ID && q.CUST_CODE == CurPosition.WorkBatch.WO.CUST_CODE).First(); |
| | | |
| | | CurStep.SetStatusMessage(StepStatus.Normal, Biz.L("验证是否客户标签")); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public Locale GetBeginMsg() |
| | | { |
| | | var msg = new Locale("MES.WorkAction.VerifyItem.BeginMsg"); |
| | | //var msg = new Locale($"开始验证产品[{CurPosition.CurWipSN.SN}]"); |
| | | var msg = new Locale("MES.WorkAction.VerifyCustomSN.BeginMsg", CurPosition.CurSN); |
| | | //var msg = new Locale($"开始验证条码[{0}]是否客户标签"); |
| | | return msg; |
| | | } |
| | | |
| | |
| | | if (!action.IsSuccessed) |
| | | { |
| | | //如果行为设置为出错需要重置工序操作 |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | //if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetNode(); |
| | | } |
| | |
| | | { |
| | | var isOK = true; |
| | | //验证逻辑 |
| | | //if (input.SN.IsNullOrEmpty()) |
| | | if (!CustInfo.RULE_CODE.IsNullOrEmpty() && !Cache.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty()) |
| | | { |
| | | CurStep.Message = Biz.L("验证失败"); |
| | | CurStep.Status = StepStatus.Error; |
| | | 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)) |
| | | { |
| | | CurStep.Message = Biz.L("验证失败"); |
| | | CurStep.Status = StepStatus.Error; |
| | | 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); |
| | | var result = Cache.CodeRule[CustInfo.RULE_CODE].Verify(CurPosition.CurSN); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | 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.VerifyCustomSN.CustSnVerifyError", CurPosition.CurSN, CustInfo.RULE_CODE); |
| | | } |
| | | } |
| | | |
| | | //验证通过则保存 |
| | |
| | | { |
| | | action = End(input); |
| | | } |
| | | |
| | | //都没有物料验证通过,则返回错误信息 |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | CurStep.Message = Biz.L("验证异常"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("验证异常", ShortMessage.Types.Exception); |
| | | action.CatchExceptionWithLog(ex, $"验证异常"); |
| | | CurStep.SetStatusMessage(StepStatus.Error, Biz.L("客户标签验证异常")); |
| | | 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); |
| | | //action.LocaleMsg = new($"标签条码[{0}]验证异常,工序已重置,请重新扫描进站产品条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.VerifyCustomSN.CustSnVerifyException", CurPosition.CurSN); |
| | | CurPosition.ResetNode(); |
| | | } |
| | | return action; |
| | |
| | | |
| | | //记录行为操作记录 |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | var wipVars = new List<MES_WIP_ACT_VAR>(); |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | var wipAct = new MES_WIP_ACT() |
| | |
| | | PRD_CODE = wipSn.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = wipSn.SN, |
| | | ACT_VAR_DIC = CurStep.ActionDic.ToJson(), |
| | | ACT_RESULT = "Y", |
| | | ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(), |
| | | TRACE_INFO = $"产品[{CurPosition.CurSN}]验证通过", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | foreach (var item in NodeAct.Variables) |
| | | { |
| | | var wipVar = new MES_WIP_ACT_VAR() |
| | | { |
| | | 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, |
| | | ITEM_CODE = wipSn.ITEM_CODE, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE, |
| | | 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, |
| | | VAR_CODE = item.VAR_CODE, |
| | | VAR_NAME = item.VAR_NAME, |
| | | VAR_CONTROL = item.VAR_CONTROL, |
| | | VALUE_TYPE = item.VALUE_TYPE, |
| | | PROCESS_VAR = item.PROCESS_VAR, |
| | | INPUT_VALUE = CurStep.ActionDic.GetOrDefault(item.VAR_CODE), |
| | | TRACE_INFO = CurStep.ActionDic.ToJson(), |
| | | }; |
| | | wipVars.Add(wipVar); |
| | | } |
| | | } |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _wipActs = wipActs.Clone(); |
| | | var _wipVars = wipVars.Clone(); |
| | | //保存数据 |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipVars, CurPosition.UserCode).ExecuteCommand(); |
| | | }; |
| | | |
| | | IsFinished = true; |
| | | CurStep.Message = Biz.L("验证通过"); |
| | | CurStep.Status = StepStatus.Finished; |
| | | action.Data.ShortMsg = new("验证通过", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"产品[{CurPosition.CurSN}]验证通过"); |
| | | action.LocaleMsg = new("MES.WorkAction.VerifyItem.VerifySuccess", CurPosition.CurSN); |
| | | CurStep.SetStatusMessage(StepStatus.Finished, Biz.L("客户标签验证通过")); |
| | | action.Data.ShortMsg = new("客户标签验证通过", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"客户标签条码[{0}]验证通过"); |
| | | action.LocaleMsg = new("MES.WorkAction.VerifyCustomSN.VerifySuccess", CurPosition.CurSN); |
| | | return action; |
| | | } |
| | | |