|
|
|
|
|
|
|
|
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 ++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |