jianghaiqing 2 months ago
commit 2f6a637222

@ -365,6 +365,7 @@ namespace DS.WMS.Core.Fee.Method
PODCode = g.Key.POD,
CreateBy = userId,
CreateTime = dtNow,
Note = "系统导入",
Details = []
};
list.Add(template);

@ -1,5 +1,13 @@
using DS.Module.SqlSugar;
using DS.Module.Core;
using DS.Module.Core.Condition;
using DS.Module.Core.Data;
using DS.Module.SqlSugar;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.HangfireJob.Method
@ -9,7 +17,7 @@ namespace DS.WMS.Core.HangfireJob.Method
/// </summary>
public class FeeCustTemplateJobService
{
ISqlSugarClient db;
ISqlSugarClient? db;
/// <summary>
/// 初始化
@ -24,13 +32,313 @@ namespace DS.WMS.Core.HangfireJob.Method
/// 生成费用
/// </summary>
/// <returns></returns>
public async Task GenerateFeesAsync()
public async Task GenerateFeesAsync()
{
var dbLinks = await db.Queryable<SysTenantLink>().ToListAsync();
foreach (var dbLink in dbLinks)
SqlSugarClient? tenantDb = null;
try
{
foreach (var dbLink in dbLinks)
{
string configId = dbLinks.IndexOf(dbLink).ToString();
//if (db.IsAnyConnection(configId))
//{
// var config = new ConnectionConfig
// {
// ConfigId = configId,
// DbType = dbLink.DbType,
// IsAutoCloseConnection = true,
// ConnectionString = dbLink.Connection
// };
// db.AddConnection(config);
//}
tenantDb = new SqlSugarClient(new ConnectionConfig
{
ConfigId = configId,
DbType = dbLink.DbType,
IsAutoCloseConnection = true,
ConnectionString = dbLink.Connection
});
tenantDb.QueryFilter.Clear<IOrgId>();
tenantDb.QueryFilter.Clear<ISharedOrgId>();
tenantDb.QueryFilter.Clear<ITenantId>();
}
}
finally
{
tenantDb?.Dispose();
}
}
/// <summary>
/// 根据开船日生成费用
/// </summary>
/// <param name="tenantDb"></param>
/// <param name="etd">开船日</param>
/// <returns></returns>
internal static async Task GenerateFeesCoreAsync(SqlSugarClient tenantDb, DateTime etd)
{
DateTime dt = DateTime.Now;
var list = await tenantDb.Queryable<FeeCustTemplate>()
.Where(x => !x.IsDisabled && SqlFunc.Between(dt, x.StartTime, x.EndTime) && (x.IsShared || x.CustomerId != null))
.Select(x => new FeeCustTemplate
{
Id = x.Id,
CustomerId = x.CustomerId,
FeeType = x.FeeType,
FeeCategoryId = x.FeeCategoryId,
FeeCategoryName = x.FeeCategoryName,
Priority = x.Priority,
IsShared = x.IsShared,
POLCode = x.POLCode,
PODCode = x.PODCode,
LaneId = x.LaneId,
SourceId = x.SourceId,
CarrierId = x.CarrierId,
ForwarderId = x.ForwarderId,
MBLFrtCode = x.MBLFrtCode,
Condition = x.Condition
}).ToListAsync();
if (list.Count == 0)
return;
if (etd == default)
etd = DateTime.Now.Date;
var tids = list.Select(x => x.Id);
var orders = await tenantDb.Queryable<SeaExport>().Where(x => SqlFunc.DateIsSame(x.ETD, etd) &&
SqlFunc.Subqueryable<FeeCustTemplateRecord>().Where(y => y.BusinessId == x.Id && y.BusinessType == BusinessType.OceanShippingExport && tids.Contains(y.TemplateId)).NotAny())
.Select<SeaExportRes>().ToListAsync();
if (orders.Count == 0)
return;
List<FeeRecord> feeList = [];
await tenantDb.Ado.BeginTranAsync();
try
{
foreach (var order in orders)
{
var custList = list.Where(x => x.CustomerId == order.CustomerId).OrderBy(x => x.Priority);
foreach (var template in custList) //遍历客户费用模板,查找匹配项
{
var fees = await CreateFeesIfMatchAsync(tenantDb,order, template);
if (fees != null)
{
feeList.AddRange(fees);
var record = new FeeCustTemplateRecord
{
BusinessId = order.CustomerId,
BusinessType = BusinessType.OceanShippingExport,
CreateTime = dt,
FeeCategoryId = template.FeeCategoryId,
FeeType = template.FeeType,
TemplateId = template.Id
};
await tenantDb.Insertable(record).ExecuteCommandAsync();
}
}
//未找到客户模板,开始匹配共享模板
if (feeList.Count == 0)
{
var sharedList = list.Where(x => x.IsShared).OrderBy(x => x.Priority).ToList();
foreach (var template in sharedList)
{
var fees = await CreateFeesIfMatchAsync(tenantDb, order, template);
if (fees != null)
{
feeList.AddRange(fees);
var record = new FeeCustTemplateRecord
{
BusinessId = order.CustomerId,
BusinessType = BusinessType.OceanShippingExport,
CreateTime = dt,
FeeCategoryId = template.FeeCategoryId,
FeeType = template.FeeType,
TemplateId = template.Id
};
await tenantDb.Insertable(record).ExecuteCommandAsync();
}
}
}
//写入当前业务的费用
if (feeList.Count > 0)
{
//var result = await feeService.Value.SaveAsync(tenantDb, feeList, true, false);
//if (!result.Succeeded)
//{
// //记录失败日志
// //await new ApplicationException(result.Message).LogAsync(Db);
//}
feeList.Clear();
}
}
await tenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await tenantDb.Ado.RollbackTranAsync();
//await ex.LogAsync(Db);
}
}
static async Task<List<FeeRecord>?> CreateFeesIfMatchAsync(SqlSugarClient tenantDb, SeaExportRes order, FeeCustTemplate template)
{
if (!string.IsNullOrEmpty(template.POLCode) && template.POLCode != order.LoadPortCode)
return null;
if (!string.IsNullOrEmpty(template.PODCode) && template.PODCode != order.DischargePortCode)
return null;
if (!string.IsNullOrEmpty(template.MBLFrtCode) && template.MBLFrtCode != order.MBLFrtCode)
return null;
if (template.LaneId.HasValue && template.LaneId != order.LaneId)
return null;
if (template.CarrierId.HasValue && template.CarrierId != order.CarrierId)
return null;
if (template.SourceId.HasValue && template.SourceId != order.SourceId)
return null;
if (template.ForwarderId.HasValue && template.ForwarderId != order.ForwarderId)
return null;
if (!string.IsNullOrEmpty(template.Condition)) //设置了自定义匹配条件
{
var conditionModel = JsonConvert.DeserializeObject<ConditionContent>(template.Condition);
if (!IsMatch(order, conditionModel))
return null;
}
if (await tenantDb.Queryable<FeeCustTemplateRecord>().AnyAsync(x => x.BusinessId == order.Id && x.BusinessType == BusinessType.OceanShippingExport &&
x.FeeType == template.FeeType && x.FeeCategoryId == template.FeeCategoryId))
return null;
var details = await tenantDb.Queryable<FeeCustTemplateDetail>().Where(y => y.TemplateId == template.Id)
.Select(x => new FeeRecord
{
BusinessId = order.Id,
BusinessType = BusinessType.OceanShippingExport,
FeeType = template.FeeType,
FeeId = x.FeeId,
FeeCode = x.FeeCode,
FeeName = x.FeeName,
CustomerId = x.CustomerId,
CustomerName = x.CustomerName,
CustomerType = x.CustomerType,
Unit = x.Unit,
UnitPrice = SqlFunc.IsNull(x.UnitPrice.Value, 0),
//Quantity = x.IsCtn ? 1 : 0,
Currency = x.Currency,
ExchangeRate = x.ExchangeRate,
TaxRate = SqlFunc.IsNull(x.TaxRate.Value, 0),
AccTaxRate = SqlFunc.IsNull(x.AccTaxRate.Value, 0),
Tax = SqlFunc.IsNull(x.Tax.Value, 0),
TaxUnitPrice = SqlFunc.IsNull(x.TaxUnitPrice.Value, 0),
IsInvoice = x.IsInvoice,
IsAdvancedPay = x.IsAdvancedPay,
Remark = template.FeeCategoryName,
TemplateId = x.TemplateId,
InputMethod = InputMethod.Automatic
}).ToListAsync();
foreach (var detail in details)
{
if (detail.CustomerId == 0)
{
switch (detail.CustomerType)
{
case "controller":
detail.CustomerId = order.CustomerId;
detail.CustomerName = order.CustomerName;
break;
case "yard":
detail.CustomerId = order.YardId;
detail.CustomerName = order.Yard;
break;
case "custom":
detail.CustomerId = order.CustomserId;
detail.CustomerName = order.Customser;
break;
case "contract":
detail.CustomerId = order.ContractClientId;
detail.CustomerName = order.ContractClientName;
break;
case "shipagency":
detail.CustomerId = order.ShipAgencyId;
detail.CustomerName = order.ShipAgency;
break;
case "shipper":
detail.CustomerId = order.ShipperId.GetValueOrDefault();
detail.CustomerName = order.Shipper;
break;
case "truck":
detail.CustomerId = order.TruckerId;
detail.CustomerName = order.Trucker;
break;
case "booking":
detail.CustomerId = order.ForwarderId;
detail.CustomerName = order.Forwarder;
break;
case "carrier":
detail.CustomerId = order.CarrierId;
detail.CustomerName = order.Carrier;
break;
case "wareHouse":
detail.CustomerId = order.WareHouseId;
detail.CustomerName = order.WareHouse;
break;
case "shippercn":
detail.CustomerId = order.ShipperCnId.GetValueOrDefault();
detail.CustomerName = order.ShipperCn;
break;
case "agent":
detail.CustomerId = order.AgentId.GetValueOrDefault();
detail.CustomerName = order.Agent;
break;
}
}
}
return details;
}
/// <summary>
/// 根据指定条件返回是否匹配的结果
/// </summary>
/// <param name="source">要对比的数据源</param>
/// <param name="condition">匹配条件</param>
/// <returns></returns>
static bool IsMatch(object source, ConditionContent condition)
{
if (source == null || condition == null)
return false;
TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, source));
if (string.IsNullOrEmpty(condition.SourceName))
condition.SourceName = TaskFlowDataNameConst.Business;
return ConditionHelper.IsPass(condition, dataContext);
}
}
}

