ソースを参照

1.添加注释

2.去掉无用代码
3.考勤打卡excel导出修改
main
wangqiang 3日前
コミット
d79f1e51e6

+ 15
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkAttendanceGroup.java ファイルの表示

import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;


/**
* 任务组配置表
* 对应表: dk_check_in_attendance_team
*/
@Data @Data
@TableName("dk_check_in_attendance_team") @TableName("dk_check_in_attendance_team")
public class DkAttendanceGroup extends BaseEntity { public class DkAttendanceGroup extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private long id; private long id;


/** 考勤组名称 */
@TableField(value = "`name`") @TableField(value = "`name`")
private String name; private String name;


/** 描述 */
@TableField(value = "`description`") @TableField(value = "`description`")
private String description; private String description;


/** 打卡时间 */
@TableField(value = "`work_days`") @TableField(value = "`work_days`")
private String workDays; private String workDays;


/** 开始打卡时间 */
@TableField(value = "`work_start_time`") @TableField(value = "`work_start_time`")
private String workStartTime; private String workStartTime;


/** 结束打卡时间 */
@TableField(value = "`work_end_time`") @TableField(value = "`work_end_time`")
private String workEndTime; private String workEndTime;


/** 允许迟到 */
@TableField(value = "`allow_late`") @TableField(value = "`allow_late`")
private Boolean allowLate; private Boolean allowLate;


/** 迟到范围 */
@TableField(value = "`late_range`") @TableField(value = "`late_range`")
private Integer lateRange; private Integer lateRange;


/** 允许早退 */
@TableField(value = "`allow_early`") @TableField(value = "`allow_early`")
private Boolean allowEarly; private Boolean allowEarly;


/** 早退范围 */
@TableField(value = "`early_range`") @TableField(value = "`early_range`")
private Integer earlyRange; private Integer earlyRange;


/** 区域配置id */
@TableField(value = "area_id") @TableField(value = "area_id")
private long areaId; private long areaId;
} }

+ 16
- 5
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkAttendanceGroupAndUser.java ファイルの表示

import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;


/**
* 任务组用户配置表
* 对应表: dk_check_in_attendance_team_and_user
*/
@Data @Data
@TableName("dk_check_in_attendance_team_and_user") @TableName("dk_check_in_attendance_team_and_user")
public class DkAttendanceGroupAndUser extends BaseEntity { public class DkAttendanceGroupAndUser extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private int id; private int id;


/** 考勤组id */
@TableField(value = "`attendance_team_id`") @TableField(value = "`attendance_team_id`")
private long attendanceTeamId; private long attendanceTeamId;


/** 考勤组名称 */
@TableField(value = "`attendance_group_name`")
private String AttendanceGroupName;

/** 用户id */
@TableField(value = "`user_id`") @TableField(value = "`user_id`")
private long userId; private long userId;


/** 姓名 */
@TableField(value = "`user_name`") @TableField(value = "`user_name`")
private String userName; private String userName;


@TableField(value = "`dept_name`")
private String deptName;

/** 用户昵称 */
@TableField(value = "`nick_name`") @TableField(value = "`nick_name`")
private String nickName; private String nickName;


@TableField(value = "`attendance_group_name`")
private String AttendanceGroupName;
/** 所属部门 */
@TableField(value = "`dept_name`")
private String deptName;
} }

+ 10
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkCheckInConfig.java ファイルの表示

import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;


