|
|
|
@ -12,6 +12,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
private readonly IGhre_StaffGroupServices _ghre_StaffGroupServices; |
|
|
|
|
private readonly IGhre_OpenClassScheduleServices _ghre_OpenClassScheduleServices; |
|
|
|
|
private readonly IGhre_OpenClassFeedbackServices _ghre_OpenClassFeedbackServices; |
|
|
|
|
private readonly IGhre_SurveyServices _ghre_SurveyServices; |
|
|
|
|
private readonly IBaseRepository<Ghre_OpenClass> _dal; |
|
|
|
|
public Ghre_OpenClassServices(ICaching caching, |
|
|
|
|
IBaseRepository<Ghre_OpenClass> dal, |
|
|
|
@ -19,6 +20,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
IGhre_OpenClassFeeServices ghre_OpenClassFeeServices, |
|
|
|
|
IGhre_StaffGroupServices ghre_StaffGroupServices, |
|
|
|
|
IGhre_OpenClassFeedbackServices ghre_OpenClassFeedbackServices, |
|
|
|
|
IGhre_SurveyServices ghre_SurveyServices, |
|
|
|
|
IGhre_OpenClassScheduleServices ghre_OpenClassScheduleServices) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
@ -29,6 +31,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas |
|
|
|
|
_ghre_OpenClassScheduleServices = ghre_OpenClassScheduleServices; |
|
|
|
|
_ghre_StaffGroupServices = ghre_StaffGroupServices; |
|
|
|
|
_ghre_OpenClassFeedbackServices = ghre_OpenClassFeedbackServices; |
|
|
|
|
_ghre_SurveyServices = ghre_SurveyServices; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_OpenClassDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
@ -857,12 +860,84 @@ WHERE A.OpenClassId = '{Id}' AND A.IsEnable = 1"; |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="Id">开班ID</param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<Ghre_SurveyStatistic>> QueryStatistic(long id) |
|
|
|
|
public async Task<ServiceResult<Ghre_OpenClassStatistic>> QueryStatistic(long id) |
|
|
|
|
{ |
|
|
|
|
var data = new Ghre_SurveyStatistic(); |
|
|
|
|
var data = new Ghre_OpenClassStatistic(); |
|
|
|
|
|
|
|
|
|
var entity = await base.QueryById(id); |
|
|
|
|
|
|
|
|
|
var surveyRecords = await Db.Queryable<Ghre_SurveyRecord>().Where(x => x.OpenClassId == id).ToListAsync(); |
|
|
|
|
|
|
|
|
|
var surveyIds = surveyRecords.Select(x => x.SurveyId).Distinct().ToList(); |
|
|
|
|
var recordOptions = await Db.Queryable<Ghre_SurveyRecordOption>() |
|
|
|
|
.Where(x => surveyIds.Contains(x.SurveyId)) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
data.CourseScore = surveyRecords.Sum(x => x.Score); |
|
|
|
|
data.TeacherScore = surveyRecords.Sum(x => x.Score); |
|
|
|
|
|
|
|
|
|
var questions = await Db.Queryable<Ghre_SurveyQuestion>() |
|
|
|
|
.OrderBy(x => x.SortNo) |
|
|
|
|
.Where(x => x.SurveyId == entity.FeedbackId) |
|
|
|
|
.Select(x => new Ghre_OpenClassQuestion() |
|
|
|
|
{ |
|
|
|
|
Id = x.Id, |
|
|
|
|
QuestionContent = x.QuestionContent, |
|
|
|
|
QuestionType = x.QuestionType, |
|
|
|
|
Score = 0 |
|
|
|
|
}).ToListAsync(); |
|
|
|
|
|
|
|
|
|
var parentQuestions = await Db.Queryable<Ghre_SurveyQuestion>() |
|
|
|
|
.OrderBy(x => x.SortNo) |
|
|
|
|
.Where(x => x.SurveyId == entity.ParentFeedbackId) |
|
|
|
|
.Select(x => new Ghre_OpenClassQuestion() |
|
|
|
|
{ |
|
|
|
|
Id = x.Id, |
|
|
|
|
QuestionContent = x.QuestionContent, |
|
|
|
|
QuestionType = x.QuestionType, |
|
|
|
|
Score = 0 |
|
|
|
|
}).ToListAsync(); |
|
|
|
|
|
|
|
|
|
questions.ForEach(async x => |
|
|
|
|
{ |
|
|
|
|
x.QuestionType = await GetParaLabel("SurveyQuestionType", x.QuestionType); |
|
|
|
|
x.Score = recordOptions.Where(o => o.SurveyQuestionId == x.Id).Sum(x => x.Score); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
parentQuestions.ForEach(async x => |
|
|
|
|
{ |
|
|
|
|
x.QuestionType = await GetParaLabel("SurveyQuestionType", x.QuestionType); |
|
|
|
|
x.Score = recordOptions.Where(o => o.SurveyQuestionId == x.Id).Sum(x => x.Score); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return ServiceResult<Ghre_SurveyStatistic>.OprateSuccess("查询成功!", data); |
|
|
|
|
data.CourseGroup.Trainee = questions; |
|
|
|
|
data.CourseGroup.ParentTeacher = parentQuestions; |
|
|
|
|
|
|
|
|
|
data.TeacherGroup.Trainee = questions; |
|
|
|
|
data.TeacherGroup.ParentTeacher = parentQuestions; |
|
|
|
|
|
|
|
|
|
data.TotalGroup.Trainee = (await _ghre_SurveyServices.QueryStatistic(entity.FeedbackId.Value)).Data; |
|
|
|
|
data.TotalGroup.ParentTeacher = (await _ghre_SurveyServices.QueryStatistic(entity.ParentFeedbackId.Value)).Data; |
|
|
|
|
|
|
|
|
|
string sql = @$"SELECT A.Id,
|
|
|
|
|
B.StaffNo, |
|
|
|
|
B.StaffName, |
|
|
|
|
C.DeptName, |
|
|
|
|
D.CourseName, |
|
|
|
|
'已评' ScoreStatus, |
|
|
|
|
0 Score, |
|
|
|
|
CASE A.Source |
|
|
|
|
WHEN 'ParentTeacher' THEN '讲师上级' |
|
|
|
|
WHEN 'Trainee' THEN '学员' |
|
|
|
|
END AS Source |
|
|
|
|
FROM Ghre_OpenClassFeedback A |
|
|
|
|
LEFT JOIN Ghra_Staff B ON A.StaffId = B.StaffID |
|
|
|
|
LEFT JOIN Ghro_Dept C ON C.DeptID = B.DeptID |
|
|
|
|
LEFT JOIN Ghre_Course D ON A.CourseId = D.Id |
|
|
|
|
WHERE A.SurveyId = {entity.FeedbackId} OR A.SurveyId = {entity.ParentFeedbackId}";
|
|
|
|
|
data.Records = DbAccess.QueryList<Ghre_OpenClassStatisticRecord>(sql); |
|
|
|
|
|
|
|
|
|
return ServiceResult<Ghre_OpenClassStatistic>.OprateSuccess("查询成功!", data); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |