Exemple #1
0
        public static void loaderBox(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count == 0)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            MESStationSession PackNoSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);


            T_R_PACKING t_R_PACKING = new T_R_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);


            List <R_PACKING> list = new List <R_PACKING>();

            if (Input.Value != null)
            {
                list = t_R_PACKING.GetListPackByPackno((string)Input.Value, Station.SFCDB);
                if (list.Count > 0)
                {
                    PackNoSession = new MESStationSession()
                    {
                        MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input, Value = list[0]
                    };
                }

                Station.StationSession.Add(PackNoSession);
            }
        }
Exemple #2
0
        /// <summary>
        /// 棧板或卡通是否存在
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void CheckPackingIsExist(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 1)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057", new string[] { }));
            }

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

            if (sessionPackObject == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }
            if (sessionPackObject.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }

            T_R_PACKING t_r_packing = new T_R_PACKING(Station.SFCDB, Station.DBType);

            if (!t_r_packing.PackNoIsExist(sessionPackObject.Value.ToString(), Station.SFCDB))
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613093329", new string[] { sessionPackObject.Value.ToString() }));
            }
        }
Exemple #3
0
        public void startPackno(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            //通过工单的数量和包规来生成箱号

            OleExec   Sfcdb     = this.DBPools["SFCDB"].Borrow();
            string    packType  = Data["packType"].ToString();
            string    wo        = Data["wo"].ToString();
            WorkOrder workorder = new WorkOrder();

            workorder.Init(wo, Sfcdb);

            T_C_PACKING t_C_PACKING = new T_C_PACKING(Sfcdb, DBTYPE);
            C_PACKING   c_PACKING   = t_C_PACKING.GetPackingBySkuAndType(workorder.SkuNO, packType, Sfcdb);
            double?     qty         = c_PACKING.MAX_QTY;

            int         packs       = (int)(workorder.WORKORDER_QTY / qty);
            string      ruleName    = c_PACKING.SN_RULE;
            T_R_PACKING t_r_packing = new T_R_PACKING(Sfcdb, DBTYPE);

            int remainQty = 0;

            if (packs * qty < workorder.WORKORDER_QTY)
            {
                remainQty = (int)(workorder.WORKORDER_QTY - packs * qty);
                packs     = packs + 1;
            }
            for (int i = 0; i < packs; i++)
            {
                string nextpackno = SNmaker.GetNextSN(ruleName, Sfcdb);
                System.Console.WriteLine(nextpackno);
                Row_R_PACKING row_r_packing = (Row_R_PACKING)t_r_packing.NewRow();

                row_r_packing.IP          = this.IP;
                row_r_packing.STATION     = "STARTPARTNO";
                row_r_packing.LINE        = "LINE0";
                row_r_packing.EDIT_EMP    = this.LoginUser.EMP_NO;
                row_r_packing.EDIT_TIME   = DateTime.Now;
                row_r_packing.CREATE_TIME = DateTime.Now;
                row_r_packing.CLOSED_FLAG = "0";
                row_r_packing.QTY         = 0;
                if (packs == i && remainQty > 0)
                {
                    row_r_packing.MAX_QTY = remainQty;
                }
                else
                {
                    row_r_packing.MAX_QTY = qty;
                }
                row_r_packing.SKUNO          = workorder.SkuNO;
                row_r_packing.PARENT_PACK_ID = "";
                row_r_packing.PACK_TYPE      = packType;
                row_r_packing.PACK_NO        = nextpackno;
                row_r_packing.ID             = t_r_packing.GetNewID(this.BU, Sfcdb);

                Sfcdb.ExecSQL(row_r_packing.GetInsertString(DBTYPE));
            }


            StationReturn.Status = StationReturnStatusValue.Pass;
        }
