添加发布考核接口

master
pd 4 years ago
parent d1007821b2
commit 714afd3e1b
  1. 20
      src/main/java/com/yipin/liuwanr/controller/AssesmentController.java
  2. 16
      src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java
  3. 6
      src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java
  4. 21
      src/main/java/com/yipin/liuwanr/service/AssesmentService.java
  5. 58
      src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java

@ -385,5 +385,25 @@ public class AssesmentController {
return resp;
}
/**
* 发布考核
* @param courseId
* @return
*/
@GetMapping("/releaseAssesment")
Response releaseAssesment(@RequestParam Integer courseId){
Response resp = new Response();
HashMap<String, Object> ret = service.releaseAssesment(courseId);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
}
}

@ -259,22 +259,6 @@ public class ExperimentalClassController {
}
//新增学生
@PostMapping("/addStudent")
Response addStudent(@RequestBody ExperimentalClassVo vo) {
Response resp = new Response();
HashMap<String, Object> ret=classService.addStudent(vo);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
}
/**
* 查询学生行政班级
* @param experimentalClassId

@ -317,7 +317,11 @@ public interface AssesmentMapper {
+ "</if>",
" and re.score is not null",
"</script>"})
List<HashMap<String, Integer>> queryScore3(@Param("assesmentId")Integer assesmentId,@Param("experimentalClassId")Integer experimentalClassId,
List<HashMap<String, Integer>> queryScore3(@Param("assesmentId")Integer assesmentId,@Param("experimentalClassId")Integer experimentalClassId,
@Param("classId") List<Integer> classId);
//开始考核
@Select("select id,assesmentName from assessment where courseId=#{courseId} and releaseType=0 and assesmentState=0")
List<Assesment> releaseAssesment(Integer courseId);
}

@ -595,4 +595,25 @@ public class AssesmentService {
return resp;
}
/**
* 开启考核
* @param courseId
* @return
*/
public HashMap<String, Object> releaseAssesment(Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", mapper.releaseAssesment(courseId));
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
}

@ -47,7 +47,7 @@ public class ExperimentalClassService {
return resp;
}
//实验班级删除学生
//实验班级删除学生
public HashMap<String, Object> experimentClassDeleteStudent(List<Student> student){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
@ -156,62 +156,6 @@ public class ExperimentalClassService {
return resp;
}
//新增学生
public HashMap<String, Object> addStudent(ExperimentalClassVo vo){
HashMap<String, Object> resp = new HashMap<String,Object>();
ExperimentalClass experimentalClass=vo.getExperimentalClass();
List<Student> studeList=vo.getStudentList();
//存储班级原有的学生
List<Integer> oldstudeId=new ArrayList<Integer>();
//新增的学生
List<Integer> newstudeId=new ArrayList<Integer>();
try {
Integer experimentalClassId=experimentalClass.getExperimentalClassId();
List<Student> students=experimentalClassMapper.querystudent(experimentalClassId);
//取出学生id
for (Student student : students) {
oldstudeId.add(student.getStudentId());
}
//得到要添加的学生和要删除的学生
for (int i = 0; i < studeList.size(); i++) {
Integer id=studeList.get(i).getStudentId();
if(oldstudeId.contains(id)) {//新增的学生如果在数据库中,则删除oldstudeId中的学生
studeList.remove(i);
oldstudeId.remove(id);
i--;
}else {//新增的学生没有在数据库中,存储起来,在关系表中绑定
newstudeId.add(id);
}
}
//在实验班级绑定新学生
if(!newstudeId.isEmpty()&&newstudeId.size()>0) {
for (int i=0;i<newstudeId.size();i++) {
Student student=new Student();
student.setStudentId(newstudeId.get(i));
student.setIntExperimentalClassId(experimentalClassId);
experimentalClassMapper.experimentClassAddStudent(student);
}
}
//删除学生
if(!oldstudeId.isEmpty()&&newstudeId.size()>0) {
for (int i=0;i<oldstudeId.size();i++) {
Student student=new Student();
student.setStudentId(oldstudeId.get(i));
student.setIntExperimentalClassId(experimentalClassId);
experimentalClassMapper.experimentClassDeleteStudent(student);
}
}
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
//新增学生显示数据
public HashMap<String, Object> queryexperimentalClass(Integer experimentalClassId){

Loading…
Cancel
Save