优化
This commit is contained in:
		@ -163,7 +163,7 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
		//2、获取当前用户所在的工地id
 | 
			
		||||
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
 | 
			
		||||
		//3、根据工地id得到完整的工地信息
 | 
			
		||||
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
 | 
			
		||||
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getRecruitId());
 | 
			
		||||
//		//4、查看当前用户是否有请假申请,有请假申请并且通过,那就无法进行打卡------------------>此处代码将改写逻辑为:每天凌晨1分的时候直接找出已请假的人然后定时插入数据到打卡记录中标记为请假
 | 
			
		||||
//		String formattedDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 | 
			
		||||
//		WgzLeave wgzLeave = iWgzLeaveService.FindAskForLeaveOrNotInfo(appUserId, by.getId(), formattedDate);
 | 
			
		||||
@ -174,7 +174,7 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
//		}
 | 
			
		||||
		//5、查看当前人、当前工地、当天的打卡记录
 | 
			
		||||
		String formattedDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 | 
			
		||||
		WgzAttendance we = publicFindByUserIdWait(appUserId, by.getId(), formattedDate);
 | 
			
		||||
		WgzAttendance we = publicFindByUserIdWait(appUserId, by.getRecruitId(), formattedDate);
 | 
			
		||||
		if (we !=null && we.getLeaveMarkId() != null && we.getLeaveMarkId()!= 0) {
 | 
			
		||||
			throw new RuntimeException("您有已通过的请假申请,请假时间为:"+formattedDate);
 | 
			
		||||
		}
 | 
			
		||||
@ -187,17 +187,8 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
			setPnchOsition(req.getPnchOsition());
 | 
			
		||||
		LocalDateTime now = LocalDateTime.now(); //当前完整年月日时分秒
 | 
			
		||||
		LocalTime localTime = now.toLocalTime(); //获取时分秒
 | 
			
		||||
		if (Objects.isNull(we)) { //表示当天第一次打卡---上班  否则  表示当天不是第一次打卡---下班
 | 
			
		||||
			wgzAttendance.setClockInTime(now);
 | 
			
		||||
			LocalTime beginWorkTime = appById.getBeginWorkTime(); //上班
 | 
			
		||||
			if (!localTime.isBefore(beginWorkTime)) {
 | 
			
		||||
				wgzAttendance.setLate(1); //迟到
 | 
			
		||||
				wgzAttendance.setLateTime(now);
 | 
			
		||||
				wgzAttendance.setExceptionType("1,");
 | 
			
		||||
			}
 | 
			
		||||
			return baseMapper.insert(wgzAttendance) > 0;
 | 
			
		||||
		}else{
 | 
			
		||||
			//7、获取上次打卡时间与这次打卡时间的间隔是否超过3分钟
 | 
			
		||||
		if (we !=null) {
 | 
			
		||||
			//获取上次打卡时间与这次打卡时间的间隔是否超过3分钟
 | 
			
		||||
			boolean flag = isMinutesDifferenceGreaterThanThree(we.getClockInTime(), now);
 | 
			
		||||
			if (!flag){
 | 
			
		||||
				throw new RuntimeException("打卡时间间隔不能少于3分钟");
 | 
			
		||||
@ -212,6 +203,15 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
				wgzAttendance.setExceptionType(exceptionType+"2,");
 | 
			
		||||
			}
 | 
			
		||||
			return baseMapper.updateById(wgzAttendance) > 0;
 | 
			
		||||
		}else{
 | 
			
		||||
			wgzAttendance.setClockInTime(now);
 | 
			
		||||
			LocalTime beginWorkTime = appById.getBeginWorkTime(); //上班
 | 
			
		||||
			if (!localTime.isBefore(beginWorkTime)) {
 | 
			
		||||
				wgzAttendance.setLate(1); //迟到
 | 
			
		||||
				wgzAttendance.setLateTime(now);
 | 
			
		||||
				wgzAttendance.setExceptionType("1,");
 | 
			
		||||
			}
 | 
			
		||||
			return baseMapper.insert(wgzAttendance) > 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -237,7 +237,7 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
		Long appUserId = SecurityUtils.getAppUserId();
 | 
			
		||||
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
 | 
			
		||||
		String formattedDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 | 
			
		||||
		WgzAttendance wgzAttendance = publicFindByUserIdWait(appUserId, by.getId(), formattedDate);
 | 
			
		||||
		WgzAttendance wgzAttendance = publicFindByUserIdWait(appUserId, by.getRecruitId(), formattedDate);
 | 
			
		||||
		//2、获取今日用户打卡状态
 | 
			
		||||
		if (wgzAttendance == null) {
 | 
			
		||||
			res.setClockingCondition(0); //上班
 | 
			
		||||
 | 
			
		||||
@ -182,7 +182,7 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
		});
 | 
			
		||||
		//4、获取当前务工者的招工信息的主题及招工创建人的基本信息
 | 
			
		||||
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(SecurityUtils.getAppUserId());
 | 
			
		||||
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
 | 
			
		||||
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getRecruitId());
 | 
			
		||||
		BgtUser one = iBgtUserService.getOne(
 | 
			
		||||
			new LambdaQueryWrapper<BgtUser>().
 | 
			
		||||
				eq(BgtUser::getUserId, appById.getUserId())
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user