|
@@ -8,6 +8,7 @@ import com.management.platform.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import com.management.platform.util.WorkDayCalculateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
@@ -27,6 +28,7 @@ import java.time.*;
|
|
|
import java.time.chrono.ChronoLocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
@@ -266,6 +268,34 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
List<Department> departmentList = departmentService.list(new QueryWrapper<Department>());
|
|
|
List<AttendanceStaff> staffList = attendanceStaffService.list(new QueryWrapper<AttendanceStaff>().between("clock_date", firstDay, lastDay));
|
|
|
List<ApplyForm> applyFormList = applyFormService.getListByFirstDateAndLastDate(startDate, endDate);
|
|
|
+ //对于请假,按照交叉的部分重新计算时长
|
|
|
+ for (ApplyForm applyForm : applyFormList) {
|
|
|
+ if (applyForm.getType() == 3) {
|
|
|
+ //每天8小时工作日
|
|
|
+// if (applyForm.getApplyId().equals("LEW1157")) {
|
|
|
+// System.out.println(applyForm.getStartTime() + " " + applyForm.getEndTime());
|
|
|
+// }
|
|
|
+ if (applyForm.getStartTime().toLocalDate().isBefore(startDate)) {
|
|
|
+ //计算相差天数
|
|
|
+ long days = ChronoUnit.DAYS.between(applyForm.getStartTime().toLocalDate(), startDate);
|
|
|
+ applyForm.setStartTime(applyForm.getStartTime().plusDays(days));
|
|
|
+ }
|
|
|
+ if (applyForm.getEndTime().toLocalDate().isAfter(endDate)) {
|
|
|
+ long days = ChronoUnit.DAYS.between(endDate, applyForm.getEndTime().toLocalDate());
|
|
|
+ applyForm.setEndTime(applyForm.getEndTime().minusDays(days));
|
|
|
+ }
|
|
|
+// if (applyForm.getApplyId().equals("LEW1157")) {
|
|
|
+// System.out.println("调整后为:"+applyForm.getStartTime() + " " + applyForm.getEndTime());
|
|
|
+// System.out.println("原来时长为:"+applyForm.getSumTime());
|
|
|
+// }
|
|
|
+ //只计算工作日
|
|
|
+ int workDays = WorkDayCalculateUtils.getWorkDaysCountInRange(formatter2.format(applyForm.getStartTime()), formatter2.format(applyForm.getEndTime()), 0);
|
|
|
+ applyForm.setSumTime((BigDecimal.valueOf(workDays).multiply(BigDecimal.valueOf(8))));
|
|
|
+// if (applyForm.getApplyId().equals("LEW1157")) {
|
|
|
+// System.out.println("调整后时长为:"+applyForm.getSumTime());
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
for (int i = 0; i < userList.size(); i++) {
|
|
|
ArrayList<String> strings = new ArrayList<>();
|
|
@@ -284,11 +314,16 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
strings.add("");//备注
|
|
|
|
|
|
List<AttendanceStaff> staffCollect = staffList.stream().filter(s -> s.getJobNumber().equals(u.getJobNumber())).collect(Collectors.toList());
|
|
|
- strings.add(staffCollect.size()+"");//实际出勤天
|
|
|
+ List<AttendanceStaff> workDaysCollect = staffCollect.stream().filter(s -> s.getAttendanceType() != 12).collect(Collectors.toList());
|
|
|
+ strings.add(workDaysCollect.size()+"");//实际出勤天
|
|
|
|
|
|
BigDecimal total8 = getDecimal(applyFormList,"病假",u.getJobNumber());
|
|
|
strings.add(total8.toString());
|
|
|
- BigDecimal total9 = getDecimal(applyFormList,"带薪假",u.getJobNumber());
|
|
|
+ String[] daixinjiaRange = "婚假、产假、护理假、丧假、独生子女护理假、哺乳假、产检假".split("、");
|
|
|
+ BigDecimal total9 = BigDecimal.ZERO;
|
|
|
+ for (String daixinjia : daixinjiaRange) {
|
|
|
+ total9 = total9.add(getDecimal(applyFormList,daixinjia,u.getJobNumber()));
|
|
|
+ }
|
|
|
strings.add(total9.toString());
|
|
|
BigDecimal total10 = getDecimal(applyFormList,"育儿假",u.getJobNumber());
|
|
|
strings.add(total10.toString());
|
|
@@ -308,6 +343,9 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
strings.add(total17.toString());
|
|
|
int countLess=0;
|
|
|
int countMore=0;
|
|
|
+ double zhoumoStaffOvertime=0;
|
|
|
+ double fadingStaffOvertime=0;
|
|
|
+ double otherStaffOvertime=0;
|
|
|
for (AttendanceStaff staff : staffCollect) {
|
|
|
Integer type = staff.getAttendanceType();
|
|
|
LocalDateTime clockStartTime = staff.getClockStartTime();
|
|
@@ -317,8 +355,23 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
LocalDateTime clockEndTime = staff.getClockEndTime();
|
|
|
LocalTime startTime = clockStartTime.toLocalTime();
|
|
|
LocalTime endTime = clockEndTime.toLocalTime();
|
|
|
-
|
|
|
- if (type == BAI_BAN) {
|
|
|
+ if (type == JIA_BAN) {
|
|
|
+ //加班处理
|
|
|
+ BigDecimal workHour = staff.getWorkHour();
|
|
|
+ if (workHour != null) {
|
|
|
+ if (staff.getClockDate().getDayOfWeek() == DayOfWeek.SATURDAY || staff.getClockDate().getDayOfWeek() == DayOfWeek.SUNDAY) {
|
|
|
+ //周末加班
|
|
|
+ zhoumoStaffOvertime+=workHour.doubleValue();
|
|
|
+ } else if(holidays.contains(staff.getClockDate().format(formatter2))) {
|
|
|
+ fadingStaffOvertime+=workHour.doubleValue();
|
|
|
+ } else {
|
|
|
+ otherStaffOvertime+=workHour.doubleValue()-8.0f;
|
|
|
+ }
|
|
|
+ }
|
|
|
+// if (staff.getName().equals("陈寿明")) {
|
|
|
+// System.out.println("陈寿明加班:"+zhoumoStaffOvertime+"+"+fadingStaffOvertime+"+"+otherStaffOvertime);
|
|
|
+// }
|
|
|
+ } else if (type == BAI_BAN) {
|
|
|
if (startTime.isAfter(LocalTime.of(8,0,0))) {
|
|
|
Duration duration = Duration.between(LocalTime.of(8,0,0),startTime );
|
|
|
long v = duration.toMinutes();
|
|
@@ -537,31 +590,47 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
}
|
|
|
strings.add(countLess+"");
|
|
|
strings.add(countMore+"");
|
|
|
- List<ApplyForm> unDaKacollect = applyFormList.stream().filter(a -> a.getType() == 6&&a.getApplyId().equals(u.getJobNumber())).collect(Collectors.toList());
|
|
|
+ List<ApplyForm> fixDakaCollection = applyFormList.stream().filter(a -> a.getType() == 6&&a.getApplyId().equals(u.getJobNumber())).collect(Collectors.toList());
|
|
|
+ List<AttendanceStaff> unDaKacollect = staffCollect.stream().filter(s -> s.getClockStartTime() == null && s.getClockEndTime() == null).collect(Collectors.toList());
|
|
|
+ unDaKacollect = unDaKacollect.stream().filter(un->!fixDakaCollection.stream().anyMatch(fix->fix.getStartTime().toLocalDate().equals(un.getClockDate()))).collect(Collectors.toList());
|
|
|
strings.add(unDaKacollect.size()+"");
|
|
|
|
|
|
- int xiaoyeCount = (int) staffCollect.stream().filter(s -> s.getAttendanceTypeName() != null && s.getAttendanceTypeName().equals("小夜班")).count();
|
|
|
- int dayeCount = (int) staffCollect.stream().filter(s -> s.getAttendanceTypeName() != null && s.getAttendanceTypeName().equals("大夜班")).count();
|
|
|
- int size = staffCollect.size();
|
|
|
- int other=size-xiaoyeCount-dayeCount;
|
|
|
- strings.add(other+"");//其他
|
|
|
+ int xiaoyeCount = (int) staffCollect.stream().filter(s -> s.getAttendanceTypeName() != null && s.getAttendanceTypeName().contains("小夜班")).count();
|
|
|
+ int dayeCount = (int) staffCollect.stream().filter(s -> s.getAttendanceTypeName() != null && s.getAttendanceTypeName().contains("大夜班")).count();
|
|
|
+// int size = staffCollect.size();
|
|
|
+// int other=size-xiaoyeCount-dayeCount;
|
|
|
+ strings.add("");//其他
|
|
|
strings.add(xiaoyeCount+"");//小夜班
|
|
|
strings.add(dayeCount+"");//大夜班
|
|
|
|
|
|
- BigDecimal zhouMoSum = applyFormList.stream().filter(a -> a.getApplyId().equals(u.getJobNumber())
|
|
|
- && (a.getStartTime().toLocalDate().getDayOfWeek() == DayOfWeek.SATURDAY || a.getStartTime().toLocalDate().getDayOfWeek() == DayOfWeek.SUNDAY))
|
|
|
+ List<ApplyForm> jiabanList = applyFormList.stream().filter(a -> a.getType() == 4 && a.getApplyId().equals(u.getJobNumber())).collect(Collectors.toList());
|
|
|
+ BigDecimal zhouMoSum = jiabanList.stream().filter(a -> (a.getStartTime().toLocalDate().getDayOfWeek() == DayOfWeek.SATURDAY || a.getStartTime().toLocalDate().getDayOfWeek() == DayOfWeek.SUNDAY))
|
|
|
.map(ApplyForm::getSumTime)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal faDingSum = applyFormList.stream().filter(a -> a.getApplyId().equals(u.getJobNumber())
|
|
|
- && holidays.contains(a.getStartTime().toLocalDate().format(formatter2)))
|
|
|
+ BigDecimal faDingSum = jiabanList.stream().filter(a -> holidays.contains(a.getStartTime().toLocalDate().format(formatter2)))
|
|
|
.map(ApplyForm::getSumTime)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal total = applyFormList.stream().filter(a -> a.getApplyId().equals(u.getJobNumber())).map(ApplyForm::getSumTime)
|
|
|
+ BigDecimal total = jiabanList.stream().map(ApplyForm::getSumTime)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
BigDecimal qiTaSum=total.subtract(faDingSum).subtract(zhouMoSum);
|
|
|
- strings.add(zhouMoSum.toString());
|
|
|
- strings.add(faDingSum.toString());
|
|
|
- strings.add(qiTaSum.toString());
|
|
|
+ if (zhoumoStaffOvertime > 0) {
|
|
|
+ strings.add(zhoumoStaffOvertime+"");
|
|
|
+ } else {
|
|
|
+ strings.add(zhouMoSum.toString());
|
|
|
+ }
|
|
|
+ if (fadingStaffOvertime > 0) {
|
|
|
+ strings.add(fadingStaffOvertime+"");
|
|
|
+ } else {
|
|
|
+ strings.add(faDingSum.toString());
|
|
|
+ }
|
|
|
+ if (otherStaffOvertime > 0) {
|
|
|
+ strings.add(otherStaffOvertime+"");
|
|
|
+ } else {
|
|
|
+ strings.add(qiTaSum.toString());
|
|
|
+ }
|
|
|
+// strings.add(zhouMoSum.add(new BigDecimal(zhoumoStaffOvertime)).toString());
|
|
|
+// strings.add(faDingSum.add(new BigDecimal(fadingStaffOvertime)).toString());
|
|
|
+// strings.add(qiTaSum.add(new BigDecimal(otherStaffOvertime)).toString());
|
|
|
|
|
|
list.add(strings);
|
|
|
}
|