@ -20,266 +20,274 @@ import com.yipin.liuwanr.vo.ExperimentalClassVo;
@Service
public class ExperimentalClassService {
private static Logger logger = Logger . getLogger ( ExperimentalClassService . class ) ;
private static Logger logger = Logger . getLogger ( ExperimentalClassService . class ) ;
@Autowired
private ExperimentalClassMapper experimentalClassMapper ;
@Autowired
private ExperimentalClassMapper experimentalClassMapper ;
@Autowired
private TeacherProjectAndCourseMapper projectAndCourseMapper ;
@Autowired
private TeacherProjectAndCourseMapper projectAndCourseMapper ;
//实验班级添加学生
public HashMap < String , Object > experimentClassAddStudent ( List < Student > studentList ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
Integer size = studentList . size ( ) ;
try {
for ( int i = 0 ; i < size ; i + + ) {
Student student = studentList . get ( i ) ;
Integer studentId = student . getStudentId ( ) ;
String experimentalClassId = student . getExperimentalClassId ( ) ;
if ( studentId = = null ) {
resp . put ( "retcode" , 300 ) ;
resp . put ( "retvalue" , "学生为空!" ) ;
} else if ( experimentalClassId = = null | | experimentalClassId = = "" ) {
resp . put ( "retcode" , 300 ) ;
resp . put ( "retvalue" , "实验班级为空!" ) ;
} else {
experimentalClassMapper . experimentClassAddStudent ( student ) ;
resp . put ( "retcode" , 200 ) ;
}
}
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "添加学生失败!" ) ;
return resp ;
}
return resp ;
}
//实验班级添加学生
public HashMap < String , Object > experimentClassAddStudent ( List < Student > studentList ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
Integer size = studentList . size ( ) ;
try {
for ( int i = 0 ; i < size ; i + + ) {
Student student = studentList . get ( i ) ;
Integer studentId = student . getStudentId ( ) ;
String experimentalClassId = student . getExperimentalClassId ( ) ;
if ( studentId = = null ) {
resp . put ( "retcode" , 300 ) ;
resp . put ( "retvalue" , "学生为空!" ) ;
} else if ( experimentalClassId = = null | | experimentalClassId = = "" ) {
resp . put ( "retcode" , 300 ) ;
resp . put ( "retvalue" , "实验班级为空!" ) ;
} else {
experimentalClassMapper . experimentClassAddStudent ( student ) ;
resp . put ( "retcode" , 200 ) ;
}
}
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "添加学生失败!" ) ;
return resp ;
}
return resp ;
}
//实验班级删除学生
public HashMap < String , Object > experimentClassDeleteStudent ( List < Student > student ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
for ( int i = 0 ; i < student . size ( ) ; i + + ) {
Student stu = student . get ( i ) ;
experimentalClassMapper . experimentClassDeleteStudent ( stu ) ;
}
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "删除学生失败" ) ;
return resp ;
}
return resp ;
}
//实验班级删除学生
public HashMap < String , Object > experimentClassDeleteStudent ( List < Student > student ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
for ( int i = 0 ; i < student . size ( ) ; i + + ) {
Student stu = student . get ( i ) ;
experimentalClassMapper . experimentClassDeleteStudent ( stu ) ;
}
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "删除学生失败" ) ;
return resp ;
}
return resp ;
}
//创建实验班级
public HashMap < String , Object > addExperimentalClass ( ExperimentalClass experimentalClass ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . addExperimentalClass ( experimentalClass ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "创建实验班级失败!" ) ;
throw e ;
}
return resp ;
}
//创建实验班级
public HashMap < String , Object > addExperimentalClass ( ExperimentalClass experimentalClass ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . addExperimentalClass ( experimentalClass ) ;
public HashMap < String , Object > queryExperimentalClass ( Integer schoolId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryExperimentalClass ( schoolId ) ) ;
// List<ExperimentalClass> a = experimentalClassMapper.queryExperimentalClass(schoolId);
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询实验班级失败!" ) ;
return resp ;
}
return resp ;
}
//给实验班级绑定项目
Integer experimentalClassId = experimentalClass . getExperimentalClassId ( ) ;
Integer courseId = experimentalClass . getCourseId ( ) ;
List < Integer > projectIds = projectAndCourseMapper . queryProject ( courseId ) ;
projectAndCourseMapper . addBatchTeachProject ( experimentalClassId , courseId , projectIds ) ;
//查询实验班级专业
public HashMap < String , Object > queryExperimentalClassSP ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryExperimentalClassSP ( experimentalClassId ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询实验班级专业失败!" ) ;
return resp ;
}
return resp ;
}
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "创建实验班级失败!" ) ;
throw e ;
}
return resp ;
}
//查询学生行政班级
public HashMap < String , Object > queryStudentClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryStudentClass ( experimentalClassId ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询学生行政 班级失败!" ) ;
return resp ;
}
return resp ;
}
public HashMap < String , Object > queryExperimentalClass ( Integer schoolId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryExperimentalClass ( schoolId ) ) ;
List < ExperimentalClass > a = experimentalClassMapper . queryExperimentalClass ( schoolId ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询实验 班级失败!" ) ;
return resp ;
}
return resp ;
}
/ * *
* 班级详情
* @param student
* @param courseId
* @return
* /
public HashMap < String , Object > queryExperimentalClassDetails ( Student student , Integer courseId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
//学生信息
List < Student > students = experimentalClassMapper . getExperimentalClassDetails ( student ) ;
//考勤数量
List < Project_Management > project = projectAndCourseMapper . getBySystemId ( courseId , 0 , 0 ) ;
int denominator = project . size ( ) ;
for ( int i = 0 ; i < students . size ( ) ; i + + ) {
Student stu = students . get ( i ) ;
Integer studentId = stu . getStudentId ( ) ;
int molecule = experimentalClassMapper . getAttendance ( studentId , courseId ) ;
stu . setAttendance ( molecule + "/" + denominator ) ;
}
resp . put ( "retvalue" , students ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询班级详情失败!" ) ;
return resp ;
}
return resp ;
}
//查询实验班级专业
public HashMap < String , Object > queryExperimentalClassSP ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryExperimentalClassSP ( experimentalClassId ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询实验班级专业失败!" ) ;
return resp ;
}
return resp ;
}
//查询学生行政班级
public HashMap < String , Object > queryStudentClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryStudentClass ( experimentalClassId ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询学生行政班级失败!" ) ;
return resp ;
}
return resp ;
}
//新增学生显示数据
public HashMap < String , Object > queryexperimentalClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < String , Object > ( ) ;
try {
List < ExperimentalClass > classes = experimentalClassMapper . queryExperimentalClassDetails1 ( experimentalClassId ) ;
List < Student > students = experimentalClassMapper . querystudent ( experimentalClassId ) ;
obj . put ( "experimentalClass" , classes ) ;
obj . put ( "students" , students ) ;
/ * *
* 班级详情
*
* @param student
* @param courseId
* @return
* /
public HashMap < String , Object > queryExperimentalClassDetails ( Student student , Integer courseId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
Integer experimentalClassId = Integer . parseInt ( student . getExperimentalClassId ( ) ) ;
//学生信息
List < Student > students = experimentalClassMapper . getExperimentalClassDetails ( student ) ;
//考勤数量
List < Project_Management > project = projectAndCourseMapper . getBySystemId ( courseId , experimentalClassId ) ;
int denominator = project . size ( ) ;
for ( int i = 0 ; i < students . size ( ) ; i + + ) {
Student stu = students . get ( i ) ;
Integer studentId = stu . getStudentId ( ) ;
int molecule = experimentalClassMapper . getAttendance ( studentId , courseId ) ;
stu . setAttendance ( molecule + "/" + denominator ) ;
}
resp . put ( "retvalue" , students ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询班级详情失败!" ) ;
return resp ;
}
return resp ;
}
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询失败!" ) ;
return resp ;
}
return resp ;
}
//新增学生显示数据
public HashMap < String , Object > queryexperimentalClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < String , Object > ( ) ;
try {
List < ExperimentalClass > classes = experimentalClassMapper . queryExperimentalClassDetails1 ( experimentalClassId ) ;
List < Student > students = experimentalClassMapper . querystudent ( experimentalClassId ) ;
obj . put ( "experimentalClass" , classes ) ;
obj . put ( "students" , students ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询失败!" ) ;
return resp ;
}
return resp ;
}
//专业下拉框
public HashMap < String , Object > getProfessionals ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
List < Professional > professionals = experimentalClassMapper . getProfessionals ( experimentalClassId ) ;
resp . put ( "retvalue" , professionals ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询专业失败!" ) ;
return resp ;
}
return resp ;
}
//专业下拉框
public HashMap < String , Object > getProfessionals ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
List < Professional > professionals = experimentalClassMapper . getProfessionals ( experimentalClassId ) ;
resp . put ( "retvalue" , professionals ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询专业失败!" ) ;
return resp ;
}
return resp ;
}
//班级下拉框
public HashMap < String , Object > getStudentClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
List < StuProfessionalArchitecture > professionals = experimentalClassMapper . getStudentClass ( experimentalClassId ) ;
resp . put ( "retvalue" , professionals ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询班级失败!" ) ;
return resp ;
}
return resp ;
}
//班级下拉框
public HashMap < String , Object > getStudentClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
List < StuProfessionalArchitecture > professionals = experimentalClassMapper . getStudentClass ( experimentalClassId ) ;
resp . put ( "retvalue" , professionals ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询班级失败!" ) ;
return resp ;
}
return resp ;
}
public HashMap < String , Object > deleteExperimentalClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . deleteExperimentalClass ( experimentalClassId ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "删除实验班级失败!" ) ;
return resp ;
}
return resp ;
}
public HashMap < String , Object > deleteExperimentalClass ( Integer experimentalClassId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . deleteExperimentalClass ( experimentalClassId ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "删除实验班级失败!" ) ;
return resp ;
}
return resp ;
}
public HashMap < String , Object > updateExperimentalClass ( ExperimentalClass experimentalClass ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . updateExperimentalClass ( experimentalClass ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "更新实验班级失败!" ) ;
return resp ;
}
return resp ;
}
public HashMap < String , Object > updateExperimentalClass ( ExperimentalClass experimentalClass ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . updateExperimentalClass ( experimentalClass ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "更新实验班级失败!" ) ;
return resp ;
}
return resp ;
}
//修改实验班级名称
public HashMap < String , Object > updateExperimentClassName ( ExperimentalClass experimentalClass ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . updateExperimentClassName ( experimentalClass ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "修改实验班级名称失败!" ) ;
return resp ;
}
return resp ;
}
//——————————————————————————————全承珠
public HashMap < String , Object > queryGetByExperimentalClassName ( String experimentalClassName ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
//修改实验班级名称
public HashMap < String , Object > updateExperimentClassName ( ExperimentalClass experimentalClass ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
experimentalClassMapper . updateExperimentClassName ( experimentalClass ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "修改实验班级名称失败!" ) ;
return resp ;
}
return resp ;
}
//——————————————————————————————全承珠
public HashMap < String , Object > queryGetByExperimentalClassName ( String experimentalClassName ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , experimentalClassMapper . queryGetByExperimentalClassName ( experimentalClassName ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Inquiry Failed" ) ;
return resp ;
}
return resp ;
}
try {
resp . put ( "retvalue" , experimentalClassMapper . queryGetByExperimentalClassName ( experimentalClassName ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Inquiry Failed" ) ;
return resp ;
}
return resp ;
}
}