/// <summary> /// 扫描9999,结束工作流 /// 如果没有Defect,即defectCodeList为null或cout为0 /// 将Session.AddValue(Session.SessionKeys.HasDefect,false) /// 否则Session.AddValue(Session.SessionKeys.HasDefect,true) /// </summary> /// <param name="prodId"></param> public void save(string prodId, string line, string editor, IList<string> defectCodeList) { logger.Debug("(PAQCOutputImpl)save start," + " [prodId]: " + prodId + " [defectList]:" + defectCodeList); FisException ex; List<string> erpara = new List<string>(); string sessionKey = prodId; try { Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (session == null) { erpara.Add(sessionKey); ex = new FisException("CHK021", erpara); //ex.logErr("", "", "", "", "83"); //logger.Error(ex); throw ex; } else { session.AddValue(Session.SessionKeys.DefectList, defectCodeList); session.AddValue(Session.SessionKeys.HasDefect, (defectCodeList != null && defectCodeList.Count != 0) ? true : false); session.Exception = null; session.SwitchToWorkFlow(); //check workflow exception if (session.Exception != null) { if (session.GetValue(Session.SessionKeys.WFTerminated) != null) { session.ResumeWorkFlow(); } throw session.Exception; } if (defectCodeList.Count == 0) { return; } //a. 获取PAQC Sorting 支持的站点 Product curProduct = (Product)session.GetValue(Session.SessionKeys.Product); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IList<string> valueList = new List<string>(); valueList = partRep.GetValueFromSysSettingByName("PAQCSortingStation"); string[] lineArray = line.Split(' '); string curLine = lineArray[0]; //b. 对于PAQC Sorting 支持的每一个站点,Insert PAQCSorting //INSERT INTO PAQCSorting([Station],[Line],[Status],[PreviousFailTime],[Remark],[Editor],[Cdt],[Udt]) //VALUES(@Station, @Line, 'I', GETDATE(), 'Automatically add at PAQC Output', @Editor, GETDATE(), GETDATE()) //@Line – ProductStatus.Line //@Station - PAQC Sorting 支持的某一个站点 string[] stationArray = valueList[0].Split(','); foreach (string stationID in stationArray) { IPAQCSorting sorting = new PAQCSortingImpl(); IList<PaqcsortingInfo> sortingList = modelRep.GetPreviousFailTimeList(curLine, stationID); PaqcsortingInfo udata = new PaqcsortingInfo(); udata.station = stationID; udata.line = curLine; udata.status = "I"; udata.previousFailTime = DateTime.Now; udata.remark = "Automatically add at PAQC Output"; udata.editor = editor; udata.cdt = DateTime.Now; udata.udt = DateTime.Now; modelRep.InsertPqacSortingInfo(udata); //c. 对于上一步Insert PAQCSorting 表的每一条记录, //都需要在PAQCSorting_Product Insert 与当前Product 的结合记录 //INSERT INTO [PAQCSorting_Product]([PAQCSortingID],[CUSTSN],[Status],[Editor],[Cdt]) //VALUES(@PAQCSortingID, @CustomerSN, 2, @Editor, GETDATE()) //PAQCSortingID - 上一步Update / Insert PAQCSorting 表的某一条记录的ID //@Customer – Product.CUSTSN PaqcsortingProductInfo pitem = new PaqcsortingProductInfo(); pitem.paqcsortingid = udata.id; pitem.custsn = curProduct.CUSTSN; pitem.status = 2; pitem.editor = editor; pitem.cdt = DateTime.Now; modelRep.InsertPqacSortingProductInfo(pitem); } } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(PAQCOutputImpl)save end," + " [prodId]: " + prodId + " [defectList]:" + defectCodeList); } }
/// <summary> /// 扫描9999,结束工作流 /// 如果没有Defect,即defectCodeList为null或cout为0 /// 将Session.AddValue(Session.SessionKeys.HasDefect,false) /// 否则Session.AddValue(Session.SessionKeys.HasDefect,true) /// </summary> /// <param name="prodId"></param> public void save(string prodId, string line, string editor,IList<string> defectCodeList) { logger.Debug("(PAQCOutputImpl)save start," + " [prodId]: " + prodId + " [defectList]:" + defectCodeList); FisException ex; List<string> erpara = new List<string>(); string sessionKey = prodId; try { Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (session == null) { erpara.Add(sessionKey); ex = new FisException("CHK021", erpara); //ex.logErr("", "", "", "", "83"); //logger.Error(ex); throw ex; } else { session.AddValue(Session.SessionKeys.DefectList, defectCodeList); session.AddValue(Session.SessionKeys.HasDefect, (defectCodeList != null && defectCodeList.Count != 0) ? true : false); session.Exception = null; session.SwitchToWorkFlow(); //check workflow exception if (session.Exception != null) { if (session.GetValue(Session.SessionKeys.WFTerminated) != null) { session.ResumeWorkFlow(); } throw session.Exception; } if (defectCodeList.Count == 0) { return; } //a. 获取PAQC Sorting 支持的站点 Product curProduct = (Product)session.GetValue(Session.SessionKeys.Product); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IList<string> valueList = new List<string>(); valueList = partRep.GetValueFromSysSettingByName("PAQCSortingStation"); string[] lineArray = line.Split(' '); string curLine = lineArray[0]; //b.对于PAQC Sorting 支持的每一个站点,如果在PAQCSorting 表中存在当前Product 所在Line 状态为’O’ 的记录, //则Update 该记录的PreviousFailTime,Editor,Udt;否则Insert string[] stationArray = valueList[0].Split(','); foreach (string stationID in stationArray) { IPAQCSorting sorting = new PAQCSortingImpl(); IList<PaqcsortingInfo> sortingList = modelRep.GetPreviousFailTimeList(curLine, stationID); int paqcSortID = 0; if (sortingList.Count > 0) { //UPDATE PAQCSorting SET PreviousFailTime = GETDATE(), Editor = @Editor, Udt = GETDATE() //WHERE Status = 'O' AND LEFT(Line, 1) = LEFT(@Line, 1) AND Station = @Station PaqcsortingInfo udata = new PaqcsortingInfo(); udata.previousFailTime = DateTime.Now; udata.editor = editor; udata.udt = DateTime.Now; PaqcsortingInfo uconf = new PaqcsortingInfo(); uconf.id = sortingList[0].id; modelRep.UpdatePqacSortingInfo(udata, uconf); paqcSortID = sortingList[0].id; } else { //INSERT INTO PAQCSorting([Station],[Line],[Status],[PreviousFailTime],[Editor],[Cdt],[Udt]) //VALUES(@Station, @Line, 'O', GETDATE(), @Editor, GETDATE(), GETDATE()) PaqcsortingInfo udata = new PaqcsortingInfo(); udata.station = stationID; udata.line = curLine; udata.status = "O"; udata.previousFailTime = DateTime.Now; udata.editor = editor; udata.cdt = DateTime.Now; udata.udt = DateTime.Now; modelRep.InsertPqacSortingInfo(udata); paqcSortID = udata.id; } //对于上一步Update / Insert PAQCSorting 表的每一条记录, //都需要在PAQCSorting_Product Insert 与当前Product 的结合记录 //INSERT INTO [PAQCSorting_Product]([PAQCSortingID],[CUSTSN],[Status],[Editor],[Cdt]) //VALUES(@PAQCSortingID, @CustomerSN, 0, @Editor, GETDATE()) //Remark: //@PAQCSortingID - 上一步Update / Insert PAQCSorting 表的某一条记录的ID //@Customer – Product.CUSTSN //Modify 2012/08/30 UC Update Status 0-〉2 //INSERT INTO [PAQCSorting_Product]([PAQCSortingID],[CUSTSN],[Status],[Editor],[Cdt]) //VALUES(@PAQCSortingID, @CustomerSN, 2, @Editor, GETDATE()) PaqcsortingProductInfo pitem = new PaqcsortingProductInfo() ; pitem.paqcsortingid = paqcSortID; pitem.custsn = curProduct.CUSTSN; pitem.status = 2;//0 pitem.editor = editor; pitem.cdt = DateTime.Now; modelRep.InsertPqacSortingProductInfo(pitem); } } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(PAQCOutputImpl)save end," + " [prodId]: " + prodId + " [defectList]:" + defectCodeList); } }