|
|
|
@ -11,6 +11,9 @@ using System.Collections.Generic;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.Logging;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
|
{
|
|
|
|
@ -203,5 +206,64 @@ namespace Myshipping.Core.Service
|
|
|
|
|
return entities.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检索往来单位(包含车队)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryItem">检索值</param>
|
|
|
|
|
/// <param name="queryType">检索类型数组(可传多个) fleet-车队;customs_broker-报关行</param>
|
|
|
|
|
/// <param name="top">默认最大行数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/DjyCustomer/QuerytDjyCustomerInfo")]
|
|
|
|
|
public async Task<List<DjyCustomerOutput>> QuerytDjyCustomerInfo([FromQuery] string queryItem, [FromQuery] string[] queryType, [FromQuery] int top = 10)
|
|
|
|
|
{
|
|
|
|
|
List<DjyCustomerOutput> list = new List<DjyCustomerOutput>();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string sqlWhere = "1=1";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryItem))
|
|
|
|
|
{
|
|
|
|
|
sqlWhere += $" and (CodeName like '%{queryItem.Trim()}%' or ShortName like '%{queryItem.Trim()}%' or FullName like '%{queryItem.Trim()}%')";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (queryType.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
sqlWhere += $" and PropString REGEXP '" + string.Join("|", queryType) + "'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entityList = await _rep.AsQueryable().Where(sqlWhere).Take(top).OrderBy(a => a.FullName)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (entityList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
list = entityList.Adapt<List<DjyCustomerOutput>>();
|
|
|
|
|
|
|
|
|
|
var custsArg = list.Select(a => a.Id).ToArray();
|
|
|
|
|
var contactList = _repContact.AsQueryable()
|
|
|
|
|
.Where(a => custsArg.Contains(a.CustomerId.Value)).ToList();
|
|
|
|
|
|
|
|
|
|
list = list.GroupJoin(contactList, l => l.Id, r => r.CustomerId.Value, (l, r) =>
|
|
|
|
|
{
|
|
|
|
|
var curList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (curList.Count > 0)
|
|
|
|
|
l.Contacts = curList.Adapt<List<DjyCustomerContactOutput>>();
|
|
|
|
|
|
|
|
|
|
return l;
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("检索车队异常,请求:queryItem={0};queryType={1};top={2} 异常:{3}", queryItem, queryType, top, ex.Message);
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah("检索车队异常,异常{msg}", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|