Quellcode durchsuchen

修正申诉处理代码
完成遗漏案件申诉处理代码

luocaiyang vor 3 Jahren
Ursprung
Commit
6614d67ada

+ 59 - 0
wispro.sp.api/AppealHandler/MissingCaseAppealHandler.cs

@@ -0,0 +1,59 @@
+using Microsoft.EntityFrameworkCore;
+using Quartz;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using wispro.sp.api.Job;
+using wispro.sp.share;
+
+namespace wispro.sp.api.AppealHandler
+{
+    public class MissingCaseAppealHandler : IDoAppealObject
+    {
+        
+
+        public void DoAppeal(AppealObject appeal, int appealRecordid, DbContext spContext)
+        {
+            var trigger = TriggerBuilder.Create()
+               .WithDescription("获取案件信息")
+               .WithSimpleSchedule(x => x.WithIntervalInSeconds(5).WithRepeatCount(0))
+               .Build();
+
+            var job = JobBuilder.Create(typeof(GetPerformanceItemJob))
+                .WithIdentity("获取案件任务")
+                .Build();
+
+            foreach (var iv in appeal.inputFieldValues)
+            {
+                if(iv.InputField == null)
+                {
+                    iv.InputField = ((spDbContext)spContext).InputFields.FirstOrDefault(s=>s.Id == iv.InputFieldId);
+                }
+
+                if(iv.InputField.FieldName == "我方文号")
+                {
+                    job.JobDataMap.Put("CaseNo", iv.Value);
+                    continue;
+                }
+
+                if(iv.InputField.FieldName =="处理事项")
+                {
+                    job.JobDataMap.Put("DoItem", iv.Value);
+                    continue;
+                }
+
+                if (iv.InputField.FieldName == "案件阶段")
+                {
+                    job.JobDataMap.Put("CaseStage", iv.Value);
+                    
+                    continue;
+                }
+            }
+
+            _ = QuartzUtil.Add(job, trigger);
+        }
+
+
+    }
+}

+ 179 - 0
wispro.sp.api/AppealHandler/MissingCaseReviewHandler.cs

