/// <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> /// Least Pass Qty /// </summary> /// <param name="sortingID"></param> /// <param name="failTime"></param> /// <returns></returns> public int getLeastPassQty(int sortingID, DateTime failTime) { IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); PaqcsortingProductInfo conf = new PaqcsortingProductInfo(); conf.paqcsortingid = sortingID; //conf.status = 1; //Least Pass Qty //参考如下方法取得Least Pass Qty: //SELECT COUNT(CUSTSN) FROM PAQCSorting_Product NOLOCK //WHERE PAQCSortingID = @PAQCSortingID AND Cdt > @PreviousFailTime //AND Status = 1 int qty = modelRep.GetCountOfPqacSortingProduct(conf, failTime); //Modify 2012/08/30 Status <>2 //============================================================== PaqcsortingProductInfo conf2 = new PaqcsortingProductInfo(); conf2.paqcsortingid = sortingID; conf2.status = 2; int qty2 = modelRep.GetCountOfPqacSortingProduct(conf2, failTime); qty = qty - qty2; //============================================================== return qty; }
/// <summary> /// 取得Pass Qty /// </summary> /// <param name="sortingID"></param> /// <returns></returns> public int getPassQty(int sortingID) { //参考如下方法取得Pass Qty: //SELECT COUNT(CUSTSN) FROM PAQCSorting_Product NOLOCK //WHERE PAQCSortingID = @PAQCSortingID //AND Status = 1 //Remark:@PAQCSortingID 为前面取得Previous Fail Time 时,同时取得的PAQCSorting.ID IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); PaqcsortingProductInfo conf = new PaqcsortingProductInfo(); conf.paqcsortingid = sortingID; //conf.status = 1; int qty = modelRep.GetCountOfPqacSortingProduct(conf); //Modify 2012/08/30 Status <>2 //============================================================== PaqcsortingProductInfo conf2 = new PaqcsortingProductInfo(); conf2.paqcsortingid = sortingID; conf2.status = 2; int qty2 = modelRep.GetCountOfPqacSortingProduct(conf2); qty = qty - qty2; //============================================================== return qty; }
/// <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); } }
/// <summary> /// 新增Product 记录至PAQCSortiing_Product /// </summary> /// <param name="sortingID"></param> /// <param name="line"></param> /// <param name="station"></param> public void insertSortingProduct(int sortingID,string line,string station,DateTime failTime) { IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); //SELECT @StartTime = MIN(Cdt) FROM PAQCSorting_Product NOLOCK //WHERE PAQCSortingID = @PAQCSortingID DateTime starttime = modelRep.GetMinCdtFromPaqcSortingProduct(sortingID); if (starttime.Year == 1) { starttime = failTime; } DateTime openTime = DateTime.Now; if (DateTime.Compare(failTime,starttime) >= 0) { openTime = failTime; } else { openTime = starttime; } //SELECT @N1 = COUNT(*) FROM PAQCSorting_Product NOLOCK //WHERE PAQCSortingID = @PAQCSortingID AND Status <> '2' PaqcsortingProductInfo conf = new PaqcsortingProductInfo(); conf.paqcsortingid = sortingID; PaqcsortingProductInfo nconf = new PaqcsortingProductInfo(); nconf.status = 2; IList<PaqcsortingProductInfo> pinfoList = modelRep.GetPaqcsortingProductInfoList(conf,nconf); int n1 = pinfoList.Count; //SELECT @N2 = CONVERT(int, Value) //FROM SysSetting NOLOCK WHERE Name = 'PAKSortingQty' int n2 = getSortingQty(); //SET @N3 = @N2 - @N1 + 1 int n3 = n2 - n1 + 1; if (n3 < 0) { n3 = 0; } //INSERT INTO PAQCSorting_Product (PAQCSortingID, CUSTSN, Status, Editor, Cdt) //SELECT TOP (@N3) @PAQCSortingID, a.CUSTSN, b.Status, b.Editor, b.Cdt //FROM Product a (NOLOCK), ProductLog b (NOLOCK) //WHERE a.ProductID = b.ProductID //AND b.Cdt > @StartTime //AND b.Cdt > @PreviousFailTime //AND LEFT(b.Line, 1) = LEFT(@Line, 1) //AND b.Station = @Station //AND a.CUSTSN NOT IN (SELECT CUSTSN FROM PAQCSorting_Product NOLOCK WHERE PAQCSortingID = @PAQCSortingID) //ORDER BY b.Cdt modelRep.InsertIntoPaqCSortingProductFromProductAndProductLog(openTime, line, station, sortingID, n3); return ; }
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); } }