/**
* 打卡配置表
* 对应表: dk_check_in_config
*/
@Data @Data
@TableName("dk_check_in_config") @TableName("dk_check_in_config")
public class DkCheckInConfig extends BaseEntity { public class DkCheckInConfig extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private int id; private int id;


/** 地点名称 */
@TableField(value = "`name`") @TableField(value = "`name`")
private String name; private String name;


/** 打卡半径/米 */
@TableField(value = "`radius`") @TableField(value = "`radius`")
private Integer radius; private Integer radius;


/** 启用状态 */
@TableField(value = "`enabled`") @TableField(value = "`enabled`")
private Boolean enabled; private Boolean enabled;


/** 经度 */
@TableField(value = "`lng`") @TableField(value = "`lng`")
private String lng; private String lng;


/** 纬度 */
@TableField(value = "`lat`") @TableField(value = "`lat`")
private String lat; private String lat;



+ 46
- 41
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkCheckInRecord.java ファイルの表示



import java.time.LocalDateTime; import java.time.LocalDateTime;


/**
* 打卡记录表
* 对应表: dk_check_in_record
*/
@Data @Data
@TableName("dk_check_in_record") @TableName("dk_check_in_record")
public class DkCheckInRecord extends BaseEntity { public class DkCheckInRecord extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private String id; private String id;


// 用户id
/** 用户id */
@TableField(value = "`sys_user_id`") @TableField(value = "`sys_user_id`")
private Long sysUserId; private Long sysUserId;


// 用户姓名
/** 用户名称 */
@TableField(value = "`sys_user_name`") @TableField(value = "`sys_user_name`")
private String sysUserName; private String sysUserName;


// 打卡时间
/** 用户昵称 */
@TableField(value = "`nick_name`")
private String nickName;

/** 考勤组id */
@TableField(value = "`attendance_group_id`")
private long attendanceGroupId;

/** 考勤组名称 */
@TableField(value = "`attendance_group_name`")
private String attendanceGroupName;

/** 月 */
@TableField(value = "`month`")
private int month;

/** 周 */
@TableField(value = "`week`")
private String week;

/** 日 */
@TableField(value = "`day`")
private int day;

/** 打卡时间 */
@TableField(value = "`check_in_time`") @TableField(value = "`check_in_time`")
private LocalDateTime checkInTime; private LocalDateTime checkInTime;


// 纬度
/** 经度 */
@TableField(value = "`latitude`") @TableField(value = "`latitude`")
private String latitude; private String latitude;


//经度
/** 纬度 */
@TableField(value = "`longitude`") @TableField(value = "`longitude`")
private String longitude; private String longitude;


// 打卡状态
@TableField(value = "`check_in_status`")
private String checkInStatus;

// 打卡类型
/** 打卡分类 */
@TableField(value = "`check_in_type`") @TableField(value = "`check_in_type`")
private String checkInType; private String checkInType;


// 上班打卡时间
@TableField(value = "`clock_in`")
private LocalDateTime clockIn;
/** 打卡状态 0正常 1迟到 2缺卡 */
@TableField(value = "`check_in_status`")
private String checkInStatus;


// 上班打卡状态
/** 上班打卡状态 */
@TableField(value = "`clock_in_status`") @TableField(value = "`clock_in_status`")
private String clockInStatus; private String clockInStatus;


// 下班打卡状态
/** 下班打卡状态 */
@TableField(value = "`clock_out_status`") @TableField(value = "`clock_out_status`")
private String clockOutStatus; private String clockOutStatus;


// 下班打卡时间
/** 上班打卡 */
@TableField(value = "`clock_in`")
private LocalDateTime clockIn;

/** 下班打卡 */
@TableField(value = "`clock_out`") @TableField(value = "`clock_out`")
private LocalDateTime clockOut; private LocalDateTime clockOut;


// 打卡月
@TableField(value = "`month`")
private int month;

// 打卡周
@TableField(value = "`week`")
private String week;

// 打卡日
@TableField(value = "`day`")
private int day;

// 描述
/** 描述 */
@TableField(value = "`description`") @TableField(value = "`description`")
private String description; private String description;

// 考勤组id
@TableField(value = "`attendance_group_id`")
private long attendanceGroupId;

// 考勤组名称
@TableField(value = "`attendance_group_name`")
private String attendanceGroupName;

// 用户姓名
@TableField(value = "`nick_name`")
private String nickName;
} }

+ 9
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/EmployeeAttendance.java ファイルの表示

public class EmployeeAttendance { public class EmployeeAttendance {
private long userId; private long userId;
private String employeeName; private String employeeName;
private String userName;
private String nickName; private String nickName;
private String department; private String department;
private String dateTime; private String dateTime;
this.nickName = nickName; this.nickName = nickName;
} }


public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getDepartment() { public String getDepartment() {
return department; return department;
} }

+ 14
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/NjBalanceManage.java ファイルの表示



import java.math.BigDecimal; import java.math.BigDecimal;


