瀏覽代碼

修正从IPEasy导入数据Bug
添加发邮件通知疑似数据缺失数据清单Job
添加发邮件带附件功能
数据同步修正为只同步案件系数和处理事项系数

luocaiyang 3 年之前
父節點
當前提交
79e6d1ee20

+ 294 - 56
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -398,13 +398,15 @@ namespace wispro.sp.api.Controllers
             return ret;
         }
 
-        public double DegreeOfDifficulty(int year,int month, int? userId = null)
+        
+        public NanduStatics DegreeOfDifficulty(CalMonth calMonth,int? userId = null)
         {
-            string strKey = $"DegreeOfDifficulty:{year}-{month}-{userId}";
+            NanduStatics retObj = new NanduStatics();
+
+            string strKey = $"DegreeOfDifficulty:{calMonth.Year}-{calMonth.Month}-{userId}";
             object cacheEntry;
             if (!MyMemoryCache.TryGetValue(strKey, out cacheEntry))
             {
-
                 IDictionary<string, double> CaseXiShu = new Dictionary<string, double>();
                 var list = Context.CaseCeoffcients;
 
@@ -413,13 +415,13 @@ namespace wispro.sp.api.Controllers
                     CaseXiShu.Add(cx.Ceoffcient, cx.Value);
                 }
 
-                var results = Context.PerformanceItems.Where<PerformanceItem>(p => p.CalMonth.Year == year && p.CalMonth.Month == month && ((p.Type == "新申请" && p.BasePoint > 0) || p.Type == "专案") && p.BasePoint > 0.0);
+                var results = Context.PerformanceItems.Where<PerformanceItem>(p => p.CalMonthId == calMonth.Id  && ((p.Type == "新申请" && p.BasePoint > 0) || p.Type == "专案") && p.BasePoint > 0.0);
 
                 if (userId != null)
                 {
                     results = Context.PerformanceItems.Where<PerformanceItem>(p =>
-                    p.CalMonth.Year == year && p.CalMonth.Month == month && ((p.Type == "新申请" && p.BasePoint > 0) || p.Type == "专案") &&
-                    (p.ItemStaffs.Where<ItemStaff>(s => s.DoPerson.Id == userId).Count() > 0 || p.ReviewerId == userId ) && p.BasePoint > 0.0);
+                    p.CalMonthId == calMonth.Id && ((p.Type == "新申请" && p.BasePoint > 0) || p.Type == "专案") &&
+                    (p.ItemStaffs.Where<ItemStaff>(s => s.DoPerson.Id == userId).Count() > 0 || p.ReviewerId == userId) && p.BasePoint > 0.0);
                 }
 
                 #region 循环计算
@@ -452,6 +454,25 @@ namespace wispro.sp.api.Controllers
                     }
                     #endregion
 
+                    switch (strCaseCeoffcient)
+                    {
+                        case "S":
+                            retObj.S += 1;
+                            break;
+                        case "A":
+                            retObj.A += 1;
+                            break;
+                        case "B":
+                            retObj.B += 1;
+                            break;
+                        case "C":
+                            retObj.C += 1;
+                            break;
+                        case "D":
+                            retObj.D += 1;
+                            break;
+                    }
+
                     if (CaseXiShu.ContainsKey(strCaseCeoffcient))
                     {
                         d += CaseXiShu[strCaseCeoffcient];
@@ -461,42 +482,18 @@ namespace wispro.sp.api.Controllers
                 }
                 #endregion
 
-                #region 统计计算
-                //var groupResult = results.GroupBy(x => x.CaseCoefficient).Select(g=> new { 
-                //    CaseCeoffcient = g.Key,
-                //    count = g.Count()
-                //});
-
-                //int iCount = 0;
-                //double d = 0.0;
-                //foreach(var g in groupResult)
-                //{
-                //    if (!string.IsNullOrEmpty(g.CaseCeoffcient))
-                //    {
-
-
-                //        if (CaseXiShu.ContainsKey(g.CaseCeoffcient))
-                //        {
-                //            d += g.count * CaseXiShu[g.CaseCeoffcient];
-                //            iCount += g.count;
-                //        }
-                //    }
-                //}
-                #endregion
-
-                cacheEntry = d / (double)iCount;
+                
 
-                // Set cache options.
+                retObj.NanduXS = d / (double)iCount;
                 
                 // Save data in cache.
-                MyMemoryCache.SetValue(strKey, cacheEntry);
-
-
-                return (double)cacheEntry;
+                MyMemoryCache.SetValue(strKey, retObj);
+                
+                return retObj;
             }
             else
             {
-                return (double)cacheEntry;
+                return (NanduStatics)cacheEntry;
             }
         }
 
@@ -511,11 +508,16 @@ namespace wispro.sp.api.Controllers
 
             return new List<string>();
         }
