Browse Source

优化第一次使用时,下载文件过大导致等待很久的问题
优化计算点数时,点数没变话也会更新数据库的问题

luocaiyang 3 năm trước cách đây
mục cha
commit
df7e4d3cfc

+ 38 - 23
wispro.sp.api/AppealHandler/ChangeDoPersonReviewer.cs

@@ -62,43 +62,58 @@ namespace wispro.sp.api.AppealHandler
                 {
                     var itemStaffs = ((spDbContext)spContext).ItemStaffs.Include(p=>p.DoPerson).Where(s => s.ItemId == appRecord.ItemId.Value);
 
-                    var newStaff = ((spDbContext)spContext).Staffs.FirstOrDefault(s=>s.Name == strNewPerson.Trim());
+                    var oldPersons = strOldPerson.Split(new char[] { ' ', ',' },StringSplitOptions.RemoveEmptyEntries);
+                    var newPersons = strNewPerson.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
+                    
+                    bool oldPersonExist = false;
+                    List<ItemStaff> waitingRemoveObj = new List<ItemStaff>();
 
-                    if (newStaff != null)
+                    foreach (ItemStaff staff in itemStaffs)
                     {
-                        bool oldPersonExist = false;
-                        foreach (ItemStaff staff in itemStaffs)
+                        if (oldPersons.Contains(staff.DoPerson.Name))
                         {
-                            if (staff.DoPerson.Name == strOldPerson.Trim())
-                            {
-                                ((spDbContext)spContext).Staffs.Remove(staff.DoPerson);
-                                oldPersonExist = true;
-                                break;
-                            }
+                            waitingRemoveObj.Add(staff);
+                            
+                            oldPersonExist = true;
+                            
                         }
-
-                        if (oldPersonExist)
+                        else
                         {
-                            ((spDbContext)spContext).ItemStaffs.Add(new ItemStaff() { 
-                                ItemId = appRecord.ItemId.Value,
-                                DoPersonId = newStaff.Id
-                            });
+                            oldPersonExist = false;
+                            break;
                         }
-                        else
+                    }
+
+                    
+
+                    if (oldPersonExist)
+                    {
+                        ((spDbContext)spContext).ItemStaffs.RemoveRange(waitingRemoveObj);
+
+                        foreach (var temName in newPersons)
                         {
-                            throw new ApplicationException("变更前处理人不存在!");
+                            var newStaff = ((spDbContext)spContext).Staffs.FirstOrDefault(s => s.Name == temName.Trim());
+
+                            if (newStaff != null)
+                            {
+                                ((spDbContext)spContext).ItemStaffs.Add(new ItemStaff()
+                                {
+                                    ItemId = appRecord.ItemId.Value,
+                                    DoPersonId = newStaff.Id
+                                });
+                            }
+                            else
+                            {
+                                throw new ApplicationException("变更后处理人不存在!");
+                            }
                         }
                     }
                     else
                     {
-                        throw new ApplicationException("变更后处理人不存在!");
+                        throw new ApplicationException("变更处理人不存在!");
                     }
 
                 }
-
-                
-                //((spDbContext)spContext).PerformanceItems.Add(Item);
-                //((spDbContext)spContext).SaveChanges();
             }
         }
     }

+ 1 - 0
wispro.sp.api/Controllers/AppealController.cs

@@ -215,6 +215,7 @@ namespace wispro.sp.api.Controllers
                         doAppeal.DoAppeal(appealObject, appealRecord.Id,Context);
                     }
 
+                    Context.SaveChanges();
                     t.Commit();
 
                     return response;

+ 22 - 0
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -496,6 +496,7 @@ namespace wispro.sp.api.Controllers
             List<PerformanceItem> ItemList = results
                 .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
                 .Include(pi => pi.Reviewer)
+                .Include(pi => pi.Customer)
                 .OrderByDescending(o => o.Id)
                 .ToList<PerformanceItem>();
 
@@ -581,6 +582,27 @@ namespace wispro.sp.api.Controllers
 
         }
 
+        private void _RefreshBasePoint()
+        {
+            spDbContext spDb = new spDbContext();
+            var lstItem = spDb.PerformanceItems.Include(p => p.Customer).Where(p => p.CalMonth.Status != 4).ToList();
+            var rules = spDb.BasePointRules.ToList();
+            foreach (var item in lstItem)
+            {
+                Utility.Utility.CalBasePoint(item, rules);
+                spDb.SaveChanges();
+            }
+        }
+        public ApiSaveResponse RefreshBasePoint()
+        {
+            System.Threading.Thread t = new Thread(_RefreshBasePoint);
+            t.Start();
+
+            return new ApiSaveResponse() {
+                Success = true
+            };
+        }
+
         private List<StaffStatistics> _calItemJX(CalMonth calMonth, List<VerifyCoefficient> verifyCoefficients, PerformanceItem item,spDbContext spDb)
         {
             System.Collections.Hashtable doPersonsBL = new System.Collections.Hashtable();

+ 6 - 1
wispro.sp.api/Job/GetPerformanceItemJob.cs

@@ -14,7 +14,12 @@ namespace wispro.sp.api.Job
 
             string CaseNo = context.JobDetail.JobDataMap.Get("CaseNo").ToString();
             string DoItem = context.JobDetail.JobDataMap.Get("DoItem").ToString();
-            string caseStage = context.JobDetail.JobDataMap.Get("CaseStage").ToString();
+            string caseStage = null;
+            var temCaseStage = context.JobDetail.JobDataMap.Get("CaseStage");
+            if (temCaseStage != null)
+            {
+                caseStage = temCaseStage.ToString();
+            }
 
             _ = new PerformanceItemController(new spDbContext(),new Services.FileTaskCacheService()).GetItemInfoByCaseStage(CaseNo, DoItem, caseStage);
             return Task.CompletedTask;

+ 28 - 22
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
                 {
@@ -49,36 +49,42 @@ namespace wispro.sp.api.Utility
                         //}
 
                         var target = new Interpreter().SetVariable("p", item);
-                        item.BasePoint = (double?)target.Eval(temString);
+                        double? temPoint = (double?)target.Eval(temString);
+
+                        if(item.BasePoint != temPoint)
+                        {
+                            item.BasePoint = temPoint;
+                        }
+                        
                         item.Type = rule.Type;
                         break;
                     }
                 }
                 catch(Exception ex) {
-                    System.Diagnostics.Debug.WriteLine(ex.Message);
+                    System.Diagnostics.Debug.WriteLine($"{rule.Rule}\t{ex.Message}" );
                 }
             }
             #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;
-
-                    }
-                }
-            }
+            //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)

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

@@ -50,8 +50,11 @@ namespace wispro.sp.web.Pages.AppCase
 
         [Inject] IConfiguration _configuration { get; set; }
 
