koul 6 vuotta sitten
vanhempi
commit
46f93042a7

+ 12 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/StuScoreDO.java

@@ -23,11 +23,13 @@ public class StuScoreDO implements Serializable {
 	private String scoreType;
 	//考试科目
 	private Long subjectId;
+	//科目名
 	private String subjectName;
 	//名称
 	private String scoreName;
 	//学生
 	private Long stuId;
+	//学生姓名
 	private String stuName;
 	//分值
 	private Double scoreTotal;
@@ -41,6 +43,16 @@ public class StuScoreDO implements Serializable {
 	private String scoreRemarks;
 	//学校
 	private Long schoolId;
+	//班级id
+	private Long classId;
+	//班级名
+	private String className;
+	//年级id
+	private Long gradeId;
+	//年级名
+	private String gradeName;
+	//标题
+	private String examTitle;
 
 
 }

+ 86 - 48
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxStuScoreServiceImpl.java

@@ -1,11 +1,11 @@
 package com.usoftchina.smartschool.school.wxschool.basic.service.impl;
 
-import com.usoftchina.smartschool.school.wxschool.mapper.WxClazzMapper;
-import com.usoftchina.smartschool.school.wxschool.mapper.WxStuScoreMapper;
-import com.usoftchina.smartschool.school.wxschool.mapper.WxStudentMapper;
 import com.usoftchina.smartschool.school.po.StuScoreDO;
 import com.usoftchina.smartschool.school.po.StudentDO;
 import com.usoftchina.smartschool.school.wxschool.basic.service.WxStuScoreService;
+import com.usoftchina.smartschool.school.wxschool.mapper.WxClazzMapper;
+import com.usoftchina.smartschool.school.wxschool.mapper.WxStuScoreMapper;
+import com.usoftchina.smartschool.school.wxschool.mapper.WxStudentMapper;
 import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -43,57 +43,95 @@ public class WxStuScoreServiceImpl implements WxStuScoreService {
 		if (ObjectUtils.isNotEmpty(stuScoreDOS)){
 			List<Map> maps = new ArrayList<>();
 			List<Long> longs = new ArrayList<>();
-			List<StudentDO> studentDOS = studentMapper.listByClazzId(studentMapper.get(stuId).getClazzId());
-			if (ObjectUtils.isNotEmpty(studentDOS)){
-				for (StudentDO st:studentDOS) {
-					longs.add(st.getStuId());
-				}
-			}
+            StudentDO studentDO = studentMapper.get(stuId);
+            if (ObjectUtils.isNotEmpty(studentDO)){
+                Long clazzId = studentDO.getClazzId();
+                if (ObjectUtils.isNotEmpty(clazzId)){
+                    List<StudentDO> studentDOS = studentMapper.listByClazzId(clazzId);
+                    if (ObjectUtils.isNotEmpty(studentDOS)){
+                        for (StudentDO st:studentDOS) {
+                            longs.add(st.getStuId());
+                        }
+                    }
+                }
+            }
 			for (StuScoreDO ss:stuScoreDOS) {
 				Map<String, Object> map = new HashMap<>();
-				List<StuScoreDO> stuScoreDOS1 = stuScoreMapper.selectScoreListByStuId(longs, ss.getScoreType(), ss.getSubjectId());
-				if (ObjectUtils.isNotEmpty(stuScoreDOS1)) {
-					Double m = 0.0;
-					for (int j = 0; j < stuScoreDOS1.size(); j++) {
-						StuScoreDO score = stuScoreDOS1.get(j);
-						Long stuId1 = score.getStuId();
-						if (stuId.compareTo(stuId1) == 0) {
-							score.setStuName(studentMapper.get(stuId1).getStuName());
-							map.put("scoreBasic", score);
-							map.put("classRank", j + 1);
-							map.put("title", clazzMapper.get(studentMapper.get(stuId).getClazzId()).getClazzName() + score.getScoreName() + score.getScoreType());
-						}
-						m = m + score.getScoreNum();
-					}
-					map.put("classAverage", new BigDecimal(m / stuScoreDOS1.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
-					//一个班级
-					List<Long> clazzIds = clazzMapper.getByClazzId(studentMapper.get(stuId).getClazzId());
-					List<Long> list = new ArrayList<>();
-					for (Long clazzId:clazzIds) {
-						List<Long> stuIds = studentMapper.selectStuIdsByClazzId(clazzId);
-						list.addAll(stuIds);
-					}
-					List<StuScoreDO> scores = stuScoreMapper.selectScoreListByStuId(list,ss.getScoreType(), ss.getSubjectId());
-					Double n = 0.0;
-					for (int k = 0; k < scores.size(); k++) {
-						StuScoreDO score = scores.get(k);
-						if (stuId.compareTo(score.getStuId()) == 0) {
-							if ("全年级".equals(score.getScoreScope())) {
-								map.put("schoolRank", k + 1);
-							} else {
-								map.put("schoolRank", "-");
-							}
-						}
-						n = n + score.getScoreNum();
-					}
-					map.put("schoolAverage", new BigDecimal(n / scores.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
-					maps.add(map);
-				}
+				if (ObjectUtils.isNotEmpty(ss.getScoreType())&&ObjectUtils.isNotEmpty(ss.getSubjectId())){
+                    List<StuScoreDO> stuScoreDOS1 = stuScoreMapper.selectScoreListByStuId(longs, ss.getScoreType(), ss.getSubjectId());
+                    if (ObjectUtils.isNotEmpty(stuScoreDOS1)) {
+                        Double m = 0.0;
+                        for (int j = 0; j < stuScoreDOS1.size(); j++) {
+                            StuScoreDO score = stuScoreDOS1.get(j);
+                            Long stuId1 = score.getStuId();
+                            if (stuId.compareTo(stuId1) == 0) {
+                                score.setStuName(score.getStuName());
+                                map.put("scoreBasic", score);
+                                map.put("classRank", j + 1);
+                                map.put("title",score.getExamTitle());
+                            }
+                            m = m + score.getScoreNum();
+                        }
+                        map.put("classAverage", new BigDecimal(m / stuScoreDOS1.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+                        //一个班级
+                        List<Long> clazzIds = clazzMapper.getByClazzId(studentMapper.get(stuId).getClazzId());
+                        List<Long> list = new ArrayList<>();
+                        for (Long clazzId:clazzIds) {
+                            List<Long> stuIds = studentMapper.selectStuIdsByClazzId(clazzId);
+                            list.addAll(stuIds);
+                        }
+                        List<StuScoreDO> scores = stuScoreMapper.selectScoreListByStuId(list,ss.getScoreType(), ss.getSubjectId());
+                        Double n = 0.0;
+                        for (int k = 0; k < scores.size(); k++) {
+                            StuScoreDO score = scores.get(k);
+                            if (stuId.compareTo(score.getStuId()) == 0) {
+                                if ("全年级".equals(score.getScoreScope())) {
+                                    map.put("schoolRank", k + 1);
+                                } else {
+                                    map.put("schoolRank", "-");
+                                }
+                            }
+                            n = n + score.getScoreNum();
+                        }
+                        map.put("schoolAverage", new BigDecimal(n / scores.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+                        maps.add(map);
+                    }
+                }
 			}
 			return maps;
 		}else {
 			throw new Exception("暂无数据");
 		}
 	}
-	
+
+
+
+    /*public List<Map> getScoreList(Long stuId, Integer pageIndex, Integer pageSize) throws Exception{
+        Integer pageStart = (pageIndex-1)*pageSize;
+        List<StuScoreDO> stuScoreDOS = stuScoreMapper.listByStu(stuId, pageStart, pageSize);
+        if (ObjectUtils.isNotEmpty(stuScoreDOS)){
+            List<Long> list = new ArrayList<>();
+            for (StuScoreDO ss:stuScoreDOS) {
+                Long classId = ss.getClassId();
+                if (ObjectUtils.isNotEmpty(classId)){
+                    List<Long> longs = studentMapper.selectStuIdsByClazzId(classId);
+
+                    list.addAll(longs);
+                }
+            }
+
+        }
+    }*/
+
+
+
+    private static List removeDuplicate(List list){
+        List listTemp = new ArrayList();
+        for(int i=0;i<list.size();i++){
+            if(!listTemp.contains(list.get(i))){
+                listTemp.add(list.get(i));
+            }
+        }
+        return listTemp;
+    }
 }

+ 40 - 4
applications/school/school-server/src/main/resources/mapper/WxStuScoreMapper.xml

@@ -4,7 +4,7 @@
 <mapper namespace="com.usoftchina.smartschool.school.wxschool.mapper.WxStuScoreMapper">
 
     <sql id="StuScoreVo">
-    select `score_id`,`score_type`,`score_name`,`stu_id`,`score_total`,`score_num`,`score_scope`,`score_date`,`score_remarks`,`school_id`,`subject_id` from stu_score
+    select `score_id`,`score_type`,`score_name`,`stu_id`,`score_total`,`score_num`,`score_scope`,`score_date`,`score_remarks`,`school_id`,`subject_id`,`stu_name`,`subject_name`,`class_id`,`class_name`,`grade_id`,`grade_name`,`exam_title` from stu_score
     </sql>
 
 	<select id="get" resultType="com.usoftchina.smartschool.school.po.StuScoreDO">
@@ -25,6 +25,14 @@
 		  		  <if test="scoreRemarks != null and scoreRemarks != ''"> and score_remarks = #{scoreRemarks} </if>
 		  		  <if test="schoolId != null and schoolId != ''"> and school_id = #{schoolId} </if>
 			<if test="subjectId != null and subjectId != ''"> and subject_id = #{subjectId} </if>
+			<if test="stuName != null and stuName != ''"> and stu_name = #{stuName} </if>
+			<if test="subjectName != null and subjectName != ''"> and subject_name = #{subjectName} </if>
+			<if test="classId != null and classId != ''"> and class_id = #{classId} </if>
+			<if test="className != null and className != ''"> and class_name = #{className} </if>
+			<if test="gradeId != null and gradeId != ''"> and grade_id = #{gradeId} </if>
+			<if test="gradeName != null and gradeName != ''"> and grade_name = #{gradeName} </if>
+			<if test="examTitle != null and examTitle != ''"> and exam_title = #{examTitle} </if>
+
 		  		</where>
         <choose>
             <when test="sort != null and sort.trim() != ''">
@@ -53,6 +61,13 @@
 		  		  <if test="scoreRemarks != null and scoreRemarks != ''"> and score_remarks = #{scoreRemarks} </if>
 		  		  <if test="schoolId != null and schoolId != ''"> and school_id = #{schoolId} </if>
 			 <if test="subjectId != null and subjectId != ''"> and subject_id = #{subjectId} </if>
+			 <if test="stuName != null and stuName != ''"> and stu_name = #{stuName} </if>
+			 <if test="subjectName != null and subjectName != ''"> and subject_name = #{subjectName} </if>
+			 <if test="classId != null and classId != ''"> and class_id = #{classId} </if>
+			 <if test="className != null and className != ''"> and class_name = #{className} </if>
+			 <if test="gradeId != null and gradeId != ''"> and grade_id = #{gradeId} </if>
+			 <if test="gradeName != null and gradeName != ''"> and grade_name = #{gradeName} </if>
+			 <if test="examTitle != null and examTitle != ''"> and exam_title = #{examTitle} </if>
 		  		</where>
 	</select>
 	 
@@ -68,7 +83,14 @@
 			`score_date`, 
 			`score_remarks`, 
 			`school_id`,
-			`subject_id`
+			`subject_id`,
+			`stu_name`,
+			`subject_name`,
+			`class_id`,
+			`class_name`,
+			`grade_id`,
+			`grade_name`,
+			`exam_title`
 		)
 		values
 		(
@@ -81,7 +103,14 @@
 			#{scoreDate}, 
 			#{scoreRemarks}, 
 			#{schoolId},
-			#{subjectId}
+			#{subjectId},
+			#{stuName},
+			#{subjectName},
+			#{classId},
+			#{className},
+			#{gradeId},
+			#{gradeName},
+			#{examTitle}
 		)
 	</insert>
 	 
@@ -97,7 +126,14 @@
 			<if test="scoreDate != null">`score_date` = #{scoreDate}, </if>
 			<if test="scoreRemarks != null">`score_remarks` = #{scoreRemarks}, </if>
 			<if test="schoolId != null">`school_id` = #{schoolId},</if>
-			<if test="subjectId != null and subjectId != ''"> subject_id = #{subjectId} </if>
+			<if test="subjectId != null"> `subject_id` = #{subjectId}, </if>
+			<if test="stuName != null "> `stu_name` = #{stuName}, </if>
+			<if test="subjectName != null"> `subject_name` = #{subjectName}, </if>
+			<if test="classId != null"> `class_id` = #{classId}, </if>
+			<if test="className != null "> `class_name` = #{className} ,</if>
+			<if test="gradeId != null "> `grade_id` = #{gradeId}, </if>
+			<if test="gradeName != null "> `grade_name` = #{gradeName}, </if>
+			<if test="examTitle != null "> `exam_title` = #{examTitle} </if>
 		</set>
 		where score_id = #{scoreId}
 	</update>