/// <summary>
        /// 获取指定产品指定工位选配零件信息
        /// </summary>
        /// <param name="info">包含产品名称、工位号的输入参数</param>
        public Socket_FittingAccessoryInfo ReceiveReadChoseMatchInfo(string info)
        {
            string[] data        = info.Split(new char[] { ',' });
            string   productName = data[0];
            string   workBench   = data[1];

            Socket_FittingAccessoryInfo fittingAccessoryInfo = new Socket_FittingAccessoryInfo();

            IAssemblingBom server = ServerModuleFactory.GetServerModule <IAssemblingBom>();

            // 获取指定工位所有装配信息,包含多种产品
            IQueryable <View_P_AssemblingBom> queryResult     = server.GetInfoOfWorkBench(workBench);
            List <View_P_AssemblingBom>       choseMatchParts = (from r in queryResult
                                                                 where r.产品名称 == productName && r.是否选配零件
                                                                 select r).ToList();

            if (choseMatchParts == null || choseMatchParts.Count == 0)
            {
                fittingAccessoryInfo.OperateState = Socket_FittingAccessoryInfo.OperateStateEnum.该工位无选配零件;
                return(fittingAccessoryInfo);
            }

            fittingAccessoryInfo.ParentCode   = choseMatchParts[0].父总成编码;
            fittingAccessoryInfo.GoodsCode    = choseMatchParts[0].零件编码;
            fittingAccessoryInfo.GoodsName    = choseMatchParts[0].零件名称;
            fittingAccessoryInfo.Spec         = choseMatchParts[0].规格;
            fittingAccessoryInfo.Counts       = choseMatchParts[0].装配数量;
            fittingAccessoryInfo.AssemblyFlag = Convert.ToInt32(choseMatchParts[0].是否总成);

            DataTable table;
            string    error;

            if (!m_choseConfectServer.GetAccessoryChoseConfectInfo(choseMatchParts[0].零件编码, "", out table, out error))
            {
                if (error.Contains(Socket_FittingAccessoryInfo.OperateStateEnum.获取选配信息失败.ToString()))
                {
                    fittingAccessoryInfo.OperateState = Socket_FittingAccessoryInfo.OperateStateEnum.获取选配信息失败;
                }
                else
                {
                    fittingAccessoryInfo.OperateState = Socket_FittingAccessoryInfo.OperateStateEnum.该零件非选配零件;
                }
            }
            else
            {
                fittingAccessoryInfo.ChoseMatchInfo = BuildChoseMatchInfoDic(table);
                fittingAccessoryInfo.OperateState   = Socket_FittingAccessoryInfo.OperateStateEnum.操作成功;
            }

            return(fittingAccessoryInfo);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取指定工位要装配的产品信息
        /// </summary>
        /// <param name="workBench">工位信息</param>
        /// <returns>返回获取到的产品信息</returns>
        public string GetProductInfo(string workBench)
        {
            try
            {
                if (m_dicProductInfoMapping.Count == 0)
                {
                    GenerateProductInfoMapping();
                }

                if (m_dicVirtualPartMapping.Count == 0)
                {
                    GeneratePartMapping();
                }

                IAssemblingBom server = ServerModuleFactory.GetServerModule <IAssemblingBom>();

                // 获取指定工位所有装配信息,包含多种产品
                IQueryable <View_P_AssemblingBom> queryResult = server.GetInfoOfWorkBench(workBench);

                // 提取指定工位所属的产品(哪些产品可以在此工位上装配零件)
                string[] productNames = (from r in queryResult select r.产品名称).Distinct().ToArray();

                StringBuilder sb    = new StringBuilder();
                int           index = 0;

                foreach (var name in productNames)
                {
                    if (index++ == 0)
                    {
                        sb.AppendFormat("{0}_{1}", name, m_dicProductInfoMapping[name]);
                    }
                    else
                    {
                        sb.AppendFormat(",{0}_{1}", name, m_dicProductInfoMapping[name]);
                    }
                }

                return(sb.ToString());
            }
            catch (Exception exce)
            {
                Console.WriteLine(exce.Message);
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取指定工位装配信息
        /// </summary>
        /// <param name="workBench">工位信息</param>
        /// <returns>返回获取到的工位信息</returns>
        public Socket_WorkBenchInfo GetWorkBenchInfo(string workBenchAndProductName)
        {
            char[]   splitChars  = { ',' };
            string[] splitString = workBenchAndProductName.Split(splitChars);
            string   workBench   = splitString[0];
            string   productName = splitString[1];

            Socket_WorkBenchInfo returnInfo = new Socket_WorkBenchInfo();

            returnInfo.WorkBench = workBench;

            if (workBench[0] == 'F')
            {
                returnInfo.WorkBenchType = WorkbenchTypeEnum.分装.ToString();
            }
            else
            {
                returnInfo.WorkBenchType = WorkbenchTypeEnum.总装.ToString();
            }

            try
            {
                //IProductInfoServer productInfoServer = ServerModuleFactory.GetServerModule<IProductInfoServer>();
                IAssemblingBom server = ServerModuleFactory.GetServerModule <IAssemblingBom>();

                // 获取指定工位所有装配信息,包含多种产品
                IQueryable <View_P_AssemblingBom> queryResult = server.GetInfoOfWorkBench(workBench);

                queryResult = from r in queryResult where r.产品名称 == productName orderby r.父总成编码 select r;

                List <string> parentNamesArray = (from r in queryResult select r.父总成名称).Distinct().ToList();

                List <string> parentNamesArray2 = (from r in queryResult where r.是否总成 == true select r.零件名称).Distinct().ToList();

                if (parentNamesArray2 != null && parentNamesArray2.Count > 0)
                {
                    foreach (var item in parentNamesArray2)
                    {
                        if (!parentNamesArray.Contains(item))
                        {
                            parentNamesArray.Add(item);
                        }
                    }
                }

                // 提取指定工位所属的分总成(哪些分总成可以在此工位上装配零件)
                List <string> parentNames = new List <string>(m_sortName);

                for (int i = 0; i < parentNames.Count; i++)
                {
                    if (!parentNamesArray.Contains(parentNames[i]))
                    {
                        parentNames.RemoveAt(i--);
                    }
                }

                returnInfo.ProductName = productName;

                #region 获取此工位父总成名称列表

                StringBuilder sb    = new StringBuilder();
                int           index = 0;

                foreach (var parentName in parentNames)
                {
                    if (index++ == 0)
                    {
                        sb.AppendFormat("{0}_{1}", parentName, m_dicVirtualPartMapping[parentName]);
                    }
                    else
                    {
                        sb.AppendFormat(",{0}_{1}", parentName, m_dicVirtualPartMapping[parentName]);
                    }
                }

                returnInfo.FZC = sb.ToString();
                sb.Remove(0, sb.Length);

                #endregion

                #region 获取此工位能够完成的分总成名称

                index = 0;

                foreach (var parentName in parentNames)
                {
                    IQueryable <View_P_AssemblingBom> childrenPart = server.GetChildrenPart(parentName);

                    // 指定产品指定父总成名称需经历的装配工位
                    List <string> parentWorkBench = (from r in childrenPart
                                                     where r.产品名称 == productName orderby r.工位
                                                     select r.工位).Distinct().ToList();

                    if (parentWorkBench.Count == 0)
                    {
                        continue;
                    }

                    if (workBench == parentWorkBench[parentWorkBench.Count - 1])
                    {
                        if (index++ == 0)
                        {
                            sb.AppendFormat("{0}", parentName);
                        }
                        else
                        {
                            sb.AppendFormat(",{0}", parentName);
                        }
                    }
                }

                returnInfo.FinishedFZC = sb.ToString();
                sb.Remove(0, sb.Length);

                #endregion

                #region 获取此工位可以装配的零件
                List <WorkbenchPartInfo> workBenchPartInfo = new List <WorkbenchPartInfo>();

                IQueryable <View_P_AssemblingBom> info = from r in queryResult where r.产品名称 == productName select r;

                foreach (var item in info)
                {
                    WorkbenchPartInfo partInfo = new WorkbenchPartInfo();

                    partInfo.ProduceName = item.产品名称;
                    partInfo.ParentName  = item.父总成名称;
                    partInfo.ParentCode  = item.父总成编码; //GetVirtualPartCode(item.父总成编码);
                    partInfo.PartCode    = item.零件编码;  //GetVirtualPartCode(item.零件编码);
                    partInfo.PartName    = item.零件名称;
                    partInfo.Spec        = item.规格;
                    partInfo.Amount      = item.装配数量;
                    workBenchPartInfo.Add(partInfo);
                }

                returnInfo.WorkBenchParts = workBenchPartInfo;
                #endregion

                if (workBench == "Z24")
                {
                    returnInfo.IsFirstWorkBenchInAssemblingLine = true;
                }
                else if (workBench == "DB")
                {
                    returnInfo.IsLastWorkBenchAssemblingLine = true;
                }

                returnInfo.OperateState = Socket_WorkBenchInfo.ReturnStateEnum.操作成功;
            }
            catch (Exception exce)
            {
                returnInfo.OperateState = Socket_WorkBenchInfo.ReturnStateEnum.获取工位初始化信息失败;
                returnInfo.ErrorInfo    = "RequestWorkBenchInfo.GetWorkBenchInfo:" + exce.Message;
            }

            return(returnInfo);
        }