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

@@ -82,4 +82,8 @@ public class DkCheckInRecord extends BaseEntity {
// 考勤组名称
@TableField(value = "`attendance_group_name`")
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

@@ -73,4 +73,6 @@ public class DkCheckInRecordDTO extends BaseEntity {

// 考勤组ids
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

@@ -74,6 +74,7 @@ public class DkAppServiceImpl implements DkAppService {
if(!b){
dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType());
@@ -98,6 +99,7 @@ public class DkAppServiceImpl implements DkAppService {
}
dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType());
@@ -120,6 +122,7 @@ public class DkAppServiceImpl implements DkAppService {
}else{
dkCheckInRecord.setSysUserId(appDTO.getUserId());
dkCheckInRecord.setSysUserName(appDTO.getUserName());
dkCheckInRecord.setNickName(appDTO.getNickName());
dkCheckInRecord.setCheckInTime(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setClockIn(TimeUtils.parseStr2LocalDateTime(appDTO.getClockIn()));
dkCheckInRecord.setCheckInType(appDTO.getCheckInType());
@@ -144,6 +147,7 @@ public class DkAppServiceImpl implements DkAppService {

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

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

@@ -73,9 +73,9 @@ public class DkRecordServiceImpl implements DkRecordService {
TimeUtils.getLastDayOfMonth(dkCheckInRecordDTO.getStrMonth()));
}
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.groupBy(DkCheckInRecord::getSysUserName).groupBy(DkCheckInRecord::getSysUserId);
queryWrapper.groupBy(DkCheckInRecord::getSysUserName).groupBy(DkCheckInRecord::getSysUserId).groupBy(DkCheckInRecord::getNickName);
}else{
queryWrapper.orderByDesc(DkCheckInRecord::getSysUserName).orderByDesc(DkCheckInRecord::getCheckInTime);
}
@@ -145,12 +145,12 @@ public class DkRecordServiceImpl implements DkRecordService {
if(Constans.GUONEI.equals(dkCheckInRecordDTO.getModelType())){
// templateFile = new FileInputStream("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();
}
if(Constans.RIBEN.equals(dkCheckInRecordDTO.getModelType())){
// 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();
}
workbook = WorkbookFactory.create(inputStream);
@@ -183,7 +183,7 @@ public class DkRecordServiceImpl implements DkRecordService {
workbook.setSheetName(newSheetIndex, "汇总");
}else{
workbook.cloneSheet(0);
workbook.setSheetName(newSheetIndex, dk.getSysUserName());
workbook.setSheetName(newSheetIndex, dk.getNickName() != null ? dk.getNickName() : dk.getSysUserName());
}

// 获取新创建的Sheet
@@ -264,20 +264,31 @@ public class DkRecordServiceImpl implements DkRecordService {
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) {

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

//根据userId获取打卡配置信息
@@ -338,7 +349,7 @@ public class DkRecordServiceImpl implements DkRecordService {
// 打卡异常判断
if(dk.getClockIn() != null && dk.getClockOut() != null){
if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
dayRecord.setRemark("迟到1次");
lateCount ++;
}
@@ -349,21 +360,21 @@ public class DkRecordServiceImpl implements DkRecordService {
}

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

if(dk.getClockOut().isBefore(workEndTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
earlyCount ++;
}
}
@@ -650,29 +661,40 @@ public class DkRecordServiceImpl implements DkRecordService {
}
}

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) {

// 定义员工类对象
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){
data.setDateTime(dkCheckInRecordDTO.getStrMonth());
data.setDateTime(formatDate(dkCheckInRecordDTO.getStrMonth()));
}
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获取打卡配置信息
DkAttendanceGroup dkAttendanceGroup = dkMapper.queryConfigByUserId(dkCheckInRecordDTO.getSysUserId());
@@ -740,7 +762,7 @@ public class DkRecordServiceImpl implements DkRecordService {
// 打卡异常判断
if(dk.getClockIn() != null && dk.getClockOut() != null){
if(dk.getClockIn().isAfter(workStartTime1)){
dayRecord.setChidao("*");
dayRecord.setChidao("");
dayRecord.setRemark("迟到1次");
lateCount ++;
}
@@ -751,22 +773,22 @@ public class DkRecordServiceImpl implements DkRecordService {
}

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

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

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

Notiek ielāde…
Atcelt
Saglabāt