|
|
@@ -1,12 +1,18 @@ |
|
|
|
package com.ruoyi.zhushi.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser; |
|
|
|
import com.ruoyi.common.helper.LoginHelper; |
|
|
|
import com.ruoyi.zhushi.entity.AppDTO; |
|
|
|
import com.ruoyi.zhushi.entity.DkAttendanceGroup; |
|
|
|
import com.ruoyi.zhushi.entity.DkCheckInRecord; |
|
|
|
import com.ruoyi.zhushi.mapper.DkAttendanceGroupMapper; |
|
|
|
import com.ruoyi.zhushi.mapper.DkRecordMapper; |
|
|
|
import com.ruoyi.zhushi.service.DkAppService; |
|
|
|
import com.ruoyi.zhushi.util.DateUtils; |
|
|
|
import com.ruoyi.zhushi.util.TimeUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
@@ -32,36 +38,18 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
// 查询考勤组信息 |
|
|
|
AppDTO appDTO1 = dkAttendanceGroupMapper.queryAttendanceGroupBYUserId(appDTO.getUserId()); |
|
|
|
|
|
|
|
// 判断是否已经打卡,如果已经打卡,则不允许再次打卡 |
|
|
|
// LambdaQueryWrapper<DkCheckInRecord> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
// queryWrapper.eq(DkCheckInRecord::getSysUserId, appDTO.getUserId()); |
|
|
|
// queryWrapper.apply("DATE(check_in_time) = DATE(NOW())"); |
|
|
|
// List<DkCheckInRecord> dkCheckInRecords = dkRecordMapper.selectList(queryWrapper); |
|
|
|
// if (dkCheckInRecords.size() > 0){ |
|
|
|
// return "已经打卡,不允许重复打卡!"; |
|
|
|
// } |
|
|
|
// 打卡开始时间 |
|
|
|
String workStartTime = appDTO1.getWorkStartTime(); |
|
|
|
if(workStartTime == null){ |
|
|
|
return "系统设置错误"; |
|
|
|
} |
|
|
|
|
|
|
|
// 根据经纬度计算两点之间的距离 |
|
|
|
// double distanceKm = GeoDistanceUtil.getDistanceKm(appDTO.getLat(), appDTO.getLng(), appDTO1.getLat(), appDTO1.getLng()); |
|
|
|
// if (distanceKm > appDTO.getRadius()) { |
|
|
|
// return "超出打卡范围"; |
|
|
|
// } |
|
|
|
|
|
|
|
// 解析给定的时分秒(格式:HH:mm:ss 或 HH:mm) |
|
|
|
|
|
|
|
// 初始化打卡记录对象 |
|
|
|
DkCheckInRecord dkCheckInRecord = new DkCheckInRecord(); |
|
|
|
|
|
|
|
// 构造查询条件 |
|
|
|
LambdaQueryWrapper<DkCheckInRecord> queryWrapper1 = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper1.eq(DkCheckInRecord::getSysUserId, appDTO.getUserId()); |
|
|
|
// queryWrapper1.apply("DATE(check_in_time) = CURDATE()"); |
|
|
|
// queryWrapper1.isNotNull(DkCheckInRecord::getClockIn); |
|
|
|
List<DkCheckInRecord> dkCheckInRecords1 = dkRecordMapper.selectList(queryWrapper1); |
|
|
|
|
|
|
|
// 判断是否已经存在打卡数据 |
|
|
@@ -73,6 +61,7 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
// true的时候表示当前时间在给定时间以前,属于正常打卡;false表示当前时间在给定时间以后,属于迟到打卡 |
|
|
|
boolean result = canSignIn(workStartTime); |
|
|
|
if(!result){ |
|
|
|
String description = StringUtils.isBlank(appDTO.getDescription())?appDTO.getDescription():"迟到:"+appDTO.getDescription(); |
|
|
|
// 允许迟到打卡 |
|
|
|
if(appDTO1.getAllowLate()){ |
|
|
|
// 根据允许的范围进行是否可以打卡判断 |
|
|
@@ -97,7 +86,7 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
dkCheckInRecord.setMonth(appDTO.getMonth()); |
|
|
|
dkCheckInRecord.setWeek(appDTO.getWeek()); |
|
|
|
dkCheckInRecord.setDay(appDTO.getDay()); |
|
|
|
dkCheckInRecord.setDescription(appDTO.getDescription()); |
|
|
|
dkCheckInRecord.setDescription(description); |
|
|
|
dkCheckInRecord.setAttendanceGroupId(appDTO.getAttendanceGroupId()); |
|
|
|
dkCheckInRecord.setAttendanceGroupName(appDTO.getAttendanceGroupName()); |
|
|
|
|
|
|
@@ -143,7 +132,7 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
dkCheckInRecord.setMonth(appDTO.getMonth()); |
|
|
|
dkCheckInRecord.setWeek(appDTO.getWeek()); |
|
|
|
dkCheckInRecord.setDay(appDTO.getDay()); |
|
|
|
dkCheckInRecord.setDescription(appDTO.getDescription()); |
|
|
|
dkCheckInRecord.setDescription(description); |
|
|
|
dkCheckInRecord.setAttendanceGroupId(appDTO.getAttendanceGroupId()); |
|
|
|
dkCheckInRecord.setAttendanceGroupName(appDTO.getAttendanceGroupName()); |
|
|
|
dkRecordMapper.insertOrUpdate(dkCheckInRecord); |
|
|
@@ -217,11 +206,6 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
public String checkOut(AppDTO appDTO) { |
|
|
|
// 查询打卡配置信息 |
|
|
|
AppDTO appDTO1 = dkAttendanceGroupMapper.queryAttendanceGroupBYUserId(appDTO.getUserId()); |
|
|
|
// 根据经纬度计算两点之间的距离 |
|
|
|
// double distanceKm = GeoDistanceUtil.getDistanceKm(appDTO.getLat(), appDTO.getLng(), appDTO1.getLat(), appDTO1.getLng()); |
|
|
|
// if (distanceKm > appDTO.getRadius()){ |
|
|
|
// return "超出范围"; |
|
|
|
// } |
|
|
|
|
|
|
|
// 打卡结束时间 |
|
|
|
String workEndTime = appDTO1.getWorkEndTime(); |
|
|
@@ -231,8 +215,6 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
// 获取当前天的下班打卡记录 |
|
|
|
LambdaQueryWrapper<DkCheckInRecord> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(DkCheckInRecord::getSysUserId, appDTO.getUserId()); |
|
|
|
// queryWrapper.eq(DkCheckInRecord::getCheckInType, "clockOut"); |
|
|
|
// queryWrapper.isNotNull(DkCheckInRecord::getClockOut); |
|
|
|
queryWrapper.apply("DATE(check_in_time) = DATE(NOW())"); |
|
|
|
queryWrapper.orderByDesc(DkCheckInRecord::getCheckInTime); |
|
|
|
|
|
|
@@ -261,6 +243,21 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
}else{ |
|
|
|
// true的时候表示当前时间在给定时间以前,为提前打卡,false的时候正常打卡 |
|
|
|
boolean result = canSignIn(workEndTime); |
|
|
|
String description = ""; |
|
|
|
if (StringUtils.isBlank(dkCheckInRecord.getDescription())) { |
|
|
|
if (StringUtils.isBlank(appDTO.getDescription())) { |
|
|
|
description = appDTO.getDescription(); |
|
|
|
} else { |
|
|
|
description = "早退:"+appDTO.getDescription(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (StringUtils.isBlank(appDTO.getDescription())) { |
|
|
|
description = dkCheckInRecord.getDescription(); |
|
|
|
} else { |
|
|
|
description = dkCheckInRecord.getDescription() +"&早退:"+appDTO.getDescription(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(result){ |
|
|
|
// 判断是否允许提前打卡 |
|
|
|
if(appDTO1.getAllowEarly()){ |
|
|
@@ -283,7 +280,7 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
dkCheckInRecord.setAttendanceGroupId(appDTO.getAttendanceGroupId()); |
|
|
|
dkCheckInRecord.setAttendanceGroupName(appDTO.getAttendanceGroupName()); |
|
|
|
dkRecordMapper.insertOrUpdate(dkCheckInRecord); |
|
|
|
dkCheckInRecord.setDescription(appDTO.getDescription()); |
|
|
|
dkCheckInRecord.setDescription(description); |
|
|
|
return "提前打卡"; |
|
|
|
} |
|
|
|
// 签到成功 |
|
|
@@ -320,7 +317,7 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
dkCheckInRecord.setMonth(appDTO.getMonth()); |
|
|
|
dkCheckInRecord.setWeek(appDTO.getWeek()); |
|
|
|
dkCheckInRecord.setDay(appDTO.getDay()); |
|
|
|
dkCheckInRecord.setDescription(appDTO.getDescription()); |
|
|
|
dkCheckInRecord.setDescription(description); |
|
|
|
dkCheckInRecord.setAttendanceGroupId(appDTO.getAttendanceGroupId()); |
|
|
|
dkCheckInRecord.setAttendanceGroupName(appDTO.getAttendanceGroupName()); |
|
|
|
dkRecordMapper.insertOrUpdate(dkCheckInRecord); |
|
|
@@ -389,4 +386,11 @@ public class DkAppServiceImpl implements DkAppService { |
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String getRealTime() { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
AppDTO appDTO = dkAttendanceGroupMapper.queryAttendanceGroupBYUserId(loginUser.getUserId()); |
|
|
|
return DateUtils.getCurrentTimeByZone(appDTO.getTimeZone()); |
|
|
|
} |
|
|
|
} |