public List <R_LOT_DETAIL> GetLotDetailByLotNo(string lotNo, OleExec DB) { List <R_LOT_DETAIL> res = new List <R_LOT_DETAIL>(); string strSql = $@" select a.* from r_lot_detail a ,r_lot_status b where a.lot_id=b.id and b.lot_no='{lotNo}' "; DataSet ds = DB.ExecSelect(strSql); foreach (DataRow VARIABLE in ds.Tables[0].Rows) { Row_R_LOT_DETAIL r = (Row_R_LOT_DETAIL)this.NewRow(); r.loadData(VARIABLE); res.Add(r.GetDataObject()); } return(res); }
/// <summary> /// FQC Lot 過站 /// </summary> /// <param name="SerialNo"></param> /// <param name="LotNo"></param> /// <param name="PassOrFail"></param> /// <param name="EmpNo"></param> /// <param name="Station"></param> /// <param name="Line"></param> /// <param name="BU"></param> /// <param name="DB"></param> /// <param name="FailInfos"></param> public void LotPassStation(string SerialNo, string LotNo, string PassOrFail, string EmpNo, string Station, string DeviceName, string Line, string BU, OleExec DB, params string[] FailInfos) { bool PassedFlag = true; string sql = string.Empty; DataTable dt = new DataTable(); Row_R_LOT_STATUS StatusRow = (Row_R_LOT_STATUS)NewRow(); T_R_LOT_DETAIL DetailTable = new T_R_LOT_DETAIL(DB, this.DBType); Row_R_LOT_DETAIL DetailRow = (Row_R_LOT_DETAIL)DetailTable.NewRow(); R_LOT_STATUS Status = null; R_LOT_DETAIL Detail = null; T_R_SN SnTable = new T_R_SN(DB, this.DBType); List <string> LotsSN = new List <string>(); if (this.DBType == DB_TYPE_ENUM.Oracle) { PassedFlag = PassOrFail.ToUpper().Equals("PASS") ? true : false; //sql = $@"SELECT * FROM R_LOT_STATUS WHERE LOT_NO='{LotNo}' AND SAMPLE_STATION='{Station}' AND LINE='{Line}'"; //判斷有沒有 LOT sql = $@"SELECT * FROM R_LOT_STATUS WHERE LOT_NO='{LotNo}' AND SAMPLE_STATION='{Station}'"; //判斷有沒有 LOT dt = DB.ExecSelect(sql).Tables[0]; if (dt.Rows.Count > 0) { StatusRow.loadData(dt.Rows[0]); Status = StatusRow.GetDataObject(); sql = $@"SELECT A.* FROM R_LOT_DETAIL A,R_SN B WHERE LOT_ID='{StatusRow.ID}' AND B.SN='{SerialNo}' AND A.SN=B.SN"; //判斷Lot中有沒有這個SN並且沒有被抽檢過 dt = DB.ExecSelect(sql).Tables[0]; if (dt.Rows.Count > 0) { DetailRow.loadData(dt.Rows[0]); Detail = DetailRow.GetDataObject(); if (Detail.SAMPLING.Equals("1")) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000093", new string[] { SerialNo })); } } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000094", new string[] { SerialNo, LotNo })); } if (Status.CLOSED_FLAG == "1") //Lot 關閉 { if (PassedFlag) { //更新 R_LOT_DETAIL STATUS Detail.STATUS = "1"; //1 表示抽檢通過 Detail.SAMPLING = "1"; //1 表示被抽檢了 //更新 R_LOT_STATUS PASS_QTY Status.PASS_QTY++; } else { //更新 R_LOT_DETAIL STATUS ,FAIL_CODE,FAIL_LOCATION,DESCRIPTION Detail.STATUS = "0"; //0 表示抽檢失敗 Detail.SAMPLING = "1"; //1 表示被抽檢了 if (FailInfos != null && FailInfos.Length == 3) //記錄失敗原因 { Detail.FAIL_CODE = FailInfos[0]; Detail.FAIL_LOCATION = FailInfos[1]; Detail.DESCRIPTION = FailInfos[2]; } //更新 R_LOT_STATUS FAIL_QTY Status.FAIL_QTY++; } if (Status.FAIL_QTY >= Status.REJECT_QTY && Status.FAIL_QTY != 0) { //更新 R_LOT_STATUS 關閉,NG, //Status.CLOSED_FLAG = "1";// 1 表示關閉Lot Status.LOT_STATUS_FLAG = "2";// 2 表示整個 Lot 不良 //更新 R_LOT_DETAIL 鎖定LOT 中所有 Detail.EDIT_EMP = EmpNo; Detail.EDIT_TIME = GetDBDateTime(DB); DetailRow.ConstructRow(Detail); DB.ExecSQL(DetailRow.GetUpdateString(this.DBType)); //該批次鎖定--add by Eden 2018-05-04 sql = $@"update r_lot_detail set sampling='4' where lot_id='{Detail.LOT_ID}'"; DB.ExecSQL(sql); //DetailTable.LockLotBySn(SerialNo, EmpNo, DB); } else { if (Status.PASS_QTY + Status.FAIL_QTY >= Status.SAMPLE_QTY) { //更新 R_LOT_STATUS 關閉,OK //Status.CLOSED_FLAG = "1"; Status.LOT_STATUS_FLAG = "1"; // 1 表示整個 Lot 正常 //更新 R_LOT_DETAIL 鎖定FAIL 的,其他的正常過站 //sql = $@"SELECT * FROM R_LOT_DETAIL WHERE LOT_ID='{StatusRow.ID}' AND STATUS='0'"; sql = $@"SELECT * FROM R_LOT_DETAIL WHERE LOT_ID='{StatusRow.ID}' AND ((SAMPLING='1' AND STATUS='1') OR (SAMPLING='0'))"; dt = DB.ExecSelect(sql).Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { LotsSN.Add(dr["SN"].ToString()); } SnTable.LotsPassStation(LotsSN, Line, Station, DeviceName, BU, PassOrFail, EmpNo, DB); // 過站 } //記錄通過數 ,UPH foreach (string SN in LotsSN) { SnTable.RecordYieldRate(Detail.WORKORDERNO, 1, SN, "PASS", Line, Station, EmpNo, BU, DB); SnTable.RecordUPH(Detail.WORKORDERNO, 1, SN, "PASS", Line, Station, EmpNo, BU, DB); } } Detail.EDIT_EMP = EmpNo; Detail.EDIT_TIME = GetDBDateTime(DB); DetailRow.ConstructRow(Detail); DB.ExecSQL(DetailRow.GetUpdateString(this.DBType)); } Status.EDIT_EMP = EmpNo; Status.EDIT_TIME = GetDBDateTime(DB); StatusRow.ConstructRow(Status); DB.ExecSQL(StatusRow.GetUpdateString(this.DBType)); } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000201", new string[] { LotNo })); } } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000091", new string[] { LotNo })); } } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } }