Example #1
0
        /// <summary>
        /// 檢查傳入機台是否符合工單上線別內可使用機台名稱
        /// </summary>
        /// <param name="equipmentName"></param>
        /// <param name="lotData"></param>
        /// <returns></returns>
        public static bool CheckEqpGruopAndDivision(string equipmentName, LotInfo lot)
        {
            bool checkResult = false;

            //找出工單上的線別(division),再用線別名稱去工作站的機台設定,找出同名稱的機台群組,再比照機台的正確性

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

            if (operationData == null)
            {
                //機台:{0},不在可用機台範圍,請至 [工作站設定] 確認機台設定
                throw new Exception(RuleMessage.Error.C10005(equipmentName));
            }

            //依據批號工作站找出歸屬的機台群組清單
            List <OperationResourceInfoEx> resourceDataList = OperationResourceInfoEx.GetDataByOperSID(operationData.OperationSID);

            if (resourceDataList.Count == 0)
            {
                //機台:{0},不在可用機台範圍,請至 [工作站設定] 確認機台設定
                throw new Exception(RuleMessage.Error.C10005(equipmentName));
            }

            foreach (var resourceData in resourceDataList)
            {
                //找出同名稱的機台群組
                var equipGroupData = EquipmentGroupInfo.GetEquipmentGroupByID(resourceData.ResourceID);

                //找出工單上的線別(Division)
                var workOrder = WorkOrderInfo.GetWorkOrderByWorkOrder(lot.WorkOrder).ChangeTo <WorkOrderInfoEx>();

                if (equipGroupData.GroupName == workOrder.Division)
                {
                    //用群組SID找出在該群組下的工作站
                    List <EquipGroupEquipInfoEx> eqGroupDataList = EquipGroupEquipInfoEx.GetEquipGroupByGroupSID(equipGroupData.ID);
                    if (eqGroupDataList.Find(p => p.EquipmentName == equipmentName) != null)
                    {
                        checkResult = true;
                    }
                }
            }

            return(checkResult);
        }
Example #2
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);
        }