Ver código fonte

添加等级计算模块
添加每天更新专案信息Job

luocaiyang 3 anos atrás
pai
commit
719a40c209

+ 522 - 6
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -970,9 +970,9 @@ namespace wispro.sp.api.Controllers
 
         public void RefreshPoint(PerformanceItem item)
         {
-            spDbContext spDb = new spDbContext();
+            //spDbContext spDb = new spDbContext();
 
-            var rules = spDb.BasePointRules.ToList();
+            var rules = Context.BasePointRules.ToList();
 
             if (item.AgentFeedbackMemo != "特殊点数申诉")
             {
@@ -981,7 +981,7 @@ namespace wispro.sp.api.Controllers
 
                 if (item.BasePoint > 0)
                 {
-                    _calItemJX(item, spDb);
+                    _calItemJX(item, Context);
                 }
                 else
                 {
@@ -989,7 +989,7 @@ namespace wispro.sp.api.Controllers
                     Context.StaffStatistics.RemoveRange(oldJxList);
                 }
 
-                spDb.SaveChanges();
+                Context.SaveChanges();
             }
 
         }
@@ -2213,6 +2213,15 @@ namespace wispro.sp.api.Controllers
 
                         calMonth.Status = 4;
                         Context.SaveChanges();
+
+                        StatisticsCount(calMonth.Id); //等级核算案件统计
+
+                        #region 将待审核的申诉全部修改为已审核
+                        var aList = Context.AppealRecords.Where(a => a.State == 0).ToList();
+                        aList.ForEach(a =>a.State = 1);
+                        Context.SaveChanges();
+                        #endregion
+
                         t.Commit();
                         return new ApiSaveResponse()
                         {
@@ -2838,8 +2847,8 @@ namespace wispro.sp.api.Controllers
 
                     if (temObj.CustomerLimitDate != null)
                     {
-                        if (!string.IsNullOrEmpty(temObj.InternalDate.ToString()))
-                            retObj.CustomerLimitDate = DateTime.Parse(temObj.InternalDate.ToString());
+                        if (!string.IsNullOrEmpty(temObj.CustomerLimitDate.ToString()))
+                            retObj.CustomerLimitDate = DateTime.Parse(temObj.CustomerLimitDate.ToString());
                     }
 
 
@@ -2984,5 +2993,512 @@ namespace wispro.sp.api.Controllers
 
             return true;
         }
