瀏覽代碼

添加导出汇总

main
1341924763@qq.com 2 天之前
父節點
當前提交
f8203c6439

二進制
ruoyi-admin/src/main/resources/template/template-guonei.xlsx 查看文件


+ 29
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/EmployeeAttendance.java 查看文件

package com.ruoyi.zhushi.entity; package com.ruoyi.zhushi.entity;


import java.math.BigDecimal;
import java.util.List; import java.util.List;


public class EmployeeAttendance { public class EmployeeAttendance {
private int chidaocishu = 0; private int chidaocishu = 0;
private int zaotuirenshu = 0; private int zaotuirenshu = 0;
private int zaotuicishu = 0; private int zaotuicishu = 0;
private java.math.BigDecimal workOverTime;
private java.math.BigDecimal restOverTime;

private BigDecimal exceptionCount;


// getters and setters // getters and setters


public void setZaotuicishu(int zaotuicishu) { public void setZaotuicishu(int zaotuicishu) {
this.zaotuicishu = zaotuicishu; this.zaotuicishu = zaotuicishu;
} }

public BigDecimal getWorkOverTime() {
return workOverTime;
}

public void setWorkOverTime(BigDecimal workOverTime) {
this.workOverTime = workOverTime;
}

public BigDecimal getRestOverTime() {
return restOverTime;
}

public void setRestOverTime(BigDecimal restOverTime) {
this.restOverTime = restOverTime;
}

public BigDecimal getExceptionCount() {
return exceptionCount;
}

public void setExceptionCount(BigDecimal exceptionCount) {
this.exceptionCount = exceptionCount;
}
} }

+ 105
- 23
zs-manager/src/main/java/com/ruoyi/zhushi/service/impl/DkRecordServiceImpl.java 查看文件

int lateCount = 0; int lateCount = 0;
// 定义早退次数 // 定义早退次数
int earlyCount = 0; int earlyCount = 0;
// 工作日加班时间
BigDecimal workOverTime = new BigDecimal(0);
// 休息日加班时间
BigDecimal restOverTime = new BigDecimal(0);
// 异常数量
BigDecimal exceptionCount = new BigDecimal(0);

