public IList<PaqcsortingInfo> GetStationList(string line, string editor, out string message) { IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IStationRepository stationRep = RepositoryFactory.GetInstance().GetRepository<IStationRepository>(); IList<PaqcsortingInfo> stationList = new List<PaqcsortingInfo>(); message = ""; ArrayList retList = new ArrayList(); if (line == "") { return stationList; } //1. 获取PAQC Sorting 支持的站点 //PAQC Sorting 支持的站点定义在SysSetting表,参考如下方法获取: //SELECT @PAQCSortingStation = Value FROM SysSetting NOLOCK //WHERE Name = 'PAQCSortingStation' //其格式是逗号分隔的站号,例如:69,8C,95 IList<string> valueList = new List<string>(); valueList = partRep.GetValueFromSysSettingByName("PAQCSortingStation"); //ITC-1413-0087 if (valueList.Count == 0) { /* List<string> erpara = new List<string>(); FisException e; erpara.Add(""); e = new FisException("PAK146", erpara);//请配置PAQC Sorting Station throw e;*/ return stationList; } string[] stationArray = valueList[0].Split(','); foreach (string stationID in stationArray) { PaqcsortingInfo newStation = new PaqcsortingInfo(); //Descr Station.Descr IStation station = stationRep.Find(stationID); newStation.station = stationID; newStation.Descr = station.Descr; //Previous Fail Time //SELECT ID, PreviousFailTime FROM PAQCSorting //WHERE Status = 'O' AND LEFT(Line, 1) = LEFT(@Line, 1) AND Station = @Station //Remark:@Line – 页面选择的Line //Note:如果没有满足条件的记录,则Previous Fail Time显示为空 IList<PaqcsortingInfo> sortingList = modelRep.GetPreviousFailTimeList(line, stationID); if (sortingList.Count > 0) { newStation.id = sortingList[0].id; newStation.previousFailTime = sortingList[0].previousFailTime; DateTime startTime = modelRep.GetMinCdtFromPaqcSortingProduct(newStation.id); if (startTime != DateTime.MinValue) { modelRep.InsertIntoPaqCSortingProductFromProductAndProductLog(startTime, line, stationID, newStation.id); } } else { newStation.id = -1; } //Pass Qty //如果前文没有得到Previous Fail Time,则显示为空;否则,参考如下方法取得Pass Qty: if (newStation.id != -1) { int passQty = getPassQty(newStation.id); newStation.PassQty = passQty; } //Least Pass Qty //如果前文没有得到Previous Fail Time,则显示为空;否则,参考如下方法取得Least Pass Qty: if (newStation.id != -1) { int leastQty = getLeastPassQty(newStation.id, newStation.previousFailTime); newStation.LeastPassQty = leastQty; } //将其中Least Pass Qty >= @PAKSortingQty 或者Previous Fail Time 为空的记录Disable int sortingQty = getSortingQty(); if (newStation.id != -1 && newStation.LeastPassQty >= sortingQty) { //5. Update PAQCSorting //检查每一条记录,如果@PAQCSortingID 对应的Least Qty >= @PAKSortingQty //则需要将PAQCSorting 表中ID = @PAQCSortingID 的记录的Status 置为'C', //并于Message 区显示:“本次PAQC Sorting 完毕! Line: ”+ LEFT(@Line, 1) + “ Station: ” + @Station + “(” + @StationDescr + “)” //message = message + station.StationId + "(" + station.Descr + ")"; //UPDATE PAQCSorting SET Stauts = 'C', Editor = @Editor, Udt = GETDATE() WHERE ID = @PAQCSortingID PaqcsortingInfo udata = new PaqcsortingInfo(); udata.status = "C"; //udata.previousFailTime = DateTime.Now; udata.editor = editor; udata.udt = DateTime.Now; PaqcsortingInfo uconf = new PaqcsortingInfo(); uconf.id = newStation.id; modelRep.UpdatePqacSortingInfo(udata, uconf); message = message + station.StationId + "(" + station.Descr + ")"; newStation.id = -2; } stationList.Add(newStation); } return stationList; }
/// <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); } }
public ArrayList updateStation(int sortingID, string editor, string station, string customer) { logger.Debug("(PAQCSortingImpl)updateStation start [sortingID]: " + sortingID); try { ArrayList retList = new ArrayList(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); //Update PAQCSorting.PreviousFailTime //参考方法: //UPDATE PAQCSorting SET PreviousFailTime = GETDATE(), Editor = @Editor, Udt = GETDATE() WHERE ID = @PAQCSortingID PaqcsortingInfo udata = new PaqcsortingInfo(); udata.previousFailTime = DateTime.Now; udata.editor = editor; udata.udt = DateTime.Now; PaqcsortingInfo uconf = new PaqcsortingInfo(); uconf.id = sortingID; modelRep.UpdatePqacSortingInfo(udata, uconf); return retList; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(PAQCSortingImpl)save end [sortingID]: " + sortingID); } }
/// <summary> /// /// </summary> /// <param name="sortingID"></param> /// <param name="editor"></param> /// <param name="station"></param> /// <param name="customer"></param> public ArrayList save(int sortingID, string custSN, string editor, string station, string customer) { logger.Debug("(PAQCSortingImpl)save start [sortingID]: " + sortingID); try { ArrayList retList = new ArrayList(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); //1. Insert PAQCSorting_Product //INSERT INTO [PAQCSorting_Product]([PAQCSortingID],[CUSTSN],[Status],[Editor],[Cdt]) //VALUES(@PAQCSortingID, @CustomerSN, 1, @Editor, GETDATE()) //ITC-1413-0089 PaqcsortingProductInfo item = new PaqcsortingProductInfo(); item.paqcsortingid = sortingID; item.custsn = custSN; item.status = 1; item.editor = editor; item.cdt = DateTime.Now; modelRep.InsertPqacSortingProductInfo(item); //Least Pass Qty PaqcsortingInfo conf = new PaqcsortingInfo(); conf.id = sortingID; IList<PaqcsortingInfo> sortList = modelRep.GetPaqcsortingInfoList(conf); int leastqty = getLeastPassQty(sortingID, sortList[0].previousFailTime); //@PAKSortingQty 取自SysSetting int sortingQty = getSortingQty(); //2. Update PAQCSorting //如果@PAQCSortingID 对应的Least Pass Qty >= @PAKSortingQty //则需要将PAQCSorting 表中ID = @PAQCSortingID 的记录的Status 置为'C', //并于Message 区显示:“本次PAQC Sorting 完毕!” //参考方法: //UPDATE PAQCSorting SET Stauts = 'C', Editor = @Editor, Udt = GETDATE() WHERE ID = @PAQCSortingID bool endFlag = false; if (leastqty >= sortingQty) { PaqcsortingInfo udata = new PaqcsortingInfo(); udata.status = "C"; udata.editor = editor; udata.udt = DateTime.Now; PaqcsortingInfo uconf = new PaqcsortingInfo(); uconf.id = sortingID; modelRep.UpdatePqacSortingInfo(udata, uconf); endFlag = true; } retList.Add(endFlag); return retList; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(PAQCSortingImpl)save end [sortingID]: " + sortingID); } }
public IList<PaqcsortingInfo> GetStationList(string line, string editor, out string message) { IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IStationRepository stationRep = RepositoryFactory.GetInstance().GetRepository<IStationRepository>(); IList<PaqcsortingInfo> stationList = new List<PaqcsortingInfo>(); message = ""; ArrayList retList = new ArrayList(); if (line == "") { return stationList; } //1. 获取PAQC Sorting 支持的站点 //PAQC Sorting 支持的站点定义在SysSetting表,参考如下方法获取: //SELECT @PAQCSortingStation = Value FROM SysSetting NOLOCK //WHERE Name = 'PAQCSortingStation' //其格式是逗号分隔的站号,例如:69,8C,95 IList<string> valueList = new List<string>(); valueList = partRep.GetValueFromSysSettingByName("PAQCSortingStation"); //ITC-1413-0087 if (valueList.Count == 0) { /* List<string> erpara = new List<string>(); FisException e; erpara.Add(""); e = new FisException("PAK146", erpara);//请配置PAQC Sorting Station throw e;*/ return stationList; } string[] stationArray = valueList[0].Split(','); foreach (string stationID in stationArray) { //SELECT @PAQCSortingID = ID FROM PAQCSorting NOLOCK //WHERE Station = @Station //AND LEFT(Line, 1) = LEFT(@Line, 1) //AND Status = 'O' IList<PaqcsortingInfo> sortingList = modelRep.GetPaqcsortingInfoList(line, stationID); foreach (var item in sortingList) { if (item.status == "O") { insertSortingProduct(item.id, line, stationID,item.previousFailTime); } if (item.status == "O" || item.status == "I") { PaqcsortingInfo newStation = new PaqcsortingInfo(); //Descr Station.Descr IStation station = stationRep.Find(stationID); newStation.station = stationID; newStation.Descr = station.Descr; //SELECT CUSTSN FROM PAQCSorting_Product //WHERE PAQCSortingID = @PAQCSortingID AND Status = '2' PaqcsortingProductInfo conf = new PaqcsortingProductInfo(); conf.paqcsortingid = item.id; conf.status = 2; PaqcsortingProductInfo nconf = new PaqcsortingProductInfo(); IList<PaqcsortingProductInfo> pinfoList = modelRep.GetPaqcsortingProductInfoList(conf, nconf); if (pinfoList.Count > 0) { newStation.editor = pinfoList[0].custsn; } //SELECT Status FROM PAQCSorting //WHERE ID = @PAQCSortingID //取得的Status 值,使用如下字符串显示 //I – Initial O– Open C – Close switch (item.status) { case "I": newStation.status = "Initial"; break; case "O": newStation.status = "Open"; break; case "C": newStation.status = "Close"; break; } //SELECT PreviousFailTime FROM PAQCSorting //WHERE ID = @PAQCSortingID newStation.previousFailTime = item.previousFailTime; //Qty //SELECT COUNT(CUSTSN) FROM PAQCSorting_Product NOLOCK //WHERE PAQCSortingID = @PAQCSortingID AND Status <> 2 PaqcsortingProductInfo cond = new PaqcsortingProductInfo(); cond.paqcsortingid = item.id; PaqcsortingProductInfo ncond = new PaqcsortingProductInfo(); ncond.status = 2; pinfoList= modelRep.GetPaqcsortingProductInfoList(cond,ncond); newStation.LeastPassQty = pinfoList.Count; newStation.id = item.id; stationList.Add(newStation); //5. Update PAQCSorting //检查每一条记录,如果@PAQCSortingID 对应的Qty >= @PAKSortingQty //则需要将PAQCSorting 表中ID = @PAQCSortingID 的记录的Status 置为'C', //并于Message 区显示:“本次PAQC Sorting 完毕! Line: ”+ LEFT(@Line, 1) + //“ Station: ” + @Station + “(” + @StationDescr + “) ” + “Sorting ID: ”+ @PAQCSortingID //UPDATE PAQCSorting SET Stauts = 'C', Editor = @Editor, Udt = GETDATE() WHERE ID = @PAQCSortingID int pakSortingQty = getSortingQty(); if (newStation.LeastPassQty >= pakSortingQty) { PaqcsortingInfo udata = new PaqcsortingInfo(); udata.status = "C"; udata.editor = editor; udata.udt = DateTime.Now; PaqcsortingInfo uconf = new PaqcsortingInfo(); uconf.id = newStation.id; modelRep.UpdatePqacSortingInfo(udata, uconf); message = message + "Line: " + line.Substring(0, 1) + " Station: " + stationID + "(" + newStation.Descr + ")" + " Sorting ID: " + item.id + " ;"; } } } } //所有记录按照Status, Station 排序显示 return (from item in stationList orderby item.status, item.station select item).ToList(); ; }
/// <summary> /// /// </summary> /// <param name="customer"></param> /// <param name="line"></param> /// <param name="station"></param> /// <param name="editor"></param> /// <param name="remark"></param> /// <returns></returns> public ArrayList addSorting( string customer,string line, string station,string editor,string remark) { logger.Debug("(PAQCSortingImpl)addSorting start [station]: " + station); try { ArrayList retList = new ArrayList(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); //c.如果用户输入的Customer S/N 在数据库中不存在,则报告错误:“Invalid Customer S/N!” var currentProduct = CommonImpl.GetProductByInput(customer, CommonImpl.InputTypeEnum.CustSN); //d.如果用户输入的Customer S/N 在ProductLog 表中不存在69 站的记录, //则报告错误:“此产品尚未进入包装,不能进行Sorting!” var repository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IList<ProductLog> logList = repository.GetProductLogs(currentProduct.ProId, "69"); if (logList.Count <= 0) { FisException ex; List<string> erpara = new List<string>(); ex = new FisException("PAK167", erpara); throw ex; } //1.Insert PAQCSorting //INSERT INTO PAQCSorting([Station],[Line],[Status],[PreviousFailTime],[Remark],[Editor],[Cdt],[Udt]) //VALUES(@Station, @Line, 'O', GETDATE(), @Remark, @Editor, GETDATE(), GETDATE()) PaqcsortingInfo info = new PaqcsortingInfo(); info.station = station; info.line = line; info.status = "O"; info.previousFailTime = DateTime.Now; info.remark = remark; info.editor = editor; info.cdt = DateTime.Now; info.udt = DateTime.Now; modelRep.InsertPqacSortingInfo(info); //2.Insert PAQCSorting_Product //INSERT INTO [PAQCSorting_Product]([PAQCSortingID],[CUSTSN],[Status],[Editor],[Cdt]) //VALUES(@PAQCSortingID, @CustomerSN, 2, @Editor, GETDATE()) PaqcsortingProductInfo pinfo = new PaqcsortingProductInfo(); pinfo.paqcsortingid = info.id; pinfo.custsn = customer; pinfo.status = 2; pinfo.editor = editor; pinfo.cdt = DateTime.Now; modelRep.InsertPqacSortingProductInfo(pinfo); retList.Add(info.id); return retList; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(PAQCSortingImpl)addSorting end [Station]: " + station); } }
/// <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); } }