优化
This commit is contained in:
		@ -12,6 +12,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@ -22,6 +23,9 @@ public class WgzAppDailyClockReq implements Serializable {
 | 
			
		||||
	@ApiModelProperty("日报状态(0正常 1补卡)")
 | 
			
		||||
	private String status;
 | 
			
		||||
 | 
			
		||||
	@ApiModelProperty("status为1时,补卡日期")
 | 
			
		||||
	private LocalDateTime rqData;
 | 
			
		||||
 | 
			
		||||
	@ApiModelProperty("今日完成工作")
 | 
			
		||||
	private String finishToday;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -188,6 +188,7 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
			if (!flag) {
 | 
			
		||||
				throw new RuntimeException("打卡时间间隔不能少于3分钟");
 | 
			
		||||
			}
 | 
			
		||||
			wgzAttendance.setId(we.getId());
 | 
			
		||||
			wgzAttendance.setClockOutTime(now);
 | 
			
		||||
			LocalTime endWorkTime = appById.getEndWorkTime(); //下班
 | 
			
		||||
			String exceptionType = we.getExceptionType();
 | 
			
		||||
@ -213,19 +214,17 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 判断两个 LocalDateTime 之间的差值分钟数是否超过 3
 | 
			
		||||
	 * 判断两个 LocalDateTime 之间的差值是否超过 3 分钟
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param startTime 开始时间
 | 
			
		||||
	 * @param endTime   结束时间
 | 
			
		||||
	 * @return 如果差值分钟数超过 3 返回 true,否则返回 false
 | 
			
		||||
	 * @return 如果差值超过 3 分钟返回 true,否则返回 false
 | 
			
		||||
	 */
 | 
			
		||||
	public static boolean isMinutesDifferenceGreaterThanThree(LocalDateTime startTime, LocalDateTime endTime) {
 | 
			
		||||
		// 计算两个时间之间的持续时间
 | 
			
		||||
		Duration duration = Duration.between(startTime, endTime);
 | 
			
		||||
		// 获取持续时间的分钟数
 | 
			
		||||
		long minutes = duration.toMinutes();
 | 
			
		||||
		// 判断分钟数是否超过 3
 | 
			
		||||
		return Math.abs(minutes) > 3;
 | 
			
		||||
	public boolean isMinutesDifferenceGreaterThanThree(LocalDateTime startTime, LocalDateTime endTime) {
 | 
			
		||||
		// 计算两个时间之间的持续时间(秒级精度)
 | 
			
		||||
		long seconds = Duration.between(startTime, endTime).getSeconds();
 | 
			
		||||
		// 超过 180 秒(3 分钟)则返回 true
 | 
			
		||||
		return Math.abs(seconds) > 180;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
 | 
			
		||||
@ -178,9 +178,9 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
			tempDate = tempDate.plusDays(1);
 | 
			
		||||
		}
 | 
			
		||||
		//2、查询当前人员指定日期的所有日报情况
 | 
			
		||||
		QueryWrapper<WgzDailyClock> queryWrapper = new QueryWrapper<>();
 | 
			
		||||
		queryWrapper.apply("DATE_FORMAT(dily_time, '%Y-%m') = {0}", req.getYearMonth());		// 使用 apply 方法添加自定义 SQL 条件
 | 
			
		||||
		List<WgzDailyClock> wgzDailyClocks = baseMapper.selectList(queryWrapper);
 | 
			
		||||
		Long appUserId = SecurityUtils.getAppUserId();
 | 
			
		||||
		LambdaQueryWrapper<WgzDailyClock> apply = new LambdaQueryWrapper<WgzDailyClock>().eq(WgzDailyClock::getUserId, appUserId).apply("DATE_FORMAT(dily_time, '%Y-%m') = {0}", req.getYearMonth());
 | 
			
		||||
		List<WgzDailyClock> wgzDailyClocks = baseMapper.selectList(apply);
 | 
			
		||||
		//3、查看当前人、当前项目、当前月是否有请假
 | 
			
		||||
        Map<LocalDate, LocalDate> ll = iWgzLeaveService.selectByUserCancelLeave(req.getYearMonth());
 | 
			
		||||
        //4、将获取的年月与数据库中的日期进行比对,然后填充数据
 | 
			
		||||
@ -195,7 +195,6 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
						setId(wgzDailyClock.getId()).
 | 
			
		||||
						setDilyTime(wgzDailyClock.getDilyTime()).
 | 
			
		||||
						setPnchOsition(wgzDailyClock.getPnchOsition());
 | 
			
		||||
 | 
			
		||||
					if (ll.get(date) !=null && ll.get(date).equals(clockDate)) {
 | 
			
		||||
						wgzAppAttachmentAcquisitionTwo.setStatus("2"); //全天请假
 | 
			
		||||
					}
 | 
			
		||||
@ -226,13 +225,24 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
		Long appUserId = SecurityUtils.getAppUserId();
 | 
			
		||||
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
 | 
			
		||||
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getRecruitId());
 | 
			
		||||
		//2、为补卡时now的时间就为前端传递的日期
 | 
			
		||||
		LocalDateTime now = LocalDateTime.now();
 | 
			
		||||
		if (req.getStatus().equals("1")){
 | 
			
		||||
			now = req.getRqData();
 | 
			
		||||
		}
 | 
			
		||||
//		//3、判断当前时间的补卡是否存在,存在就不允许插入
 | 
			
		||||
//		LambdaQueryWrapper<WgzDailyClock> apply = new LambdaQueryWrapper<WgzDailyClock>()
 | 
			
		||||
//			.eq(WgzDailyClock::getUserId, appUserId)
 | 
			
		||||
//			.eq(WgzDailyClock::getRecruitId, appById.getId())
 | 
			
		||||
//			.eq(WgzDailyClock::getDilyTime, now);
 | 
			
		||||
//		List<WgzDailyClock> wgzDailyClocks = baseMapper.selectList(apply);
 | 
			
		||||
		//1、组装数据
 | 
			
		||||
		WgzDailyClock dc = new WgzDailyClock();
 | 
			
		||||
		BeanUtils.copyProperties(req,dc);
 | 
			
		||||
		dc.setStatus(req.getStatus());
 | 
			
		||||
		dc.setRecruitId(appUserId);
 | 
			
		||||
		dc.setUserId(appUserId);
 | 
			
		||||
		dc.setDilyTime(LocalDateTime.now());
 | 
			
		||||
		dc.setDilyTime(now);
 | 
			
		||||
		dc.setAuditorUserId(appById.getUserId());
 | 
			
		||||
		int insert = baseMapper.insert(dc);
 | 
			
		||||
		//2、插入成功,且状态为1,那么就需要发送消息给【补日报】的人和上级【招工】
 | 
			
		||||
 | 
			
		||||
@ -237,7 +237,7 @@ public class WgzMessageServiceImpl extends ServicePlusImpl<WgzMessageMapper, Wgz
 | 
			
		||||
		if(count == num){
 | 
			
		||||
			return "1"; //已招满
 | 
			
		||||
		}
 | 
			
		||||
		if (recruitEndTime.isAfter(LocalDate.now())){
 | 
			
		||||
		if (!LocalDate.now().isBefore(recruitEndTime)){
 | 
			
		||||
			return "2"; //已失效
 | 
			
		||||
		}
 | 
			
		||||
		return "0";
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user