for(DkCheckInRecordDTO dk : dkCheckInRecordDTOS){ for(DkCheckInRecordDTO dk : dkCheckInRecordDTOS){
// 根据打卡时间获取日期 // 根据打卡时间获取日期
LocalDate localDate = dk.getCheckInTime() != null ? dk.getCheckInTime().toLocalDate() : LocalDate.now(); LocalDate localDate = dk.getCheckInTime() != null ? dk.getCheckInTime().toLocalDate() : LocalDate.now();
if(dk.getClockIn() != null && dk.getClockOut() == null){ if(dk.getClockIn() != null && dk.getClockOut() == null){
dayRecord.setYichang("*"); dayRecord.setYichang("*");
dayRecord.setRemark("异常打卡"); dayRecord.setRemark("异常打卡");
exceptionCount = exceptionCount.add(new BigDecimal(1));
if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
lateCount ++;
}
} }
if(dk.getClockIn() == null && dk.getClockOut() != null){ if(dk.getClockIn() == null && dk.getClockOut() != null){
dayRecord.setYichang("*"); dayRecord.setYichang("*");
dayRecord.setRemark("异常打卡"); dayRecord.setRemark("异常打卡");
exceptionCount = exceptionCount.add(new BigDecimal(1));

if(dk.getClockOut().isBefore(workEndTime1)){
dayRecord.setChidao("*");
earlyCount ++;
}
} }
if(dk.getClockIn() == null && dk.getClockOut() == null){ if(dk.getClockIn() == null && dk.getClockOut() == null){
dayRecord.setRemark("缺卡"); dayRecord.setRemark("缺卡");
} }


// 判断是否为工作日加班
if(dk.getClockOut() != null){
if(dk.getClockOut().isAfter(workEndTime1)){

// 判断是否为休假日加班
if(Constans.EXPORT_ZHOULIU==week || Constans.EXPORT_ZHOURI== week){
if(dk.getClockIn() != null && dk.getClockOut() != null){
dayRecord.setXiuxiri("*");
dayRecord.setRemark("加班1次");
// 计算时间差 // 计算时间差
Duration duration = Duration.between(workEndTime1, dk.getClockOut());
Duration duration = Duration.between(dk.getClockIn(), dk.getClockOut());
// 获取小时差(注意:此方法会舍去分钟和秒部分) // 获取小时差(注意:此方法会舍去分钟和秒部分)
long hours1 = duration.toMinutes(); // 结果:6 小时(15:45 - 09:30 = 6小时15分钟) long hours1 = duration.toMinutes(); // 结果:6 小时(15:45 - 09:30 = 6小时15分钟)


BigDecimal b = new BigDecimal("60"); BigDecimal b = new BigDecimal("60");
// 执行除法,指定精度和舍入模式 // 执行除法,指定精度和舍入模式
BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP); BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP);
dayRecord.setGongzuori("*");
dayRecord.setRemark("加班1次:" + result + "小时");
restOverTime = restOverTime.add(result);
}
}
}else {
// 判断是否为工作日加班
if(dk.getClockOut() != null){
if(dk.getClockOut().isAfter(workEndTime1)){
// 计算时间差
Duration duration = Duration.between(workEndTime1, dk.getClockOut());
// 获取小时差(注意:此方法会舍去分钟和秒部分)
long hours1 = duration.toMinutes(); // 结果:6 小时(15:45 - 09:30 = 6小时15分钟)

if(hours1 >= 30){
BigDecimal a = new BigDecimal(hours1);
BigDecimal b = new BigDecimal("60");
// 执行除法,指定精度和舍入模式
BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP);
dayRecord.setGongzuori("*");
dayRecord.setRemark("加班1次:" + result + "小时");

workOverTime = workOverTime.add(result);
}
} }
} }
}
// 判断是否为休假日加班
if(Constans.ZHOULIU.equals(dk.getWeek()) || Constans.ZHOURI.equals(dk.getWeek())){
dayRecord.setXiuxiri("*");
dayRecord.setRemark("加班1次");
} }
// 判断是否为法定节假日加班 // 判断是否为法定节假日加班
// // 获取法定节假日时间 // // 获取法定节假日时间
// dayRecords.add(new DayRecord(3, "日", "", "", "休息", "年假", 0, "")); // dayRecords.add(new DayRecord(3, "日", "", "", "休息", "年假", 0, ""));
// 添加更多日期记录... // 添加更多日期记录...


data.setWorkOverTime(workOverTime);
data.setRestOverTime(restOverTime);
data.setExceptionCount(exceptionCount);
data.setDayRecords(dayRecords); data.setDayRecords(dayRecords);
return data; return data;
} }
setCellValue(sheet, 6, 10, data.getEmployeeName()); setCellValue(sheet, 6, 10, data.getEmployeeName());
setCellValue(sheet, 3, 1, data.getDateTime()); setCellValue(sheet, 3, 1, data.getDateTime());
// setCellValue(sheet, 2, 0, data.getYear() + "年" + data.getMonth() + "月考勤记录"); // setCellValue(sheet, 2, 0, data.getYear() + "年" + data.getMonth() + "月考勤记录");

// 汇总数据
setCellValue(sheet, 41, 5, data.getChidaocishu());
setCellValue(sheet, 41, 7, data.getExceptionCount());
setCellValue(sheet, 41, 8, data.getWorkOverTime() + "小时");
setCellValue(sheet, 41, 9, data.getRestOverTime() + "小时");