+
+        #region 等级考核计算
+        /// <summary>
+        /// 等级考核案件量统计
+        /// </summary>
+        /// <param name="calMonthId"></param>
+        /// <returns></returns>
+        private List<StaffStatisticsforLevel> StatisticsCount(int calMonthId)
+        {
+            var retlist = new List<StaffStatisticsforLevel>();
+
+            #region 新申请
+            var newList = Context.PerformanceItems.Include(p => p.ItemStaffs)
+                .Where(p=>p.CalMonthId == calMonthId && p.BasePoint >0
+                    && (p.Type =="新申请" || p.Type =="专案" || (p.Type == "其它" && p.WordCount >0 && (p.DoItem =="新申请" || p.DoItem == "翻译")))
+                ).ToList();
+
+            foreach(var p in newList)
+            {
+                var pointList = Context.StaffStatistics.Include(i=>i.Staff).Where(i=>i.ItemId == p.Id).ToList();
+
+                #region 新申请处理
+                var doList = pointList.Where(i => i.jxType.Contains("处理"));
+                foreach(var h in doList)
+                {
+                    var temObj = retlist.FirstOrDefault(s=>s.StaffId == h.StaffId && s.Type == "新申请" && s.isReview == false);
+                    if(temObj == null)
+                    {
+                        temObj = new StaffStatisticsforLevel();
+                        temObj.StaffId = h.StaffId;
+                        
+                        temObj.GradeId = h.Staff.StaffGradeId.Value ;
+
+                        if(temObj.GradeId == 0)
+                        {
+                            System.Diagnostics.Debug.WriteLine("");
+                        }
+
+                        temObj.CalMonthId = p.CalMonthId;
+                        temObj.Type = "新申请";
+                        retlist.Add(temObj);
+                    }
+
+                    switch (p.CaseCoefficient)
+                    {
+                        case "S":
+                            if(p.Type == "专案")
+                            {
+                                temObj.S += h.totalBasePoint.Value;
+                            }
+                            else
+                            {
+                                temObj.S+=(double)(1.0M/ (decimal)doList.Count());
+                            }
+                            break;
+                        case "A":
+                            if (p.Type == "专案")
+                            {
+                                temObj.A += h.totalBasePoint.Value;
+                            }
+                            else
+                            {
+                                temObj.A += (double)(1.0M / (decimal)doList.Count());
+                            }
+                            break;
+                        case "B":
+                            if (p.Type == "专案")
+                            {
+                                temObj.B += h.totalBasePoint.Value;
+                            }
+                            else
+                            {
+                                temObj.B += (double)(1.0M / (decimal)doList.Count());
+                            }
+                            break;
+                        case "C":
+                            if (p.Type == "专案")
+                            {
+                                temObj.C += h.totalBasePoint.Value;
+                            }
+                            else
+                            {
+                                temObj.C += (double)(1.0M / (decimal)doList.Count());
+                            }
+                            break;
+                        case "D":
+                            if (p.Type == "专案")
+                            {
+                                temObj.D += h.totalBasePoint.Value;
+                            }
+                            else
+                            {
+                                temObj.D += (double)(1.0M / (decimal)doList.Count());
+                            }
+                            break;
+                    }
+                    
+                }
+                #endregion
+
+                #region 新申请审核
+                var reviewer = pointList.FirstOrDefault(i => i.jxType.Contains("审核"));
+                if(reviewer != null)
+                {
+                    var temObj = retlist.FirstOrDefault(s => s.StaffId == reviewer.StaffId && s.Type == "新申请" && s.isReview == true);
+
+                    if(temObj == null)
+                    {
+                        temObj = new StaffStatisticsforLevel();
+                        temObj.StaffId = reviewer.StaffId;
+                        temObj.GradeId = reviewer.Staff.StaffGradeId.Value;
+
+                        if (temObj.GradeId == 0)
+                        {
+                            System.Diagnostics.Debug.WriteLine("");
+                        }
+                        temObj.CalMonthId = p.CalMonthId;
+                        temObj.Type = "新申请";
+                        temObj.isReview = true;
+                        retlist.Add(temObj);
+                    }
+
+                    switch (p.CaseCoefficient)
+                    {
+                        case "S":
+                            temObj.S += 1;
+                            break;
+                        case "A":
+                            temObj.A += 1;
+                            break;
+                        case "B":
+                            temObj.B += 1;
+                            break;
+                        case "C":
+                            temObj.D += 1;
+                            break;
+                        case "D":
+                            temObj.D += 1;
+                            break;
+                    }
+                }
+                #endregion
+            }
+            #endregion
+
+            #region 国内OA
+            var cnOA = Context.PerformanceItems.Include(x=>x.ItemStaffs)
+                .Where(x => x.CalMonthId == calMonthId && x.Type == "OA" && x.CaseNo.Contains("CN") && x.BasePoint > 0
+                && (x.CaseStage == "一通" || x.DoItemCoefficient.Contains("首次转入"))).ToList();
+
+            foreach(var p in cnOA)
+            {
+                var pointList = Context.StaffStatistics.Include(i => i.Staff).Where(i=> i.ItemId == p.Id).ToList();
+
+                #region 国内OA处理
+                var doList = pointList.Where(i => i.jxType.Contains("处理"));
+                foreach (var h in doList)
+                {
+                    var temObj = retlist.FirstOrDefault(s => s.StaffId == h.StaffId && s.Type == "国内OA" && s.isReview == false);
+                    if (temObj == null)
+                    {
+                        temObj = new StaffStatisticsforLevel();
+                        temObj.StaffId = h.StaffId;
+                        temObj.GradeId = h.Staff.StaffGradeId.Value ;
+                        if (temObj.GradeId == 0)
+                        {
+                            System.Diagnostics.Debug.WriteLine("");
+                        }
+                        temObj.CalMonthId = p.CalMonthId;
+                        temObj.Type = "国内OA";
+                        retlist.Add(temObj);
+                    }
+
+                    switch (p.CaseCoefficient)
+                    {
+                        case "S":
+                            temObj.S += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "A":
+                            temObj.A += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "B":
+                            temObj.B += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "C":
+                            temObj.C += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "D":
+                            temObj.D += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                    }
+
+                }
+                #endregion
+
+                #region 国内OA审核
+                var reviewer = pointList.FirstOrDefault(i => i.jxType.Contains("审核"));
+                if (reviewer != null)
+                {
+                    var temObj = retlist.FirstOrDefault(s => s.StaffId == reviewer.StaffId && s.Type == "国内OA" && s.isReview == true);
+
+                    if (temObj == null)
+                    {
+                        temObj = new StaffStatisticsforLevel();
+                        temObj.StaffId = reviewer.StaffId;
+                        temObj.GradeId = reviewer.Staff.StaffGradeId.Value;
+                        if (temObj.GradeId == 0)
+                        {
+                            System.Diagnostics.Debug.WriteLine("");
+                        }
+                        temObj.CalMonthId = p.CalMonthId;
+                        temObj.Type = "国内OA";
+                        temObj.isReview = true;
+
+                        retlist.Add(temObj);
+                    }
+
+                    switch (p.CaseCoefficient)
+                    {
+                        case "S":
+                            temObj.S += 1;
+                            break;
+                        case "A":
+                            temObj.A += 1;
+                            break;
+                        case "B":
+                            temObj.B += 1;
+                            break;
+                        case "C":
+                            temObj.D += 1;
+                            break;
+                        case "D":
+                            temObj.D += 1;
+                            break;
+                    }
+                }
+                #endregion
+            }
+            #endregion
+
+            #region 涉外OA
+            var gwOA = Context.PerformanceItems.Include(x => x.ItemStaffs)
+                .Where(x => x.CalMonthId == calMonthId && x.Type == "OA" && !x.CaseNo.Contains("CN") && x.BasePoint>0
+                && (x.DoItemCoefficient.Contains("实质"))).ToList();
+
+            foreach (var p in gwOA)
+            {
+                var pointList = Context.StaffStatistics.Include(i => i.Staff).Where(i => i.ItemId == p.Id).ToList();
+
+                #region 涉外OA处理
+                var doList = pointList.Where(i => i.jxType.Contains("处理"));
+                foreach (var h in doList)
+                {
+                    var temObj = retlist.FirstOrDefault(s => s.StaffId == h.StaffId && s.Type == "涉外OA" && s.isReview == false);
+                    if (temObj == null)
+                    {
+                        temObj = new StaffStatisticsforLevel();
+                        temObj.StaffId = h.StaffId;
+                        temObj.GradeId = h.Staff.StaffGradeId.Value;
+                        if (temObj.GradeId == 0)
+                        {
+                            System.Diagnostics.Debug.WriteLine("");
+                        }
+                        temObj.CalMonthId = p.CalMonthId;
+                        temObj.Type = "涉外OA";
+                        retlist.Add(temObj);
+                    }
+
+                    switch (p.CaseCoefficient)
+                    {
+                        case "S":
+                            temObj.S += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "A":
+                            temObj.A += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "B":
+                            temObj.B += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "C":
+                            temObj.C += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                        case "D":
+                            temObj.D += (double)(1.0M / (decimal)doList.Count());
+                            break;
+                    }
+
+                }
+                #endregion
+
+                #region 涉外OA审核
+                var reviewer = pointList.FirstOrDefault(i => i.jxType.Contains("审核"));
+                if (reviewer != null)
+                {
+                    var temObj = retlist.FirstOrDefault(s => s.StaffId == reviewer.StaffId && s.Type == "涉外OA" && s.isReview == true);
+
+                    if (temObj == null)
+                    {
+                        temObj = new StaffStatisticsforLevel();
+                        temObj.StaffId = reviewer.StaffId;
+                        temObj.GradeId = reviewer.Staff.StaffGradeId.Value;
+                        if (temObj.GradeId == 0)
+                        {
+                            System.Diagnostics.Debug.WriteLine("");
+                        }
+                        temObj.CalMonthId = calMonthId;
+                        temObj.Type = "涉外OA";
+                        temObj.isReview = true;
+
+                        retlist.Add(temObj);
+                    }
+
+                    switch (p.CaseCoefficient)
+                    {
+                        case "S":
+                            temObj.S += 1;
+                            break;
+                        case "A":
+                            temObj.A += 1;
+                            break;
+                        case "B":
+                            temObj.B += 1;
+                            break;
+                        case "C":
+                            temObj.D += 1;
+                            break;
+                        case "D":
+                            temObj.D += 1;
+                            break;
+                    }
+                }
+                #endregion
+            }
+            #endregion
+
+            return retlist;
+        }
+
+        /// <summary>
+        /// 指定等级人员等级考核案件量统计汇总
+        /// </summary>
+        /// <param name="levelCaseCounts"></param>
+        /// <param name="GradeCode"></param>
+        /// <param name="calReviw"></param>
+        /// <returns></returns>
+        private LevelStatisticsResult CalLevelStatistics(List<StaffStatisticsforLevel> levelCaseCounts,string GradeCode,bool calReviw)
+        {
+            var retList = new List<LevelStatistics>();
+            
+            var temList = levelCaseCounts.Where(x=>x.Grade.Grade.StartsWith(GradeCode)).ToList();
+
+            foreach (var s in temList)
+            {
+                var temObj = retList.FirstOrDefault(i=>i.StaffId == s.StaffId);
+
+                if(temObj == null)
+                {
+                    temObj = new LevelStatistics();
+                    temObj.StaffId = s.StaffId;
+                    temObj.StaffName = s.Staff.Name;
+                    temObj.Grade = s.Grade.Grade;
+                    //var Department = Context.DepartmentPositions.FirstOrDefault(x => x.StaffId == s.StaffId);
+                    temObj.Department = Context.DepartmentPositions.Include(x => x.department).FirstOrDefault(x => x.StaffId == s.StaffId)?.department.Name;
+                    
+                    retList.Add(temObj);
+                }
+
+                if (!s.isReview)
+                {
+                    if(s.Type == "国内OA")
+                    {
+                        temObj.dS += (double)((decimal)s.S / 2M);
+                        temObj.dA += (double)((decimal)s.A / 2M);
+                        temObj.dB += (double)((decimal)s.B / 2M);
+                        temObj.dC += (double)((decimal)s.C / 2M);
+                        temObj.dD += (double)((decimal)s.D / 2M);
+                    }
+                    else
+                    {
+                        temObj.dS += s.S;
+                        temObj.dA += s.A;
+                        temObj.dB += s.B;
+                        temObj.dC += s.C;
+                        temObj.dD += s.D;
+                    }
+                }
+                else
+                {
+                    if (calReviw)
+                    {
+                        if (s.Type == "国内OA")
+                        {
+                            temObj.vS += (double)((decimal)s.S / 2M);
+                            temObj.vA += (double)((decimal)s.A / 2M);
+                            temObj.vB += (double)((decimal)s.B / 2M);
+                            temObj.vC += (double)((decimal)s.C / 2M);
+                            temObj.vD += (double)((decimal)s.D / 2M);
+                        }
+                        else
+                        {
+                            temObj.vS += s.S;
+                            temObj.vA += s.A;
+                            temObj.vB += s.B;
+                            temObj.vC += s.C;
+                            temObj.vD += s.D;
+                        }
+                    }
+                }
+            }
+
+            return new LevelStatisticsResult() {Grade =GradeCode ,  Statistics = retList};
+
+        }
+
+        /// /// <summary>
+        /// 获取季度等级考核结果
+        /// </summary>
+        /// <param name="year">考核年度</param>
+        /// <param name="quarter">考核季度,取值为1、2、3、4</param>
+        /// <param name="GradeCode">等级</param>
+        /// <returns></returns>
+        public LevelStatisticsResult CalAgentLevel(int year,int quarter,string GradeCode)
+        {
+            LevelStatisticsResult result = new LevelStatisticsResult();
+
+            var Months = new List<int>() { 1,2,3};
+            switch (quarter)
+            {
+                case 1:
+                    Months = new List<int>() { 1, 2, 3 };
+                    break;
+                case 2:
+                    Months = new List<int>() { 4,5,6 };
+                    break;
+                case 3:
+                    Months = new List<int>() { 7,8,9};
+                    break;
+                case 4:
+                    Months = new List<int>() { 10,11,12 };
+                    break;
+            }
+
+            //var mList = Context.CalMonths.Where(c=>c.Year == year && Months.Contains(c.Month)).ToList();
+            //foreach (var m in mList)
+            //{
+            //    StatisticsLevelCount(m.Id);
+            //}
+            var resp = Context.StaffStatisticsforLevels
+                .Include(p => p.Staff)
+                .Include(p => p.Grade)
+                .Where(p => Months.Contains(p.CalMonth.Month) && p.CalMonth.Year == year);
+            var temtList = resp.ToList();
+
+            bool isReview = (GradeCode == "A");
+            result = CalLevelStatistics(temtList, GradeCode, isReview);
+
+            if (!isReview)
+            {
+                string UpgradCode = "A";
+                switch (GradeCode)
+                {
+                    case "B":
+                        UpgradCode = "A";
+                        break;
+                    case "C":
+                        UpgradCode = "B";
+                        break;
+                    case "D":
+                        UpgradCode = "C";
+                        break;
+                }
+
+                var temResult = CalLevelStatistics(temtList, UpgradCode, isReview);
+                result.UpgradeBase = temResult.doAverage();
+            }
+
+            var temAverage= result.pAverage(result.Statistics[0].StaffId);
+            return result;
+        }
+
+        /// <summary>
+        /// 重新统计指定月份的人员案件数量
+        /// </summary>
+        /// <param name="year"></param>
+        /// <param name="month"></param>
+        public bool StatisticsLevelCount(int year,int month)
+        {
+            try
+            {
+                var temObj = Context.CalMonths.FirstOrDefault(l => l.Year == year && l.Month == month);
+
+                if (temObj != null)
+                {
+                    var temList = Context.StaffStatisticsforLevels.Where(l => l.CalMonthId == temObj.Id);
+                    Context.StaffStatisticsforLevels.RemoveRange(temList);
+
+                    var NewList = StatisticsCount(temObj.Id);
+
+                    Context.StaffStatisticsforLevels.AddRange(NewList);
+                    Context.SaveChanges();
+                }
+
+                return true;
+            }
+            catch { return false; }
+        }
+        #endregion
     }
 }

+ 433 - 0
wispro.sp.api/Job/ImportProjectInfoJob.cs

@@ -0,0 +1,433 @@
+using Microsoft.Data.SqlClient;
+using Quartz;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+using wispro.sp.utility;
+using System.Linq;
+
+namespace wispro.sp.api.Job
+{
+    public class ImportProjectInfoJob : Quartz.IJob
+    {
+        public Task Execute(IJobExecutionContext context)
+        {
+            DownloadProject_SQL();
+            return Task.CompletedTask;
+        }
+
+        private void DownloadProject_SQL()
+        {
+            
+            List<PerformanceItem> pfItems = new List<PerformanceItem>();
+            
+                DataTable data = GetDataFromIPEasy();
+
+                var Items = GetProjectItem(data);
+
+			foreach (var item in Items)
+			{
+				var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
+				if (temObj == null)
+				{
+					item.Type = "专案";
+					pfItems.Add(item);
+				}
+			}
+
+            //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
+            foreach (var item in pfItems)
+            {
+                SaveProjectItem(item);
+            }
+        }
+
+        private void SaveProjectItem(PerformanceItem item)
+        {
+            spDbContext spDb = new spDbContext();
+            var temObj = spDb.ProjectInfos.FirstOrDefault(p => p.CaseNo == item.CaseNo);
+
+            if (temObj == null)
+            {
+                ProjectInfo project = new ProjectInfo();
+                project.CaseNo = item.CaseNo;
+                project.CaseName = item.CaseName;
+                project.BusinessType = item.BusinessType;
+
+
+                if (item.Customer != null)
+                {
+                    var temCustomer = spDb.Customers.FirstOrDefault(c => c.Name == item.Customer.Name);
+                    if (temCustomer != null)
+                    {
+                        project.CustomerId = temCustomer.Id;
+                    }
+                }
+
+                project.CaseState = 0;
+                project.CaseType = item.CaseType;
+
+                project.ReviewerId = item.ReviewerId;
+                project.WorkflowUserId = item.WorkflowUserId;
+
+                spDb.ProjectInfos.Add(project);
+            }
+
+            spDb.SaveChanges();
+        }
+
+        private List<PerformanceItem> GetProjectItem(DataTable dt)
+		{
+			#region 删除重复行
+			DataTable temdt = new DataTable();
+			foreach (DataColumn col in dt.Columns)
+			{
+
+				DataColumn temCol = new DataColumn();
+				temCol.ColumnName = col.ColumnName;
+				temCol.DataType = col.DataType;
+				temCol.Caption = col.Caption;
+
+				temdt.Columns.Add(temCol);
+			}
+
+			new ExcelHelper().MerageDataTable(temdt, dt);
+			#endregion
+
+			List<PerformanceItem> Items = new List<PerformanceItem>();
+			int iRow = 0;
+			foreach (DataRow row in temdt.Rows)
+			{
+				string strDebug = $"{++iRow}\t{row["我方文号"]}";
+				PerformanceItem item = null;
+				
+				item = Row2Item_3(row);
+				
+				if (item != null)
+				{
+					Items.Add(item);
+				}
+			}
+
+			return Items;
+		}
+
+        private PerformanceItem Row2Item_3(DataRow row)
+        {
+            PerformanceItem item = new PerformanceItem();
+
+            item.CaseNo = row["我方文号"].ToString().Trim();
+            item.CaseName = row["案件名称"].ToString().Trim();
+            item.CaseType = row["案件类型"].ToString().Trim();
+            item.BusinessType = row["业务类型"].ToString().Trim();
+            item.Customer = new Customer();
+            item.Customer.Name = row["客户名称"].ToString().Trim();
+            item.CaseState = row["案件状态"].ToString().Trim();
+
+            DateTime temDate = new DateTime();
+            if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
+            {
+                item.EntrustingDate = temDate;
+            }
+
+
+            string strHandler = "";
+            if (row.Table.Columns.Contains("处理人"))
+            {
+                strHandler = row["处理人"].ToString().Trim();
+            }
+            else
+            {
+                if (row.Table.Columns.Contains("案件处理人"))
+                {
+                    strHandler = row["案件处理人"].ToString().Trim();
+                }
+            }
+
+            string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+            item.ItemStaffs = new List<ItemStaff>();
+
+            foreach (string name in temHandlers)
+            {
+                ItemStaff itemStaff = new ItemStaff();
+                string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
+
+                if (!name.Contains("君龙"))
+                {
+                    temName = name.Trim();
+                }
+
+                int? iTem = GetStaff(name);
+                if ((iTem != null))
+                {
+                    //itemStaff.Item = item;
+                    itemStaff.DoPersonId = iTem.Value;
+                    item.ItemStaffs.Add(itemStaff);
+                }
+                else
+                {
+                    itemStaff.DoPerson = new Staff()
+                    {
+                        Name = temName,
+                        Account = temName,
+                        Password = "12345678",
+                        IsCalPerformsnce = false,
+                        Status = "试用期",
+                        StaffGradeId = 4
+                    };
+                    item.ItemStaffs.Add(itemStaff);
+                }
+            }
+
+            if (item.ItemStaffs.Count == 0)
+            {
+                System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
+            }
+
+            if (row.Table.Columns.Contains("核稿人"))
+            {
+                item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
+            }
+            else
+            {
+                if (row.Table.Columns.Contains("案件核稿人"))
+                {
+                    item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
+                }
+            }
+
+            if (row.Table.Columns.Contains("业务人员"))
+            {
+                item.WorkflowUserId = GetStaff(row["业务人员"].ToString().Trim());
+            }
+
+            if (row.Table.Columns.Contains("国家(地区)"))
+            {
+                item.Country = row["国家(地区)"].ToString().Trim();
+            }
+
+            return item;
+        }
+
+        private int? GetStaff(string v)
+        {
+            using (spDbContext spDb = new spDbContext())
+            {
+                if (!string.IsNullOrEmpty(v))
+                {
+                    string temName = v.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
+
+                    if (!v.Contains("君龙"))
+                    {
+                        temName = v;
+                    }
+                    var staff = spDb.Staffs.Where<Staff>(s => s.Name == temName).FirstOrDefault();
+
+                    if (staff != null)
+                    {
+                        return staff.Id;
+                    }
+                }
+
+                return null;
+            }
+        }
+        private PerformanceItem Row2Item_2(DataRow row, CalMonth calMonth)
+        {
+            PerformanceItem item = new PerformanceItem();
+
+            item.CaseNo = row["我方文号"].ToString().Trim();
+            item.CaseName = row["案件名称"].ToString().Trim();
+            item.CaseType = row["案件类型"].ToString().Trim();
+            item.BusinessType = row["业务类型"].ToString().Trim();
+            item.Customer = new Customer();
+            item.Customer.Name = row["客户名称"].ToString().Trim();
+            item.CaseState = row["案件状态"].ToString().Trim();
+            item.DoItem = row["处理事项"].ToString().Trim();
+
+            if (row.Table.Columns.Contains("国家(地区)"))
+            {
+                item.Country = row["国家(地区)"].ToString().Trim();
+            }
+
+            DateTime temDate = new DateTime();
+            if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
+            {
+                item.InternalDate = temDate;
+            }
+
+            if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
+            {
+                item.CustomerLimitDate = temDate;
+            }
+
+            if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
+            {
+                item.FirstDraftDate = temDate;
+            }
+
+            if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
+            {
+                item.FinalizationDate = temDate;
+            }
+
+            if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
+            {
+                item.EntrustingDate = temDate;
+            }
+
+            if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
+            {
+                item.FinishedDate = temDate;
+            }
+
+            item.DoItemState = row["处理状态"].ToString().Trim();
+
+            string strHandler = "";
+            if (row.Table.Columns.Contains("处理人"))
+            {
+                strHandler = row["处理人"].ToString().Trim();
+            }
+            else
+            {
+                if (row.Table.Columns.Contains("案件处理人"))
+                {
+                    strHandler = row["案件处理人"].ToString().Trim();
+                }
+            }
+
+            string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+            item.ItemStaffs = new List<ItemStaff>();
+
+            foreach (string name in temHandlers)
+            {
+                ItemStaff itemStaff = new ItemStaff();
+                string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
+                if (!name.Contains("君龙"))
+                {
+                    temName = name.Trim();
+                }
+                int? iTem = GetStaff(temName);
+                if ((iTem != null))
+                {
+                    //itemStaff.Item = item;
+                    itemStaff.DoPersonId = iTem.Value;
+                    item.ItemStaffs.Add(itemStaff);
+                }
+                else
+                {
+                    itemStaff.DoPerson = new Staff()
+                    {
+                        Name = temName,
+                        Account = temName,
+                        Password = "12345678",
+                        IsCalPerformsnce = false,
+                        Status = "试用期",
+                        StaffGradeId = 4
+                    };
+                    item.ItemStaffs.Add(itemStaff);
+                }
+            }
+
+            if (item.ItemStaffs.Count == 0)
+            {
+                System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
+            }
+
+            if (row.Table.Columns.Contains("核稿人"))
+            {
+                item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
+            }
+            else
+            {
+                if (row.Table.Columns.Contains("案件核稿人"))
+                {
+                    item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
+                }
+            }
+
+            if (row.Table.Columns.Contains("业务人员"))
+            {
+                if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
+                {
+                    string name = row["业务人员"].ToString().Trim();
+                    string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
+                    if (!name.Contains("君龙"))
+                    {
+                        temName = name.Trim();
+                    }
+                    item.WorkflowUserId = GetStaff(temName);
+                }
+            }
+
+
+
+
+            return item;
+        }
+        private DataTable GetDataFromIPEasy()
+		{
+			DataTable dt = new DataTable();
+			string strSQL = @"SELECT  p_case_info.case_volume as 我方文号,
+	                        p_case_info.case_volume_customer as 客户文号,
+	                        p_case_info.case_name as 案件名称,
+	                        p_case_info.charge_date as 委案日期,
+	                        i_case_status.case_status_zh_cn as 案件状态,
+	                        i_case_type.case_type_zh_cn as 案件类型,
+	                        p_case_info.app_no as 申请号,
+	                        p_case_info.app_date as 申请日,
+	                        i_business_type.business_type_zh_cn as 业务类型,
+	                        STUFF((SELECT ',' + u.cn_name from c_customer_user as cu 
+		                        inner join s_user_info as u on u.user_id = cu.user_id where cu.customer_id = p_case_info.customer_id FOR XML PATH('') ),1,1,'') as 流程负责人,
+	                        c_customer.customer_name as 客户名称,
+	                        STUFF((SELECT ',' + u.cn_name from p_revise_user_list as pl
+		                        inner join s_user_info as u on u.user_id = pl.revise_user_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件核稿人,
+	                        STUFF((SELECT ',' + u.cn_name from p_proc_pic_list as pl
+		                        inner join s_user_info as u on u.user_id = pl.pic_id where pl.obj_id = p_case_info.case_id   FOR XML PATH('') ),1,1,'') as 案件处理人,
+	                        p_case_info.create_time as 开卷日期,
+	                        STUFF((SELECT ',' + ui.cn_name from p_sales_list as sl 
+		                        inner join dbo.s_user_info as ui on ui.user_id = sl.sales_user_id 
+		                        where sl.obj_id = p_case_info.case_id AND sl.is_enabled=1 order by sl.seq FOR XML PATH('') ),1,1,'') as 业务人员,
+	                        i_country.country_zh_cn as '国家(地区)'  
+                        from p_case_info
+	                        inner join   p_case_advance_info  with(nolock)  on p_case_info.case_id=p_case_advance_info.case_id  
+	                        inner join   i_apply_type  with(nolock)  on i_apply_type.apply_type_id=p_case_info.apply_type_id  
+	                        inner join   i_case_type  with(nolock)  on i_case_type.case_type_id=p_case_info.case_type_id  
+	                        inner join   i_country  with(nolock)  on i_country.country_id=p_case_info.country_id  
+	                        inner join   i_case_status  with(nolock)  on i_case_status.case_status_id=p_case_info.case_status_id  
+	                        inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
+	                        inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
+	                        inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
+                        where p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SCN%'
+						and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'
+						order by 我方文号";
+					
+
+
+			using (var conn = new SqlConnection(ConfigHelper.GetSectionValue("IPEasySetting:ConnectionStrings")))
+			{
+				try
+				{
+					conn.Open();
+					using (var cmd = conn.CreateCommand())
+					{
+						cmd.CommandText = strSQL;
+						cmd.CommandType = CommandType.Text;
+						
+						using (var reader = cmd.ExecuteReader())
+						{
+							dt.Load(reader);
+						}
+					}
+				}
+				catch (Exception ex)
+				{
+					throw ex;
+				}
+			}
+			return dt;
+		}
+	}
+}

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

@@ -107,16 +107,11 @@ namespace wispro.sp.api.Job
             DownloadReport_SQL("每月绩效统计--中国一次OA授权表", calMonth, true, true);
             //DownloadReport("每月绩效统计--中国一次OA授权表", calMonth, true,true);
 
-            //专案数据
-            DownloadProject_SQL(calMonth);
-            //DownloadProject(calMonth);
-
             return Task.CompletedTask;
         }
 
         private void DownloadReport_SQL(string ReportName, CalMonth calMonth, bool isModifyDate, bool isFirstOA = false)
         {
-        
             try
             {
                 DataTable data = GetDataFromIPEasy(ReportName,isModifyDate);
@@ -128,242 +123,7 @@ 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;
-
-            tryAgain:
-            try
-            {
-                wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, isModifyDate);
-
-                if (!System.IO.File.Exists(strFilePath))
-                {
-                    throw new ApplicationException("超时!");
-                }
-            }
-            catch {
-                tryCount++;
-
-                if (tryCount < 5)
-                {
-                    goto tryAgain;
-                }
-            }
-
-            System.Threading.Thread.Sleep(5000);
-            if (System.IO.File.Exists(strFilePath))
-            {
-                InputPerformanceItem(strFilePath, true, false, 1, calMonth, isFirstOA);
-
-                try
-                {
-                    System.IO.File.Move(strFilePath, strFinalPath);
-                }
-                catch { }
-            }
-            else
-            {
-                tryCount++;
-
-                if (tryCount < 5)
-                {
-                    goto tryAgain;
-                }
-            }
-        }
-
-        private void DownloadProject_SQL(CalMonth calMonth)
-        {
-            string[] ReportNames = new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
-
-            List<PerformanceItem> pfItems = new List<PerformanceItem>();
-            foreach (var ReportName in ReportNames)
-            {
-                DataTable data = GetDataFromIPEasy(ReportName, false);
-
-                var Items = GetProjectItem(calMonth, ReportName.Contains("专案开卷报表"),data);
-
-                foreach (var item in Items)
-                {
-                    var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
-                    if (temObj == null)
-                    {
-                        item.Type = "专案";
-                        pfItems.Add(item);
-                    }
-                }
-            }
-
-            //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
-            foreach (var item in pfItems)
-            {
-                SaveProjectItem(item);
-            }
-
-        }
-
-        private void DownloadProject(CalMonth calMonth)
-        {
-            string strFileSavePath = utility.ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
-
-            int tryCount = 0;
-
-            string[] ReportNames =new string[] { "每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷" };
-
-            List<PerformanceItem> pfItems = new List<PerformanceItem>();
-            foreach (var ReportName in ReportNames)
-            {
-            tryAgain:
-                try
-                {
-                    wispro.sp.utility.IPEasyUtility.DownloadReport(ReportName, false);
-                }
-                catch
-                {
-                    tryCount++;
-
-                    if (tryCount < 5)
-                    {
-                        goto tryAgain;
-                    }
-                }
-
-                System.Threading.Thread.Sleep(5000);
-                string filename = $"{ReportName.Trim().Replace("~","_")}.xlsx";
-                string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
-                string strFinalPath = System.IO.Path.Combine(strFileSavePath, $"{calMonth.Year}{calMonth.Month}-{filename}");
-
-                if (System.IO.File.Exists(strFilePath))
-                {
-
-                    var Items = GetProjectItem(strFilePath, calMonth, ReportName.Contains("专案开卷报表"));
-
-
-                    foreach (var item in Items)
-                    {
-                        var temObj = pfItems.FirstOrDefault<PerformanceItem>(s => s.CaseNo == item.CaseNo);
-                        if (temObj == null)
-                        {
-                            item.Type = "专案";
-                            pfItems.Add(item);
-                        }
-                    }
-
-                    try
-                    {
-                        System.IO.File.Move(strFilePath, strFinalPath);
-                    }
-                    catch { }
-
-                }
-                else
-                {
-                    tryCount++;
-
-                    if (tryCount < 5)
-                    {
-                        goto tryAgain;
-                    }
-                }
-            }
-
-            //List<BasePointRule> rules = spDb.BasePointRules.ToList<BasePointRule>();
-            foreach (var item in pfItems)
-            {
-                SaveProjectItem(item);
-            }
-
-        }
-
-        private void SaveProjectItem(PerformanceItem item)
-        {
-            var temObj = spDb.ProjectInfos.FirstOrDefault(p=>p.CaseNo == item.CaseNo);
-
-            if (temObj == null)
-            {
-                ProjectInfo project = new ProjectInfo();
-                project.CaseNo = item.CaseNo;
-                project.CaseName = item.CaseName;
-                project.BusinessType = item.BusinessType;
-                
-                
-                if(item.Customer != null)
-                {
-                    var temCustomer = spDb.Customers.FirstOrDefault(c => c.Name == item.Customer.Name);
-                    if(temCustomer != null)
-                    {
-                        project.CustomerId = temCustomer.Id;
-                    }
-                }
-
-                project.CaseState = 0;
-                project.CaseType = item.CaseType;
-                
-                project.ReviewerId = item.ReviewerId;
-                project.WorkflowUserId = item.WorkflowUserId;
-
-                spDb.ProjectInfos.Add(project);
-            }
-
-            spDb.SaveChanges();
-        }
-
-        private List<PerformanceItem> GetProjectItem(string strPath,CalMonth calMonth,bool isOpenSheet)
-        {
-            DataTable dt = NPOIExcel.ExcelToDataTable(strPath, true, true, 1);
-            return GetProjectItem(calMonth, isOpenSheet, dt);
-        }
-
-        private List<PerformanceItem> GetProjectItem(CalMonth calMonth, bool isOpenSheet, DataTable dt)
-        {
-            #region 删除重复行
-            DataTable temdt = new DataTable();
-            foreach (DataColumn col in dt.Columns)
-            {
-
-                DataColumn temCol = new DataColumn();
-                temCol.ColumnName = col.ColumnName;
-                temCol.DataType = col.DataType;
-                temCol.Caption = col.Caption;
-
-                temdt.Columns.Add(temCol);
-            }
-
-            new ExcelHelper().MerageDataTable(temdt, dt);
-            #endregion
-
-            List<PerformanceItem> Items = new List<PerformanceItem>();
-            int iRow = 0;
-            foreach (DataRow row in temdt.Rows)
-            {
-                string strDebug = $"{++iRow}\t{row["我方文号"]}";
-                PerformanceItem item = null;
-                if (!isOpenSheet)
-                {
-                    item = Row2Item_2(row, calMonth);
-                }
-                else
-                {
-                    item = Row2Item_3(row, calMonth);
-                }
-
-                if (item != null)
-                {
-                    item.CalMonth = calMonth;
-                    item.CalMonthId = calMonth.Id;
-                    Items.Add(item);
-                }
-            }
-
-            return Items;
-        }
-
+        
         private Task InputPerformanceItem(string strExcelFile, bool isColumnName, bool ignorHideRows = false, int ColumnNameRow = 0, CalMonth calMonth = null, bool isFirstOAFile = false)
         {
             DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName, ignorHideRows, ColumnNameRow);
@@ -457,235 +217,7 @@ namespace wispro.sp.api.Job
             return Task.CompletedTask;
         }
 
-        private PerformanceItem Row2Item_3(DataRow row, CalMonth calMonth)
-        {
-            PerformanceItem item = new PerformanceItem();
-
-            item.CaseNo = row["我方文号"].ToString().Trim();
-            item.CaseName = row["案件名称"].ToString().Trim();
-            item.CaseType = row["案件类型"].ToString().Trim();
-            item.BusinessType = row["业务类型"].ToString().Trim();
-            item.Customer = new Customer();
-            item.Customer.Name = row["客户名称"].ToString().Trim();
-            item.CaseState = row["案件状态"].ToString().Trim();
-
-            DateTime temDate = new DateTime();
-            if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
-            {
-                item.EntrustingDate = temDate;
-            }
-
-            
-            string strHandler = "";
-            if (row.Table.Columns.Contains("处理人"))
-            {
-                strHandler = row["处理人"].ToString().Trim();
-            }
-            else
-            {
-                if (row.Table.Columns.Contains("案件处理人"))
-                {
-                    strHandler = row["案件处理人"].ToString().Trim();
-                }
-            }
-
-            string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
-            item.ItemStaffs = new List<ItemStaff>();
-
-            foreach (string name in temHandlers)
-            {
-                ItemStaff itemStaff = new ItemStaff();
-                string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
-
-                if (!name.Contains("君龙"))
-                {
-                    temName = name.Trim();
-                }
-
-                int? iTem = GetStaff(name);
-                if ((iTem != null))
-                {
-                    //itemStaff.Item = item;
-                    itemStaff.DoPersonId = iTem.Value;
-                    item.ItemStaffs.Add(itemStaff);
-                }
-                else
-                {
-                    itemStaff.DoPerson = new Staff()
-                    {
-                        Name = temName,
-                        Account = temName,
-                        Password = "12345678",
-                        IsCalPerformsnce = false,
-                        Status = "试用期",
-                        StaffGradeId = 4
-                    };
-                    item.ItemStaffs.Add(itemStaff);
-                }
-            }
-
-            if (item.ItemStaffs.Count == 0)
-            {
-                System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
-            }
-
-            if (row.Table.Columns.Contains("核稿人"))
-            {
-                item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
-            }
-            else
-            {
-                if (row.Table.Columns.Contains("案件核稿人"))
-                {
-                    item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
-                }
-            }
-
-            if (row.Table.Columns.Contains("业务人员"))
-            {
-                item.WorkflowUserId = GetStaff(row["业务人员"].ToString().Trim());
-            }
-
-            if (row.Table.Columns.Contains("国家(地区)"))
-            {
-                item.Country = row["国家(地区)"].ToString().Trim();
-            }
-
-            return item;
-        }
-        private PerformanceItem Row2Item_2(DataRow row, CalMonth calMonth)
-        {
-            PerformanceItem item = new PerformanceItem();
-
-            item.CaseNo = row["我方文号"].ToString().Trim();
-            item.CaseName= row["案件名称"].ToString().Trim();
-            item.CaseType = row["案件类型"].ToString().Trim();
-            item.BusinessType= row["业务类型"].ToString().Trim();
-            item.Customer = new Customer();
-            item.Customer.Name = row["客户名称"].ToString().Trim();
-            item.CaseState = row["案件状态"].ToString().Trim();
-            item.DoItem = row["处理事项"].ToString().Trim();
-
-            if (row.Table.Columns.Contains("国家(地区)"))
-            {
-                item.Country = row["国家(地区)"].ToString().Trim();
-            }
-
-            DateTime temDate = new DateTime();
-            if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
-            {
-                item.InternalDate  = temDate;
-            }
-
-            if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
-            {
-                item.CustomerLimitDate = temDate;
-            }
-
-            if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
-            {
-                item.FirstDraftDate  = temDate;
-            }
-
-            if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
-            {
-                item.FinalizationDate = temDate;
-            }
-
-            if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
-            {
-                item.EntrustingDate = temDate;
-            }
-
-            if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
-            {
-                item.FinishedDate = temDate;
-            }
-
-            item.DoItemState = row["处理状态"].ToString().Trim();
-
-            string strHandler = "";
-            if (row.Table.Columns.Contains("处理人"))
-            {
-                strHandler = row["处理人"].ToString().Trim();
-            }
-            else
-            {
-                if (row.Table.Columns.Contains("案件处理人"))
-                {
-                    strHandler = row["案件处理人"].ToString().Trim();
-                }
-            }
-
-            string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
-            item.ItemStaffs = new List<ItemStaff>();
-
-            foreach (string name in temHandlers)
-            {
-                ItemStaff itemStaff = new ItemStaff();
-                string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
-                if (!name.Contains("君龙"))
-                {
-                    temName = name.Trim();
-                }
-                int? iTem = GetStaff(temName);
-                if ((iTem != null))
-                {
-                    //itemStaff.Item = item;
-                    itemStaff.DoPersonId = iTem.Value;
-                    item.ItemStaffs.Add(itemStaff);
-                }
-                else
-                {
-                    itemStaff.DoPerson = new Staff()
-                    {
-                        Name = temName,
-                        Account = temName,
-                        Password = "12345678",
-                        IsCalPerformsnce = false,
-                        Status = "试用期",
-                        StaffGradeId = 4
-                    };
-                    item.ItemStaffs.Add(itemStaff);
-                }
-            }
-
-            if (item.ItemStaffs.Count == 0)
-            {
-                System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
-            }
-
-            if (row.Table.Columns.Contains("核稿人"))
-            {
-                item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim());
-            }
-            else
-            {
-                if (row.Table.Columns.Contains("案件核稿人"))
-                {
-                    item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim());
-                }
-            }
-
-            if (row.Table.Columns.Contains("业务人员"))
-            {
-                if (!string.IsNullOrEmpty(row["业务人员"].ToString().Trim()))
-                {
-                    string name = row["业务人员"].ToString().Trim();
-                    string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
-                    if (!name.Contains("君龙"))
-                    {
-                        temName = name.Trim();
-                    }
-                    item.WorkflowUserId = GetStaff(temName);
-                }
-            }
-            
-
-            
-
-            return item;
-        }
+        
         private PerformanceItem Row2Item_1(DataRow row,  CalMonth calMonth)
         {
             PerformanceItem item = new PerformanceItem();
@@ -1390,13 +922,8 @@ namespace wispro.sp.api.Job
 	                        inner join   c_customer  with(nolock)  on c_customer.customer_id=p_case_info.customer_id  
 	                        inner join i_business_type on i_business_type.business_type_id = p_case_info.business_type_id 
 	                        inner join s_dept_info on s_dept_info.dept_id = p_case_info.charge_dept_id 
-                        where p_case_info.is_enabled=1 and  
-                        (p_case_info.business_type_id='ad0d4c8f-7c2d-4cbf-a5b4-cc1a64d4c384'    
-	                        or p_case_info.business_type_id='20184cc4-1dd8-4d5b-81bd-4b39ca3700f4'
-	                        or p_case_info.business_type_id='94713100-f013-4444-a5a1-1dd1b78d8cdf'
-	                        or p_case_info.business_type_id='f2d4d629-b7a5-4fa5-888d-91029ce7a3f5'
-	                        or p_case_info.business_type_id='32144fb3-2ce0-4ed9-ae6f-a6a09fb66e60') AND  
-	                        (DATEDIFF(dd,p_case_info.create_time,getdate())<='31') ";
+                        where p_case_info.is_enabled=1 p_case_info.is_enabled=1 and  p_case_info.case_volume like 'S%' and not p_case_info.case_volume like 'SC%'
+						and i_case_status.case_status_zh_cn<>'已完成' and i_case_status.case_status_zh_cn<>'结案'";
                     break;
             }
             

