public JsonResult GetStandardList(int quotaId) { var standardBll = new InstructorReviewStandardBll(); var standardList = standardBll.QueryList($"InstructorQuotaId={quotaId} AND IsDelete=0"); return(Json(ErrorModel.GetDataSuccess(standardList))); }
private void ComputeScore() { var quotaBll = new InstructorQuotaBll(); var quotaList = quotaBll.QueryList("IsDelete=0").ToList(); var standardBll = new InstructorReviewStandardBll(); var standardList = standardBll.QueryList("IsDelete=0").ToList(); var currentYear = DateTime.Now.Year; var currentMonth = DateTime.Now.Month; var instructorQuotaRecordBll = new InstructorQuotaRecordBll(); var condition = $"Year={currentYear} AND Month={currentMonth} AND IsDelete=0"; var recordList = instructorQuotaRecordBll.QueryList(condition).ToList(); // 将指标完成记录以指标Id分组 var groupList = recordList.GroupBy(item => item.QuotaId); // 分别计算每项指标得分 var counterList = new List <ScoreCounter>(); foreach (var item in groupList) { var quotaId = item.Key; var quota = quotaList.Single(q => q.Id == quotaId); var standards = standardList.Where(s => s.InstructorQuotaId == quotaId).ToList(); if (quota.NeedReview) { counterList.AddRange( from record in item let score = ScoreCalculater(quota.QuataAmmount, quota.BaseScore, record.FinishedAmmount, standards) select new ScoreCounter { InstructorId = record.InstructorId, QuotaId = quotaId, Score = score }); } } // 统计指导司机本月总得分 var instructorScoreList = counterList.GroupBy(item => item.InstructorId) .Select(group => new InstructorReviewScore { InstructorId = group.Key, Year = currentYear, Month = currentMonth, Score = group.Sum(s => s.Score) }); // 删除本月当前得分记录,插入新的得分记录 var scoreBll = new InstructorReviewScoreBll(); var deleteCondition = $"Year={currentYear} AND Month={currentMonth}"; scoreBll.ExecuteTransation( () => !scoreBll.Exists(deleteCondition) || scoreBll.Delete(deleteCondition), () => { scoreBll.BulkInsert(instructorScoreList); return(true); }); }