SELECT A.*,B.CourseName,C.AssistName,IFNULL(C.AssistIcon,'') AS AssistIcon,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead
SELECT A.*,B.CourseName,C.AssistName,IFNULL(C.AssistIcon,'') AS AssistIcon,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead
,E.SName AS SchoolName,IFNULL(F.RoomName,'') AS RoomName
,E.SName AS SchoolName,IFNULL(F.RoomName,'') AS RoomName,plan.TotalPlanNum,ySplan.UsePlanNum
FROM rb_class AS A LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
FROM rb_class AS A LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
LEFT JOIN rb_assist AS C ON A.Assist_Id=C.AId
LEFT JOIN rb_assist AS C ON A.Assist_Id=C.AId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_school AS E ON A.School_Id=E.SId
LEFT JOIN rb_school AS E ON A.School_Id=E.SId
LEFT JOIN rb_class_room AS F ON A.ClassRoomId=F.RoomId
LEFT JOIN rb_class_room AS F ON A.ClassRoomId=F.RoomId
LEFT JOIN ((SELECT ClassId,COUNT(*) AS TotalPlanNum FROM rb_class_plan where `Status`=0 GROUP BY ClassId)) as plan on plan.ClassId=a.ClassId
LEFT JOIN ((SELECT ClassId,COUNT(*) AS UsePlanNum FROM rb_class_plan where `Status`=0 and DATE_FORMAT(ClassDate,'%Y-%m-%d') <=DATE_FORMAT(NOW(),'%Y-%m-%d') GROUP BY ClassId)) as ySplan on ySplan.ClassId=a.ClassId
WHERE 1=1
WHERE 1=1
");
");
if(query!=null)
if(query!=null)
...
@@ -509,87 +511,6 @@ where a.`Status`=0 and a.IsSubscribe=1 and ClassStatus in(1,2)");
...
@@ -509,87 +511,6 @@ where a.`Status`=0 and a.IsSubscribe=1 and ClassStatus in(1,2)");
SELECT plan.TotalPlanNum,ySplan.UsePlanNum,A.*,B.CourseName,C.AssistName,IFNULL(C.AssistIcon,'') AS AssistIcon,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead
,E.SName AS SchoolName,IFNULL(F.RoomName,'') AS RoomName
FROM rb_class AS A LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
LEFT JOIN rb_assist AS C ON A.Assist_Id=C.AId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_school AS E ON A.School_Id=E.SId
LEFT JOIN rb_class_room AS F ON A.ClassRoomId=F.RoomId
LEFT JOIN ((SELECT ClassId,COUNT(*) as TotalPlanNum from rb_class_plan where `Status`=0 GROUP BY ClassId)) as plan on plan.ClassId=a.ClassId
LEFT JOIN ((SELECT ClassId,COUNT(*) as UsePlanNum from rb_class_plan where `Status`=0 and DATE_FORMAT(ClassDate,'%Y-%m-%d') <=DATE_FORMAT(NOW(),'%Y-%m-%d') GROUP BY ClassId)) as ySplan on ySplan.ClassId=a.ClassId
WHERE 1=1 ");
if(query!=null)
{
if(query.Group_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Group_Id),query.Group_Id);
}
if(query.School_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.School_Id),query.School_Id);
}
if(query.Status>=0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Status),(int)query.Status);
}
if(query.ClassStatus>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.ClassStatus),(int)query.ClassStatus);
}
if(!string.IsNullOrWhiteSpace(query.ClassName))
{
builder.AppendFormat(" AND A.{0} LIKE @ClassName ",nameof(RB_Class_ViewModel.ClassName));