예제 #1
0
        /// <summary>
        /// 依據傳入的工作站取得可使用機台清單
        /// </summary>
        /// <param name="operationName">工作站名稱</param>
        public static List <EquipmentInfo> GetEquipmentListByOperationName(string operationName)
        {
            //清除機台清單
            List <EquipmentInfo> equipmentList = new List <EquipmentInfo>();

            //取得批號目前的工作站資料
            var operationData = OperationInfo.GetOperationByName(operationName);

            if (operationData == null)
            {
                //[00171]工作站:{0}不存在!!
                throw new Exception(TextMessage.Error.T00171(operationName));
            }

            //確認工作站是否有啟用使用機台的功能
            if (operationData.EQUIPFLAG == "Y")
            {
                //依據工作站找出歸屬的機台群組清單
                List <OperationResourceInfoEx> resourceDataList = OperationResourceInfoEx.GetDataByOperSID(operationData.OperationSID);

                if (resourceDataList.Count > 0)
                {
                    #region 取得該工作站可使用的所有機台資料
                    foreach (var resourceData in resourceDataList)
                    {
                        if (resourceData.ResourceType == "Group")
                        {
                            //如果資源類別為Group,則找出此機台群組內的所有機台資訊
                            var equipGroupData = EquipmentGroupInfo.GetEquipmentGroupByID(resourceData.ResourceID);

                            //用群組SID找出在該群組下的工作站
                            List <EquipGroupEquipInfoEx> eqGroupDataList = EquipGroupEquipInfoEx.GetEquipGroupByGroupSID(equipGroupData.ID);

                            if (eqGroupDataList.Count > 0)
                            {
                                foreach (var eqGroupData in eqGroupDataList)
                                {
                                    //取得機台資訊
                                    var equipmentData = EquipmentInfo.GetEquipmentByName(eqGroupData.EquipmentName);

                                    //如果機台資料不為NULL才要確認是否己經加入清單內
                                    if (equipmentData != null)
                                    {
                                        //確認是否已經加入機台清單
                                        if (equipmentList.Contains(equipmentData) == false)
                                        {
                                            equipmentList.Add(equipmentData);
                                        }
                                    }
                                }
                            }
                        }
                        else if (resourceData.ResourceType == "Equip")
                        {
                            //如果資源類別為Equip,則加入此機台資訊
                            var equipmentData = EquipmentInfo.GetEquipmentByID(resourceData.ResourceID);

                            //如果機台資料不為NULL才要確認是否己經加入清單內
                            if (equipmentData != null)
                            {
                                //確認是否已經加入機台清單
                                if (equipmentList.Contains(equipmentData) == false)
                                {
                                    equipmentList.Add(equipmentData);
                                }
                            }
                        }
                        else if (resourceData.ResourceType == "Type")
                        {
                            //如果資源類別為Type,則加入所有此Type的機台資訊
                            var equipmentTypeData  = EquipmentTypeInfo.GetEquipmentTypeByID(resourceData.ResourceID);
                            var equipmentDatalList = EquipmentInfo.GetEquipmentsByType(equipmentTypeData);

                            foreach (var equipmentData in equipmentDatalList)
                            {
                                //確認是否已經加入機台清單
                                if (equipmentList.Contains(equipmentData) == false)
                                {
                                    equipmentList.Add(equipmentData);
                                }
                            }
                        }
                    }
                    #endregion
                }
            }

            //以機台名稱排序
            equipmentList.Sort(p => p.EquipmentName);

            return(equipmentList);
        }
예제 #2
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                /*  1.	檢查畫面上所有輸入欄位是否都已輸入。
                 *  2.	如為當站進站(批號狀態為Wait),則將批號進站併上機台。(EquipmentAddLot、CheckIn、Dispatch)。
                 *  3.	如為預約進站,則將預約資訊塞入客製表,做批號備註。(AddComment)
                 *  4.	清空畫面,游標停在機加批號。
                 */
                string           equipmentName = "";
                EquipmentInfo    equipData     = null;
                TransactionStamp txnStamp      = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台是否有輸入
                if (ttbLot.Text.IsNullOrEmpty() || _LotData == null)
                {
                    AjaxFocus(ttbLot);
                    throw new Exception(TextMessage.Error.T00030(GetUIResource("LotCheckInLot"), ""));
                }

                //如果機台下拉式清單Enabled為TRUE,則必須檢查是否有選擇機台
                if (ddlEquip.Enabled)
                {
                    ddlEquip.Must(lblEquip);

                    //取得機台資訊
                    equipData = EquipmentInfo.GetEquipmentByID(ddlEquip.SelectedValue);

                    //註記機台名稱
                    equipmentName = equipData.EquipmentName;
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //批號狀態為Wait時,表示目前要執行進站
                    if (_LotData.Status == LotDefaultStatus.Wait.ToString())
                    {
                        CheckBom(_LotData.OperationName, equipData, _LotData);

                        if (equipData != null)
                        {
                            //批號上機台
                            EMSTxn.Default.AddLotToEquipment(_LotData, equipData, txnStamp);

                            //取得機台狀態資料
                            var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("RUN");

                            if (equipData.CurrentState != "RUN")
                            {
                                //更新機台狀態
                                EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                            }
                        }

                        //批號進站
                        WIPTransaction.CheckIn(_LotData, equipmentName, "", "", LotDefaultStatus.Run.ToString(), txnStamp);

                        //將批號Dispatch到下一規則
                        WIPTransaction.DispatchLot(_LotData, txnStamp);
                    }
                    else
                    {
                        CheckBom(_WIPReserveCheckInData.OperationName, equipData, _LotData);

                        //執行預約進站功能
                        _WIPReserveCheckInData.Equipment = equipmentName;
                        _WIPReserveCheckInData.InTime    = DBCenter.GetSystemTime();
                        _WIPReserveCheckInData.InsertToDB();

                        //做批號備註。(AddComment)
                        var reason  = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "ReserveLotCheckIn");
                        var massage = "";

                        WIPTransaction.AddLotComment(_LotData, reason, massage, txnStamp);
                    }
                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }