Commit 9b731e1b by 陶然

优化同步OA请假的Job

parent f78a1f1e
...@@ -51,5 +51,8 @@ namespace Jst.HumanResources.Oa.Entities ...@@ -51,5 +51,8 @@ namespace Jst.HumanResources.Oa.Entities
[Ignore] [Ignore]
public bool IsSuccess { get; set; } public bool IsSuccess { get; set; }
[Ignore]
public string Reason { get; set; }
} }
} }
...@@ -33,7 +33,7 @@ namespace Jst.HumanResources.Oa.Jobs ...@@ -33,7 +33,7 @@ namespace Jst.HumanResources.Oa.Jobs
var queryNotSigned = connHr.From<Attendance>(); var queryNotSigned = connHr.From<Attendance>();
//只查三个月以内的 //只查三个月以内的
queryNotSigned.Where(o => o.TimeResult == "NotSigned" & o.BaseCheckTime >= DateTime.Now.AddMonths(-3)); queryNotSigned.Where(o => o.TimeResult != "Normal" & o.TimeResult != "Leave" & o.BaseCheckTime >= DateTime.Now.AddMonths(-3));
//查出未打卡的人清单 //查出未打卡的人清单
var notSigneds = connHr.Select(queryNotSigned); var notSigneds = connHr.Select(queryNotSigned);
...@@ -56,15 +56,32 @@ namespace Jst.HumanResources.Oa.Jobs ...@@ -56,15 +56,32 @@ namespace Jst.HumanResources.Oa.Jobs
{ {
var beginStr = "alt=开始时间 value=\""; var beginStr = "alt=开始时间 value=\"";
var endStr = "alt=结束时间 value=\""; var endStr = "alt=结束时间 value=\"";
var reasonBeginStr = "请假理由 size=31 value=";
var reasonEndStr = "name=Text77021621";
int beginReasonIndex = oa.FormContent.IndexOf(reasonBeginStr);
int endReasonIndex = oa.FormContent.IndexOf(reasonEndStr);
int beginIndex = oa.FormContent.IndexOf(beginStr); int beginIndex = oa.FormContent.IndexOf(beginStr);
int endIndex = oa.FormContent.IndexOf(endStr); int endIndex = oa.FormContent.IndexOf(endStr);
if (beginIndex == -1) continue; if (beginIndex == -1) continue;
if (endIndex == -1) continue; if (endIndex == -1) continue;
if (!DateTime.TryParse(oa.FormContent.Substring(beginIndex + beginStr.Length, 10), out var beginTime)) continue; if (!DateTime.TryParse(oa.FormContent.Substring(beginIndex + beginStr.Length, 10), out var beginTime)) continue;
if (!DateTime.TryParse(oa.FormContent.Substring(endIndex + endStr.Length, 10), out var endtTime)) continue; if (!DateTime.TryParse(oa.FormContent.Substring(endIndex + endStr.Length, 10), out var endtTime)) continue;
var reason = string.Empty;
if (beginReasonIndex != -1)
{
if (endReasonIndex == -1) endReasonIndex = beginReasonIndex + reasonBeginStr.Length - 6;
try
{
reason = oa.FormContent.Substring(beginReasonIndex + reasonBeginStr.Length, endReasonIndex - beginReasonIndex - reasonBeginStr.Length);
}
catch { }
}
oa.IsSuccess = true; oa.IsSuccess = true;
oa.TimeStr = beginTime; oa.TimeStr = beginTime;
oa.LateTime = endtTime.AddDays(1); oa.LateTime = endtTime.AddDays(1);
oa.Reason = reason;
} }
foreach (var notSigned in notSigneds) foreach (var notSigned in notSigneds)
{ {
...@@ -72,12 +89,14 @@ namespace Jst.HumanResources.Oa.Jobs ...@@ -72,12 +89,14 @@ namespace Jst.HumanResources.Oa.Jobs
if (oas.IsNullOrEmpty()) continue; if (oas.IsNullOrEmpty()) continue;
var oa = oas.FirstOrDefault(o => o.IsSuccess == true & o.TimeStr >= notSigned.BaseCheckTime & notSigned.BaseCheckTime < o.LateTime); var oa = oas.FirstOrDefault(o => o.IsSuccess == true & o.TimeStr >= notSigned.BaseCheckTime & notSigned.BaseCheckTime < o.LateTime);
if (oa == null) continue; if (oa == null) continue;
notSigned.SourceType = "OA";
notSigned.AddOnlyProperties(o => o.SourceType);
notSigned.TimeResult = "Leave"; notSigned.TimeResult = "Leave";
notSigned.AddOnlyProperties(o => o.TimeResult); notSigned.AddOnlyProperties(o => o.TimeResult);
notSigned.Summary = $"已匹配到OA请假申请,时间为:{oa.TimeStr:G}{oa.LateTime:G}"; notSigned.SourceType = "OA";
notSigned.AddOnlyProperties(o => o.SourceType);
notSigned.Summary = $"{oa.Reason}";
notSigned.AddOnlyProperties(o => o.Summary); notSigned.AddOnlyProperties(o => o.Summary);
notSigned.Remark = $"已匹配到OA请假申请,时间为:{oa.TimeStr:yyyy-MM-dd}{oa.LateTime:yyyy-MM-dd}";
notSigned.AddOnlyProperties(o => o.Remark);
connHr.UpdateOnly(notSigned); connHr.UpdateOnly(notSigned);
success++; success++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment