新增考勤接口

This commit is contained in:
jinqiming 2022-02-09 17:46:08 +08:00
parent fa5450c571
commit 262e138752
5 changed files with 51 additions and 104 deletions

View File

@ -1,6 +1,15 @@
package com.snow.system.controller;
import java.util.Date;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.snow.common.constant.SequenceConstants;
import com.snow.framework.util.ShiroUtils;
import com.snow.system.domain.SysUser;
import com.snow.system.service.ISysSequenceService;
import com.snow.system.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
@ -34,6 +43,12 @@ public class SysOaAttendanceController extends BaseController
@Autowired
private ISysOaAttendanceService sysOaAttendanceService;
@Autowired
private ISysSequenceService sequenceService;
@Autowired
private ISysUserService sysUserService;
@RequiresPermissions("system:attendance:view")
@GetMapping()
public String attendance()
@ -51,6 +66,12 @@ public class SysOaAttendanceController extends BaseController
{
startPage();
List<SysOaAttendance> list = sysOaAttendanceService.selectSysOaAttendanceList(sysOaAttendance);
if(CollUtil.isNotEmpty(list)){
list.forEach(t->{
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(t.getUserId()));
t.setUserId(sysUser.getUserName());
});
}
return getDataTable(list);
}
@ -86,6 +107,15 @@ public class SysOaAttendanceController extends BaseController
@ResponseBody
public AjaxResult addSave(SysOaAttendance sysOaAttendance)
{
Long userId = ShiroUtils.getUserId();
sysOaAttendance.setUserId(String.valueOf(userId));
if(ObjectUtil.isEmpty(sysOaAttendance.getUserCheckTime())){
sysOaAttendance.setUserCheckTime(new Date());
}
String attendanceCode = sequenceService.getNewSequenceNo(SequenceConstants.OA_ATTENDANCE_SEQUENCE);
sysOaAttendance.setAttendanceCode(attendanceCode);
sysOaAttendance.setSourceType("USER");
sysOaAttendance.setWorkDate(new Date());
return toAjax(sysOaAttendanceService.insertSysOaAttendance(sysOaAttendance));
}

View File

