Пример #1
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;
            }
        }
Пример #2
0
        /// <summary>
        /// 處理SN狀態/記錄過站記錄/統計良率 for TCQS
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void TCQSPassStationAction(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            SN     SnObject = null;
            T_R_SN TRSN     = new T_R_SN(Station.SFCDB, Station.DBType);
            T_R_TCQS_YIELD_RATE_DETAIL TRTCQS = new T_R_TCQS_YIELD_RATE_DETAIL(Station.SFCDB, Station.DBType);
            R_TCQS_YIELD_RATE_DETAIL   RTCQS  = new R_TCQS_YIELD_RATE_DETAIL();
            string ErrMessage = string.Empty;
            string DeviceName = string.Empty;
            //獲取DB時間,所有數據更新使用同一時間
            DateTime DT = Station.GetDBDateTime();

            if (Paras.Count != 4)
            {
                //參數不正確:配置表中参数不够,应该为 {0} 个,实际只有 {1} 个!
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000051", new string[] { "3", Paras.Count.ToString() });
                throw new MESReturnMessage(ErrMessage);
            }

            //獲取到 SN 對象
            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null)
            {
                //无法获取到 {0} 的数据,请检查工站配置!
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            SnObject = (SN)SNSession.Value;

            //STATUS,方便過站處理/寫良率和UPH使用
            MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (StatusSession == null)
            {
                //如果沒有,則創建一個該工站的StatusSession,且SN狀態默認為該Action中設定的狀態Value = Paras[1].VALUE
                StatusSession = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), Value = Paras[1].VALUE, SessionKey = Paras[1].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(StatusSession);
                //如果該工站沒有設定默認狀態,則默認為PASS
                if (StatusSession.Value == null ||
                    (StatusSession.Value != null && StatusSession.Value.ToString() == ""))
                {
                    StatusSession.Value = "PASS";
                }
            }

            //Device:站點名稱
            MESStationSession DeviceSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (DeviceSession != null)
            {
                DeviceName = DeviceSession.Value.ToString();
            }
            else //如果站點名稱不存在,則默認為工站名稱
            {
                DeviceName = Station.StationName;
            }

            //TCQSRecord:TCQS良率統計記錄
            MESStationSession TCQSSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (TCQSSession == null)
            {
                //无法获取到 {0} 的数据,请检查工站配置!
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            else
            {
                RTCQS = (R_TCQS_YIELD_RATE_DETAIL)TCQSSession.Value;
            }

            //如果過站,則按MES原邏輯處理
            if (RTCQS.TOTAL_FRESH_BUILD_QTY > 0 || RTCQS.TOTAL_REWORK_BUILD_QTY > 0)
            {
                TRSN.PassStation(SnObject.SerialNo, Station.Line, Station.StationName, DeviceName, Station.BU, StatusSession.Value.ToString(), Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            //所有測試記錄,都要統計在TCQS的三個表中(TCQS_Yield/Tmp_ATEData/R_SN_Detail)
            ErrMessage = TRTCQS.RecordTCQSYieldRate(RTCQS, SnObject.SerialNo, Station.BU, Station.SFCDB);
            Station.AddMessage("MES00000150", new string[] { SnObject.SerialNo, "TCQS Yield Rate" }, StationMessageState.Pass);
        }