Exemple #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());
        }
Exemple #2
0
        public static void CheckPackNoAndDnLineStatus(MESPubLab.MESStation.MESStationBase Station,
                                                      MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            string packNo = Input.Value.ToString(),
                   dnNo   = Station.DisplayOutput.Find(t => t.Name == "DN_NO").Value.ToString(),
                   dnLine = Station.DisplayOutput.Find(t => t.Name == "DN_ITEM").Value.ToString(),
                   skuNo  = Station.DisplayOutput.Find(t => t.Name == "SKU_NO").Value.ToString();

            if (dnNo.Length == 0 && dnLine.Length == 0)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180801113040"));
            }
            var rPacking = new PalletBase(packNo, Station.SFCDB);

            if (rPacking.GetCount(Station.SFCDB) != 1)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180602102010", new string[] { packNo }));
            }
            if (!rPacking.DATA.SKUNO.Equals(skuNo))
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180801085546", new string[] { packNo, rPacking.DATA.SKUNO, dnNo, dnLine, skuNo }));
            }
            var rDnStatus = Station.SFCDB.ORM.Queryable <R_DN_STATUS>()
                            .Where(x => x.DN_NO == dnNo && x.DN_LINE == dnLine && x.DN_FLAG == "0").ToList();

            if (rDnStatus.Count != 1)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180731133647", new string[] { dnNo, dnLine }));
            }
            var rShipDetail = Station.SFCDB.ORM.Queryable <R_SHIP_DETAIL>()
                              .Where(x => x.DN_NO == dnNo && x.DN_LINE == dnLine).ToList();
            var packSnQty = rPacking.GetSnCount(Station.SFCDB);

            if (packSnQty > rDnStatus.FirstOrDefault().QTY - rShipDetail.Count)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180801091520", new string[] { packNo, packSnQty.ToString(), rDnStatus.FirstOrDefault().QTY.ToString() }));
            }
            rShipDetail = Station.SFCDB.ORM.Queryable <R_SHIP_DETAIL, R_PACKING, R_SN_PACKING>((rsd, rp, rsp) =>
                                                                                               rsd.ID == rsp.SN_ID && rp.ID == rsp.PACK_ID && rp.PARENT_PACK_ID == rPacking.DATA.ID).Select((rsd, rp, rsp) => rsd).ToList();
            if (rShipDetail.Count > 0)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180802105858", new string[] { packNo }));
            }
        }
Exemple #3
0
        /// <summary>
        /// OBA工站InLot,返回LOT信息
        /// </summary>
        /// <param name="user"></param>
        /// <param name="packNo"></param>
        /// <param name="DB"></param>
        public R_LOT_STATUS ObaInLotByPackno(User user, R_LOT_STATUS rLotStatus, string packNo, string AqlLevel, 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_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);

            List <C_AQLTYPE> cAqlTypeList  = tCAqlType.GetAqlTypeBySkunoAndLevel(rowRPacking.SKUNO, AqlLevel, DB);
            Row_R_LOT_STATUS rowRLotStatus = (Row_R_LOT_STATUS)tRLotStatus.NewRow();

            rowRLotStatus.ID              = rLotStatus.ID;
            rowRLotStatus.LOT_NO          = rLotStatus.LOT_NO;
            rowRLotStatus.SKUNO           = rLotStatus.SKUNO;
            rowRLotStatus.AQL_TYPE        = rLotStatus.AQL_TYPE;
            rowRLotStatus.LOT_QTY         = rLotStatus.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        = rLotStatus.PASS_QTY;
            rowRLotStatus.FAIL_QTY        = rLotStatus.FAIL_QTY;
            rowRLotStatus.CLOSED_FLAG     = rLotStatus.CLOSED_FLAG;
            rowRLotStatus.LOT_STATUS_FLAG = rLotStatus.LOT_STATUS_FLAG;
            rowRLotStatus.SAMPLE_STATION  = rLotStatus.SAMPLE_STATION;
            rowRLotStatus.LINE            = rLotStatus.LINE;
            rowRLotStatus.AQL_LEVEL       = AqlLevel;
            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.GetUpdateString(this.DBType) + ";" + rowRLotPack.GetInsertString(this.DBType));
            DB.ThrowSqlExeception = false;
            return(rowRLotStatus.GetDataObject());
        }
Exemple #4
0
        public static void CloseCartionAndPalletAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec SFCDB = Station.SFCDB;
            string  Run   = "";

            try
            {
                Run = (Station.StationSession.Find(T => T.MESDataType == Paras[0].SESSION_TYPE && T.SessionKey == Paras[0].SESSION_KEY).Value).ToString();
                if (Run.ToUpper() == "FALSE")
                {
                    return;
                }
            }
            catch
            {
            }

            MESStationSession sessionCarton = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionCarton == null)
            {
                throw new System.Exception("sessionCartion miss ");
            }

            MESStationSession sessionPallet = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionPallet == null)
            {
                throw new System.Exception("sessionPallet miss ");
            }
            MESStationSession sessionPrintPL = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_PL" && t.SessionKey == "1");

            if (sessionPrintPL == null)
            {
                sessionPrintPL = new MESStationSession()
                {
                    MESDataType = "ISPRINT_PL", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintPL);
            }
            sessionPrintPL.Value = "FALSE";
            MESStationSession sessionPrintCTN = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_CTN" && t.SessionKey == "1");

            if (sessionPrintCTN == null)
            {
                sessionPrintCTN = new MESStationSession()
                {
                    MESDataType = "ISPRINT_CTN", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintCTN);
            }
            sessionPrintCTN.Value = "FALSE";
            CartionBase cartion = (CartionBase)sessionCarton.Value;
            PalletBase  Pallet  = (PalletBase)sessionPallet.Value;

            cartion.DATA.CLOSED_FLAG = "1";
            cartion.DATA.EDIT_TIME   = DateTime.Now;
            cartion.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
            Station.SFCDB.ExecSQL(cartion.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));

            Pallet.DATA.CLOSED_FLAG = "1";
            Pallet.DATA.EDIT_TIME   = DateTime.Now;
            Pallet.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
            Station.SFCDB.ExecSQL(cartion.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));
            sessionPrintPL.Value  = "TRUE";
            sessionPrintCTN.Value = "TRUE";

            MESStationSession CTNPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_CTN" && T.SessionKey == "1");

            if (CTNPrintSession == null)
            {
                CTNPrintSession = new MESStationSession()
                {
                    MESDataType = "PRINT_CTN", SessionKey = "1"
                };
                Station.StationSession.Add(CTNPrintSession);
            }
            CTNPrintSession.Value = cartion.DATA.PACK_NO;

            MESStationSession PlPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_PL" && T.SessionKey == "1");

            if (PlPrintSession == null)
            {
                PlPrintSession = new MESStationSession()
                {
                    MESDataType = "PRINT_PL", SessionKey = "1"
                };
                Station.StationSession.Add(PlPrintSession);
            }
            PlPrintSession.Value = Pallet.DATA.PACK_NO;


            Station.StationSession.Remove(sessionCarton);
            Station.StationSession.Remove(sessionPallet);
        }
