|
|
@@ -1,10 +1,16 @@
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
+using EyeSoft.Collections.Generic;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using OASystem.API.OAMethodLib.DeepSeekAPI;
|
|
|
using OASystem.API.OAMethodLib.GenericSearch;
|
|
|
+using OASystem.Domain.AesEncryption;
|
|
|
+using OASystem.Domain.Entities.Customer;
|
|
|
using OASystem.Domain.Entities.Financial;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Domain.ViewModels.Search;
|
|
|
using OASystem.Infrastructure.Repositories.System;
|
|
|
+using static iTextSharp.text.pdf.AcroFields;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
|
@@ -15,16 +21,22 @@ namespace OASystem.API.Controllers
|
|
|
[ApiController]
|
|
|
public class SearchController : ControllerBase
|
|
|
{
|
|
|
+ private readonly SqlSugarClient _sqlSugar;
|
|
|
private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
|
|
|
+ private readonly DynamicSearchService<NewClientDataView> _clientSearchService;
|
|
|
public SearchController(
|
|
|
- DynamicSearchService<Grp_DelegationInfo> groupSearchService
|
|
|
+ SqlSugarClient sqlSugar,
|
|
|
+ DynamicSearchService<Grp_DelegationInfo> groupSearchService,
|
|
|
+ DynamicSearchService<NewClientDataView> clientSearchService
|
|
|
)
|
|
|
{
|
|
|
+ _sqlSugar = sqlSugar;
|
|
|
_groupSearchService = groupSearchService;
|
|
|
+ _clientSearchService = clientSearchService;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 接团信息 单字段(团组名称)关键字输入提示
|
|
|
+ /// 接团信息 关键字输入提示(单字段)
|
|
|
/// </summary>
|
|
|
/// <param name="keyword">关键字</param>
|
|
|
/// <returns></returns>
|
|
|
@@ -88,5 +100,109 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 客户资料 关键字输入提示(多字段)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="userId">关键字</param>
|
|
|
+ /// <param name="keyword">关键字</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("group/{userId}/{keyword}")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> ClientKeywordSearch(int userId,string keyword)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 验证请求参数
|
|
|
+ if (string.IsNullOrEmpty(keyword))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"暂无数据!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询有权限的数据
|
|
|
+ var clientIds = await _sqlSugar
|
|
|
+ .Queryable<Crm_ClientDataAndUser>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.usersId == userId)
|
|
|
+ .Select(x => x.NewClientDataId)
|
|
|
+ .ToListAsync();
|
|
|
+ if (clientIds == null || clientIds.Count < 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"暂无数据!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ var data = _sqlSugar.Queryable<Crm_NewClientData>()
|
|
|
+ .Where(x => x.IsDel == 0 && clientIds.Contains(x.Id))
|
|
|
+ .OrderByDescending(x => x.CreateTime)
|
|
|
+ .Select(x => new NewClientDataView (){
|
|
|
+ Id = x.Id,
|
|
|
+ Client = x.Client,
|
|
|
+ Contact = x.Contact,
|
|
|
+ Job = x.Job,
|
|
|
+ Telephone = x.Telephone,
|
|
|
+ Location = x.Location,
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+ int index = 0;
|
|
|
+ data.ForEach(x =>
|
|
|
+ {
|
|
|
+ index++;
|
|
|
+ x.RowNumber = index;
|
|
|
+ x.Client = AesEncryptionHelper.Decrypt(x.Client);
|
|
|
+ x.Contact = AesEncryptionHelper.Decrypt(x.Contact);
|
|
|
+ x.Job = AesEncryptionHelper.Decrypt(x.Job);
|
|
|
+ x.Telephone = AesEncryptionHelper.Decrypt(x.Telephone);
|
|
|
+ x.Location = AesEncryptionHelper.Decrypt(x.Location);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ var searchRequest = new DynamicSearchRequest
|
|
|
+ {
|
|
|
+ Keyword = keyword,
|
|
|
+ RequireAllSingleChars = true,
|
|
|
+ PageIndex = 1,
|
|
|
+ PageSize = 999999,
|
|
|
+ FieldWeights = new Dictionary<string, int>
|
|
|
+ {
|
|
|
+ { "Client", 10 },
|
|
|
+ { "Contact", 8 },
|
|
|
+ { "Location", 6 }
|
|
|
+ },
|
|
|
+ OrderBy = "CreateTime"
|
|
|
+ };
|
|
|
+
|
|
|
+ // 验证字段配置
|
|
|
+ var validation = _clientSearchService.ValidateFieldConfig(
|
|
|
+ searchRequest.FieldWeights,
|
|
|
+ searchRequest.ReturnFields);
|
|
|
+
|
|
|
+ if (!validation.IsValid)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
|
|
|
+ }
|
|
|
+
|
|
|
+ var result = _clientSearchService.SearchDataSource(searchRequest,data);
|
|
|
+
|
|
|
+ if (result.Success)
|
|
|
+ {
|
|
|
+ var view = result.Items.Select(x => x.Data).ToList();
|
|
|
+
|
|
|
+ int resetIndex = 0;
|
|
|
+ view.ForEach(x => {
|
|
|
+ resetIndex++;
|
|
|
+ x.RowNumber = resetIndex;
|
|
|
+ });
|
|
|
+
|
|
|
+ return Ok(JsonView(true, result.Message, view, view.Count));
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(true,"暂无数据"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"搜索服务暂时不可用!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|