@ -0,0 +1,83 @@
namespace DS.WMS.Core.Info.Dtos
{
/// <summary>
/// 往来单位银行与发票导入模型
/// </summary>
public class InfoClientBankModel
{
/// <summary>
/// 公司名称
/// </summary>
public string? CompanyName { get; set; }
/// <summary>
/// 币种
/// </summary>
public string? Currency { get; set; }
/// <summary>
/// 银行名称
/// </summary>
public string? BankName { get; set; }
/// <summary>
/// 银行账号
/// </summary>
public string? BankAccount { get; set; }
/// <summary>
/// 银行地址
/// </summary>
public string? BankAddress { get; set; }
/// <summary>
/// 发票地址
/// </summary>
public string? InvoiceAddress { get; set; }
/// <summary>
/// 发票收件人
/// </summary>
public string? InvoiceRecevier { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string? Tel { get; set; }
/// <summary>
/// 纳税人识别号
/// </summary>
public string? TaxId { get; set; }
/// <summary>
/// 开票电话
/// </summary>
public string? InvoiceTel { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; set; }
/// <summary>
/// 发票抬头
/// </summary>
public string? InvoiceHeader { get; set; }
/// <summary>
/// 默认应付
/// </summary>
public bool IsDefaultP { get; set; }
/// <summary>
/// 默认应收
/// </summary>
public bool IsDefaultR { get; set; }
/// <summary>
/// 默认银行
/// </summary>
public bool IsDefault { get; set; }
}
}

@ -0,0 +1,53 @@
namespace DS.WMS.Core.Info.Dtos
{
/// <summary>
/// 往来单位联系人导入模型
/// </summary>
public class InfoClientContactModel
{
/// <summary>
/// 所属公司
/// </summary>
public string? CompanyName { get; set; }
/// <summary>
/// 联系人名称
/// </summary>
public string? ContactName { get; set; }
/// <summary>
/// 联系人英文名
/// </summary>
public string? ContactEnName { get; set; }
/// <summary>
/// 电话
/// </summary>
public string? Tel { get; set; }
/// <summary>
/// 手机
/// </summary>
public string? Mobile { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string? Email { get; set; }
/// <summary>
/// QQ
/// </summary>
public string? QQ { get; set; }
/// <summary>
/// 职务
/// </summary>
public string? Job { get; set; }
/// <summary>
/// 是否默认联系人
/// </summary>
public bool IsDefault { get; set; }
}
}

@ -75,6 +75,11 @@
/// </summary>
public string? Attribute { get; set; }
/// <summary>
/// 客户属性
/// </summary>
public string[] AttributeNames => Attribute == null ? [] : Attribute.Split(',', StringSplitOptions.RemoveEmptyEntries);
/// <summary>
/// 商务
/// </summary>

@ -33,4 +33,11 @@ public interface IClientBankService
/// <param name="req"></param>
/// <returns></returns>
Task<DataResult> DeleteAsync(IdModel req);
/// <summary>
/// 导入客户银行
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
Task<DataResult> ImportAsync(List<InfoClientBankModel> list);
}

@ -35,4 +35,11 @@ public interface IClientContactService
/// <param name="model"></param>
/// <returns></returns>
Task<DataResult> DeleteAsync(IdModel model);
/// <summary>
/// 导入客户联系人
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
Task<DataResult> ImportAsync(List<InfoClientContactModel> list);
}

@ -1,6 +1,8 @@
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;
@ -111,4 +113,94 @@ public class ClientBankService : ServiceBase, IClientBankService
int rows = await TenantDb.Deleteable<InfoClientBank>().Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
/// <summary>
/// 导入客户银行
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public async Task<DataResult> ImportAsync(List<InfoClientBankModel> list)
{
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
var clientNames = list.Select(x => x.CompanyName).Distinct();
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames.Contains(x.ShortName))
.Select(x => new
{
x.Id,
x.ShortName,
x.OrgId
}).ToListAsync();
StringBuilder sb = new();
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)
{
sb.Append("," + model.CompanyName);
continue;
}
InfoClientBank bank = new()
{
ClientId = client.Id,
OrgId = client.OrgId,
BankName = model.BankName,
Account = model.BankAccount,
BankAddress = model.BankAddress,
BankAccountNo = model.BankAccount,
IsInvoiceDefault = model.IsDefault,
CreateBy = userId,
CreateUserName = User.UserName,
CreateTime = dtNow,
InvoiceHeaders = []
};
if (model.Currency == "人民币")
bank.Currency = FeeCurrency.RMB_CODE;
else if (model.Currency == "美元")
bank.Currency = FeeCurrency.USD_CODE;
bank.InvoiceHeaders.Add(new InvoiceHeader
{
Header = model.InvoiceHeader,
AddressTel = model.InvoiceAddress + " " + model.InvoiceTel
});
banks.Add(bank);
}
if (sb.Length > 0)
{
sb.Remove(0, 1);
return DataResult.Failed("下列【公司名称】匹配不到客户/供应商:" + sb.ToString());
}
await TenantDb.Ado.BeginTranAsync();
try
{
await TenantDb.Fastest<InfoClientBank>().BulkMergeAsync(banks);
foreach (var bank in banks)
{
foreach (var item in bank.InvoiceHeaders)
item.RelativeId = bank.Id;
}
var invoiceHeaders = banks.SelectMany(x => x.InvoiceHeaders).ToList();
await TenantDb.Fastest<InvoiceHeader>().BulkMergeAsync(invoiceHeaders);
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.Failed("导入失败:" + ex.Message);
}
}
}