Exemple #5
0
        public static void CartionAndPalletAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec SFCDB = Station.SFCDB;
            string  Run   = "";

            try
            {
                Run = (Station.StationSession.Find(T => T.MESDataType == Paras[0].SESSION_TYPE && T.SessionKey == Paras[0].SESSION_KEY).Value).ToString();
                if (Run.ToUpper() == "FALSE")
                {
                    return;
                }
            }
            catch
            {
            }
            MESStationSession sessionSN = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionSN == null)
            {
                throw new System.Exception("sessionSN miss ");
            }

            MESStationSession sessionCartion = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionCartion == null)
            {
                throw new System.Exception("sessionCartion miss ");
            }

            MESStationSession sessionPallet = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (sessionPallet == null)
            {
                throw new System.Exception("sessionPallet miss ");
            }

            MESStationSession sessionPrintPL = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_PL" && t.SessionKey == "1");

            if (sessionPrintPL == null)
            {
                sessionPrintPL = new MESStationSession()
                {
                    MESDataType = "ISPRINT_PL", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintPL);
            }
            sessionPrintPL.Value = "FALSE";
            MESStationSession sessionPrintCTN = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_CTN" && t.SessionKey == "1");

            if (sessionPrintCTN == null)
            {
                sessionPrintCTN = new MESStationSession()
                {
                    MESDataType = "ISPRINT_CTN", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintCTN);
            }
            sessionPrintCTN.Value = "FALSE";

            SN SN = (SN)sessionSN.Value;

            if (SN.isPacked(Station.SFCDB))
            {
                throw new System.Exception($@"{SN.SerialNo} is packed!");
            }

            CartionBase cartion = (CartionBase)sessionCartion.Value;
            PalletBase  Pallet  = (PalletBase)sessionPallet.Value;



            cartion.Add(SN, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);

            if (cartion.DATA.MAX_QTY <= cartion.GetCount(Station.SFCDB))
            {
                sessionPrintCTN.Value = "TRUE";
                //設置打印變量
                MESStationSession CTNPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_CTN" && T.SessionKey == "1");
                if (CTNPrintSession == null)
                {
                    CTNPrintSession = new MESStationSession()
                    {
                        MESDataType = "PRINT_CTN", SessionKey = "1"
                    };
                    Station.StationSession.Add(CTNPrintSession);
                }
                CTNPrintSession.Value = cartion.DATA.PACK_NO;
                T_C_PACKING      TCP           = new T_C_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                List <C_PACKING> PackConfigs   = TCP.GetPackingBySku(SN.SkuNo, Station.SFCDB);
                C_PACKING        CartionConfig = PackConfigs.Find(T => T.PACK_TYPE == "CARTION");
                C_PACKING        PalletConfig  = PackConfigs.Find(T => T.PACK_TYPE == "PALLET");
                if (CartionConfig == null)
                {
                    throw new Exception("Can't find CartionConfig");
                }
                if (PalletConfig == null)
                {
                    throw new Exception("Can't find PalletConfig");
                }
                if (Pallet.DATA.MAX_QTY <= Pallet.GetCount(Station.SFCDB))
                {
                    sessionPrintPL.Value = "TRUE";
                    //設置打印變量
                    MESStationSession PlPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_PL" && T.SessionKey == "1");
                    if (PlPrintSession == null)
                    {
                        PlPrintSession = new MESStationSession()
                        {
                            MESDataType = "PRINT_PL", SessionKey = "1"
                        };
                        Station.StationSession.Add(PlPrintSession);
                    }
                    PlPrintSession.Value = Pallet.DATA.PACK_NO;

                    Pallet.DATA.CLOSED_FLAG = "1";
                    Pallet.DATA.EDIT_TIME   = DateTime.Now;
                    Pallet.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
                    Station.SFCDB.ExecSQL(Pallet.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));

                    Pallet.DATA = PackingBase.GetNewPacking(PalletConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
                }
                cartion.DATA.CLOSED_FLAG = "1";
                cartion.DATA.EDIT_TIME   = DateTime.Now;
                cartion.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
                Station.SFCDB.ExecSQL(cartion.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));
                cartion.DATA = PackingBase.GetNewPacking(CartionConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);

                Pallet.Add(cartion, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            sessionCartion.Value = cartion;
            sessionPallet.Value  = Pallet;

            cartion.DATA.AcceptChange();
            Pallet.DATA.AcceptChange();
        }