liujc %!s(int64=2) %!d(string=hai) anos
pai
achega
d1a6bf2bf8

+ 12 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/DailySummaryOfClassesForTheCurrentSemesterWrapper.java

@@ -24,6 +24,15 @@ public class DailySummaryOfClassesForTheCurrentSemesterWrapper {
 
     @Data
     public static class DailySummaryOfClassesForTheCurrentSemesterDto{
+        @ApiModelProperty(value = "课程类型列表",required = false)
+        private List<DailySummaryOfClassesForTheCurrentSemesterDetailDto> dailySummaryOfClassesForTheCurrentSemesterDetailDtos;
+
+        @ApiModelProperty(value = "上课时间",required = false)
+        private LocalDate courseDate;
+    }
+
+    @Data
+    public static class DailySummaryOfClassesForTheCurrentSemesterDetailDto{
         @ApiModelProperty(value = "剩余课时数",required = false)
         private Integer subCourseNum;
 
@@ -32,9 +41,6 @@ public class DailySummaryOfClassesForTheCurrentSemesterWrapper {
 
         @ApiModelProperty(value = "课程类型",required = false)
         private CourseSchedule.CourseScheduleType scheduleType;
-
-        @ApiModelProperty(value = "上课时间",required = false)
-        private LocalDate courseDate;
     }
 
     @Data
@@ -43,5 +49,8 @@ public class DailySummaryOfClassesForTheCurrentSemesterWrapper {
         private List<DailySummaryOfClassesForTheCurrentSemesterDto> dailySummaryOfClassesForTheCurrentSemesterDtos;
 
         private String week;
+
+        @ApiModelProperty(value = "课程状态NOT_START,ING,END",required = false)
+        private String courseStatus;
     }
 }

+ 11 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/SchoolIndexStatWrapper.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 public class SchoolIndexStatWrapper {
 
     @Data
@@ -16,6 +18,9 @@ public class SchoolIndexStatWrapper {
         @ApiModelProperty("乐团编号")
         private String musicGroupId;
 
+        @ApiModelProperty("查询周期(week按周,month按月,term按学期)")
+        private String period;
+
         @ApiModelProperty("开始时间(年月日)")
         private String startTime;
 
@@ -102,7 +107,7 @@ public class SchoolIndexStatWrapper {
         private Integer totalNum = 0;
 
         @ApiModelProperty("出勤率")
-        private Integer attendanceRate = 0;
+        private BigDecimal attendanceRate = BigDecimal.ZERO;
     }
 
     @Data
@@ -110,19 +115,19 @@ public class SchoolIndexStatWrapper {
     public static class StudentLesson {
 
         @ApiModelProperty("应交人数")
-        private Integer expectNum;
+        private Integer expectNum = 0;
 
         @ApiModelProperty("实际提交人数")
-        private Integer actualNum;
+        private Integer actualNum = 0;
 
         @ApiModelProperty("合格提交人数")
-        private Integer passNum;
+        private Integer passNum = 0;
 
         @ApiModelProperty("提交率")
-        private Integer commitRate;
+        private BigDecimal commitRate = BigDecimal.ZERO;
 
         @ApiModelProperty("合格率")
-        private Integer passRate;
+        private BigDecimal passRate = BigDecimal.ZERO;
     }
 
 

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -6018,9 +6018,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
 		LocalDate startDate = LocalDate.parse(startTerm, formatter);
 		LocalDate endDate = LocalDate.parse(endTerm, formatter);
+		LocalDate now = LocalDate.now();
 		List<DailySummaryOfClassesForTheCurrentSemesterWrapper.DailySummaryOfClassesForTheCurrentSemesterMapDto> result = new ArrayList<>();
 		LocalDate currentWeekStart = startDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-		DateTimeFormatter format = DateTimeFormatter.ofPattern("yy年MM月dd日");
+		DateTimeFormatter format = DateTimeFormatter.ofPattern("MM月dd日");
 		StringBuffer sb;
 		int week = 0;
 		while (!currentWeekStart.isAfter(endDate)) {
@@ -6031,6 +6032,16 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			LocalDate currentWeekEnd = currentWeekStart.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
 			String endStart = currentWeekEnd.format(format);
 			sb.append(endStart).append(")");
+			// 判断课程状态
+			String courseStatus;
+			if (currentWeekEnd.isBefore(now)) {
+				courseStatus = "END";
+			} else if (currentWeekStart.isAfter(now)) {
+				courseStatus = "NOT_START";
+			} else {
+				courseStatus = "ING";
+			}
+			vo.setCourseStatus(courseStatus);
 			List<DailySummaryOfClassesForTheCurrentSemesterWrapper.DailySummaryOfClassesForTheCurrentSemesterDto> currentWeekDates = new ArrayList<>();
 			for (DailySummaryOfClassesForTheCurrentSemesterWrapper.DailySummaryOfClassesForTheCurrentSemesterDto dto : summary) {
 				if (!dto.getCourseDate().isBefore(currentWeekStart) && dto.getCourseDate().isBefore(currentWeekEnd)) {

+ 71 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SchoolIndexStatServiceImpl.java

@@ -9,11 +9,14 @@ import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.wrapper.SchoolIndexStatWrapper;
 import com.ym.mec.biz.service.SchoolIndexStatService;
 import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.Collator;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -53,6 +56,12 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
         Map<Integer, String> subjectMap = subjectDao.findBySubjectIds(subjectIdList).stream().collect(Collectors.toMap(Subject::getId, s -> s.getName(), (s1, s2) -> s1));
         //年级分布
         List<SchoolIndexStatWrapper.GradeDistribution> gradeDistributions = studentRegistrations.stream()
+                .map(e -> {
+                    if (e.getCurrentGrade() == null) {
+                        e.setCurrentGrade("一年级");
+                    }
+                    return e;
+                })
                 .collect(Collectors.groupingBy(
                         e -> e.getCurrentGrade(),
                         Collectors.collectingAndThen(
@@ -67,9 +76,10 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
                     distribution.setStudentNum(entry.getValue());
                     return distribution;
                 })
-                .sorted(Comparator.comparing(SchoolIndexStatWrapper.GradeDistribution::getGrade))
+                .sorted(Comparator.comparingInt(entry -> gradeOrder.indexOf(entry.getGrade())))
                 .collect(Collectors.toList());
         result.setGradeDistributions(gradeDistributions);
+
         //声部分布
         List<SchoolIndexStatWrapper.SubjectDistribution> subjectDistributions = studentRegistrations.stream()
                 .collect(Collectors.groupingBy(
@@ -121,6 +131,7 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
                 });
             });
         });
+        musicGradeDistributions.sort(Comparator.comparingInt(entry -> gradeOrder.indexOf(entry.getGrade())));
         result.setMusicGradeDistributions(musicGradeDistributions);
 
         //声部年级分组
@@ -145,6 +156,7 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
                 subjectGradeDistributions.add(gradeDistribution);
             }
         }
+        subjectGradeDistributions.sort(Comparator.comparingInt(entry -> gradeOrder.indexOf(entry.getGrade())));
         result.setSubjectGradeDistributions(subjectGradeDistributions);
         return result;
     }
@@ -160,12 +172,14 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
         if(CollectionUtils.isEmpty(musicGroupIds)){
             return new SchoolIndexStatWrapper.StudentAttendance();
         }
+        this.setTime(queryDto);
         //获取学员考勤数据
         SchoolIndexStatWrapper.StudentAttendance studentAttendance = studentAttendanceDao.statCoopAttendance(musicGroupIds,queryDto);
         if(Objects.nonNull(studentAttendance)){
-            int num = studentAttendance.getNormalNum() + studentAttendance.getLateNum();
+            Integer num = studentAttendance.getNormalNum() + studentAttendance.getLateNum();
             if(num > 0){
-                studentAttendance.setAttendanceRate(num / studentAttendance.getTotalNum());
+                studentAttendance.setAttendanceRate(new BigDecimal(num).
+                        divide(new BigDecimal(studentAttendance.getTotalNum()),4,BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2));
             }
         }
         return studentAttendance;
@@ -182,6 +196,59 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
         if(CollectionUtils.isEmpty(musicGroupIds)){
             return new SchoolIndexStatWrapper.StudentLesson();
         }
-        return lessonExaminationDao.schoolLessonStat(musicGroupIds,queryDto);
+        this.setTime(queryDto);
+        SchoolIndexStatWrapper.StudentLesson studentLesson = lessonExaminationDao.schoolLessonStat(musicGroupIds, queryDto);
+        if(Objects.nonNull(studentLesson)){
+            if(studentLesson.getActualNum() > 0){
+                studentLesson.setCommitRate(new BigDecimal(studentLesson.getActualNum()).
+                        divide(new BigDecimal(studentLesson.getExpectNum()),4,BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2));
+            }
+            if(studentLesson.getPassNum() > 0){
+                studentLesson.setPassRate(new BigDecimal(studentLesson.getPassNum()).
+                        divide(new BigDecimal(studentLesson.getExpectNum()),4,BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2));
+            }
+        }
+        return studentLesson;
+    }
+
+    private void setTime(SchoolIndexStatWrapper.QueryDto queryDto){
+        if(StringUtils.isNotEmpty(queryDto.getPeriod())){
+            Date now = new Date();
+            if(queryDto.getPeriod().equals("week")){
+                queryDto.setStartTime(DateUtil.format(DateUtil.getWeekDayWithDate(now,Calendar.MONDAY),DateUtil.DEFAULT_PATTERN));
+                queryDto.setEndTime(DateUtil.format(DateUtil.getWeekDayWithDate(now,Calendar.SUNDAY),DateUtil.DEFAULT_PATTERN));
+            }
+            if(queryDto.getPeriod().equals("month")){
+                DateUtil.getFirstDayOfMonth(now);
+                queryDto.setStartTime(DateUtil.format(DateUtil.getFirstDayOfMonth(now),DateUtil.DEFAULT_PATTERN));
+                queryDto.setEndTime(DateUtil.format(DateUtil.getLastDayOfMonth(now),DateUtil.DEFAULT_PATTERN));
+            }
+            if(queryDto.getPeriod().equals("term")){
+                queryDto.setStartTime(DateUtil.getStartTerm(now));
+                queryDto.setEndTime(DateUtil.getEndTerm(now));
+            }
+        }
     }
