Pārlūkot izejas kodu

导出数据赋值修改

main
1341924763@qq.com pirms 8 stundām
vecāks
revīzija
b5da52cdde

Binārs
ruoyi-admin/src/main/resources/template/template-guonei.xlsx Parādīt failu


Binārs
ruoyi-admin/src/main/resources/template/template-riben.xlsx Parādīt failu


+ 4
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkCheckInRecord.java Parādīt failu

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

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

+ 2
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/entity/DkCheckInRecordDTO.java Parādīt failu



// 考勤组ids // 考勤组ids
private List<Long> attendanceGroupIds; private List<Long> attendanceGroupIds;
// 用户昵称
private String nickName;
} }

+ 4
- 0
zs-manager/src/main/java/com/ruoyi/zhushi/service/impl/DkAppServiceImpl.java Parādīt failu

if(!b){ if(!b){
dkCheckInRecord.setSysUserId(appDTO.getUserId()); dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName()); dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType()); dkCheckInRecord.setCheckInType(appDTO.getCheckInType());
} }
dkCheckInRecord.setSysUserId(appDTO.getUserId()); dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName()); dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType()); dkCheckInRecord.setCheckInType(appDTO.getCheckInType());
}else{ }else{
dkCheckInRecord.setSysUserId(appDTO.getUserId()); dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName()); dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType()); dkCheckInRecord.setCheckInType(appDTO.getCheckInType());


dkCheckInRecord.setSysUserId(appDTO.getUserId()); dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName()); dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn())); dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType()); dkCheckInRecord.setCheckInType(appDTO.getCheckInType());

+ 53
- 31
zs-manager/src/main/java/com/ruoyi/zhushi/service/impl/DkRecordServiceImpl.java Parādīt failu

TimeUtils.getLastDayOfMonth(dkCheckInRecordDTO.getStrMonth())); TimeUtils.getLastDayOfMonth(dkCheckInRecordDTO.getStrMonth()));
} }
if(flag != null){ if(flag != null){
queryWrapper.select(DkCheckInRecord::getSysUserName, DkCheckInRecord::getSysUserId);
queryWrapper.select(DkCheckInRecord::getSysUserName, DkCheckInRecord::getSysUserId, DkCheckInRecord::getNickName);
queryWrapper.in(null != dkCheckInRecordDTO.getAttendanceGroupIds() ,DkCheckInRecord::getAttendanceGroupId, dkCheckInRecordDTO.getAttendanceGroupIds()); queryWrapper.in(null != dkCheckInRecordDTO.getAttendanceGroupIds() ,DkCheckInRecord::getAttendanceGroupId, dkCheckInRecordDTO.getAttendanceGroupIds());
queryWrapper.groupBy(DkCheckInRecord::getSysUserName).groupBy(DkCheckInRecord::getSysUserId);
queryWrapper.groupBy(DkCheckInRecord::getSysUserName).groupBy(DkCheckInRecord::getSysUserId).groupBy(DkCheckInRecord::getNickName);
}else{ }else{
queryWrapper.orderByDesc(DkCheckInRecord::getSysUserName).orderByDesc(DkCheckInRecord::getCheckInTime); queryWrapper.orderByDesc(DkCheckInRecord::getSysUserName).orderByDesc(DkCheckInRecord::getCheckInTime);
} }
if(Constans.GUONEI.equals(dkCheckInRecordDTO.getModelType())){ if(Constans.GUONEI.equals(dkCheckInRecordDTO.getModelType())){
// templateFile = new FileInputStream("template-guonei.xlsx"); // templateFile = new FileInputStream("template-guonei.xlsx");
// DkRecordServiceImpl.class.getClassLoader().getResourceAsStream("template/template-guonei.xlsx"); // DkRecordServiceImpl.class.getClassLoader().getResourceAsStream("template/template-guonei.xlsx");
ClassPathResource resource = new ClassPathResource("template/template-guonei.xlsx");
ClassPathResource resource = new ClassPathResource("template/template-guonei.xls");
inputStream = resource.getInputStream(); inputStream = resource.getInputStream();
} }
if(Constans.RIBEN.equals(dkCheckInRecordDTO.getModelType())){ if(Constans.RIBEN.equals(dkCheckInRecordDTO.getModelType())){
// templateFile = new FileInputStream("template-riben.xlsx"); // templateFile = new FileInputStream("template-riben.xlsx");
ClassPathResource resource = new ClassPathResource("template/template-riben.xlsx");
ClassPathResource resource = new ClassPathResource("template/template-riben.xls");
inputStream = resource.getInputStream(); inputStream = resource.getInputStream();
} }
workbook = WorkbookFactory.create(inputStream); workbook = WorkbookFactory.create(inputStream);
workbook.setSheetName(newSheetIndex, "汇总"); workbook.setSheetName(newSheetIndex, "汇总");
}else{ }else{
workbook.cloneSheet(0); workbook.cloneSheet(0);
workbook.setSheetName(newSheetIndex, dk.getSysUserName());
workbook.setSheetName(newSheetIndex, dk.getNickName() != null ? dk.getNickName() : dk.getSysUserName());
} }


// 获取新创建的Sheet // 获取新创建的Sheet
return sheet; return sheet;
} }


public static String formatDate(String input) {
// 解析输入字符串为LocalDate
LocalDate date = LocalDate.parse(input + "-01"); // 假设输入是年月,补全为月初

// 定义目标格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月");

// 格式化日期
return date.format(formatter);
}