+ 2 - 0
wispro.sp.api/Job/InvalidDataMessageJob.cs

@@ -32,6 +32,7 @@ namespace wispro.sp.api.Job
                 dt.Columns.Add("我方文号");
                 dt.Columns.Add("业务人员");
                 dt.Columns.Add("申请国家");
+                dt.Columns.Add("客户名称");
                 dt.Columns.Add("专利类型");
                 dt.Columns.Add("处理事项");
                 dt.Columns.Add("案件阶段");
@@ -57,6 +58,7 @@ namespace wispro.sp.api.Job
                     row["基础点数"] = p.BasePoint;
                     row["绩效类型"] = p.Type;
                     row["备注"] = p.CaseMemo;
+                    row["客户名称"] = p.ApplicationName;
                     row["申请国家"] = p.Country;
 
                     if (p.WorkflowUser != null)

+ 74 - 27
wispro.sp.api/Job/UpdateJXDataFromIPEasyJob.cs

@@ -108,10 +108,10 @@ namespace wispro.sp.api.Job
 		            i_ctrl_proc.ctrl_proc_zh_cn=@DoItem and 
 		            p_case_info.case_volume =@CaseNo";
 
-                    if (!string.IsNullOrEmpty(Item.CaseStage))
-                    {
-                        strSql = $"{strSql} and review_stage=@CaseStage";
-                    }
+                    //if (!string.IsNullOrEmpty(Item.CaseStage))
+                    //{
+                    //    strSql = $"select * from  ({strSql}) as t where review_stage=@CaseStage";
+                    //}
 
 
                     using (var cmd = conn.CreateCommand())