+
+    // 定义自定义顺序的列表
+    List<String> gradeOrder = Arrays.asList(
+            "一年级",
+            "二年级",
+            "三年级",
+            "四年级",
+            "五年级",
+            "六年级",
+            "六年级/初一",
+            "七年级/初一",
+            "初一/七年级",
+            "七年级/初二",
+            "八年级/初二",
+            "初二/八年级",
+            "八年级/初三",
+            "初三/九年级",
+            "九年级/初三",
+            "高一",
+            "高二",
+            "高三"
+    );
 }

+ 8 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -4246,8 +4246,14 @@
         </foreach>
         group by cs.type_
     </select>
-    <select id="getDailySummaryOfClassesForTheCurrentSemester"
-            resultType="com.ym.mec.biz.dal.wrapper.DailySummaryOfClassesForTheCurrentSemesterWrapper$DailySummaryOfClassesForTheCurrentSemesterDto">
+    <resultMap id="DailySummaryMap" type="com.ym.mec.biz.dal.wrapper.DailySummaryOfClassesForTheCurrentSemesterWrapper$DailySummaryOfClassesForTheCurrentSemesterDto">
+        <result property="courseDate" column="courseDate"/>
+        <collection property="dailySummaryOfClassesForTheCurrentSemesterDetailDtos" ofType="com.ym.mec.biz.dal.wrapper.DailySummaryOfClassesForTheCurrentSemesterWrapper$DailySummaryOfClassesForTheCurrentSemesterDetailDto">
+            <result property="totalCourseNum" column="totalCourseNum"/>
+            <result property="scheduleType" column="scheduleType"/>
+        </collection>
+    </resultMap>
+    <select id="getDailySummaryOfClassesForTheCurrentSemester" resultMap="DailySummaryMap">
         select cs.class_date_ courseDate,cs.type_ scheduleType,COUNT(cs.id_) totalCourseNum
         from course_schedule cs
         where cs.group_type_ = 'MUSIC' AND cs.is_lock_ = 0 AND cs.del_flag_ = 0 AND cs.pre_course_flag_ = 0 AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)

+ 2 - 4
mec-biz/src/main/resources/config/mybatis/LessonExaminationMapper.xml

@@ -162,9 +162,7 @@
         group by s.id_
     </select>
     <select id="schoolLessonStat" resultType="com.ym.mec.biz.dal.wrapper.SchoolIndexStatWrapper$StudentLesson">
-        select SUM(cs.expectNum) expectNum,SUM(cs.actualNum) actualNum,SUM(cs.passNum) passNum,
-        TRUNCATE(SUM(cs.actualNum)/SUM(cs.expectNum),1) commitRate,
-        TRUNCATE(SUM(cs.passNum)/SUM(cs.expectNum),1) passRate
+        select SUM(cs.expectNum) expectNum,SUM(cs.actualNum) actualNum,SUM(cs.passNum) passNum
         from (
         select ch.expect_num_ expectNum,ch.completed_num_ actualNum,ch.completed_num_ passNum from
         course_homework ch
@@ -184,7 +182,7 @@
             #{item}
         </foreach>
         AND cs.class_date_ BETWEEN #{queryDto.startTime} AND #{queryDto.endTime}
-        )
+        )cs
     </select>
 
 </mapper>