Jelajahi Sumber

Merge remote-tracking branch 'origin/Joburgess'

Joburgess 5 tahun lalu
induk
melakukan
4a065aaeaf

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.Student4operating;
+import com.ym.mec.biz.dal.dto.StudentServeDto;
 import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.enums.GroupType;
 import org.apache.ibatis.annotations.Param;
@@ -70,4 +71,13 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
      */
 
     List<Student> getServiceStudents();
+
+    /**
+     * @describe 查询被服务学员信息
+     * @author Joburgess
+     * @date 2020.05.27
+     * @param monday:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentServeDto>
+     */
+    List<StudentServeDto> getBeServiceStudents(@Param("monday") String monday);
 }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentServeDto.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.Student;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.05.27
+ */
+public class StudentServeDto extends Student {
+
+    private Date courseStartTime;
+
+    public Date getCourseStartTime() {
+        return courseStartTime;
+    }
+
+    public void setCourseStartTime(Date courseStartTime) {
+        this.courseStartTime = courseStartTime;
+    }
+}

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleTeacherSalary.java

@@ -176,7 +176,7 @@ public class CourseScheduleTeacherSalary {
 	public Integer getUserId(){
 		return this.userId;
 	}
-			
+
 	public void setExpectSalary(java.math.BigDecimal expectSalary){
 		this.expectSalary = expectSalary;
 	}

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentServeService.java

@@ -0,0 +1,18 @@
+package com.ym.mec.biz.service;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.05.27
+ */
+public interface StudentServeService {
+
+    /**
+     * @describe 学生服务信息统计
+     * @author Joburgess
+     * @date 2020/4/10
+     * @param :
+     * @return void
+     */
+    void exercisesSituationStatistics(String monday);
+
+}

+ 70 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -0,0 +1,70 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao;
+import com.ym.mec.biz.dal.dto.StudentServeDto;
+import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.service.StudentServeService;
+import com.ym.mec.util.date.DateUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.*;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.05.27
+ */
+@Service
+public class StudentServeServiceImpl implements StudentServeService {
+
+    @Autowired
+    private StudentDao studentDao;
+    @Autowired
+    private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
+
+    @Override
+    public void exercisesSituationStatistics(String monday) {
+        LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
+
+        if(nowDate.getDayOfWeek()== DayOfWeek.MONDAY){
+            int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.plusDays(-1).toString());
+            if(lastWeekTodayUpdateNum<=0){
+                nowDate = nowDate.plusDays(-1);
+            }
+        }
+
+        if(StringUtils.isNotBlank(monday)){
+            nowDate=LocalDate.parse(monday, DateUtil.dateFormatter);
+        }
+        LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
+        LocalDate sunDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
+        Date nextMonday = Date.from(sunDayDate.plusDays(1).atStartOfDay(DateUtil.zoneId).toInstant());
+
+        List<StudentServeDto> serviceStudents = studentDao.getBeServiceStudents(monDayDate.toString());
+        if(CollectionUtils.isEmpty(serviceStudents)){
+            return;
+        }
+
+        //本周有课学员编号集合
+        Set<Integer> haveClassStudentIds=new HashSet<>();
+        //本周无课学员编号集合
+        Set<Integer> noClassStudentIds=new HashSet<>();
+        for (StudentServeDto serviceStudent : serviceStudents) {
+            if(Objects.nonNull(serviceStudent.getCourseStartTime())&&serviceStudent.getCourseStartTime().after(nextMonday)){
+                continue;
+            }
+            if(Objects.nonNull(serviceStudent.getCourseStartTime())){
+                haveClassStudentIds.add(serviceStudent.getUserId());
+            }else{
+                noClassStudentIds.add(serviceStudent.getUserId());
+            }
+        }
+
+    }
+}

+ 19 - 0
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -330,4 +330,23 @@
         LEFT JOIN student s ON s.user_id_=su.id_
         WHERE s.service_tag_=1 AND FIND_IN_SET('STUDENT', su.user_type_)
     </select>
+
+    <resultMap id="StudentServeDto" type="com.ym.mec.biz.dal.dto.StudentServeDto" extends="Student">
+            <result property="courseStartTime" column="course_start_time_"/>
+    </resultMap>
+    <select id="getBeServiceStudents">
+        SELECT
+            s.*,
+            MIN( CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) ) course_start_time_
+        FROM
+            student s
+            LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
+            LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+            AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) &gt; #{monday}
+            AND cs.group_type_ IN ( 'MUSIC', 'PRACTICE' )
+        WHERE
+            s.service_tag_ = 1
+        GROUP BY
+            s.user_id_
+    </select>
 </mapper>