@@ -0,0 +1,179 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using wispro.sp.api.Controllers;
+using wispro.sp.entity;
+using wispro.sp.share;
+
+namespace wispro.sp.api.AppealHandler
+{
+    public class MissingCaseReviewHandler : IDoAppealObject
+    {
+
+        public void DoAppeal(AppealObject appeal, int appealRecordId, DbContext spContext)
+        {
+            bool isAggree = false;
+            foreach (var iv in appeal.inputFieldValues)
+            {
+                if (iv.InputField == null)
+                {
+                    iv.InputField = ((spDbContext)spContext).InputFields.FirstOrDefault(s => s.Id == iv.InputFieldId);
+                }
+
+                if (iv.InputField.FieldName == "审核意见" && iv.Value =="同意")
+                {
+                    isAggree = true;
+                    break;
+                }
+
+            }
+            if (isAggree)
+            {
+                var result = ((spDbContext)spContext).InputFieldValues.Where<InputFieldValue>(f => f.AppealRecordId == appealRecordId  && f.InputField.AppealState == 0).ToList();
+
+                string strCaseNo="";
+                string strDoItem="";
+                string strCaseStage = "";
+                foreach (var iv in result)
+                {
+                    if (iv.InputField == null)
+                    {
+                        iv.InputField = ((spDbContext)spContext).InputFields.FirstOrDefault(s => s.Id == iv.InputFieldId);
+                    }
+
+                    if (iv.InputField.FieldName == "我方文号")
+                    {
+                        strCaseNo = iv.Value;
+                        continue;
+                    }
+
+                    if (iv.InputField.FieldName == "处理事项")
+                    {
+                        strDoItem=iv.Value;
+                        continue;
+                    }
+
+                    if (iv.InputField.FieldName == "案件阶段")
+                    {
+                        strCaseStage = iv.Value;
+                        continue;
+                    }
+                }
+
+                var itemControler = new PerformanceItemController((spDbContext)spContext);
+
+                
+                PerformanceItem Item = itemControler.GetItemInfoByCaseStage(strCaseNo,strDoItem, strCaseStage);
+                var Rules = ((spDbContext)spContext).BasePointRules.ToList();
+                
+                Utility.Utility.CalBasePoint(Item, Rules);
+
+                CalMonth calMonth = ((spDbContext)spContext).CalMonths.FirstOrDefault(c=>c.Status == 0);
+
+                if (calMonth != null)
+                {
+                    SaveToDb(Item, (spDbContext)spContext, calMonth);
+                }
+                //((spDbContext)spContext).PerformanceItems.Add(Item);
+                //((spDbContext)spContext).SaveChanges();
+            }
+        }
+
+        private void SaveToDb(PerformanceItem item,spDbContext Context,CalMonth calMonth)
+        {
+            try
+            {
+                item.CalMonthId = calMonth.Id;
+                var results = Context.PerformanceItems.Where<PerformanceItem>(x =>
+                   x.CaseNo == item.CaseNo && x.DoItem == item.DoItem && x.DoItem != "提出报告" && x.CaseStage == item.CaseStage);
+
+                var items = results.Include(pi => pi.CalMonth).FirstOrDefault<PerformanceItem>();
+
+                if (items != null)
+                {
+                    item.AgentFeedbackMemo = "已算绩效";
+                    item.DoItemMemo = $"{items.DoItemMemo}\r\n{items.CalMonth.Year}-{items.CalMonth.Month}已计算!";
+                    item.BasePoint = 0;
+                }
+
+                if (item.Customer != null && !string.IsNullOrEmpty(item.Customer.Name))
+                {
+                    var temCustomer = Context.Customers.Where<Customer>(c => c.Name == item.Customer.Name).FirstOrDefault();
+
+                    if (temCustomer == null)
+                    {
+                        temCustomer = new Customer() { Name = item.Customer.Name };
+                        //item.Customer.Id = 0;
+
+                        Context.Customers.Add(temCustomer);
+                        Context.SaveChanges();
+                        item.Customer = temCustomer;
+                        //item.CustomerId = item.Customer.Id;
+                    }
+                    else
+                    {
+                        item.Customer = temCustomer;
+                    }
+
+                    item.CustomerId = item.Customer.Id;
+                    item.Customer = null;
+                }
+                else
+                {
+                    item.Customer = null;
+                }
+
+
+                var ItemStaffs = item.ItemStaffs;
+                item.ItemStaffs = null;
+
+                if (item.ReviewerId != null)
+                {
+                    var Reviewer = item.Reviewer;
+                    item.Reviewer = null;
+                }
+
+                Context.PerformanceItems.Add(item);
+                Context.SaveChanges();
+
+                foreach (ItemStaff itemStaff in ItemStaffs)
+                {
+                    itemStaff.ItemId = item.Id;
+                    itemStaff.Item = null;
+
+                    if (itemStaff.DoPersonId == 0 && itemStaff.DoPerson != null)
+                    {
+                        var temStaff = Context.Staffs.FirstOrDefault<Staff>(s => s.Name == itemStaff.DoPerson.Name);
+
+                        if (temStaff != null)
+                        {
+                            itemStaff.DoPersonId = temStaff.Id;
+                            itemStaff.DoPerson = null;
+                        }
+                        else
+                        {
+                            Context.Staffs.Add(itemStaff.DoPerson);
+                            Context.SaveChanges();
+                            itemStaff.DoPersonId = itemStaff.DoPerson.Id;
+                            itemStaff.DoPerson = null;
+                        }
+                    }
+                    else
+                    {
+                        itemStaff.DoPerson = null;
+                    }
+                }
+
+                Context.ItemStaffs.AddRange(ItemStaffs);
+                Context.SaveChanges();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+    }
+}

+ 38 - 4
wispro.sp.api/Controllers/AppealController.cs

@@ -7,6 +7,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
+using System.Reflection;
 using System.Threading.Tasks;
 using wispro.sp.entity;
 using wispro.sp.share;
@@ -51,8 +52,18 @@ namespace wispro.sp.api.Controllers
             ApiSaveResponse response = new ApiSaveResponse();
             response.Success = true;
 
+            
+            
             AppealRecord appealRecord = new AppealRecord();
-            appealRecord.ItemId = ItemId;
+            if(ItemId > 0)
+            {
+                appealRecord.ItemId = ItemId;
+            }
+            else
+            {
+                appealRecord.ItemId = null;
+            }
+            
             appealRecord.TypeId = typeid;
             appealRecord.ReviewerId = reviewerId;
             appealRecord.CreaterId =  Context.Staffs.Where<Staff>(s => s.Name == User.Identity.Name).FirstOrDefault().Id;
@@ -78,6 +89,13 @@ namespace wispro.sp.api.Controllers
                 }
 
                 Context.SaveChanges();
+
+                if (!string.IsNullOrEmpty(appealRecord.Type.ApplealObject))
+                {
+                    IDoAppealObject doAppeal = (IDoAppealObject)Activator.CreateInstance(Type.GetType(appealRecord.Type.ApplealObject));
+                    doAppeal.DoAppeal(appealObject, appealRecord.Id, Context);
+                }
+
                 t.Commit();
 
                 return response;
@@ -139,6 +157,19 @@ namespace wispro.sp.api.Controllers
                     }
 
                     Context.SaveChanges();
+
+                    if(appealRecord.Type == null)
+                    {
+                        appealRecord.Type = Context.AppealTypes.FirstOrDefault(s=>s.Id == appealRecord.TypeId);
+                    }
+
+                    if (!string.IsNullOrEmpty(appealRecord.Type.ReviewObject))
+                    {
+                        IDoAppealObject doAppeal = (IDoAppealObject)Activator.CreateInstance(Type.GetType(appealRecord.Type.ReviewObject));
+
+                        doAppeal.DoAppeal(appealObject, appealRecord.Id,Context);
+                    }
+
                     t.Commit();
 
                     return response;
@@ -319,9 +350,12 @@ namespace wispro.sp.api.Controllers
                 record.Creater.ItemStaffs = null;
                 record.Creater.ReviewerItems = null;
                 record.Creater.Customers = null;
-                record.Item.ItemStaffs = null;
-                record.Item.PreOastaff = null;
-                record.Item.Reviewer = null;
+                if (record.Item != null)
+                {
+                    record.Item.ItemStaffs = null;
+                    record.Item.PreOastaff = null;
+                    record.Item.Reviewer = null;
+                }
             }
 
             return retList;

