Parcourir la source

添加文件比较模块之查询是否存在某个案号
添加其他新申请案件绩效分配报表
修正前一版本前台权限判断Bug
重构测试Form程序

luocaiyang il y a 9 mois
Parent
commit
0146894d1a

+ 53 - 0
wispro.sp.api/Controllers/CaseFileCompareController.cs

@@ -8,10 +8,13 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq.Expressions;
+using System.Text.RegularExpressions;
+using wispro.sp.api.AppealHandler;
 using wispro.sp.api.Services;
 using wispro.sp.entity;
 using wispro.sp.entity.CompareCase;
 using wispro.sp.share;
+using static OneOf.Types.TrueFalseOrNull;
 
 namespace wispro.sp.api.Controllers
 {
@@ -237,6 +240,56 @@ namespace wispro.sp.api.Controllers
             return ret;
         }
 
+        public bool CaseExist(string caseNo)
+        {
+            return Context.CaseInfos.Where(p => p.CaseNo == caseNo.Trim()).Count() > 0;
+        }
+
+        public IList<Object> CalMean_Std(DateTime start,DateTime end)
+        {
+
+            double AverageA = Context.CaseInfos.Where<CaseInfo>(
+                p => p.FinalVersionDate >= start && p.FinalVersionDate <= end && p.DRRCalim!= null)
+                .Average(x=>x.DRRCalim.TextSimilarity);
+               
+            double AverageB = Context.CaseInfos.Where<CaseInfo>(
+                p => p.FinalVersionDate >= start && p.FinalVersionDate <= end && p.RFRAll != null)
+                .Average(x => x.RFRAll.TextSimilarity);
+
+            double stdA = Math.Sqrt( Context.CaseInfos.Where<CaseInfo>(
+                p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
+                .Average((x => (x.DRRCalim.TextSimilarity - AverageA) * (x.DRRCalim.TextSimilarity - AverageA))));
+                
+
+            double stdB = Math.Sqrt(Context.CaseInfos.Where<CaseInfo>(
+                p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
+                .Average((x => (x.RFRAll.TextSimilarity - AverageB) * (x.RFRAll.TextSimilarity - AverageB))));
+
+            var response2 = Context.CaseInfos.Where<CaseInfo>(
+                p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
+                .Include(p=>p.DRRCalim)
+                .Include(p=>p.RFRAll);
+            
+            IList<Object> results = new List<Object>();
+            foreach(var item in response2.ToList())
+            {
+                results.Add(
+                    new { 
+                        Id = item.Id,
+                        CaseNo = item.CaseNo,
+                        CaseName = item.CaseName,
+                        Customer = item.Customer,
+                        Reviewer = item.Reviewer,
+                        Handlers = item.Handlers,
+                        zScoreA = (item.DRRCalim?.TextSimilarity -AverageA)/stdA,
+                        zScoreB = (item.RFRAll?.TextSimilarity - AverageB) / stdB
+                    }    
+                );
+            }
+
+            return results;
+
+        }
         private string GetExpress(IList<FieldCondition> conditions)
         {
             string str = "";

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

@@ -859,6 +859,77 @@ namespace wispro.sp.api.Controllers
 
             return null;
         }
+
+        [Authorize]
+        public FileProcessTask GetOtherNewCaseAllocationReport(int Year, int Month)
+        {
+            CalMonth calMonth = Context.CalMonths.FirstOrDefault(c => c.Year == Year && c.Month == Month);
+            if (calMonth != null)
+            {
+                var filename = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}-{calMonth.Year}{calMonth.Month}其它新申请代理人案件绩效金额清单.xlsx";
+                var attachfileSavePath = utility.ConfigHelper.GetSectionValue("AttachFileSavePath");
+                var filePath = Path.Combine(attachfileSavePath, filename);
+
+                var fileTask = new FileProcessTask()
+                {
+                    Id = Guid.NewGuid().ToString(),
+                    FileName = filename,
+                    FilePath = filePath,
+                    Processed = 0
+                };
+
+                fileTaskService.Add(fileTask);
+
+                ExportDataResult result = new ExportDataResult()
+                {
+                    fileTask = fileTask,
+                    calMonth = calMonth
+                };
+
+                System.Threading.Thread t = new System.Threading.Thread(new ParameterizedThreadStart(_GetOtherNewCaseAllocationReport));
+                t.Start(result);
+
+                return fileTask;
+            }
+
+            return null;
+        }
+
+        private void _GetOtherNewCaseAllocationReport(object exportDataResult)
+        {
+            ExportDataResult result = (ExportDataResult)exportDataResult;
+            FileProcessTask file = result.fileTask;
+            CalMonth calMonth = result.calMonth;
+
+            //var StatisticsResults = _CalMyStatistics(calMonth);
+            string strSQL = @" SELECT Staff.Name as 姓名, CaseNo as 我方案号,CaseName as 案件名称,Type as 案件类型,CaseCoefficient as 案件系数,[Ratio] as 分配比率
+                  ,[ActualAmount] as 绩效金额
+                  FROM [spDB].[dbo].[AllocationRatio],
+                  performanceItem,staff
+                  where Staff.Id = AllocationRatio.PersonId and PerformanceItem.Id= AllocationRatio.ItemId
+                  and ItemId in (select id from PerformanceItem where CalMonthId in (select id from CalMonth where year =@year and month=@month))
+                  order by CaseNo";
+
+            DataTable dt = new DataTable();
+            spDbContext spDb = new spDbContext();
+            using (var conn = spDb.Database.GetDbConnection())
+            {
+                conn.Open();
+                var cmd = conn.CreateCommand();
+                cmd.CommandText = strSQL;
+                cmd.CommandType = CommandType.Text;
+
+                cmd.Parameters.Add(new SqlParameter("year", calMonth.Year));
+                cmd.Parameters.Add(new SqlParameter("month", calMonth.Month));
+                using (var reader = cmd.ExecuteReader())
+                {
+                    dt.Load(reader);
+                }
+            }
+
+            NPOIExcel.DataTableToExcel(dt, result.fileTask.FilePath);
+            result.fileTask.Finished = true;
+        }
         private void ExportStaticPointReport(object exportDataResult)
         {
             ExportDataResult result = (ExportDataResult)exportDataResult;

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

@@ -135,6 +135,16 @@ RenderFragment gdIcon =
                                                 <Button Icon="download" Type="@ButtonType.Text" OnClick="() => ExportJXPointAsync(HandlingCalMonth)">导出案件绩效点数报表</Button>
                                             }
                                          </MenuItem>
+                                         <MenuItem>
+                                            @if (isDownloading)
+                                            {
+                                                <Button Icon="download" Type="@ButtonType.Text" Loading>导出其他新申请案件绩效分配报表</Button>
+                                            }
+                                            else
+                                            {
+                                                <Button Icon="download" Type="@ButtonType.Text" OnClick="() => ExportJXMoneyAsync(HandlingCalMonth)">导出其他新申请案件绩效分配报表</Button>
+                                            }
+                                         </MenuItem>
                                         <MenuItem>
                                             @if (isDownloading)
                                             {

+ 19 - 1
wispro.sp.web/Pages/AppCase/CaseManager.razor.cs

@@ -207,7 +207,25 @@ namespace wispro.sp.web.Pages.AppCase
 
         }
 
-        
+        private async Task ExportJXMoneyAsync(CalMonth calMonth)
+        {
+            isDownloading = true;
+            var fileData = await _ItemService.ExportJXMoneyAsync(calMonth.Year, calMonth.Month);
+
+            while (!fileData.Finished)
+            {
+                fileData = await _ItemService.getExportDataProcessing(fileData.Id);
+                await Task.Delay(20);
+            }
+
+            NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
+
+            isDownloading = false;
+
+        }
+
+
+
 
         private async Task ExportCCSDataAsync(CalMonth calMonth)
         {

+ 13 - 2
wispro.sp.web/Services/AuthService.cs

@@ -105,6 +105,17 @@ namespace wispro.sp.web.Services
             }
             else
             {
+                //Console.WriteLine($"userId:{_user.Userid}");
+                //foreach(var uRole in _user.Roles)
+                //{
+                //    Console.Write(uRole.ToString() + ",");
+                //}
+
+                //foreach (var role in Roles)
+                //{
+                //    Console.Write(role.ToString() + ",");
+                //}
+
                 if (Roles.Contains(_user.Userid?.ToString()))
                 {
                     canVisist = true;
@@ -115,8 +126,8 @@ namespace wispro.sp.web.Services
                     {
                         foreach (var role in Roles)
                         {
-                            Console.WriteLine($"user:{uRole},{role}");
-                            if (uRole == role)
+                            //Console.WriteLine($"user:{uRole},{role}");
+                            if (uRole.Contains(role))
                             {
                                 canVisist = true;
                                 break;

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

@@ -76,10 +76,17 @@ namespace wispro.sp.web.Services
         
         public async Task<FileProcessTask> ExportJXPointReport(int Year, int month)
         {
+            
             var fileData = await _httpClient.Get<FileProcessTask>($"PerformanceItem/GetStaticsPointReport?Year={Year}&Month={month}");
             return fileData;
         }
 
+        public async Task<FileProcessTask> ExportJXMoneyAsync(int Year, int month)
+        {
+            var fileData = await _httpClient.Get<FileProcessTask>($"PerformanceItem/GetOtherNewCaseAllocationReport?Year={Year}&Month={month}");
+            return fileData;
+        }
+
         public async Task<FileProcessTask> CurrentData2Excel(CalMonth calMonth)
         {
             var fileData = await _httpClient.Get<FileProcessTask>($"PerformanceItem/CurrentData2Excel?Year={calMonth.Year}&Month={calMonth.Month}");

+ 174 - 0
wispro.sp.winClient/APIService.cs

@@ -0,0 +1,174 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text;
+using System.Threading.Tasks;
+using wispro.sp.entity.CompareCase;
+using wispro.sp.share.webViewObject;
+using wispro.sp.share;
+using wispro.sp.utility;
+
+namespace wispro.sp.winClient
+{
+    public class APIService
+    {
+        string strAPIBaseUri = ConfigHelper.GetSectionValue("APIBaseUri");
+
+        private HttpClient CreateHttp()
+        {
+            HttpClientHandler clientHandler = new HttpClientHandler();
+            clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
+
+            return new HttpClient(clientHandler) { Timeout=TimeSpan.FromMinutes(2)};
+
+        }
+
+        private async Task<userToken> Login()
+        {
+            share.webViewObject.loginDto dto = new share.webViewObject.loginDto();
+            dto.Name = "caiyangl";
+            dto.Password = "Lqftiu807005";
+            try
+            {
+                var response = await CreateHttp().PostAsJsonAsync<loginDto>($"{strAPIBaseUri}/api/account/Login", dto);
+
+                if (response.IsSuccessStatusCode)
+                {
+                    userToken? Token = await response.Content.ReadFromJsonAsync<userToken>();
+                    return Token;
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            catch (Exception ex)
+            {
+                return null;
+            }
+
+        }
+
+        /// <summary>
+        /// 保存CaseInfo新型
+        /// </summary>
+        /// <param name="caseinfo"></param>
+        /// <returns></returns>
+        public async Task<bool> SaveCompareResult(CaseInfo caseinfo)
+        {
+            userToken? Token = await Login();
+
+            if (Token != null)
+            {
+                HttpClient http = CreateHttp();//
+                http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token?.Token);
+                try
+                {
+                    var data = await http.PostAsJsonAsync<CaseInfo>($"{strAPIBaseUri}/api/CaseFileCompare/Save", caseinfo);
+
+                    if (data.IsSuccessStatusCode)
+                    {
+                        var ret = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
+                        if (ret.Success)
+                        {
+                            return true;
+                        }
+                        else
+                        {
+                            throw new Exception(ret.ErrorMessage);
+                        }
+
+                    }
+                    else
+                    {
+                        return false;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    return false;
+                }
+
+            }
+
+            return false;
+        }
+
+        public async Task<List<Object>> CalZScore()
+        {
+            userToken? Token = await Login();
+            if (Token != null)
+            {
+                HttpClient http = CreateHttp();
+                http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token?.Token);
+                try
+                {
+                    var data = await http.GetAsync($"{strAPIBaseUri}/api/CaseFileCompare/CalMean_Std?start=2024-10-01&end=2024-12-01");
+
+                    if (data.IsSuccessStatusCode)
+                    {
+                        var ret = await data.Content.ReadFromJsonAsync<IList<Object>>();
+                        if (ret != null)
+                        {
+                            return (List<object>)ret;
+                        }
+
+                    }
+                    else
+                    {
+                        return null;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+
+            }
+
+            return null;
+        }
+
+        public async Task<bool> CaseExist(string caseNo)
+        {
+            userToken? Token = await Login();
+
+            if (Token != null)
+            {
+                HttpClient http = CreateHttp();
+
+                http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token?.Token);
+                try
+                {
+                    var data = await http.GetAsync($"{strAPIBaseUri}/api/CaseFileCompare/CaseExist?CaseNo={caseNo}");
+
+                    if (data.IsSuccessStatusCode)
+                    {
+                        
+                        bool? ret = await data.Content.ReadFromJsonAsync<bool>();
+                        if (ret != null)
+                        {
+                            return (bool)ret;
+                        }
+
+                    }
+                    else
+                    {
+                        return false;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+
+            }
+
+            return false;
+
+        }
+        
+    }
+}

+ 86 - 0
wispro.sp.winClient/ExtractFile.cs

@@ -0,0 +1,86 @@
+using SharpCompress.Archives;
+using SharpCompress.Archives.Rar;
+using SharpCompress.Common;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.winClient
+{
+    public class ExtractFileUtil
+    {
+
+        
+        public static void ExtractZip(string zipFilePath, string extractPath)
+        {
+            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+            // 确保提取目录存在
+            Directory.CreateDirectory(extractPath);
+
+            // 使用 ZipArchive 解压缩 ZIP 文件
+            using (FileStream zipToOpen = new FileStream(zipFilePath, FileMode.Open))
+            {
+                using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Read, true, Encoding.GetEncoding("GB2312")))
+                {
+                    foreach (ZipArchiveEntry entry in archive.Entries)
+                    {
+                        if (entry.FullName.EndsWith("/", StringComparison.Ordinal) || entry.FullName.EndsWith("\\", StringComparison.Ordinal))
+                        {
+                            Console.WriteLine($"目录: {entry.FullName}");
+                        }
+                        else
+                        {
+                            string entryPath = Path.Combine(extractPath, entry.FullName);
+
+                            Directory.CreateDirectory(new System.IO.FileInfo(entryPath).Directory.FullName);
+                            entry.ExtractToFile(entryPath, true);
+                        }
+                    }
+                }
+            }
+        }
+
+        public static void ExtractRarFile(string rarPath, string outputPath)
+        {
+            try
+            {
+                // 确保输出目录存在
+                Directory.CreateDirectory(outputPath);
+
+                // 打开RAR文件
+                using (var archive = RarArchive.Open(rarPath))
+                {
+                    // 遍历所有文件
+                    foreach (var entry in archive.Entries)
+                    {
+                        if (!entry.IsDirectory)
+                        {
+                            // 构建完整输出路径
+                            string outputFilePath = Path.Combine(outputPath, entry.Key);
+
+                            // 确保输出文件的目录存在
+                            Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath));
+
+                            // 解压文件
+                            entry.WriteToFile(outputFilePath, new ExtractionOptions
+                            {
+                                ExtractFullPath = true,
+                                Overwrite = true
+                            });
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                throw new Exception($"解压RAR文件时出错: {ex.Message}");
+            }
+        }
+
+
+    }
+}

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

@@ -1417,30 +1417,7 @@ namespace wispro.sp.winClient
             sw.Dispose();
         }
 
-        private async void button8_ClickAsync(object sender, EventArgs e)
-        {
-            //var caseInfo= IPEasyUtility.GetCaseInfo("PAEPO2213258-标准A+级-结案");
-            IPEasyUtility.GetPerformanceRecord("PAEPO2213258-标准A+级-结案", "欧洲案答辩");
-            return;
-
-            var downloader = new IPEasyDownloader();
-            downloader.login("caiyangl","j)wx*lier*@3");
-            downloader.Search("PACN2023");
-            return;
-            //await RefreshPerformanceItem(1);
-
-            //await RefreshPerformanceItem(2);
-
-            //await RefreshPerformanceItem(3);
-            for (int i=0; i<10; i++)
-            {
-                save(i);
-            }
-
-            System.Diagnostics.Debug.WriteLine(getInt().ToString());
-
-        }
-
+        
         private async void button9_Click(object sender, EventArgs e)
         {
             if (Token == null)

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 67
wispro.sp.winClient/IPEasyDownloader.cs


+ 3 - 1
wispro.sp.winClient/appsettings.json

@@ -16,5 +16,7 @@
     "mail": "luocaiyang@china-wispro.com"
 
   },
-  "InvalidDataMessageMails":"罗才洋|luocaiyang@china-wispro.com,何青瓦|heqingwa@china-wispro.com,钟子敏|zhongzimin@china-wispro.com,吴芳|wufang@china-wispro.com,邢丽霞|xinglixia@china-wispro.com,田婵玉|tianchanyu@china-wispro.com,周珊珊|zhoushanshan@china-wispro.com"
+  "InvalidDataMessageMails": "罗才洋|luocaiyang@china-wispro.com,何青瓦|heqingwa@china-wispro.com,钟子敏|zhongzimin@china-wispro.com,吴芳|wufang@china-wispro.com,邢丽霞|xinglixia@china-wispro.com,田婵玉|tianchanyu@china-wispro.com,周珊珊|zhoushanshan@china-wispro.com",
+  "APIBaseUri": "http://1.116.113.26:81"
+
 }

+ 1 - 1
wispro.sp.winClient/frmCaseFileCompare.Designer.cs

@@ -100,7 +100,7 @@
             button2.Name = "button2";
             button2.Size = new System.Drawing.Size(204, 42);
             button2.TabIndex = 7;
-            button2.Text = "button2";
+            button2.Text = "绩效测试";
             button2.UseVisualStyleBackColor = true;
             button2.Click += button2_Click;
             // 

+ 100 - 207
wispro.sp.winClient/frmCaseFileCompare.cs

@@ -38,62 +38,7 @@ namespace wispro.sp.winClient
         {
 
         }
-
-        private HttpClient CreateHttp()
-        {
-            HttpClientHandler clientHandler = new HttpClientHandler();
-            clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
-
-            return new HttpClient(clientHandler);
-
-        }
-
-        string strAPIBaseUri = "http://localhost:39476";
-        private async Task<bool> SaveCompareResult(CaseInfo caseinfo)
-        {
-            share.webViewObject.loginDto dto = new share.webViewObject.loginDto();
-            dto.Name = "caiyangl";
-            dto.Password = "Lqftiu807005";
-
-            var response = await CreateHttp().PostAsJsonAsync<loginDto>($"{strAPIBaseUri}/api/account/Login", dto);
-
-            if (response.IsSuccessStatusCode)
-            {
-                userToken? Token = await response.Content.ReadFromJsonAsync<userToken>();
-
-                HttpClient http = CreateHttp();//
-                http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token?.Token);
-                try
-                {
-                    var data = await http.PostAsJsonAsync<CaseInfo>($"{strAPIBaseUri}/api/CaseFileCompare/Save", caseinfo);
-
-                    if (data.IsSuccessStatusCode)
-                    {
-                        var ret = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
-                        if(ret.Success)
-                        {
-                            return true;
-                        }
-                        else
-                        {
-                            throw new Exception(ret.ErrorMessage);
-                        }
-                        
-                    }
-                    else
-                    {
-                        return false;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    return false;
-                }
-
-            }
-
-            return false;
-        }
+        
 
         private CaseInfo getCaseInfo_files(string caseNo,out string draftFile,out string returnFile,out string finalFile)
         {
@@ -174,7 +119,7 @@ namespace wispro.sp.winClient
 
         }
 
-        private void compareCaseFile()
+        private async Task compareCaseFile()
         {
             DataTable table = wispro.sp.utility.IPEasyUtility.GetFinished3FilesCases(1);
 
@@ -192,19 +137,28 @@ namespace wispro.sp.winClient
                     string finalFile =string.Empty;
 
                     string CaseNo = row["我方文号"].ToString();
+
+                    var isExistResp = new APIService().CaseExist(CaseNo);
+
+                    isExistResp.Wait();
+
+                    if (isExistResp.Result)
+                    {
+                        continue;
+                    }
+
                     CaseInfo caseInfo = getCaseInfo_files(CaseNo, out draftFile,out returnFile, out finalFile);
-                   
                     
 
-                    int i = (string.IsNullOrEmpty(draftFile) ? 1 : 0) +
-                        (string.IsNullOrEmpty(returnFile) ? 1 : 0) +
-                        (string.IsNullOrEmpty(finalFile) ? 1 : 0);
+                    int i = (string.IsNullOrEmpty(draftFile) ? 0 : 1) +
+                        (string.IsNullOrEmpty(returnFile) ? 0 : 1) +
+                        (string.IsNullOrEmpty(finalFile) ? 0 : 1);
 
                     if (i > 1)
                     {
                         CompareFiles(draftFile, returnFile, finalFile, caseInfo);
 
-                        SaveCompareResult(caseInfo);
+                        await new APIService().SaveCompareResult(caseInfo);
 
                     }
 
@@ -304,20 +258,66 @@ namespace wispro.sp.winClient
 
         }
 
-        private string ExtractFile(string file,int type,string strExtractPath)
+        
+        CaseInfo caseInfo;
+        private void button1_Click(object sender, EventArgs e)
+        {
+            if (string.IsNullOrEmpty(this.txtCaseNo.Text))
+            {
+                if (MessageBox.Show("获取前一天所有的完成案件,并比较文档?", "提示框", MessageBoxButtons.YesNo) == DialogResult.Yes)
+                {
+                    compareCaseFile();
+                    return;
+                }
+                else
+                {
+                    MessageBox.Show("请输入案号!", "提示框", MessageBoxButtons.OK);
+                    this.txtCaseNo.Focus();
+                    return;
+                }
+            }
+            else
+            {
+                #region 获取文本框中输入的案件,并比较三个文件
+                string draftFile = string.Empty;
+                string finalFile = string.Empty;
+                string returnFile = string.Empty;
+                caseInfo = getCaseInfo_files(txtCaseNo.Text.Trim(), out draftFile, out returnFile, out finalFile);
+
+                int i = (string.IsNullOrEmpty(draftFile) ? 0 : 1) +
+                            (string.IsNullOrEmpty(returnFile) ? 0 : 1) +
+                            (string.IsNullOrEmpty(finalFile) ? 0 : 1);
+
+                if (i > 1)
+                {
+                    CompareFiles(draftFile, returnFile, finalFile, caseInfo);
+
+                    for (int k = 0; k < 1; k++)
+                    {
+                        new APIService().SaveCompareResult(caseInfo);
+                    }
+
+                }
+
+                comboBox1.SelectedIndex = 0;
+                #endregion
+            }
+
+        }
+
+        private static string ExtractFile(string file, int type, string strExtractPath)
         {
-            
             if (file.ToLower().EndsWith(".zip") || file.ToLower().EndsWith(".rar"))
             {
-                string extractPath = Path.Combine(strExtractPath, file.Substring(0,file.Length-4));
+                string extractPath = Path.Combine(strExtractPath, file.Substring(0, file.Length - 4));
 
                 if (file.ToLower().EndsWith(".zip"))
                 {
-                    ExtractZip(file, extractPath);
+                    ExtractFileUtil.ExtractZip(file, extractPath);
                 }
                 else
                 {
-                    ExtractRarFile(file, extractPath);
+                    ExtractFileUtil.ExtractRarFile(file, extractPath);
                 }
 
                 foreach (string f in Directory.GetFiles(extractPath, "*.*", SearchOption.AllDirectories))
@@ -343,7 +343,7 @@ namespace wispro.sp.winClient
                             }
                             break;
                     }
-                    
+
                 }
 
                 return null;
@@ -354,108 +354,6 @@ namespace wispro.sp.winClient
             }
         }
 
-        CaseInfo caseInfo;
-        private void button1_Click(object sender, EventArgs e)
-        {
-            //compareCaseFile();
-            //return;
-            if (string.IsNullOrEmpty(this.txtCaseNo.Text))
-            {
-                MessageBox.Show("请输入案号!", "提示框", MessageBoxButtons.OK);
-                this.txtCaseNo.Focus();
-                return;
-            }
-
-            string draftFile = string.Empty;
-            string finalFile = string.Empty;
-            string returnFile = string.Empty;
-            caseInfo = getCaseInfo_files(txtCaseNo.Text.Trim(), out draftFile, out returnFile, out finalFile);
-
-            int i = (string.IsNullOrEmpty(draftFile) ? 0 : 1) +
-                        (string.IsNullOrEmpty(returnFile) ? 0 : 1) +
-                        (string.IsNullOrEmpty(finalFile) ? 0 : 1);
-
-            if (i > 1)
-            {
-                CompareFiles(draftFile, returnFile, finalFile, caseInfo);
-
-                for (int k = 0; k < 10; k++)
-                {
-                    SaveCompareResult(caseInfo);
-                }
-
-            }
-            
-            comboBox1.SelectedIndex = 0;
-
-        }
-
-        private void ExtractZip(string zipFilePath, string extractPath)
-        {
-            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
-            // 确保提取目录存在
-            Directory.CreateDirectory(extractPath);
-
-            // 使用 ZipArchive 解压缩 ZIP 文件
-            using (FileStream zipToOpen = new FileStream(zipFilePath, FileMode.Open))
-            {
-                using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Read, true, Encoding.GetEncoding("GB2312")))
-                {
-                    foreach (ZipArchiveEntry entry in archive.Entries)
-                    {
-                        if (entry.FullName.EndsWith("/", StringComparison.Ordinal) || entry.FullName.EndsWith("\\", StringComparison.Ordinal))
-                        {
-                            Console.WriteLine($"目录: {entry.FullName}");
-                        }
-                        else
-                        {
-                            string entryPath = Path.Combine(extractPath, entry.FullName);
-
-                            Directory.CreateDirectory(new System.IO.FileInfo(entryPath).Directory.FullName);
-                            entry.ExtractToFile(entryPath, true);
-                        }
-                    }
-                }
-            }
-        }
-
-        public static void ExtractRarFile(string rarPath, string outputPath)
-        {
-            try
-            {
-                // 确保输出目录存在
-                Directory.CreateDirectory(outputPath);
-
-                // 打开RAR文件
-                using (var archive = RarArchive.Open(rarPath))
-                {
-                    // 遍历所有文件
-                    foreach (var entry in archive.Entries)
-                    {
-                        if (!entry.IsDirectory)
-                        {
-                            // 构建完整输出路径
-                            string outputFilePath = Path.Combine(outputPath, entry.Key);
-
-                            // 确保输出文件的目录存在
-                            Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath));
-
-                            // 解压文件
-                            entry.WriteToFile(outputFilePath, new ExtractionOptions
-                            {
-                                ExtractFullPath = true,
-                                Overwrite = true
-                            });
-                        }
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                throw new Exception($"解压RAR文件时出错: {ex.Message}");
-            }
-        }
-
         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
         {
             if (caseInfo != null )
@@ -584,45 +482,40 @@ namespace wispro.sp.winClient
 
         private void button2_Click(object sender, EventArgs e)
         {
-            
             new Form1().ShowDialog();
-            return;
-            var caseInfo = IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件",true);
-            return;
-            var retData = IPEasyUtility.GetFinished3FilesCases(1);
-            return;
             
-            OpenFileDialog openFileDialog = new OpenFileDialog();
-
-            if(openFileDialog.ShowDialog() == DialogResult.OK)
-            {
-                string strPath = openFileDialog.FileName.ToLower().Replace(".rar", "").Replace(".zip","");
-
-                if(openFileDialog.FileName.Contains(".rar"))
-                {
-                    ExtractRarFile(openFileDialog.FileName, strPath);
-                }
-                else
-                {
-                    ExtractZip(openFileDialog.FileName,strPath);
-                }
-                
-
-                string[] files = Directory.EnumerateFiles(strPath, "*.*", SearchOption.AllDirectories).ToArray<string>();
-                Array.Sort(files);
-                Array.Reverse(files);
-                draft_fristReturn = new CompareDocx();
-                draft_fristReturn.Compare(files[0], files[1]);
-
-                if (files.Length > 2)
-                {
-                    fristReturn_Finally = new CompareDocx();
-                    fristReturn_Finally.Compare(files[1], files[2]);
-                }
-
-                SaveResult(strPath,draft_fristReturn);
-                SaveResult(strPath, fristReturn_Finally);
-            }
+            #region 选择文档比较
+            //OpenFileDialog openFileDialog = new OpenFileDialog();
+
+            //if(openFileDialog.ShowDialog() == DialogResult.OK)
+            //{
+            //    string strPath = openFileDialog.FileName.ToLower().Replace(".rar", "").Replace(".zip","");
+
+            //    if(openFileDialog.FileName.Contains(".rar"))
+            //    {
+            //        ExtractFileUtil.ExtractRarFile(openFileDialog.FileName, strPath);
+            //    }
+            //    else
+            //    {
+            //        ExtractFileUtil.ExtractZip(openFileDialog.FileName,strPath);
+            //    }
+
+            //    string[] files = Directory.EnumerateFiles(strPath, "*.*", SearchOption.AllDirectories).ToArray<string>();
+            //    Array.Sort(files);
+            //    Array.Reverse(files);
+            //    draft_fristReturn = new CompareDocx();
+            //    draft_fristReturn.Compare(files[0], files[1]);
+
+            //    if (files.Length > 2)
+            //    {
+            //        fristReturn_Finally = new CompareDocx();
+            //        fristReturn_Finally.Compare(files[1], files[2]);
+            //    }
+
+            //    SaveResult(strPath,draft_fristReturn);
+            //    SaveResult(strPath, fristReturn_Finally);
+            //}
+            #endregion
 
         }
 

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

@@ -8,6 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="Quartz" Version="3.13.1" />
     <PackageReference Include="SharpCompress" Version="0.38.0" />
   </ItemGroup>