考勤打卡模块
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
package com.ruoyi.wgz.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppSubmitTheClockReq;
|
||||
import com.ruoyi.wgz.domain.WgzAttendance;
|
||||
import com.ruoyi.wgz.bo.WgzAttendanceQueryBo;
|
||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考勤打卡Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IWgzAttendanceService extends IServicePlus<WgzAttendance> {
|
||||
/**
|
||||
* 查询单个
|
||||
* @return
|
||||
*/
|
||||
WgzAttendance queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
TableDataInfo<WgzAttendance> queryPageList(WgzAttendanceQueryBo bo);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<WgzAttendance> queryList(WgzAttendanceQueryBo bo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入考勤打卡
|
||||
* @param bo 考勤打卡新增业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean insert(WgzAttendance bo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改考勤打卡
|
||||
* @param bo 考勤打卡编辑业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean update(WgzAttendance bo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* APP相关
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* 用户提交打卡
|
||||
*/
|
||||
Boolean userSubmitTheClock(@Validated @RequestBody WgzAppSubmitTheClockReq req);
|
||||
|
||||
// /**
|
||||
// * 查看当前人、当前工地、当前日期的打卡记录
|
||||
// */
|
||||
// WgzAttendance findByUserIdWait(Long appUserId, Long recruitId, String date);
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
package com.ruoyi.wgz.service;
|
||||
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserDailyCalendarReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserDailyRecordReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppDailyCalendarReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppDailyRecordReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppUserDailyRecordRes;
|
||||
import com.ruoyi.wgz.bo.res.WgzUserDailyCalendarRes;
|
||||
import com.ruoyi.wgz.domain.WgzDailyClock;
|
||||
@ -68,15 +68,15 @@ public interface IWgzDailyClockService extends IServicePlus<WgzDailyClock> {
|
||||
/**
|
||||
* 日报日历
|
||||
*/
|
||||
WgzUserDailyCalendarRes userDailyCalendar(@Validated WgzAppUserDailyCalendarReq req);
|
||||
WgzUserDailyCalendarRes userDailyCalendar(@Validated WgzAppDailyCalendarReq req);
|
||||
|
||||
/**
|
||||
* 日报日历·日报记录(历史记录分页查询)
|
||||
*/
|
||||
TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(@Validated WgzAppUserDailyRecordReq req);
|
||||
TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(@Validated WgzAppDailyRecordReq req);
|
||||
|
||||
/**
|
||||
* 日报日历·日报记录(历史记录分页查询)
|
||||
* 日报日历·查看日报
|
||||
*/
|
||||
WgzDailyClock userCheckDailyNewspaper(Long id);
|
||||
}
|
||||
|
||||
@ -85,7 +85,12 @@ public interface IWgzLeaveService extends IServicePlus<WgzLeave> {
|
||||
Boolean userCancelLeave(@Validated @RequestBody WgzAppCancelLeaveReq req);
|
||||
|
||||
/*
|
||||
* 查看指定人、指定项目、指定月是否请假
|
||||
* 查看指定人、指定项目、指定月是否请假(只传递年月)
|
||||
*/
|
||||
Map<LocalDate, LocalDate> selectByUserCancelLeave(String yearMonth);
|
||||
|
||||
/*
|
||||
* 查看指定人、指定项目、指定日期是否请假
|
||||
*/
|
||||
WgzLeave FindAskForLeaveOrNotInfo(Long appUserId, Long recruitId, String date);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.wgz.bo.WgzUserQueryBo;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppModifyingUserProfilePictureReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppPersonalBasicInformationReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppRegisterReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppRealNameAuthenticationReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppPersonalBasicInformationRes;
|
||||
import com.ruoyi.wgz.domain.WgzUser;
|
||||
@ -71,7 +71,7 @@ public interface IWgzUserService extends IServicePlus<WgzUser> {
|
||||
/**
|
||||
* 务工者APP注册账号
|
||||
*/
|
||||
Boolean userRegister(WgzAppUserRegisterReq bo);
|
||||
Boolean userRegister(WgzAppRegisterReq bo);
|
||||
|
||||
/**
|
||||
* 修改用户头像修改用户头像
|
||||
|
||||
@ -0,0 +1,196 @@
|
||||
package com.ruoyi.wgz.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.bgt.domain.BgtProjectRecruit;
|
||||
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
||||
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
|
||||
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppSubmitTheClockReq;
|
||||
import com.ruoyi.wgz.domain.WgzLeave;
|
||||
import com.ruoyi.wgz.service.IWgzLeaveService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.wgz.bo.WgzAttendanceQueryBo;
|
||||
import com.ruoyi.wgz.domain.WgzAttendance;
|
||||
import com.ruoyi.wgz.mapper.WgzAttendanceMapper;
|
||||
import com.ruoyi.wgz.service.IWgzAttendanceService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 考勤打卡Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMapper, WgzAttendance> implements IWgzAttendanceService {
|
||||
|
||||
//上班打卡状态 0上 1下
|
||||
public static final String Clocking = "0";
|
||||
public static final String OffDuty= "1";
|
||||
|
||||
@Autowired
|
||||
private IBgtProjectRecruitApplyService iBgtProjectRecruitApplyService;
|
||||
|
||||
@Autowired
|
||||
private IBgtProjectRecruitService iBgtProjectRecruitService;
|
||||
|
||||
@Autowired
|
||||
private IWgzLeaveService iWgzLeaveService;
|
||||
|
||||
|
||||
@Override
|
||||
public WgzAttendance queryById(Long id){
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WgzAttendance> queryPageList(WgzAttendanceQueryBo bo) {
|
||||
Page<WgzAttendance> result = page(PageUtils.buildPage(), buildQueryWrapper(bo));
|
||||
return PageUtils.buildDataInfo(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WgzAttendance> queryList(WgzAttendanceQueryBo bo) {
|
||||
return list(buildQueryWrapper(bo));
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WgzAttendance> buildQueryWrapper(WgzAttendanceQueryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<WgzAttendance> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getRecruitId() != null, WgzAttendance::getRecruitId, bo.getRecruitId());
|
||||
lqw.eq(bo.getUserId() != null, WgzAttendance::getUserId, bo.getUserId());
|
||||
lqw.eq(bo.getLeaveMarkId() != null, WgzAttendance::getLeaveMarkId, bo.getLeaveMarkId());
|
||||
lqw.eq(bo.getDailyWage() != null, WgzAttendance::getDailyWage, bo.getDailyWage());
|
||||
lqw.eq(bo.getDate() != null, WgzAttendance::getDate, bo.getDate());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getPnchOsition()), WgzAttendance::getPnchOsition, bo.getPnchOsition());
|
||||
lqw.eq(bo.getClockInTime() != null, WgzAttendance::getClockInTime, bo.getClockInTime());
|
||||
lqw.eq(bo.getClockOutTime() != null, WgzAttendance::getClockOutTime, bo.getClockOutTime());
|
||||
lqw.eq(bo.getLate() != null, WgzAttendance::getLate, bo.getLate());
|
||||
lqw.eq(bo.getLateTime() != null, WgzAttendance::getLateTime, bo.getLateTime());
|
||||
lqw.eq(bo.getEarlyLeave() != null, WgzAttendance::getEarlyLeave, bo.getEarlyLeave());
|
||||
lqw.eq(bo.getEarlyLeaveTime() != null, WgzAttendance::getEarlyLeaveTime, bo.getEarlyLeaveTime());
|
||||
lqw.eq(bo.getMissedIn() != null, WgzAttendance::getMissedIn, bo.getMissedIn());
|
||||
lqw.eq(bo.getMissedOut() != null, WgzAttendance::getMissedOut, bo.getMissedOut());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getExceptionType()), WgzAttendance::getExceptionType, bo.getExceptionType());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insert(WgzAttendance bo) {
|
||||
WgzAttendance add = BeanUtil.toBean(bo, WgzAttendance.class);
|
||||
validEntityBeforeSave(add);
|
||||
return save(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(WgzAttendance bo) {
|
||||
WgzAttendance update = BeanUtil.toBean(bo, WgzAttendance.class);
|
||||
validEntityBeforeSave(update);
|
||||
return updateById(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(WgzAttendance entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP相关
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean userSubmitTheClock(WgzAppSubmitTheClockReq req) {
|
||||
//1、获取当前用户信息
|
||||
Long appUserId = SecurityUtils.getAppUserId();
|
||||
//2、获取当前用户所在的工地id
|
||||
BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
|
||||
//3、根据工地id得到完整的工地信息
|
||||
BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
|
||||
//4、查看当前用户是否有请假申请,有请假申请并且通过,那就无法进行打卡
|
||||
String formattedDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
WgzLeave wgzLeave = iWgzLeaveService.FindAskForLeaveOrNotInfo(appUserId, by.getId(), formattedDate);
|
||||
if (wgzLeave != null) { //表示有请假申请
|
||||
LocalDateTime startTime = wgzLeave.getStartTime();
|
||||
LocalDate localDate = startTime.toLocalDate();
|
||||
throw new RuntimeException("您有已通过的请假申请,请假时间为:"+localDate);
|
||||
}
|
||||
//5、查看当前人、当前工地、当天是否有打卡记录
|
||||
//4、组装完整的打卡信息
|
||||
WgzAttendance wgzAttendance = new WgzAttendance().
|
||||
setRecruitId(appById.getId()).
|
||||
setUserId(appUserId).
|
||||
setDailyWage(appById.getRecruitAmount()).
|
||||
setDate(LocalDate.now()).
|
||||
setPnchOsition(req.getPnchOsition()).
|
||||
setDate(LocalDate.now());
|
||||
//设置打卡时间
|
||||
LocalDateTime now = LocalDateTime.now(); //当前完整年月日时分秒
|
||||
LocalTime localTime = now.toLocalTime(); //获取时分秒
|
||||
if (req.getType().equals(Clocking)) {
|
||||
wgzAttendance.setClockInTime(now);
|
||||
//判断当前打卡时间是否在上班时间之前
|
||||
LocalTime beginWorkTime = appById.getBeginWorkTime(); //上班
|
||||
if (!localTime.isBefore(beginWorkTime)) {
|
||||
wgzAttendance.setLate(1); //迟到
|
||||
wgzAttendance.setLateTime(now);
|
||||
wgzAttendance.setExceptionType("1,");
|
||||
}
|
||||
}
|
||||
if (req.getType().equals(OffDuty)) {
|
||||
wgzAttendance.setClockOutTime(now);
|
||||
//判断当前打卡时间是否在下班时间之后
|
||||
LocalTime endWorkTime = appById.getEndWorkTime(); //下班
|
||||
if (!localTime.isAfter(endWorkTime)) {
|
||||
wgzAttendance.setEarlyLeave(1); //早退
|
||||
wgzAttendance.setEarlyLeaveTime(now);
|
||||
wgzAttendance.setExceptionType("2,");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public WgzAttendance findByUserIdWait(Long appUserId, Long recruitId, String date) {
|
||||
// LambdaQueryWrapper<WgzAttendance> qw = new LambdaQueryWrapper<>();
|
||||
// qw.eq(WgzAttendance::getRecruitId,recruitId);
|
||||
// qw.eq(WgzAttendance::getUserId,appUserId);
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
@ -6,9 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserDailyCalendarReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserDailyRecordReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppLeaveHistoryListPageRes;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppDailyCalendarReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppDailyRecordReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppUserDailyRecordRes;
|
||||
import com.ruoyi.wgz.bo.res.WgzUserDailyCalendarRes;
|
||||
import com.ruoyi.wgz.bo.rests.WgzAppAttachmentAcquisitionTwo;
|
||||
@ -113,7 +112,7 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
||||
*/
|
||||
|
||||
@Override
|
||||
public WgzUserDailyCalendarRes userDailyCalendar(WgzAppUserDailyCalendarReq req) {
|
||||
public WgzUserDailyCalendarRes userDailyCalendar(WgzAppDailyCalendarReq req) {
|
||||
//1、获取当月的所有日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
LocalDate firstDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||
@ -153,7 +152,7 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(WgzAppUserDailyRecordReq req) {
|
||||
public TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(WgzAppDailyRecordReq req) {
|
||||
Page<WgzAppUserDailyRecordRes> pe = new Page<>();
|
||||
pe.setCurrent(req.getPageNum());
|
||||
pe.setSize(req.getPageSize());
|
||||
|
||||
@ -175,7 +175,7 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
|
||||
eq(WgzLeave::getUserId, appUserId).
|
||||
eq(WgzLeave::getRecruitId, by.getId()).
|
||||
eq(WgzLeave::getAuditorType, "2")
|
||||
.apply("date_format(start_time,'%Y%m') = {0}", yearMonth);
|
||||
.apply("date_format(start_time,'%Y-%m') = {0}", yearMonth);
|
||||
List<WgzLeave> wgzLeaves = baseMapper.selectList(apply);
|
||||
wgzLeaves.forEach( leave -> {
|
||||
LocalDateTime startTime = leave.getStartTime();
|
||||
@ -184,4 +184,14 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
|
||||
});
|
||||
return ld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WgzLeave FindAskForLeaveOrNotInfo(Long appUserId, Long recruitId, String date) {
|
||||
LambdaQueryWrapper<WgzLeave> apply = new LambdaQueryWrapper<WgzLeave>().
|
||||
eq(WgzLeave::getUserId, appUserId).
|
||||
eq(WgzLeave::getRecruitId, recruitId).
|
||||
eq(WgzLeave::getAuditorType, "2")
|
||||
.apply("date_format(start_time,'%Y-%m-%d') = {0}", date);
|
||||
return baseMapper.selectOne(apply);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.wgz.bo.WgzUserQueryBo;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppModifyingUserProfilePictureReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppPersonalBasicInformationReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppRegisterReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppRealNameAuthenticationReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppPersonalBasicInformationRes;
|
||||
import com.ruoyi.wgz.common.SnowflakeIdUtil;
|
||||
@ -116,7 +116,7 @@ public class WgzUserServiceImpl extends ServicePlusImpl<WgzUserMapper, WgzUser>
|
||||
|
||||
//注册
|
||||
@Override
|
||||
public Boolean userRegister(WgzAppUserRegisterReq bo) {
|
||||
public Boolean userRegister(WgzAppRegisterReq bo) {
|
||||
WgzUser wgzUser = new WgzUser();
|
||||
//1、查询手机号是否存在
|
||||
Integer count = baseMapper.selectCount(
|
||||
|
||||
Reference in New Issue
Block a user