/// <summary> /// 启动工作流,根据输入productID获取Model和标准重量,成功后调用NeedCheckSN /// 如果需要检查的SN,调用CheckSN,否则调用Save /// 将actualWeight放到Session.ActuralWeight中,用于检查是否和标准重量相符 /// 将actualWeight放到Session.CartonWeight中,用于保存CartonWeight重量用 /// </summary> /// <param name="productID"></param> /// <param name="actualWeight"></param> /// <param name="line"></param> /// <param name="editor"></param> /// <param name="station"></param> /// <param name="customer"></param> /// <returns></returns> public StandardWeight InputUUT(string productID, decimal actualWeight, string line, string editor, string station, string customer,out bool needCheckSN) { logger.Debug("(PizzaWeight)InputUUT Start," + " [productID]:" + productID + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [actualWeight]:" + actualWeight.ToString() + " [customer]:" + customer); try { string sessionKey = productID; Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, currentSessionType); if (currentSession == null) { currentSession = new Session(sessionKey, currentSessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", currentSessionType); string wfName, rlName; RouteManagementUtils.GetWorkflow(station, "036PizzaWeight.xoml", "036pizzaweight.rules", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); // currentSession.AddValue(Session.SessionKeys., currentProduct); currentSession.AddValue(Session.SessionKeys.ActuralWeight, actualWeight); currentSession.AddValue(Session.SessionKeys.CartonWeight, actualWeight); currentSession.AddValue(Session.SessionKeys.IsComplete, false); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } Product currentProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product); string modelTolerance = currentSession.GetValue (Session.SessionKeys.Tolerance).ToString(); decimal standardWeight =(decimal)currentSession.GetValue(Session.SessionKeys.StandardWeight); //out parameter StandardWeight currentStandardWeight = new StandardWeight(); currentStandardWeight.Model = currentProduct.Model; currentStandardWeight.Weight = standardWeight; currentStandardWeight.Tolerance = modelTolerance; needCheckSN = false; if (String.Compare(currentProduct.ModelObj.Region, "JPN",true) == 0) { needCheckSN = true; } return currentStandardWeight; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw new SystemException(e.Message); } finally { logger.Debug("(PizzaWeight)InputUUT End," + " [productID]:" + productID + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [actualWeight]:" + actualWeight.ToString() + " [customer]:" + customer); } }
/// <summary> /// 因为Carton需要根据其中任意一个SN进行SFC, /// 所以在本方法中需要先根据Carton号码获取一个Product对像放到Session中 /// CommonImpl.GetProductByInput(cartonNumber, CommonImpl.InputTypeEnum.Carton) /// 将cartonNumber放到Session.Carton /// 将CartonWeight放到Session.CartonWeight,用于保存CartonWeight重量用 /// ProductRepository.GetProductIDListByCarton(string cartonSN)可以获取属于该Carton的所有的ProductID /// 根据CartonWeight/Carton中的机器数量获得平均每台机器的ActuralWeight,并放到Session.ActuralWeight,用于检查是否和标准重量相符 /// 启动工作流,根据输入cartonNumber获取Model和标准重量 /// </summary> /// <param name="cartonNumber"></param> /// <param name="line"></param> /// <param name="editor"></param> /// <param name="station"></param> /// <param name="customer"></param> /// <returns>StandardWeight对象</returns> public StandardWeight InputCarton(string custSN, decimal cartonWeight, string line, string editor, string station, string customer, out string productID,out string cartonSN) { logger.Debug("(CartonWeight)InputCarton Start," + " [custSN]:" + custSN + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [cartonWeight]:" + cartonWeight.ToString() + " [customer]:" + customer); try { var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN); if (currentProduct == null) { FisException fe = new FisException("CHK079", new string[] { custSN }); throw fe; } //ITC-1268-0104 //判断cartonsn是否不为空 if ((currentProduct.CartonSN == null) || (currentProduct.CartonSN.Trim() == string.Empty)) { throw new FisException("CHK101", new string[] { currentProduct.ProId }); } string sessionKey = currentProduct.ProId; Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, currentSessionType); if (currentSession == null) { currentSession = new Session(sessionKey, currentSessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", currentSessionType); IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); IList<string> productlist = productRepository.GetProductIDListByCarton(currentProduct.CartonSN); decimal actweight = cartonWeight / productlist.Count; string wfName, rlName; RouteManagementUtils.GetWorkflow(station, "036CartonWeight.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.Carton, currentProduct.CartonSN); currentSession.AddValue(Session.SessionKeys.Product, currentProduct); currentSession.AddValue(Session.SessionKeys.CartonWeight, cartonWeight); currentSession.AddValue(Session.SessionKeys.ActuralWeight, actweight); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(currentProduct.ProId); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } string modelTolerance = currentSession.GetValue(Session.SessionKeys.Tolerance).ToString(); decimal standardWeight = (decimal)currentSession.GetValue(Session.SessionKeys.StandardWeight); //out parameter StandardWeight currentStandardWeight = new StandardWeight(); currentStandardWeight.Model = currentProduct.Model; currentStandardWeight.Weight = standardWeight; currentStandardWeight.Tolerance = modelTolerance; cartonSN = currentProduct.CartonSN; productID = currentProduct.ProId; return currentStandardWeight; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw new SystemException(e.Message); } finally { logger.Debug("(CartonWeight)InputCarton End," + " [custSN]:" + custSN + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [cartonWeight]:" + cartonWeight.ToString() + " [customer]:" + customer); } }