|
|
@@ -12,6 +12,7 @@ import com.ruoyi.common.helper.LoginHelper; |
|
|
|
import com.ruoyi.zhushi.entity.*; |
|
|
|
import com.ruoyi.zhushi.mapper.DkRecordMapper; |
|
|
|
import com.ruoyi.zhushi.service.DkRecordService; |
|
|
|
import com.ruoyi.zhushi.util.CalendarGenerator; |
|
|
|
import com.ruoyi.zhushi.util.Constans; |
|
|
|
import com.ruoyi.zhushi.util.TimeUtils; |
|
|
|
import okhttp3.OkHttpClient; |
|
|
@@ -31,10 +32,7 @@ import java.text.SimpleDateFormat; |
|
|
|
import java.time.*; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.TextStyle; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class DkRecordServiceImpl implements DkRecordService { |
|
|
@@ -51,19 +49,22 @@ public class DkRecordServiceImpl implements DkRecordService { |
|
|
|
public TableDataInfo<DkCheckInRecordDTO> queryPageList(DkCheckInRecordDTO dkCheckInRecordDTO, PageQuery pageQuery) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
LambdaQueryWrapper<DkCheckInRecord> queryWrapper = buildQueryWrapper(dkCheckInRecordDTO, null); |
|
|
|
if (loginUser == null) { |
|
|
|
return TableDataInfo.build(); |
|
|
|
}else { |
|
|
|
// 获取用户角色 |
|
|
|
List<RoleDTO> roles = loginUser.getRoles(); |
|
|
|
if (roles != null && roles.size() > 0) { |
|
|
|
for (RoleDTO role : roles) { |
|
|
|
if (role.getRoleKey().equals(Constans.ROLEKEY)) { |
|
|
|
queryWrapper.eq(DkCheckInRecord::getSysUserId, loginUser.getUserId()); |
|
|
|
if (dkCheckInRecordDTO.getFlag().equals("my")){ |
|
|
|
if (loginUser == null) { |
|
|
|
return TableDataInfo.build(); |
|
|
|
}else { |
|
|
|
// 获取用户角色 |
|
|
|
List<RoleDTO> roles = loginUser.getRoles(); |
|
|
|
if (roles != null && roles.size() > 0) { |
|
|
|
for (RoleDTO role : roles) { |
|
|
|
if (role.getRoleKey().equals(Constans.ROLEKEY)) { |
|
|
|
queryWrapper.eq(DkCheckInRecord::getSysUserId, loginUser.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Page<DkCheckInRecordDTO> result = dkMapper.selectVoPage(pageQuery.build(), queryWrapper); |
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
@@ -522,6 +523,19 @@ public class DkRecordServiceImpl implements DkRecordService { |
|
|
|
setCellValue(sheet, 41, 8, data.getWorkOverTime() + "小时"); |
|
|
|
setCellValue(sheet, 41, 9, data.getRestOverTime() + "小时"); |
|
|
|
|
|
|
|
// 要生成的年份 |
|
|
|
int year = LocalDate.now().getYear(); |
|
|
|
int month = LocalDate.now().getMonthValue(); |
|
|
|
int rowIndex = 10; |
|
|
|
Map<Integer, List<CalendarGenerator.DayInfo>> calendar = CalendarGenerator.generateYearCalendar(year); |
|
|
|
List<CalendarGenerator.DayInfo> dayInfos = calendar.get(month); |
|
|
|
for (int i = 0; i < dayInfos.size(); i++) { |
|
|
|
rowIndex = i + 10; |
|
|
|
setCellValue(sheet, rowIndex, 1, dayInfos.get(i).getDay()); |
|
|
|
setCellValue(sheet, rowIndex, 2, dayInfos.get(i).getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (DayRecord record : data.getDayRecords()) { |
|
|
|
if(record.getDay() == 1){ |
|
|
|
fillTemplateCell(sheet, 10, record); |
|
|
@@ -760,7 +774,6 @@ public class DkRecordServiceImpl implements DkRecordService { |
|
|
|
DayOfWeek dayOfWeek = localDate.getDayOfWeek(); |
|
|
|
int week = dayOfWeek.getValue(); |
|
|
|
if(week == Constans.EXPORT_ZHOUYI){ |
|
|
|
|
|
|
|
dayRecord.setWeekday("月"); |
|
|
|
}else if(week == Constans.EXPORT_ZHOUER){ |
|
|
|
dayRecord.setWeekday("火"); |
|
|
@@ -816,45 +829,47 @@ public class DkRecordServiceImpl implements DkRecordService { |
|
|
|
|
|
|
|
|
|
|
|
// // 判断是否为休假日加班 |
|
|
|
// 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(dk.getClockIn(), 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); |
|
|
|
// 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.EXPORT_ZHOULIU==week || Constans.EXPORT_ZHOURI==week){ |
|
|
|
if(dk.getClockIn() != null && dk.getClockOut() != null){ |
|
|
|
dayRecord.setXiuxiri("*"); |
|
|
|
dayRecord.setRemark("加班1次"); |
|
|
|
// 计算时间差 |
|
|
|
Duration duration = Duration.between(dk.getClockIn(), 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); |
|
|
|
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.setGongzuorijiaban(result); |
|
|
|
dayRecord.setHeji( result); |
|
|
|
dayRecord.setRemark("加班1次:" + result + "小时"); |
|
|
|
|
|
|
|
workOverTime = workOverTime.add(result); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 判断是否为法定节假日加班 |
|
|
|
// // 获取法定节假日时间 |
|
|
|
// List<LocalDate> holidays = getHolidays(LocalDate.now().getYear()); |
|
|
@@ -886,6 +901,35 @@ public class DkRecordServiceImpl implements DkRecordService { |
|
|
|
setCellValue(sheet, 2, 0, data.getDateTime()); |
|
|
|
// setCellValue(sheet, 2, 0, data.getYear() + "年" + data.getMonth() + "月考勤记录"); |
|
|
|
|
|
|
|
// 要生成的年份 |
|
|
|
int year = LocalDate.now().getYear(); |
|
|
|
int month = LocalDate.now().getMonthValue(); |
|
|
|
int rowIndex = 10; |
|
|
|
Map<Integer, List<CalendarGenerator.DayInfo>> calendar = CalendarGenerator.generateYearCalendar(year); |
|
|
|
List<CalendarGenerator.DayInfo> dayInfos = calendar.get(month); |
|
|
|
for (int i = 0; i < dayInfos.size(); i++) { |
|
|
|
rowIndex = i + 10; |
|
|
|
setCellValue(sheet, rowIndex, 0, dayInfos.get(i).getDay()); |
|
|
|
String weekday = ""; |
|
|
|
int week = dayInfos.get(i).getDayOfWeek().getValue(); |
|
|
|
if(week == Constans.EXPORT_ZHOUYI){ |
|
|
|
weekday = "月"; |
|
|
|
}else if(week == Constans.EXPORT_ZHOUER){ |
|
|
|
weekday = "火"; |
|
|
|
}else if(week == Constans.EXPORT_ZHOUSAN){ |
|
|
|
weekday = "水"; |
|
|
|
}else if(week == Constans.EXPORT_ZHOUSI){ |
|
|
|
weekday = "木"; |
|
|
|
}else if(week == Constans.EXPORT_ZHOUWU){ |
|
|
|
weekday = "金"; |
|
|
|
} else if(week == Constans.EXPORT_ZHOULIU){ |
|
|
|
weekday = "土"; |
|
|
|
}else if(week == Constans.EXPORT_ZHOURI){ |
|
|
|
weekday = "日"; |
|
|
|
} |
|
|
|
setCellValue(sheet, rowIndex, 1, weekday); |
|
|
|
} |
|
|
|
|
|
|
|
for (DayRecord record : data.getDayRecords()) { |
|
|
|
if(record.getDay() == 1){ |
|
|
|
fillTemplateRiBenCell(sheet, 10, record); |