+
         private List<StaffStatistics> _CalMyStatistics(CalMonth calMonth, int? userid = null)
         {
-
-
-            double gspjXS = DegreeOfDifficulty(calMonth.Year, calMonth.Month);
+            NanduStatics gspjXS = DegreeOfDifficulty(calMonth);
+            calMonth.NanduXS = gspjXS.NanduXS;
+            calMonth.S = gspjXS.S;
+            calMonth.A = gspjXS.A;
+            calMonth.B = gspjXS.B;
+            calMonth.C = gspjXS.C;
+            calMonth.D = gspjXS.D;
 
             //未归档,从绩效记录中统计数据
             var results = Context.PerformanceItems.Where<PerformanceItem>(s => s.CalMonth.Id == calMonth.Id);
@@ -542,16 +544,13 @@ namespace wispro.sp.api.Controllers
             foreach (PerformanceItem item in ItemList)
             {
 
-
-
-
                 //if (item.BasePoint == null)
                 //{
 
                 if (item.AgentFeedbackMemo != "特殊点数申诉")
                 {
                     Utility.Utility.CalBasePoint(item, Rules);
-
+ 
                     Context.SaveChanges();
                 }
                 //}
@@ -594,24 +593,31 @@ namespace wispro.sp.api.Controllers
                 retList = retList.Where<StaffStatistics>(s => s.StaffId == userid.Value).ToList();
             }
 
-            IDictionary<int, double> staffXiShu = new Dictionary<int, double>();
+            IDictionary<int, NanduStatics> staffXiShu = new Dictionary<int, NanduStatics>();
             foreach (StaffStatistics ss in retList)
             {
                 if (ss.jxType.Contains("新申请") || ss.jxType.Contains("专案"))
                 {
                     if (!staffXiShu.ContainsKey(ss.StaffId))
                     {
-                        staffXiShu.Add(ss.StaffId, DegreeOfDifficulty(calMonth.Year, calMonth.Month, ss.StaffId));
+                        NanduStatics nandu = DegreeOfDifficulty(calMonth, ss.StaffId);
+                        staffXiShu.Add(ss.StaffId, nandu);
                     }
 
-                    ss.totalActuallyPoint = ss.totalBasePoint * staffXiShu[ss.StaffId] / gspjXS;
+                    ss.totalActuallyPoint = ss.totalBasePoint * staffXiShu[ss.StaffId].NanduXS / gspjXS.NanduXS;
+                    ss.NanduXS = staffXiShu[ss.StaffId].NanduXS;
+                    ss.S = staffXiShu[ss.StaffId].S;
+                    ss.A = staffXiShu[ss.StaffId].A;
+                    ss.B = staffXiShu[ss.StaffId].B;
+                    ss.C = staffXiShu[ss.StaffId].C;
+                    ss.D = staffXiShu[ss.StaffId].D;
                 }
                 else
                 {
                     ss.totalActuallyPoint = ss.totalBasePoint;
                 }
 
-                ss.CalMonth.PerformanceItems = null;
+                //ss.CalMonth.PerformanceItems = null;
             }
 
 
@@ -693,6 +699,191 @@ namespace wispro.sp.api.Controllers
             };
         }
 