@@ -120,10 +120,10 @@ namespace wispro.sp.api.Job
                         cmd.CommandType = CommandType.Text;
                         cmd.Parameters.Add(new SqlParameter("DoItem", Item.DoItem));
                         cmd.Parameters.Add(new SqlParameter("CaseNo", Item.CaseNo));
-                        if (!string.IsNullOrEmpty(Item.CaseStage))
-                        {
-                            cmd.Parameters.Add(new SqlParameter("CaseStage", Item.CaseStage));
-                        }
+                        //if (!string.IsNullOrEmpty(Item.CaseStage))
+                        //{
+                        //    cmd.Parameters.Add(new SqlParameter("CaseStage", Item.CaseStage));
+                        //}
 
                         using (var reader = cmd.ExecuteReader())
                         {
@@ -139,14 +139,10 @@ namespace wispro.sp.api.Job
                                     retItem.FinishedDate = row["finish_date"].ToString();
                                     DateTime temDate = DateTime.Now;
                                     DateTime.TryParse(retItem.FinishedDate,out temDate);
-                                    if (Item.FinishedDate.HasValue && Item.FinishedDate.Value == temDate)
+                                    if ((Item.FinishedDate.HasValue && Item.FinishedDate.Value == temDate) ||
+                                        (!string.IsNullOrEmpty(Item.CaseStage) && Item.CaseStage == row["review_stage"].ToString()))
                                     {
-                                        retItem.CaseNo = row["case_volume"].ToString();
-                                        retItem.CaseCoefficient = row["case_coefficient"].ToString();
-                                        retItem.DoItemCoefficient = row["proc_coefficient"].ToString();
-                                        retItem.Reviewer = row["reviser"].ToString();
-                                        retItem.FinishedDate = row["finish_date"].ToString();
-                                        retItem.WordCount = row["translate_count"].ToString();
+                                        GetItemData(retItem, row);
 
                                         bRet = true;
                                         break;
@@ -157,12 +153,8 @@ namespace wispro.sp.api.Job
                                 if (!bRet)
                                 {
                                     DataRow row = dt.Rows[0];
-                                    retItem.CaseNo = row["case_volume"].ToString();
-                                    retItem.CaseCoefficient = row["case_coefficient"].ToString();
-                                    retItem.DoItemCoefficient = row["proc_coefficient"].ToString();
-                                    retItem.Reviewer = row["reviser"].ToString();
-                                    retItem.FinishedDate = row["finish_date"].ToString();
-                                    retItem.WordCount = row["translate_count"].ToString();
+                                    GetItemData(retItem, row);
+
                                 }
                             }
                             else
@@ -170,12 +162,8 @@ namespace wispro.sp.api.Job
                                 if (dt.Rows.Count > 0)
                                 {
                                     DataRow row = dt.Rows[0];
-                                    retItem.CaseNo = row["case_volume"].ToString();
-                                    retItem.CaseCoefficient = row["case_coefficient"].ToString();
-                                    retItem.DoItemCoefficient = row["proc_coefficient"].ToString();
-                                    retItem.Reviewer = row["reviser"].ToString();
-                                    retItem.FinishedDate = row["finish_date"].ToString();
-                                    retItem.WordCount = row["translate_count"].ToString();
+                                    GetItemData(retItem, row);
+
                                 }
 
                             }
@@ -197,8 +185,67 @@ namespace wispro.sp.api.Job
 
             return retItem;
         }
+
+        private static void GetItemData(dynamic retItem, DataRow row)
+        {
+            retItem.CaseNo = row["case_volume"].ToString();
+            retItem.ApplicationType = row["apply_type_zh_cn"].ToString();
+            retItem.BusinessType = row["business_type_zh_cn"].ToString();
+            retItem.DoItem = row["ctrl_proc_zh_cn"].ToString(); ;
+            retItem.CaseStage = row["review_stage"].ToString();
+            retItem.CaseCoefficient = row["case_coefficient"].ToString();
+            retItem.DoItemCoefficient = row["proc_coefficient"].ToString();
+            retItem.DoPersons = row["pic"].ToString();
+            retItem.Reviewer = row["reviser"].ToString();
+            retItem.CustomerName = row["customer_name"].ToString();
+            retItem.FinishedDate = row["finish_date"].ToString();
+            retItem.WordCount = row["translate_count"].ToString();
+            retItem.ReturnDate = row["back_date"].ToString();
+            retItem.CaseType = row["case_type_zh_cn"].ToString();
+            retItem.CaseState = row["case_status_zh_cn"].ToString();
+            retItem.DoItemMemo = row["proc_status_zh_cn"].ToString();
+            retItem.DoItemState = row["proc_note"].ToString();
+            retItem.CaseName = row["case_name"].ToString();
+            retItem.EntrustingDate = row["charge_date"].ToString();
+            retItem.CustomerLimitDate = row["cus_due_date"].ToString();
+            retItem.InternalDate = row["int_due_date"].ToString();
+            retItem.FirstDraftDate = row["first_doc_date"].ToString();
+            retItem.CaseMemo = row["case_remark"].ToString();
+            retItem.FinalizationDate = row["finish_doc_date"].ToString();
+        }
+
         public void UpdateFromIPEasy(PerformanceItem Item,spDbContext spDb)
         {
+            List<string> caseNos = new List<string>()
+            {
+                "AHK2211737",
+                "PAHK2211739",
+                "PACN2120893-TS",
+                "PAKR2117244",
+                "PAIN2117242",
+                "PAEPO1912286",
+                "PAUS2116581-转所",
+                "PATW2111942",
+                "PACN2024870-TS客户自行递交",
+                "PAUS2010428",
+                "PAEPO2111073",
+                "PAUS1915675",
+                "PAUS2111071",
+                "PAAU2210170",
+                "PAUS2010164",
+                "PACN1914374",
+                "PAUS2210315",
+                "PAUS2016669-结案",
+                "PAEPO1510129",
+                "PAUS2016669-结案",
+                "PACN2026619-TS",
+                "PACN2123589-TS",
+                "PACN2125458"
+            };
+            if (caseNos.Contains(Item.CaseNo))
+            {
+                System.Diagnostics.Debug.WriteLine("");
+            }
             dynamic retObj = GetItemFromIPEasyDB(Item, spDb); //utility.IPEasyUtility.GetPerformanceRecord(Item.CaseNo, Item.DoItem, string.IsNullOrEmpty(Item.CaseStage) ? null : Item.CaseStage);
 
             var appealAJXS = spDb.AppealTypes.FirstOrDefault(p => p.Name.Contains("案件系数"));

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

@@ -53,6 +53,17 @@ namespace wispro.sp.api
             _ = QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
             #endregion
 
+            #region 每月获取绩效数据Job
+            JobKey jobProject = new JobKey("ImportProject");
+            var triggerProject = TriggerBuilder.Create()
+                .WithDescription("同步专案信息")
+                .WithSchedule(CronScheduleBuilder.CronSchedule(utility.ConfigHelper.GetSectionValue("ImportProjectScheduleSetting")).WithMisfireHandlingInstructionDoNothing())
+                .Build();
+
+
+            _ = QuartzUtil.Add(typeof(ImportProjectInfoJob), jobProject, triggerProject);
+            #endregion
+
             #region 每天更新绩效数据
             JobKey jobKey1 = new JobKey("UpdateSchedule");
             var trigger1 = TriggerBuilder.Create()

+ 2 - 1
wispro.sp.api/appsettings.json

@@ -11,9 +11,10 @@
     "DefaultConnect": "Data Source=(local);Initial Catalog=spDB;User ID=sa;Password=Lqftiu807005"
   },
 
-  "UpdateScheduleSetting": "00 45 15 1-9 * ? *",
+  "UpdateScheduleSetting": "00 01 12 1-9 * ? *",
   "InvalidDataScheduleSetting": "00 29 16 1-6 * ? *",
   "AgentMessageScheduleSetting": "00 10 06 7 * ? *",
+  "ImportProjectScheduleSetting": "0 13 10 * * ?",
 
   "ValidAudience": "StaffPerformance",
   "ValidIssuer": "http://localhost:39476",

+ 20 - 0
wispro.sp.api/spDbContext.cs

@@ -62,6 +62,8 @@ namespace wispro.sp.api
 
         public virtual DbSet<Position> Positions { get; set; }
 
+        public virtual DbSet<StaffStatisticsforLevel> StaffStatisticsforLevels { get; set; }
+
         #region 流程定义
         public virtual DbSet<Workflow> Workflows { get; set; }
 
@@ -399,6 +401,24 @@ namespace wispro.sp.api
                     .HasConstraintName("FK_StaffStatistics_PerformanceItem");
             });
 