Exemple #4
0
        /// <summary>
        /// 打開卡通或棧板
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void OpenPackingAction(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 1)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057", new string[] { }));
            }

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

            if (sessionPackObject == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }
            if (sessionPackObject.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }
            try
            {
                string result = "";
                LogicObject.Packing packObject  = (LogicObject.Packing)sessionPackObject.Value;
                T_R_PACKING         t_r_packing = new T_R_PACKING(Station.SFCDB, Station.DBType);
                result = t_r_packing.UpdateCloseFlagByPackID(packObject.PackID, "0", Station.SFCDB);
                if (Convert.ToInt32(result) == 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154414", new string[] { packObject.PackNo }));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #5
0
        public void DataLoad(string packNo, string bu, OleExec sfcdb, DB_TYPE_ENUM DBType)
        {
            List <string>  itemList       = new List <string>();
            T_C_SKU        t_c_sku        = new T_C_SKU(sfcdb, DBType);
            T_R_PACKING    t_r_packing    = new T_R_PACKING(sfcdb, DBType);
            T_R_SN_PACKING t_r_sn_packing = new T_R_SN_PACKING(sfcdb, DBType);
            T_R_SN         t_r_sn         = new T_R_SN(sfcdb, DBType);
            T_C_PACKING    t_c_packing    = new T_C_PACKING(sfcdb, DBType);
            R_PACKING      packing        = new R_PACKING();
            C_SKU          sku            = new C_SKU();
            Packing        packObject     = new Packing();
            C_PACKING      c_packing      = new C_PACKING();

            packing = t_r_packing.GetRPackingByPackNo(sfcdb, packNo).GetDataObject();
            sku     = t_c_sku.GetSku(packing.SKUNO, sfcdb, DBType).GetDataObject();
            if (packing.PACK_TYPE == LogicObject.PackType.PALLET.ToString().ToUpper())
            {
                c_packing = t_c_packing.GetPackingBySkuAndType(sku.SKUNO, LogicObject.PackType.CARTON.ToString().ToUpper(), sfcdb);
                if (c_packing.MAX_QTY == 1 && bu.ToUpper().Equals("VERTIV"))
                {
                    //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN
                    itemList = t_r_packing.GetPakcingSNList(packing.ID, sfcdb);
                }
                else
                {
                    List <R_PACKING> packingList = t_r_packing.GetListPackByParentPackId(packing.ID, sfcdb);
                    foreach (R_PACKING pack in packingList)
                    {
                        itemList.Add(pack.PACK_NO);
                    }
                }
            }
            else if (packing.PACK_TYPE == LogicObject.PackType.CARTON.ToString().ToUpper())
            {
                List <Row_R_SN_PACKING> snPackingList = t_r_sn_packing.GetPackItem(packing.ID, sfcdb);
                foreach (Row_R_SN_PACKING sn in snPackingList)
                {
                    itemList.Add(t_r_sn.GetById(sn.SN_ID, sfcdb).SN);
                }
            }
            this.PackID       = packing.ID;
            this.PackNo       = packing.PACK_NO;
            this.PackType     = packing.PACK_TYPE;
            this.ParentPackID = packing.PARENT_PACK_ID;
            this.Skuno        = packing.SKUNO;
            this.SkunoVer     = sku.VERSION;
            this.MaxQty       = packing.MAX_QTY;
            this.Qty          = packing.QTY;
            this.ClosedFlag   = packing.CLOSED_FLAG;
            this.CreatTime    = packing.CREATE_TIME;
            this.EditTime     = packing.EDIT_TIME;
            this.EditEmp      = packing.EDIT_EMP;
            this.Line         = packing.LINE;
            this.Station      = packing.STATION;
            this.IP           = packing.IP;
            this.PackList     = itemList;
        }
Exemple #6
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 #7
0
        public PalletBase(string PLNO, OleExec DB)
        {
            T_R_PACKING   TRP  = new T_R_PACKING(DB, DB_TYPE_ENUM.Oracle);
            Row_R_PACKING data = TRP.GetRPackingByPackNo(DB, PLNO);

            if (data.PACK_TYPE != "PALLET")
            {
                throw new Exception($@"{PLNO} in not Pallet");
            }
            DATA = data;
        }
Exemple #8
0
        /// <summary>
        /// 檢查棧板或卡通中SN是否已出貨
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void CheckSnIsShippedByCartonOrPallet(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 1)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057", new string[] { }));
            }

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

            if (sessionPackObject == null || sessionPackObject.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }

            R_PACKING packObject = Station.SFCDB.ORM.Queryable <R_PACKING>().Where(p => p.PACK_NO == sessionPackObject.Value.ToString()).ToList().FirstOrDefault();

            if (packObject != null)
            {
                List <R_SN> snList      = new List <R_SN>();
                T_R_PACKING t_r_packing = new T_R_PACKING(Station.SFCDB, Station.DBType);
                string      strSnList   = "";
                if (packObject.PACK_TYPE == LogicObject.PackType.PALLET.ToString())
                {
                    snList = t_r_packing.GetSnListByPalletID(packObject.ID, Station.SFCDB);
                }
                else if (packObject.PACK_TYPE == LogicObject.PackType.CARTON.ToString())
                {
                    snList = t_r_packing.GetSnListByCartonID(packObject.ID, Station.SFCDB);
                }
                else
                {
                    throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180529094259", new string[] { }));
                }

                foreach (R_SN sn in snList)
                {
                    strSnList += sn.SN + ",";
                }
                if (snList.Count > 0 && packObject.PACK_TYPE == LogicObject.PackType.PALLET.ToString())
                {
                    throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180808142945", new string[] { packObject.PACK_NO, snList.Count().ToString(), strSnList }));
                }
                if (snList.Count > 0 && packObject.PACK_TYPE == LogicObject.PackType.CARTON.ToString())
                {
                    throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180808141806", new string[] { packObject.PACK_NO, snList.Count().ToString(), strSnList }));
                }
            }
            else
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613093329", new string[] { sessionPackObject.Value.ToString() }));
            }
        }
Exemple #9
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 #10
0
        public static Row_R_PACKING GetNewPacking(C_PACKING config, string line, string Station, string IP, string BU, string User, OleExec DB)
        {
            T_R_PACKING   TRP = new T_R_PACKING(DB, DB_TYPE_ENUM.Oracle);
            Row_R_PACKING RRP = (Row_R_PACKING)TRP.NewRow();

            RRP.PACK_NO        = SNMaker.SNmaker.GetNextSN(config.SN_RULE, DB);
            RRP.PACK_TYPE      = config.PACK_TYPE;
            RRP.PARENT_PACK_ID = "";
            RRP.SKUNO          = config.SKUNO;
            RRP.MAX_QTY        = config.MAX_QTY;
            RRP.QTY            = 0;
            RRP.CLOSED_FLAG    = "0";
            RRP.LINE           = line;
            RRP.STATION        = Station;
            RRP.ID             = TRP.GetNewID(BU, DB);
            RRP.IP             = IP;
            DB.ExecSQL(RRP.GetInsertString(DB_TYPE_ENUM.Oracle));
            RRP.AcceptChange();
            return(RRP);
        }
Exemple #11
0
        /// <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
        }
        public static void LoadPackingBySkuStation(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            MESStationSession sessionSKU = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (sessionSKU == null)
            {
                throw new Exception("Can't load session SKU");
            }
            LogicObject.SKU   SKU           = (LogicObject.SKU)sessionSKU.Value;
            MESStationSession sessionCarton = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionCarton == null)
            {
                sessionCarton = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, SessionKey = Paras[1].SESSION_KEY
                };
                Station.StationSession.Add(sessionCarton);
            }

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

            if (sessionPallet == null)
            {
                sessionPallet = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, SessionKey = Paras[2].SESSION_KEY
                };
                Station.StationSession.Add(sessionPallet);
            }

            T_C_PACKING      TCP           = new T_C_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            List <C_PACKING> PackConfigs   = TCP.GetPackingBySku(SKU.SkuNo, Station.SFCDB);
            C_PACKING        CartionConfig = PackConfigs.Find(T => T.PACK_TYPE == "CARTON");
            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");
            }

            T_R_PACKING   TRP        = new T_R_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            Row_R_PACKING RowCartion = null;

            try
            {
                RowCartion = (Row_R_PACKING)TRP.GetObjBySelect($@"select * from R_PACKING where SKUNO='{SKU.SkuNo}' 
and PACK_TYPE='{CartionConfig.PACK_TYPE}' 
and LINE='{Station.Line}' 
and STATION='{Station.StationName}' 
and IP='{Station.IP}' and CLOSED_FLAG='0'", Station.SFCDB, DB_TYPE_ENUM.Oracle);
            }
            catch
            {
                RowCartion = Packing.PackingBase.GetNewPacking(CartionConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }

            Row_R_PACKING RowPallet = null;

            try
            {
                RowPallet = (Row_R_PACKING)TRP.GetObjBySelect($@"select * from R_PACKING where SKUNO='{SKU.SkuNo}' 
and PACK_TYPE='{PalletConfig.PACK_TYPE}' 
and LINE='{Station.Line}' 
and STATION='{Station.StationName}' 
and IP='{Station.IP}' and CLOSED_FLAG='0'", Station.SFCDB, DB_TYPE_ENUM.Oracle);
            }
            catch
            {
                RowPallet = Packing.PackingBase.GetNewPacking(PalletConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            Packing.CartionBase Cartion = new Packing.CartionBase(RowCartion);
            Packing.PalletBase  Pallet  = new Packing.PalletBase(RowPallet);
            if (Cartion.DATA.PARENT_PACK_ID == null || Cartion.DATA.PARENT_PACK_ID == "")
            {
                Pallet.Add(Cartion, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }

            sessionCarton.Value = Cartion;
            sessionPallet.Value = Pallet;
        }
Exemple #13
0
        /// <summary>
        /// 移棧板或卡通內的數據
        /// add by fgg 2018.06.08
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void MovePackingSessionValue(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 8)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057", new string[] { }));
            }

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

            if (sessionOne == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }
            if (sessionOne.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }

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

            if (sessionTwo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }
            if (sessionTwo.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }

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

            if (sessionValue == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }
            if (sessionValue.Value.ToString() == "")
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }

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

            if (sessionItemListOne == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY }));
            }

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

            if (sessionItemListTwo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[4].SESSION_TYPE + Paras[4].SESSION_KEY }));
            }

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

            if (sessionCountOne == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[5].SESSION_TYPE + Paras[5].SESSION_KEY }));
            }

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

            if (sessionCountTwo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[6].SESSION_TYPE + Paras[6].SESSION_KEY }));
            }

            R_Station_Action_Para moveFlag = Paras[7];

            bool moveToRight;

            if (moveFlag.VALUE.ToString().Equals("0"))
            {
                moveToRight = true;
            }
            else if (moveFlag.VALUE.ToString().Equals("1"))
            {
                moveToRight = false;
            }
            else
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[7].SESSION_TYPE + Paras[7].SESSION_KEY }));
            }

            try
            {
                LogicObject.Packing packOne        = (LogicObject.Packing)sessionOne.Value;;
                LogicObject.Packing packTwo        = (LogicObject.Packing)sessionTwo.Value;;
                string              result         = "";
                T_R_PACKING         t_r_packing    = new T_R_PACKING(Station.SFCDB, Station.DBType);
                T_R_SN_PACKING      t_r_sn_packing = new T_R_SN_PACKING(Station.SFCDB, Station.DBType);
                T_R_SN              t_r_sn         = new T_R_SN(Station.SFCDB, Station.DBType);
                T_R_MOVE_LIST       t_r_move_list  = new T_R_MOVE_LIST(Station.SFCDB, Station.DBType);
                T_C_PACKING         t_c_packing    = new T_C_PACKING(Station.SFCDB, Station.DBType);
                LogicObject.Packing packOneObject  = new LogicObject.Packing();
                LogicObject.Packing packTwoObject  = new LogicObject.Packing();
                R_SN            r_sn;
                Row_R_MOVE_LIST rowMoveList;
                Row_R_PACKING   rowPacking;
                C_PACKING       c_packing = new C_PACKING();
                if (packOne.ClosedFlag == "0")
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613090152", new string[] { packOne.PackNo }));
                }
                if (packTwo.ClosedFlag == "0")
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613090152", new string[] { packTwo.PackNo }));
                }
                if (!packOne.PackType.Equals(packTwo.PackType))
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612114250", new string[] { packOne.PackNo, packTwo.PackNo }));
                }
                if (!packOne.Skuno.Equals(packTwo.Skuno))
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141141", new string[] { packOne.PackNo, packTwo.PackNo }));
                }
                if (!packOne.SkunoVer.Equals(packTwo.SkunoVer))
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141356", new string[] { packOne.PackNo, packTwo.PackNo }));
                }

                Newtonsoft.Json.Linq.JArray moveValueArray = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(sessionValue.Value.ToString());

                if (packOne.PackType == LogicObject.PackType.PALLET.ToString().ToUpper())
                {
                    for (int i = 0; i < moveValueArray.Count; i++)
                    {
                        c_packing = t_c_packing.GetPackingBySkuAndType(packTwo.Skuno, LogicObject.PackType.CARTON.ToString().ToUpper(), Station.SFCDB);
                        if (c_packing.MAX_QTY == 1 && Station.BU.ToUpper().Equals("VERTIV"))
                        {
                            //更新棧板號
                            //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN,故更新信息另外處理
                            R_PACKING packingObjectTemp = t_r_packing.GetPackingObjectBySN(moveValueArray[i].ToString(), Station.SFCDB);
                            if (packingObjectTemp == null)
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180620114012", new string[] { moveValueArray[i].ToString() }));
                            }
                            if (!t_r_packing.CheckPackNoExistByParentPackID(packingObjectTemp.PACK_NO, packOne.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo }));
                            }
                            if (t_r_packing.CheckPackNoExistByParentPackID(packingObjectTemp.PACK_NO, packTwo.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo }));
                            }
                            result     = t_r_packing.UpdateParentPackIDByPackNo(packingObjectTemp.PACK_NO, packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB);
                            rowPacking = t_r_packing.GetRPackingByPackNo(Station.SFCDB, packingObjectTemp.PACK_NO);
                        }
                        else
                        {
                            if (!t_r_packing.CheckPackNoExistByParentPackID(moveValueArray[i].ToString(), packOne.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo }));
                            }
                            if (t_r_packing.CheckPackNoExistByParentPackID(moveValueArray[i].ToString(), packTwo.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo }));
                            }
                            //更新棧板號
                            result     = t_r_packing.UpdateParentPackIDByPackNo(moveValueArray[i].ToString(), packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB);
                            rowPacking = t_r_packing.GetRPackingByPackNo(Station.SFCDB, moveValueArray[i].ToString());
                        }
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        result = t_r_packing.UpdateQtyByID(packTwo.PackID, true, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        result = t_r_packing.UpdateQtyByID(packOne.PackID, false, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        //寫入記錄

                        rowMoveList               = (Row_R_MOVE_LIST)t_r_move_list.NewRow();
                        rowMoveList.ID            = t_r_move_list.GetNewID(Station.BU, Station.SFCDB);
                        rowMoveList.MOVE_ID       = rowPacking.ID;
                        rowMoveList.FROM_LOCATION = packOne.PackID;
                        rowMoveList.TO_LOCATION   = packTwo.PackID;
                        rowMoveList.PACK_TYPE     = packOne.PackType;
                        rowMoveList.MOVE_EMP      = Station.LoginUser.EMP_NO;
                        rowMoveList.MOVE_DATE     = Station.GetDBDateTime();
                        result = Station.SFCDB.ExecSQL(rowMoveList.GetInsertString(Station.DBType));
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "R_MOVE_LIST" }));
                        }
                    }
                }
                else if (packOne.PackType == LogicObject.PackType.CARTON.ToString().ToUpper())
                {
                    for (int i = 0; i < moveValueArray.Count; i++)
                    {
                        r_sn = new R_SN();
                        r_sn = t_r_sn.GetDetailBySN(moveValueArray[i].ToString(), Station.SFCDB);
                        if (!t_r_sn_packing.CheckSNExistByPackID(r_sn.ID, packOne.PackID, Station.SFCDB))
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo }));
                        }
                        if (t_r_sn_packing.CheckSNExistByPackID(r_sn.ID, packTwo.PackID, Station.SFCDB))
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo }));
                        }
                        //更新卡通號
                        result = t_r_sn_packing.UpdatePackIDBySnID(r_sn.ID, packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_SN_PACKING" }));
                        }

                        result = t_r_packing.UpdateQtyByID(packTwo.PackID, true, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        result = t_r_packing.UpdateQtyByID(packOne.PackID, false, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }

                        //寫入記錄
                        rowMoveList               = (Row_R_MOVE_LIST)t_r_move_list.NewRow();
                        rowMoveList.ID            = t_r_move_list.GetNewID(Station.BU, Station.SFCDB);
                        rowMoveList.MOVE_ID       = r_sn.ID;
                        rowMoveList.FROM_LOCATION = packOne.PackID;
                        rowMoveList.TO_LOCATION   = packTwo.PackID;
                        rowMoveList.PACK_TYPE     = packOne.PackType;
                        rowMoveList.MOVE_EMP      = Station.LoginUser.EMP_NO;
                        rowMoveList.MOVE_DATE     = Station.GetDBDateTime();
                        result = Station.SFCDB.ExecSQL(rowMoveList.GetInsertString(Station.DBType));
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "R_MOVE_LIST" }));
                        }
                    }
                }
                else
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180607163531", new string[] { "Pack:" + packOne.PackType }));
                }
                //關閉卡通或棧板
                result = t_r_packing.UpdateCloseFlagByPackID(packOne.PackID, "1", Station.SFCDB);
                if (Convert.ToInt32(result) == 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154506", new string[] { packOne.PackNo }));
                }
                //關閉卡通或棧板
                result = t_r_packing.UpdateCloseFlagByPackID(packTwo.PackID, "1", Station.SFCDB);
                if (Convert.ToInt32(result) == 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154506", new string[] { packTwo.PackNo }));
                }

                packOneObject.DataLoad(packOne.PackNo, Station.BU, Station.SFCDB, Station.DBType);
                packTwoObject.DataLoad(packTwo.PackNo, Station.BU, Station.SFCDB, Station.DBType);
                sessionOne.Value = packOneObject;
                sessionTwo.Value = packTwoObject;
                if (moveToRight)
                {
                    sessionItemListOne.Value = packOneObject.PackList;
                    sessionItemListTwo.Value = packTwoObject.PackList;
                    sessionCountOne.Value    = packOneObject.PackList.Count;
                    sessionCountTwo.Value    = packTwoObject.PackList.Count;
                }
                else
                {
                    sessionItemListOne.Value = packTwoObject.PackList;
                    sessionItemListTwo.Value = packOneObject.PackList;
                    sessionCountOne.Value    = packTwoObject.PackList.Count;
                    sessionCountTwo.Value    = packOneObject.PackList.Count;
                }
                Station.StationMessages.Add(new StationMessage()
                {
                    Message = MESReturnMessage.GetMESReturnMessage("MSGCODE20180612142034", new string[] { packOne.PackNo.ToString(), moveValueArray.Count.ToString(), packTwo.PackNo.ToString() }),
                    State   = StationMessageState.Pass
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #14
0
        /// <summary>
        /// 檢查Pack狀態是否可以入OBA
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void CheckPackStatusInOba(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.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");
            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>();
            #endregion
            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))
                {
                    throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180526185434", new string[] { packSession.Value.ToString() }));
                }
                if (rLotPackList.Count == 0)
                {
                    rLotStatus = LotNo.ObaInLotByPackno(Station.User, rLotStatus, packSession.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 加載界面信息
            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);
            }
            #endregion
        }