导入代码

dev
嵇文龙 1 month ago
parent 5c5df78378
commit ee43cfdab9

@ -2,12 +2,10 @@ using System.Text;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Info.Interface;
using Mapster;
using Masuit.Tools.Models;
namespace DS.WMS.Core.Info.Method;
@ -113,7 +111,7 @@ public class ClientContactService : ServiceBase, IClientContactService
}).ToListAsync();
StringBuilder sb = new();
List<InfoClientContact> contacts = new(list.Count * 2);
List<InfoClientContact> contacts = new(list.Count);
foreach (var model in list)
{
var clientList = clients.FindAll(x => x.ShortName == model.CompanyName || x.Description == model.CompanyName);
@ -146,11 +144,11 @@ public class ClientContactService : ServiceBase, IClientContactService
}
}
if (sb.Length > 0)
{
sb.Remove(0, 1);
return DataResult.Failed("下列【所属公司】匹配不到客户/供应商:" + sb.ToString());
}
//if (sb.Length > 0)
//{
// sb.Remove(0, 1);
// return DataResult.Failed("下列【所属公司】匹配不到客户/供应商:" + sb.ToString());
//}
await TenantDb.Ado.BeginTranAsync();
try

@ -260,6 +260,20 @@ public class ClientInfoService : ServiceBase, IClientInfoService
{
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
TenantDb.QueryFilter.Clear<IOrgId>();
TenantDb.QueryFilter.Clear<ISharedOrgId>();
var clientNames1 = list.Select(x => x.ShortName).Distinct();
var clientNames2 = list.Select(x => x.CNName).Distinct();
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames1.Contains(x.ShortName) || clientNames2.Contains(x.Description))
.Select(x => new InfoClient
{
Id = x.Id,
ShortName = x.ShortName,
Description = x.Description,
IsCustomer = x.IsCustomer,
IsSupplier = x.IsSupplier
}).ToListAsync();
var attrbutes = list.SelectMany(x => x.AttributeNames).Where(x => !string.IsNullOrEmpty(x)).Distinct();
var dicList = await Db.Queryable<SysDictData>().InnerJoin<SysDictType>((d, t) => d.TypeId == t.Id)
@ -284,10 +298,21 @@ public class ClientInfoService : ServiceBase, IClientInfoService
x.DefaultOrgId
}).ToListAsync();
List<InfoClient> clients = new List<InfoClient>(list.Count);
List<InfoClient> newClients = new(list.Count);
List<InfoClient> existClients = [];
foreach (var model in list)
{
InfoClient client = new()
InfoClient? client = clients.Find(x => x.ShortName == model.ShortName && x.Description == model.CNName);
if (client != null)
{
client.IsCustomer = model.IsCustomer;
client.IsSupplier = model.IsSupplier;
//client.Note = "系统导入";
existClients.Add(client);
continue;
}
client = new()
{
Address = model.Address,
AuditStatus = model.StatusText == "认证" ? AuditStatusEnum.Approve : AuditStatusEnum.NoAudit,
@ -324,7 +349,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
var dicValue = item.Value.ToUpperCamelCase();
PropertyExtensions.SetPropertyValue(client.ClientTag, dicValue, true);
}
client.AccountDates.Add(new InfoClientAccountDate
{
AccountType = model.StlType,
@ -336,15 +361,18 @@ public class ClientInfoService : ServiceBase, IClientInfoService
CreateTime = dtNow,
});
clients.Add(client);
newClients.Add(client);
}
await TenantDb.Ado.BeginTranAsync();
try
{
await TenantDb.Fastest<InfoClient>().RemoveDataCache($"{SqlSugarCacheConst.InfoClient}{User.TenantId}").BulkMergeAsync(clients);
foreach (var client in clients)
if (existClients.Count > 0)
await TenantDb.Updateable(existClients).UpdateColumns(x => new { x.IsCustomer, x.IsSupplier }).ExecuteCommandAsync();
await TenantDb.Fastest<InfoClient>().RemoveDataCache($"{SqlSugarCacheConst.InfoClient}{User.TenantId}").BulkMergeAsync(newClients);
foreach (var client in newClients)
{
client.ClientTag.ClientId = client.Id;
@ -352,14 +380,16 @@ public class ClientInfoService : ServiceBase, IClientInfoService
item.ClientId = client.Id;
}
var tags = clients.Select(x => x.ClientTag).ToList();
var tags = newClients.Select(x => x.ClientTag).ToList();
await TenantDb.Fastest<InfoClientTag>().BulkMergeAsync(tags);
var accountDates = clients.SelectMany(x => x.AccountDates).ToList();
var accountDates = newClients.SelectMany(x => x.AccountDates).ToList();
await TenantDb.Fastest<InfoClientAccountDate>().BulkMergeAsync(accountDates);
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
var result = DataResult.Success;
result.Message = $"新增往来单位:{newClients.Count}项,更新往来单位:{existClients}项";
return result;
}
catch (Exception ex)
{

@ -35,9 +35,6 @@ namespace DS.WMS.Core.Invoice.Method
SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.ApplicationId == a.Id && d.Category == DetailCategory.InvoiceApplication && (d.OriginalAmount - d.OriginalProcessedAmount) != 0).Any())
.Select(a => new InvoiceApplicationDto
{
//Currency = SqlFunc.IsNullOrEmpty(a.Currency) ? SqlFunc.Subqueryable<ApplicationDetail>().Where(
// d => d.ApplicationId == a.Id && d.Category == DetailCategory.InvoiceApplication).SelectStringJoin(d => d.Currency, ",")
// : a.Currency,
AmountRMB = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.RMB_CODE).Sum(y => y.ApplyAmount),
AmountUSD = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount),
AmountOther = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency != FeeCurrency.RMB_CODE && y.Currency != FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount),