+        private void Export2ExcelThread()
+        {
+            spDbContext spDb = new spDbContext();
+            List<PerformanceItem> items = spDb.PerformanceItems
+                .Include(p => p.Reviewer).ThenInclude(p => p.StaffGrade)
+                .Include(p=>p.PreOastaff)
+                .Include(p => p.Customer)
+                .Include(p => p.CalMonth)
+                .Include(p => p.ItemStaffs).ThenInclude(s => s.DoPerson).ThenInclude(s => s.StaffGrade)
+                .Where(p => p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J")).OrderBy(p => p.CaseNo).ThenBy(p => p.DoItem).ToList();
+
+            DataTable dt = new DataTable();
+            #region 栏位名称
+            dt.Columns.Add("我方文号",typeof(string));
+            dt.Columns.Add("申请类型", typeof(string));
+            dt.Columns.Add("业务类型", typeof(string));
+            dt.Columns.Add("备注(填表注意事项)", typeof(string));
+            dt.Columns.Add("处理事项", typeof(string));
+            dt.Columns.Add("案件阶段", typeof(string));
+            dt.Columns.Add("案件系数", typeof(string));
+            dt.Columns.Add("处理事项系数", typeof(string));
+            dt.Columns.Add("前一次OA处理事项系数", typeof(string));
+            dt.Columns.Add("前一次OA处理人", typeof(string));
+            dt.Columns.Add("处理人等级", typeof(string));
+            dt.Columns.Add("基本点数", typeof(string));
+            dt.Columns.Add("核稿系数", typeof(string));
+            dt.Columns.Add("核稿绩效", typeof(string));
+            dt.Columns.Add("处理人", typeof(string));
+            dt.Columns.Add("核稿人", typeof(string));
+            dt.Columns.Add("客户名称", typeof(string));
+            dt.Columns.Add("申请人", typeof(string));
+            dt.Columns.Add("处理事项完成日", typeof(string));
+            dt.Columns.Add("定稿日", typeof(string));
+            dt.Columns.Add("返稿日", typeof(string));
+            dt.Columns.Add("案件类型", typeof(string));
+            dt.Columns.Add("案件状态", typeof(string));
+            dt.Columns.Add("处理事项备注", typeof(string));
+            dt.Columns.Add("处理状态", typeof(string));
+            dt.Columns.Add("案件名称", typeof(string));
+            dt.Columns.Add("委案日期", typeof(string));
+            dt.Columns.Add("客户期限", typeof(string));
+            dt.Columns.Add("内部期限", typeof(string));
+            dt.Columns.Add("初稿日", typeof(string));
+            dt.Columns.Add("备注(发文严重超期是否属客观原因,若为否,请填写原因", typeof(string));
+            dt.Columns.Add("绩效类型", typeof(string));
+            dt.Columns.Add("案件备注", typeof(string));
+            dt.Columns.Add("处理人绩效系数", typeof(string));
+            dt.Columns.Add("系统核算绩效", typeof(string));
+            dt.Columns.Add("实际处理人", typeof(string));
+
+            #endregion
+
+            var verifyCeoffients = spDb.VerifyCoefficients.ToList();
+            var Rules = spDb.BasePointRules.ToList();
+
+            foreach(var p in items)
+            {
+                Utility.Utility.CalBasePoint(p, Rules);
+                var jxList = _calItemJX(p.CalMonth, verifyCeoffients, p, spDb);
+
+                bool isPJFP = true;
+                bool isReviewerInDopersons = false;
+                if (p.ReviewerId.HasValue)
+                {
+                    isReviewerInDopersons = (p.ItemStaffs.Where(i => i.DoPersonId == p.ReviewerId).Count() > 0);
+                }
+                
+                double total = p.ItemStaffs.Count();
+                if (p.ItemStaffs.Where<ItemStaff>(p => p.PerformancePoint != null || p.PerformancePoint == 0).Count() > 0)
+                {
+                    total = p.ItemStaffs.Select(i => i.PerformancePoint.Value).Sum();
+                    isPJFP = false;
+                }
+
+                foreach (var iStaff in p.ItemStaffs)
+                {
+                    DataRow row = dt.NewRow();
+                    row["我方文号"] = p.CaseNo;
+                    row["申请类型"] = p.ApplicationType;
+
+                    if(p.Customer.Name.Contains("OPPO") && p.ApplicationType == "实用新型")
+                    {
+                        row["申请类型"] = "发明";
+                        row["案件备注"] = $"{row["案件备注"]}\r\nOPPO案件实用新型修改为发明】";
+                    }
+
+                    row["业务类型"] = p.BusinessType;
+                    row["备注(填表注意事项)"] = p.AgentFeedbackMemo;
+                    row["处理事项"] = p.DoItem;
+                    row["案件阶段"] = p.CaseStage;
+                    
+                    row["案件系数"] = p.CaseCoefficient;
+                    if(p.isDanger() && string.IsNullOrEmpty(p.OverDueMemo))
+                    {
+                        switch (p.CaseCoefficient)
+                        {
+                            case "S":
+                                row["案件系数"] = "A";
+                                break;
+                            case "A":
+                                row["案件系数"] = "B";
+                                break;
+                            case "B":
+                                row["案件系数"] = "C";
+                                break;
+                            case "C":
+                                row["案件系数"] = "D";
+                                break;
+                        }
+
+                        row["案件备注"] = $"{row["案件备注"]}\r\n严重延期降系数【{p.CaseCoefficient}->{row["案件系数"]}】";
+                    }
+
+                    row["处理事项系数"] = p.DoItemCoefficient;
+                    row["前一次OA处理事项系数"] = "";
+                    row["前一次OA处理人"] = p.PreOastaff.Name;
+
+                    if(iStaff.DoPerson.Status == "试用期")
+                    {
+                        row["实际处理人"] = iStaff.DoPerson.Name;
+                        row["案件备注"] = $"{row["案件备注"]}\r\n处理人{iStaff.DoPerson.Name}未转正";
+                        row["处理人"] = p.Reviewer.Name;
+                        row["处理人等级"] = p.Reviewer.StaffGrade.Grade;
+                        row["基本点数"] = (p.BasePoint / total).ToString();
+                       
+                        row["核稿人"] = "";
+                        row["核稿系数"] = "";
+                        row["核稿绩效"] = "";
+                        row["处理人绩效系数"] = p.Reviewer.StaffGrade.Coefficient;
+                        row["系统核算绩效"] = "";
+                    }
+                    else
+                    {
+                        row["处理人"] = iStaff.DoPerson.Name;
+                        row["处理人等级"] = iStaff.DoPerson.StaffGrade.Grade;
+                        row["基本点数"] = (p.BasePoint / total).ToString();
+                        row["处理人绩效系数"] = iStaff.DoPerson.StaffGrade.Coefficient;
+                        row["系统核算绩效"] = "";
+
+                        if (isReviewerInDopersons)
+                        {
+                            row["核稿人"] = "";
+                            row["核稿系数"] = "";
+                            row["核稿绩效"] = "";
+                            row["处理人绩效系数"] = "";
+                            row["系统核算绩效"] = "";
+                            row["案件备注"] = $"{row["案件备注"]}\r\n核稿人与处理人一致,置空核稿人栏位";
+                        }
+                        else
+                        {
+                            row["核稿人"] = p.Reviewer?.Name;
+                            var vCoefficient = Context.VerifyCoefficients.FirstOrDefault(c => c.CheckerId == p.ReviewerId && c.DoPersonId == iStaff.DoPersonId);
+                            if (vCoefficient != null)
+                            {
+                                row["核稿系数"] = vCoefficient.Coefficient;
+                                row["核稿绩效"] = (p.BasePoint / total) * vCoefficient.Coefficient;
+                            }
+                        }
+                        
+                    }
+
+                    row["客户名称"] = p.Customer.Name;
+                    row["申请人"] = p.ApplicationName;
+                    row["处理事项完成日"] = p.FinishedDate?.ToString("yyyy-MM-dd");
+                    row["定稿日"] = p.FinalizationDate?.ToString("yyyy-MM-dd");
+                    row["返稿日"] = p.ReturnDate?.ToString("yyyy-MM-dd");
+                    row["案件类型"] = p.CaseType;
+                    row["案件状态"] = p.CaseState;
+                    row["处理事项备注"] = p.DoItemMemo;
+                    row["处理状态"] = p.DoItemState;
+                    row["案件名称"] = p.CaseName;
+                    row["委案日期"] = p.EntrustingDate?.ToString("yyyy-MM-dd");
+                    row["客户期限"] = p.CustomerLimitDate?.ToString("yyyy-MM-dd");
+                    row["内部期限"] = p.InternalDate?.ToString("yyyy-MM-dd");
+                    row["初稿日"] = p.FirstDraftDate?.ToString("yyyy-MM-dd");
+                    row["备注(发文严重超期是否属客观原因,若为否,请填写原因"] = p.OverDueMemo;
+                    row["绩效类型"] = p.Type;
+                    row["案件备注"] = p.CaseMemo;
+                    
+                    dt.Rows.Add(row);
+                }
+            }
+
+            NPOIExcel.DataTableToExcel(dt,$"c:\\temp\\{DateTime.Now.ToString("yyyyMMddhhmmss")}-线下绩效核算数据.xlsx");
+        }
 
         private void _CompareExcel2DB()
         {
@@ -1170,12 +1361,18 @@ namespace wispro.sp.api.Controllers
             
         }
 
+        public List<StaffStatistics> CalItemJX(int itemid)
+        {
+            var Item = Context.PerformanceItems.Include(p=>p.CalMonth).FirstOrDefault(p=>p.Id == itemid);
+            List<VerifyCoefficient> verifyCoefficients = Context.VerifyCoefficients.ToList<VerifyCoefficient>();
+            
+            return _calItemJX(Item.CalMonth,verifyCoefficients,Item,Context);
+
+        }
+
         private List<StaffStatistics> _calItemJX(CalMonth calMonth, List<VerifyCoefficient> verifyCoefficients, PerformanceItem item,spDbContext spDb)
         {
-            //if(item.CaseNo == "PACN2116373")
-            //{
-            //    System.Diagnostics.Debug.WriteLine("");
-            //}
+            
             System.Collections.Hashtable doPersonsBL = new System.Collections.Hashtable();
 
             bool isPJFP = true;
@@ -1204,7 +1401,8 @@ namespace wispro.sp.api.Controllers
                 //spDb.Entry(itemStaff.DoPerson).Reference(b => b.StaffGrade).Load();
 
                 #region 计算审核人绩效点数,核稿人绩效点数按照核稿人与个处理人的核稿系数计算后加总,没有找到核稿系数(比如同级别),核稿系数为0
-                if (item.ReviewerId != null && item.Type != "专案" && item.ItemStaffs.FirstOrDefault(s=>s.DoPersonId == item.ReviewerId) == null)
+                if (item.ReviewerId != null && item.Type != "专案" && 
+                    item.ItemStaffs.FirstOrDefault(s=>s.DoPersonId == item.ReviewerId) == null)
                 {
 
                     #region 取审核人等级审核等级系数
@@ -1262,7 +1460,21 @@ namespace wispro.sp.api.Controllers
                 }
                 else
                 {
-                    handlerBasePoint = itemStaff.PerformancePoint.Value;
+                    if (itemStaff.PerformancePoint == null)
+                    {
+                        if (isPJFP)
+                        {
+                            handlerBasePoint = item.BasePoint.Value * 1.0 / total;
+                        }
+                        else
+                        {
+                            handlerBasePoint = item.BasePoint.Value * itemStaff.PerformancePoint.Value / total;
+                        }
+                    }
+                    else
+                    {
+                        handlerBasePoint = itemStaff.PerformancePoint.Value;
+                    }
                 }
 
                 string handlerJxType = $"{item.Type}处理";
@@ -1342,12 +1554,13 @@ namespace wispro.sp.api.Controllers
 
             if (calMonth != null || calMonth.Status !=4)
             {
-                var retList = CalMyStatistics(year, month);
+                var retList = _CalMyStatistics(calMonth);
 
                 using (var t = Context.Database.BeginTransaction())
                 {
                     try
                     {
+                        Context.SaveChanges();
                         foreach (var obj in retList)
                         {
                             obj.CalMonthId = calMonth.Id;
@@ -1387,6 +1600,7 @@ namespace wispro.sp.api.Controllers
             }
 
         }
+
         /// <summary>
         /// 计算指定用户,指定年月的绩效统计信息
         /// </summary>
@@ -1423,7 +1637,18 @@ namespace wispro.sp.api.Controllers
                     }
                     else
                     {
-                        retList = _CalMyStatistics(calMonth, userid);
+                        try
+                        {
+                            retList = _CalMyStatistics(calMonth, userid);
+                        }
+                        catch(Exception ex)
+                        {
+                            StreamWriter sw = System.IO.File.AppendText("c:\\temp\\log.txt");
+                            sw.WriteLine($"{ex.Message}");
+                            sw.Flush();
+                            sw.Close();
+                            sw.Dispose();
+                        }
                     }
 
                     // Set cache options.
@@ -1431,15 +1656,28 @@ namespace wispro.sp.api.Controllers
                         // Keep in cache for this time, reset time if accessed.
                         .SetSlidingExpiration(TimeSpan.FromHours(1));
 
+                    foreach(var temObj in (List<StaffStatistics>)retList)
+                    {
+                        temObj.CalMonth.PerformanceItems = null;
+                    }
+
                     // Save data in cache.
                     MyMemoryCache.SetValue(strKey, retList);
 
+
+
                     return (List<StaffStatistics>)retList;
                 }
             }
             else
             {
-                return (List<StaffStatistics>)retList;
+                var temList = (List<StaffStatistics>)retList;
+                foreach (var temObj in temList)
+                {
+                    temObj.CalMonth.PerformanceItems = null;
+                }
+
+                return temList;
             }
            
         }

+ 10 - 4
wispro.sp.api/Job/ImportReportJob.cs

@@ -126,6 +126,9 @@ namespace wispro.sp.api.Job
         private void DownloadReport(string ReportName,CalMonth calMonth,bool isModifyDate,bool isFirstOA=false)
         {
             string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
+            string filename = $"{ReportName.Trim()}.xlsx";
+            string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
+            string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
 
             int tryCount = 0;
 
@@ -133,6 +136,11 @@ namespace wispro.sp.api.Job
             try
             {
                 wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, isModifyDate);
+
+                if (!System.IO.File.Exists(strFilePath))
+                {
+                    throw new ApplicationException("超时!");
+                }
             }
             catch {
                 tryCount++;
@@ -144,10 +152,8 @@ namespace wispro.sp.api.Job
             }
 
             System.Threading.Thread.Sleep(5000);
-            string filename = $"{ReportName.Trim()}.xlsx";
-            string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
-            string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
-            InputPerformanceItem(strFinalPath, true, false, 1, calMonth, isFirstOA);
+            
+            InputPerformanceItem(strFilePath, true, false, 1, calMonth, isFirstOA);
             System.IO.File.Move(strFilePath, strFinalPath);
         }
 

文件差異過大導致無法顯示
+ 75 - 0
wispro.sp.api/Job/InvalidDataMessageJob.cs


