Bläddra i källkod

新增关键字搜索功能及优化代码结构

在 GroupsController 中新增 GroupItemKeywordSearch 方法,用于支持关键字搜索组信息;引入 OASystem.RedisRepository 命名空间;调整文件生成逻辑,新增 CreatePolandVisaPdf 方法;修复表单字段 CurrentNationality 的映射问题;扩展 Res_OfficialActivities 中 Job 字段长度至 nvarchar(120);注释掉旧搜索逻辑以便调试新功能;优化代码格式以提升可读性。
Lyyyi 1 dag sedan
förälder
incheckning
5372bbf01b

+ 63 - 25
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -47,6 +47,7 @@ using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
 using OASystem.Infrastructure.Tools;
+using OASystem.RedisRepository;
 using Quartz.Logging;
 using Quartz.Util;
 using SQLitePCL;
@@ -1179,7 +1180,43 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GroupItemKeywordSearch(string keyword)
         {
+            var jw = JsonView(true, "暂无数据");
+            if (string.IsNullOrEmpty(keyword)) return Ok(jw);
 
+            var expression = Expressionable
+                .Create<Grp_DelegationInfo>()
+                .And(x => x.IsDel == 0);
+
+            string field = "TeamName,ClientUnit,ClientName";
+            var groupData = _sqlSugar.Queryable<Grp_DelegationInfo>()
+                .Where(expression.ToExpression())
+                .Select(field)
+                .ToList();
+
+            var keywordArray = keyword.ToCharArray();
+            var matches = groupData
+                .Where(fullString => !string.IsNullOrWhiteSpace(fullString.TeamName) &&
+                        keywordArray.All(keyword => fullString.TeamName.Contains(keyword)))
+                .Select(x => new
+                {
+                    x.TeamName,
+                    x.ClientUnit,
+                    x.ClientName
+                })
+                .DistinctBy(x => x.TeamName)
+                .ToList();
+
+            if (matches.Any())
+            {
+                jw.Code = StatusCodes.Status200OK;
+                jw.Msg = "搜索成功";
+                jw.Data = matches;
+                jw.Count = matches.Count;
+            }
+
+            return Ok(jw);
+
+            #region 智能搜索
             //try
             //{
             //    // 验证请求参数
@@ -1199,7 +1236,7 @@ namespace OASystem.API.Controllers
             //            { "ClientUnit", 8 },
             //            { "ClientName", 6 }
             //        },
-            //        Filters = new List<SearchFilter>() 
+            //        Filters = new List<SearchFilter>()
             //        {
             //            new(){Field = "IsDel",Operator="eq",Value="1" }
             //        },
@@ -1221,7 +1258,7 @@ namespace OASystem.API.Controllers
 
             //    if (result.Success)
             //    {
-            //        return Ok(JsonView(true,"搜索成功!", result.Items, result.Items.Count));
+            //        return Ok(JsonView(true, "搜索成功!", result.Items, result.Items.Count));
             //    }
 
             //    return Ok(JsonView(true, $"暂无数据!"));
@@ -1232,30 +1269,31 @@ namespace OASystem.API.Controllers
             //}
 
 
-            var stopwatch = Stopwatch.StartNew();
+            //var stopwatch = Stopwatch.StartNew();
 
-            if (string.IsNullOrWhiteSpace(keyword))
-            {
-                var result = await GetDefaultResultsAsync();
-                stopwatch.Stop();
-                return Ok(JsonView(true, $"操作成功!耗时:{stopwatch.ElapsedMilliseconds}ms", result, result.Count));
-            }
+            //if (string.IsNullOrWhiteSpace(keyword))
+            //{
+            //    var result = await GetDefaultResultsAsync();
+            //    stopwatch.Stop();
+            //    return Ok(JsonView(true, $"操作成功!耗时:{stopwatch.ElapsedMilliseconds}ms", result, result.Count));
+            //}
 
-            // 分析搜索模式
-            var searchAnalysis = AnalyzeSearchPattern(keyword);
+            //// 分析搜索模式
+            //var searchAnalysis = AnalyzeSearchPattern(keyword);
 
-            if (!searchAnalysis.HasSearchContent)
-            {
-                var result = await GetDefaultResultsAsync();
-                stopwatch.Stop();
-                return Ok(JsonView(true, $"操作成功!耗时:{stopwatch.ElapsedMilliseconds}ms", result, result.Count));
-            }
+            //if (!searchAnalysis.HasSearchContent)
+            //{
+            //    var result = await GetDefaultResultsAsync();
+            //    stopwatch.Stop();
+            //    return Ok(JsonView(true, $"操作成功!耗时:{stopwatch.ElapsedMilliseconds}ms", result, result.Count));
+            //}
 
-            // 原生SQL查询
-            var results = await SearchWithNativeSql(searchAnalysis);
-            var results1 = CalculateUnifiedMatchScore(results, searchAnalysis);
-            stopwatch.Stop();
-            return Ok(JsonView(true, $"搜索成功!耗时:{stopwatch.ElapsedMilliseconds}ms", results1, results1.Count));
+            //// 原生SQL查询
+            //var results = await SearchWithNativeSql(searchAnalysis);
+            //var results1 = CalculateUnifiedMatchScore(results, searchAnalysis);
+            //stopwatch.Stop();
+            //return Ok(JsonView(true, $"搜索成功!耗时:{stopwatch.ElapsedMilliseconds}ms", results1, results1.Count));
+            #endregion
 
         }
 
@@ -5898,11 +5936,11 @@ FROM
                             companyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList()
                         };
 
+                        //生成文件
                         string outFilePath = CreatePolandVisaPdf(visaData, polandSavePath, currTempPath);
 
                         filePaths.Add(outFilePath);
-                        #region 生成文件
-                        #endregion
+
                     }
 
                     break;
@@ -6016,7 +6054,7 @@ FROM
                 SetFieldValue(formFields, "4.Birthday", birthday);
 
                 string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
-                SetFieldValue(formFields, "CurrentNationality", currentNationality); // 出生地
+                SetFieldValue(formFields, "5.CurrentNationality", currentNationality); // 出生地
                 SetFieldValue(formFields, "CountryBirth", "中国"); // 出生国
                 SetFieldValue(formFields, "CurrentNationalityCountry", "中国"); // 现国籍
                 SetFieldValue(formFields, "NationalityBirth", ""); // 出生时国籍,如与现国籍不同

+ 1 - 1
OASystem/OASystem.Domain/Entities/Resource/Res_OfficialActivities.cs

@@ -70,7 +70,7 @@ namespace OASystem.Domain.Entities.Resource
         /// <summary>
         /// 联系人职务
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(50)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(120)")]
         public string Job { get; set; }
         /// <summary>
         /// 联系电话