|
@@ -12,8 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.time.DayOfWeek;
|
|
|
-import java.time.LocalDate;
|
|
|
+import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoField;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
@@ -64,31 +63,41 @@ public class DutyWorkbenchServiceImpl implements IDutyWorkbenchService {
|
|
|
public CheckWeek queryCheckWeekCount(Long deptId, String startTime, String endTime) {
|
|
|
LocalDate sTime = LocalDate.parse(startTime);
|
|
|
LocalDate eTime = LocalDate.parse(endTime);
|
|
|
- long daysBetween = ChronoUnit.DAYS.between(sTime, eTime);
|
|
|
- long total = daysBetween + 1;
|
|
|
- CheckWeek checkWeek = new CheckWeek();
|
|
|
- long count = signInRecordMapper.queryDaysCount(deptId, startTime, endTime);
|
|
|
- checkWeek.setDays(count);
|
|
|
- checkWeek.setDelDays(total-count);
|
|
|
- if (count == 0) {
|
|
|
- checkWeek.setLateDays(0L);
|
|
|
- checkWeek.setEarlyDays(0L);
|
|
|
- checkWeek.setLackDays(2*total);
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ long daysBetween;
|
|
|
+ long until;
|
|
|
+ if (eTime.isAfter(now)) {
|
|
|
+ daysBetween = ChronoUnit.DAYS.between(sTime, now);
|
|
|
+ until = getWeekInTimes(sTime, now, 5).size();
|
|
|
} else {
|
|
|
- long normal = signInRecordMapper.queryStatusCount(deptId, "1", startTime, endTime);
|
|
|
- long lateDays = signInRecordMapper.queryStatusCount(deptId, "2", startTime, endTime);
|
|
|
- long earlyDays = signInRecordMapper.queryStatusCount(deptId, "3", startTime, endTime);
|
|
|
- checkWeek.setLateDays(lateDays);
|
|
|
- checkWeek.setEarlyDays(earlyDays);
|
|
|
- checkWeek.setLackDays(2*total-normal-lateDays-earlyDays);
|
|
|
+ daysBetween = ChronoUnit.DAYS.between(sTime, eTime);
|
|
|
+ until = getWeekInTimes(sTime, eTime, 5).size();
|
|
|
}
|
|
|
+ long total = daysBetween + 1;
|
|
|
+ CheckWeek checkWeek = new CheckWeek();
|
|
|
+ // 出勤天数
|
|
|
+ long days = signInRecordMapper.queryDaysCount("1", deptId, startTime, endTime);
|
|
|
+ // 缺勤天数
|
|
|
+ long delDays = signInRecordMapper.queryDaysCount("4", deptId, startTime, endTime);
|
|
|
+ checkWeek.setDays(days);
|
|
|
+ checkWeek.setDelDays(delDays);
|
|
|
+ // 迟到
|
|
|
+ long lateDays = signInRecordMapper.queryStatusCount(deptId, "2", startTime, endTime);
|
|
|
+ // 早退
|
|
|
+ long earlyDays = signInRecordMapper.queryStatusCount(deptId, "3", startTime, endTime);
|
|
|
+ // 缺卡
|
|
|
+ long lackDays = signInRecordMapper.queryStatusCount(deptId, "4", startTime, endTime);
|
|
|
+ checkWeek.setLateDays(lateDays);
|
|
|
+ checkWeek.setEarlyDays(earlyDays);
|
|
|
+ checkWeek.setLackDays(lackDays);
|
|
|
+
|
|
|
long logCount = reportRecordMapper.querylogCount(deptId, startTime, endTime);
|
|
|
long weekCount = weekReportRecordMapper.queryWeekCount(deptId, startTime, endTime);
|
|
|
checkWeek.setDailySubmit(logCount);
|
|
|
checkWeek.setDailyNotSubmit(total-logCount);
|
|
|
- long until = sTime.until(eTime, ChronoUnit.WEEKS);
|
|
|
- checkWeek.setWeekSubmit(logCount);
|
|
|
- checkWeek.setWeekNotSubmit(until-logCount);
|
|
|
+ // long until = sTime.until(eTime, ChronoUnit.WEEKS);
|
|
|
+ checkWeek.setWeekSubmit(weekCount);
|
|
|
+ checkWeek.setWeekNotSubmit(until-weekCount);
|
|
|
return checkWeek;
|
|
|
}
|
|
|
|
|
@@ -446,4 +455,36 @@ public class DutyWorkbenchServiceImpl implements IDutyWorkbenchService {
|
|
|
}
|
|
|
return months;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定时间内星期几的所有日期
|
|
|
+ * @Author liuwenxu.com (2020-04-26)
|
|
|
+ *
|
|
|
+ * @param start 开始日期 2020-04-01
|
|
|
+ * @param end 截止日期 2020-05-01
|
|
|
+ * @param week 星期几 1
|
|
|
+ * @return ArrayList<LocalDate> [2020-04-06, 2020-04-13, 2020-04-20, 2020-04-27]
|
|
|
+ */
|
|
|
+ public static List<LocalDate> getWeekInTimes(LocalDate start, LocalDate end, int week) {
|
|
|
+ ArrayList<LocalDate> list = new ArrayList<>();
|
|
|
+
|
|
|
+ long days = ChronoUnit.DAYS.between(start, end) + 1;
|
|
|
+ log.info("[{}~{})之间共有:{}天", start, end, days);
|
|
|
+
|
|
|
+ Calendar startCalender = GregorianCalendar.from(start.atStartOfDay(ZoneId.systemDefault()));
|
|
|
+ for (int i = 0; i <= days - 1; i++) {
|
|
|
+ // 1代表周日,7代表周六
|
|
|
+ if (startCalender.get(Calendar.DAY_OF_WEEK) == week + 1) {
|
|
|
+ list.add(
|
|
|
+ LocalDateTime.ofInstant(
|
|
|
+ startCalender.toInstant(),
|
|
|
+ ZoneOffset.systemDefault()
|
|
|
+ ).toLocalDate()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ startCalender.add(Calendar.DATE, 1);
|
|
|
+ }
|
|
|
+ log.info("[{}~{})之间共有:{}个 星期{}", start, end, list.size(), week);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|