Joburgess 5 年之前
父節點
當前提交
b79fbe3c87

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

@@ -12,8 +12,18 @@ public class StudentAttendanceDto {
 
     private String signInLongitudeLatitude;
 
+    private Integer update;
+
     private List<StudentAttendance> studentAttendances;
 
+    public Integer getUpdate() {
+        return update;
+    }
+
+    public void setUpdate(Integer update) {
+        this.update = update;
+    }
+
     public String getSignInLongitudeLatitude() {
         return signInLongitudeLatitude;
     }

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

@@ -65,6 +65,16 @@ public class TeacherAttendance {
 
 	private String signOutLongitudeLatitude;
 
+	private Integer update;
+
+	public Integer getUpdate() {
+		return update;
+	}
+
+	public void setUpdate(Integer update) {
+		this.update = update;
+	}
+
 	public String getSignInLongitudeLatitude() {
 		return signInLongitudeLatitude;
 	}

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.CourseScheduleResponse;
+import com.ym.mec.biz.dal.dto.StudentAttendanceDto;
 import com.ym.mec.biz.dal.dto.StudentPersonalAttendanceDto;
 import com.ym.mec.biz.dal.entity.StudentAttendance;
 import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
@@ -9,7 +10,6 @@ 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> {
@@ -19,7 +19,7 @@ public interface StudentAttendanceService extends BaseService<Long, StudentAtten
 	 * @Date: 2019/9/11
 	 * 批量插入学生上课签到信息
 	 */
-	Map addStudentAttendances(List<StudentAttendance> studentAttendances);
+	Map addStudentAttendances(StudentAttendanceDto studentAttendanceInfo);
 
 	/**
 	 * @describe 获取当前课程的学生

+ 7 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -66,8 +66,8 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public Map addStudentAttendances(List<StudentAttendance> studentAttendances) {
-//		List<StudentAttendance> studentAttendances=studentAttendanceInfos.getStudentAttendances();
+	public Map addStudentAttendances(StudentAttendanceDto studentAttendanceInfos) {
+		List<StudentAttendance> studentAttendances=studentAttendanceInfos.getStudentAttendances();
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		if(Objects.isNull(sysUser)){
 			throw new BizException("请登录");
@@ -135,12 +135,11 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 		courseSchedule.setLeaveStudentNum(leaveStudentNum);
 		courseScheduleDao.update(courseSchedule);
 
-//		TeacherSignOutDto teacherSignOutDto=new TeacherSignOutDto();
-//		TeacherAttendance teacherAttendance = new TeacherAttendance(courseSchedule.getId(), 0);
-//		teacherAttendance.setSignInLongitudeLatitude(studentAttendanceInfos.getSignInLongitudeLatitude());
-//		teacherSignOutDto.setTeacherAttendanceInfo(teacherAttendance);
-//		return teacherAttendanceService.addTeacherAttendanceRecord(teacherSignOutDto);
-        return null;
+		TeacherSignOutDto teacherSignOutDto=new TeacherSignOutDto();
+		TeacherAttendance teacherAttendance = new TeacherAttendance(courseSchedule.getId(), 0);
+		teacherAttendance.setSignInLongitudeLatitude(studentAttendanceInfos.getSignInLongitudeLatitude());
+		teacherSignOutDto.setTeacherAttendanceInfo(teacherAttendance);
+		return teacherAttendanceService.addTeacherAttendanceRecord(teacherSignOutDto);
 	}
 
 	@Override

+ 18 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherAttendanceServiceImpl.java

@@ -80,9 +80,9 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 
 		TeacherAttendance teacherAttendance=teacherAttendanceDao.findByTeacherAttendanceInfo(user.getId().longValue(),teacherSignOutDto.getTeacherAttendanceInfo().getCourseScheduleId());
 
-//		if(StringUtils.isBlank(teacherSignOutDto.getTeacherAttendanceInfo().getSignInLongitudeLatitude())){
-//			throw new BizException("未获取到您的位置");
-//		}
+		if(StringUtils.isBlank(teacherSignOutDto.getTeacherAttendanceInfo().getSignInLongitudeLatitude())){
+			throw new BizException("未获取到您的位置");
+		}
 
 		Date date = new Date();
 		if(Objects.isNull(teacherAttendance)){
@@ -119,18 +119,21 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 
 		//是否在范围内
 		boolean isInScore = true;
-//		if(StringUtils.isBlank(school.getLongitudeLatitude())){
-//			school.setLongitudeLatitude(teacherSignOutDto.getTeacherAttendanceInfo().getSignInLongitudeLatitude());
-//			schoolDao.update(school);
-//		}else{
-//			SysConfig sysConfig = sysConfigService.findByParamName(SysConfigService.ATTENDANCE_RANGE);
-//			double attendanceRange = Double.valueOf(sysConfig.getParanValue());
-//			double distance = MapUtil.distance(teacherSignOutDto.getTeacherAttendanceInfo().getSignInLongitudeLatitude(),
-//					school.getLongitudeLatitude());
-//			if(distance>attendanceRange){
-//				isInScore=false;
-//			}
-//		}
+		if(StringUtils.isBlank(school.getLongitudeLatitude())){
+			if(teacherSignOutDto.getTeacherAttendanceInfo().getUpdate().equals(YesOrNoEnum.YES.getCode())){
+				school.setLongitudeLatitude(teacherSignOutDto.getTeacherAttendanceInfo().getSignInLongitudeLatitude());
+				schoolDao.update(school);
+			}
+			isInScore = false;
+		}else{
+			SysConfig sysConfig = sysConfigService.findByParamName(SysConfigService.ATTENDANCE_RANGE);
+			double attendanceRange = Double.valueOf(sysConfig.getParanValue());
+			double distance = MapUtil.distance(teacherSignOutDto.getTeacherAttendanceInfo().getSignInLongitudeLatitude(),
+					school.getLongitudeLatitude());
+			if(distance>attendanceRange){
+				isInScore=false;
+			}
+		}
 
 		String classDate = DateUtil.format(courseSchedule.getClassDate(), DateUtil.DEFAULT_PATTERN);
 		String startClassTime = DateUtil.format(courseSchedule.getStartClassTime(), DateUtil.EXPANDED_TIME_FORMAT);

+ 3 - 5
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherAttendanceController.java

@@ -1,7 +1,7 @@
 package com.ym.mec.teacher.controller;
 
+import com.ym.mec.biz.dal.dto.StudentAttendanceDto;
 import com.ym.mec.biz.dal.dto.TeacherSignOutDto;
-import com.ym.mec.biz.dal.entity.StudentAttendance;
 import com.ym.mec.biz.dal.page.TeacherAttendanceQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.StudentAttendanceService;
@@ -12,8 +12,6 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-
 @RequestMapping("teacherAttendance")
 @Api(tags = "教师签到服务")
 @RestController
@@ -48,7 +46,7 @@ public class TeacherAttendanceController extends BaseController {
 
     @ApiOperation(value = "点名")
     @PostMapping("/addStudentAttendances")
-    public Object addStudentAttendances(@RequestBody List<StudentAttendance> studentAttendances){
-        return succeed(studentAttendanceService.addStudentAttendances(studentAttendances));
+    public Object addStudentAttendances(@RequestBody StudentAttendanceDto studentAttendanceInfo){
+        return succeed(studentAttendanceService.addStudentAttendances(studentAttendanceInfo));
     }
 }