/**
* 用户年假管理表
* 对应表: nj_balance_manage
*/
@Data @Data
@TableName("nj_balance_manage") @TableName("nj_balance_manage")
public class NjBalanceManage extends BaseEntity { public class NjBalanceManage extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private long id; private long id;


/** 员工编号 */
@TableField(value = "`user_id`") @TableField(value = "`user_id`")
private long userId; private long userId;


/** 员工姓名 */
@TableField(value = "`user_name`") @TableField(value = "`user_name`")
private String userName; private String userName;


/** 员工姓名 */
@TableField(value = "`nick_name`") @TableField(value = "`nick_name`")
private String nickName; private String nickName;


/** 部门名称 */
@TableField(value = "`dept_name`") @TableField(value = "`dept_name`")
private String deptName; private String deptName;


/** 年假总额 */
@TableField(value = "`annual_leave`") @TableField(value = "`annual_leave`")
private BigDecimal annualLeave; private BigDecimal annualLeave;


/** 已使用天数 */
@TableField(value = "`used_day`") @TableField(value = "`used_day`")
private BigDecimal usedDay; private BigDecimal usedDay;


/** 剩余天数 */
@TableField(value = "`unused_day`") @TableField(value = "`unused_day`")
private BigDecimal unusedDay; private BigDecimal unusedDay;


/** 上年结转 */
@TableField(value = "`last_year_unused_day`") @TableField(value = "`last_year_unused_day`")
private BigDecimal lastYearUnusedDay; private BigDecimal lastYearUnusedDay;


/** 状态 */
@TableField(value = "`is_enable`") @TableField(value = "`is_enable`")
private Boolean isEnable; private Boolean isEnable;
} }

+ 12
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/NjRuleConfig.java ファイルの表示

import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;


/**
* 年假配置表
* 对应表: nj_rule_config
*/
@Data @Data
@TableName("nj_rule_config") @TableName("nj_rule_config")
public class NjRuleConfig extends BaseEntity { public class NjRuleConfig extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private long id; private long id;


/** 规则名称 */
@TableField(value = "`rule_name`") @TableField(value = "`rule_name`")
private String ruleName; private String ruleName;


/** 年假起算方式 1:自然年,2,入职周年 */
@TableField(value = "`calculation_method`") @TableField(value = "`calculation_method`")
private Integer calculationMethod; private Integer calculationMethod;


/** 年假发放规则 入职满一年(5天):5, 入职满10年(10天):10,入职满20年(15天):15, 默认规则:0 */
@TableField(value = "`annualLeave_tiers`") @TableField(value = "`annualLeave_tiers`")
private Integer annualLeaveTiers; private Integer annualLeaveTiers;


/** 年假有效期 true:当前年有效 */
@TableField(value = "`validity_period`") @TableField(value = "`validity_period`")
private Boolean validityPeriod; private Boolean validityPeriod;


/** 可否请半天年假 true:可以,false:不可以 */
@TableField(value = "`allow_half_day`") @TableField(value = "`allow_half_day`")
private Boolean allowHalfDay; private Boolean allowHalfDay;


/** 适用范围 true:全部,false:指定员工 */
@TableField(value = "`applicable_range`") @TableField(value = "`applicable_range`")
private Boolean applicableRange; private Boolean applicableRange;


/** 生成周期 true:当前年一月一日 */
@TableField(value = "`generation_cycle`") @TableField(value = "`generation_cycle`")
private Boolean generationCycle; private Boolean generationCycle;



+ 12
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/NjRuleConfigAndUser.java ファイルの表示



import java.time.LocalDate; import java.time.LocalDate;


/**
* 年假用户表
* 对应表: nj_rule_config_and_user
*/
@Data @Data
@TableName("nj_rule_config_and_user") @TableName("nj_rule_config_and_user")
public class NjRuleConfigAndUser extends BaseEntity { public class NjRuleConfigAndUser extends BaseEntity {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private long id; private long id;


/** 配置表ID */
@TableField(value = "`nj_rule_config_id`") @TableField(value = "`nj_rule_config_id`")
private long njRuleConfigId; private long njRuleConfigId;


/** 规则名称 */
@TableField(value = "`rule_name`") @TableField(value = "`rule_name`")
private String ruleName; private String ruleName;


/** 用户id */
@TableField(value = "`user_id`") @TableField(value = "`user_id`")
private long userId; private long userId;


/** 用户名称 */
@TableField(value = "`user_name`") @TableField(value = "`user_name`")
private String userName; private String userName;


/** 用户名称 */
@TableField(value = "`nick_name`") @TableField(value = "`nick_name`")
private String nickName; private String nickName;


/** 部门名称 */
@TableField(value = "`dept_name`") @TableField(value = "`dept_name`")
private String deptName; private String deptName;


/** 入职时间 */
@TableField(value = "`joined_date`") @TableField(value = "`joined_date`")
private LocalDate joinedDate; private LocalDate joinedDate;
} }

+ 2
- 108
zs-manager/src/main/java/com/ruoyi/zhushi/job/DkJob.java ファイルの表示



// 每天18执行 // 每天18执行
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
// @Scheduled(cron = "0/10 * * * * ?")
public void executeTask() throws ParseException { public void executeTask() throws ParseException {
// 任务逻辑 // 任务逻辑
System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis()); System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
try { try {
// 判断当天时间是否为节假日,为0的时候是工作日
// String yearHoliday = HolidayUtil.isWorkingDay(LocalDate.now().toString());
// if(yearHoliday.equals("0")){
// 获取所有员工
List<JSONObject> jsonObjects = dkRecordMapper.queryAllUsers();
// 获取所有员工
List<JSONObject> jsonObjects = dkRecordMapper.queryAllUsers(null);
for (JSONObject jsonObject : jsonObjects) { for (JSONObject jsonObject : jsonObjects) {
// 获取员工id // 获取员工id
Long userId = jsonObject.getLong("userId"); Long userId = jsonObject.getLong("userId");
if(appDTO == null){ if(appDTO == null){
continue; continue;
} }
// 获取员工打卡记录根据员工id
// List<DkCheckInRecord> records = dkRecordMapper.getRecordHistory(userId);
// if(records == null || records.size() == 0){
DkCheckInRecord dkCheckInRecord = new DkCheckInRecord(); DkCheckInRecord dkCheckInRecord = new DkCheckInRecord();
dkCheckInRecord.setSysUserId(userId); dkCheckInRecord.setSysUserId(userId);
dkCheckInRecord.setSysUserName(userName); dkCheckInRecord.setSysUserName(userName);
dkCheckInRecord.setAttendanceGroupId(appDTO.getId()); dkCheckInRecord.setAttendanceGroupId(appDTO.getId());
dkCheckInRecord.setAttendanceGroupName(appDTO.getName()); dkCheckInRecord.setAttendanceGroupName(appDTO.getName());
dkRecordMapper.insertOrUpdate(dkCheckInRecord); dkRecordMapper.insertOrUpdate(dkCheckInRecord);
// }

} }
// }

System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis()); System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
// 具体任务逻辑 // 具体任务逻辑
} catch (Exception e) { } catch (Exception e) {
} }
} }


// 每周一到周五18点执行
// @Scheduled(cron = "0 0 18 ? * MON-FRI")
public void executeWeekdayTask() {
System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
try {

// 获取所有员工
List<JSONObject> jsonObjects = dkRecordMapper.queryAllUsers();
for (JSONObject jsonObject : jsonObjects) {
// 获取员工id
Long userId = jsonObject.getLong("userId");
// 如果没有员工id,则跳过
if (userId == null){
continue;
}
// 获取员工姓名
String userName = jsonObject.getString("userName");

// 根据userId 查询考勤组信息
DkAttendanceGroup appDTO = dkRecordMapper.queryConfigByUserId(userId);
// 如果没有考勤组信息,则跳过
if(appDTO == null){
continue;
}
// 获取员工打卡记录根据员工id
List<DkCheckInRecord> records = dkRecordMapper.getRecordHistory(userId);
if(records == null || records.size() == 0){
DkCheckInRecord dkCheckInRecord = new DkCheckInRecord();
dkCheckInRecord.setSysUserId(userId);
dkCheckInRecord.setSysUserName(userName);
dkCheckInRecord.setCheckInTime(LocalDateTime.now());
dkCheckInRecord.setCheckInStatus(Constans.CHECK_IN_STATUS_0);
dkCheckInRecord.setClockInStatus(Constans.CHECK_IN_STATUS_0);
dkCheckInRecord.setClockOutStatus(Constans.CHECK_IN_STATUS_0);
dkCheckInRecord.setAttendanceGroupId(appDTO.getId());
dkCheckInRecord.setAttendanceGroupName(appDTO.getName());
dkRecordMapper.insertOrUpdate(dkCheckInRecord);
}

}

System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
// 具体任务逻辑
} catch (Exception e) {
System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
}
}