@ -8,56 +8,7 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-attendance-add">
<div class="form-group">
<label class="col-sm-3 control-label is-required">考勤编码:</label>
<div class="col-sm-8">
<input name="attendanceCode" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">考勤来源详见字典表sys_oa_attendance_source_type(ATM考勤机打卡</label>
<div class="col-sm-8">
<select name="sourceType" class="form-control m-b" th:with="type=${@dict.getType('sys_oa_attendance_source_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">关联的审批实例ID当该字段非空时表示打卡记录与请假、加班等审批有关</label>
<div class="col-sm-8">
<input name="procInstId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">关联的审批实例ID当该字段非空时表示打卡记录与请假、加班等审批有关</label>
<div class="col-sm-8">
<input name="approveId" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">打卡结果详见字典表sys_oa_attendance_time_result(Normal正常Early早退Late迟到SeriousLate严重迟到Absenteeism旷工迟到NotSigned未打卡)</label>
<div class="col-sm-8">
<select name="timeResult" class="form-control m-b" th:with="type=${@dict.getType('sys_oa_attendance_time_result')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">位置结果详见字典表sys_oa_attendance_location_result </label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_oa_attendance_location_result')}">
<input type="radio" th:id="${'locationResult_' + dict.dictCode}" name="locationResult" th:value="${dict.dictValue}" th:checked="${dict.default}">
<label th:for="${'locationResult_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">打卡人的UserID</label>
<div class="col-sm-8">
<input name="userId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">考勤类型详见字典表sys_oa_attendance_check_type(OnDuty上班OffDuty下班</label>
<label class="col-sm-3 control-label">考勤类型:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_oa_attendance_check_type')}">
<input type="radio" th:id="${'checkType_' + dict.dictCode}" name="checkType" th:value="${dict.dictValue}" th:checked="${dict.default}">
@ -65,63 +16,15 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">实际打卡时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="userCheckTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">工作日:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="workDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
<input type="text" class="date-input form-control" name="workDate" placeholder="请选择补卡工作日" required/>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">打卡记录ID</label>
<div class="col-sm-8">
<input name="recordId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">排班ID</label>
<div class="col-sm-8">
<input name="planId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">考勤组id</label>
<div class="col-sm-8">
<input name="groupId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">考勤组id</label>
<div class="col-sm-8">
<input name="attendanceId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">计算迟到和早退,基准时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="baseCheckTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">删除标识:</label>
<div class="col-sm-8">
<input name="isDelete" class="form-control" type="text">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />

View File

@ -59,7 +59,7 @@
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:attendance:add">
<i class="fa fa-plus"></i> 添加
<i class="fa fa-plus"></i> 补卡
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:attendance:edit">
<i class="fa fa-edit"></i> 修改

View File

@ -12,8 +12,11 @@ import com.snow.dingtalk.model.request.AttendanceListRequest;
import com.snow.dingtalk.model.response.AttendanceListResponse;
import com.snow.dingtalk.service.AttendanceService;
import com.snow.system.domain.SysOaAttendance;
import com.snow.system.domain.SysUser;
import com.snow.system.mapper.SysUserMapper;
import com.snow.system.service.ISysOaAttendanceService;
import com.snow.system.service.ISysSequenceService;
import com.snow.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
@ -39,6 +42,8 @@ public class SyncDingAttendanceTask {
private final ISysSequenceService sequenceService;
private final SysUserMapper sysUserMapper;
/**
* 定时任务同步数据每十分钟同步一次
* @param dataFrom 开始时间
@ -54,13 +59,16 @@ public class SyncDingAttendanceTask {
if(StrUtil.isNotBlank(dataTo)){
attendanceListRequest.setWorkDateTo(dataTo);
}else {
attendanceListRequest.setWorkDateTo(DateUtils.getDate()+" 59:59:59");
attendanceListRequest.setWorkDateTo(DateUtils.getDate()+" 23:59:59");
}
long offset=0L;
long limit=10L;
attendanceListRequest.setOffset(offset);
attendanceListRequest.setLimit(limit);
attendanceListRequest.setUserIdList(CollUtil.newArrayList("manager4480"));
//获取所有用户
SysUser sysUser=new SysUser();
List<SysUser> sysUsers = sysUserMapper.selectUserList(sysUser);
attendanceListRequest.setUserIdList(sysUsers.stream().map(SysUser::getDingUserId).collect(Collectors.toList()));
AttendanceListResponse attendanceListResponse = attendanceService.getAttendanceList(attendanceListRequest);
saveSysOaAttendance(attendanceListResponse);
boolean isHasMore=attendanceListResponse.isHasMore();
@ -86,6 +94,12 @@ public class SyncDingAttendanceTask {
SysOaAttendance sysOaAttendance = BeanUtil.copyProperties(attendance, SysOaAttendance.class);
sysOaAttendance.setAttendanceCode(newSequenceNo);
sysOaAttendance.setAttendanceId(attendance.getId());
//把钉钉的userId转化成系统userId保存
SysUser sysUser = sysUserMapper.selectUserByDingUserId(attendance.getUserId());
if(ObjectUtil.isNull(sysUser)){
return null;
}
sysOaAttendance.setUserId(String.valueOf(sysUser.getUserId()));
//判断是否已同步过
LambdaQueryWrapper<SysOaAttendance> sysOaAttendanceLambdaQueryWrapper = new QueryWrapper<SysOaAttendance>().lambda().eq(SysOaAttendance::getAttendanceId,attendance.getId());
SysOaAttendance oaAttendance= sysOaAttendanceService.getOne(sysOaAttendanceLambdaQueryWrapper);

View File

@ -62,7 +62,7 @@ public class SysOaAttendance extends BaseEntity
private Date userCheckTime;
/** 工作日 */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@Excel(name = "工作日", width = 30, dateFormat = "yyyy-MM-dd")
private Date workDate;