|
@@ -3,22 +3,19 @@ package com.management.platform.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.management.platform.entity.Attendance;
|
|
|
-import com.management.platform.entity.AttendanceStaff;
|
|
|
-import com.management.platform.entity.DayInfo;
|
|
|
-import com.management.platform.entity.User;
|
|
|
+import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.AttendanceStaffMapper;
|
|
|
-import com.management.platform.service.AttendanceService;
|
|
|
-import com.management.platform.service.AttendanceStaffService;
|
|
|
+import com.management.platform.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.management.platform.service.UserService;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.*;
|
|
@@ -45,6 +42,12 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
@Resource
|
|
|
private UserService userService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SpecialDateSetService specialDateSetService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ApplyFormService applyFormService;
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg refreshData(String month) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
@@ -201,10 +204,16 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
User user = userService.getById(userId);
|
|
|
wrapper.eq("job_number", user.getJobNumber());
|
|
|
}
|
|
|
- IPage<Attendance> iPage = page(new Page(pageIndex, pageSize), wrapper);
|
|
|
+ IPage<AttendanceStaff> iPage = page(new Page(pageIndex, pageSize), wrapper);
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("total", iPage.getTotal());
|
|
|
- map.put("records", iPage.getRecords());
|
|
|
+ List<AttendanceStaff> records = iPage.getRecords();
|
|
|
+ for (AttendanceStaff record : records) {
|
|
|
+ if (record.getAttendanceType()==0){
|
|
|
+ record.setWorkHour(record.getWorkHour().subtract(BigDecimal.ONE));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("records",records );
|
|
|
msg.setData(map);
|
|
|
return msg;
|
|
|
}
|
|
@@ -212,6 +221,48 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
@Override
|
|
|
public HttpRespMsg getAttendanceUserData(String month, String date, String userId, HttpServletRequest request) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ // 1. 解析月份参数
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
+ DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ YearMonth yearMonth = YearMonth.parse(month, formatter);
|
|
|
+ // 3. 生成该月所有日期的信息
|
|
|
+ List<AttendanceStaff> allList = new ArrayList<>();
|
|
|
+ LocalDate startDate = yearMonth.atDay(1);
|
|
|
+ LocalDate endDate = yearMonth.atEndOfMonth();
|
|
|
+
|
|
|
+ // 2. 获取自定义休息日列表
|
|
|
+ List<LocalDate> customHolidays = getCustomHolidays(yearMonth);
|
|
|
+
|
|
|
+ // 2.1 获取自定义工作日列表
|
|
|
+ List<LocalDate> workdays = getWorkDays(yearMonth);
|
|
|
+ // 2.2 获取自定义调休日列表
|
|
|
+ List<LocalDate> freeDays = getFreeDays(yearMonth);
|
|
|
+
|
|
|
+ for (LocalDate d = startDate; !d.isAfter(endDate); d = d.plusDays(1)) {
|
|
|
+ AttendanceStaff staff = new AttendanceStaff();
|
|
|
+ staff.setClockDate(d);
|
|
|
+ // 判断是否为休息日(周末或自定义假日)
|
|
|
+ if (d.getDayOfWeek() == DayOfWeek.SATURDAY
|
|
|
+ || d.getDayOfWeek() == DayOfWeek.SUNDAY
|
|
|
+ || customHolidays.contains(d)) {
|
|
|
+ staff.setAttendanceType(5);//休息
|
|
|
+ staff.setAttendanceTypeName("休息");
|
|
|
+ staff.setColor("#2e2e2e");
|
|
|
+ }
|
|
|
+ if (freeDays.contains(d)) {
|
|
|
+ staff.setAttendanceType(6);//调休
|
|
|
+ staff.setAttendanceTypeName("调休");
|
|
|
+ staff.setColor("#2e2e2e");
|
|
|
+ }
|
|
|
+ if (workdays.contains(d)){
|
|
|
+ staff.setAttendanceType(0);//白班
|
|
|
+ staff.setAttendanceTypeName("白班");
|
|
|
+ staff.setColor("#2e2e2e");
|
|
|
+ }
|
|
|
+ allList.add(staff);
|
|
|
+ }
|
|
|
+
|
|
|
QueryWrapper<AttendanceStaff> wrapper = new QueryWrapper<AttendanceStaff>()
|
|
|
.eq("month", month);
|
|
|
if (userId==null|| StringUtils.isEmpty(userId)){
|
|
@@ -222,140 +273,358 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
wrapper.eq("job_number", user.getJobNumber());
|
|
|
}
|
|
|
List<AttendanceStaff> list = list(wrapper);
|
|
|
- for (AttendanceStaff staff : list) {
|
|
|
+
|
|
|
+ for (AttendanceStaff staff : allList) {
|
|
|
+ LocalDate clockDate = staff.getClockDate();
|
|
|
+ if (clockDate.isAfter(LocalDate.now())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Optional<AttendanceStaff> first = list.stream().filter(l -> l.getClockDate() != null && l.getClockDate().equals(clockDate)).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ AttendanceStaff s = first.get();
|
|
|
+ BeanUtils.copyProperties(s,staff);
|
|
|
+ if (staff.getAttendanceType()==0){
|
|
|
+ staff.setAttendanceTypeName("白班");
|
|
|
+ staff.setColor("#2e2e2e");
|
|
|
+ }else if (staff.getAttendanceType()==1){
|
|
|
+ staff.setAttendanceTypeName("大夜班");
|
|
|
+ staff.setColor("#67C23A");//绿色
|
|
|
+ }
|
|
|
+ else if (staff.getAttendanceType()==2){
|
|
|
+ staff.setAttendanceTypeName("小夜班");
|
|
|
+ staff.setColor("#67C23A");//绿色
|
|
|
+ }
|
|
|
+ else if (staff.getAttendanceType()==3){
|
|
|
+ staff.setAttendanceTypeName("中班");
|
|
|
+ staff.setColor("#909399");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (staff.getId()==null&&staff.getAttendanceType()==null) {
|
|
|
+ staff.setAttendanceType(4);//班次异常
|
|
|
+ staff.setAttendanceTypeName("班次异常");
|
|
|
+ staff.setColor("#F56C6C");
|
|
|
+ } else if (staff.getAttendanceType() == 5 || staff.getAttendanceType() == 6){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (AttendanceStaff staff : allList) {
|
|
|
Integer type = staff.getAttendanceType();
|
|
|
LocalDate clockDate = staff.getClockDate();
|
|
|
+ String format = clockDate.format(formatter1);
|
|
|
+ List<ApplyForm> applyFormList= applyFormService.getListByDate(format,userId);
|
|
|
+
|
|
|
LocalDateTime clockStartTime = staff.getClockStartTime();
|
|
|
- LocalTime startTime = clockStartTime.toLocalTime();
|
|
|
LocalDateTime clockEndTime = staff.getClockEndTime();
|
|
|
- LocalTime endTime = clockEndTime.toLocalTime();
|
|
|
-
|
|
|
- List<HashMap<String,Object>> maplist = new ArrayList<>();
|
|
|
- switch (type) {
|
|
|
- case BAI_BAN:
|
|
|
- if (startTime.isAfter(LocalTime.of(8,0,0))){
|
|
|
+ if (clockStartTime!=null&&clockEndTime!=null) {
|
|
|
+ LocalTime startTime = clockStartTime.toLocalTime();
|
|
|
+ LocalTime endTime = clockEndTime.toLocalTime();
|
|
|
+ List<HashMap<String, Object>> maplist = new ArrayList<>();
|
|
|
+ if (type == BAI_BAN) {
|
|
|
+ if (startTime.isAfter(LocalTime.of(8, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","晚点");
|
|
|
+ map.put("res", "晚点");
|
|
|
+ String str = startTime + "上班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(LocalTime.of(8,0,0),startTime );
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(晚点"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
+ map.put("msg", startTime + "上班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
|
|
|
- if (endTime.isBefore(LocalTime.of(17,0,0))){
|
|
|
+ if (endTime.isBefore(LocalTime.of(17, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","早退");
|
|
|
+ map.put("res", "早退");
|
|
|
+ String str = endTime + "下班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(endTime,LocalTime.of(17,0,0) );
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(早退"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
- double v = calculateOvertimeHours(LocalTime.of(17,0),endTime );
|
|
|
+ map.put("res", "正常");
|
|
|
+ String str = endTime + "下班考勤打卡:";
|
|
|
+ double v = calculateOvertimeHours(LocalTime.of(17, 0), endTime);
|
|
|
if (v>0) {
|
|
|
- map.put("extra", "(17:00-"+endTime+"加班"+v+"小时)");
|
|
|
+ str += "(17:00-" + endTime + "加班" + v + "小时)";
|
|
|
}
|
|
|
+ map.put("msg", str);
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
- break;
|
|
|
- case ZHONG_BAN:
|
|
|
- if (startTime.isAfter(LocalTime.of(13,0,0))){
|
|
|
+ staff.setAttendanceTypeName("白班");
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (type == ZHONG_BAN) {
|
|
|
+ if (startTime.isAfter(LocalTime.of(13, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","晚点");
|
|
|
+ map.put("res", "晚点");
|
|
|
+ String str = startTime + "上班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(LocalTime.of(13,0,0),startTime);
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(晚点"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
+ map.put("msg", startTime + "上班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
|
|
|
- if (endTime.isBefore(LocalTime.of(21,0,0))){
|
|
|
+ if (endTime.isBefore(LocalTime.of(21, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","早退");
|
|
|
+ map.put("res", "早退");
|
|
|
+ String str = endTime + "下班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(endTime,LocalTime.of(21,0,0));
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(早退"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
- double v = calculateOvertimeHours(LocalTime.of(21,0,0), endTime);
|
|
|
- if (v>0) {
|
|
|
- map.put("extra", "(21:00-"+endTime+"加班"+v+"小时)");
|
|
|
+ map.put("msg", endTime + "下班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
+ double v = calculateOvertimeHours(LocalTime.of(21, 0, 0), endTime);
|
|
|
+ if (v > 0) {
|
|
|
+ map.put("extra", "(21:00-" + endTime + "加班" + v + "小时)");
|
|
|
}
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
- break;
|
|
|
- case XIAO_YE_BAN:
|
|
|
- if (startTime.isAfter(LocalTime.of(16,0,0))){
|
|
|
+ staff.setAttendanceTypeName("中班");
|
|
|
+ }
|
|
|
+ else if (type == XIAO_YE_BAN) {
|
|
|
+ if (startTime.isAfter(LocalTime.of(16, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","晚点");
|
|
|
+ map.put("res", "晚点");
|
|
|
+ String str = startTime + "上班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(LocalTime.of(16,0,0),startTime );
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(晚点"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
+ map.put("msg", startTime + "上班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
|
|
|
- if (endTime.isBefore(LocalTime.of(23,59,59))&&endTime.isAfter(LocalTime.of(16,0,0))){
|
|
|
+ if (endTime.isBefore(LocalTime.of(23, 59, 59)) && endTime.isAfter(LocalTime.of(16, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","早退");
|
|
|
+ map.put("res", "早退");
|
|
|
+ String str = endTime + "下班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(endTime,LocalTime.of(23,59, 59) );
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(早退"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
- double v = calculateOvertimeHours(LocalTime.of(23,59,59), endTime);
|
|
|
- if (v>0) {
|
|
|
- map.put("extra", "(00:00-"+endTime+"加班"+v+"小时)");
|
|
|
+ map.put("msg", endTime + "下班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
+ double v = calculateOvertimeHours(LocalTime.of(23, 59, 59), endTime);
|
|
|
+ if (v > 0) {
|
|
|
+ map.put("extra", "(00:00-" + endTime + "加班" + v + "小时)");
|
|
|
}
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
- break;
|
|
|
- case DA_YE_BAN:
|
|
|
- if (startTime.isAfter(LocalTime.of(23,59,59))){
|
|
|
+ staff.setAttendanceTypeName("小夜班");
|
|
|
+ }
|
|
|
+ else if (type == DA_YE_BAN) {
|
|
|
+ if (startTime.isAfter(LocalTime.of(23, 59, 59))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","晚点");
|
|
|
+ map.put("res", "晚点");
|
|
|
+ String str = startTime + "上班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(LocalTime.of(23, 59, 59),startTime );
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(晚点"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",startTime+"上班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
+ map.put("msg", startTime + "上班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
|
|
|
- if (endTime.isBefore(LocalTime.of(8,0,0))){
|
|
|
+ if (endTime.isBefore(LocalTime.of(8, 0, 0))) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","早退");
|
|
|
+ map.put("res", "早退");
|
|
|
+ String str = endTime + "下班考勤打卡:";
|
|
|
+ Duration duration = Duration.between(endTime,LocalTime.of(8,0, 0) );
|
|
|
+ long v = duration.toMinutes();
|
|
|
+ str+= "(早退"+v+"分钟)";
|
|
|
+ map.put("msg",str );
|
|
|
+ map.put("color","#F56C6C");
|
|
|
maplist.add(map);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("msg",endTime+"下班考勤打卡");
|
|
|
- map.put("res","正常");
|
|
|
- double v = calculateOvertimeHours(LocalTime.of(8,0,0), endTime);
|
|
|
- if (v>0) {
|
|
|
- map.put("extra", "(08:00-"+endTime+"加班"+v+"小时)");
|
|
|
+ map.put("msg", endTime + "下班考勤打卡");
|
|
|
+ map.put("res", "正常");
|
|
|
+ double v = calculateOvertimeHours(LocalTime.of(8, 0, 0), endTime);
|
|
|
+ if (v > 0) {
|
|
|
+ map.put("extra", "(08:00-" + endTime + "加班" + v + "小时)");
|
|
|
}
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
- break;
|
|
|
-
|
|
|
+ staff.setAttendanceTypeName("大夜班");
|
|
|
+ }
|
|
|
+ if (!maplist.isEmpty()) {
|
|
|
+ if (!applyFormList.isEmpty()){
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ for (ApplyForm applyForm : applyFormList) {
|
|
|
+ if (applyForm.getType()==3) {
|
|
|
+ stringBuilder
|
|
|
+ .append(applyForm.getStartTime().format(formatter2))
|
|
|
+ .append("-").append(applyForm.getEndTime().format(formatter2))
|
|
|
+ .append(applyForm.getApplyBillName())
|
|
|
+ .append(" 时长")
|
|
|
+ .append(applyForm.getSumTime()).append("小时");
|
|
|
+ }else {
|
|
|
+ stringBuilder
|
|
|
+ .append(applyForm.getStartTime().format(formatter2))
|
|
|
+ .append("-").append(applyForm.getEndTime().format(formatter2))
|
|
|
+ .append(applyForm.getTypeName())
|
|
|
+ .append(" 时长")
|
|
|
+ .append(applyForm.getSumTime()).append("小时");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("res", stringBuilder.toString());
|
|
|
+ map.put("color","#F56C6C");
|
|
|
+ for (HashMap<String, Object> hashMap : maplist) {
|
|
|
+ hashMap.put("res","正常");
|
|
|
+ }
|
|
|
+ maplist.add(1,map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ staff.setMaplist(maplist);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ List<HashMap<String, Object>> mapList = new ArrayList<>();
|
|
|
+ if (!applyFormList.isEmpty()){
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ for (ApplyForm applyForm : applyFormList) {
|
|
|
+ if (applyForm.getType()==3) {
|
|
|
+ stringBuilder
|
|
|
+ .append(applyForm.getStartTime().format(formatter2))
|
|
|
+ .append("-").append(applyForm.getEndTime().format(formatter2))
|
|
|
+ .append(applyForm.getApplyBillName())
|
|
|
+ .append(" 时长")
|
|
|
+ .append(applyForm.getSumTime()).append("小时");
|
|
|
+ }else {
|
|
|
+ stringBuilder
|
|
|
+ .append(applyForm.getStartTime().format(formatter2))
|
|
|
+ .append("-").append(applyForm.getEndTime().format(formatter2))
|
|
|
+ .append(applyForm.getTypeName())
|
|
|
+ .append(" 时长")
|
|
|
+ .append(applyForm.getSumTime()).append("小时");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("res", stringBuilder.toString());
|
|
|
+ map.put("color","#F56C6C");
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ staff.setMaplist(mapList);
|
|
|
}
|
|
|
- staff.setMaplist(maplist);
|
|
|
}
|
|
|
- msg.setData(list);
|
|
|
+ msg.setData(allList);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ private List<LocalDate> getWorkDays(YearMonth yearMonth) {
|
|
|
+ List<LocalDate> workDays = new ArrayList<>();
|
|
|
+ LocalDate endOfMonth = yearMonth.atEndOfMonth();
|
|
|
+ LocalDate startOfMonth = yearMonth.atDay(1);
|
|
|
+ List<SpecialDateSet> dateSetList = specialDateSetService.list(new QueryWrapper<SpecialDateSet>()
|
|
|
+ .between("special_date", startOfMonth, endOfMonth).eq("type",1));
|
|
|
+ List<String> collect2 = new ArrayList<>();
|
|
|
+ if (!dateSetList.isEmpty()){
|
|
|
+ String[] array = dateSetList.stream()
|
|
|
+ .map(SpecialDateSet::getSpecialDate)
|
|
|
+ .map(date -> date.format(DateTimeFormatter.ISO_LOCAL_DATE))
|
|
|
+ .toArray(String[]::new);
|
|
|
+ collect2.addAll(Arrays.stream(array).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ // 将字符串日期转换为LocalDate并添加到列表中
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
|
|
+ for (String dateStr : collect2) {
|
|
|
+ LocalDate holiday = LocalDate.parse(dateStr, formatter);
|
|
|
+ if (holiday.getYear() == yearMonth.getYear() &&
|
|
|
+ holiday.getMonth() == yearMonth.getMonth()) {
|
|
|
+ workDays.add(holiday);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return workDays;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<LocalDate> getFreeDays(YearMonth yearMonth) {
|
|
|
+ List<LocalDate> holidays = new ArrayList<>();
|
|
|
+ List<String> collect2 = new ArrayList<>();
|
|
|
+
|
|
|
+ LocalDate endOfMonth = yearMonth.atEndOfMonth();
|
|
|
+ LocalDate startOfMonth = yearMonth.atDay(1);
|
|
|
+ List<SpecialDateSet> dateSetList = specialDateSetService.list(new QueryWrapper<SpecialDateSet>()
|
|
|
+ .between("special_date", startOfMonth, endOfMonth).eq("type",0));
|
|
|
+ if (!dateSetList.isEmpty()){
|
|
|
+ String[] array = dateSetList.stream()
|
|
|
+ .map(SpecialDateSet::getSpecialDate)
|
|
|
+ .map(date -> date.format(DateTimeFormatter.ISO_LOCAL_DATE))
|
|
|
+ .toArray(String[]::new);
|
|
|
+ collect2.addAll(Arrays.stream(array).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ // 将字符串日期转换为LocalDate并添加到列表中
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
|
|
+ for (String dateStr : collect2) {
|
|
|
+ LocalDate holiday = LocalDate.parse(dateStr, formatter);
|
|
|
+ if (holiday.getYear() == yearMonth.getYear() &&
|
|
|
+ holiday.getMonth() == yearMonth.getMonth()) {
|
|
|
+ holidays.add(holiday);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return holidays;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 辅助方法:获取自定义休息日列表(示例)
|
|
|
+ private List<LocalDate> getCustomHolidays(YearMonth yearMonth) {
|
|
|
+ List<LocalDate> holidays = new ArrayList<>();
|
|
|
+
|
|
|
+ // 2025年中国法定节假日列表
|
|
|
+ String[] holidayDates = {
|
|
|
+ "2025-01-01", // 元旦
|
|
|
+ "2025-01-28", "2025-01-29", "2025-01-30", "2025-01-31", "2025-02-03", "2025-02-04", // 春节
|
|
|
+ "2025-04-04", // 清明节
|
|
|
+ "2025-05-01", "2025-05-02", "2025-05-05", // 劳动节
|
|
|
+ "2025-06-02", // 端午节
|
|
|
+ "2025-10-01", "2025-10-02", "2025-10-03", "2025-10-06", "2025-10-07", "2025-10-08" // 国庆节
|
|
|
+ };
|
|
|
+ // 将字符串日期转换为LocalDate并添加到列表中
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
|
|
+ for (String dateStr : holidayDates) {
|
|
|
+ LocalDate holiday = LocalDate.parse(dateStr, formatter);
|
|
|
+ if (holiday.getYear() == yearMonth.getYear() &&
|
|
|
+ holiday.getMonth() == yearMonth.getMonth()) {
|
|
|
+ holidays.add(holiday);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return holidays;
|
|
|
+ }
|
|
|
+
|
|
|
public static BigDecimal calculateWorkHours(LocalDateTime start, LocalDateTime end) {
|
|
|
// 1. 计算时间差
|
|
|
Duration duration = Duration.between(start, end);
|