@ -576,6 +576,9 @@ namespace DS.WMS.Core.Invoice.Method
if (details.Count == 0)
return DataResult.Success;
if (invoiceAmount == 0)
return DataResult.Failed("开票金额不能为零");
var totalRMB = details.Sum(x => x.ApplyAmount);
if (Math.Abs(invoiceAmount) > totalRMB)
return DataResult.Failed("申请开票金额不能大于剩余开票金额");

@ -68,7 +68,7 @@
"GenerateFeesUrl": "/feeApi/FeeCustTemplate/GenerateFees"
},
"HangfireSettings": {
"DbString": "server=rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com;port=3306;uid=rulesengine_admin;pwd=Rule1qaz2wsx!QAZ;database=shippingweb8_hangfire;Allow User Variables=true",
"DbString": "server=rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com;port=3306;uid=rulesengine_admin;pwd=Rule1qaz2wsx!QAZ;database=shippingweb8_hangfire2;Allow User Variables=true",
"WorkerCount": 10,
"ServerName": "FeeApi",
"Queues": "fee"

@ -223,9 +223,9 @@ public class ClientInfoController : ApiController
AgreementTerm = item["E"] == null ? null : DateTime.Parse(item["E"].ToString()),
StatusText = item["F"]?.ToString(),
Address = item["G"]?.ToString(),
CNName = item["H"]?.ToString(),
ENName = item["I"]?.ToString(),
ShortName = item["J"]?.ToString(),
CNName = item["H"]?.ToString()?.Trim(),
ENName = item["I"]?.ToString()?.Trim(),
ShortName = item["J"]?.ToString()?.Trim(),
TaxID = item["K"]?.ToString(),
Code = item["L"]?.ToString(),
StlType = item["M"]?.ToString(),
@ -295,9 +295,9 @@ public class ClientInfoController : ApiController
AgreementTerm = item["C"] == null ? null : DateTime.Parse(item["C"].ToString()),
StatusText = item["D"]?.ToString(),
Address = item["E"]?.ToString(),
CNName = item["F"]?.ToString(),
ENName = item["G"]?.ToString(),
ShortName = item["H"]?.ToString(),
CNName = item["F"]?.ToString()?.Trim(),
ENName = item["G"]?.ToString()?.Trim(),
ShortName = item["H"]?.ToString()?.Trim(),
TaxID = item["I"]?.ToString(),
Code = item["J"]?.ToString(),
StlType = item["K"]?.ToString(),
@ -374,6 +374,9 @@ public class ClientInfoController : ApiController
IsDefault = int.TryParse(item["P"]?.ToString(), out int value3) && value3 == 1,
};
if (string.IsNullOrEmpty(model.CompanyName))
model.CompanyName = model.InvoiceHeader;
if (string.IsNullOrEmpty(model.CompanyName))
sb.Append($"行号:{rows.IndexOf(item) + 2} 未填写【公司名称】");

Loading…
Cancel
Save