Esempio n. 1
0
        /// <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());
        }
Esempio n. 2
0
        public static void SNInputToLot(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            OleExec DB          = Station.SFCDB;
            string  strSql      = "";
            var     LOT_session = Station.StationSession.Find(t => t.MESDataType == "LOTNO" && t.SessionKey == "1");

            if (LOT_session == null)
            {
                LOT_session = new MESStationSession()
                {
                    MESDataType = "LOTNO", SessionKey = "1"
                };
                Station.StationSession.Add(LOT_session);
            }
            var LOT_COUNT_session = Station.StationSession.Find(t => t.MESDataType == "LOT_COUNT" && t.SessionKey == "1");

            if (LOT_COUNT_session == null)
            {
                LOT_COUNT_session = new MESStationSession()
                {
                    MESDataType = "LOT_COUNT", SessionKey = "1", Value = 0
                };
                Station.StationSession.Add(LOT_COUNT_session);
            }

            var SN_Session = Station.StationSession.Find(t => t.MESDataType == "SN" && t.SessionKey == "1");

            SN sn = (SN)SN_Session.Value;

            if (sn.CompletedFlag != "1")
            {
                throw new Exception($@"'{sn.SerialNo}'  is not  Completed");
            }
            string           lotno = "";//LOT_session.Value.ToString();
            T_R_LOT_STATUS   TRLS  = new T_R_LOT_STATUS(DB, DB_TYPE_ENUM.Oracle);
            Row_R_LOT_STATUS RRLS  = (Row_R_LOT_STATUS)TRLS.NewRow();

            if (LOT_session.Value == null)
            {
                RRLS.ID              = TRLS.GetNewID(Station.BU, DB);
                RRLS.SKUNO           = sn.SkuNo;
                RRLS.LOT_QTY         = 0;
                RRLS.LOT_STATUS_FLAG = "0";
                RRLS.SAMPLE_STATION  = Station.DisplayName;
                RRLS.CLOSED_FLAG     = "0";
                RRLS.LOT_NO          = SNMaker.SNmaker.GetNextSN("HWDLOT", DB);
                RRLS.EDIT_TIME       = DateTime.Now;
                RRLS.EDIT_EMP        = Station.LoginUser.EMP_NO;
                DB.ExecSQL(RRLS.GetInsertString(DB_TYPE_ENUM.Oracle));
                RRLS.AcceptChange();
                lotno = RRLS.LOT_NO;
            }
            else
            {
                lotno  = LOT_session.Value.ToString();
                strSql = $@"select * from R_LOT_STATUS where lot_no = '{lotno}'";
                var d = DB.RunSelect(strSql);
                RRLS.loadData(d.Tables[0].Rows[0]);
            }
            LOT_session.Value = lotno;
            if (RRLS.CLOSED_FLAG == "1")
            {
                throw new Exception($@"LotNo '{RRLS.LOT_NO}' is closed");
            }


            strSql = $@"select l.lot_no from r_lot_status l inner join r_lot_detail d on 
l.lot_no = d.lot_id  where sn = '{sn.SerialNo}' and l.lot_no like 'LOT-%' and d.status = '0'";

            var data = DB.RunSelect(strSql);

            if (data.Tables[0].Rows.Count > 0)
            {
                throw new Exception($@"'{sn.SerialNo}'  is in lot'{data.Tables[0].Rows[0]["lot_no"].ToString()}'");
            }
            if (sn.SkuNo != RRLS.SKUNO)
            {
                throw new Exception($@"'{sn.SerialNo}': '{sn.SkuNo}'  but lot is '{RRLS.SKUNO}'");
            }

            T_R_LOT_DETAIL TRLD = new T_R_LOT_DETAIL(DB, DB_TYPE_ENUM.Oracle);
            R_LOT_DETAIL   R    = new R_LOT_DETAIL();

            R.ID        = TRLD.GetNewID(Station.BU, DB);
            R.LOT_ID    = RRLS.LOT_NO;
            R.SN        = sn.SerialNo;
            R.STATUS    = "0";
            R.EDIT_EMP  = Station.LoginUser.EMP_NO;
            R.EDIT_TIME = DateTime.Now;
            DB.ORM.Insertable <R_LOT_DETAIL>(R).ExecuteCommand();

            T_R_SN TRS = new T_R_SN(DB, DB_TYPE_ENUM.Oracle);

            TRS.RecordPassStationDetail(sn.SerialNo, Station.Line, Station.StationName, Station.DisplayName, Station.BU, DB);

            int count = DB.ORM.Queryable <R_LOT_DETAIL>().Where(t => t.LOT_ID == R.LOT_ID).Count();

            RRLS.LOT_QTY   = count;
            RRLS.EDIT_TIME = DateTime.Now;
            RRLS.EDIT_EMP  = Station.LoginUser.EMP_NO;
            DB.ExecSQL(RRLS.GetUpdateString(DB_TYPE_ENUM.Oracle));
            RRLS.AcceptChange();
            LOT_COUNT_session.Value = count;
            Station.NextInput       = Station.Inputs[1];
        }