Bladeren bron

fix:1、作业改造

Joburgess 4 jaren geleden
bovenliggende
commit
adcae1737d

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentAttendanceDto.java

@@ -23,8 +23,18 @@ public class StudentAttendanceDto {
     @ApiModelProperty(value = "备注",required = false)
     private String remark;
 
+    private String deviceNum;
+
     private List<StudentAttendance> studentAttendances;
 
+    public String getDeviceNum() {
+        return deviceNum;
+    }
+
+    public void setDeviceNum(String deviceNum) {
+        this.deviceNum = deviceNum;
+    }
+
     public String getRemark() {
         return remark;
     }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TeacherAttendance.java

@@ -102,6 +102,17 @@ public class TeacherAttendance {
 	@ApiModelProperty(value = "考勤申述凭证")
 	private String url;
 
+	@ApiModelProperty(value = "设备号")
+	private String deviceNum;
+
+	public String getDeviceNum() {
+		return deviceNum;
+	}
+
+	public void setDeviceNum(String deviceNum) {
+		this.deviceNum = deviceNum;
+	}
+
 	public String getUrl() {
 		return url;
 	}

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/listener/CourseEventListener.java

@@ -1,7 +1,10 @@
 package com.ym.mec.biz.event.listener;
 
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.event.CourseStatusChangeEvent;
 import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.StudentServeService;
 import com.ym.mec.common.redis.service.RedisCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -9,8 +12,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 /**
  * @Author qnc99
@@ -27,6 +34,10 @@ public class CourseEventListener {
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
     @Autowired
     private RedisCache<String, Object> redisCache;
+    @Autowired
+    private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Autowired
+    private StudentServeService studentServeService;
 
     @Async
     @EventListener
@@ -50,4 +61,29 @@ public class CourseEventListener {
             redisCache.delete(KEY);
         }
     }
+
+    @Async
+    @EventListener
+    public void courseStatusChangeMonitor2(CourseStatusChangeEvent courseStatusChangeEvent){
+        if(redisCache.getRedisTemplate().opsForValue().size("exercisesSituationStatistics2")>0){
+            return;
+        }
+
+        Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("exercisesSituationStatistics2", Thread.currentThread().getId(), 1, TimeUnit.HOURS);
+        if(!success){
+            return;
+        }
+
+
+        try{
+            List<CourseScheduleStudentPayment> cssps = courseScheduleStudentPaymentDao.findByCourseScheduleIds(new ArrayList<>(courseStatusChangeEvent.getCourseIds()));
+            if(CollectionUtils.isEmpty(cssps)){
+                return;
+            }
+            List<Integer> studentIds = cssps.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toList());
+            studentServeService.exercisesSituationStatistics2(null,studentIds);
+        } finally {
+            redisCache.delete("exercisesSituationStatistics2");
+        }
+    }
 }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -278,6 +278,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
         teacherAttendance.setSignOutStatus(isInScore?YesOrNoEnum.YES:YesOrNoEnum.NO);
         teacherAttendance.setCurrentClassTimes(classTimes + 1);
         teacherAttendance.setRemark(studentAttendanceInfos.getRemark());
+        teacherAttendance.setDeviceNum(studentAttendanceInfos.getDeviceNum());
         teacherAttendance.setSignOutAttachments(studentAttendanceInfos.getSignOutAttachments());
         if (Objects.nonNull(teacherAttendance.getId())) {
             teacherAttendanceDao.update(teacherAttendance);

+ 10 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -353,16 +353,12 @@ public class StudentServeServiceImpl implements StudentServeService {
                             "EXERCISE", null);
                     results.add(studentExtracurricularExercisesSituation);
                 }else{
-                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
+                    Map<Integer, List<StudentServeCourseDto>> teacherCourseMap = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId));
                     Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
-                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-                        if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
-                            teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
-                        }else{
-                            continue;
-                        }
-                        teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
+                    for (Map.Entry<Integer, List<StudentServeCourseDto>> teacherCourseMapEntry : teacherCourseMap.entrySet()) {
+                        StudentServeCourseDto courseInfo = teacherCourseMapEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
+                        teacherServiceCourseIdMap.put(teacherCourseMapEntry.getKey(), new HashSet<>());
+                        teacherServiceCourseIdMap.get(teacherCourseMapEntry.getKey()).add(courseInfo.getCourseScheduleId());
                     }
                     for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
                         StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
@@ -394,16 +390,12 @@ public class StudentServeServiceImpl implements StudentServeService {
                             "EXERCISE", null);
                     results.add(studentExtracurricularExercisesSituation);
                 }else{
-                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
+                    Map<Integer, List<StudentServeCourseDto>> teacherCourseMap = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId));
                     Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
-                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-                        if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
-                            teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
-                        }else{
-                            continue;
-                        }
-                        teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
+                    for (Map.Entry<Integer, List<StudentServeCourseDto>> teacherCourseMapEntry : teacherCourseMap.entrySet()) {
+                        StudentServeCourseDto courseInfo = teacherCourseMapEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
+                        teacherServiceCourseIdMap.put(teacherCourseMapEntry.getKey(), new HashSet<>());
+                        teacherServiceCourseIdMap.get(teacherCourseMapEntry.getKey()).add(courseInfo.getCourseScheduleId());
                     }
                     for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
                         StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),

+ 9 - 4
mec-biz/src/main/resources/config/mybatis/TeacherAttendanceMapper.xml

@@ -34,6 +34,7 @@
         <result column="sign_out_attachments_" property="signOutAttachments"/>
         <result column="sign_out_remark_" property="signOutRemark"/>
         <result column="url_" property="url"/>
+        <result column="device_num_" property="deviceNum"/>
     </resultMap>
     
     <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="Mapper">
@@ -58,12 +59,12 @@
         INSERT INTO teacher_attendance
         (group_type_,teacher_id_,music_group_id_,class_group_id_,course_schedule_id_,sign_in_time_,sign_in_status_,remark_,create_time_,sign_out_time_,
         sign_out_status_,current_class_times_,sign_in_longitude_latitude_,sign_out_longitude_latitude_,current_schedule_id_,sign_out_attachments_,
-        sign_out_remark_,update_attendance_type_,url_)
+        sign_out_remark_,update_attendance_type_,url_,device_num_)
         VALUES(#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{teacherId},
         #{musicGroupId},#{classGroupId},#{courseScheduleId},#{signInTime},#{signInStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{remark},
         now(),#{signOutTime},#{signOutStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{currentClassTimes},#{signInLongitudeLatitude},#{signOutLongitudeLatitude},#{currentScheduleId},#{signOutAttachments},#{signOutRemark},
-        #{updateAttendanceEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{url})
+        #{updateAttendanceEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{url},#{deviceNum})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.TeacherAttendance" useGeneratedKeys="true"
@@ -71,7 +72,7 @@
         INSERT INTO teacher_attendance
         (group_type_,teacher_id_,music_group_id_,class_group_id_,course_schedule_id_,sign_in_time_,sign_in_status_,
         remark_,create_time_,sign_out_time_,sign_out_status_,sign_in_longitude_latitude_,sign_out_longitude_latitude_,current_schedule_id_,sign_out_attachments_,
-        sign_out_remark_,update_attendance_type_,url_)
+        sign_out_remark_,update_attendance_type_,url_,device_num_)
         VALUE
         <foreach collection="teacherAttendances" item="teacherAttendance" separator=",">
             (#{teacherAttendance.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
@@ -82,7 +83,8 @@
             #{teacherAttendance.signOutStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             #{teacherAttendance.signInLongitudeLatitude},#{teacherAttendance.signOutLongitudeLatitude},#{teacherAttendance.currentScheduleId},
             #{teacherAttendance.signOutAttachments},#{teacherAttendance.signOutRemark},
-            #{teacherAttendance.updateAttendanceEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{teacherAttendance.url})
+            #{teacherAttendance.updateAttendanceEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{teacherAttendance.url},
+            #{teacherAttendance.deviceNum})
         </foreach>
     </insert>
 
@@ -162,6 +164,9 @@
             <if test="signOutRemark != null">
                 sign_out_remark_ = #{signOutRemark},
             </if>
+            <if test="deviceNum != null and deviceNum!=''">
+                device_num_ = #{deviceNum},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>