|
@@ -6,6 +6,7 @@ import {
|
|
|
getAllReport,
|
|
|
getHiredDate,
|
|
|
getResignationDate,
|
|
|
+ getUserTakingDetail,
|
|
|
} from '@/services/ReportDaily';
|
|
|
|
|
|
async function getLateSubmissionsAndUnsubmittedReports(option) {
|
|
@@ -15,7 +16,7 @@ async function getLateSubmissionsAndUnsubmittedReports(option) {
|
|
|
// 遍历报表数据,生成以工号为键、提交时间数组为值的数据结构
|
|
|
reportData.forEach(item => {
|
|
|
const employeeId = item.creator_id;
|
|
|
- // if (item.creator_name != '徐俊杰') return;
|
|
|
+ // if (item.creator_name != '张西明') return;
|
|
|
const reportTime = moment(item.create_time, 'YYYY年MM月DD日 HH:mm');
|
|
|
if (!employeeSubmissions[employeeId]) {
|
|
|
employeeSubmissions[employeeId] = {
|
|
@@ -25,19 +26,14 @@ async function getLateSubmissionsAndUnsubmittedReports(option) {
|
|
|
}
|
|
|
employeeSubmissions[employeeId].dates.push(reportTime);
|
|
|
});
|
|
|
-
|
|
|
+ // debugger
|
|
|
// 遍历工号,检查每个工号对应的提交时间
|
|
|
for (const employeeId in employeeSubmissions) {
|
|
|
const submissions = employeeSubmissions[employeeId].dates;
|
|
|
console.log(`请求${employeeSubmissions[employeeId].name}的请假详情`);
|
|
|
onProcess?.(`请求${employeeSubmissions[employeeId].name}的请假详情`);
|
|
|
// 查询请假情况
|
|
|
- const takingLeave = await getUserTakingLeave(startDate, endDate, employeeId);
|
|
|
- // 判断是否为节假日或者请假
|
|
|
- const isHoliday = date => {
|
|
|
- let day = date.format('YYYY-MM-DD');
|
|
|
- return holiday[day] || takingLeave[day];
|
|
|
- };
|
|
|
+ const takingLeave = await getUserTakingDetail(startDate, endDate, employeeId);
|
|
|
|
|
|
// 根据日志提交时间、节假日、请假情况,获取未提交以及漏交记录
|
|
|
const { lateSubmissions, unsubmittedReports, takingLeaveReports } = await analyzeDates(
|
|
@@ -50,8 +46,6 @@ async function getLateSubmissionsAndUnsubmittedReports(option) {
|
|
|
employeeSubmissions[employeeId].lateSubmissions = lateSubmissions;
|
|
|
employeeSubmissions[employeeId].unsubmittedReports = unsubmittedReports;
|
|
|
employeeSubmissions[employeeId].takingLeaveReports = takingLeaveReports;
|
|
|
-
|
|
|
- delete employeeSubmissions[employeeId].dates;
|
|
|
}
|
|
|
|
|
|
onProcess('请求全部完成', true);
|
|
@@ -72,34 +66,36 @@ async function analyzeDates(dateArray, startDate, endDate, holiday, takingLeave)
|
|
|
|
|
|
while (currentDay.isSameOrBefore(endDate, 'day')) {
|
|
|
let index = -1;
|
|
|
- // 一日可能有多条记录,通过遍历找到今日最后一次提交记录
|
|
|
- sortedDates.forEach((time, i) => {
|
|
|
- let flag = time.isSame(currentDay, 'day');
|
|
|
- if (flag) index = i;
|
|
|
- });
|
|
|
- let date = index == -1 ? null : sortedDates[index];
|
|
|
-
|
|
|
- // 无提交记录或者没有在9点以后提交都算未提交
|
|
|
- if (!date || date.hour() < 9) {
|
|
|
- let dayKey = currentDay.format('YYYY-MM-DD');
|
|
|
- if (holiday[dayKey]) {
|
|
|
- // 节假日不做处理
|
|
|
- } else if (takingLeave[dayKey]) {
|
|
|
- // 判断是否为请假
|
|
|
- takingLeaveReports.push(dayKey);
|
|
|
- } else {
|
|
|
- // 今日未提交,根据次日提交情况判断是漏交还是迟交
|
|
|
- let nextDay = sortedDates.find(time => time.diff(currentDay, 'day') == 1);
|
|
|
- if (nextDay && nextDay.hour() < 9) {
|
|
|
- lateSubmissions.push(dayKey);
|
|
|
+ let dayKey = currentDay.format('YYYY-MM-DD');
|
|
|
+ if (holiday[dayKey] || currentDay.day() === 0 || currentDay.day() === 6) {
|
|
|
+ // 节假日与周末不做处理
|
|
|
+ } else {
|
|
|
+ // 一日可能有多条记录,通过遍历找到今日最后一次提交记录
|
|
|
+ sortedDates.forEach((time, i) => {
|
|
|
+ let flag = time.isSame(currentDay, 'day');
|
|
|
+ if (flag) index = i;
|
|
|
+ });
|
|
|
+ let date = index == -1 ? null : sortedDates[index];
|
|
|
+
|
|
|
+ // 无提交记录或者没有在9点以后提交都算未提交
|
|
|
+ if (!date || date.hour() < 9) {
|
|
|
+ if (takingLeave[dayKey]) {
|
|
|
+ // 判断是否为请假
|
|
|
+ takingLeaveReports.push(dayKey);
|
|
|
} else {
|
|
|
- unsubmittedReports.push(dayKey);
|
|
|
+ // 今日未提交,根据次日提交情况判断是漏交还是迟交
|
|
|
+ let nextDay = sortedDates.find(time => time.diff(currentDay, 'day') == 1);
|
|
|
+ if (nextDay && nextDay.hour() < 9) {
|
|
|
+ lateSubmissions.push(dayKey);
|
|
|
+ } else {
|
|
|
+ unsubmittedReports.push(dayKey);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 删除数组内多余数据,提高下次遍历效率
|
|
|
- if (index != -1) sortedDates.splice(0, index);
|
|
|
+ // if (index != -1) sortedDates.splice(0, index);
|
|
|
|
|
|
currentDay.add(1, 'days');
|
|
|
}
|