+            modelBuilder.Entity<StaffStatisticsforLevel>(entity =>
+            {
+                entity.ToTable("StaffStatisticsforLevel");
+
+                entity.HasOne(d => d.CalMonth)
+                    .WithMany()
+                    .HasForeignKey(d => d.CalMonthId);
+
+                entity.HasOne(d => d.Staff)
+                    .WithMany()
+                    .HasForeignKey(d => d.StaffId);
+
+                entity.HasOne(d => d.Grade)
+                    .WithMany()
+                    .HasForeignKey(d => d.GradeId);
+                
+            });
+
             modelBuilder.Entity<Message>(entity =>
             {
                 //entity.HasKey(e => e.Id);

+ 187 - 0
wispro.sp.share/LevelStatistics.cs

@@ -0,0 +1,187 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.share
+{
+    public class LevelStatisticsResult
+    {
+        public double doAverage()
+        {
+            var temList = Statistics.Where(s => s.dS > 0 || s.dA > 0 || s.dB > 0 || s.dC > 0 || s.dD > 0);
+            int count = temList.Count();
+
+            double ret = 0.0;
+            switch (Grade)
+            {
+                case "A":
+                    ret=(double)((((decimal)temList.Sum(s => s.dS)*2.5M)+((decimal)temList.Sum(s=>s.dA)*1.5M))/(decimal)count);
+                    break;
+                case "B":
+                    ret = (double)((((decimal)temList.Sum(s => s.dS) * 2.5M) + ((decimal)temList.Sum(s => s.dA) * 1.5M) +((decimal)temList.Sum(s => s.dB))) / (decimal)count);
+                    break;
+                case "C":
+                    ret = (double)((((decimal)temList.Sum(s => s.dS) * 2.5M) + ((decimal)temList.Sum(s => s.dA) * 1.5M) + ((decimal)temList.Sum(s => s.dB))+((decimal)temList.Sum(s => s.dC)*0.7M)) / (decimal)count);
+                    break;
+                case "D":
+                    ret = (double)((((decimal)temList.Sum(s => s.dS) * 2.5M) + ((decimal)temList.Sum(s => s.dA) * 1.5M) + ((decimal)temList.Sum(s => s.dB)) + ((decimal)temList.Sum(s => s.dC) * 0.7M)) / (decimal)count);
+                    break;
+            }
+
+            return ret;
+        }
+
+        public double vAverage()
+        {
+            var temList = Statistics.Where(s => s.vS > 0 || s.vA > 0 || s.vB > 0 || s.vC > 0 || s.vD > 0);
+            int count = temList.Count();
+
+            double ret = (double)(((decimal)temList.Sum(s => s.dS) * 2.5M + (decimal)temList.Sum(s => s.dA) * 1.5M + (decimal)temList.Sum(s => s.dB) + (decimal)temList.Sum(s => s.dC) * 0.7M) / (decimal)count);
+
+            return ret;
+        }
+
+        public double pAverage(int staffId)
+        {
+            var temObj = Statistics.FirstOrDefault(s => s.StaffId == staffId);
+
+            if(temObj != null)
+            {
+                switch (Grade)
+                {
+                    case "A":
+                        return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M) / (decimal)doAverage());
+                        break;
+                    case "B":
+                        return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M+(decimal)temObj.dB) / (decimal)doAverage());
+                        break;
+                    case "C":
+                    case "D":
+                        return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB + (decimal)temObj.dC * 0.7M) / (decimal)doAverage());
+                        break;
+                    default:
+                        return 0.0;
+                }
+            }
+            else
+            {
+                return 0.0;
+            }
+        }
+
+        public double pvAverage(int staffId)
+        {
+            var temObj = Statistics.FirstOrDefault(s => s.StaffId == staffId);
+
+            if (temObj != null)
+            {
+                return (double)(((decimal)temObj.vS * 2.5M + (decimal)temObj.vA * 1.5M + (decimal)temObj.vB + (decimal)temObj.vC * 0.7M)/(decimal)vAverage());
+            }
+            else
+            {
+                return 0.0;
+            }
+        }
+
+        public double p2(int staffId)
+        {
+            var temObj = Statistics.FirstOrDefault(s => s.StaffId == staffId);
+            switch (Grade)
+            {
+                case "B":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB) / ((decimal)doAverage() * 0.95M));
+                    break;
+                case "C":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB + (decimal)temObj.dC * 0.7M) / ((decimal)UpgradeBase*0.7M));
+                    break;
+                case"D":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB + (decimal)temObj.dC * 0.7M) / 14M);
+                default:
+                    return 0.0;
+            }
+        }
+
+        public double p3(int staffId)
+        {
+            var temObj = Statistics.FirstOrDefault(s => s.StaffId == staffId);
+            switch (Grade)
+            {
+                case "B":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB) / ((decimal)doAverage()));
+                    break;
+                case "C":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB + (decimal)temObj.dC * 0.7M) / ((decimal)UpgradeBase * 0.8M));
+                    break;
+                case "D":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB + (decimal)temObj.dC * 0.7M) / 16M);
+                default:
+                    return 0.0;
+            }
+        }
+
+        public double toUpgradeLevel(int staffId)
+        {
+            var temObj = Statistics.FirstOrDefault(s => s.StaffId == staffId);
+            switch (Grade)
+            {
+                case "B":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M ) / ((decimal)UpgradeBase));
+                    break;
+                case "C":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB ) / ((decimal)UpgradeBase * 0.9M));
+                    break;
+                case "D":
+                    return (double)(((decimal)temObj.dS * 2.5M + (decimal)temObj.dA * 1.5M + (decimal)temObj.dB + (decimal)temObj.dC * 0.7M) / 18M);
+                default:
+                    return 0.0;
+            }
+        }
+
+        /// <summary>
+        /// 升级基数
+        /// </summary>
+        public double UpgradeBase { get; set; }
+
+        /// <summary>
+        /// 人员等级
+        /// </summary>
+        public string Grade { get; set; }
+
+        /// <summary>
+        /// 个人案件数量统计
+        /// </summary>
+        public List<LevelStatistics> Statistics { get; set; }
+    }
+
+    public class LevelStatistics
+    {
+        public int StaffId { get; set; }
+
+        public string StaffName { get; set; }
+
+        public string Grade { get; set; }
+
+        public string Department { get; set; }
+
+        public double dS { get; set; }
+        public double dA { get; set; }
+
+        public double dB { get; set; }
+
+        public double dC { get; set; }
+
+        public double dD { get; set; }
+
+        public double vS { get; set; }
+
+        public double vA { get; set; }
+
+        public double vB { get; set; }
+
+        public double vC { get; set; }
+
+        public double vD { get; set; }
+    }
+}

+ 7 - 0
wispro.sp.web/Layouts/BasicLayout.razor

@@ -81,6 +81,13 @@
                     Key="appealRecords",
                     Path="/AppealRecords",
                     Icon ="message",
+                },
+                new MenuDataItem
+                {
+                    Name="级别调整计算",
+                    Key="Level",
+                    Path="/LevelStatistics",
+                    Icon ="message",
                 }
 
             }

+ 237 - 0
wispro.sp.web/Pages/AppCase/LevelStatistics.razor