@ -1,10 +1,13 @@
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;
@ -87,4 +90,75 @@ public class ClientContactService : ServiceBase, IClientContactService
int rows = await TenantDb.Deleteable<InfoClientContact>().Where(x => model.Ids.Contains(x.Id)).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
/// <summary>
/// 导入客户联系人
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public async Task<DataResult> ImportAsync(List<InfoClientContactModel> list)
{
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
var clientNames = list.Select(x => x.CompanyName).Distinct();
var clients = await TenantDb.Queryable<InfoClient>().Where(x => clientNames.Contains(x.ShortName))
.Select(x => new
{
x.Id,
x.ShortName,
x.OrgId
}).ToListAsync();
StringBuilder sb = new();
List<InfoClientContact> contacts = new List<InfoClientContact>(list.Count);
foreach (var model in list)
{
var client = clients.Find(x => x.ShortName == model.CompanyName);
if (client == null)
{
sb.Append("," + model.CompanyName);
continue;
}
InfoClientContact contact = new()
{
ClientId = client.Id,
OrgId = client.OrgId,
CreateBy = userId,
CreateUserName = User.UserName,
CreateTime = dtNow,
Name = model.ContactName,
EnName = model.ContactEnName,
Job = model.Job,
Email = model.Email,
Mobile = model.Mobile,
Tel = model.Tel,
QQ = model.QQ,
IsDefault = model.IsDefault
};
contacts.Add(contact);
}
if (sb.Length > 0)
{
sb.Remove(0, 1);
return DataResult.Failed("下列【所属公司】匹配不到客户/供应商:" + sb.ToString());
}
await TenantDb.Ado.BeginTranAsync();
try
{
await TenantDb.Fastest<InfoClientContact>().BulkMergeAsync(contacts);
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.Failed("导入失败:" + ex.Message);
}
}
}

@ -261,7 +261,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
var attrbutes = list.Select(x => x.Attribute).Where(x => !string.IsNullOrEmpty(x)).Distinct();
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)
.Where((d, t) => t.Code == "infoclient-ArrclientTag" && attrbutes.Contains(d.Name))
.Select((d, t) => new
@ -306,12 +306,12 @@ public class ClientInfoService : ServiceBase, IClientInfoService
IsSupplier = model.IsSupplier,
OperatorId = users.Find(x => x.UserName == model.OP)?.Id,
OperatorName = model.OP,
Name = model.CNName,
OrgId = (users.Find(x => x.UserName == model.Sale)?.DefaultOrgId).GetValueOrDefault(),
Sale = model.Sale,
SaleId = users.Find(x => x.UserName == model.Sale)?.Id,
QQ = model.QQ,
ShortName = model.CNName,
Description = model.CNName,
Tel = model.Tel,
Note = "系统导入",
ClientTag = new InfoClientTag(),
@ -337,17 +337,17 @@ public class ClientInfoService : ServiceBase, IClientInfoService
CreateTime = dtNow,
});
client.Contacts.Add(new InfoClientContact
{
Name = model.ContactName,
Address = model.Address,
Email = model.Email,
Mobile = model.Phone,
Tel = model.Tel,
QQ = model.QQ,
IsDefault = true,
OrgId = client.OrgId
});
//client.Contacts.Add(new InfoClientContact
//{
// Name = model.ContactName,
// Address = model.Address,
// Email = model.Email,
// Mobile = model.Phone,
// Tel = model.Tel,
// QQ = model.QQ,
// IsDefault = true,
// OrgId = client.OrgId
//});
clients.Add(client);
}
@ -355,13 +355,23 @@ public class ClientInfoService : ServiceBase, IClientInfoService
await TenantDb.Ado.BeginTranAsync();
try
{
await TenantDb.Storageable(clients).WhereColumns(x => new { x.ShortName, x.Description }).ExecuteCommandAsync();
await TenantDb.Fastest<InfoClient>().BulkMergeAsync(clients);
foreach (var client in clients)
{
client.ClientTag.ClientId = client.Id;
//await TenantDb.InsertNav(clients)
//.Include(x => x.ClientTag)
//.Include(x => x.AccountDates)
//.Include(x => x.Contacts)
//.ExecuteCommandAsync();
foreach (var item in client.AccountDates)
item.ClientId = client.Id;
//foreach (var item in client.Contacts)
// item.ClientId = client.Id;
}
var accountDates = clients.SelectMany(x => x.AccountDates).ToList();
await TenantDb.Fastest<InfoClientAccountDate>().BulkMergeAsync(accountDates);
//var contacts = clients.SelectMany(x => x.Contacts).ToList();
//await TenantDb.Fastest<InfoClientContact>().BulkMergeAsync(contacts);
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
@ -548,8 +558,18 @@ public class ClientInfoService : ServiceBase, IClientInfoService
.And(x => x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim())
.AndIF(req.Id > 0, x => x.Id != req.Id);
if (await TenantDb.Queryable<InfoClient>().Where(expr.ToExpression()).AnyAsync())
return DataResult.Failed("客户信息已存在,请检查客户全称/简称是否重复!", MultiLanguageConst.ClientInfoExist);
var client = await TenantDb.Queryable<InfoClient>().Where(expr.ToExpression()).Select(x => new
{
ClientId = x.Id,
x.ShortName,
x.Description
}).FirstAsync();
if (client != null)
{
var result = DataResult.Failed("客户信息已存在,请检查客户全称/简称是否重复!", MultiLanguageConst.ClientInfoExist);
result.Code = ResultCode.Fail;
result.Data = client;
}
return DataResult.Success;
}

@ -266,9 +266,10 @@ namespace DS.WMS.Core.Info.Method
public async Task<DataResult> EditAsync(InfoClientStakeholder stakeholder)
{
await TenantDb.Storageable(stakeholder).DefaultAddElseUpdate().ExecuteCommandAsync();
return DataResult.Success;
var result = DataResult.Success;
result.Data = stakeholder;
return result;
}
}
}