private EmployeeAttendance prepareSampleData(DkCheckInRecordDTO dkCheckInRecordDTO) { private EmployeeAttendance prepareSampleData(DkCheckInRecordDTO dkCheckInRecordDTO) {


// 定义员工类对象 // 定义员工类对象
EmployeeAttendance data = new EmployeeAttendance(); EmployeeAttendance data = new EmployeeAttendance();
// 设置员工的名字 // 设置员工的名字
data.setEmployeeName(dkCheckInRecordDTO.getSysUserName());
data.setEmployeeName(dkCheckInRecordDTO.getNickName());
// 设置员工的id // 设置员工的id
data.setUserId(dkCheckInRecordDTO.getSysUserId());
data.setUserId(dkCheckInRecordDTO.getSysUserName().matches("\\d+") ? Long.parseLong(dkCheckInRecordDTO.getSysUserName()) : 0);
// 判断月日是否为空 // 判断月日是否为空
if(dkCheckInRecordDTO.getStrMonth() != null){ if(dkCheckInRecordDTO.getStrMonth() != null){
data.setDateTime(dkCheckInRecordDTO.getStrMonth());
data.setDateTime(formatDate(dkCheckInRecordDTO.getStrMonth()));
} }
if(dkCheckInRecordDTO.getStrDay() != null){ if(dkCheckInRecordDTO.getStrDay() != null){
data.setDateTime(dkCheckInRecordDTO.getStrDay());
data.setDateTime(convertToChineseFormat(dkCheckInRecordDTO.getStrDay()));
} }


//根据userId获取打卡配置信息 //根据userId获取打卡配置信息
// 打卡异常判断 // 打卡异常判断
if(dk.getClockIn() != null && dk.getClockOut() != null){ if(dk.getClockIn() != null && dk.getClockOut() != null){
if(dk.getClockIn().isAfter(workStartTime1)){ if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
dayRecord.setRemark("迟到1次"); dayRecord.setRemark("迟到1次");
lateCount ++; 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)); exceptionCount = exceptionCount.add(new BigDecimal(1));
if(dk.getClockIn().isAfter(workStartTime1)){ if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
lateCount ++; 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)); exceptionCount = exceptionCount.add(new BigDecimal(1));


if(dk.getClockOut().isBefore(workEndTime1)){ if(dk.getClockOut().isBefore(workEndTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
earlyCount ++; earlyCount ++;
} }
} }
} }
} }


public static String convertToChineseFormat(String dateStr) {
// 解析输入字符串为LocalDate
LocalDate date = LocalDate.parse(dateStr);

// 定义目标格式(年-月-日带前导零)
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");

// 格式化日期
return date.format(formatter);
}

private EmployeeAttendance prepareSampleDataRiBen(DkCheckInRecordDTO dkCheckInRecordDTO) { private EmployeeAttendance prepareSampleDataRiBen(DkCheckInRecordDTO dkCheckInRecordDTO) {


// 定义员工类对象 // 定义员工类对象
EmployeeAttendance data = new EmployeeAttendance(); EmployeeAttendance data = new EmployeeAttendance();
// 设置员工的名字 // 设置员工的名字
data.setEmployeeName(dkCheckInRecordDTO.getSysUserName());
// 设置员工id
data.setUserId(dkCheckInRecordDTO.getSysUserId());
data.setEmployeeName(dkCheckInRecordDTO.getNickName());
// 设置员工id
data.setUserId(dkCheckInRecordDTO.getSysUserName().matches("\\d+") ? Long.parseLong(dkCheckInRecordDTO.getSysUserName()) : 0);
// 判断月日是否为空 // 判断月日是否为空
if(dkCheckInRecordDTO.getStrMonth() != null){ if(dkCheckInRecordDTO.getStrMonth() != null){
data.setDateTime(dkCheckInRecordDTO.getStrMonth());
data.setDateTime(formatDate(dkCheckInRecordDTO.getStrMonth()));
} }
if(dkCheckInRecordDTO.getStrDay() != null){ if(dkCheckInRecordDTO.getStrDay() != null){
data.setDateTime(dkCheckInRecordDTO.getStrDay());
data.setDateTime(convertToChineseFormat(dkCheckInRecordDTO.getStrDay()));
} }


// 判断月日是否为空
if(dkCheckInRecordDTO.getStrMonth() != null){
data.setDateTime(dkCheckInRecordDTO.getStrMonth());
}
if(dkCheckInRecordDTO.getStrDay() != null){
data.setDateTime(dkCheckInRecordDTO.getStrDay());
}
// // 判断月日是否为空
// if(dkCheckInRecordDTO.getStrMonth() != null){
// data.setDateTime(dkCheckInRecordDTO.getStrMonth());
// }
// if(dkCheckInRecordDTO.getStrDay() != null){
// data.setDateTime(dkCheckInRecordDTO.getStrDay());
// }


//根据userId获取打卡配置信息 //根据userId获取打卡配置信息
DkAttendanceGroup dkAttendanceGroup = dkMapper.queryConfigByUserId(dkCheckInRecordDTO.getSysUserId()); DkAttendanceGroup dkAttendanceGroup = dkMapper.queryConfigByUserId(dkCheckInRecordDTO.getSysUserId());
// 打卡异常判断 // 打卡异常判断
if(dk.getClockIn() != null && dk.getClockOut() != null){ if(dk.getClockIn() != null && dk.getClockOut() != null){
if(dk.getClockIn().isAfter(workStartTime1)){ if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
dayRecord.setRemark("迟到1次"); dayRecord.setRemark("迟到1次");
lateCount ++; 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)); exceptionCount = exceptionCount.add(new BigDecimal(1));
if(dk.getClockIn().isAfter(workStartTime1)){ if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
lateCount ++; 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)); exceptionCount = exceptionCount.add(new BigDecimal(1));


if(dk.getClockOut().isBefore(workEndTime1)){ if(dk.getClockOut().isBefore(workEndTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
earlyCount ++; earlyCount ++;
} }
} }

Notiek ielāde…
Atcelt
Saglabāt