|
@@ -2,6 +2,7 @@
|
|
|
using Quartz;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using wispro.sp.entity;
|
|
@@ -10,213 +11,212 @@ namespace wispro.sp.api.Job
|
|
|
{
|
|
|
public class UpdateJXDataFromIPEasyJob : IJob
|
|
|
{
|
|
|
- public Task Execute(IJobExecutionContext context)
|
|
|
+ public void UpdateFromIPEasy(PerformanceItem Item,spDbContext spDb)
|
|
|
{
|
|
|
- spDbContext spDb = new spDbContext();
|
|
|
+ dynamic retObj = utility.IPEasyUtility.GetPerformanceRecord(Item.CaseNo, Item.DoItem, string.IsNullOrEmpty(Item.CaseStage) ? null : Item.CaseStage);
|
|
|
|
|
|
- var lstItem = spDb.PerformanceItems.Where<PerformanceItem>(p =>
|
|
|
- ((p.AgentFeedbackMemo != "已算绩效" || p.AgentFeedbackMemo==null ) && p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J")))
|
|
|
- .Include(p=>p.Reviewer)
|
|
|
- .Include(p=>p.CalMonth)
|
|
|
- .ToList<PerformanceItem>();
|
|
|
-
|
|
|
|
|
|
- if (lstItem != null)
|
|
|
+ IDictionary<String, Object> keyValuePairs = (IDictionary<String, Object>)retObj;
|
|
|
+
|
|
|
+ if (keyValuePairs.ContainsKey("DoItemCoefficient") && Item.DoItemCoefficient != retObj.DoItemCoefficient)
|
|
|
{
|
|
|
- int i = 0;
|
|
|
- foreach (var Item in lstItem)
|
|
|
- {
|
|
|
- System.Diagnostics.Debug.WriteLine($"{DateTime.Now}\t{++i}\t{Item.CaseNo}");
|
|
|
- int iTryCount = 0;
|
|
|
- TryAgain:
|
|
|
- try
|
|
|
- {
|
|
|
- iTryCount++;
|
|
|
- dynamic retObj = utility.IPEasyUtility.GetPerformanceRecord(Item.CaseNo, Item.DoItem,string.IsNullOrEmpty(Item.CaseStage)?null: Item.CaseStage);
|
|
|
+ Item.DoItemCoefficient = retObj.DoItemCoefficient;
|
|
|
+ }
|
|
|
|
|
|
+ if (keyValuePairs.ContainsKey("DoItemMemo") && Item.DoItemMemo != retObj.DoItemMemo && !string.IsNullOrEmpty(retObj.DoItemMemo))
|
|
|
+ {
|
|
|
+ Item.DoItemMemo = retObj.DoItemMemo;
|
|
|
+ }
|
|
|
|
|
|
- IDictionary<String, Object> keyValuePairs = (IDictionary<String, Object>)retObj;
|
|
|
+ if (keyValuePairs.ContainsKey("DoItemState") && Item.DoItemState != retObj.DoItemState && !string.IsNullOrEmpty(retObj.DoItemState))
|
|
|
+ {
|
|
|
+ Item.DoItemState = retObj.DoItemState;
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("DoItemCoefficient") && Item.DoItemCoefficient != retObj.DoItemCoefficient)
|
|
|
- {
|
|
|
- Item.DoItemCoefficient = retObj.DoItemCoefficient;
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("CustomerLimitDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.CustomerLimitDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.CustomerLimitDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("DoItemMemo") && Item.DoItemMemo != retObj.DoItemMemo && !string.IsNullOrEmpty(retObj.DoItemMemo))
|
|
|
- {
|
|
|
- Item.DoItemMemo = retObj.DoItemMemo;
|
|
|
- }
|
|
|
+ if (date != Item.CustomerLimitDate)
|
|
|
+ Item.CustomerLimitDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("DoItemState") && Item.DoItemState != retObj.DoItemState && !string.IsNullOrEmpty(retObj.DoItemState))
|
|
|
- {
|
|
|
- Item.DoItemState = retObj.DoItemState;
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("EntrustingDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.EntrustingDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.EntrustingDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("CustomerLimitDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.CustomerLimitDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.CustomerLimitDate);
|
|
|
+ if (date != Item.EntrustingDate)
|
|
|
+ Item.EntrustingDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.CustomerLimitDate)
|
|
|
- Item.CustomerLimitDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("FinalizationDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.FinalizationDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.FinalizationDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("EntrustingDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.EntrustingDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.EntrustingDate);
|
|
|
+ if (date != Item.FinalizationDate)
|
|
|
+ Item.FinalizationDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.EntrustingDate)
|
|
|
- Item.EntrustingDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("FinishedDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.FinishedDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.FinishedDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("FinalizationDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.FinalizationDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.FinalizationDate);
|
|
|
+ if (date != Item.FinishedDate)
|
|
|
+ Item.FinishedDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.FinalizationDate)
|
|
|
- Item.FinalizationDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("FirstDraftDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.FirstDraftDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.FirstDraftDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("FinishedDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.FinishedDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.FinishedDate);
|
|
|
+ if (date != Item.FirstDraftDate)
|
|
|
+ Item.FirstDraftDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.FinishedDate)
|
|
|
- Item.FinishedDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("InternalDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.InternalDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.InternalDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("FirstDraftDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.FirstDraftDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.FirstDraftDate);
|
|
|
+ if (date != Item.InternalDate)
|
|
|
+ Item.InternalDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.FirstDraftDate)
|
|
|
- Item.FirstDraftDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("ReturnDate"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.ReturnDate))
|
|
|
+ {
|
|
|
+ DateTime date = DateTime.Parse(retObj.ReturnDate);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("InternalDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.InternalDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.InternalDate);
|
|
|
+ if (date != Item.ReturnDate)
|
|
|
+ Item.ReturnDate = date;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.InternalDate)
|
|
|
- Item.InternalDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("WordCount"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.WordCount))
|
|
|
+ {
|
|
|
+ var wordCount = int.Parse(retObj.WordCount);
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("ReturnDate"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.ReturnDate))
|
|
|
- {
|
|
|
- DateTime date = DateTime.Parse(retObj.ReturnDate);
|
|
|
+ if (wordCount != Item.WordCount)
|
|
|
+ Item.WordCount = wordCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (date != Item.ReturnDate)
|
|
|
- Item.ReturnDate = date;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("WordCount"))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.WordCount))
|
|
|
- {
|
|
|
- var wordCount = int.Parse(retObj.WordCount);
|
|
|
+ if (keyValuePairs.ContainsKey("Reviewer") && (Item.Reviewer == null || Item.Reviewer.Name != retObj.Reviewer) && !string.IsNullOrEmpty(retObj.Reviewer))
|
|
|
+ {
|
|
|
+ string name = retObj.Reviewer;
|
|
|
|
|
|
- if (wordCount != Item.WordCount)
|
|
|
- Item.WordCount = wordCount;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (!string.IsNullOrEmpty(name))
|
|
|
+ {
|
|
|
+ var temReviewer = spDb.Staffs.Where<Staff>(s => s.Name == name).FirstOrDefault();
|
|
|
+ if (temReviewer == null)
|
|
|
+ {
|
|
|
+ //Item.Reviewer = new Staff() { Name = retObj.Reviewer };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //Item.Reviewer = temReviewer;
|
|
|
+ Item.ReviewerId = temReviewer.Id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ if (keyValuePairs.ContainsKey("ApplicationType") && Item.ApplicationType != retObj.ApplicationType && !string.IsNullOrEmpty(retObj.ApplicationType))
|
|
|
+ {
|
|
|
+ Item.ApplicationType = retObj.ApplicationType;
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("Reviewer") && (Item.Reviewer ==null || Item.Reviewer.Name != retObj.Reviewer) && !string.IsNullOrEmpty(retObj.Reviewer))
|
|
|
- {
|
|
|
- string name = retObj.Reviewer;
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(name))
|
|
|
- {
|
|
|
- var temReviewer = spDb.Staffs.Where<Staff>(s => s.Name == name).FirstOrDefault();
|
|
|
- if (temReviewer == null)
|
|
|
- {
|
|
|
- //Item.Reviewer = new Staff() { Name = retObj.Reviewer };
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //Item.Reviewer = temReviewer;
|
|
|
- Item.ReviewerId = temReviewer.Id;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("BusinessType") && Item.BusinessType != retObj.BusinessType && !string.IsNullOrEmpty(retObj.BusinessType))
|
|
|
+ {
|
|
|
+ Item.BusinessType = retObj.BusinessType;
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("ApplicationType") && Item.ApplicationType != retObj.ApplicationType && !string.IsNullOrEmpty(retObj.ApplicationType))
|
|
|
- {
|
|
|
- Item.ApplicationType = retObj.ApplicationType;
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("CaseCoefficient") && Item.CaseCoefficient != retObj.CaseCoefficient && !string.IsNullOrEmpty(retObj.CaseCoefficient))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(retObj.CaseCoefficient))
|
|
|
+ {
|
|
|
+ Item.CaseCoefficient = retObj.CaseCoefficient;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("BusinessType") && Item.BusinessType != retObj.BusinessType && !string.IsNullOrEmpty(retObj.BusinessType))
|
|
|
- {
|
|
|
- Item.BusinessType = retObj.BusinessType;
|
|
|
- }
|
|
|
+ //if (keyValuePairs.ContainsKey("CaseMemo") && Item.CaseMemo != retObj.CaseMemo && !string.IsNullOrEmpty(retObj.CaseMemo))
|
|
|
+ //{
|
|
|
+ // Item.CaseMemo = retObj.CaseMemo;
|
|
|
+ //}
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("CaseCoefficient") && Item.CaseCoefficient != retObj.CaseCoefficient && !string.IsNullOrEmpty(retObj.CaseCoefficient))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(retObj.CaseCoefficient)){
|
|
|
- Item.CaseCoefficient = retObj.CaseCoefficient;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("CaseStage") && Item.CaseStage != retObj.CaseStage && !string.IsNullOrEmpty(retObj.CaseStage))
|
|
|
+ {
|
|
|
+ Item.CaseStage = retObj.CaseStage;
|
|
|
+ }
|
|
|
|
|
|
- //if (keyValuePairs.ContainsKey("CaseMemo") && Item.CaseMemo != retObj.CaseMemo && !string.IsNullOrEmpty(retObj.CaseMemo))
|
|
|
- //{
|
|
|
- // Item.CaseMemo = retObj.CaseMemo;
|
|
|
- //}
|
|
|
+ if (keyValuePairs.ContainsKey("CaseState") && Item.CaseState != retObj.CaseState && !string.IsNullOrEmpty(retObj.CaseState))
|
|
|
+ {
|
|
|
+ Item.CaseState = retObj.CaseState;
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("CaseStage") && Item.CaseStage != retObj.CaseStage && !string.IsNullOrEmpty(retObj.CaseStage))
|
|
|
- {
|
|
|
- Item.CaseStage = retObj.CaseStage;
|
|
|
- }
|
|
|
+ if (keyValuePairs.ContainsKey("CaseType") && Item.CaseType != retObj.CaseType && !string.IsNullOrEmpty(retObj.CaseType))
|
|
|
+ {
|
|
|
+ Item.CaseType = retObj.CaseType;
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("CaseState") && Item.CaseState != retObj.CaseState && !string.IsNullOrEmpty(retObj.CaseState))
|
|
|
- {
|
|
|
- Item.CaseState = retObj.CaseState;
|
|
|
- }
|
|
|
+ if (spDb.Entry(Item).State != EntityState.Unchanged)
|
|
|
+ {
|
|
|
+ if (Item.AgentFeedbackMemo != "特殊点数申诉")
|
|
|
+ {
|
|
|
+ Utility.Utility.CalBasePoint(Item, spDb.BasePointRules.ToList());
|
|
|
+ spDb.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (keyValuePairs.ContainsKey("CaseType") && Item.CaseType != retObj.CaseType && !string.IsNullOrEmpty(retObj.CaseType))
|
|
|
- {
|
|
|
- Item.CaseType = retObj.CaseType;
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task Execute(IJobExecutionContext context)
|
|
|
+ {
|
|
|
+ spDbContext spDb = new spDbContext();
|
|
|
+
|
|
|
+ var lstItem = spDb.PerformanceItems.Where<PerformanceItem>(p =>
|
|
|
+ ((p.AgentFeedbackMemo != "已算绩效" || p.AgentFeedbackMemo==null ) && p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J")))
|
|
|
+ .Include(p=>p.Reviewer)
|
|
|
+ .Include(p=>p.CalMonth)
|
|
|
+ .ToList<PerformanceItem>();
|
|
|
+
|
|
|
+
|
|
|
+ if (lstItem != null)
|
|
|
+ {
|
|
|
+ int i = 0;
|
|
|
+ foreach (var Item in lstItem)
|
|
|
+ {
|
|
|
+
|
|
|
+ int iTryCount = 0;
|
|
|
+ TryAgain:
|
|
|
+ try
|
|
|
+ {
|
|
|
+ iTryCount++;
|
|
|
|
|
|
- //if (Item.FinishedDate.HasValue &&
|
|
|
- // Item.FinishedDate.Value.ToString("yyyy-MM") != DateTime.Parse($"{Item.CalMonth.Year}-{Item.CalMonth.Month}-01").ToString("yyyy-MM"))
|
|
|
- //{
|
|
|
- // //删除完成日变成下一个月的记录
|
|
|
- // var ItemStaffs = spDb.ItemStaffs.Where(p => p.ItemId == Item.Id).ToList();
|
|
|
- // foreach(var itemstaff in ItemStaffs)
|
|
|
- // {
|
|
|
- // spDb.Remove(itemstaff);
|
|
|
- // }
|
|
|
- // spDb.PerformanceItems.Remove(Item);
|
|
|
- // spDb.SaveChanges();
|
|
|
+ UpdateFromIPEasy(Item, spDb);
|
|
|
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- if (spDb.Entry(Item).State != EntityState.Unchanged)
|
|
|
- {
|
|
|
- Utility.Utility.CalBasePoint(Item, spDb.BasePointRules.ToList());
|
|
|
- spDb.SaveChanges();
|
|
|
- }
|
|
|
+ Log($"{DateTime.Now}\t{++i}\t{Item.CaseNo}");
|
|
|
+ System.Diagnostics.Debug.WriteLine($"{DateTime.Now}\t{i}\t{Item.CaseNo}");
|
|
|
//}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
@@ -227,11 +227,21 @@ namespace wispro.sp.api.Job
|
|
|
}
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine(ex.ToString());
|
|
|
+ Log($"{DateTime.Now}\t{++i}\t{Item.CaseNo}\r\n{ex.ToString()}");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
}
|
|
|
+
|
|
|
+ private void Log(string strMessage)
|
|
|
+ {
|
|
|
+ StreamWriter sw = File.AppendText("c:\\temp\\log.txt");
|
|
|
+ sw.Write($"{strMessage}\r\n");
|
|
|
+ sw.Flush();
|
|
|
+ sw.Close();
|
|
|
+ sw.Dispose();
|
|
|
+ }
|
|
|
}
|
|
|
}
|