Parcourir la source

1.考勤组添加午休设置

main
wangqiang il y a 1 jour
Parent
révision
007202d0e4

+ 1
- 1
zs-manager/src/main/java/com/ruoyi/zhushi/controller/NjRuleConfigController.java Voir le fichier

import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;


/** /**
* 打卡控制台
* 年假规则配置
*/ */
@Validated @Validated
@RequiredArgsConstructor @RequiredArgsConstructor

+ 13
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkAttendanceGroup.java Voir le fichier

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

/** '午休开始时间' */
@TableField(value = "lunch_start_time")
private String lunchStartTime;

/** '午休结束时间 */
@TableField(value = "lunch_end_time")
private String lunchEndTime;

/** 午休时间 单位小时*/
@TableField(value = "lunch_time")
private String lunchTime;

} }

+ 8
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkAttendanceGroupDTO.java Voir le fichier

private Long areaId; private Long areaId;


private List<DkAttendanceGroupAndUser> members; private List<DkAttendanceGroupAndUser> members;

private String lunchStartTime;


private String lunchEndTime;

private String c;

} }

+ 19
- 28
zs-manager/src/main/java/com/ruoyi/zhushi/service/impl/DkRecordServiceImpl.java Voir le fichier

String workEndTime = dkAttendanceGroup.getWorkEndTime(); String workEndTime = dkAttendanceGroup.getWorkEndTime();
LocalDateTime workEndTime1 = LocalDateTime.of(localDate, LocalTime.parse(workEndTime)); LocalDateTime workEndTime1 = LocalDateTime.of(localDate, LocalTime.parse(workEndTime));


// 获取所属考勤组的午休开始时间
String lunchStartTime = dkAttendanceGroup.getLunchStartTime();
LocalDateTime lunchStartTime1 = LocalDateTime.of(localDate, LocalTime.parse(lunchStartTime));
// 获取所属考勤组的午休结束时间
String lunchEndTime = dkAttendanceGroup.getLunchEndTime();
LocalDateTime lunchEndTime1 = LocalDateTime.of(localDate, LocalTime.parse(lunchEndTime));
// 获取所属考勤组的午休时间
String lunchTime = dkAttendanceGroup.getLunchTime();

// 构造DayRecord // 构造DayRecord
DayRecord dayRecord = new DayRecord(); DayRecord dayRecord = new DayRecord();
dayRecord.setDay(localDate.getDayOfMonth()); dayRecord.setDay(localDate.getDayOfMonth());
DayOfWeek dayOfWeek = localDate.getDayOfWeek(); DayOfWeek dayOfWeek = localDate.getDayOfWeek();
int week = dayOfWeek.getValue(); int week = dayOfWeek.getValue();
String chineseWeek = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CHINESE); String chineseWeek = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CHINESE);
// System.out.println("中文星期:" + chineseWeek); // 输出:星期三
//System.out.println("中文星期:" + chineseWeek); // 输出:星期三
dayRecord.setWeekday(chineseWeek); dayRecord.setWeekday(chineseWeek);
dayRecord.setStartTime(null != dk.getClockIn() ? dk.getClockIn().format(DateTimeFormatter.ofPattern("HH:mm:ss")) : ""); dayRecord.setStartTime(null != dk.getClockIn() ? dk.getClockIn().format(DateTimeFormatter.ofPattern("HH:mm:ss")) : "");
dayRecord.setEndTime(null != dk.getClockOut() ? dk.getClockOut().format(DateTimeFormatter.ofPattern("HH:mm:ss")) : ""); dayRecord.setEndTime(null != dk.getClockOut() ? dk.getClockOut().format(DateTimeFormatter.ofPattern("HH:mm:ss")) : "");
//上下班都打卡了 //上下班都打卡了
if(dk.getClockIn() != null && dk.getClockOut() != null){ if(dk.getClockIn() != null && dk.getClockOut() != null){
double Overtime = 0; double Overtime = 0;
//12点前 减去午休 1小时
if (getTimeCode(dk.getClockIn())==0) {
// 计算时间差 判断 打卡时间是不是在上班时间之后 之后使用打卡时间 否则使用规定上班时间
if (dk.getClockIn().isBefore(lunchStartTime1)) {
// 午休之前 打卡时间在规定上班时间后 使用打卡时间 否则使用规定上班时间 计算
Overtime = calculateOvertime(dk.getClockIn().isAfter(workStartTime1)?dk.getClockIn():workStartTime1, Overtime = calculateOvertime(dk.getClockIn().isAfter(workStartTime1)?dk.getClockIn():workStartTime1,
dk.getClockOut(),1);
}else if (getTimeCode(dk.getClockIn())==1){//12-13 点打卡 不减少午休 按照 13点开始算
LocalDateTime newTime = dk.getClockIn().withHour(13).withMinute(0).withSecond(0).withNano(0);
Overtime = calculateOvertime(newTime,dk.getClockOut(),0);
} else if (getTimeCode(dk.getClockIn())==2){//13点后 不减午休
// 计算时间差 判断 打卡时间是不是在上班时间之后 之后使用打卡时间 否则使用规定上班时间
dk.getClockOut(),Double.valueOf(lunchTime));

}else if (dk.getClockIn().isAfter(lunchStartTime1)){
//午休之后 打卡时间计算
Overtime = calculateOvertime(dk.getClockIn(),dk.getClockOut(),0); Overtime = calculateOvertime(dk.getClockIn(),dk.getClockOut(),0);
} else {
//午休中 使用午休结束时间计算
Overtime = calculateOvertime(lunchEndTime1,dk.getClockOut(),0);
} }
//转换时间格式 //转换时间格式
dayRecord.setXiuxiri(formatOvertime(Overtime)); dayRecord.setXiuxiri(formatOvertime(Overtime));
// 每0.5小时为单位,舍去不足 // 每0.5小时为单位,舍去不足
double stepped = Math.floor(hours * 2) / 2.0; double stepped = Math.floor(hours * 2) / 2.0;
return stepped; return stepped;
/* // 判断是否是整数
if (stepped == (int) stepped) {
return String.valueOf((int) stepped); // 去掉 .0
} else {
return String.valueOf(stepped); // 保留 .5
}*/
} }


/*--------------------------------------------------日本 --------------------------*/ /*--------------------------------------------------日本 --------------------------*/
// 格式化为 HH:mm:ss 字符串 // 格式化为 HH:mm:ss 字符串
return String.format("%d:%02d:00", hours, minutesPart); return String.format("%d:%02d:00", hours, minutesPart);
} }
// 判断时间 在12前 0 12-13 1 13点后2
public static int getTimeCode(LocalDateTime time) {
int hour = time.getHour();

if (hour < 12) {
return 0;
} else if (hour == 12) {
return 1;
} else {
return 2;
}
}







Chargement…
Annuler
Enregistrer