for (DayRecord record : data.getDayRecords()) { for (DayRecord record : data.getDayRecords()) {
if(record.getDay() == 1){ if(record.getDay() == 1){
// 定义早退次数 // 定义早退次数
int earlyCount = 0; int earlyCount = 0;


// 工作日加班时间
BigDecimal workOverTime = new BigDecimal(0);
// 休息日加班时间
BigDecimal restOverTime = new BigDecimal(0);
// 异常数量
BigDecimal exceptionCount = new BigDecimal(0);

// 定义集合,用于存储每天打卡记录 // 定义集合,用于存储每天打卡记录
List<DayRecord> dayRecords = new ArrayList<>(); List<DayRecord> dayRecords = new ArrayList<>();
// 根据用户的ID查询该用户所有的打卡记录 // 根据用户的ID查询该用户所有的打卡记录
if(dk.getClockIn() != null && dk.getClockOut() == null){ if(dk.getClockIn() != null && dk.getClockOut() == null){
dayRecord.setYichang("*"); dayRecord.setYichang("*");
dayRecord.setRemark("异常打卡"); dayRecord.setRemark("异常打卡");
exceptionCount = exceptionCount.add(new BigDecimal(1));
if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
lateCount ++;
}
} }


if(dk.getClockIn() == null && dk.getClockOut() != null){ if(dk.getClockIn() == null && dk.getClockOut() != null){
dayRecord.setYichang("*"); dayRecord.setYichang("*");
dayRecord.setRemark("异常打卡"); dayRecord.setRemark("异常打卡");
exceptionCount = exceptionCount.add(new BigDecimal(1));

if(dk.getClockOut().isBefore(workEndTime1)){
dayRecord.setChidao("*");
earlyCount ++;
}
} }
if(dk.getClockIn() == null && dk.getClockOut() == null){ if(dk.getClockIn() == null && dk.getClockOut() == null){
dayRecord.setRemark("缺卡"); dayRecord.setRemark("缺卡");
} }


// 判断是否为工作日加班
if(dk.getClockOut() != null){
if(dk.getClockOut().isAfter(workEndTime1)){

// 判断是否为休假日加班
if(Constans.EXPORT_ZHOULIU==week || Constans.EXPORT_ZHOURI==week){
if(dk.getClockIn() != null && dk.getClockOut() != null){
dayRecord.setXiuxiri("*");
dayRecord.setRemark("加班1次");
// 计算时间差 // 计算时间差
Duration duration = Duration.between(workEndTime1, dk.getClockOut());
Duration duration = Duration.between(dk.getClockIn(), dk.getClockOut());
// 获取小时差(注意:此方法会舍去分钟和秒部分) // 获取小时差(注意:此方法会舍去分钟和秒部分)
long hours1 = duration.toMinutes(); // 结果:6 小时(15:45 - 09:30 = 6小时15分钟) long hours1 = duration.toMinutes(); // 结果:6 小时(15:45 - 09:30 = 6小时15分钟)


BigDecimal b = new BigDecimal("60"); BigDecimal b = new BigDecimal("60");
// 执行除法,指定精度和舍入模式 // 执行除法,指定精度和舍入模式
BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP); BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP);
dayRecord.setGongzuori("*");
dayRecord.setRemark("加班1次:" + result + "小时");
restOverTime = restOverTime.add(result);
}
}
}else{
// 判断是否为工作日加班
if(dk.getClockOut() != null){
if(dk.getClockOut().isAfter(workEndTime1)){
// 计算时间差
Duration duration = Duration.between(workEndTime1, dk.getClockOut());
// 获取小时差(注意:此方法会舍去分钟和秒部分)
long hours1 = duration.toMinutes(); // 结果:6 小时(15:45 - 09:30 = 6小时15分钟)

if(hours1 >= 30){
BigDecimal a = new BigDecimal(hours1);
BigDecimal b = new BigDecimal("60");
// 执行除法,指定精度和舍入模式
BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP);
dayRecord.setGongzuori("*");
dayRecord.setRemark("加班1次:" + result + "小时");

workOverTime = workOverTime.add(result);
}
} }
} }
}
// 判断是否为休假日加班
if(Constans.ZHOULIU.equals(dk.getWeek()) || Constans.ZHOURI.equals(dk.getWeek())){
dayRecord.setXiuxiri("*");
dayRecord.setRemark("加班1次");
} }
// 判断是否为法定节假日加班 // 判断是否为法定节假日加班
// // 获取法定节假日时间 // // 获取法定节假日时间
// 添加更多日期记录... // 添加更多日期记录...
data.setChidaocishu(lateCount); data.setChidaocishu(lateCount);
data.setZaotuicishu(earlyCount); data.setZaotuicishu(earlyCount);
data.setWorkOverTime(workOverTime);
data.setRestOverTime(restOverTime);
data.setExceptionCount(exceptionCount);
data.setDayRecords(dayRecords); data.setDayRecords(dayRecords);
return data; return data;
} }

Loading…
取消
儲存