+ 2 - 1
wispro.sp.api/Job/MailJob.cs

@@ -15,7 +15,8 @@ namespace wispro.sp.api.Job
             string Body = context.JobDetail.JobDataMap.Get("Body").ToString();
             string To = context.JobDetail.JobDataMap.Get("To").ToString();
             string Reciver = context.JobDetail.JobDataMap.Get("Reciever").ToString();
-            utility.MailUtil.SendEmail(Subject,Body,Reciver,To);
+            string AttachFiles = context.JobDetail.JobDataMap.Get("AttachFiles")?.ToString();
+            utility.MailUtil.SendEmail(Subject,Body,Reciver,To,AttachFiles);
             return Task.CompletedTask;
         }
     }

+ 2 - 1
wispro.sp.api/Job/QuartzUtil.cs

@@ -53,7 +53,7 @@ namespace wispro.sp.api.Job
             await _scheduler.ScheduleJob(job, trigger);
         }
 
-        public static async Task AddMailJob(string Subject,string Body,string toName,string To)
+        public static async Task AddMailJob(string Subject,string Body,string toName,string To,string AttachFiles=null)
         {
             await Init();
 
@@ -69,6 +69,7 @@ namespace wispro.sp.api.Job
             job.JobDataMap.Put("Body", Body);
             job.JobDataMap.Put("To", To);
             job.JobDataMap.Put("Reciever", toName);
+            job.JobDataMap.Put("AttachFiles", AttachFiles);
 
             await _scheduler.ScheduleJob(job, trigger);
         }

+ 111 - 111
wispro.sp.api/Job/UpdateJXDataFromIPEasyJob.cs

@@ -24,92 +24,92 @@ namespace wispro.sp.api.Job
                 Item.DoItemCoefficient = retObj.DoItemCoefficient;
             }
 
-            if (keyValuePairs.ContainsKey("DoItemMemo") && Item.DoItemMemo != retObj.DoItemMemo && !string.IsNullOrEmpty(retObj.DoItemMemo))
-            {
-                Item.DoItemMemo = retObj.DoItemMemo;
-            }
+            //if (keyValuePairs.ContainsKey("DoItemMemo") && Item.DoItemMemo != retObj.DoItemMemo && !string.IsNullOrEmpty(retObj.DoItemMemo))
+            //{
+            //    Item.DoItemMemo = retObj.DoItemMemo;
+            //}
 
-            if (keyValuePairs.ContainsKey("DoItemState") && Item.DoItemState != retObj.DoItemState && !string.IsNullOrEmpty(retObj.DoItemState))
-            {
-                Item.DoItemState = retObj.DoItemState;
-            }
+            //if (keyValuePairs.ContainsKey("DoItemState") && Item.DoItemState != retObj.DoItemState && !string.IsNullOrEmpty(retObj.DoItemState))
+            //{
+            //    Item.DoItemState = retObj.DoItemState;
+            //}
 
-            if (keyValuePairs.ContainsKey("CustomerLimitDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.CustomerLimitDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.CustomerLimitDate);
+            //if (keyValuePairs.ContainsKey("CustomerLimitDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.CustomerLimitDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.CustomerLimitDate);
 
-                    if (date != Item.CustomerLimitDate)
-                        Item.CustomerLimitDate = date;
-                }
-            }
+            //        if (date != Item.CustomerLimitDate)
+            //            Item.CustomerLimitDate = date;
+            //    }
+            //}
 
-            if (keyValuePairs.ContainsKey("EntrustingDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.EntrustingDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.EntrustingDate);
+            //if (keyValuePairs.ContainsKey("EntrustingDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.EntrustingDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.EntrustingDate);
 
-                    if (date != Item.EntrustingDate)
-                        Item.EntrustingDate = date;
-                }
-            }
+            //        if (date != Item.EntrustingDate)
+            //            Item.EntrustingDate = date;
+            //    }
+            //}
 
