客户相关导入优化

dev
嵇文龙 1 month ago
parent 123b85fbce
commit 5c5df78378

@ -123,13 +123,15 @@ public class ClientBankService : ServiceBase, IClientBankService
{
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
TenantDb.QueryFilter.Clear<IOrgId>();
TenantDb.QueryFilter.Clear<ISharedOrgId>();
var clientNames = list.Select(x => x.CompanyName).Distinct();
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames.Contains(x.ShortName))
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames.Contains(x.ShortName) || clientNames.Contains(x.Description))
.Select(x => new
{
x.Id,
x.ShortName,
x.Description,
x.OrgId
}).ToListAsync();
@ -137,17 +139,19 @@ public class ClientBankService : ServiceBase, IClientBankService
List<InfoClientBank> banks = new List<InfoClientBank>(list.Count);
foreach (var model in list)
{
var client = clients.Find(x => x.ShortName == model.CompanyName);
if (client == null)
var clientList = clients.FindAll(x => x.ShortName == model.CompanyName || x.Description == model.CompanyName);
if (clientList.Count == 0)
{
sb.Append("," + model.CompanyName);
continue;
}
foreach (var item in clientList)
{
InfoClientBank bank = new()
{
ClientId = client.Id,
OrgId = client.OrgId,
ClientId = item.Id,
OrgId = item.OrgId,
BankName = model.BankName,
Account = model.BankAccount,
BankAddress = model.BankAddress,
@ -172,6 +176,7 @@ public class ClientBankService : ServiceBase, IClientBankService
banks.Add(bank);
}
}
if (sb.Length > 0)
{

@ -100,31 +100,35 @@ public class ClientContactService : ServiceBase, IClientContactService
{
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
TenantDb.QueryFilter.Clear<IOrgId>();
TenantDb.QueryFilter.Clear<ISharedOrgId>();
var clientNames = list.Select(x => x.CompanyName).Distinct();
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames.Contains(x.ShortName))
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames.Contains(x.ShortName) || clientNames.Contains(x.Description))
.Select(x => new
{
x.Id,
x.ShortName,
x.Description,
x.OrgId
}).ToListAsync();
StringBuilder sb = new();
List<InfoClientContact> contacts = new List<InfoClientContact>(list.Count);
List<InfoClientContact> contacts = new(list.Count * 2);
foreach (var model in list)
{
var client = clients.Find(x => x.ShortName == model.CompanyName);
if (client == null)
var clientList = clients.FindAll(x => x.ShortName == model.CompanyName || x.Description == model.CompanyName);
if (clientList.Count == 0)
{
sb.Append("," + model.CompanyName);
continue;
}
foreach (var item in clientList)
{
InfoClientContact contact = new()
{
ClientId = client.Id,
OrgId = client.OrgId,
ClientId = item.Id,
OrgId = item.OrgId,
CreateBy = userId,
CreateUserName = User.UserName,
CreateTime = dtNow,
@ -140,6 +144,7 @@ public class ClientContactService : ServiceBase, IClientContactService
contacts.Add(contact);
}
}
if (sb.Length > 0)
{

@ -318,10 +318,10 @@ public class ClientInfoService : ServiceBase, IClientInfoService
AccountDates = []
};
var dicValue = dicList.Find(x => x.Name == model.Attribute)?.Value;
if (!string.IsNullOrEmpty(dicValue))
var dicValues = dicList.FindAll(x => model.AttributeNames.Contains(x.Name));
foreach (var item in dicValues)
{
dicValue = dicValue.ToUpperCamelCase();
var dicValue = item.Value.ToUpperCamelCase();
PropertyExtensions.SetPropertyValue(client.ClientTag, dicValue, true);
}

@ -357,7 +357,7 @@ public class ClientInfoController : ApiController
{
var model = new InfoClientBankModel
{
CompanyName = item["A"]?.ToString(),
CompanyName = item["A"]?.ToString()?.Trim(),
Currency = item["B"]?.ToString(),
BankName = item["C"]?.ToString(),
BankAccount = item["E"]?.ToString(),
@ -415,7 +415,7 @@ public class ClientInfoController : ApiController
{
var model = new InfoClientContactModel
{
CompanyName = item["A"]?.ToString(),
CompanyName = item["A"]?.ToString()?.Trim(),
ContactName = item["B"]?.ToString(),
ContactEnName = item["C"]?.ToString(),
Tel = item["D"]?.ToString(),

Loading…
Cancel
Save