|
@@ -1,4 +1,5 @@
|
|
|
using EyeSoft.Collections.Generic;
|
|
using EyeSoft.Collections.Generic;
|
|
|
|
|
+using Humanizer;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
using NPOI.SS.Formula.Functions;
|
|
@@ -9,8 +10,10 @@ using OASystem.Domain.AesEncryption;
|
|
|
using OASystem.Domain.Entities.Customer;
|
|
using OASystem.Domain.Entities.Customer;
|
|
|
using OASystem.Domain.Entities.Financial;
|
|
using OASystem.Domain.Entities.Financial;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
|
|
+using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Domain.ViewModels.Search;
|
|
using OASystem.Domain.ViewModels.Search;
|
|
|
using OASystem.Infrastructure.Repositories.CRM;
|
|
using OASystem.Infrastructure.Repositories.CRM;
|
|
|
|
|
+using OASystem.Infrastructure.Repositories.Groups;
|
|
|
using OASystem.Infrastructure.Repositories.System;
|
|
using OASystem.Infrastructure.Repositories.System;
|
|
|
using static iTextSharp.text.pdf.AcroFields;
|
|
using static iTextSharp.text.pdf.AcroFields;
|
|
|
|
|
|
|
@@ -24,18 +27,21 @@ namespace OASystem.API.Controllers
|
|
|
public class SearchController : ControllerBase
|
|
public class SearchController : ControllerBase
|
|
|
{
|
|
{
|
|
|
private readonly SqlSugarClient _sqlSugar;
|
|
private readonly SqlSugarClient _sqlSugar;
|
|
|
|
|
+ private readonly DelegationInfoRepository _groupRep;
|
|
|
private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
|
|
private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
|
|
|
private readonly DynamicSearchService<NewClientDataView> _clientSearchService;
|
|
private readonly DynamicSearchService<NewClientDataView> _clientSearchService;
|
|
|
-
|
|
|
|
|
private readonly NewClientDataRepository _clientDataRepository;
|
|
private readonly NewClientDataRepository _clientDataRepository;
|
|
|
|
|
+
|
|
|
public SearchController(
|
|
public SearchController(
|
|
|
SqlSugarClient sqlSugar,
|
|
SqlSugarClient sqlSugar,
|
|
|
- DynamicSearchService<Grp_DelegationInfo> groupSearchService,
|
|
|
|
|
- DynamicSearchService<NewClientDataView> clientSearchService,
|
|
|
|
|
- NewClientDataRepository clientDataRepository
|
|
|
|
|
|
|
+ DelegationInfoRepository groupRep,
|
|
|
|
|
+ DynamicSearchService<Grp_DelegationInfo> groupSearchService,
|
|
|
|
|
+ DynamicSearchService<NewClientDataView> clientSearchService,
|
|
|
|
|
+ NewClientDataRepository clientDataRepository
|
|
|
)
|
|
)
|
|
|
{
|
|
{
|
|
|
_sqlSugar = sqlSugar;
|
|
_sqlSugar = sqlSugar;
|
|
|
|
|
+ _groupRep = groupRep;
|
|
|
_groupSearchService = groupSearchService;
|
|
_groupSearchService = groupSearchService;
|
|
|
_clientSearchService = clientSearchService;
|
|
_clientSearchService = clientSearchService;
|
|
|
_clientDataRepository = clientDataRepository;
|
|
_clientDataRepository = clientDataRepository;
|
|
@@ -621,5 +627,114 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView(false, "搜索服务暂时不可用,请稍后重试"));
|
|
return Ok(JsonView(false, "搜索服务暂时不可用,请稍后重试"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 三公-接团信息 关键字输入提示(单字段)
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="currUserId">用户名称ID</param>
|
|
|
|
|
+ /// <param name="keyword">关键字</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ [HttpGet("GroupEnterExitCostKeywordSearch/{currUserId}/{keyword}")]
|
|
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
|
|
+ public async Task<IActionResult> GroupEnterExitCostKeywordSearch(int currUserId,string keyword)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ // 验证请求参数
|
|
|
|
|
+ if (currUserId < 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Ok(JsonView(true, $"请传入有效的用户ID!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (string.IsNullOrEmpty(keyword))
|
|
|
|
|
+ {
|
|
|
|
|
+ return Ok(JsonView(true, $"暂无数据!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var searchRequest = new DynamicSearchRequest
|
|
|
|
|
+ {
|
|
|
|
|
+ Keyword = keyword,
|
|
|
|
|
+ RequireAllSingleChars = true,
|
|
|
|
|
+ PageIndex = 1,
|
|
|
|
|
+ PageSize = 30,
|
|
|
|
|
+ FieldWeights = new Dictionary<string, int>
|
|
|
|
|
+ {
|
|
|
|
|
+ { "TeamName", 10 },
|
|
|
|
|
+ //{ "ClientUnit", 8 },
|
|
|
|
|
+ //{ "ClientName", 6 }
|
|
|
|
|
+ },
|
|
|
|
|
+ Filters = new List<SearchFilter>()
|
|
|
|
|
+ {
|
|
|
|
|
+ new(){Field = "IsDel",Operator="eq",Value="0" }
|
|
|
|
|
+ },
|
|
|
|
|
+ OrderBy = "TeamName",
|
|
|
|
|
+ ReturnFields = new List<string>() { "TeamName" }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 验证字段配置
|
|
|
|
|
+ var validation = _groupSearchService.ValidateFieldConfig(
|
|
|
|
|
+ searchRequest.FieldWeights,
|
|
|
|
|
+ searchRequest.ReturnFields);
|
|
|
|
|
+
|
|
|
|
|
+ if (!validation.IsValid)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var result = await _groupSearchService.SearchAsync(searchRequest);
|
|
|
|
|
+
|
|
|
|
|
+ if (result.Success)
|
|
|
|
|
+ {
|
|
|
|
|
+ var groupIds = result.Items.Select(x => x.Data.Id).ToList();
|
|
|
|
|
+ var isNullDatas = _sqlSugar.Queryable<Grp_EnterExitCost>()
|
|
|
|
|
+ .Where(x => x.IsDel == 0 && groupIds.Contains(x.DiId))
|
|
|
|
|
+ .Select(x => x.DiId)
|
|
|
|
|
+ .Distinct()
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+ var isViewDatas = _sqlSugar.Queryable<Grp_EnterExitCostPermission>()
|
|
|
|
|
+ .Where(x1 => x1.IsDel == 0 && x1.UserId == currUserId && groupIds.Contains(x1.GroupId))
|
|
|
|
|
+ .Select(x1 => x1.GroupId)
|
|
|
|
|
+ .Distinct()
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+ var provCityDatas = await _groupRep.ProvinceCityBasicSource();
|
|
|
|
|
+
|
|
|
|
|
+ var data = result.Items.Select(x =>
|
|
|
|
|
+ {
|
|
|
|
|
+ int groupId = x.Data.Id;
|
|
|
|
|
+ int cityId = x.Data.CityId;
|
|
|
|
|
+ bool isNull = !isNullDatas.Where(x => x == groupId).Any();
|
|
|
|
|
+ bool isView = isViewDatas.Where(x => x == groupId).Any();
|
|
|
|
|
+
|
|
|
|
|
+ var provinceId = 122; //默认四川
|
|
|
|
|
+ if (provinceId > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ var parentId = _groupRep.FindParentIdByChildId(provCityDatas, cityId);
|
|
|
|
|
+ if (parentId != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ provinceId = (int)parentId;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return new
|
|
|
|
|
+ {
|
|
|
|
|
+ x.Data.Id,
|
|
|
|
|
+ groupName = x.Data.TeamName,
|
|
|
|
|
+ provinceId,
|
|
|
|
|
+ isNull,
|
|
|
|
|
+ isView,
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+ }).ToList();
|
|
|
|
|
+
|
|
|
|
|
+ return Ok(JsonView(true, result.Message, data, data.Count));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return Ok(JsonView(true, result.Message));
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Ok(JsonView(true, $"搜索服务暂时不可用!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|