/// <summary>
        ///  竞品分析
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageNo"></param>
        /// <param name="collection"></param>
        /// <returns></returns>
        public ActionResult CompeteProduct(int? pageNo,string parm, FormCollection collection)
        {
            Dictionary<string, string> sitemaster = GetSiteMaster();
            ViewData["SiteMaster"] = sitemaster;
            int PageNo = pageNo ?? 1;
            int PageSize = 20;
            Dictionary<string, string> dict = ParmHelper.Analysis(collection);
            if (dict.Count == 0)
            {

                Hashtable ht = ParmHelper.AnalysisParmByHt(parm);
                ht.Add("memberID", EnterPriseMemberInfo.MemberID);

                string city = ht["city"] == null ? "" : ht["city"].ToString();
                string level = ht["level"] == null ? "" : ht["level"].ToString();
                ht.Add("cityshow", GetCityRegion(city));
                ht.Add("proshow", GetProLv(level));

                if (ht["city"] != null && ht["city"].ToString() != "")
                {
                    ht.Add("cities", ht["city"].ToString().Split('-'));
                }
                if (ht["proshow"] != null && ht["proshow"].ToString() != "")
                {
                    level = level.Trim('-');
                    ht.Add("isprovice", level.Split('-'));
                }
                //查询项目ID
                DBiddingProjectStandardDao dDao = new DBiddingProjectStandardDao();
                IList<int> projectoids=dDao.GetCompeteAnalysis(ht);
                if (projectoids.Count() > 0)
                {
                    ht.Add("projectids", projectoids.ToArray());
                }

                MemberEnterpriseAliasDao mDao = new MemberEnterpriseAliasDao();
                IList<MemberEnterpriseAlias> enterpriseList = mDao.FindByMemberID(EnterPriseMemberInfo.MemberID);
                if (ht["compete"] != null && !string.IsNullOrEmpty(ht["compete"].ToString()))
                {
                    int count=enterpriseList.Count;
                    string[] productenterprises = new string[count];
                    int i=0;
                    foreach (MemberEnterpriseAlias v in enterpriseList)
                    {
                        productenterprises[i] = v.EnterpriseName;
                        i++;

                    }
                    ht.Add("productenterprises", productenterprises);
                }

                ViewData["Query"] = ht;
                if (projectoids.Count==0|| ht["commonname"] == null || ht["commonname"].ToString() == "")
                {
                    PagedList<ProductState> newList2 = new PagedList<ProductState>(new List<ProductState>(), 1, 1, 0);
                    ViewData["Pa"] = new ProductAnalysis();
                    ViewData["Count"] = 0;
                    return View(newList2);
                }
                else
                {
                    ht.Add("commonnames", ht["commonname"].ToString().Split('|'));
                }

                MyProductAnalysisHelper m = new MyProductAnalysisHelper();
                m.PageSize = PageSize;
                ProductAnalysis pa = new ProductAnalysis();
                int total = 0;
                //List<int> competeMembers = new List<int>();
                //if (ht["compete"] != null && !string.IsNullOrEmpty(ht["compete"].ToString()))
                //{
                //    string[] competes = ht["compete"].ToString().Split('|');
                //    CRMService crmS = new CRMService();
                //    for (int i = 0; i < competes.Length; i++)
                //    {

                //        int id = crmS.GetMemberID(competes[i]);
                //        if (id != 0 && !competeMembers.Contains(id))
                //        {
                //            competeMembers.Add(id);
                //        }
                //    }
                //}
                if (ht["formulation"].ToString() == "注射")
                {
                    ht.Add("formulation1", "注射");
                    if (ht["Formulation2"] != null)
                    {
                        string temp = ht["Formulation2"].ToString().Trim(',');
                        string[] formulation2s = temp.Split(',');
                        ht.Add("formulation2s", formulation2s);
                    }
                }

                List<ProductState> list = m.GetList(PageNo, ht, enterpriseList,ref total, ref pa);
                list.Sort();

                foreach (ProductState p in list)
                {
                    foreach (MemberEnterpriseAlias n in enterpriseList)
                    {
                        if (p.ProductEnterprise == n.EnterpriseName)
                        {
                            p.IsMine = true;
                            break;
                        }
                    }
                }
                list.OrderBy(p => p.CommonName).OrderBy(p => p.Formulation).OrderBy(p => p.ChineseSpecification);
                list.OrderBy(p => new { p.CommonName, p.Formulation, p.ChineseSpecification });
                ViewData["Pa"] = pa;
                ViewData["Count"] = total;
                PagedList<ProductState> newList = new PagedList<ProductState>(list, PageNo, PageSize);
                return View(newList);
            }
            else
            {

                string parmeter = ParmHelper.BuildParm(dict);
                return RedirectToAction("CompeteProduct", new { parm = parmeter, id = 1 });

            }
        }
        /// <summary>
        /// 得到中标项目
        /// </summary>
        /// <param name="ht"></param>
        /// <returns></returns>
        private Dictionary<int, IList<ProductReportEx>> GetBidProject(Hashtable ht)
        {
            Dictionary<int, IList<ProductReportEx>> dict = new Dictionary<int, IList<ProductReportEx>>();
            DBiddingProjectStandardDao dpDao = new DBiddingProjectStandardDao();
            DBiddingMedicineStandardDao dmDao = new DBiddingMedicineStandardDao();

            IList<DBiddingProjectStandard> list = dpDao.GetProjectByProductQuery(ht);
            if (list.Count > 0)
            {
                var a = (from c in list select c.OID).ToList();
                if (a.Count == 0)
                {
                    IList<ProductReportEx> ilist = new List<ProductReportEx>();
                    dict.Add(0, ilist);
                    return dict;
                }
                long[] projectoids = new long[a.Count()];
                for (int i = 0; i < projectoids.Length; i++)
                {
                    projectoids[i] = a[i];
                }
                ht.Add("projectids", projectoids);

                IList<DBiddingMedicineStandard> listDetail = dmDao.GetProductQuery(ht);
                int total = dmDao.GetProductQueryCount(ht);

                List<ProductReportEx> listPR = new List<ProductReportEx>();
                foreach (DBiddingMedicineStandard d in listDetail)
                {
                    DBiddingProjectStandard project = (from p in list where p.OID == d.ProjectOID select p).First();
                    ProductReportEx pr = new ProductReportEx();
                    pr.ProjectOID = (int)project.OID;
                    pr.BidDate = project.BidDate;
                    pr.BiddingPrice = GetBiddingPrice(d);
                    pr.ChineseSpecification = d.ChineseSpecification;
                    pr.City = project.Provice;
                    pr.CommonName = d.CommonName;
                    pr.Formulation = d.Formulation;
                    pr.Package = d.Packaging;
                    pr.Unit = d.Unit;
                    pr.ConvertCoefficient = d.ConvertCoefficient;
                    pr.QualityLevel = d.QualityLevel;
                    pr.ProductEnterprise = d.ProductEnterprise;
                    pr.ProjectIntroduction = project.ProjectIntroduction;

                    pr.NewProjectName = project.NewProjectName;
                    pr.NewProjectDescription = project.NewProjectDescription;
                    pr.IsProvice = project.IsProvice??0;
                    pr.IsBaseMedicin = project.IsBaseMedicine??0;
                    pr.Remark = project.Remark;
                    pr.GoodsName = d.GoodsName;
                    pr.Material = d.Material;
                    pr.NowPrice = d.NowPrice??0;
                    pr.InPrice = d.InPrice??0;
                    pr.TenderPrice = d.TenderPrice??0;
                    pr.State = d.State;
                    pr.TempRetailPrice = d.TempRetailPrice??0;
                    pr.PriceVersion = d.PriceVersion;
                    pr.LeastPharmaceuticalPrice = d.LeastPharmaceuticalPrice??0;
                    pr.GoodsRemark = d.GoodsRemark;
                    pr.PackagingPrice = d.PackagingPrice??0;
                    pr.LimitPrice = d.LimitPrice??0;
                    pr.Formulation1 = d.Formulation1;
                    pr.Formulation2 = d.Formulation2;
                    pr.EnterpriseRank = d.EnterpriseRank;
                    pr.DeliveryEnterprise = d.DeliveryEnterprise;
                    pr.BiddingEnterprise = d.BiddingEnterprise;
                    pr.AdjustPrice = d.AdjustPrice??0;
                    pr.OriginalPrice = d.OriginalPrice??0;
                    listPR.Add(pr);
                }
                dict.Add(total, listPR.OrderByDescending(p => p.BidDate).ToList());
            }
            return dict;
        }