/// <summary> /// OBA工站創建LOT,返回LOT信息 /// </summary> /// <param name="user"></param> /// <param name="packNo"></param> /// <param name="DB"></param> public R_LOT_STATUS CreateLotByPackno(User user, string packNo, OleExec DB) { T_R_PACKING tRPacking = new T_R_PACKING(DB, this.DBType); Row_R_PACKING rowRPacking = tRPacking.GetRPackingByPackNo(DB, packNo); PalletBase palletBase = new PalletBase(rowRPacking); T_C_SKU tCSku = new T_C_SKU(DB, this.DBType); T_R_LOT_STATUS tRLotStatus = new T_R_LOT_STATUS(DB, this.DBType); T_C_AQLTYPE tCAqlType = new T_C_AQLTYPE(DB, this.DBType); T_R_LOT_PACK tRLotPack = new T_R_LOT_PACK(DB, this.DBType); T_C_SKU_AQL tCSkuAql = new T_C_SKU_AQL(DB, this.DBType); C_SKU_AQL cSkuAql = tCSkuAql.GetSkuAql(DB, rowRPacking.SKUNO); List <C_AQLTYPE> cAqlTypeList = tCAqlType.GetAqlTypeBySkunoAndLevel(rowRPacking.SKUNO, cSkuAql.DEFAULLEVEL, DB); if (cAqlTypeList.Count == 0) { throw new Exception(MESDataObject.MESReturnMessage.GetMESReturnMessage("MSGCODE20180625165842", new string[] { })); } Row_C_SKU rCSku = tCSku.GetSku(rowRPacking.SKUNO, DB, this.DBType); Row_R_LOT_STATUS rowRLotStatus = (Row_R_LOT_STATUS)tRLotStatus.NewRow(); rowRLotStatus.ID = tRLotStatus.GetNewID(user.BU, DB, this.DBType); rowRLotStatus.LOT_NO = SNMaker.SNmaker.GetNextSN("OBALOT", DB); rowRLotStatus.SKUNO = rowRPacking.SKUNO; rowRLotStatus.AQL_TYPE = cSkuAql.AQLTYPE; rowRLotStatus.LOT_QTY = palletBase.GetSnCount(DB); rowRLotStatus.REJECT_QTY = cAqlTypeList.Where(t => t.LOT_QTY > rowRLotStatus.LOT_QTY).OrderBy(t => t.LOT_QTY).Take(1).ToList <C_AQLTYPE>()[0].REJECT_QTY; rowRLotStatus.SAMPLE_QTY = cAqlTypeList.Where(t => t.LOT_QTY > rowRLotStatus.LOT_QTY).OrderBy(t => t.LOT_QTY).Take(1).ToList <C_AQLTYPE>()[0].SAMPLE_QTY; rowRLotStatus.SAMPLE_QTY = rowRLotStatus.SAMPLE_QTY > rowRLotStatus.LOT_QTY ? rowRLotStatus.LOT_QTY : rowRLotStatus.SAMPLE_QTY; rowRLotStatus.PASS_QTY = 0; rowRLotStatus.FAIL_QTY = 0; rowRLotStatus.CLOSED_FLAG = "0"; rowRLotStatus.LOT_STATUS_FLAG = "0"; rowRLotStatus.SAMPLE_STATION = "OBA"; rowRLotStatus.AQL_LEVEL = cSkuAql.DEFAULLEVEL; rowRLotStatus.LINE = ""; rowRLotStatus.EDIT_EMP = user.EMP_NO; rowRLotStatus.EDIT_TIME = tRPacking.GetDBDateTime(DB); Row_R_LOT_PACK rowRLotPack = (Row_R_LOT_PACK)tRLotPack.NewRow(); rowRLotPack.ID = tRLotPack.GetNewID(user.BU, DB, this.DBType); rowRLotPack.LOTNO = rowRLotStatus.LOT_NO; rowRLotPack.PACKNO = packNo; rowRLotPack.EDIT_EMP = user.EMP_NO; rowRLotPack.EDIT_TIME = rowRLotStatus.EDIT_TIME; DB.ThrowSqlExeception = true; DB.ExecSQL(rowRLotStatus.GetInsertString(this.DBType)); DB.ExecSQL(rowRLotPack.GetInsertString(this.DBType)); DB.ThrowSqlExeception = false; return(rowRLotStatus.GetDataObject()); }
/// <summary> /// 檢查Pack狀態是否可以入OBA /// </summary> /// <param name="Station"></param> /// <param name="Input"></param> /// <param name="Paras"></param> public static void CheckPackStatusInOba(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras) { DisplayOutPut Dis_LotNo = Station.DisplayOutput.Find(t => t.Name == "LOTNO"); DisplayOutPut Dis_SkuNo = Station.DisplayOutput.Find(t => t.Name == "SKUNO"); DisplayOutPut Dis_Ver = Station.DisplayOutput.Find(t => t.Name == "VER"); MESStationInput Level = Station.Inputs.Find(t => t.DisplayName == "AQLLEVEL"); MESStationSession packSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); #region 用於界面上顯示的批次信息 R_LOT_STATUS rLotStatus = new R_LOT_STATUS(); List <R_LOT_PACK> rLotPackList = new List <R_LOT_PACK>(); List <string> cAqlLevel = new List <string>(); #endregion T_R_PACKING t_r_packing = new T_R_PACKING(Station.SFCDB, Station.DBType); //add by fgg 2018.6.28 卡棧板是否關閉,避免棧板還沒有關閉就拿去抽檢OBA,導致抽檢總數異常,進而導致OBA抽檢數量不對 if (!t_r_packing.CheckCloseByPackno(packSession.Value.ToString(), Station.SFCDB)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180611104338", new string[] { packSession.Value.ToString() })); } LotNo LotNo = new LotNo(Station.DBType); T_R_LOT_PACK tRLotPack = new T_R_LOT_PACK(Station.SFCDB, Station.DBType); rLotPackList = tRLotPack.GetRLotPackWithWaitClose(Station.SFCDB, packSession.Value.ToString()); List <R_LOT_STATUS> rLotStatusList = tRLotPack.GetRLotStatusWithWaitClose(Station.SFCDB, packSession.Value.ToString()); rLotStatus = rLotStatusList.Find(t => t.CLOSED_FLAG == "1"); if (rLotStatus != null) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180526181007", new string[] { packSession.Value.ToString() })); } else { rLotStatus = rLotStatusList.Find(t => t.CLOSED_FLAG == "0"); } if (Dis_LotNo.Value.Equals("")) { #region 當前Lot為空=>檢查當前Pack無有效LOT?新建LOT:加載LOT; if (rLotPackList.Count == 0) { rLotStatus = LotNo.CreateLotByPackno(Station.LoginUser, packSession.Value.ToString(), Station.SFCDB); rLotPackList.Add( new R_LOT_PACK() { LOTNO = rLotStatus.LOT_NO, PACKNO = packSession.Value.ToString() }); } else { rLotStatus = rLotStatusList.Find(t => t.CLOSED_FLAG == "0"); } #endregion } else { #region 當前Lot不為空=>PackNo與當前頁面LOT的機種版本是否一致?ReLoad LOT信息:Throw e; T_R_PACKING tRPacking = new T_R_PACKING(Station.SFCDB, Station.DBType); Row_R_PACKING rowRPacking = tRPacking.GetRPackingByPackNo(Station.SFCDB, packSession.Value.ToString()); if (!rowRPacking.SKUNO.Equals(Dis_SkuNo.Value.ToString())) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180526185434", new string[] { packSession.Value.ToString() })); } if (rLotPackList.Count == 0) { rLotStatus = LotNo.ObaInLotByPackno(Station.User, rLotStatus, packSession.Value.ToString(), Level.Value.ToString(), Station.SFCDB); rLotPackList.Add(new R_LOT_PACK() { LOTNO = rLotStatus.LOT_NO, PACKNO = packSession.Value.ToString() }); } else { throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180526185618", new string[] { packSession.Value.ToString(), rLotStatus.LOT_NO })); } #endregion } #region 加載AQL等級 T_C_AQLTYPE tCAqlType = new T_C_AQLTYPE(Station.SFCDB, Station.DBType); cAqlLevel = tCAqlType.GetAqlLevelByType(rLotStatus.AQL_TYPE, Station.SFCDB); T_C_SKU_AQL tCSkuAql = new T_C_SKU_AQL(Station.SFCDB, Station.DBType); C_SKU_AQL cSkuAql = tCSkuAql.GetSkuAql(Station.SFCDB, rLotStatus.SKUNO); #endregion #region 加載界面信息 MESStationSession lotNoSession = new MESStationSession() { MESDataType = Paras[2].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[2].SESSION_KEY, ResetInput = Input }; MESStationSession skuNoSession = new MESStationSession() { MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[3].SESSION_KEY, ResetInput = Input }; MESStationSession aqlSession = new MESStationSession() { MESDataType = Paras[4].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[4].SESSION_KEY, ResetInput = Input }; MESStationSession lotQtySession = new MESStationSession() { MESDataType = Paras[5].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[5].SESSION_KEY, ResetInput = Input }; MESStationSession sampleQtySession = new MESStationSession() { MESDataType = Paras[6].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[6].SESSION_KEY, ResetInput = Input }; MESStationSession RejectQtySession = new MESStationSession() { MESDataType = Paras[7].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[7].SESSION_KEY, ResetInput = Input }; Station.StationSession.Clear(); Station.StationSession.Add(lotNoSession); Station.StationSession.Add(skuNoSession); Station.StationSession.Add(aqlSession); Station.StationSession.Add(lotQtySession); Station.StationSession.Add(sampleQtySession); Station.StationSession.Add(RejectQtySession); lotNoSession.Value = rLotStatus.LOT_NO; skuNoSession.Value = rLotStatus.SKUNO; aqlSession.Value = rLotStatus.AQL_TYPE; lotQtySession.Value = rLotStatus.LOT_QTY; sampleQtySession.Value = rLotStatus.SAMPLE_QTY; RejectQtySession.Value = rLotStatus.REJECT_QTY; MESStationInput s = Station.Inputs.Find(t => t.DisplayName == Paras[1].SESSION_TYPE); s.DataForUse.Clear(); foreach (var VARIABLE in rLotPackList) { s.DataForUse.Add(VARIABLE.PACKNO); } MESStationInput l = Station.Inputs.Find(t => t.DisplayName == "AQLLEVEL"); l.DataForUse.Clear(); foreach (string VARIABLE in cAqlLevel) { l.DataForUse.Add(VARIABLE); } //設置默認等級 l.Value = cSkuAql.DEFAULLEVEL; #endregion }