+ 82 - 0
wispro.sp.api/Controllers/IPEasyController.cs

@@ -192,5 +192,87 @@ namespace wispro.sp.api.Controllers
             }
         }
 
+        public PerformanceItem GetDoItemInfo(string CaseNo, string DoItem,string caseStage)
+        {
+            var retItem = GetFromCache(CaseNo, DoItem);
+            if (retItem != null)
+            {
+                return retItem;
+            }
+            else
+            {
+                dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanceRecord(CaseNo, DoItem,caseStage);
+                PerformanceItem Item = new PerformanceItem();
+                Item.CaseName = retObj.CaseName;
+                Item.CaseNo = retObj.CaseNo;
+                Item.DoItem = retObj.DoItem;
+                Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
+                Item.Customer = new Customer();
+                Item.Customer.Name = retObj.CustomerName;
+                Item.Customer.Name = Item.Customer.Name.Replace("(null)", "");
+                Item.DoItemCoefficient = retObj.DoItemCoefficient;
+                Item.DoItemMemo = retObj.DoItemMemo;
+                Item.DoItemState = retObj.DoItemState;
+                Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
+                Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
+                Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
+                //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
+                Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
+
+                if (!string.IsNullOrEmpty(retObj.DoPersons))
+                {
+
+                    Item.ItemStaffs = new List<ItemStaff>();
+                    string[] names = retObj.DoPersons.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                    foreach (var name in names)
+                    {
+
+                        ItemStaff iStaff = new ItemStaff();
+                        iStaff.DoPerson = Context.Staffs.Where<Staff>(s => s.Name == name).FirstOrDefault();
+                        if (iStaff.DoPerson == null)
+                        {
+                            iStaff.DoPerson = new Staff() { Name = name };
+                        }
+                        else
+                        {
+                            iStaff.DoPersonId = iStaff.DoPerson.Id;
+                        }
+
+
+
+                        Item.ItemStaffs.Add(iStaff);
+                    }
+                }
+
+                Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
+
+                if (!string.IsNullOrEmpty(retObj.Reviewer))
+                {
+                    string name = retObj.Reviewer;
+                    var temReviewer = Context.Staffs.Where<Staff>(s => s.Name == name).FirstOrDefault();
+                    if (temReviewer == null)
+                    {
+                        Item.Reviewer = new Staff() { Name = retObj.Reviewer };
+                    }
+                    else
+                    {
+                        Item.Reviewer = temReviewer;
+                        Item.ReviewerId = temReviewer.Id;
+                    }
+                }
+                Item.ApplicationType = retObj.ApplicationType;
+                Item.BusinessType = retObj.BusinessType;
+                Item.CaseCoefficient = retObj.CaseCoefficient;
+                Item.CaseMemo = retObj.CaseMemo;
+                Item.CaseStage = retObj.CaseStage;
+                Item.CaseState = retObj.CaseState;
+                Item.CaseType = retObj.CaseType;
+
+                SaveToCache(Item);
+
+                return Item;
+            }
+        }
+
     }
 }

+ 63 - 15
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -293,9 +293,12 @@ namespace wispro.sp.api.Controllers
                 itemStaff.Item = null;
             }
 
-            item.Reviewer.ReviewerItems = null;
-            item.Reviewer.Customers = null;
-            item.Reviewer.ItemStaffs = null;
+            if (item.Reviewer != null)
+            {
+                item.Reviewer.ReviewerItems = null;
+                item.Reviewer.Customers = null;
+                item.Reviewer.ItemStaffs = null;
+            }
 
             item.Customer.PerformanceItems = null;
             item.CalMonth.PerformanceItems = null;
@@ -432,8 +435,21 @@ namespace wispro.sp.api.Controllers
             List<StaffStatistics> retList = new List<StaffStatistics>();
             List<VerifyCoefficient> verifyCoefficients = Context.VerifyCoefficients.ToList<VerifyCoefficient>();
 