-            if (keyValuePairs.ContainsKey("FinalizationDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.FinalizationDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.FinalizationDate);
+            //if (keyValuePairs.ContainsKey("FinalizationDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.FinalizationDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.FinalizationDate);
 
-                    if (date != Item.FinalizationDate)
-                        Item.FinalizationDate = date;
-                }
-            }
+            //        if (date != Item.FinalizationDate)
+            //            Item.FinalizationDate = date;
+            //    }
+            //}
 
-            if (keyValuePairs.ContainsKey("FinishedDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.FinishedDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.FinishedDate);
+            //if (keyValuePairs.ContainsKey("FinishedDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.FinishedDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.FinishedDate);
 
-                    if (date != Item.FinishedDate)
-                        Item.FinishedDate = date;
-                }
-            }
+            //        if (date != Item.FinishedDate)
+            //            Item.FinishedDate = date;
+            //    }
+            //}
 
-            if (keyValuePairs.ContainsKey("FirstDraftDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.FirstDraftDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.FirstDraftDate);
+            //if (keyValuePairs.ContainsKey("FirstDraftDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.FirstDraftDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.FirstDraftDate);
 
-                    if (date != Item.FirstDraftDate)
-                        Item.FirstDraftDate = date;
-                }
-            }
+            //        if (date != Item.FirstDraftDate)
+            //            Item.FirstDraftDate = date;
+            //    }
+            //}
 
-            if (keyValuePairs.ContainsKey("InternalDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.InternalDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.InternalDate);
+            //if (keyValuePairs.ContainsKey("InternalDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.InternalDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.InternalDate);
 
-                    if (date != Item.InternalDate)
-                        Item.InternalDate = date;
-                }
-            }
+            //        if (date != Item.InternalDate)
+            //            Item.InternalDate = date;
+            //    }
+            //}
 
-            if (keyValuePairs.ContainsKey("ReturnDate"))
-            {
-                if (!string.IsNullOrEmpty(retObj.ReturnDate))
-                {
-                    DateTime date = DateTime.Parse(retObj.ReturnDate);
+            //if (keyValuePairs.ContainsKey("ReturnDate"))
+            //{
+            //    if (!string.IsNullOrEmpty(retObj.ReturnDate))
+            //    {
+            //        DateTime date = DateTime.Parse(retObj.ReturnDate);
 
-                    if (date != Item.ReturnDate)
-                        Item.ReturnDate = date;
-                }
-            }
+            //        if (date != Item.ReturnDate)
+            //            Item.ReturnDate = date;
+            //    }
+            //}
 
             if (keyValuePairs.ContainsKey("WordCount"))
             {
@@ -123,34 +123,34 @@ namespace wispro.sp.api.Job
             }
 
 
-            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("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("ApplicationType") && Item.ApplicationType != retObj.ApplicationType && !string.IsNullOrEmpty(retObj.ApplicationType))
-            {
-                Item.ApplicationType = retObj.ApplicationType;
-            }
+            //if (keyValuePairs.ContainsKey("ApplicationType") && Item.ApplicationType != retObj.ApplicationType && !string.IsNullOrEmpty(retObj.ApplicationType))
+            //{
+            //    Item.ApplicationType = retObj.ApplicationType;
+            //}
 
-            if (keyValuePairs.ContainsKey("BusinessType") && Item.BusinessType != retObj.BusinessType && !string.IsNullOrEmpty(retObj.BusinessType))
-            {
-                Item.BusinessType = retObj.BusinessType;
-            }
+            //if (keyValuePairs.ContainsKey("BusinessType") && Item.BusinessType != retObj.BusinessType && !string.IsNullOrEmpty(retObj.BusinessType))
+            //{
+            //    Item.BusinessType = retObj.BusinessType;
+            //}
 
             if (keyValuePairs.ContainsKey("CaseCoefficient") && Item.CaseCoefficient != retObj.CaseCoefficient && !string.IsNullOrEmpty(retObj.CaseCoefficient))
             {
@@ -165,20 +165,20 @@ namespace wispro.sp.api.Job
             //    Item.CaseMemo = retObj.CaseMemo;
             //}
 
-            if (keyValuePairs.ContainsKey("CaseStage") && Item.CaseStage != retObj.CaseStage && !string.IsNullOrEmpty(retObj.CaseStage))
-            {
-                Item.CaseStage = retObj.CaseStage;
-            }
+            //if (keyValuePairs.ContainsKey("CaseStage") && Item.CaseStage != retObj.CaseStage && !string.IsNullOrEmpty(retObj.CaseStage))
+            //{
+            //    Item.CaseStage = retObj.CaseStage;
+            //}
 
-            if (keyValuePairs.ContainsKey("CaseState") && Item.CaseState != retObj.CaseState && !string.IsNullOrEmpty(retObj.CaseState))
-            {
-                Item.CaseState = retObj.CaseState;
-            }
+            //if (keyValuePairs.ContainsKey("CaseState") && Item.CaseState != retObj.CaseState && !string.IsNullOrEmpty(retObj.CaseState))
+            //{
+            //    Item.CaseState = retObj.CaseState;
+            //}
 
-            if (keyValuePairs.ContainsKey("CaseType") && Item.CaseType != retObj.CaseType && !string.IsNullOrEmpty(retObj.CaseType))
-            {
-                Item.CaseType = retObj.CaseType;
-            }
+            //if (keyValuePairs.ContainsKey("CaseType") && Item.CaseType != retObj.CaseType && !string.IsNullOrEmpty(retObj.CaseType))
+            //{
+            //    Item.CaseType = retObj.CaseType;
+            //}
 
             if (spDb.Entry(Item).State != EntityState.Unchanged)
             {
@@ -287,8 +287,8 @@ namespace wispro.sp.api.Job
 
                         UpdateFromIPEasy(Item, spDb);
 
-                        Log($"{DateTime.Now}\t{++i}\t{Item.CaseNo}");
-                        System.Diagnostics.Debug.WriteLine($"{DateTime.Now}\t{i}\t{Item.CaseNo}");
+                        Log($"{DateTime.Now}\t{++i}/{lstItem.Count}\t{Item.CaseNo}");
+                        System.Diagnostics.Debug.WriteLine($"{DateTime.Now}\t{i}/{lstItem.Count}\t{Item.CaseNo}");
                         //}
                     }
                     catch(Exception ex)

+ 9 - 0
wispro.sp.api/Program.cs

@@ -63,7 +63,16 @@ namespace wispro.sp.api
 
             _ = QuartzUtil.Add(typeof(UpdateJXDataFromIPEasyJob), jobKey1, trigger1);
             #endregion
+            #region 疑似绩效数据通知
+            JobKey jobKey2 = new JobKey("InvalidData");
+            var trigger2 = TriggerBuilder.Create()
+                .WithDescription("疑似绩效数据通知")
+                .WithSchedule(CronScheduleBuilder.CronSchedule(utility.ConfigHelper.GetSectionValue("InvalidDataScheduleSetting")).WithMisfireHandlingInstructionDoNothing())
+                .Build();
+
 
+            _ = QuartzUtil.Add(typeof(InvalidDataMessageJob), jobKey2, trigger2);
+            #endregion
 
             host.Run();
         }

+ 10 - 9
wispro.sp.api/appsettings.json

@@ -11,7 +11,8 @@
     "DefaultConnect": "Data Source=(local);Initial Catalog=spDB;User ID=sa;Password=Lqftiu807005"
   },
 
