public ActionResult FinancialReport(string id) { HomeController.RootSearch(this); StockFinancialReportContext data = new StockFinancialReportContext(); data.Stock = db.Stocks.FirstOrDefault(f => f.StockId == id); data.FinancialReports = db.StockFinancialReports.Where(f => f.StockId == id).OrderByDescending(f => f.ReportDate).ToList(); return(View(data)); }
public ActionResult LatestFinancialReport() { HomeController.RootSearch(this); StockFinancialReportContext data = new StockFinancialReportContext(); //var searchDate = DateTime.Today.AddDays(-7); //var year = DateTime.Today.Year - 1; data.FinancialReports = db.StockFinancialReports.Include("Stock").OrderByDescending(f => f.NoticeDate).Take(300).ToList(); return(View(data)); }
public ActionResult StockSelection3521() { HomeController.RootSearch(this); StockFinancialReportContext data = new StockFinancialReportContext(); data.FinancialReports = new List <StockFinancialReport>(); decimal YSTZ = 30; // 营业收入同比增长率 decimal XSMLL = 50; // 销售毛利率 decimal YYJLL = 20; // 净利率 decimal count = 1; // 2年内出现次数 decimal ZZCZZL = 0.1m; bool ignoreCount; bool.TryParse(Request.QueryString["IgnoreCount"], out ignoreCount); if (string.IsNullOrEmpty(Request.QueryString["YSTZ"])) { data.FinancialReports = (from p in db.StockFinancialReports.Include("Stock") join q in db.StockFinancialReports.GroupBy(f => f.StockId).Select(g => new { StockId = g.Key, ReportDate = g.Max(x => x.ReportDate) }) on new { StockId = p.StockId, ReportDate = p.ReportDate } equals new { StockId = q.StockId, ReportDate = q.ReportDate } where p.YSTZ >= YSTZ && p.XSMLL >= XSMLL && p.YYJLL >= YYJLL && p.ZZCZZL >= ZZCZZL select p).OrderByDescending(f => f.NoticeDate).ToList(); } else { if (decimal.TryParse(Request.QueryString["YSTZ"], out YSTZ) && decimal.TryParse(Request.QueryString["XSMLL"], out XSMLL) && decimal.TryParse(Request.QueryString["ROEPJ"], out YYJLL) && decimal.TryParse(Request.QueryString["Count"], out count) && decimal.TryParse(Request.QueryString["ZZCZZL"], out ZZCZZL)) { if (ignoreCount) { data.FinancialReports = (from p in db.StockFinancialReports.Include("Stock") join q in db.StockFinancialReports.GroupBy(f => f.StockId).Select(g => new { StockId = g.Key, ReportDate = g.Max(x => x.ReportDate) }) on new { StockId = p.StockId, ReportDate = p.ReportDate } equals new { StockId = q.StockId, ReportDate = q.ReportDate } where p.YSTZ >= YSTZ && p.XSMLL >= XSMLL && p.YYJLL >= YYJLL && p.ZZCZZL >= ZZCZZL select p).OrderByDescending(f => f.NoticeDate).ToList(); } else { var reportDate = DateTime.Now.AddYears(-2).AddMonths(-3); var financialReports = db.StockFinancialReports.Include("Stock").Where(p => p.ReportDate > reportDate && p.YSTZ >= YSTZ && p.XSMLL >= XSMLL && p.YYJLL >= YYJLL && p.ZZCZZL >= ZZCZZL).ToList(); var stockIds = financialReports.GroupBy(f => f.StockId).Select(g => new { StockId = g.Key, ReportCount = g.Count() }).Where(g => g.ReportCount >= count).Select(g => g.StockId).ToList(); data.FinancialReports = financialReports.Where(f => stockIds.Contains(f.StockId)).OrderBy(f => f.StockId).ThenByDescending(f => f.ReportDate).ToList(); } } } //if (!ignoreCount) //{ // var stockIds1 = data.FinancialReports.Select(f => f.StockId).ToList(); // var reportDate1 = new DateTime(DateTime.Now.Year - 1, 12, 31); // var reportDate2 = new DateTime(DateTime.Now.Year - 2, 12, 31); // stockIds1 = db.StockFinancialReports.Where(f => stockIds1.Contains(f.StockId) && (f.ReportDate == reportDate1 || f.ReportDate == reportDate2) && f.ZZCZZL >= ZZCZZL).Select(f => f.StockId).ToList(); // data.FinancialReports = data.FinancialReports.Where(f => stockIds1.Contains(f.StockId)).ToList(); //} return(View(data)); }