// @Scheduled(cron = "0/10 * * * * MON-FRI") // 每分钟执行
// public void testTask() {
// System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
// try {
// // 获取所有员工
// List<JSONObject> jsonObjects = dkRecordMapper.queryAllUsers();
// for (JSONObject jsonObject : jsonObjects) {
// // 获取员工id
// Long userId = jsonObject.getLong("userId");
// // 如果没有员工id,则跳过
// if (userId == null){
// continue;
// }
// // 获取员工姓名
// String userName = jsonObject.getString("userName");
//
// // 根据userId 查询考勤组信息
// DkAttendanceGroup appDTO = dkRecordMapper.queryConfigByUserId(userId);
// // 如果没有考勤组信息,则跳过
// if(appDTO == null){
// continue;
// }
// // 获取员工打卡记录根据员工id
// List<DkCheckInRecord> records = dkRecordMapper.getRecordHistory(userId);
// if(records == null || records.size() == 0){
// DkCheckInRecord dkCheckInRecord = new DkCheckInRecord();
// dkCheckInRecord.setSysUserId(userId);
// dkCheckInRecord.setSysUserName(userName);
// dkCheckInRecord.setCheckInTime(LocalDateTime.now());
// dkCheckInRecord.setCheckInStatus(Constans.CHECK_IN_STATUS_0);
// dkCheckInRecord.setClockInStatus(Constans.CHECK_IN_STATUS_0);
// dkCheckInRecord.setClockOutStatus(Constans.CHECK_IN_STATUS_0);
// dkCheckInRecord.setAttendanceGroupId(appDTO.getId());
// dkCheckInRecord.setAttendanceGroupName(appDTO.getName());
// dkRecordMapper.insertOrUpdate(dkCheckInRecord);
// }
//
// }
//
// System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
// // 具体任务逻辑
// } catch (Exception e) {
// System.out.println("执行工作日18点定时任务:" + System.currentTimeMillis());
// }
// }


} }

+ 1
- 1
zs-manager/src/main/java/com/ruoyi/zhushi/mapper/DkRecordMapper.java ファイルの表示



List<DkCheckInRecord> getRecordHistory(@Param("userId") long userId); List<DkCheckInRecord> getRecordHistory(@Param("userId") long userId);


List<JSONObject> queryAllUsers();
List<JSONObject> queryAllUsers(@Param("attendanceGroupIds") List<Long> attendanceGroupIds);
} }

+ 342
- 684
zs-manager/src/main/java/com/ruoyi/zhushi/service/impl/DkRecordServiceImpl.java
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 20
- 1
zs-manager/src/main/resources/mapper/DkRecordMapper.xml ファイルの表示

</select> </select>


<select id="queryAllUsers" resultType="com.alibaba.fastjson.JSONObject"> <select id="queryAllUsers" resultType="com.alibaba.fastjson.JSONObject">
SELECT user_id userId, user_name userName , nick_name nickName FROM `sys_user`
SELECT
user_id userId,
user_name userName,
nick_name nickName
FROM
sys_user u
WHERE
del_flag = 0
AND u.dept_id IN ( SELECT dept_id FROM sys_dept WHERE FIND_IN_SET( '100', ancestors ) OR dept_id = 100 )
AND user_id != 1
<if test="attendanceGroupIds != null and attendanceGroupIds.size() > 0">
AND user_id IN (
SELECT user_id
FROM dk_check_in_attendance_team_and_user
WHERE attendance_team_id IN
<foreach collection="attendanceGroupIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
</select> </select>


<select id="getRecordHistory" resultType="com.ruoyi.zhushi.entity.DkCheckInRecord"> <select id="getRecordHistory" resultType="com.ruoyi.zhushi.entity.DkCheckInRecord">

バイナリ
zs-manager/src/main/resources/template/template-guonei.xlsx ファイルの表示


バイナリ
zs-manager/src/main/resources/template/template-riben.xlsx ファイルの表示


読み込み中…
キャンセル
保存