Эх сурвалжийг харах

调课,小程序获取班级,老师

LIVE_YE 2 жил өмнө
parent
commit
6683f374ec

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/AppletController.java

@@ -49,4 +49,13 @@ public class AppletController {
         return  appletService.indexList(formalTeacherClass);
     }
 
+    /**
+     *
+     */
+    @GetMapping("/pc/statistics")
+    public AjaxResult pcStatistics()
+    {
+        return  appletService.pcStatistics();
+    }
+
 }

+ 6 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/course/CourseTableController.java

@@ -103,4 +103,10 @@ public class CourseTableController extends BaseController
     }
 
 
+    @GetMapping(value = "/now")
+    public AjaxResult now(Long schoolId, Long classId)
+    {
+        return courseTableService.now(schoolId,classId);
+    }
+
 }

+ 86 - 51
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -8,16 +8,17 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.util.Calendar;
 import java.util.Date;
+
 import org.apache.commons.lang3.time.DateFormatUtils;
 
 /**
  * 时间工具类
- * 
+ *
  * @author ruoyi
  */
-public class DateUtils extends org.apache.commons.lang3.time.DateUtils
-{
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static String YYYY = "yyyy";
 
     public static String YYYY_MM = "yyyy-MM";
@@ -29,63 +30,52 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
 
     private static String[] parsePatterns = {
-            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 
+            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
             "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
             "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
 
     /**
      * 获取当前Date型日期
-     * 
+     *
      * @return Date() 当前日期
      */
-    public static Date getNowDate()
-    {
+    public static Date getNowDate() {
         return new Date();
     }
 
     /**
      * 获取当前日期, 默认格式为yyyy-MM-dd
-     * 
+     *
      * @return String
      */
-    public static String getDate()
-    {
+    public static String getDate() {
         return dateTimeNow(YYYY_MM_DD);
     }
 
-    public static final String getTime()
-    {
+    public static final String getTime() {
         return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
     }
 
-    public static final String dateTimeNow()
-    {
+    public static final String dateTimeNow() {
         return dateTimeNow(YYYYMMDDHHMMSS);
     }
 
-    public static final String dateTimeNow(final String format)
-    {
+    public static final String dateTimeNow(final String format) {
         return parseDateToStr(format, new Date());
     }
 
-    public static final String dateTime(final Date date)
-    {
+    public static final String dateTime(final Date date) {
         return parseDateToStr(YYYY_MM_DD, date);
     }
 
-    public static final String parseDateToStr(final String format, final Date date)
-    {
+    public static final String parseDateToStr(final String format, final Date date) {
         return new SimpleDateFormat(format).format(date);
     }
 
-    public static final Date dateTime(final String format, final String ts)
-    {
-        try
-        {
+    public static final Date dateTime(final String format, final String ts) {
+        try {
             return new SimpleDateFormat(format).parse(ts);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             throw new RuntimeException(e);
         }
     }
@@ -93,8 +83,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如2018/08/08
      */
-    public static final String datePath()
-    {
+    public static final String datePath() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyy/MM/dd");
     }
@@ -102,8 +91,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如20180808
      */
-    public static final String dateTime()
-    {
+    public static final String dateTime() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyyMMdd");
     }
@@ -111,18 +99,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期型字符串转化为日期 格式
      */
-    public static Date parseDate(Object str)
-    {
-        if (str == null)
-        {
+    public static Date parseDate(Object str) {
+        if (str == null) {
             return null;
         }
-        try
-        {
+        try {
             return parseDate(str.toString(), parsePatterns);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             return null;
         }
     }
@@ -130,8 +113,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 获取服务器启动时间
      */
-    public static Date getServerStartDate()
-    {
+    public static Date getServerStartDate() {
         long time = ManagementFactory.getRuntimeMXBean().getStartTime();
         return new Date(time);
     }
@@ -139,20 +121,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 计算相差天数
      */
-    public static int differentDaysByMillisecond(Date date1, Date date2)
-    {
+    public static int differentDaysByMillisecond(Date date1, Date date2) {
         return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
     }
 
     /**
      * 计算时间差
      *
-     * @param endTime 最后时间
+     * @param endTime   最后时间
      * @param startTime 开始时间
      * @return 时间差(天/小时/分钟)
      */
-    public static String timeDistance(Date endDate, Date startTime)
-    {
+    public static String timeDistance(Date endDate, Date startTime) {
         long nd = 1000 * 24 * 60 * 60;
         long nh = 1000 * 60 * 60;
         long nm = 1000 * 60;
@@ -173,8 +153,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDateTime ==> Date
      */
-    public static Date toDate(LocalDateTime temporalAccessor)
-    {
+    public static Date toDate(LocalDateTime temporalAccessor) {
         ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
     }
@@ -182,10 +161,66 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDate ==> Date
      */
-    public static Date toDate(LocalDate temporalAccessor)
-    {
+    public static Date toDate(LocalDate temporalAccessor) {
         LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
         ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
     }
+
+    /**
+     * 判断当前日期是星期几
+     *
+     * @param pTime 修要判断的时间
+     * @return dayForWeek 判断结果
+     * @Exception 发生异常
+     */
+
+    public static int dayForWeek(String pTime) throws Exception {
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+
+        Calendar c = Calendar.getInstance();
+
+        c.setTime(format.parse(pTime));
+
+        int dayForWeek = 0;
+
+        if (c.get(Calendar.DAY_OF_WEEK) == 1) {
+
+            dayForWeek = 7;
+
+        } else {
+
+            dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
+
+        }
+
+        return dayForWeek;
+
+    }
+
+    /***
+     * 判断str3是否在str1与str2之间
+     * @param str1
+     * @param str2
+     * @param str3
+     * @param format 时间格式
+     * @return
+     * @throws Exception
+     */
+    public static Boolean isClass(String str1,String str2,String str3,String format) throws Exception {
+        //判断某个日期是否在两个日期范围之外
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
+        Date date1 = simpleDateFormat.parse(str1);
+        Date date2 = simpleDateFormat.parse(str2);
+        Date date3 = simpleDateFormat.parse(str3);
+        Boolean bl = true;
+        if (date1.getTime() > date3.getTime() || date2.getTime() < date3.getTime()) {
+            bl = false;
+        }
+        return bl;
+    }
+
+
+
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CourseTableMapper.java

@@ -58,4 +58,6 @@ public interface CourseTableMapper
      * @return 结果
      */
     public int deleteCourseTableByIds(Long[] ids);
+
+    CourseTable selectCourseTableByClassIdAndWeek(Long classId, int week);
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CourseTableTimeMapper.java

@@ -58,4 +58,6 @@ public interface CourseTableTimeMapper
      * @return 结果
      */
     public int deleteCourseTableTimeByIds(Long[] ids);
+
+    CourseTableTime selectCourseTableTimeBySchoolId(Long schoolId);
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IAppletService.java

@@ -12,4 +12,6 @@ public interface IAppletService {
     public void xiake(FormalTeacherClass formalTeacherClass);
     public AjaxResult index(FormalTeacherClass formalTeacherClass);
     public AjaxResult indexList(FormalTeacherClass formalTeacherClass);
+
+    AjaxResult pcStatistics();
 }

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ICourseTableService.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service;
 
 import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.system.domain.CourseTable;
 
 /**
@@ -58,4 +60,6 @@ public interface ICourseTableService
      * @return 结果
      */
     public int deleteCourseTableById(Long id);
+
+    AjaxResult now(Long schoolId,Long classId);
 }

+ 35 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AppletServiceImpl.java

@@ -2,7 +2,10 @@ package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
+import com.ruoyi.common.core.domain.entity.SysRole;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.system.service.IAppletService;
@@ -103,4 +106,36 @@ public class AppletServiceImpl implements IAppletService {
         }
         return AjaxResult.success(list);
     }
+
+    @Override
+    public AjaxResult pcStatistics() {
+        Map<String,Object> map = new HashMap<>();
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        List<SysRole> roles = user.getRoles();
+        boolean blt = false;
+        boolean bls = false;
+        for (SysRole role : roles) {
+            if("teacher".equals(role.getRoleKey())){
+                blt = true;
+            }
+            if("school".equals(role.getRoleKey())){
+                bls = true;
+            }
+        }
+        //老师
+        if(blt){
+            //查询本月家长的审核数据
+
+
+        }
+        //学校
+        if(bls){
+
+        }
+        //两个都有
+        if(blt && bls){
+
+        }
+        return null;
+    }
 }

+ 89 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CourseTableServiceImpl.java

@@ -1,7 +1,16 @@
 package com.ruoyi.system.service.impl;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.system.domain.CourseTableTime;
+import com.ruoyi.system.mapper.CourseTableTimeMapper;
+import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.CourseTableMapper;
@@ -19,6 +28,8 @@ public class CourseTableServiceImpl implements ICourseTableService
 {
     @Autowired
     private CourseTableMapper courseTableMapper;
+    @Autowired
+    private CourseTableTimeMapper courseTableTimeMapper;
 
     /**
      * 查询课程
@@ -93,4 +104,82 @@ public class CourseTableServiceImpl implements ICourseTableService
     {
         return courseTableMapper.deleteCourseTableById(id);
     }
+
+    @SneakyThrows
+    @Override
+    public AjaxResult now(Long schoolId,Long classId) {
+        //SysUser user = SecurityUtils.getLoginUser().getUser();
+        Map<String,Object> map = new HashMap<>();
+        map.put("teacher","");
+        map.put("subject","");
+        //获取当前时间
+        String nowTime = DateUtils.getTime();
+        //判断当天是周几
+        int dayForWeek = DateUtils.dayForWeek(nowTime);
+        if(dayForWeek==6 || dayForWeek==7){
+            return AjaxResult.success(map);
+        }
+        //获取当前账号所属学校时间表
+        CourseTableTime courseTableTime = courseTableTimeMapper.selectCourseTableTimeBySchoolId(schoolId);
+        //判断当前时间是第几节课
+        int index = isClass(courseTableTime);
+        if(index == 0){
+            return AjaxResult.success(map);
+        }
+        //获取当前班级课程
+        CourseTable courseTable = courseTableMapper.selectCourseTableByClassIdAndWeek(classId,dayForWeek);
+        if(index == 1){
+            map.put("teacher",courseTable.getOneTeacher());
+            map.put("subject",courseTable.getOneClass());
+        }else if(index == 2){
+            map.put("teacher",courseTable.getTwoTeacher());
+            map.put("subject",courseTable.getTwoClass());
+        }else if(index == 3){
+            map.put("teacher",courseTable.getThreeTeacher());
+            map.put("subject",courseTable.getThreeClass());
+        }else if(index == 4){
+            map.put("teacher",courseTable.getFourTeacher());
+            map.put("subject",courseTable.getFourClass());
+        }else if(index == 5){
+            map.put("teacher",courseTable.getFiveTeacher());
+            map.put("subject",courseTable.getFiveClass());
+        }else if(index == 6){
+            map.put("teacher",courseTable.getSixTeacher());
+            map.put("subject",courseTable.getSixClass());
+        }else if(index == 7){
+            map.put("teacher",courseTable.getSevenTeacher());
+            map.put("subject",courseTable.getSevenClass());
+        }else if(index == 8){
+            map.put("teacher",courseTable.getEightTeacher());
+            map.put("subject",courseTable.getEightClass());
+        }
+
+        return AjaxResult.success(map);
+    }
+
+    @SneakyThrows
+    private int isClass(CourseTableTime courseTableTime) {
+        //获取当前时间
+        String nowTime = DateUtils.getTime();
+        int index = 0;
+        if(DateUtils.isClass(courseTableTime.getOneStartTime(),courseTableTime.getOneEndTime(),nowTime,"HH:mm:ss")){
+            index = 1;
+        }else if(DateUtils.isClass(courseTableTime.getTwoStartTime(),courseTableTime.getTwoEndTime(),nowTime,"HH:mm:ss")){
+            index = 2;
+        }else if(DateUtils.isClass(courseTableTime.getThreeStartTime(),courseTableTime.getThreeEndTime(),nowTime,"HH:mm:ss")){
+            index = 3;
+        }else if(DateUtils.isClass(courseTableTime.getFourStartTime(),courseTableTime.getFourEndTime(),nowTime,"HH:mm:ss")){
+            index = 4;
+        }else if(DateUtils.isClass(courseTableTime.getFiveStartTime(),courseTableTime.getFiveEndTime(),nowTime,"HH:mm:ss")){
+            index = 5;
+        }else if(DateUtils.isClass(courseTableTime.getSixStartTime(),courseTableTime.getSixEndTime(),nowTime,"HH:mm:ss")){
+            index = 6;
+        }else if(DateUtils.isClass(courseTableTime.getSevenStartTime(),courseTableTime.getSevenEndTime(),nowTime,"HH:mm:ss")){
+            index = 7;
+        }else if(DateUtils.isClass(courseTableTime.getEightStartTime(),courseTableTime.getEightEndTime(),nowTime,"HH:mm:ss")){
+            index = 8;
+        }
+        return index;
+    }
+
 }

+ 5 - 1
ruoyi-system/src/main/resources/mapper/system/CourseTableMapper.xml

@@ -67,7 +67,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectCourseTableVo"/>
         where id = #{id}
     </select>
-        
+    <select id="selectCourseTableByClassIdAndWeek" resultMap="CourseTableResult">
+        <include refid="selectCourseTableVo"/>
+        where class_id = #{classId} and week = #{week}
+    </select>
+
     <insert id="insertCourseTable" parameterType="CourseTable" useGeneratedKeys="true" keyProperty="id">
         insert into course_table
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 7 - 2
ruoyi-system/src/main/resources/mapper/system/CourseTableTimeMapper.xml

@@ -37,7 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectCourseTableTimeList" parameterType="CourseTableTime" resultMap="CourseTableTimeResult">
         <include refid="selectCourseTableTimeVo"/>
-        <where>  
+        <where>
+            <if test="schoolId != null  and schoolId != 0"> and school_id = #{schoolId}</if>
             <if test="schoolName != null  and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
             <if test="oneStartTime != null  and oneStartTime != ''"> and one_start_time = #{oneStartTime}</if>
             <if test="oneEndTime != null  and oneEndTime != ''"> and one_end_time = #{oneEndTime}</if>
@@ -62,7 +63,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectCourseTableTimeVo"/>
         where id = #{id}
     </select>
-        
+    <select id="selectCourseTableTimeBySchoolId" resultMap="CourseTableTimeResult">
+        <include refid="selectCourseTableTimeVo"/>
+        where school_id = #{schoolId}
+    </select>
+
     <insert id="insertCourseTableTime" parameterType="CourseTableTime" useGeneratedKeys="true" keyProperty="id">
         insert into course_table_time
         <trim prefix="(" suffix=")" suffixOverrides=",">