public ActionResult GetProjectAccountingInfo(string projectGid) { var timeEntriesGroupByEmployeesView = GetProjectEffortByEmployeePrivate(projectGid); var projectInfo = _projectService.GetProjectById(projectGid); var projectAccountingInfo = _projectService.GetProjectEstimatedEffortById(projectGid); projectAccountingInfo.Id = 1; projectAccountingInfo.ProjectGid = projectGid; projectAccountingInfo.ProjectId = projectInfo.Id; projectAccountingInfo.ProjectName = projectInfo.Name; projectAccountingInfo.TimeEntriesGroupByEmployeesView = timeEntriesGroupByEmployeesView; projectAccountingInfo.SpentManHour = timeEntriesGroupByEmployeesView.Sum(a => a.TotalHours); projectAccountingInfo.SpentManHourRate = timeEntriesGroupByEmployeesView.Sum(a => a.TotalHoursRate); var today = DateTime.Now.Date; // 获取今天,以及今天的w和y var year = today.YearOfWeekOfYear(); var week = today.WeekOfYear(); // 计算本周一 var weekDay = today.DayOfWeek; var monday = today.AddDays(-(int)weekDay + 1); // 计算AC projectAccountingInfo.ActualCostByWeek = _timeEntryService.GetActualEffortByWeek(projectGid, monday); decimal lastTotalHours = 0; decimal lastTotalHoursRate = 0; // 每周的数据要加上前一周的数据 foreach (var acbw in projectAccountingInfo.ActualCostByWeek) { acbw.TotalHours += lastTotalHours; acbw.TotalHoursRate += lastTotalHoursRate; lastTotalHours = acbw.TotalHours; lastTotalHoursRate = acbw.TotalHoursRate; } // 计算EC lastTotalHours = 0; lastTotalHoursRate = 0; projectAccountingInfo.EstimateToCompletionByWeek = _resourcePlanService.GetBudgetByWeek(projectGid, year, week); foreach (var etcbw in projectAccountingInfo.EstimateToCompletionByWeek) { etcbw.TotalHours += lastTotalHours; etcbw.TotalHoursRate += lastTotalHoursRate; lastTotalHours = etcbw.TotalHours; lastTotalHoursRate = etcbw.TotalHoursRate; } // 计算ETC projectAccountingInfo.EAC = lastTotalHoursRate; // 数据怎么给eChart做折线图 return(Json(projectAccountingInfo, JsonRequestBehavior.AllowGet)); }