yonge %!s(int64=5) %!d(string=hai) anos
pai
achega
7ac6b4ab71

+ 13 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -9,11 +9,18 @@ import java.util.List;
 
 public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStudentMapper> {
 
+	/**
+	 * 批量插入学生
+	 * @param classGroupStudentMapperList
+	 * @return
+	 */
+	int classGroupStudentsInsert(@Param("classGroupStudentMapperList") List<ClassGroupStudentMapper> classGroupStudentMapperList);
 
-    /**
-     * 批量插入学生
-     * @param classGroupStudentMapperList
-     * @return
-     */
-    int classGroupStudentsInsert(@Param("classGroupStudentMapperList") List<ClassGroupStudentMapper> classGroupStudentMapperList);
+	/**
+	 * 根据班级和学生编号查询
+	 * @param classGroupId
+	 * @param userId
+	 * @return
+	 */
+	ClassGroupStudentMapper query(@Param("classGroupId") int classGroupId, @Param("userId") Integer userId);
 }

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

@@ -69,6 +69,9 @@ public class ClassGroup {
 
 	@ApiModelProperty(value = "当前课次",required = false)
 	private Integer currentClassTimes;
+	
+	@ApiModelProperty(value = "班级图标",required = false)
+	private String img;
 
 	public String getTeachMode() {
 		return teachMode;
@@ -198,6 +201,14 @@ public class ClassGroup {
 		this.expectStudentNum = expectStudentNum;
 	}
 
+	public String getImg() {
+		return img;
+	}
+
+	public void setImg(String img) {
+		this.img = img;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 31 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/StudentAttendanceService.java

@@ -1,33 +1,43 @@
 package com.ym.mec.biz.service;
 
+import java.util.List;
+import java.util.Map;
+
+import com.ym.mec.biz.dal.dto.StudentPersonalAttendanceDto;
 import com.ym.mec.biz.dal.entity.StudentAttendance;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
 
-import java.util.List;
-import java.util.Map;
-
 public interface StudentAttendanceService extends BaseService<Long, StudentAttendance> {
 
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/11
-     * 批量插入学生上课签到信息
-     */
-    void addStudentAttendances(List<StudentAttendance> studentAttendances);
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/11
+	 * 批量插入学生上课签到信息
+	 */
+	void addStudentAttendances(List<StudentAttendance> studentAttendances);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/16
+	 * 获取当前课程的学生
+	 */
+	Map<String, Object> getCurrentCourseStudents(QueryInfo queryInfo);
 
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/16
-     * 获取当前课程的学生
-     */
-    Map<String, Object> getCurrentCourseStudents(QueryInfo queryInfo);
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/16
+	 * 获取学生个人签到信息
+	 */
+	PageInfo<StudentPersonalAttendanceDto> getStudentPersonalAttendances(QueryInfo queryInfo);
 
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/16
-     * 获取学生个人签到信息
-     */
-    PageInfo getStudentPersonalAttendances(QueryInfo queryInfo);
+	/**
+	 * 请假
+	 * @param userId 用户编号
+	 * @param courseScheduleId 课程编号
+	 * @param remark 请假理由
+	 * @return
+	 */
+	boolean leave(Integer userId, Long courseScheduleId, String remark);
 }

+ 63 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -1,27 +1,37 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dao.CourseScheduleDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
 import com.ym.mec.biz.dal.dto.StudentPersonalAttendanceDto;
 import com.ym.mec.biz.dal.dto.StudentStatusCountUtilEntity;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.StudentAttendance;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
 import com.ym.mec.biz.service.StudentAttendanceService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.ym.mec.util.date.DateUtil;
 
 @Service
 public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentAttendance>  implements StudentAttendanceService {
@@ -32,6 +42,9 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 	private MusicGroupStudentFeeDao studentFeeDao;
 	@Autowired
 	private CourseScheduleDao courseScheduleDao;
+	
+	@Autowired
+	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 
 	@Override
 	public BaseDAO<Long, StudentAttendance> getDAO() {
@@ -73,7 +86,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 	public Map<String, Object> getCurrentCourseStudents(QueryInfo queryInfo) {
 		Map<String,Object> result=new HashMap<>();
 
-		PageInfo pageInfo = super.queryPage(queryInfo);
+		PageInfo<StudentAttendance> pageInfo = super.queryPage(queryInfo);
 
 		result.put("pageInfo",pageInfo);
 
@@ -84,6 +97,8 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 				case LEAVE:
 					result.put("numberOfLeavePeoples",studentStatusCount.getNumberOfStudent());
 					break;
+			default:
+				break;
 
 			}
 		});
@@ -92,7 +107,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 	}
 
 	@Override
-	public PageInfo getStudentPersonalAttendances(QueryInfo queryInfo) {
+	public PageInfo<StudentPersonalAttendanceDto> getStudentPersonalAttendances(QueryInfo queryInfo) {
 		PageInfo<StudentPersonalAttendanceDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 		Map<String, Object> params = new HashMap<String, Object>();
 		MapUtil.populateMap(params, queryInfo);
@@ -110,4 +125,43 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 		pageInfo.setRows(dataList);
 		return pageInfo;
 	}
+
+	@Override
+	@Transactional
+	public boolean leave(Integer userId, Long courseScheduleId, String remark) {
+		
+		CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
+		if(courseSchedule == null){
+			throw new BizException("课程编号异常");
+		}
+		
+		if(courseSchedule.getStatus() == CourseStatusEnum.OVER){
+			throw new BizException("课程已结束");
+		}
+		
+		Date date = new Date();
+		
+		if(DateUtil.addHours(date, 2).after(courseSchedule.getStartClassTime())){
+			throw new BizException("开课2个小时之前才可以请假");
+		}
+		
+		StudentAttendance studentAttendance  = new StudentAttendance();
+		studentAttendance.setClassGroupId(courseSchedule.getClassGroupId());
+		studentAttendance.setCourseScheduleId(courseScheduleId);
+		studentAttendance.setCreateTime(date);
+		studentAttendance.setCurrentClassTimes(0);
+		studentAttendance.setRemark(remark);
+		studentAttendance.setStatus(StudentAttendanceStatusEnum.LEAVE);
+		studentAttendance.setUserId(userId);
+		
+		studentAttendanceDao.insert(studentAttendance);
+		
+		ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.query(courseSchedule.getClassGroupId(), userId);
+		classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.LEAVE);
+		classGroupStudentMapperDao.update(classGroupStudentMapper);
+		
+		//发送消息至老师
+		
+		return true;
+	}
 }

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -17,6 +17,7 @@
         <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="expect_student_num_" property="expectStudentNum"/>
         <result column="total_class_times_" property="totalClassTimes"/>
+        <result column="img_" property="img"/>
         <!--<association property="musicGroupId" javaType="com.ym.mec.biz.dal.entity.MusicGroup" >-->
         <!--<result column="name_" property="name"/>-->
         <!--<result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>-->
@@ -52,6 +53,7 @@
             <if test="expectStudentNum!=null">expect_student_num_,</if>
             <if test="totalClassTimes!=null">total_class_times_,</if>
             <if test="currentClassTimes!=null">current_class_times_,</if>
+            <if test="img!=null">img_,</if>
         </trim>
         VALUES
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -66,6 +68,7 @@
             <if test="expectStudentNum!=null">#{expectStudentNum},</if>
             <if test="totalClassTimes!=null">#{totalClassTimes},</if>
             <if test="currentClassTimes!=null">#{currentClassTimes},</if>
+            <if test="img!=null">#{img},</if>
         </trim>
     </insert>
 
@@ -112,6 +115,9 @@
             <if test="currentClassTimes!=null">
                 current_class_times_=#{currentClassTimes},
             </if>
+            <if test="img!=null">
+                img_=#{img},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -71,4 +71,8 @@
             (#{item.id},#{item.classGroupId},#{item.userId},#{item.status},#{item.createTime})
         </foreach>
     </insert>
+    
+    <select id="query" resultMap="ClassGroupStudentMapper" parameterType="map">
+		SELECT * FROM class_group_student_mapper where class_group_id_ = #{classGroupId} and user_id_ = #{userId}
+	</select>
 </mapper>

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

@@ -259,7 +259,7 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
         }
         PageResponse response = new PageResponse();
 
-        IPage<StudentAttendance> page = new Page<>(req.getPageNo(),req.getPageSize());
+        IPage<StudentAttendance> page = new Page<StudentAttendance>(req.getPageNo(),req.getPageSize());
         IPage<StudentAttendance> studentAttendanceIPage = this.page(page,new QueryWrapper<StudentAttendance>().eq("course_schedule_id_",req.getCourseScheduleId()));
 
         List<CallStudentResp> callStudentResps = new ArrayList<>();

+ 55 - 47
mec-student/src/main/java/com/ym/mec/student/controller/StudentCourseScheduleController.java

@@ -1,21 +1,28 @@
 package com.ym.mec.student.controller;
 
-import com.ym.mec.biz.dal.dto.ClassDateAdjustDto;
-import com.ym.mec.biz.dal.entity.CourseScheduleComplaints;
-import com.ym.mec.biz.dal.page.StudentCourseScheduleRecordQueryInfo;
-import com.ym.mec.biz.service.CourseScheduleService;
-import com.ym.mec.biz.service.StudentAttendanceService;
-import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
 
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.CourseScheduleComplaints;
+import com.ym.mec.biz.dal.page.StudentCourseScheduleRecordQueryInfo;
+import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.StudentAttendanceService;
+import com.ym.mec.common.controller.BaseController;
+
 /**
  * @Author Joburgess
  * @Date 2019/9/24
@@ -25,49 +32,50 @@ import java.util.Date;
 @RestController
 public class StudentCourseScheduleController extends BaseController {
 
-    @Autowired
-    private CourseScheduleService scheduleService;
-    @Autowired
-    private StudentAttendanceService studentAttendanceService;
+	@Autowired
+	private CourseScheduleService scheduleService;
+
+	@Autowired
+	private StudentAttendanceService studentAttendanceService;
 
-    @ApiOperation(value = "根据月份获取乐团在该月有课的日期")
-    @GetMapping("/getCourseScheduleDateByMonth")
-    public Object getCourseScheduleDateByMonth(@ApiParam(value = "月份", required = true) @RequestParam Date month,
-                                               @ApiParam(value = "未上课", required = true) Integer isAttend) {
-        return succeed(scheduleService.getCourseScheduleDateByStudent(month,isAttend));
-    }
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
 
-    @ApiOperation(value = "根据日期获取当日排课")
-    @GetMapping("/getCourseSchedulesWithDate")
-    public Object getCourseSchedulesWithDate(@ApiParam(value = "日期", required = true) Date date){
-        return succeed(scheduleService.getStudentCourseSchedulesWithDate(date));
-    }
+	@ApiOperation(value = "根据月份获取乐团在该月有课的日期")
+	@GetMapping("/getCourseScheduleDateByMonth")
+	public Object getCourseScheduleDateByMonth(@ApiParam(value = "月份", required = true) @RequestParam Date month,
+			@ApiParam(value = "未上课", required = true) Integer isAttend) {
+		return succeed(scheduleService.getCourseScheduleDateByStudent(month, isAttend));
+	}
 
-    @ApiOperation(value = "课时调整")
-    @PostMapping(value = "/classStartDateAdjust",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    public Object classStartDateAdjust(ClassDateAdjustDto classDateAdjustDto){
-        scheduleService.classStartDateAdjust(classDateAdjustDto);
-        return succeed();
-    }
+	@ApiOperation(value = "根据日期获取当日排课")
+	@GetMapping("/getCourseSchedulesWithDate")
+	public Object getCourseSchedulesWithDate(@ApiParam(value = "日期", required = true) Date date) {
+		return succeed(scheduleService.getStudentCourseSchedulesWithDate(date));
+	}
 
-    @ApiOperation(value = "课时交换")
-    @GetMapping(value = "/courseSwap",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    public Object courseSwap(Long courseScheduleId1,Long courseScheduleId2){
-        scheduleService.courseSwap(courseScheduleId1,courseScheduleId2);
-        return succeed();
-    }
+	@ApiOperation(value = "上课记录")
+	@GetMapping(value = "/findStudentCourseScheduleRecords")
+	public Object findStudentCourseScheduleRecords(StudentCourseScheduleRecordQueryInfo queryInfo) {
+		return succeed(scheduleService.findStudentCourseScheduleRecords(queryInfo));
+	}
 
-    @ApiOperation(value = "上课记录")
-    @GetMapping(value = "/findStudentCourseScheduleRecords")
-    public Object findStudentCourseScheduleRecords(StudentCourseScheduleRecordQueryInfo queryInfo){
-        return succeed(scheduleService.findStudentCourseScheduleRecords(queryInfo));
-    }
+	@ApiModelProperty(value = "课程投诉")
+	@PostMapping("/courseScheduleCommplaint")
+	public Object courseScheduleCommplaint(CourseScheduleComplaints courseScheduleComplaints) {
+		scheduleService.courseScheduleCommplaint(courseScheduleComplaints);
+		return succeed();
+	}
 
-    @ApiModelProperty(value = "课程投诉")
-    @PostMapping("/courseScheduleCommplaint")
-    public Object courseScheduleCommplaint(CourseScheduleComplaints courseScheduleComplaints){
-        scheduleService.courseScheduleCommplaint(courseScheduleComplaints);
-        return succeed();
-    }
+	@ApiModelProperty(value = "请假")
+	@PostMapping("/leave")
+	public Object leave(long courseScheduleId, String reason) {
+		SysUser user = sysUserFeignService.queryUserInfo();
+		if (user == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		studentAttendanceService.leave(user.getId(), courseScheduleId, reason);
+		return succeed();
+	}
 
 }