@@ -0,0 +1,237 @@
+@page "/LevelStatistics"
+
+<PageContainer>
+    <Breadcrumb>
+        <Breadcrumb>
+            <BreadcrumbItem>
+                <a href="/Home"><Icon Type="home"></Icon></a>
+            </BreadcrumbItem>
+            <BreadcrumbItem>
+                <Icon Type="manager"></Icon><span>代理人等级考核计算</span>
+            </BreadcrumbItem>
+        </Breadcrumb>
+    </Breadcrumb>
+
+    <ChildContent>
+        <Card Title="">
+            <Extra>
+                <DatePicker TValue="DateTime?" @bind-Value="@SelectedTime" @Ref="refDate" Picker="@DatePickerType.Quarter" Locale="@CN" CultureInfo="CiCn"/>
+                <Button Type="primary" Icon="folder-add" OnClick="()=>ShowSelectedDate()" Style="float:right">查看</Button>
+            </Extra>
+            <CardTabs>
+                <Tabs>
+                    <TabPane Key="A" Tab="A级代理人">
+                        @if(AResult == null)
+                        {
+                            <spin/>
+                        }
+                        else
+                        {
+                            <table width="100%" border="1" style="line-height:40px;">
+
+                                <thead>
+                                    <tr>
+                                        <th rowspan="2" width="10%">代理人</th>
+                                        <th rowspan="2" width="16%">部门</th>
+                                        <th rowspan="2" width="10%">代理人等级</th>
+                                        <th colspan="4">承办</th>
+                                        <th colspan="4">审核</th>
+                                        <th rowspan="2" width="8%">Z1(承办)</th>
+                                        <th rowspan="2" width="8%">Z2(核稿)</th>
+                                    </tr>
+                                    <tr>
+                                        
+                                        <th width="6%">S</th>
+                                        <th width="6%">A</th>
+                                        <th width="6%">B</th>
+                                        <th width="6%">C</th>
+                                        <th width="6%">S</th>
+                                        <th width="6%">A</th>
+                                        <th width="6%">B</th>
+                                        <th width="6%">C</th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    @foreach(var TemObj in AResult.Statistics)
+                                    {
+                                        <tr>
+                                            <td align="center">@TemObj.StaffName</td>
+                                            <td align="center">@TemObj.Department</td>
+                                            <td align="center">@TemObj.Grade</td>
+                                            <td align="center">@TemObj.dS</td>
+                                            <td align="center">@TemObj.dA</td>
+                                            <td align="center">@TemObj.dB</td>
+                                            <td align="center">@TemObj.dC</td>
+                                            <td align="center">@TemObj.vS</td>
+                                            <td align="center">@TemObj.vA</td>
+                                            <td align="center">@TemObj.vB</td>
+                                            <td align="center">@TemObj.vC</td>
+                                            <td align="center">@((AResult.pAverage(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((AResult.pvAverage(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                        </tr>
+                                    }
+                                </tbody>
+                            </table>
+                        }
+                    </TabPane>
+                    <TabPane Key="B" Tab="B级代理人">
+                        @if(BResult == null)
+                        {
+                            <spin/>
+                        }
+                        else
+                        {
+                            <table width="100%" border="1" style="line-height:40px;">
+
+                                <thead>
+                                    <tr>
+                                        <th rowspan="2" width="10%">代理人</th>
+                                        <th rowspan="2">部门</th>
+                                        <th rowspan="2" width="10%">代理人等级</th>
+                                        <th colspan="5">承办</th>
+                                        <th rowspan="2" width="8%">Z1</th>
+                                        <th rowspan="2" width="8%">B2(B*0.95)</th>
+                                        <th rowspan="2" width="8%">B3(B*100%)</th>
+                                        <th rowspan="2" width="8%">A1</th>
+                                    </tr>
+                                    <tr>
+                                        
+                                        <th width="6%">S</th>
+                                        <th width="6%">A</th>
+                                        <th width="6%">B</th>
+                                        <th width="6%">C</th>
+                                        <th width="6%">D</th>
+                                        
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    @foreach(var TemObj in BResult.Statistics)
+                                    {
+                                        <tr>
+                                            <td align="center">@TemObj.StaffName</td>
+                                            <td align="center">@TemObj.Department</td>
+                                            <td align="center">@TemObj.Grade</td>
+                                            <td align="center">@TemObj.dS</td>
+                                            <td align="center">@TemObj.dA</td>
+                                            <td align="center">@TemObj.dB</td>
+                                            <td align="center">@TemObj.dC</td>
+                                            <td align="center">@TemObj.dD</td>
+                                            <td align="center">@((BResult.pAverage(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((BResult.p2(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((BResult.p3(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((BResult.toUpgradeLevel(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                        </tr>
+                                    }
+                                </tbody>
+                            </table>
+                        }
+                    </TabPane>
+                    <TabPane Key="C" Tab="C级代理人">
+                        @if(CResult == null)
+                        {
+                            <spin/>
+                        }
+                        else
+                        {
+                            <table width="100%" border="1" style="line-height:40px;">
+
+                                <thead>
+                                    <tr>
+                                        <th rowspan="2" width="10%">代理人</th>
+                                        <th rowspan="2">部门</th>
+                                        <th rowspan="2" width="10%">代理人等级</th>
+                                        <th colspan="5">承办</th>
+                                        <th rowspan="2" width="8%">Z1</th>
+                                        <th rowspan="2" width="8%">C2(B*0.7)</th>
+                                        <th rowspan="2" width="8%">C3(B*0.8))</th>
+                                        <th rowspan="2" width="8%">B1(B*0.9)</th>
+                                    </tr>
+                                    <tr>
+                                        
+                                        <th width="6%">S</th>
+                                        <th width="6%">A</th>
+                                        <th width="6%">B</th>
+                                        <th width="6%">C</th>
+                                        <th width="6%">D</th>
+                                        
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    @foreach(var TemObj in CResult.Statistics)
+                                    {
+                                        <tr>
+                                            <td align="center">@TemObj.StaffName</td>
+                                            <td align="center">@TemObj.Department</td>
+                                            <td align="center">@TemObj.Grade</td>
+                                            <td align="center">@TemObj.dS</td>
+                                            <td align="center">@TemObj.dA</td>
+                                            <td align="center">@TemObj.dB</td>
+                                            <td align="center">@TemObj.dC</td>
+                                            <td align="center">@TemObj.dD</td>
+                                            <td align="center">@((CResult.pAverage(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((CResult.p2(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((CResult.p3(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((CResult.toUpgradeLevel(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                        </tr>
+                                    }
+                                </tbody>
+                            </table>
+                        }
+                    </TabPane>
+                    <TabPane Key="D" Tab="D级代理人">
+                       @if(CResult == null)
+                        {
+                            <spin/>
+                        }
+                        else
+                        {
+                            <table width="100%" border="1" style="line-height:40px;">
+
+                                <thead>
+                                    <tr>
+                                        <th rowspan="2" width="10%">代理人</th>
+                                        <th rowspan="2">部门</th>
+                                        <th rowspan="2" width="10%">代理人等级</th>
+                                        <th colspan="5">承办</th>
+                                        <th rowspan="2" width="8%">Z1</th>
+                                        <th rowspan="2" width="8%">D2(14)</th>
+                                        <th rowspan="2" width="8%">D3(16)</th>
+                                        <th rowspan="2" width="8%">C1(18)</th>
+                                    </tr>
+                                    <tr>
+                                        
+                                        <th width="6%">S</th>
+                                        <th width="6%">A</th>
+                                        <th width="6%">B</th>
+                                        <th width="6%">C</th>
+                                        <th width="6%">D</th>
+                                        
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    @foreach(var TemObj in DResult.Statistics)
+                                    {
+                                        <tr>
+                                            <td align="center">@TemObj.StaffName</td>
+                                            <td align="center">@TemObj.Department</td>
+                                            <td align="center">@TemObj.Grade</td>
+                                            <td align="center">@TemObj.dS</td>
+                                            <td align="center">@TemObj.dA</td>
+                                            <td align="center">@TemObj.dB</td>
+                                            <td align="center">@TemObj.dC</td>
+                                            <td align="center">@TemObj.dD</td>
+                                            <td align="center">@((DResult.pAverage(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((DResult.p2(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((DResult.p3(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                            <td align="center">@((DResult.toUpgradeLevel(TemObj.StaffId)*100.00).ToString("0.00"))%</td>
+                                        </tr>
+                                    }
+                                </tbody>
+                            </table>
+                        }
+                    </TabPane>
+                </Tabs>
+            </CardTabs>
+        </Card>
+    </ChildContent>
+</PageContainer>

+ 96 - 0
wispro.sp.web/Pages/AppCase/LevelStatistics.razor.cs

@@ -0,0 +1,96 @@
+using AntDesign;
+using Microsoft.AspNetCore.Components;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Threading.Tasks;
+using wispro.sp.share;
+using wispro.sp.web.Services;
+using System.Linq;
+
+namespace wispro.sp.web.Pages.AppCase
+{
+    public partial class LevelStatistics
+    {
+        CultureInfo CiEn = CultureInfo.GetCultureInfo("en-US");
+        CultureInfo CiCn = CultureInfo.GetCultureInfo("zh-CN");
+        DatePicker<DateTime?> refDate;
+        DateTime? SelectedTime;
+
+        DatePickerLocale CN = new DatePickerLocale
+        {
+            FirstDayOfWeek = DayOfWeek.Sunday,
+            Lang = new DateLocale
+            {
+                YearFormat = "yyyy年",
+                MonthFormat = "M月",
+                DateSelect = "选择日期",
+                WeekSelect = "选择周",
+                MonthSelect = "选择月份",
+                YearSelect = "选择年份",
+                QuarterSelect = "选择季度",
+                Today = "今天"
+            }
+        };
+
+        [Inject]
+        PerformanceItemServices pService { get; set; }
+        private async Task ShowSelectedDate()
+        {
+            if (SelectedTime != null)
+            {
+                int year = SelectedTime.Value.Year;
+
+                int quartar = 1;
+                if (SelectedTime.Value.Month <= 3)
+                {
+                    quartar = 1;
+                }
+                else
+                {
+                    if (SelectedTime.Value.Month <= 6)
+                    {
+                        quartar = 2;
+                    }
+                    else
+                    {
+                        if (SelectedTime.Value.Month <= 9)
+                        {
+                            quartar = 3;
+                        }
+                        else
+                        {
+                            quartar = 4;
+                        }
+                    }
+                }
+
+                await pService.StatisticsLevelCount(year, 1);
+                await pService.StatisticsLevelCount(year, 2);
+                await pService.StatisticsLevelCount(year, 3);
+            }
+        }
+
+        LevelStatisticsResult AResult;
+        LevelStatisticsResult BResult;
+        LevelStatisticsResult CResult;
+        LevelStatisticsResult DResult;
+        protected override async Task OnInitializedAsync()
+        {
+            if(SelectedTime == null)
+            {
+                SelectedTime = DateTime.Now.AddMonths(-3);
+            }
+
+
+            AResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "A");
+            BResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "B");
+            CResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "C");
+            DResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "D");
+            
+            await base.OnInitializedAsync();
+        }
+
+        
+    }
+}

+ 12 - 0
wispro.sp.web/Services/PerformanceItemServices.cs

@@ -343,7 +343,19 @@ namespace wispro.sp.web.Services
             return data;
         }
 
+        #region 绩效等级计算
+        public async Task StatisticsLevelCount(int year ,int month)
+        {
+            await _httpClient.Get<bool>($"PerformanceItem/StatisticsLevelCount?year={year}&month={month}");
+        }
+
+        public async Task<LevelStatisticsResult> CalAgentLevel(int year, int quarter, string GradeCode)
+        {
+            var data =await _httpClient.Get<LevelStatisticsResult>($"PerformanceItem/CalAgentLevel?year={year}&quarter={quarter}&GradeCode={GradeCode}");
+            return data;
+        }
 
+        #endregion
 
 
 

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

@@ -188,9 +188,10 @@ namespace wispro.sp.winClient
        
         private async void button3_Click(object sender, EventArgs e)
         {
-            await StartImport();
+            
+            //await StartImport();
             //await RemoveDBNotFinishedDate();
-            //await CalJXPoint();
+            await CalJXPoint();
             //await RefreshPerformanceItem(3);
             //await UpdateStaff();
 

+ 39 - 0
wospro.sp.entity/StaffStatisticsforLevel.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.entity
+{
+    public class StaffStatisticsforLevel
+    {
+        public int Id { get; set; }
+
+        public CalMonth CalMonth { get; set; }
+
+        public int CalMonthId { get; set; }
+
+        public Staff Staff { get; set; }
+
+        public int StaffId { get; set; }
+
+        public int GradeId { get; set; }
+
+        public StaffGrade Grade { get; set; }
+
+        public string Type { get; set; }
+
+        public bool isReview { get; set; }
+
+        public double S { get; set; }
+
+        public double A { get; set; }
+
+        public double B { get; set; }
+
+        public double C { get; set; }
+
+        public double D { get; set; }
+    }
+}