+        [Inject] protected IAuthService _authService { get; set; }
+
         protected override async Task OnInitializedAsync()
         {
+            await _authService.CanVisitResource();
             await iconService.CreateFromIconfontCN("//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js");
             calMonths  = await _CalMonthService.GetAll();
 

+ 2 - 0
wispro.sp.web/Pages/CustomerList.razor.cs

@@ -27,9 +27,11 @@ namespace wispro.sp.web.Pages
         bool _isAdd = false;
 
         [Inject]OrganizationService  orgService { get; set; }
+        [Inject] protected IAuthService _authService { get; set; }
 
         protected override async System.Threading.Tasks.Task OnInitializedAsync()
         {
+            await _authService.CanVisitResource();
 
             _loading = true;
             _Customers = await  orgService.GetAllCustomer();

+ 6 - 0
wispro.sp.web/wispro.sp.web.csproj

@@ -4,6 +4,8 @@
     <TargetFramework>net5</TargetFramework>
     <RazorLangVersion>3.0</RazorLangVersion>
     <Platforms>AnyCPU;x64;x86</Platforms>
+	<BlazorWebAssemblyLoadAllGlobalizationData>false</BlazorWebAssemblyLoadAllGlobalizationData>
+	<InvariantGlobalization>true</InvariantGlobalization>
   </PropertyGroup>
 
   <ItemGroup>
@@ -91,6 +93,10 @@
     </Content>
   </ItemGroup>
 
+  <ItemGroup>
+    <Folder Include="wwwroot\scripts\" />
+  </ItemGroup>
+
   <ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
 
 </Project>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2288 - 0
wispro.sp.web/wwwroot/decode.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 0
wispro.sp.web/wwwroot/decode.min.js


+ 24 - 2
wispro.sp.web/wwwroot/index.html

@@ -221,14 +221,36 @@
         </div>
     </div>
 
-    <script src="_content/AntDesign.Charts/g2plot.js"></script>
     <script src="_content/AntDesign/js/ant-design-blazor.js"></script>
     <script src="_content/AntDesign.Charts/ant-design-charts-blazor.js"></script>
-    <script src="_framework/blazor.webassembly.js"></script>
+    <script src="_framework/blazor.webassembly.js"  autostart="false"></script>
     <!--<script src="script/helper.js"></script>-->
     <script src="https://d3js.org/d3.v5.min.js"></script>
     <script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
     <script src="https://unpkg.com/d3-graphviz@3.1.0/build/d3-graphviz.js"></script>
+
+    <script type="module">
+        import { BrotliDecode } from './decode.js';
+        Blazor.start({
+            loadBootResource: function (type, name, defaultUri, integrity) {
+                if (type !== 'dotnetjs' && location.hostname !== 'localhost') {
+                    return (async function () {
+                        const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
+                        if (!response.ok) {
+                            throw new Error(response.statusText);
+                        }
+                        const originalResponseBuffer = await response.arrayBuffer();
+                        const originalResponseArray = new Int8Array(originalResponseBuffer);
+                        const decompressedResponseArray = BrotliDecode(originalResponseArray);
+                        const contentType = type ===
+                            'dotnetwasm' ? 'application/wasm' : 'application/octet-stream';
+                        return new Response(decompressedResponseArray,
+                            { headers: { 'content-type': contentType } });
+                    })();
+                }
+            }
+        });
+    </script>
 </body>
 
 </html>

+ 24 - 89
wispro.sp.winClient/Form1.cs

@@ -184,101 +184,15 @@ namespace wispro.sp.winClient
             woman
         }
 
+        
        
         private async void button3_Click(object sender, EventArgs e)
         {
-            await UserField2String();
-            //share.Utility.UserConditionHelper.GetPropertyDescription<Staff>(typeof(PerformanceItem).AssemblyQualifiedName);
-
-            #region Demo流程数据
-            //HttpClient http = new HttpClient();
-            //int wfId = 6;
-            //var workflow = await GetWorkflow(wfId, http);
-            //var Steps = await GetSteps(wfId, http);
-            //var Actions = await GetActions(wfId, http);
-            //var Transfers = await GetTransfers(wfId,http);
-            #endregion
-            //FlowChartUtility flowChart = new FlowChartUtility();
-            //flowChart.workflow = workflow;
-            //flowChart.Steps = Steps;
-            //flowChart.Transfers = Transfers;
-
-            //string strSvg = flowChart.GetSvgString();
-
-            ////var file = System.IO.File.CreateText("c:\\temp\\tem.svg");
-            ////file.WriteLine(strSvg);
-            ////file.Close();
-
-            //System.Xml.XmlDocument xmdoc = new System.Xml.XmlDocument();
-            //xmdoc.LoadXml(strSvg);
-            //Svg.SvgDocument svg = Svg.SvgDocument.Open(xmdoc);
-            //Bitmap bitmap = svg.Draw();
-            //bitmap.Save("c:\\temp\\test.jpg",ImageFormat.Jpeg);
-            //MemoryStream mStream = new MemoryStream();
-            //bitmap.Save(mStream, ImageFormat.Jpeg);
-            //byte[] bitMaps = new byte[mStream.Length];
-            //mStream.Read(bitMaps, 0, (int)mStream.Length);
-
-
-
-            //var test =wispro.sp.utility.EmunHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.LogicSymbols>();
-
-            //Console.WriteLine("");
-            //dynamic dynObj = new ExpandoObject();
-            //dynObj.Name = "名称";
-            //dynObj.Text = "aaabc";
-
-
-            //List<dynamic> list = new List<dynamic>();
-            //for(int i = 0; i < 3; i++)
-            //{
-            //    dynamic d = new ExpandoObject();
-            //    d.Id = i + 1;
-            //    d.Filed1 = $"Field{i}";
-            //    d.Date = DateTime.Now.AddDays(i);
-            //    list.Add(d);
-            //}
-
-            //dynObj.List = list;
-            //var temTxt = System.Text.Json.JsonSerializer.Serialize(dynObj);
-
-            //var dynamic = System.Text.Json.JsonSerializer.Deserialize<ExpandoObject>(temTxt);
-
-
-            //MessageBox.Show(((IDictionary<string, object>)dynamic)["Name"].ToString());
-
-            //wispro.sp.utility.MailUtil.SendEmail("测试邮件标题","测试邮件内容","罗才洋","luocaiyang@139.com");
-            //CreateAppealModel model = new CreateAppealModel();
-            //HttpClient http = new HttpClient();
-            //PerformanceItem item = await http.GetFromJsonAsync<wispro.sp.entity.PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/Get?Id=7341");
-            //List<AppealType> appealTypes = await http.GetFromJsonAsync<List<AppealType>>($"{strAPIBaseUri}/api/Appeal/GetAppealTypes");
-            //var appealType = appealTypes.Where<AppealType>(a => a.Id == 1).FirstOrDefault();
-            //await model.Init(item, appealType);
-            ////await TestQueryFilter();
-            //List<PerformanceItem> retList = new List<PerformanceItem>();
-            //var test= retList.Where<PerformanceItem>(p => p.isDanger());
-
-            //await InitRules(true);
-
-            ////return;
+            await RefreshPerformanceItem();
 
             //await ImportUsers();
             //await InputPerformanceItem("c:\\temp\\21.01-21.11 工程师绩效报表-总表.xlsx", true, false, 0);
 
-            ////CalMonth cal = new CalMonth()
-            ////{
-            ////    Year = 2021,
-            ////    Month = 9,
-            ////    Status = 0
-            ////};
-
-            ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--发客户超过一个月未完成案件.xlsx", true,false,1, cal);
-
-            ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--上个月递交完成案件.xlsx", true, false, 1, cal);
-
-            ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--中国一次OA授权表.xlsx", true, false, 1, cal,true);
-
-            //MessageBox.Show("导入完成!");
         }
 
         private PerformanceItem Row2Item_1(DataRow row, List<Staff> Staffs, CalMonth calMonth)
@@ -620,6 +534,17 @@ namespace wispro.sp.winClient
 
         }
 
+        private async Task RefreshPerformanceItem()
+        {
+            if (Token == null)
+            {
+                await Login();
+            }
+
+            await RefreshItemAsync();
+
+        }
+
         private async Task UserField2String()
         {
             if (Token == null)
@@ -895,7 +820,7 @@ namespace wispro.sp.winClient
             return retStr;
         }
 
-        string strAPIBaseUri = "https://47.106.221.167"; //"http://localhost:39476";//
+        string strAPIBaseUri = "https://47.106.221.167"; // "http://localhost:39476";//
 
         userToken Token;
         public async Task Login()
@@ -1059,6 +984,16 @@ namespace wispro.sp.winClient
 
         }
 
+        private async Task<PerformanceItem> RefreshItemAsync()
+        {
+            HttpClient http = CreateHttp();
+            http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
+            var data = await http.GetFromJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/RefreshBasePoint");
+
+            return data;
+        }
+
+
         private async Task<List<Staff>> getReviewers(int itemId,int appealTypeId)
         {
             HttpClient http = CreateHttp();