SELECT A.*,class.ClassName,lp.LessonPlanNum,IFNULL(B.RoomName,'') AS RoomName,IFNULL(T.TeacherName,'') AS TeacherName,IFNULL(T.TeacherHead,'') AS UserIcon
FROM RB_Class_Plan AS A LEFT JOIN rb_class_room AS B ON A.ClassRoomId=B.RoomId
LEFT JOIN rb_class as class on a.ClassId=class.ClassId
LEFT JOIN rb_teacher AS T ON A.TeacherId=T.TId
LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanNum from rb_class_lessonplan where `Status`=0 GROUP BY ClassPlanId)as lp on a.ClassPlanId=lp.ClassPlanId
WHERE 1=1 and class.ClassStatus=2 and t.`Status`=0
");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.Status),(int)DateStateEnum.Normal);
//builder.AppendFormat(@"
// SELECT A.*,class.ClassName,lp.LessonPlanNum,lps.LessonPlanSummaryNum,IFNULL(B.RoomName,'') AS RoomName,IFNULL(T.TeacherName,'') AS TeacherName,IFNULL(T.TeacherHead,'') AS UserIcon
// FROM RB_Class_Plan AS A LEFT JOIN rb_class_room AS B ON A.ClassRoomId=B.RoomId
// LEFT JOIN rb_class as class on a.ClassId=class.ClassId
// LEFT JOIN rb_teacher AS T ON A.TeacherId=T.TId
// LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanNum from rb_class_lessonplan where `Status`=0 GROUP BY ClassPlanId)as lp on a.ClassPlanId=lp.ClassPlanId
//LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanSummaryNum from rb_class_lessonplan where `Status`=0 and ISNULL(Summary)=0 and LENGTH(trim(Summary))>0 GROUP BY ClassPlanId)as lps on a.ClassPlanId=lps.ClassPlanId
//WHERE 1=1 and class.ClassStatus=2 and t.`Status`=0
// ");
// builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Status), (int)DateStateEnum.Normal);
if(query!=null)
{
if(query.ClassId>0)
...
...
@@ -406,18 +407,42 @@ WHERE 1=1 and class.ClassStatus=2 and t.`Status`=0
}
if(!string.IsNullOrEmpty(query.QMonth))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y/%m')= DATE_FORMAT('{1}-01','%y/%m') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.QMonth);
builder.AppendFormat(" AND DATE_FORMAT(A.{0},''%y/%m'')= DATE_FORMAT(''{1}-01'',''%y/%m'') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.QMonth);
}
if(!string.IsNullOrEmpty(query.StartTime))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y-%m-%d')>=DATE_FORMAT('{1}','%y-%m-%d') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.StartTime);
builder.AppendFormat(" AND DATE_FORMAT(A.{0},''%y-%m-%d'')>=DATE_FORMAT(''{1}'',''%y-%m-%d'') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.StartTime);
}
if(!string.IsNullOrEmpty(query.EndTime))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y-%m-%d')<=DATE_FORMAT('{1}','%y-%m-%d') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.EndTime);
builder.AppendFormat(" AND DATE_FORMAT(A.{0},''%y-%m-%d'')<=DATE_FORMAT(''{1}'',''%y-%m-%d'') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.EndTime);
////A.*,class.ClassName,lp.LessonPlanNum,IFNULL(B.RoomName,'') AS RoomName,IFNULL(T.TeacherName,'') AS TeacherName,IFNULL(T.TeacherHead,'') AS UserIcon
////FROM RB_Class_Plan AS A LEFT JOIN rb_class_room AS B ON A.ClassRoomId=B.RoomId
////LEFT JOIN rb_class as class on a.ClassId=class.ClassId
//// LEFT JOIN rb_teacher AS T ON A.TeacherId=T.TId
////LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanNum from rb_class_lessonplan where `Status`=0 GROUP BY ClassPlanId)as lp on a.ClassPlanId=lp.ClassPlanId,