瀏覽代碼

员工添加及当前课时更新

Joburgess 5 年之前
父節點
當前提交
10dfd85d7e

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherAttendanceDao.java

@@ -22,5 +22,12 @@ public interface TeacherAttendanceDao extends BaseDAO<Long, TeacherAttendance> {
      * @return
      */
     int getTeacherPersonalAttendancesCount(Map<String,Object> params);
+
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/24
+     * 统计课次
+     */
+    int countClassTime(Long classGroupId);
 	
 }

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.enums.JobNatureEnum;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 
@@ -10,7 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 /**
  * 对应数据库表(employee):
  */
-public class Employee {
+public class Employee extends SysUser {
 
 	/**  */
 	private Integer userId;

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/EmployeeService.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.EmployeeOperateEnum;
 import com.ym.mec.biz.dal.page.EmployeeQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -24,4 +25,10 @@ public interface EmployeeService extends BaseService<Integer, Employee> {
      */
     void employeeOperate(Long employeeId, EmployeeOperateEnum operate);
 
+    /**
+     * 新增员工
+     * @param employee
+     */
+    void add(Employee employee) throws Exception;
+
 }

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

@@ -8,6 +8,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -44,6 +46,8 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee>  imp
 
 	@Autowired
 	private ObjectMapper objectMapper;
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
 
 	@Override
 	public BaseDAO<Integer, Employee> getDAO() {
@@ -51,6 +55,20 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee>  imp
 	}
 
 	@Override
+	public void add(Employee employee) throws Exception {
+		SysUser user = sysUserFeignService.getUserByMobile(employee.getPhone());
+		if(user != null){
+			throw new Exception("系统已存在该手机号的老师,请核查");
+		}
+		//保存用户表信息
+		sysUserFeignService.addUser(employee);
+		//注册到融云
+
+		//保存教师表数据
+		employeeDao.insert(employee);
+	}
+
+	@Override
 	public PageInfo queryEmployByOrganId(EmployeeQueryInfo queryInfo) throws IOException {
 		String url = "http://auth-server/queryUserInfo";
 

+ 10 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherAttendanceServiceImpl.java

@@ -2,17 +2,11 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
-import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
-import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.TeacherAttendanceDto;
 import com.ym.mec.biz.dal.dto.TeacherPersonalAttendanceDto;
 import com.ym.mec.biz.dal.dto.TeacherSignOutDto;
-import com.ym.mec.biz.dal.entity.CourseHomework;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.StudentCourseHomework;
-import com.ym.mec.biz.dal.entity.TeacherAttendance;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.biz.dal.enums.ParamEnum;
 import com.ym.mec.biz.dal.enums.SignStatusEnum;
@@ -45,6 +39,8 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 	private StudentCourseHomeworkDao studentCourseHomeworkDao;
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
+	@Autowired
+	private ClassGroupDao classGroupDao;
 
 	@Override
 	public BaseDAO<Long, TeacherAttendance> getDAO() {
@@ -79,6 +75,12 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 		teacherAttendance.setCreateTime(date);
 		teacherAttendanceDao.insert(teacherAttendance);
 		if(teacherAttendance.getStatus()==SignStatusEnum.YES_QUIT){
+			//更新课次
+			ClassGroup classGroup=new ClassGroup();
+			classGroup.setId(currentCourseDetail.getClassId().intValue());
+			classGroup.setCurrentClassTimes(teacherAttendanceDao.countClassTime(currentCourseDetail.getClassId()));
+			classGroupDao.update(classGroup);
+			//新增课堂作业
 			CourseHomework courseHomework=teacherSignOutDto.getCourseHomeworkInfo();
 			courseHomework.setCourseScheduleId(teacherAttendance.getCourseScheduleId());
 			courseHomework.setMusicGroupId(currentCourseDetail.getMusicGroupId().intValue());

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

@@ -145,5 +145,9 @@
         <include refid="queryCondition"/>
     </select>
 
+    <select id="countClassTime" resultType="java.lang.Integer">
+        select count(*) from teacher_attendance where class_group_id_=#{classGroupId} for update
+    </select>
+
 
 </mapper>

+ 14 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/EmployeeController.java

@@ -1,5 +1,7 @@
 package com.ym.mec.web.controller.education;
 
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.Teacher;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -41,4 +43,16 @@ public class EmployeeController extends BaseController {
         employeeService.employeeOperate(employeeId,operate);
         return succeed();
     }
+
+    @ApiOperation(value = "新增员工")
+    @PostMapping("/add")
+    public Object add(Employee employee) {
+        try {
+            employeeService.add(employee);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return failed(e.getMessage());
+        }
+        return succeed();
+    }
 }