修改考核管理查看成绩页面+实验班级层级展示

master
pd 4 years ago
parent b59945cedf
commit fdc8a892a9
  1. 6
      src/main/java/com/yipin/liuwanr/Test.java
  2. 33
      src/main/java/com/yipin/liuwanr/controller/AssesmentController.java
  3. 10
      src/main/java/com/yipin/liuwanr/entity/Record.java
  4. 52
      src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java
  5. 68
      src/main/java/com/yipin/liuwanr/service/AssesmentService.java

@ -15,9 +15,9 @@ public class Test {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//方法一 //方法一
System.out.println((new Test()).getURLContent()); // System.out.println((new Test()).getURLContent());
String urlStr = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=40&sort=symbol&asc=1&node=hs_a&symbol=&_s_r_a=init"; // String urlStr = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=40&sort=symbol&asc=1&node=hs_a&symbol=&_s_r_a=init";
System.out.println((new Test()).getURLContent(urlStr)); // System.out.println((new Test()).getURLContent(urlStr));
} }

@ -367,12 +367,6 @@ public class AssesmentController {
if(StringUtils.isEmpty(assesmentId)){ if(StringUtils.isEmpty(assesmentId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("考核信息为空"); resp.setErrmessage("考核信息为空");
}else if(StringUtils.isEmpty(experimentalClassId)){
resp.setStatus(300);
resp.setErrmessage("实验班级信息为空");
}else if(StringUtils.isEmpty(classId)){
resp.setStatus(300);
resp.setErrmessage("行政信息为空");
}else{ }else{
HashMap<String, Object> ret = service.queryScore(assesmentId,experimentalClassId,classId); HashMap<String, Object> ret = service.queryScore(assesmentId,experimentalClassId,classId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
@ -397,18 +391,11 @@ public class AssesmentController {
* @return * @return
*/ */
@GetMapping("/queryHistogram") @GetMapping("/queryHistogram")
Response queryHistogram(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId, Response queryHistogram(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) {
@RequestParam List<Integer> classId) {
Response resp = new Response(); Response resp = new Response();
if(StringUtils.isEmpty(assesmentId)){ if(StringUtils.isEmpty(assesmentId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("考核信息为空"); resp.setErrmessage("考核信息为空");
}else if(StringUtils.isEmpty(experimentalClassId)){
resp.setStatus(300);
resp.setErrmessage("实验班级信息为空");
}else if(classId.isEmpty()&&classId.size()<0){
resp.setStatus(300);
resp.setErrmessage("行政信息为空");
}else { }else {
HashMap<String, Object> ret = service.queryHistogram(assesmentId, experimentalClassId, classId); HashMap<String, Object> ret = service.queryHistogram(assesmentId, experimentalClassId, classId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
@ -432,18 +419,11 @@ public class AssesmentController {
* @return * @return
*/ */
@GetMapping("/getLinechart") @GetMapping("/getLinechart")
Response getLinechart(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId, Response getLinechart(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) {
@RequestParam List<Integer> classId) {
Response resp = new Response(); Response resp = new Response();
if(StringUtils.isEmpty(assesmentId)){ if(StringUtils.isEmpty(assesmentId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("考核信息为空"); resp.setErrmessage("考核信息为空");
}else if(StringUtils.isEmpty(experimentalClassId)){
resp.setStatus(300);
resp.setErrmessage("实验班级信息为空");
}else if(classId.isEmpty()&&classId.size()<0){
resp.setStatus(300);
resp.setErrmessage("行政信息为空");
}else{ }else{
HashMap<String, Object> ret = service.getLinechart(assesmentId,experimentalClassId,classId); HashMap<String, Object> ret = service.getLinechart(assesmentId,experimentalClassId,classId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
@ -467,18 +447,11 @@ public class AssesmentController {
* @return * @return
*/ */
@GetMapping("/queryAssesmentScore") @GetMapping("/queryAssesmentScore")
Response queryAssesmentScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId, Response queryAssesmentScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) {
@RequestParam List<Integer> classId) {
Response resp = new Response(); Response resp = new Response();
if(StringUtils.isEmpty(assesmentId)){ if(StringUtils.isEmpty(assesmentId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("考核信息为空"); resp.setErrmessage("考核信息为空");
}else if(StringUtils.isEmpty(experimentalClassId)){
resp.setStatus(300);
resp.setErrmessage("实验班级信息为空");
}else if(classId.isEmpty()&&classId.size()<0){
resp.setStatus(300);
resp.setErrmessage("行政信息为空");
}else{ }else{
HashMap<String, Object> ret = service.queryAssesmentScore(assesmentId,experimentalClassId,classId); HashMap<String, Object> ret = service.queryAssesmentScore(assesmentId,experimentalClassId,classId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");

@ -17,6 +17,16 @@ public class Record {
private Integer integral; private Integer integral;
private String projectName; private String projectName;
private String studentName;
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
private Integer number; private Integer number;
public Integer getNumber() { public Integer getNumber() {

@ -127,7 +127,8 @@ public interface AssesmentMapper {
* @param studentIds * @param studentIds
* @return * @return
*/ */
@Select({"<script>", "select classId from student WHERE studentId in " @Select({"<script>",
"select classId from student WHERE studentId in "
+ "<foreach collection='studentIds' item='stu' open='(' separator=',' close=')'>#{stu}</foreach> ", + "<foreach collection='studentIds' item='stu' open='(' separator=',' close=')'>#{stu}</foreach> ",
"GROUP BY classId", "GROUP BY classId",
"</script>"}) "</script>"})
@ -186,7 +187,7 @@ public interface AssesmentMapper {
* @return * @return
*/ */
@Select("select DISTINCT DATE_FORMAT(creationTime,'%Y') as creationTime from experimental_class_ning " + @Select("select DISTINCT DATE_FORMAT(creationTime,'%Y') as creationTime from experimental_class_ning " +
" WHERE isdel=0 and founder=(select staffName from staff where staffId=#{staffId}) and schoolId={schoolId} GROUP BY creationTime ORDER BY creationTime desc ") " WHERE isdel=0 and founder=(select staffName from staff where staffId=#{staffId}) and schoolId=#{schoolId} GROUP BY creationTime ORDER BY creationTime desc ")
List<ExperimentalClass> queryCreationTime(@Param("staffId") Integer staffId,@Param("schoolId")Integer schoolId); List<ExperimentalClass> queryCreationTime(@Param("staffId") Integer staffId,@Param("schoolId")Integer schoolId);
@ -234,12 +235,12 @@ public interface AssesmentMapper {
@Select("SELECT c.classId as classId,c.className as className from assessment ass left join class c on FIND_IN_SET(c.classId,ass.classId) where ass.id=#{assesmentId}") @Select("SELECT c.classId as classId,c.className as className from assessment ass left join class c on FIND_IN_SET(c.classId,ass.classId) where ass.id=#{assesmentId}")
List<SutdentClass> queryClass(Integer assesmentId); List<SutdentClass> queryClass(Integer assesmentId);
//s.isdel=0 and
@Select("select s.studentId,studentName from student s left join experimental_class_student ecs on s.studentId=ecs.studentId where s.isdel=0 and ecs.experimentalClassId=#{experimentalClassId} ") @Select("select s.studentId,studentName from student s left join experimental_class_student ecs on s.studentId=ecs.studentId where ecs.experimentalClassId=#{experimentalClassId} ")
List<Student> getByExperimentalClassId(Integer experimentalClassId); List<Student> getByExperimentalClassId(Integer experimentalClassId);
//isdel=0 and
@Select("SELECT studentId,studentName from student where isdel=0 and classId=#{classId} ") @Select("SELECT studentId,studentName from student where classId=#{classId} ")
List<Student> getByclassId(Integer classId); List<Student> getByclassId(Integer classId);
@ -257,23 +258,13 @@ public interface AssesmentMapper {
/** /**
* 分组查询分数和对应人数 * 分组查询分数和对应人数
*
* @param assesmentId
* @param experimentalClassId
* @param classId
* @return
*/ */
@Select({"<script>", @Select({"<script>",
"select re.score as score,count(re.recordId) as number FROM (record re left join assessment ass on ass.id=re.assesmentId) left join student stu on re.studentId=stu.studentId " "select score,count(studentId) as number from record where assesmentId=#{assesmentId}",
+ " where re.assesmentId=#{assesmentId} ", "<foreach collection='students' item='stu' open='and studentId in (' separator=',' close=')'>#{stu.studentId}</foreach>",
" <if test=' experimentalClassId!=null '> and FIND_IN_SET(#{experimentalClassId},stu.experimentalClassId) </if>", " and score is not null GROUP BY score",
" <if test=' classId!=null '>"
+ "<foreach collection='classId' item='id' open='and stu.classId in (' separator=',' close=')'>#{id}</foreach>"
+ "</if>",
" and re.score is not null GROUP BY re.score",
"</script>"}) "</script>"})
List<Record> queryScore2(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, List<Record> getGroupByScore(@Param("assesmentId") Integer assesmentId,@Param("students") List<Student> students);
@Param("classId") List<Integer> classId);
/** /**
@ -312,28 +303,21 @@ public interface AssesmentMapper {
* @return * @return
*/ */
@Select({"<script>", @Select({"<script>",
"select judgmentPointsName,count(pr.judgmentPointsId) as number from PointRecord pr left join hr_judgment_points jp on pr.judgmentPointsId=jp.judgmentPointsId where rightAndWrong=-1 and assesmentId=#{assesmentId} ", "select judgmentPointsName,count(pr.judgmentPointsId) as number from PointRecord pr left join hr_judgment_points jp on pr.judgmentPointsId=jp.judgmentPointsId "
+ "where rightAndWrong=-1 and assesmentId=#{assesmentId} ",
" <if test='experimentalClassId!=null '> and experimentalClassId=#{experimentalClassId}</if>", " <if test='experimentalClassId!=null '> and experimentalClassId=#{experimentalClassId}</if>",
" <if test='classId!=null '>" " <if test='classId!=null '> and classId =#{classId} </if>",
+ "<foreach collection='classId' item='id' open='and classId in (' separator=',' close=')'>#{id} </foreach>"
+ "</if>",
"GROUP BY pr.judgmentPointsId", "GROUP BY pr.judgmentPointsId",
"</script>"}) "</script>"})
List<PointRecord> queryError(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, List<PointRecord> queryError(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId,
@Param("classId") List<Integer> classId); @Param("classId") Integer classId);
@Select({"<script>", @Select({"<script>",
"select stu.studentName as studentName,re.score as score FROM (record re left join assessment ass on ass.id=re.assesmentId) left join student stu on re.studentId=stu.studentId " "select studentName,score from record r left join student s on r.studentId=s.studentId where r.assesmentId=#{assesmentId}",
+ " where re.assesmentId=#{assesmentId} ", "<foreach collection='students' item='stu' open=' and r.studentId in (' separator=',' close=')'> #{stu.studentId} </foreach>",
" <if test=' experimentalClassId!=null '>and FIND_IN_SET(#{experimentalClassId},stu.experimentalClassId) </if>",
" <if test=' classId!=null '>"
+ "<foreach collection='classId' item='id' open='and stu.classId in (' separator=',' close=')'> #{id} </foreach>"
+ "</if>",
" and re.score is not null",
"</script>"}) "</script>"})
List<HashMap<String, Integer>> queryScore3(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, List<Record> queryScoreDetailed(@Param("assesmentId") Integer assesmentId,@Param("students") List<Student> students);
@Param("classId") List<Integer> classId);
//开始考核 //开始考核

@ -76,9 +76,9 @@ public class AssesmentService {
try { try {
//转换时间格式 //转换时间格式
assesment = AssesmentHelper.helpAssesment(assesment); assesment = AssesmentHelper.helpAssesment(assesment);
if (assesment.getExperimentalClassId() != null) { String experimentalClassId=assesment.getExperimentalClassId();
//行政班级id if (!StringUtils.isEmpty(experimentalClassId)) {
List<String> classid = mapper.queryClassId(studentIds); List<String> classid = mapper.queryClassId(studentIds);//行政班级id
String classId = String.join(",", classid); String classId = String.join(",", classid);
assesment.setClassId(classId); assesment.setClassId(classId);
} }
@ -92,13 +92,6 @@ public class AssesmentService {
//得到考核id //得到考核id
Integer assesmentId = assesment.getId(); Integer assesmentId = assesment.getId();
String name = assesment.getAssesmentName();
Integer number = mapper.getByAssesmentName(name);
if (number != null && number > 0) {
name += (number + 1);
assesment.setAssesmentName(name);
}
//往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目 //往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目
mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesmentId); mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesmentId);
@ -180,16 +173,14 @@ public class AssesmentService {
Assesment before = mapper.queryGetById(assesment.getId()); Assesment before = mapper.queryGetById(assesment.getId());
//数据库存储的学生 //数据库存储的学生
List<Student> students = mapper.queryStudent(assesment.getId()); List<Student> students = mapper.queryStudent(assesment.getId());
if (assesment.getExperimentalClassId() != null) { String experimentalClassId=assesment.getExperimentalClassId();
//新的行政班级id if (!StringUtils.isEmpty(experimentalClassId)) {
List<String> classid = mapper.queryClassId(studentIds); List<String> classid = mapper.queryClassId(studentIds);//新的行政班级id
String classId = String.join(",", classid); String classId = String.join(",", classid);
if (!classId.equals(before.getClassId())) { if (!classId.equals(before.getClassId())) {
assesment.setClassId(classId); assesment.setClassId(classId);
} else {
assesment.setClassId(before.getClassId());
} }
} else if (assesment.getClassId() != null) { } else if (!StringUtils.isEmpty(assesment.getClassId())) {
assesment.setExperimentalClassId(null); assesment.setExperimentalClassId(null);
} }
// 比较两批学生的信息 // 比较两批学生的信息
@ -217,13 +208,6 @@ public class AssesmentService {
Integer pointNumber = mapper.queryPointNumber(assesment.getExperimentId()); Integer pointNumber = mapper.queryPointNumber(assesment.getExperimentId());
assesment.setAssessmentNumber(pointNumber); assesment.setAssessmentNumber(pointNumber);
String name = assesment.getAssesmentName();
Integer number = mapper.getByAssesmentName(name);
if (number != null && number > 0) {
name += (number + 1);
assesment.setAssesmentName(name);
}
mapper.updateAssesment(assesment); mapper.updateAssesment(assesment);
resp.put("retcode", 200); resp.put("retcode", 200);
@ -391,7 +375,7 @@ public class AssesmentService {
try { try {
List<ExperimentalClass> experimentalClasses = mapper.queryExperimental(assesmentId); List<ExperimentalClass> experimentalClasses = mapper.queryExperimental(assesmentId);
List<SutdentClass> classes = mapper.queryClass(assesmentId); List<SutdentClass> classes = mapper.queryClass(assesmentId);
obj.put("xperimentalClass", experimentalClasses); obj.put("experimentalClass", experimentalClasses);
obj.put("class", classes); obj.put("class", classes);
resp.put("retvalue", obj); resp.put("retvalue", obj);
@ -412,15 +396,9 @@ public class AssesmentService {
public HashMap<String, Object> queryScore(Integer assesmentId, Integer experimentalClassId, Integer classId) { public HashMap<String, Object> queryScore(Integer assesmentId, Integer experimentalClassId, Integer classId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
Score score; Score score;
List<Student> students = null;
int size = 0; int size = 0;
try { try {
List<Student> students=queryStudents(experimentalClassId,classId);
if (experimentalClassId != null) {
students = mapper.getByExperimentalClassId(experimentalClassId);
} else if (classId != null) {
students = mapper.getByclassId(classId);
}
//判分点数量 //判分点数量
Integer pointNumber = mapper.getAssesmentNumber(assesmentId); Integer pointNumber = mapper.getAssesmentNumber(assesmentId);
if (StringUtils.isEmpty(pointNumber)) { if (StringUtils.isEmpty(pointNumber)) {
@ -467,7 +445,6 @@ public class AssesmentService {
} else { } else {
score = new Score(0.0, 0.0, 0, 0, 0, pointNumber, 0.0); score = new Score(0.0, 0.0, 0, 0, 0, pointNumber, 0.0);
} }
resp.put("retvalue", score); resp.put("retvalue", score);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (Exception e) { } catch (Exception e) {
@ -479,16 +456,25 @@ public class AssesmentService {
return resp; return resp;
} }
private List<Student> queryStudents(Integer experimentalClassId, Integer classId){
List<Student> students=null;
if (experimentalClassId != null) {
students = mapper.getByExperimentalClassId(experimentalClassId);
} else if (classId != null) {
students = mapper.getByclassId(classId);
}
return students;
}
/** /**
* 成绩柱状图 * 成绩柱状图
*
* @param assesmentId * @param assesmentId
* @param experimentalClassId * @param experimentalClassId
* @param classId * @param classId
* @return * @return
*/ */
public HashMap<String, Object> queryHistogram(Integer assesmentId, Integer experimentalClassId, List<Integer> classId) { public HashMap<String, Object> queryHistogram(Integer assesmentId, Integer experimentalClassId,Integer classId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
List<Integer> obj = new ArrayList<Integer>(); List<Integer> obj = new ArrayList<Integer>();
try { try {
@ -503,7 +489,9 @@ public class AssesmentService {
Integer nine = 0; Integer nine = 0;
Integer ten = 0; Integer ten = 0;
List<Record> scores = mapper.queryScore2(assesmentId, experimentalClassId, classId); List<Student> students=queryStudents(experimentalClassId,classId);
List<Record> scores = mapper.getGroupByScore(assesmentId,students);
for (int i = 0; i < scores.size(); i++) { for (int i = 0; i < scores.size(); i++) {
Integer score = scores.get(i).getScore(); Integer score = scores.get(i).getScore();
Integer number = scores.get(i).getNumber(); Integer number = scores.get(i).getNumber();
@ -563,7 +551,7 @@ public class AssesmentService {
* @param classId * @param classId
* @return * @return
*/ */
public HashMap<String, Object> getLinechart(Integer assesmentId, Integer experimentalClassId, List<Integer> classId) { public HashMap<String, Object> getLinechart(Integer assesmentId, Integer experimentalClassId,Integer classId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
List<Object> obj = new ArrayList<Object>(); List<Object> obj = new ArrayList<Object>();
try { try {
@ -599,10 +587,14 @@ public class AssesmentService {
* @param classId * @param classId
* @return * @return
*/ */
public HashMap<String, Object> queryAssesmentScore(Integer assesmentId, Integer experimentalClassId, List<Integer> classId) { public HashMap<String, Object> queryAssesmentScore(Integer assesmentId, Integer experimentalClassId,Integer classId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
resp.put("retvalue", mapper.queryScore3(assesmentId, experimentalClassId, classId)); List<Student> students=queryStudents(experimentalClassId,classId);
if(!students.isEmpty() && students.size()>0){
List<Record> records=mapper.queryScoreDetailed(assesmentId,students);
resp.put("retvalue",records );
}
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());

Loading…
Cancel
Save