@ -14,6 +14,14 @@ namespace DS.WMS.Core.Op.Interface
{
public interface ISeaExportCommonService
{
/// <summary>
/// 更新手动更新海运出口派车报关标识
/// </summary>
/// <param name="id"></param>
/// <param name="code"></param>
/// <param name="type">类型 true 勾选保存 false 勾选取消</param>
public void UpdateSeaExportTag(long id, string code, bool type = true);
/// <summary>
/// 海运出口差异日志
/// </summary>

@ -33,6 +33,8 @@ using DS.Module.Core.Data;
using Masuit.Tools.Models;
using System.ComponentModel;
using DS.Module.DjyServiceStatus;
using DS.WMS.Core.Invoice.Dtos;
using NPOI.SS.Formula.Functions;
namespace DS.WMS.Core.Op.Method
{
@ -62,6 +64,59 @@ namespace DS.WMS.Core.Op.Method
_djyServiceStatusService = _serviceProvider.GetRequiredService<IDjyServiceStatusService>();
}
/// <summary>
/// 更新手动更新海运出口派车报关标识
/// </summary>
/// <param name="id"></param>
/// <param name="code"></param>
/// <param name="type">类型 true 勾选保存 false 勾选取消</param>
public async void UpdateSeaExportTag(long id,string code,bool type = true) {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var order = tenantDb.Queryable<SeaExport>().Filter(null, true).First(x => x.Id == id);
var oldOrder = order.Adapt<SeaExport>();
if (type)
{
if (code == "YPC")
{
order.IsLand = true;
}
if (code == "BG")
{
order.IsCustoms = true;
}
}
else
{
if (code == "YPC")
{
order.IsLand = false;
}
if (code == "BG")
{
order.IsCustoms = false;
}
}
//order.Note = "更新主单货物状态";
await tenantDb.Updateable(order)
.UpdateColumnsIF(code == "YPC", x => new { x.IsLand })
.UpdateColumnsIF(code == "BG", x => new { x.IsCustoms })
.EnableDiffLogEvent().ExecuteCommandAsync();
// 记录日志
await SaveSeaExportLogAsync(new SeaExportSaveLog()
{
OperateType = "Update",
OldOrder = oldOrder,
NewOrder = order,
SourceCode = "UpdateSeaExportTag",
SourceName = "手动更新海运出口标识",
}, tenantDb);
}
#region 海运出口差异日志
/// <summary>
/// 忽略的字段
@ -1001,13 +1056,20 @@ namespace DS.WMS.Core.Op.Method
var oldOrder = order.Adapt<SeaExport>();
order.BusinessStatusName = status.StatusName;
order.BusinessStatus = status.SystemCode;
order.IsVGM = status.SystemCode == "YFVGM" ? true : false;
order.IsBooking = status.SystemCode == "YFCD" ? true : false;
if (status.SystemCode == "YPC")
order.IsLand = true;
if(status.SystemCode == "BG")
order.IsCustoms = true;
if (status.SystemCode == "YFVGM")
order.IsVGM = true;
if (status.SystemCode == "YFCD")
order.IsBooking = true;
//order.Note = "更新主单货物状态";
await tenantDb.Updateable(order).UpdateColumns(x => new { x.BusinessStatusName, x.BusinessStatus })
.UpdateColumnsIF(status.SystemCode == "YFVGM", x => new { x.IsVGM })
.UpdateColumnsIF(status.SystemCode == "YFCD", x => new { x.IsBooking })
.UpdateColumnsIF(status.SystemCode == "YPC", x => new { x.IsLand })
.UpdateColumnsIF(status.SystemCode == "BG", x => new { x.IsCustoms })
.EnableDiffLogEvent().ExecuteCommandAsync();
// 记录日志
await SaveSeaExportLogAsync(new SeaExportSaveLog()

@ -10,7 +10,7 @@ using MiniExcelLibs;
namespace DS.WMS.FeeApi.Controllers
{
/// <summary>
/// 往来单位费用模板API
/// 自动费用模板API
/// </summary>
public class FeeCustTemplateController : ApiController
{
@ -53,24 +53,13 @@ namespace DS.WMS.FeeApi.Controllers
/// </summary>
/// <returns></returns>
[HttpPost, Route("Import")]
public async Task<IActionResult> ImportAsync()
public async Task<IActionResult> ImportAsync(IFormFile file)
{
Stream? stream;
try
{
if (Request.Form.Files.Count == 0)
return BadRequest("请求不包含文件流");
stream = Request.Form.Files[0].OpenReadStream();
}
catch (InvalidOperationException)
{
stream = Request.Body;
}
if (file == null)
return BadRequest("请求未包含文件流");
MemoryStream ms = new();
await stream.CopyToAsync(ms);
var query = await MiniExcel.QueryAsync(ms, excelType: ExcelType.XLSX, startCell: "A4");
var stream = file.OpenReadStream();
var query = await MiniExcel.QueryAsync(stream, excelType: ExcelType.XLSX, startCell: "A4");
List<FeeCustTemplateModel> list = [];
try
{
@ -116,7 +105,6 @@ namespace DS.WMS.FeeApi.Controllers
}
var result = await _invokeService.ImportAsync(list);
ms.Dispose();
return Ok(result);
}

@ -191,7 +191,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">业务ID和类型</param>
/// <returns></returns>
[HttpPost, Route("ApplyBusinessAudit")]
public async Task<DataResult> ApplyBusinessAuditAsync(IdModel model)
public async Task<DataResult> ApplyBusinessAuditAsync([FromBody] IdModel model)
{
if (!long.TryParse(model.Id, out long bid) || model.BusinessType == null)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
@ -204,7 +204,8 @@ namespace DS.WMS.FeeApi.Controllers
/// </summary>
/// <param name="model">业务ID和类型</param>
/// <returns></returns>
public async Task<DataResult> WithdrawBusinessAsync(IdModel model)
[HttpPost, Route("WithdrawBusiness")]
public async Task<DataResult> WithdrawBusinessAsync([FromBody] IdModel model)
{
if (!long.TryParse(model.Id, out long bid) || model.BusinessType == null)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
@ -218,7 +219,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("GetPrintInfo")]
public async Task<DataResult<dynamic>> GetPrintInfoAsync(IdModel model)
public async Task<DataResult<dynamic>> GetPrintInfoAsync([FromBody] IdModel model)
{
if (model == null || model.Ids?.Length == 0)
return DataResult<dynamic>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
@ -236,7 +237,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("SetInvoiceEnabled")]
public async Task<DataResult> SetInvoiceEnabledAsync(IdModel model)
public async Task<DataResult> SetInvoiceEnabledAsync([FromBody] IdModel model)
{
if (model == null || model.Ids?.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);

@ -196,13 +196,12 @@ public class ClientInfoController : ApiController
#region 导入
/// <summary>
/// 导入客户/供应商
/// 导入客户
/// </summary>
/// <param name="type">类型1=客户2=供应商3=客户+供应商</param>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost, Route("Import")]
public async Task<DataResult> ImportAsync([FromForm] int type, IFormFile file)
[HttpPost, Route("ImportClient")]
public async Task<DataResult> ImportClientAsync(IFormFile file)
{
if (file == null)
return DataResult.Failed("请求未包含文件流");
@ -248,20 +247,76 @@ public class ClientInfoController : ApiController
Email = item["AF"]?.ToString(),
ContactName = item["AG"]?.ToString(),
NFDS = item["AP"] == null ? null : int.Parse(item["AP"].ToString()),
IsCustomer = true
};
//if (string.IsNullOrEmpty(model.DeptName))
// sb.Append($"行号:{rows.IndexOf(item) + 2} 未填写【所属部门】");
if (type == 3)
{
model.IsCustomer = model.IsSupplier = true;
}
else
list.Add(model);
}
if (sb.Length > 0)
return DataResult.Failed("导入失败:" + sb.ToString());
}
catch (Exception ex)
{
return DataResult.Failed("读取文件失败:" + ex.Message);
}
return await _invokeService.ImportAsync(list);
}
/// <summary>
/// 导入供应商
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost, Route("ImportSupplier")]
public async Task<DataResult> ImportSupplierAsync(IFormFile file)
{
if (file == null)
return DataResult.Failed("请求未包含文件流");
var stream = file.OpenReadStream();
var rows = (await MiniExcel.QueryAsync(stream, excelType: ExcelType.XLSX, startCell: "A2")).ToList();
StringBuilder sb = new StringBuilder();
List<InfoClientModel> list = [];
try
{
foreach (IDictionary<string, object> item in rows)
{
var model = new InfoClientModel
{
model.IsCustomer = type == 1;
model.IsSupplier = type == 2;
}
ContactTel = item["A"]?.ToString(),
Contact = item["B"]?.ToString(),
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(),
TaxID = item["I"]?.ToString(),
Code = item["J"]?.ToString(),
StlType = item["K"]?.ToString(),
Attribute = item["V"]?.ToString(),
Business = item["L"]?.ToString(),
OP = item["M"]?.ToString(),
Sale = item["N"]?.ToString(),
CustomerService = item["P"]?.ToString(),
Authenticator = item["Q"]?.ToString(),
PrepaidRMB = item["R"] == null ? 0 : decimal.Parse(item["R"].ToString()),
PrepaidUSD = item["S"] == null ? 0 : decimal.Parse(item["S"].ToString()),
Quota = item["T"] == null ? 0 : decimal.Parse(item["T"].ToString()),
RestQuota = item["U"] == null ? 0 : decimal.Parse(item["U"].ToString()),
ContactName = item["B"]?.ToString(),
IsSupplier = true
};
//if (string.IsNullOrEmpty(model.DeptName))
// sb.Append($"行号:{rows.IndexOf(item) + 2} 未填写【所属部门】");
list.Add(model);
}
@ -278,6 +333,115 @@ public class ClientInfoController : ApiController
return await _invokeService.ImportAsync(list);
}
/// <summary>
/// 导入银行与发票
/// </summary>
/// <param name="service"></param>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost, Route("ImportBank")]
public async Task<DataResult> ImportBankAsync([FromServices] IClientBankService service, IFormFile file)
{
if (file == null)
return DataResult.Failed("请求未包含文件流");
var stream = file.OpenReadStream();
var rows = (await MiniExcel.QueryAsync(stream, excelType: ExcelType.XLSX, startCell: "A2")).ToList();
StringBuilder sb = new StringBuilder();
List<InfoClientBankModel> list = [];
try
{
foreach (IDictionary<string, object> item in rows)
{
var model = new InfoClientBankModel
{
CompanyName = item["A"]?.ToString(),
Currency = item["B"]?.ToString(),
BankName = item["C"]?.ToString(),
BankAccount = item["E"]?.ToString(),
BankAddress = item["F"]?.ToString(),
InvoiceAddress = item["G"]?.ToString(),
InvoiceRecevier = item["H"]?.ToString(),
Tel = item["I"]?.ToString(),
TaxId = item["J"]?.ToString(),
InvoiceTel = item["K"]?.ToString(),
Remark = item["L"]?.ToString(),
InvoiceHeader = item["M"]?.ToString(),
IsDefaultP = int.TryParse(item["N"]?.ToString(), out int value1) && value1 == 1,
IsDefaultR = int.TryParse(item["O"]?.ToString(), out int value2) && value2 == 1,
IsDefault = int.TryParse(item["P"]?.ToString(), out int value3) && value3 == 1,
};
if (string.IsNullOrEmpty(model.CompanyName))
sb.Append($"行号:{rows.IndexOf(item) + 2} 未填写【公司名称】");
list.Add(model);
}
if (sb.Length > 0)
return DataResult.Failed("导入失败:" + sb.ToString());
}
catch (Exception ex)
{
return DataResult.Failed("读取文件失败:" + ex.Message);
}
return await service.ImportAsync(list);
}
/// <summary>
/// 导入联系人
/// </summary>
/// <param name="service"></param>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost, Route("ImportContact")]
public async Task<DataResult> ImportContactAsync([FromServices] IClientContactService service, IFormFile file)
{
if (file == null)
return DataResult.Failed("请求未包含文件流");
var stream = file.OpenReadStream();
var rows = (await MiniExcel.QueryAsync(stream, excelType: ExcelType.XLSX, startCell: "A2")).ToList();
StringBuilder sb = new StringBuilder();
List<InfoClientContactModel> list = [];
try
{
foreach (IDictionary<string, object> item in rows)
{
var model = new InfoClientContactModel
{
CompanyName = item["A"]?.ToString(),
ContactName = item["B"]?.ToString(),
ContactEnName = item["C"]?.ToString(),
Tel = item["D"]?.ToString(),
Mobile = item["E"]?.ToString(),
Email = item["F"]?.ToString(),
QQ = item["G"]?.ToString(),
IsDefault = item["H"]?.ToString() == "是",
Job = item["I"]?.ToString()
};
if (string.IsNullOrEmpty(model.CompanyName))
sb.Append($"行号:{rows.IndexOf(item) + 2} 未填写【公司名称】");
list.Add(model);
}
if (sb.Length > 0)
return DataResult.Failed("导入失败:" + sb.ToString());
}
catch (Exception ex)
{
return DataResult.Failed("读取文件失败:" + ex.Message);
}
return await service.ImportAsync(list);
}
#endregion
}

@ -6,6 +6,7 @@ using DS.Module.PrintModule;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.TaskPlat.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -23,6 +24,8 @@ namespace DS.WMS.OpApi.Controllers
private readonly IUser user;
private readonly ISaasDbService saasDbService;
private readonly ISeaExportCommonService _seaComService;
/// <summary>
/// 构造函数
/// </summary>
@ -35,6 +38,7 @@ namespace DS.WMS.OpApi.Controllers
this.serviceProvider = serviceProvider;
this.user = user;
this.saasDbService = saasDbService;
this._seaComService = serviceProvider.GetRequiredService<ISeaExportCommonService>();
}
/// <summary>
@ -129,6 +133,10 @@ namespace DS.WMS.OpApi.Controllers
[Route("SaveServiceStatus")]
public async Task<DjyResult> SaveServiceStatus([FromBody] EmbedServiceProjectStatusDto req)
{
if (req.StatusCodes[0].StatusCode.Contains("BG")|| req.StatusCodes[0].StatusCode.Contains("YPC"))
{
_seaComService.UpdateSeaExportTag(long.Parse(req.businessId), req.StatusCodes[0].StatusCode,true);
}
return await _invokeService.SaveServiceStatus(req);
}
@ -142,6 +150,10 @@ namespace DS.WMS.OpApi.Controllers
[Route("CancelServiceStatus")]
public async Task<DjyResult> CancelServiceStatus([FromBody] EmbedServiceProjectStatusDto req)
{
if (req.StatusCodes[0].StatusCode.Contains("BG") || req.StatusCodes[0].StatusCode.Contains("YPC"))
{
_seaComService.UpdateSeaExportTag(long.Parse(req.businessId), req.StatusCodes[0].StatusCode, false);
}
return await _invokeService.CancelServiceStatus(req);
}

Loading…
Cancel
Save