public IActionResult SummaryUserProductValue([Bind(Prefix = "SummaryUserProductValueQueryViewModel")] SummaryUserProductValueQueryViewModel queryModel) { var startDateTime = queryModel.StartDateTime; var endDateTime = queryModel.EndDateTime; var l = _userContractService.GetSummaryUserProductValue(queryModel).ToList(); return(PartialView("_SummaryProductValueList", l)); }
public IEnumerable <SummaryUserProductValueViewModel> GetSummaryUserProductValue(SummaryUserProductValueQueryViewModel queryModel) { string staffNoString = queryModel.StaffNoString; string[] staffNoArray = staffNoString.Split(','); var staffNoList = staffNoArray.ToList(); var staffNoIntList = staffNoList.Select <string, int>(q => Convert.ToInt32(q)); // var query = from c in dt.AsEnumerable() // group c by new { id = c.Field<int>("ID") } //into s // select new // { // ID = s.Key.id, // Math = s.Sum(p => p.Field<decimal>("Math")), // Chinese = s.Sum(p => p.Field<decimal>("Chinese")) // }; var connTable = (from p in _userContractRepository.EntityItems join q in _contractRepository.EntityItems on p.ContractId equals q.Id join r in _userRepository.EntityItems on p.UserId equals r.Id where q.FinishDateTime >= queryModel.StartDateTime && q.FinishDateTime <= queryModel.EndDateTime && q.FinishStatus == (int)FinishStatus.Finished select new { r.StaffName, r.StaffNo, q.FinishDateTime, Amount = p.Ratio * q.Amount }); var query = from p in connTable group p by new { p.StaffName, p.StaffNo } into s select new SummaryUserProductValueViewModel { StaffName = s.Key.StaffName, StaffNo = s.Key.StaffNo, Amount = s.Sum(p => p.Amount) }; //var linqVar = (from p in _userContractRepository.EntityItems // join q in _contractRepository.EntityItems on p.ContractId equals q.Id // join r in _userRepository.EntityItems on p.UserId equals r.Id // //TODO:合同完成时间 // select new SummaryUserProductValueViewModel // { // StaffName = r.StaffName, // StaffNo = r.StaffNo, // Amount = p.Ratio * q.Amount // }); if (queryModel.SummaryPdtValueOrderType == SummaryPdtValueOrderType.PdtValue) { query = query.OrderByDescending(x => x.Amount); } return(query); }