AttendanceSummaryConfirmHelper.cs
9.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using System;
using NCC.Extend.Entitys.Dto.LqAttendanceSummary;
using NCC.Extend.Entitys.Enum;
using NCC.Extend.Entitys.lq_attendance_summary;
using Newtonsoft.Json;
namespace NCC.Extend
{
/// <summary>
/// 考勤汇总员工确认状态与快照
/// </summary>
public static class AttendanceSummaryConfirmHelper
{
public const string SignedPolicyOverwrite = "overwrite";
public const string SignedPolicyIgnore = "ignore";
public static bool IsSigned(int? status)
{
return status == (int)AttendanceSummaryConfirmStatusEnum.已签字确认;
}
public static bool IsSigned(LqAttendanceSummaryEntity entity)
{
return entity != null && IsSigned(entity.ConfirmStatus);
}
public static string StatusName(int? status)
{
if (status == (int)AttendanceSummaryConfirmStatusEnum.已发送待确认)
{
return "待确认";
}
if (status == (int)AttendanceSummaryConfirmStatusEnum.已签字确认)
{
return "已确认";
}
return "未发送";
}
public static void ResetToUnsent(LqAttendanceSummaryEntity entity)
{
if (entity == null)
{
return;
}
entity.ConfirmStatus = (int)AttendanceSummaryConfirmStatusEnum.未发送;
entity.SendTime = null;
entity.SendUserId = null;
entity.SendUserName = null;
entity.ConfirmTime = null;
entity.SignatureImage = null;
entity.ConfirmSnapshotJson = null;
}
public static DateTime? ResolveDeadline(DateTime? sendTime)
{
return sendTime.HasValue ? sendTime.Value.Date.AddDays(1) : (DateTime?)null;
}
public static bool IsExpired(DateTime? sendTime, int confirmStatus, DateTime now)
{
var deadline = ResolveDeadline(sendTime);
return confirmStatus == (int)AttendanceSummaryConfirmStatusEnum.已发送待确认
&& deadline.HasValue
&& now >= deadline.Value;
}
public static void FillDeadline(LqAttendanceSummaryListOutput item, DateTime now)
{
if (item == null)
{
return;
}
item.confirmDeadline = ResolveDeadline(item.sendTime);
item.confirmExpired = IsExpired(item.sendTime, item.confirmStatus, now);
}
public static AttendanceSummaryConfirmSnapshot FromListItem(LqAttendanceSummaryListOutput item)
{
if (item == null)
{
return new AttendanceSummaryConfirmSnapshot();
}
return new AttendanceSummaryConfirmSnapshot
{
userName = item.userName,
organizeName = item.organizeName,
year = item.year,
month = item.month,
attendanceGroupDisplay = item.attendanceGroupDisplay,
expectedAttendanceDays = item.expectedAttendanceDays,
actualAttendanceDays = item.actualAttendanceDays,
workDays = item.workDays,
leaveDays = item.leaveDays,
restDays = item.restDays,
monthEntitledRestDays = item.monthEntitledRestDays,
monthOnDutyDays = item.monthOnDutyDays,
monthCompositeWorkDays = item.monthCompositeWorkDays,
monthPaidLeaveDays = item.monthPaidLeaveDays,
monthLeaveDaysTotal = item.monthLeaveDaysTotal,
monthLateEarlyDays = item.monthLateEarlyDays,
monthAbsenteeismDays = item.monthAbsenteeismDays,
monthSupplementDays = item.monthSupplementDays,
monthSupplementCount = item.monthSupplementCount,
monthBlockingSupplementDays = item.monthBlockingSupplementDays,
monthIsFullAttendance = item.monthIsFullAttendance,
monthLateDeductionAmount = item.monthLateDeductionAmount,
monthLeaveDeductionAmount = item.monthLeaveDeductionAmount,
monthAbsenteeismDeductionAmount = item.monthAbsenteeismDeductionAmount,
monthMissingCardCount = item.monthMissingCardCount,
monthMissingCardDeductionAmount = item.monthMissingCardDeductionAmount,
monthSupplementDeductionAmount = item.monthSupplementDeductionAmount,
monthPunchApplyDeductionAmount = item.monthPunchApplyDeductionAmount,
abnormalDays = item.abnormalDays,
lateCount = item.lateCount,
lateMinutes = item.lateMinutes,
earlyLeaveCount = item.earlyLeaveCount,
earlyLeaveMinutes = item.earlyLeaveMinutes,
personalLeaveDays = item.personalLeaveDays,
sickLeaveDays = item.sickLeaveDays,
annualLeaveDays = item.annualLeaveDays,
marriageLeaveDays = item.marriageLeaveDays,
funeralLeaveDays = item.funeralLeaveDays,
welfareLeaveDays = item.welfareLeaveDays,
paidVacationDays = item.paidVacationDays,
cumulativeRestDays = item.cumulativeRestDays
};
}
public static void ApplySnapshot(LqAttendanceSummaryListOutput item, string snapshotJson)
{
if (item == null || string.IsNullOrWhiteSpace(snapshotJson))
{
return;
}
try
{
var snap = JsonConvert.DeserializeObject<AttendanceSummaryConfirmSnapshot>(snapshotJson);
if (snap == null)
{
return;
}
if (!string.IsNullOrWhiteSpace(snap.userName)) item.userName = snap.userName;
if (!string.IsNullOrWhiteSpace(snap.organizeName)) item.organizeName = snap.organizeName;
if (!string.IsNullOrWhiteSpace(snap.attendanceGroupDisplay))
{
item.attendanceGroupDisplay = snap.attendanceGroupDisplay;
}
item.expectedAttendanceDays = snap.expectedAttendanceDays;
item.actualAttendanceDays = snap.actualAttendanceDays;
item.workDays = snap.workDays;
item.leaveDays = snap.leaveDays;
item.restDays = snap.restDays;
item.monthEntitledRestDays = snap.monthEntitledRestDays;
item.monthOnDutyDays = snap.monthOnDutyDays;
item.monthCompositeWorkDays = snap.monthCompositeWorkDays;
item.monthPaidLeaveDays = snap.monthPaidLeaveDays;
item.monthLeaveDaysTotal = snap.monthLeaveDaysTotal;
item.monthLateEarlyDays = snap.monthLateEarlyDays;
item.monthAbsenteeismDays = snap.monthAbsenteeismDays;
item.monthSupplementDays = snap.monthSupplementDays;
item.monthSupplementCount = snap.monthSupplementCount;
item.monthBlockingSupplementDays = snap.monthBlockingSupplementDays;
item.monthIsFullAttendance = snap.monthIsFullAttendance;
item.monthLateDeductionAmount = snap.monthLateDeductionAmount;
item.monthLeaveDeductionAmount = snap.monthLeaveDeductionAmount;
item.monthAbsenteeismDeductionAmount = snap.monthAbsenteeismDeductionAmount;
item.monthMissingCardCount = snap.monthMissingCardCount;
item.monthMissingCardDeductionAmount = snap.monthMissingCardDeductionAmount;
item.monthSupplementDeductionAmount = snap.monthSupplementDeductionAmount;
item.monthPunchApplyDeductionAmount = snap.monthPunchApplyDeductionAmount;
item.abnormalDays = snap.abnormalDays;
item.lateCount = snap.lateCount;
item.lateMinutes = snap.lateMinutes;
item.earlyLeaveCount = snap.earlyLeaveCount;
item.earlyLeaveMinutes = snap.earlyLeaveMinutes;
item.personalLeaveDays = snap.personalLeaveDays;
item.sickLeaveDays = snap.sickLeaveDays;
item.annualLeaveDays = snap.annualLeaveDays;
item.marriageLeaveDays = snap.marriageLeaveDays;
item.funeralLeaveDays = snap.funeralLeaveDays;
item.welfareLeaveDays = snap.welfareLeaveDays;
item.paidVacationDays = snap.paidVacationDays;
item.cumulativeRestDays = snap.cumulativeRestDays;
if (item.cumulativeRestDays == 0m)
{
item.cumulativeRestDays = AttendanceSummaryMonthMetricsHelper.CalcCumulativeRestDays(
snap.paidVacationDays,
snap.personalLeaveDays,
snap.sickLeaveDays,
snap.welfareLeaveDays,
snap.annualLeaveDays,
snap.marriageLeaveDays,
snap.funeralLeaveDays);
}
}
catch (JsonException)
{
}
}
}
}