-  "UpdateScheduleSetting": "00 03 09 *, * ? *",
+  "UpdateScheduleSetting": "00 10 09 * * ? *",
+  "InvalidDataScheduleSetting": "00 58 17 * * ? *",
 
   "ValidAudience": "StaffPerformance",
   "ValidIssuer": "http://localhost:39476",
@@ -28,7 +29,7 @@
     "Account": "caiyangl",
     "Password": "j)wx*lier*@3",
     "ChormeDriverPath": "D:\\source\\repos\\StaffPerformance\\packages\\ChormeDriver\\97.0.4692.71",
-    "ScheduleSetting": "00 22 14 * * ? *",
+    "ScheduleSetting": "00 22 15 * * ? *",
     "IPEasyWeb": "http://47.106.221.167/Login.aspx"
   },
 
@@ -41,13 +42,13 @@
   },
 
   "Authorize": {
-    "/Department": "[94]-[1],[128]-[7]",
-    "/Workflow/Manage": "[94]-[1]",
-    "/CaseManager": "[94]-[1],[128]-[7]",
-    "/Project/ProjectSearch": "[94]-[1],[128]-[7]",
-    "/AppealRecords": "[94]-[1],[128]-[7]",
-    "/CustomerList": "[94]-[1],[128]-[7]",
-    "/StaffGrade": "[94]-[1],[128]-[7]"
+    "/Department": "[94]-[1],[128]-[7],[44]-[5]",
+    "/Workflow/Manage": "[94]-[1],[44]-[5]",
+    "/CaseManager": "[94]-[1],[128]-[7],[44]-[5]",
+    "/Project/ProjectSearch": "[94]-[1],[128]-[7],[44]-[5]",
+    "/AppealRecords": "[94]-[1],[128]-[7],[44]-[5]",
+    "/CustomerList": "[94]-[1],[128]-[7],[44]-[5]",
+    "/StaffGrade": "[94]-[1],[128]-[7],[44]-[5]"
   },
 
   "Lastest_feedback_date": "8"

+ 1 - 1
wispro.sp.api/spDbContext.cs

@@ -99,7 +99,7 @@ namespace wispro.sp.api
                 //ConfigurationManager.AppSettings["ValidAudience"]
             }
 
-            //_ = optionsBuilder.UseLoggerFactory(LoggerFactory);
+            _ = optionsBuilder.UseLoggerFactory(LoggerFactory);
         }
 
         protected override void OnModelCreating(ModelBuilder modelBuilder)

+ 18 - 0
wispro.sp.share/NanduStatics.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.share
+{
+    public class NanduStatics
+    {
+        public double NanduXS { get; set; }
+        public int S { get; set; }
+        public int A { get; set; }
+        public int B { get; set; }
+        public int C { get; set; }
+        public int D { get; set; }
+    }
+}

+ 10 - 3
wispro.sp.utility/IPEasyUtility.cs

@@ -157,8 +157,8 @@ namespace wispro.sp.utility
                     
                     startDate.Click();
                     System.Threading.Thread.Sleep(500);
-
-                    startDate.SendKeys($"{DateTime.Now.AddMonths(-1).Year }-{DateTime.Now.AddMonths(-1).Month}-01");
+                    
+                    startDate.SendKeys(new DateTime(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month, 1).ToString("yyyy-MM-dd"));
 
                     var endDate = driver.FindElement(By.XPath("//input[contains(@id,'dt_e_')]"));//.Id("dt_e_4F8FE88D-9040-45F1-9723-45699BCD4CAF"));
                     endDate.Click();