+            var Rules = Context.BasePointRules.ToList();
+
             foreach (PerformanceItem item in ItemList)
             {
+                
+
+
+
+                //if (item.BasePoint == null)
+                //{
+                    
+                    Utility.Utility.CalBasePoint(item,Rules);
+
+                    Context.SaveChanges();
+                //}
 
                 if (item.BasePoint != null && item.BasePoint.Value > 0)
                 {
@@ -443,7 +459,7 @@ namespace wispro.sp.api.Controllers
 
                     bool isPJFP = true;
                     double total = item.ItemStaffs.Count();
-                    if (item.ItemStaffs.Where<ItemStaff>(p => p.PerformancePoint == null || p.PerformancePoint == 0).Count() == 0)
+                    if (item.ItemStaffs.Where<ItemStaff>(p => p.PerformancePoint != null || p.PerformancePoint == 0).Count() > 0)
                     {
                         total = item.ItemStaffs.Select(i => i.PerformancePoint.Value).Sum();
                         isPJFP = false;
@@ -464,8 +480,10 @@ namespace wispro.sp.api.Controllers
                         #region 计算审核人绩效点数,核稿人绩效点数按照核稿人与个处理人的核稿系数计算后加总,没有找到核稿系数(比如同级别),核稿系数为0
                         if (item.ReviewerId != null && item.Type !="专案")
                         {
+                            
                             #region 取审核人等级审核等级系数
-                            VerifyCoefficient vcoefficient = verifyCoefficients.Where<VerifyCoefficient>(v =>
+                            VerifyCoefficient vcoefficient 
+                                = verifyCoefficients.Where<VerifyCoefficient>(v =>
                                     v.CheckerId == item.Reviewer.StaffGrade.Id
                                     && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
                             .FirstOrDefault<VerifyCoefficient>();
@@ -485,7 +503,7 @@ namespace wispro.sp.api.Controllers
                                 }
                                 else
                                 {
-                                    if (item.Reviewer.IsOnJob)  //判断是否在职
+                                    if (item.Reviewer.IsOnJob && itemStaff.DoPerson.Status != "试用期")  //判断是否在职
                                     {
                                         temReviewerStatic = new StaffStatistics()
                                         {
@@ -540,17 +558,34 @@ namespace wispro.sp.api.Controllers
                             {
                                 if (item.Type != "专案")
                                 {
-                                    temStatic = new StaffStatistics()
+                                    if (itemStaff.DoPerson.Status == "试用期" && item.Reviewer != null)
                                     {
-                                        CalMonth = calMonth,
-                                        CalMonthId = calMonth.Id,
-                                        StaffId = itemStaff.DoPersonId,
-                                        totalBasePoint = handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient,
-                                        jxType = handlerJxType
-                                    };
+                                        temStatic = new StaffStatistics()
+                                        {
+                                            CalMonth = calMonth,
+                                            CalMonthId = calMonth.Id,
+                                            StaffId = item.Reviewer.Id,
+                                            totalBasePoint = handlerBasePoint * item.Reviewer.StaffGrade.Coefficient,
+                                            jxType = handlerJxType
+                                        };
 
 
-                                    itemStatistics.Add(temStatic);
+                                        itemStatistics.Add(temStatic);
+                                    }
+                                    else
+                                    {
+                                        temStatic = new StaffStatistics()
+                                        {
+                                            CalMonth = calMonth,
+                                            CalMonthId = calMonth.Id,
+                                            StaffId = itemStaff.DoPersonId,
+                                            totalBasePoint = handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient,
+                                            jxType = handlerJxType
+                                        };
+
+
+                                        itemStatistics.Add(temStatic);
+                                    }
                                 }
                                 else
                                 {
@@ -725,7 +760,7 @@ namespace wispro.sp.api.Controllers
             IQueryable<PerformanceItem> response;
             if (queryFilter.userId > 0)
             {
-                 response = Context.PerformanceItems.Where<PerformanceItem>(dynamicWhere).Where(s => (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == queryFilter.userId).Count() > 0 || s.ReviewerId == queryFilter.userId));
+                response = Context.PerformanceItems.Where<PerformanceItem>(dynamicWhere).Where(s => (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == queryFilter.userId).Count() > 0));// || s.ReviewerId == queryFilter.userId));
 
             }
             else
@@ -892,5 +927,18 @@ namespace wispro.sp.api.Controllers
 
             return retObj;
         }
+
+        public PerformanceItem GetItemInfoByCaseStage(string CaseNo, string DoItem,string caseStage)
+        {
+            var retObj = Context.PerformanceItems.FirstOrDefault<PerformanceItem>(p => p.CaseNo == CaseNo.Trim() 
+            && p.DoItem == DoItem.Trim() && p.CaseStage == caseStage);
+
+            if (retObj == null)
+            {
+                retObj = IPEasyUtility.GetPerformanceRecord(CaseNo, DoItem, caseStage);
+            }
+
+            return retObj;
+        }
     }
 }

+ 23 - 0
wispro.sp.api/Job/GetPerformanceItemJob.cs

@@ -0,0 +1,23 @@
+using Quartz;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using wispro.sp.api.Controllers;
+
+namespace wispro.sp.api.Job
+{
+    public class GetPerformanceItemJob : IJob
+    {
+        public Task Execute(IJobExecutionContext context)
+        {
+
+            string CaseNo = context.JobDetail.JobDataMap.Get("CaseNo").ToString();
+            string DoItem = context.JobDetail.JobDataMap.Get("DoItem").ToString();
+            string caseStage = context.JobDetail.JobDataMap.Get("CaseStage").ToString();
+
+            new PerformanceItemController(new spDbContext()).GetItemInfoByCaseStage(CaseNo,DoItem,caseStage);
+            return Task.CompletedTask;
+        }
+    }
+}

+ 16 - 3
wispro.sp.api/Job/QuartzUtil.cs

@@ -22,9 +22,6 @@ namespace wispro.sp.api.Job
         public static async Task Add(Type type, JobKey jobKey, ITrigger trigger = null)
         {
             await Init();
-            //_scheduler = await _schedulerFactory.GetScheduler();
-
-            //await _scheduler.Start();
 
             if (trigger == null)
             {
@@ -42,6 +39,22 @@ namespace wispro.sp.api.Job
             await _scheduler.ScheduleJob(job, trigger);
         }
 
+        public static async Task Add(IJobDetail job, ITrigger trigger = null)
+        {
+            await Init();
+
+            if (trigger == null)
+            {
+                trigger = TriggerBuilder.Create()
+                    .WithIdentity("april.trigger")
+                    .WithDescription("default")
+                    .WithSimpleSchedule(x => x.WithMisfireHandlingInstructionFireNow().WithRepeatCount(-1))
+                    .Build();
+            }
+
+            await _scheduler.ScheduleJob(job, trigger);
+        }
+
         public static async Task AddMailJob(string Subject,string Body,string toName,string To)
         {
             await Init();

+ 32 - 9
wispro.sp.api/Job/UpdateJXDataFromIPEasyJob.cs

@@ -8,24 +8,32 @@ using wispro.sp.entity;
 
 namespace wispro.sp.api.Job
 {
-    public class UpdateJXDataFromIPEasyJob: IJob
+    public class UpdateJXDataFromIPEasyJob : IJob
     {
         public Task Execute(IJobExecutionContext context)
         {
             spDbContext spDb = new spDbContext();
 
             var lstItem = spDb.PerformanceItems.Where<PerformanceItem>(p =>
-                (p.DoItem == "新申请" && (p.CaseCoefficient == null || p.CaseCoefficient == "") && p.CalMonth.Status ==0) ||
-                (p.DoItem == "处理审查意见" && (p.CaseStage == "一通" || p.CaseStage == "二通") && (p.DoItemCoefficient == null || p.DoItemCoefficient == "") && p.CalMonth.Status == 0))
+                (p.DoItem == "新申请" && (p.CaseCoefficient == null || p.CaseCoefficient == "") && p.CalMonth.Status == 0) ||
+                (p.DoItem == "处理审查意见" && (p.CaseStage == "一通" || p.CaseStage == "二通") && (p.DoItemCoefficient == null || p.DoItemCoefficient == "") && p.CalMonth.Status == 0) ||
+                ((p.DoItem == "Final Action") || (p.DoItem == "翻译校核") || (p.DoItem == "申復") || (p.DoItem == "口审评估") ||
+                (p.DoItem == "欧洲案答辩") || (p.DoItem == "RCE") || (p.DoItem == "Non Final Action") || (p.DoItem == "Advisory Action") && (p.DoItemCoefficient == null || p.DoItemCoefficient =="") && p.CalMonth.Status == 0) ||
+                (p.FinishedDate == null && p.CalMonth.Status == 0))
                 .Include(p=>p.Reviewer)
-                .ToList<PerformanceItem>()
-                ;
+                .Include(p=>p.CalMonth)
+                .ToList<PerformanceItem>();
+           
 
-            if(lstItem != null)
+            if (lstItem != null)
             {
                 int i = 0;
-                foreach(var Item in lstItem)
+                foreach (var Item in lstItem)
                 {
+                    if (Item.CaseNo == "PAIN2134921" || Item.CaseNo == "PAUS2010405" || Item.CaseNo == "PAUS2016667")
+                    {
+                        Console.WriteLine("");
+                    }
                     System.Diagnostics.Debug.WriteLine($"{DateTime.Now}\t{++i}\t{Item.CaseNo}");
                     int iTryCount = 0;    
                 TryAgain:
@@ -186,10 +194,25 @@ namespace wispro.sp.api.Job
                             Item.CaseType = retObj.CaseType;
                         }
 
-                        if (spDb.Entry(Item).State != EntityState.Unchanged)
+                        if (Item.FinishedDate.HasValue && 
+                            Item.FinishedDate.Value.ToString("yyyy-MM") != DateTime.Parse($"{Item.CalMonth.Year}-{Item.CalMonth.Month}-01").ToString("yyyy-MM"))
                         {
-                            Utility.Utility.CalBasePoint(Item, spDb.BasePointRules.ToList());
+                            var ItemStaffs = spDb.ItemStaffs.Where(p => p.ItemId == Item.Id).ToList();
+                            foreach(var itemstaff in ItemStaffs)
+                            {
+                                spDb.Remove(itemstaff);
+                            }
+                            spDb.PerformanceItems.Remove(Item);
                             spDb.SaveChanges();
+
+                        }
+                        else
+                        {
+                            if (spDb.Entry(Item).State != EntityState.Unchanged)
+                            {
+                                Utility.Utility.CalBasePoint(Item, spDb.BasePointRules.ToList());
+                                spDb.SaveChanges();
+                            }
                         }
                     }
                     catch(Exception ex)

+ 23 - 2
wispro.sp.api/Utility/Utility.cs

@@ -26,7 +26,7 @@ namespace wispro.sp.api.Utility
                 var interpreter = new Interpreter(options)
                     .Reference(typeof(System.Linq.Enumerable));
 
-                //System.Diagnostics.Debug.WriteLine(rule.Rule);
+                System.Diagnostics.Debug.WriteLine(rule.Rule);
 
                 try
                 {
@@ -43,7 +43,8 @@ namespace wispro.sp.api.Utility
                             temString = $"{rule.PointExpress.Trim()}.0";
                         }
 
-                        item.BasePoint = (double?)interpreter.Eval(temString);
+                        var target = new Interpreter().SetVariable("p", item);
+                        item.BasePoint = (double?)target.Eval(temString);
                         item.Type = rule.Type;
                         break;
                     }
@@ -53,6 +54,26 @@ namespace wispro.sp.api.Utility
                 }
             }
             #endregion
+
+            if(item.DoItem =="处理审查意见" && item.ApplicationType == "发明" && item.PreOastaffId != null)
+            {
+                if(item.ItemStaffs.Where<ItemStaff>(s=>s.DoPersonId == item.PreOastaffId).Count() == 0)
+                {
+                    switch (item.DoItemCoefficient)
+                    {
+                        case "实质":
+                            item.BasePoint = 0.5;
+                            break;
+                        case "形式":
+                            item.BasePoint = 0.2;
+                            break;
+                        case "非实质":
+                            item.BasePoint = 0.3;
+                            break;
+
+                    }
+                }
+            }
         }
 
         public static List<string> GetDoItemCeofficient(PerformanceItem item, List<BasePointRule> rules)

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

@@ -11,7 +11,7 @@
     "DefaultConnect": "Data Source=(local);Initial Catalog=spDB;User ID=sa;Password=Lqftiu807005"
   },
 
-  "UpdateScheduleSetting": "00 35 14 * * ? *",
+  "UpdateScheduleSetting": "00 48 09 * * ? *",
 
   "ValidAudience": "StaffPerformance",
   "ValidIssuer": "http://localhost:39476",

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

@@ -676,8 +676,8 @@ namespace wispro.sp.api
                 new SelectValue(){Id =17, InputFieldId =19, Value ="中-英" },
                 new SelectValue(){Id =18, InputFieldId =19, Value ="英-中" },
 
-                new SelectValue(){Id =19, InputFieldId =22, Value ="同意" },
-                new SelectValue(){Id =20, InputFieldId =22, Value ="拒绝" },
+                new SelectValue(){Id =19, InputFieldId =21, Value ="同意" },
+                new SelectValue(){Id =20, InputFieldId =21, Value ="拒绝" },
             };
 
             List<CaseCeoffcient> caseCeoffcients = new List<CaseCeoffcient>()

+ 14 - 0
wispro.sp.share/IDoAction.cs

@@ -0,0 +1,14 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.share
+{
+    public interface IDoAppealObject
+    {
+        public void DoAppeal(AppealObject appeal, int appealRecordId, DbContext spContext);
+    }
+}

+ 1 - 0
wispro.sp.share/wispro.sp.share.csproj

@@ -7,6 +7,7 @@
 
   <ItemGroup>
     <PackageReference Include="AntDesign.ProLayout" Version="0.1.8" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
   </ItemGroup>
 
   <ItemGroup>

+ 13 - 17
wispro.sp.utility/ExcelHelper.cs

@@ -329,29 +329,25 @@ namespace wispro.sp.utility
 
         private DataRow isExists(DataRow row,DataTable dt)
         {
-
-            //DataRow[] temRows = dt.Select($"我方文号='{row["我方文号"].ToString()}' and 处理事项='{row["处理事项"].ToString()}' and 处理人='{row["处理人"].ToString()}'");
-            //if (temRows.Length > 0)
-            //{
-            //    return temRows[0];
-            //}
-            //else
-            //{
-            //    return null;
-            //}
-
-
             foreach (DataRow temRow in dt.Rows)
             {
                 if(row["我方文号"].ToString() == temRow["我方文号"].ToString() &&
                     row["处理事项"].ToString() == temRow["处理事项"].ToString() &&
                     row["处理人"].ToString() == temRow["处理人"].ToString())
                 {
-                    System.Diagnostics.Debug.WriteLine(string.Format("{0} 重复项目", row["我方文号"].ToString()));
-
-                    return temRow;
-
-                    
+                    if (row["处理事项"].ToString() == "处理审查意见")
+                    {
+                        if (row["案件阶段"].ToString() == temRow["案件阶段"].ToString())
+                        {
+                            System.Diagnostics.Debug.WriteLine(string.Format("{0} 重复项目", row["我方文号"].ToString()));
+                            return temRow;
+                        }
+                    }
+                    else
+                    {
+                        System.Diagnostics.Debug.WriteLine(string.Format("{0} 重复项目", row["我方文号"].ToString()));
+                        return temRow;
+                    }
                 }
             }
 

+ 1 - 1
wispro.sp.utility/IPEasyUtility.cs

@@ -371,7 +371,7 @@ namespace wispro.sp.utility
                 var DoItemLinks = driver.FindElements(By.XPath($"//td[@colname='ctrl_proc'][normalize-space()='{doItemName}']"));
                 if (DoItemLinks.Count > 0)
                 {
-                    if (caseStage != null)
+                    if (!string.IsNullOrEmpty(caseStage))
                     {
                         foreach(var DoItemLink in DoItemLinks)
                         {

+ 2 - 2
wispro.sp.web/Components/InputValueSetting.razor

@@ -28,8 +28,8 @@
                     {
                         <Select DataSource="@FieldTypes"
                                 @bind-Value="@context.InputValueSetting.valueType"
-                                LabelName="@nameof(wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.FieldType>.Description)"
-                                ValueName="@nameof(wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.FieldType>.Value)"
+                                LabelName="@nameof(wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.EnumFieldType>.Description)"
+                                ValueName="@nameof(wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.EnumFieldType>.Value)"
                                 Placeholder="请选项一项"
                                 DefaultActiveFirstItem="false"
                                 EnableSearch="true"

+ 3 - 0
wispro.sp.web/Components/ReviewerAppeal.razor

@@ -1,5 +1,7 @@
 @inherits FeedbackComponent<ReviewerAppealModel>
 <Collapse >
+    @if (_Model.Item != null)
+    {
     <Panel Active="true" Style="width:100%" Header="案件信息摘要">
         <div>
             <Row>
@@ -15,6 +17,7 @@
             </Row>
         </div>
     </Panel>
+    }
     <Panel Active="true" Header="@($"{@_Model.AppealRecord.Creater.Name}与{@_Model.AppealRecord.CreateTime.ToString("yyyy-MM-dd")}提交如下审核内容")">
         @*<Row>
             <AntDesign.Col Span="4"><b>提交人:</b></AntDesign.Col>

+ 2 - 0
wispro.sp.web/Models/ReviewerAppealModel.cs

@@ -100,6 +100,8 @@ namespace wispro.sp.web.Models
             }
 
             
+
+            
         }
 
     }

+ 6 - 4
wispro.sp.web/Pages/AppCase/MyCaselist.razor.cs

@@ -227,15 +227,17 @@ namespace wispro.sp.web.Pages.AppCase
         }
 
         #region 特殊绩效字段选择框变更时处理代码
-        void SelectChanged(Reason  value)
+        async void SelectChanged(Reason  value)
         {
             if (!_loading && EditingItem != null)
             {
 
-                var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
-                EditingItem = null;
+                var respone =await _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
+                EditingItem = await _ItemService.GetPerformancItem(EditingItem.Id) ;
                 _ = RefreshMyStatistics();
-                table.ReloadData();
+                StateHasChanged();
+                EditingItem = null;
+                //table.ReloadData();
             }
         }
 

+ 4 - 4
wispro.sp.web/Pages/Welcome.razor

@@ -61,12 +61,12 @@
                                             {
                                                 if (context.CreaterId == _CurrentUser.Userid)
                                                 {
-                                                    <span>(@context.Reviewer.Name 在 @context.ReviewTime.Value.ToFriendlyDisplay() 审核了你提交的 @context.Item.CaseNo @context.Type.Name")</span> }
+                                            <span>(@context.Reviewer.Name 在 @context.ReviewTime.Value.ToFriendlyDisplay() 审核了你提交的 @(context.Item==null?"":context.Item.CaseNo) @context.Type.Name")</span> }
                                                 else
                                                 {
                                                     if (context.ReviewerId != _CurrentUser.Userid)
                                                     {
-                                                    <span>(您在 @context.CreateTime.ToFriendlyDisplay()提交的 @context.Item.CaseNo @context.Type.Name,@context.Reviewer.Name 已于 @context.ReviewTime.Value.ToFriendlyDisplay() 审核完成"</span> 
+                                                    <span>(您在 @context.CreateTime.ToFriendlyDisplay()提交的 @(context.Item==null?"":context.Item.CaseNo) @context.Type.Name,@context.Reviewer.Name 已于 @context.ReviewTime.Value.ToFriendlyDisplay() 审核完成"</span> 
                                                     }
                                                 }
                                             }
@@ -74,10 +74,10 @@
                                             {
                                                 if (context.CreaterId == _CurrentUser.Userid)
                                                 {
-                                                    <span>您在 @context.CreateTime.ToFriendlyDisplay() 提交的 @context.Item.CaseNo @context.Type.Name ,正在等待 @context.Reviewer.Name 审核!"</span>}
+                                        <span>您在 @context.CreateTime.ToFriendlyDisplay() 提交的 @(context.Item==null?"":context.Item.CaseNo) @context.Type.Name ,正在等待 @context.Reviewer.Name 审核!"</span>}
                                                 else
                                                 {
-                                                    <span>@context.Creater.Name 在 @context.CreateTime.ToFriendlyDisplay() 提交的 @context.Item.CaseNo @context.Type.Name ,请您尽快<Button Danger Type="@ButtonType.Link" OnClick="()=>ShowModel(context)">审核</Button>!</span>
+                                        <span>@context.Creater.Name 在 @context.CreateTime.ToFriendlyDisplay() 提交的 @(context.Item==null?"":context.Item.CaseNo) @context.Type.Name ,请您尽快<Button Danger Type="@ButtonType.Link" OnClick="()=>ShowModel(context)">审核</Button>!</span>
                                                 }
                                                                                 
                                             }

+ 44 - 31
wispro.sp.web/Pages/Welcome.razor.cs

@@ -52,22 +52,26 @@ namespace wispro.sp.web.Pages
                 AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
                 if (AppealRecords != null)
                 {
-                    //_user = await _userService.GetUser();
-                    AppealRecords.Sort((a, b) =>
-                    {
-                        var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
-                        var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
-
-                        if (ed > sd)
-                        {
-                            return 1;
-                        }
-                        else
-                        {
-                            return -1;
-                        }
-
-                    });
+                    //try
+                    //{
+                    //    //_user = await _userService.GetUser();
+                    //    //AppealRecords.Sort((a, b) =>
+                    //    //{
+                    //    //    var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
+                    //    //    var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
+
+                    //    //    if (ed > sd)
+                    //    //    {
+                    //    //        return 1;
+                    //    //    }
+                    //    //    else
+                    //    //    {
+                    //    //        return -1;
+                    //    //    }
+
+                    //    //});
+                    //}
+                    //catch { }
                 }
             }
             else
@@ -85,6 +89,8 @@ namespace wispro.sp.web.Pages
             var templateOptions = new Models.ReviewerAppealModel();
             await templateOptions.Init(_atService, appealRecord.Id);
 
+            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions));
+
             var modalConfig = new ModalOptions();
             modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
             modalConfig.Width = 650;
@@ -109,21 +115,28 @@ namespace wispro.sp.web.Pages
                     await _modalRef.CloseAsync();
 
                     AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
-                    AppealRecords.Sort((a, b) =>
-                    {
-                        var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
-                        var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
-
-                        if (ed > sd)
-                        {
-                            return 1;
-                        }
-                        else
-                        {
-                            return -1;
-                        }
-
-                    });
+                    //AppealRecords.Sort((a, b) =>
+                    //{
+                    //    try
+                    //    {
+                    //        var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
+                    //        var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
+
+                    //        if (ed > sd)
+                    //        {
+                    //            return 1;
+                    //        }
+                    //        else
+                    //        {
+                    //            return -1;
+                    //        }
+                    //    }
+                    //    catch
+                    //    {
+                    //        return 0;
+                    //    }
+
+                    //});
 
                     StateHasChanged();
 

+ 1 - 1
wispro.sp.web/Services/AgentFeedbackMemoItemsServices.cs

@@ -73,7 +73,7 @@ namespace wispro.sp.web.Services
             new Reason(){Name="中-英",Value="中-英",Expresses= new List<string>(){ "p.DoItem==\"新申请\"" , "p.DoItem==\"翻译\"" } },
             new Reason(){Name="英-中",Value="英-中",Expresses= new List<string>(){ "p.DoItem==\"新申请\"" , "p.DoItem==\"翻译\"" }},
             new Reason(){Name="英-德",Value="英-德",Expresses= new List<string>(){ "p.DoItem==\"新申请\"" , "p.DoItem==\"翻译\"" }},
-            new Reason(){Name="已算绩效",Value="已算绩效",Expresses= new List<string>(){ "p.DoItem==\"新申请\"" , "p.DoItem==\"翻译\"" }}
+            new Reason(){Name="已算绩效",Value="已算绩效",Expresses= new List<string>(){ "p.DoItem==\"新申请\"" , "p.DoItem==\"翻译\"", "p.DoItem==\"处理审查意见\""  }}
         };
 
         public List<Reason> GetItems(PerformanceItem item)

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

@@ -36,6 +36,12 @@ namespace wispro.sp.web.Services
             return data;
         }
 
+        public async Task<PerformanceItem> GetPerformancItem(int Id)
+        {
+            PerformanceItem data = await _httpClient.Get<PerformanceItem>($"PerformanceItem/Get?Id={Id}");
+            return data;
+        }
+
         public async Task<ListApiResponse<PerformanceItem>> GetMyList(int userid,jxType type,int pageIndex=1,int pageSize=5)
         {
             ListApiResponse<PerformanceItem> data = await _httpClient.Get<ListApiResponse<PerformanceItem>>($"PerformanceItem/GetMyList?userid={userid}&Type={Convert.ToInt32(type)}&pageIndex={pageIndex}&pageSize={pageSize}");

+ 2 - 0
wispro.sp.web/Utils/JwtPaser.cs

@@ -43,11 +43,13 @@ namespace wispro.sp.web.Utils
 
         private static byte[] ParseBase64WithoutPadding(string base64)
         {
+            base64 = base64.Replace('-', '+').Replace('_', '/');
             switch (base64.Length % 4)
             {
                 case 2: base64 += "=="; break;
                 case 3: base64 += "="; break;
             }
+            Console.WriteLine(base64);
             return Convert.FromBase64String(base64);
         }
     }

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

@@ -39,7 +39,7 @@ namespace wispro.sp.entity
 
         public int TypeId { get; set; }
 
-        public int ItemId { get; set; }
+        public int? ItemId { get; set; }
 
         public virtual PerformanceItem Item { get; set; }
     }

+ 15 - 0
wospro.sp.entity/AppealType.cs

@@ -34,5 +34,20 @@ namespace wispro.sp.entity
         public int Type { get; set; }
 
         
+        /// <summary>
+        /// 是否需要审核
+        /// </summary>
+        public bool NeedReview { get; set; }
+
+        /// <summary>
+        /// 申诉处理对象
+        /// </summary>
+        public string ApplealObject { get; set; }
+
+        /// <summary>
+        /// 审核处理对象
+        /// </summary>
+        public string ReviewObject { get; set; }
+        
     }
 }

+ 8 - 2
wospro.sp.entity/workflowDefine/ConditionTree.cs

@@ -77,9 +77,9 @@ namespace wispro.sp.entity.workflowDefine
     {
         [Description("用户输入值")]
         ActionInputValue,
-        [Description("用户操作")]
+        [Description("完成操作")]
         DoAction,
-        [Description("绑定对象属性值")]
+        [Description("流程对象属性")]
         BindObjectProperty,
         [Description("流程操作用户")]
         DoActionUser
@@ -146,6 +146,12 @@ namespace wispro.sp.entity.workflowDefine
         public FieldType FieldType { get; set; }
     }
 
+    public class ActionFinished : ConditionTreeNode
+    {
+        public int ActionId { get; set; }
+    }
+
+
     public class UserFieldNode : ConditionTreeNode
     {
         public UserField Field { get; set; }