Beispiel #1
0
        /*Modify by LLF 2018-02-22
         * public void Init(string StrLotNo, MESDBHelper.OleExec SFCDB, MESDataObject.DB_TYPE_ENUM _DBType)
         * {
         *  string ColoumName = "lot_no";
         *  DBType = _DBType;
         *  T_R_LOT_STATUS TRWB = new T_R_LOT_STATUS(SFCDB, DBType);
         *  T_R_LOT_DETAIL TWC = new T_R_LOT_DETAIL(SFCDB, DBType);
         *  RLotNo = TRWB.GetByInput(StrLotNo, ColoumName, SFCDB);
         *  SLot = RLotNo.GetDataObject();
         *  Rlotdetail = TWC.GetByLotID(SLot.ID, SFCDB);
         *  Slotdetail = Rlotdetail.GetDataObject();
         * }
         *
         * public void Init(string StrLotNo, MESDBHelper.OleExec SFCDB)
         * {
         *  Init(StrLotNo, SFCDB, DBType);
         * }*/

        public void Init(string StrLotNo, string StrSN, MESDBHelper.OleExec SFCDB, MESDataObject.DB_TYPE_ENUM _DBType)
        {
            string ColoumName = "lot_no";

            DBType = _DBType;
            T_R_LOT_STATUS TRWB = new T_R_LOT_STATUS(SFCDB, DBType);
            T_R_LOT_DETAIL TWC  = new T_R_LOT_DETAIL(SFCDB, DBType);

            RLotNo     = TRWB.GetByInput(StrLotNo, ColoumName, SFCDB);
            SLot       = RLotNo.GetDataObject();
            Rlotdetail = TWC.GetByLotID(SLot.ID, StrSN, SFCDB);
            Slotdetail = Rlotdetail.GetDataObject();
        }
Beispiel #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];
        }