@@ -187,7 +187,7 @@ namespace wispro.sp.utility
 
                 string strFilePath = System.IO.Path.Combine(strFileSavePath, $"{ReportName.Trim()}.xlsx");
 
-
+                int iwaiting = 0;
                 while (true)
                 {
 
@@ -195,6 +195,13 @@ namespace wispro.sp.utility
                     if (!file.Exists || file.Length == 0)
                     {
                         System.Threading.Thread.Sleep(5000);
+
+                        iwaiting += 5000;
+
+                        if(iwaiting > 360000)
+                        {
+                            break;
+                        }
                     }
                     else
                     {

+ 20 - 1
wispro.sp.utility/MailUtil.cs

@@ -12,7 +12,7 @@ namespace wispro.sp.utility
 {
     public class MailUtil
     {
-        public static void SendEmail(string subject, string body,string toMailName, string toEmail)
+        public static void SendEmail(string subject, string body,string toMailName, string toEmail,string AttachFiles=null)
         {
             MimeMessage message = new MimeMessage();
             string strMail = ConfigHelper.GetSectionValue("MailSetting:mail");
@@ -20,10 +20,29 @@ namespace wispro.sp.utility
             message.From.Add(from);
             MailboxAddress to = new MailboxAddress(toMailName, toEmail);
             message.To.Add(to);
+            
             message.Subject = subject;
+            
 
             BodyBuilder bodyBuilder = new BodyBuilder();
             bodyBuilder.HtmlBody = body;
+
+            if (!string.IsNullOrEmpty(AttachFiles))
+            {
+                var files = AttachFiles.Split(';');
+
+                foreach(var file in files)
+                {
+                    if (!string.IsNullOrEmpty(file.Trim()))
+                    {
+                        if (System.IO.File.Exists(file))
+                        {
+                            bodyBuilder.Attachments.Add(file);
+                        }
+                    }
+                }
+            }
+
             message.Body = bodyBuilder.ToMessageBody();
 
             SmtpClient client = new SmtpClient();

+ 5 - 0
wispro.sp.web/Pages/AppCase/CaseManager.razor.cs

@@ -138,5 +138,10 @@ namespace wispro.sp.web.Pages.AppCase
             item = await _ItemService.RefreshItem(item.Id);
             StateHasChanged();
         }
+
+        async Task<string> CalItemJX(PerformanceItem item)
+        {
+            return null;
+        }
     }
 }

+ 9 - 2
wispro.sp.web/Services/PerformanceItemServices.cs

@@ -329,8 +329,15 @@ namespace wispro.sp.web.Services
             return data;
         }
 
-        
+        public async Task<List<StaffStatistics>> CalItemStatistics(int ItemId)
+        {
+            var data = await _httpClient.Get<List<StaffStatistics>>($"PerformanceItem/CalItemJX?itemid={ItemId}");
+            return data;
+        }
+
+
+
+
 
-       
     }
 }

+ 12 - 2
wispro.sp.winClient/Form1.cs

@@ -188,7 +188,8 @@ namespace wispro.sp.winClient
        
         private async void button3_Click(object sender, EventArgs e)
         {
-            await Compare2DB();
+           await GetTest();
+            //await Compare2DB();
             //await RefreshPerformanceItem(1);
 
             //await RefreshPerformanceItem(2);
@@ -769,9 +770,18 @@ namespace wispro.sp.winClient
             return retStr;
         }
 
-        string strAPIBaseUri = "http://localhost:39476";// "https://47.106.221.167"; //
+        string strAPIBaseUri = "https://47.106.221.167"; //"http://localhost:39476";// 
 
         userToken Token;
+
+        public async Task GetTest()
+        {
+            await Login();
+            var strUrl = "https://47.106.221.167/api/PerformanceItem/CalMyStatistics?userid=98&year=2021&month=12";
+            var response =await CreateHttp().GetFromJsonAsync<List<StaffStatistics>>(strUrl);
+
+            
+        }
         public async Task Login()
         {
             share.webViewObject.loginDto dto = new share.webViewObject.loginDto();

+ 10 - 0
wospro.sp.entity/CalMonth.cs

@@ -32,6 +32,16 @@ namespace wispro.sp.entity
         /// </summary>
         public int Status { get; set; }
 
+        public double? NanduXS { get; set; }
+
+        public int? S { get; set; }
+        public int? A { get; set; }
+
+        public int? B { get; set; }
+
+        public int? C { get; set; }
+        public int? D { get; set; }
+
         public virtual List<PerformanceItem> PerformanceItems { get; set; }
     }
 }

+ 1 - 1
wospro.sp.entity/PerformanceItem.cs

@@ -160,7 +160,7 @@ namespace wispro.sp.entity
         public int? Status { get; set; }
 
         /// <summary>
-        /// 案件状态
+        /// 案件备注
         /// </summary>
         public string CaseMemo { get; set; }
 

+ 10 - 0
wospro.sp.entity/StaffStatistics.cs

@@ -47,5 +47,15 @@ namespace wispro.sp.entity
         /// 难度系数调整后点数统计
         /// </summary>
         public double? totalActuallyPoint { get; set; }
+
+        public double? NanduXS { get; set; }
+
+        public int? S { get; set; }
+        public int? A { get; set; }
+
+        public int? B { get; set; }
+
+        public int? C { get; set; }
+        public int? D { get; set; }
     }
 }