diff --git a/snow-admin/src/main/java/com/snow/system/controller/SysOaAttendanceController.java b/snow-admin/src/main/java/com/snow/system/controller/SysOaAttendanceController.java index b29830c..90d6395 100644 --- a/snow-admin/src/main/java/com/snow/system/controller/SysOaAttendanceController.java +++ b/snow-admin/src/main/java/com/snow/system/controller/SysOaAttendanceController.java @@ -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 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)); } diff --git a/snow-admin/src/main/resources/templates/system/attendance/add.html b/snow-admin/src/main/resources/templates/system/attendance/add.html index 8d90756..d9ef72f 100644 --- a/snow-admin/src/main/resources/templates/system/attendance/add.html +++ b/snow-admin/src/main/resources/templates/system/attendance/add.html @@ -8,56 +8,7 @@
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
-
-
- -
- -
-
-
- +
@@ -65,63 +16,15 @@
-
- -
-
- - -
-
-
-
+
- +
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
-
-
- -
- -
-
diff --git a/snow-admin/src/main/resources/templates/system/attendance/attendance.html b/snow-admin/src/main/resources/templates/system/attendance/attendance.html index f051940..9087bc3 100644 --- a/snow-admin/src/main/resources/templates/system/attendance/attendance.html +++ b/snow-admin/src/main/resources/templates/system/attendance/attendance.html @@ -59,7 +59,7 @@
- 添加 + 补卡 修改 diff --git a/snow-quartz/src/main/java/com/snow/quartz/task/SyncDingAttendanceTask.java b/snow-quartz/src/main/java/com/snow/quartz/task/SyncDingAttendanceTask.java index eea4b3c..cc18a8b 100644 --- a/snow-quartz/src/main/java/com/snow/quartz/task/SyncDingAttendanceTask.java +++ b/snow-quartz/src/main/java/com/snow/quartz/task/SyncDingAttendanceTask.java @@ -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 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 sysOaAttendanceLambdaQueryWrapper = new QueryWrapper().lambda().eq(SysOaAttendance::getAttendanceId,attendance.getId()); SysOaAttendance oaAttendance= sysOaAttendanceService.getOne(sysOaAttendanceLambdaQueryWrapper); diff --git a/snow-system/src/main/java/com/snow/system/domain/SysOaAttendance.java b/snow-system/src/main/java/com/snow/system/domain/SysOaAttendance.java index 2e75401..4f69a8c 100644 --- a/snow-system/src/main/java/com/snow/system/domain/SysOaAttendance.java +++ b/snow-system/src/main/java/com/snow/system/domain/SysOaAttendance.java @@ -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;