douhandong 1 month ago
commit 345479d530

@ -705,6 +705,9 @@ public static class MultiLanguageConst
[Description("税率不一致,禁止提交")]
public const string InconsistentTaxRates= "Inconsistent_Tax_Rates";
[Description("发票或其明细已进入结算流程,请先取消结算后再删除")]
public const string InvoiceIsSettled = "Invoice_Is_Settled";
#endregion
#region 预订舱API

@ -51,6 +51,11 @@ namespace DS.WMS.Core.Application.Dtos
/// </summary>
public long CustomerId { get; set; }
/// <summary>
/// 费用对象名称
/// </summary>
public string? CustomerName { get; set; }
/// <summary>
/// 汇率信息
/// </summary>

@ -1,8 +1,7 @@
using DS.WMS.Core.Application.Dtos;
using System.Linq.Expressions;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Entity;
using System.Linq.Expressions;
using DS.WMS.Core.Fee.Method;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
@ -35,8 +34,7 @@ namespace DS.WMS.Core.Application.Method
.InnerJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
.LeftJoin<SeaExport>((d, f, s) => f.BusinessId == s.Id && f.BusinessType == BusinessType.OceanShippingExport)
.WhereIF(expr1 != null, expr1)
.LeftJoin<CodeSource>((d, f, s, cs) => s.SourceId == cs.Id)
.Select((d, f, s, cs) => new ApplicationDetailDto
.Select((d, f, s) => new ApplicationDetailDto
{
//---------------明细表--------------
Id = d.Id,
@ -45,7 +43,6 @@ namespace DS.WMS.Core.Application.Method
RefId = d.RefId,
RecordId = d.RecordId,
FeeType = d.FeeType,
CustomerName = d.CustomerName,
FeeId = d.FeeId,
FeeName = d.FeeName,
Currency = d.Currency,
@ -60,19 +57,19 @@ namespace DS.WMS.Core.Application.Method
Amount = f.Amount,
AccTaxRate = f.AccTaxRate,
CustomerId = f.CustomerId,//费用对象ID
CustomerName = f.CustomerName,
OrderAmount = f.OrderAmount,
InvoiceAmount = f.InvoiceAmount,
SettlementAmount = f.SettlementAmount,
OrderSettlementAmount = f.OrderSettlementAmount,
OrderInvSettlementAmount = f.OrderInvSettlementAmount,
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
//---------------业务表--------------
BusinessId = s.Id,
BusinessType = BusinessType.OceanShippingExport,
AccountDate = s.AccountDate,
CntrTotal = s.CntrTotal,
CustomerNo = s.CustomerNo,
ClientName = s.CustomerName, //委托单位
//DischargePort = s.DischargePort,
ETD = s.ETD,
HBLNO = s.HBLNO,
LoadPort = s.LoadPort,
@ -82,8 +79,7 @@ namespace DS.WMS.Core.Application.Method
Vessel = s.Vessel,//船名
Voyage = s.Voyno,//航次
BookingNo = s.BookingNo,
//---------------附加表--------------
SourceName = cs.SourceName
SourceName = s.SourceName
});
//海运进口

@ -15,7 +15,7 @@ public interface IFeeRecordService
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult<List<FeeRecordRes>>> GetListByPageAsync(PageRequest request);
Task<DataResult<List<FeeRecordRes>>> GetListAsync(PageRequest request);
/// <summary>
/// 根据查询条件获取费用数据

@ -42,11 +42,26 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<FeeRecordRes>>> GetListByPageAsync(PageRequest request)
public async Task<DataResult<List<FeeRecordRes>>> GetListAsync(PageRequest request)
{
long UserId = long.Parse(User.UserId);
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
//传递业务查询条件检测
string? bsId = null;
foreach (var item in whereList)
{
if (item is ConditionalModel conditionModel && string.Equals(conditionModel.FieldName, nameof(FeeRecord.BusinessId), StringComparison.OrdinalIgnoreCase))
{
bsId = conditionModel.FieldValue;
break;
}
}
//未指定业务ID返回空
if (string.IsNullOrEmpty(bsId))
return DataResult<List<FeeRecordRes>>.Success([]);
var data = await TenantDb.Queryable<FeeRecord>()
.Where(x => x.IsOpen || (!x.IsOpen && x.CreateBy == UserId))
.Where(whereList)

@ -57,7 +57,7 @@ namespace DS.WMS.Core.Fee.Method
if (req.Id == 0)
{
if (tenantDb.Queryable<FeeTemplate>()
.Where(x => x.OpType == req.OpType && x.FeeType == req.FeeType).Any())
.Where(x => x.OpType == req.OpType && x.FeeType == req.FeeType && x.TemplateName == req.TemplateName).Any())
{
return DataResult.Failed("费用模板已存在!", MultiLanguageConst.FeeTemplateExist);
}

@ -337,18 +337,6 @@ 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
//});
clients.Add(client);
}
@ -362,17 +350,14 @@ public class ClientInfoService : ServiceBase, IClientInfoService
foreach (var item in client.AccountDates)
item.ClientId = client.Id;
//foreach (var item in client.Contacts)
// item.ClientId = client.Id;
}
var tags = clients.Select(x => x.ClientTag).ToList();
await TenantDb.Fastest<InfoClientTag>().BulkMergeAsync(tags);
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;
}

@ -105,12 +105,15 @@ namespace DS.WMS.Core.Invoice.Method
OriginalCurrency = x.OriginalCurrency, //原始币别
ExchangeRate = x.ExchangeRate, //折算汇率
OriginalAmount = x.OriginalAmount, //原始金额
SaleName = x.SaleName,
CustomerNo = x.CustomerNo,
MBLNO = x.MBLNO,
HBLNO = x.HBLNO,
SaleName = x.SaleName,
ClientName = x.ClientName,
ETD = x.ETD,
SourceName = x.SourceName,
AuditTime = y.AuditTime
}).ToListAsync();
@ -146,7 +149,7 @@ namespace DS.WMS.Core.Invoice.Method
protected override Task PostSaveAsync(Entity.Invoice invoice)
{
return Task.Factory.StartNew(UpdateInvoiceApplications, new List<Entity.Invoice> { invoice });
return RefreshApplicationStatus([invoice], null);
}
protected override async Task OnDeleteDetailAsync(List<Entity.Invoice> invoices, DeleteOption deleteOption)
@ -205,42 +208,59 @@ namespace DS.WMS.Core.Invoice.Method
protected override Task PostDeleteAsync(List<Entity.Invoice> invoices, DeleteOption deleteOption)
{
return Task.Factory.StartNew(UpdateInvoiceApplications, invoices);
////获取关联的发票申请的ID
//var ids = invoices.SelectMany(x => x.Details).Where(x => x.RefId.HasValue).Select(x => x.RefId.GetValueOrDefault()).Distinct();
//if (deleteOption == DeleteOption.Entire)
//{
// return TenantDb.Updateable<InvoiceApplication>()
// .SetColumns(x => x.Status == InvoiceApplicationStatus.AuditPassed)
// .Where(x => ids.Contains(x.Id))
// .ExecuteCommandAsync();
//}
//else if (deleteOption == DeleteOption.DetailOnly)
//{
// //获取关联的发票申请的明细ID
// var ids2 = invoices.SelectMany(x => x.Details).Where(x => x.DetailId.HasValue).Select(x => x.DetailId.GetValueOrDefault()).Distinct();
//}
//return Task.CompletedTask;
return RefreshApplicationStatus(invoices, deleteOption);
}
//更新发票申请的状态
void UpdateInvoiceApplications(object? state)
private async Task RefreshApplicationStatus(List<Entity.Invoice> invoices, DeleteOption? deleteOption)
{
var list = state as IEnumerable<Entity.Invoice>;
if (list == null || !list.Any())
if (invoices == null || !invoices.Any())
return;
var ids = list.SelectMany(x => x.Details).Where(x => x.RefId.HasValue).Select(x => x.RefId.GetValueOrDefault()).Distinct().ToList();
var appDetails = TenantDb.Queryable<ApplicationDetail>().Where(d => ids.Contains(d.ApplicationId))
//获取关联的发票申请的ID
var ids = invoices.SelectMany(x => x.Details).Where(x => x.RefId.HasValue).Select(x => x.RefId.GetValueOrDefault()).Distinct().ToList();
var appDetails = await TenantDb.Queryable<ApplicationDetail>().Where(d => ids.Contains(d.ApplicationId))
.Select(d => new ApplicationDetail
{
Id = d.Id,
Category = d.Category,
ApplicationId = d.ApplicationId,
OriginalAmount = d.OriginalAmount,
OriginalProcessedAmount = d.OriginalProcessedAmount
}).ToList();
}).ToListAsync();
List<InvoiceApplication> list2 = new(ids.Count);
foreach (var id in ids)
{
var entity = new InvoiceApplication { Id = id };
var inv = list.FirstOrDefault(x => x.Details.Any(y => y.RefId == id));
entity.AcutalInvoiceNO = inv?.InvoiceNO;
var details = appDetails.FindAll(x => x.ApplicationId == id);
if (details.All(x => x.OriginalAmount == x.OriginalAmount - x.OriginalProcessedAmount))
{
entity.Status = InvoiceApplicationStatus.Invoiced;
entity.Status = deleteOption.HasValue ? InvoiceApplicationStatus.AuditPassed : InvoiceApplicationStatus.Invoiced;
list2.Add(entity);
}
else if (details.All(x => x.OriginalAmount - x.OriginalProcessedAmount == 0))
{
entity.Status = InvoiceApplicationStatus.AuditPassed;
entity.Status = deleteOption == null ? InvoiceApplicationStatus.Invoiced : InvoiceApplicationStatus.AuditPassed;
list2.Add(entity);
}
else if (details.Exists(x => x.OriginalAmount != x.OriginalAmount - x.OriginalProcessedAmount))
@ -250,7 +270,8 @@ namespace DS.WMS.Core.Invoice.Method
}
}
TenantDb.Updateable(list2).UpdateColumns(x => new { x.Status, x.AcutalInvoiceNO }).ExecuteCommand();
await TenantDb.Updateable(list2).UpdateColumns(x => new { x.Status }).ExecuteCommandAsync();
}
}
}

@ -9,13 +9,11 @@ using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Invoice.Interface;
using DS.WMS.Core.Settlement.Entity;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using LanguageExt.Pretty;
using Mapster;
using Masuit.Tools.Models;
using Microsoft.Extensions.DependencyInjection;
using Org.BouncyCastle.Asn1.Cmp;
using SqlSugar;
namespace DS.WMS.Core.Invoice.Method
@ -227,7 +225,8 @@ namespace DS.WMS.Core.Invoice.Method
if (invoice.PushModeValues.Length > 0)
invoice.PushMode = string.Join(",", invoice.PushModeValues.Select(x => (int)x));
if (request.Invoice.Mode == InvoiceMode.Applcation && request.Applications != null && request.Applications.Count > 0) //按发票申请开出
//按申请开票
if (request.Invoice.Mode == InvoiceMode.Applcation && request.Applications?.Count > 0)
{
var ids = request.Applications.Select(x => x.ApplicationId);
var details = await TenantDb.Queryable<ApplicationDetail>()
@ -339,21 +338,36 @@ namespace DS.WMS.Core.Invoice.Method
invoice.Details.Add(detail);
}
DataResult result2;
//执行开票金额分配
foreach (var app in request.Applications)
{
var details2 = invoice.Details.Where(x => x.RefId == app.ApplicationId).OrderBy(x => x.ApplyAmount).ToList();
if (app.AmountRMB.HasValue)
{
result2 = AssignAmount(details2.FindAll(x => x.OriginalCurrency == FeeCurrency.RMB_CODE), app.AmountRMB.Value);
if (!result2.Succeeded)
return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
}
if (app.AmountUSD.HasValue)
{
result2 = AssignAmount(details2.FindAll(x => x.OriginalCurrency == FeeCurrency.USD_CODE), app.AmountUSD.Value);
if (!result2.Succeeded)
return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
}
////执行开票金额分配
//foreach (var app in request.Applications)
//{
// var details2 = invoice.Details.Where(x => x.RefId == app.ApplicationId).OrderBy(x => x.ApplyAmount).ToList();
// if (app.AmountRMB.HasValue)
// {
// var result2 = AssignAmount(details2.FindAll(x => x.OriginalCurrency == FeeCurrency.RMB_CODE), app.AmountRMB.Value);
// if (!result2.Succeeded)
// return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
// }
if (app.AmountOther.HasValue)
{
result2 = AssignAmount(details2.FindAll(x => x.OriginalCurrency != FeeCurrency.RMB_CODE && x.OriginalCurrency != FeeCurrency.USD_CODE), app.AmountOther.Value);
if (!result2.Succeeded)
return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
}
//}
}
}
else if (request.Invoice.Mode == InvoiceMode.Free) //自由开票
//自由开票
else if (request.Invoice.Mode == InvoiceMode.Free)
{
if (request.BizList?.Count > 0)
{
@ -409,32 +423,32 @@ namespace DS.WMS.Core.Invoice.Method
OriginalAmount = x.OriginalAmount,
OriginalCurrency = x.OriginalCurrency ?? (invoice.Currency.IsNullOrEmpty() ? x.Currency : invoice.Currency),
}).ToList();
//补充购方信息
invoice.CustomerTaxID = await TenantDb.Queryable<InfoClient>().Where(x => x.Id == invoice.CustomerId).Select(x => x.TaxNo).FirstAsync();
var header = await TenantDb.Queryable<InvoiceHeader>().Where(x => x.RelativeId == invoice.CustomerId)
.OrderByDescending(x => x.Id).FirstAsync();
if (header != null)
{
invoice.InvoiceHeader = header.Header;
invoice.CustomerAddressTel = header.AddressTel;
}
var clientBank = await TenantDb.Queryable<InfoClientBank>().Where(x => x.ClientId == invoice.CustomerId && x.Currency == invoice.Currency)
.OrderByDescending(x => x.IsInvoiceDefault).Select(x => new
{
x.Account,
x.BankName
}).FirstAsync();
if (clientBank != null)
{
invoice.CustomerAccount = clientBank.Account;
invoice.CustomerBankName = clientBank.BankName;
}
}
}
if (invoice.Id == 0)
{
//补充购方信息
invoice.CustomerTaxID = await TenantDb.Queryable<InfoClient>().Where(x => x.Id == invoice.CustomerId).Select(x => x.TaxNo).FirstAsync();
var header = await TenantDb.Queryable<InvoiceHeader>().Where(x => x.RelativeId == invoice.CustomerId)
.OrderByDescending(x => x.Id).FirstAsync();
if (header != null)
{
invoice.InvoiceHeader = header.Header;
invoice.CustomerAddressTel = header.AddressTel;
}
var clientBank = await TenantDb.Queryable<InfoClientBank>().Where(x => x.ClientId == invoice.CustomerId && x.Currency == invoice.Currency)
.OrderByDescending(x => x.IsInvoiceDefault).Select(x => new
{
x.Account,
x.BankName
}).FirstAsync();
if (clientBank != null)
{
invoice.CustomerAccount = clientBank.Account;
invoice.CustomerBankName = clientBank.BankName;
}
//补充销方信息
var org = await Db.Queryable<SysOrg>().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync();
if (org != null)
@ -877,6 +891,10 @@ namespace DS.WMS.Core.Invoice.Method
if (invoices.Any(x => !string.IsNullOrEmpty(x.ApiCode)))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsIssued));
var ids = invoices.Select(x => x.Id);
if (TenantDb.Queryable<ApplicationDetail>().Any(x => ids.Contains(x.RefId.Value) && x.Category == DetailCategory.InvoiceSettlement))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsSettled));
return DataResult.Success;
}
@ -888,12 +906,12 @@ namespace DS.WMS.Core.Invoice.Method
/// <returns></returns>
protected virtual async Task OnDeleteDetailAsync(List<TEntity> invoices, DeleteOption deleteOption)
{
var appIds = invoices.Select(x => x.Id);
var ids = invoices.Select(x => x.Id);
if (deleteOption == DeleteOption.DetailOnly)
{
var excludeIds = invoices.SelectMany(x => x.Details).Select(x => x.Id);
var details = await TenantDb.Queryable<ApplicationDetail>().Where(x => appIds.Contains(x.ApplicationId) && !excludeIds.Contains(x.Id))
var details = await TenantDb.Queryable<ApplicationDetail>().Where(x => ids.Contains(x.ApplicationId) && !excludeIds.Contains(x.Id))
.Select(x => new ApplicationDetail
{
Id = x.Id,
@ -919,7 +937,7 @@ namespace DS.WMS.Core.Invoice.Method
else if (deleteOption == DeleteOption.Entire)
{
//删除发票主表则同时删除对应发票明细
await TenantDb.Deleteable<InvoiceDetail>().Where(x => appIds.Contains(x.ApplicationId)).ExecuteCommandAsync();
await TenantDb.Deleteable<InvoiceDetail>().Where(x => ids.Contains(x.ApplicationId)).ExecuteCommandAsync();
}
foreach (var item in invoices)

@ -1,6 +1,5 @@
using System.Runtime.Serialization;
using DS.WMS.Core.Application.Dtos;
using SqlSugar;
namespace DS.WMS.Core.Settlement.Dtos
{
@ -161,18 +160,18 @@ namespace DS.WMS.Core.Settlement.Dtos
/// <summary>
/// 结算明细(发票开出/收、付费申请)
/// </summary>
public List<SettlementDetailDto>? SettlementDetails { get; set; }
public List<SettlementDetailGroup>? SettlementDetails { get; set; }
}
/// <summary>
/// 付费自由结算返回明细
/// 自由结算返回明细
/// </summary>
public class FreeSettlement
public class FreeSettlementDto : ApplicationSettlementDto
{
/// <summary>
/// 结算明细
/// </summary>
public new List<FreeSettlementDetailDto>? Details { get; set; }
public new List<SettlementDetailDto>? SettlementDetails { get; set; }
/// <summary>
/// 结算金额合计

@ -1,13 +1,12 @@
using System.Runtime.Serialization;
using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Application.Dtos;
namespace DS.WMS.Core.Settlement.Dtos
{
/// <summary>
/// 结算明细DTO
/// 结算(分组)明细DTO
/// </summary>
public class SettlementDetailDto
public class SettlementDetailGroup
{
/// <summary>
/// 申请/发票ID
@ -122,85 +121,10 @@ namespace DS.WMS.Core.Settlement.Dtos
}
/// <summary>
/// 付费自由结算明细DTO
/// 结算费用明细DTO
/// </summary>
public class FreeSettlementDetailDto
public class SettlementDetailDto : ApplicationDetailDto
{
/// <summary>
/// ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 费用记录ID
/// </summary>
public long RecordId { get; set; }
/// <summary>
/// 业务ID
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; }
/// <summary>
/// 主提单号
/// </summary>
public string? MBLNO { get; set; }
/// <summary>
/// 分提单号
/// </summary>
public string? HBLNO { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string? CustomerNo { get; set; }
/// <summary>
/// 委托单位
/// </summary>
public string? ClientName { get; set; }
/// <summary>
/// 开船日期
/// </summary>
public DateTime? ETD { get; set; }
/// <summary>
/// 业务来源
/// </summary>
public string? SourceName { get; set; }
/// <summary>
/// 揽货人
/// </summary>
public string? Sale { get; set; }
/// <summary>
/// 会计期间
/// </summary>
public string? AccountDate { get; set; }
/// <summary>
/// 船名
/// </summary>
public string? Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string? Voyage { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string? Carrier { get; set; }
/// <summary>
/// 经营单位
/// </summary>
@ -211,59 +135,9 @@ namespace DS.WMS.Core.Settlement.Dtos
/// </summary>
public string? CustomNo { get; set; }
/// <summary>
/// 客户/费用对象名称
/// </summary>
public string? CustomerName { get; set; }
/// <summary>
/// 费用名称
/// </summary>
public string? FeeName { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public FeeType FeeType { get; set; }
/// <summary>
/// 结算金额
/// </summary>
public decimal ApplyAmount { get; set; }
/// <summary>
/// 币别
/// </summary>
public string Currency { get; set; }
/// <summary>
/// 折算汇率
/// </summary>
public decimal? ExchangeRate { get; set; }
/// <summary>
/// 原始汇率
/// </summary>
public decimal? OriginalRate { get; set; }
/// <summary>
/// 原始币别
/// </summary>
public string OriginalCurrency { get; set; }
/// <summary>
/// 原始金额
/// </summary>
public decimal OriginalAmount { get; set; }
/// <summary>
/// 更改单
/// </summary>
public string? ChangeOrder { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Note { get; set; }
}
}

@ -89,9 +89,14 @@ namespace DS.WMS.Core.Settlement.Dtos
public string BillTypeText => BillType.GetDescription();
/// <summary>
/// 结算银行账户
/// 机构银行ID
/// </summary>
public string? Account { get; set; }
public long? OrgBankId { get; set; }
/// <summary>
/// 机构银行名称账号
/// </summary>
public string? OrgBankName { get; set; }
/// <summary>
/// 结算业务类别

@ -6,7 +6,7 @@ namespace DS.WMS.Core.Settlement.Entity
/// <summary>
/// 结算表
/// </summary>
[SugarTable("application_payment_settlement", TableDescription = "结算表")]
[SugarTable("application_settlement", TableDescription = "结算表")]
public class ApplicationSettlement : SettlementBase
{
/// <summary>

@ -53,10 +53,10 @@ namespace DS.WMS.Core.Settlement.Entity
public decimal Amount { get; set; }
/// <summary>
/// 结算银行账户
/// 机构银行账户ID
/// </summary>
[SugarColumn(ColumnDescription = "结算银行账户", Length = 50, IsNullable = true)]
public string? Account { get; set; }
[SugarColumn(ColumnDescription = "机构银行账户ID", IsNullable = true)]
public long? OrgBankId { get; set; }
/// <summary>
/// 结算业务类别

@ -29,7 +29,7 @@ namespace DS.WMS.Core.Settlement.Interface
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult<List<SettlementDetailDto>>> GetDetailsAsync(PageRequest<long> request);
Task<DataResult<List<SettlementDetailGroup>>> GetDetailsAsync(PageRequest<long> request);
/// <summary>
/// 获取付费申请分页列表

@ -30,20 +30,20 @@ namespace DS.WMS.Core.Settlement.Interface
/// </summary>
/// <param name="id">结算单ID</param>
/// <returns></returns>
Task<DataResult<ApplicationSettlementDto>> GetAsync(long id);
Task<DataResult<FreeSettlementDto>> GetAsync(long id);
/// <summary>
/// 获取结算明细
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult<FreeSettlement>> GetDetailsAsync(PageRequest<long> request);
Task<DataResult<FreeSettlementDto>> GetDetailsAsync(PageRequest<long> request);
/// <summary>
/// 根据业务编号及类型获取该票业务的币别
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
Task<DataResult<List<FeeClient>>> GetCurrenciesAsync(params FeeClient[] items);
Task<DataResult<List<FeeClient>>> GetCurrenciesAsync(List<FeeClient> items);
}
}

@ -95,6 +95,14 @@ namespace DS.WMS.Core.Settlement.Method
if (model != null)
{
if (model.SaleDeptId.HasValue)
model.SaleDeptName = await Db.Queryable<SysOrg>().Where(x => x.Id == model.SaleDeptId.Value)
.Select(x => x.OrgName).FirstAsync();
if (model.OrgBankId.HasValue)
model.OrgBankName = await TenantDb.Queryable<SysBank>().Where(x => x.Id == model.OrgBankId.Value)
.Select(x => x.BankName + " " + x.BankAccountNo).FirstAsync();
model.SettlementDetails = await GetSettlementDetails(id);
if (model.SettlementDetails.Count > 0)
{
@ -117,7 +125,7 @@ namespace DS.WMS.Core.Settlement.Method
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
protected override async Task<List<SettlementDetailDto>> GetSettlementDetails(long id)
protected override async Task<List<SettlementDetailGroup>> GetSettlementDetails(long id)
{
var list = await TenantDb.Queryable<PaymentApplication>()
.InnerJoin<ApplicationDetail>((i, d1) => i.Id == d1.ApplicationId)
@ -125,7 +133,7 @@ namespace DS.WMS.Core.Settlement.Method
.Where((i, d1, d2) => d2.ApplicationId == id &&
d2.Category == DetailCategory.PaidApplication && d1.Category == DetailCategory.ChargeApplication)
.GroupBy((i, d1, d2) => i.Id)
.Select((i, d1, d2) => new SettlementDetailDto
.Select((i, d1, d2) => new SettlementDetailGroup
{
SettlementAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(d3 => d3.ApplicationId == i.Id).Sum(d3 => d3.ApplyAmount),
ApplicationNOList = SqlFunc.Subqueryable<PaymentApplication>().Where(a => a.Id == d1.RefId).ToList(a => a.ApplicationNO)
@ -212,10 +220,10 @@ namespace DS.WMS.Core.Settlement.Method
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<SettlementDetailDto>>> GetDetailsAsync(PageRequest<long> request)
public async Task<DataResult<List<SettlementDetailGroup>>> GetDetailsAsync(PageRequest<long> request)
{
var details = await GetSettlementDetails(request.OtherQueryCondition);
return DataResult<List<SettlementDetailDto>>.Success(details);
return DataResult<List<SettlementDetailGroup>>.Success(details);
}
/// <summary>

@ -187,7 +187,7 @@ namespace DS.WMS.Core.Settlement.Method
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
public async Task<DataResult<List<FeeClient>>> GetCurrenciesAsync(params FeeClient[] items)
public async Task<DataResult<List<FeeClient>>> GetCurrenciesAsync(List<FeeClient> items)
{
var bizIds = items.Select(x => x.Id).Distinct();
var types = items.Select(x => x.BusinessType).Distinct();
@ -205,19 +205,17 @@ namespace DS.WMS.Core.Settlement.Method
f.ExchangeRate
}).ToListAsync();
var currencies = list.GroupBy(x => new { x.BusinessId, x.BusinessType, x.CustomerId }).Select(x => new FeeClient
foreach (var item in items)
{
Id = x.Key.BusinessId,
BusinessType = x.Key.BusinessType,
CustomerId = x.Key.CustomerId,
ExchangeRates = x.GroupBy(y => y.Currency).Select(y => new CurrencyExchangeRate
{
Currency = y.Key,
ExchangeRate = x.Where(z => z.Currency == y.Key).Select(z => z.ExchangeRate).FirstOrDefault()
}).ToList()
}).ToList();
item.ExchangeRates = list.Where(x => x.BusinessId == item.Id && x.BusinessType == item.BusinessType && x.CustomerId == item.CustomerId)
.GroupBy(x => x.Currency).Select(x => new CurrencyExchangeRate
{
Currency = x.Key,
ExchangeRate = x.First().ExchangeRate
}).ToList();
}
return DataResult<List<FeeClient>>.Success(currencies);
return DataResult<List<FeeClient>>.Success(items);
}
/// <summary>
@ -225,56 +223,33 @@ namespace DS.WMS.Core.Settlement.Method
/// </summary>
/// <param name="id">结算单ID</param>
/// <returns></returns>
public async Task<DataResult<ApplicationSettlementDto>> GetAsync(long id)
public async Task<DataResult<FreeSettlementDto>> GetAsync(long id)
{
var model = await TenantDb.Queryable<ApplicationSettlement>().Select(x => new ApplicationSettlementDto
var model = await TenantDb.Queryable<ApplicationSettlement>().Select(x => new FreeSettlementDto
{
SettlementTypeName = x.SettlementType.StlName, //结算方式
CustomerBankName = x.CustomerBank.BankName,
CustomerAccount = x.CustomerBank.Account
}, true).FirstAsync(x => x.Id == id && x.Mode == SettlementMode.FreeSettlement);
if (model != null)
{
Id = x.Id,
ApplicationNO = x.ApplicationNO, //申请编号
SettlementNO = x.SettlementNO, //结算单号
CustomerId = x.CustomerId, //结算单位
CustomerName = x.CustomerName,
Mode = x.Mode, //结算类型
SettlementDate = x.SettlementDate, //结算日期
SettlementTypeId = x.SettlementTypeId, //结算方式
CustomerBankId = x.CustomerBankId, //客户银行
Account = x.Account, //客户账户
Currency = x.Currency, //币别
Amount = x.Amount, //金额
ExchangeRate = x.ExchangeRate, //汇率
IsLocked = x.IsLocked, //锁定状态
SaleDeptId = x.SaleDeptId, //所属分部
BillType = x.BillType, //单据类型
Category = x.Category, //业务类别
LedgerVoucherNO = x.LedgerVoucherNO, //总账凭证号
RelativeNO = x.RelativeNO, //相关号码
InvoiceAmount = x.InvoiceAmount,
InvoiceDate = x.InvoiceDate,
InvoiceNO = x.InvoiceNO,
Note = x.Note, //备注
AccountAmount = x.AccountAmount, //记账资料
AccountCurrency = x.AccountCurrency,
AccountRate = x.AccountRate,
PrePayAmount = x.PrePayAmount, //预付支资料
PrePayCurrency = x.PrePayCurrency,
PrePayRate = x.PrePayRate,
AHSRAmount = x.AHSRAmount, //实收支资料
AHSRCurrency = x.AHSRCurrency,
AHSRRate = x.AHSRRate,
FinancialAmount = x.FinancialAmount,//财务费用
FinancialCurrency = x.FinancialCurrency,
FinancialRate = x.FinancialRate,
AdvanceAmount = x.AdvanceAmount, //预收支资料
AdvanceCurrency = x.AdvanceCurrency,
AdvanceRate = x.AdvanceRate,
}).FirstAsync(x => x.Id == id && x.Mode == SettlementMode.FreeSettlement);
var templist = await TenantDb.Queryable<ApplicationDetail>().Where(x => x.ApplicationId == id).ToListAsync();
model.SettlementDetails = templist.Adapt<List<SettlementDetailDto>>();
return DataResult<ApplicationSettlementDto>.Success(model);
if (model.SaleDeptId.HasValue)
model.SaleDeptName = await Db.Queryable<SysOrg>().Where(x => x.Id == model.SaleDeptId.Value)
.Select(x => x.OrgName).FirstAsync();
if (model.OrgBankId.HasValue)
model.OrgBankName = await TenantDb.Queryable<SysBank>().Where(x => x.Id == model.OrgBankId.Value)
.Select(x => x.BankName + " " + x.BankAccountNo).FirstAsync();
model.SettlementDetails = await CreateApplicationDetailQuery((d, f, s) => d.ApplicationId == id)
.Select(x => new SettlementDetailDto
{
}, true).ToListAsync();
}
return DataResult<FreeSettlementDto>.Success(model);
}
/// <summary>
@ -282,12 +257,12 @@ namespace DS.WMS.Core.Settlement.Method
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<FreeSettlement>> GetDetailsAsync(PageRequest<long> request)
public async Task<DataResult<FreeSettlementDto>> GetDetailsAsync(PageRequest<long> request)
{
var model = new FreeSettlement();
model.Details = await TenantDb.Queryable<ApplicationDetail>().Where(x => x.ApplicationId == request.OtherQueryCondition && x.Category == DetailCategory.PaidFreeSettlement)
var model = new FreeSettlementDto();
model.SettlementDetails = await TenantDb.Queryable<ApplicationDetail>().Where(x => x.ApplicationId == request.OtherQueryCondition && x.Category == DetailCategory.PaidFreeSettlement)
.InnerJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
.Select((d, f) => new FreeSettlementDetailDto
.Select((d, f) => new SettlementDetailDto
{
Id = d.Id,
RecordId = f.Id,
@ -304,7 +279,7 @@ namespace DS.WMS.Core.Settlement.Method
Currency = d.Currency
}).ToListAsync();
var gList = model.Details.GroupBy(x => x.BusinessType);
var gList = model.SettlementDetails.GroupBy(x => x.BusinessType);
foreach (var g in gList)
{
var ids = g.Select(x => x.BusinessId);
@ -342,7 +317,7 @@ namespace DS.WMS.Core.Settlement.Method
item.ClientName = biz.ClientName;
item.ETD = biz.ETD;
item.SourceName = biz.SourceName;
item.Sale = biz.Sale;
item.SaleName = biz.Sale;
item.AccountDate = biz.AccountDate;
item.Vessel = biz.Vessel;
item.Voyage = biz.Voyage;
@ -359,14 +334,14 @@ namespace DS.WMS.Core.Settlement.Method
}
}
model.SummaryItems = model.Details.GroupBy(x => new { x.FeeType, x.Currency }).Select(x => new SummaryItem
model.SummaryItems = model.SettlementDetails.GroupBy(x => new { x.FeeType, x.Currency }).Select(x => new SummaryItem
{
FeeType = x.Key.FeeType,
Currency = x.Key.Currency,
Amount = x.Sum(y => y.ApplyAmount)
}).ToList();
return DataResult<FreeSettlement>.Success(model);
return DataResult<FreeSettlementDto>.Success(model);
}
protected override async Task<DataResult> PreSaveAsync(ApplicationSettlement settlement)

@ -48,6 +48,10 @@ namespace DS.WMS.Core.Settlement.Method
model.SaleDeptName = await Db.Queryable<SysOrg>().Where(x => x.Id == model.SaleDeptId.Value)
.Select(x => x.OrgName).FirstAsync();
if (model.OrgBankId.HasValue)
model.OrgBankName = await TenantDb.Queryable<SysBank>().Where(x => x.Id == model.OrgBankId.Value)
.Select(x => x.BankName + " " + x.BankAccountNo).FirstAsync();
model.SettlementDetails = await GetSettlementDetails(id);
if (model.SettlementDetails.Count > 0)
{
@ -188,7 +192,7 @@ namespace DS.WMS.Core.Settlement.Method
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
protected override async Task<List<SettlementDetailDto>> GetSettlementDetails(long id)
protected override async Task<List<SettlementDetailGroup>> GetSettlementDetails(long id)
{
var list = await TenantDb.Queryable<Invoice.Entity.Invoice>()
.InnerJoin<ApplicationDetail>((i, d1) => i.Id == d1.ApplicationId)
@ -196,7 +200,7 @@ namespace DS.WMS.Core.Settlement.Method
.Where((i, d1, d2) => d2.ApplicationId == id &&
d2.Category == DetailCategory.InvoiceSettlement && d1.Category == DetailCategory.InvoiceIssuance)
.GroupBy((i, d1, d2) => i.Id)
.Select((i, d1, d2) => new SettlementDetailDto
.Select((i, d1, d2) => new SettlementDetailGroup
{
Id = i.Id,
InvoiceApplyAmount = i.ApplyAmount,

@ -1,9 +1,11 @@
using DS.Module.Core;
using System.Linq.Expressions;
using DS.Module.Core;
using DS.Module.Core.Enums;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Method;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Settlement.Dtos;
using DS.WMS.Core.Settlement.Entity;
using DS.WMS.Core.Settlement.Interface;
@ -230,7 +232,7 @@ namespace DS.WMS.Core.Settlement.Method
if (doc == null)
return DataResult<TEntity>.Failed("结算单据与费用明细不一致");
var exchange = doc.ExchangeRates?.Find(x => x.Currency == settlement.Currency);
var exchange = doc.ExchangeRates?.Find(x => x.Currency == detail.OriginalCurrency);
if (exchange == null)
return DataResult<TEntity>.Failed($"未传入结算币别 {settlement.Currency} 与费用原币别 {detail.OriginalCurrency} 之间的汇率信息");
@ -243,9 +245,11 @@ namespace DS.WMS.Core.Settlement.Method
//执行结算费用分配
foreach (var doc in request.Documents)
{
var details2 = details1.Where(x => x.RefId == doc.Id).OrderBy(x => x.ApplyAmount).ToList();
var details2 = settlement.Mode != SettlementMode.FreeSettlement ?
details1.Where(x => x.RefId == doc.Id).OrderBy(x => x.ApplyAmount) :
details1.Where(x => x.BusinessId == doc.Id && x.BusinessType == doc.BusinessType && x.CustomerName == doc.CustomerName).OrderBy(x => x.ApplyAmount);
var rmbDetails = details2.FindAll(x => x.Currency == FeeCurrency.RMB_CODE);
var rmbDetails = details2.Where(x => x.Currency == FeeCurrency.RMB_CODE);
var totalRMB = rmbDetails.Sum(x => x.ApplyAmount);
doc.SettlementRMB ??= totalRMB;
@ -265,7 +269,7 @@ namespace DS.WMS.Core.Settlement.Method
}
}
var usdDetails = details2.FindAll(x => x.Currency == FeeCurrency.USD_CODE);
var usdDetails = details2.Where(x => x.Currency == FeeCurrency.USD_CODE);
var totalUSD = usdDetails.Sum(x => x.ApplyAmount);
doc.SettlementUSD ??= totalUSD;
@ -285,7 +289,7 @@ namespace DS.WMS.Core.Settlement.Method
}
}
var otherDetails = details2.FindAll(x => x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE);
var otherDetails = details2.Where(x => x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE);
var total = rmbDetails.Sum(x => x.ApplyAmount);
doc.SettlementOther ??= total;
@ -624,9 +628,80 @@ namespace DS.WMS.Core.Settlement.Method
DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
protected virtual Task<List<SettlementDetailDto>> GetSettlementDetails(long id)
/// <summary>
/// 返回针对结算费用明细及其关联业务的查询对象
/// </summary>
/// <param name="expr1">关联条件1</param>
/// <returns>查询对象</returns>
protected virtual ISugarQueryable<SettlementDetailDto> CreateApplicationDetailQuery(
Expression<Func<ApplicationDetail, FeeRecord, SeaExport, bool>>? expr1 = null)
{
//海运出口
var query1 = TenantDb.Queryable<ApplicationDetail>()
.InnerJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
.LeftJoin<SeaExport>((d, f, s) => f.BusinessId == s.Id && f.BusinessType == BusinessType.OceanShippingExport)
.WhereIF(expr1 != null, expr1)
.Select((d, f, s) => new SettlementDetailDto
{
//---------------明细表--------------
Id = d.Id,
ApplicationId = d.ApplicationId,
DetailId = d.DetailId,
RefId = d.RefId,
RecordId = d.RecordId,
FeeType = d.FeeType,
FeeId = d.FeeId,
FeeName = d.FeeName,
Currency = d.Currency,
ApplyAmount = d.ApplyAmount,
ExchangeRate = d.ExchangeRate,
OriginalAmount = d.OriginalAmount,
OriginalCurrency = d.OriginalCurrency,
ProcessedAmount = d.ProcessedAmount,
OriginalProcessedAmount = d.OriginalProcessedAmount,
//---------------费用表--------------
OriginalRate = f.ExchangeRate,
Amount = f.Amount,
AccTaxRate = f.AccTaxRate,
CustomerId = f.CustomerId,//费用对象ID
CustomerName = f.CustomerName,
OrderAmount = f.OrderAmount,
InvoiceAmount = f.InvoiceAmount,
SettlementAmount = f.SettlementAmount,
OrderSettlementAmount = f.OrderSettlementAmount,
OrderInvSettlementAmount = f.OrderInvSettlementAmount,
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
Note = f.Note,
//---------------业务表--------------
AccountDate = s.AccountDate,
CntrTotal = s.CntrTotal,
CustomerNo = s.CustomerNo,
ClientName = s.CustomerName, //委托单位
ETD = s.ETD,
MBLNO = s.MBLNO,
HBLNO = s.HBLNO,
LoadPort = s.LoadPort,
SaleDeptId = s.SaleDeptId,
SaleName = s.Sale,//揽货人
Carrier = s.Carrier,
Vessel = s.Vessel,//船名
Voyage = s.Voyno,//航次
BookingNo = s.BookingNo,
SourceName = s.SourceName,
Enterprise = s.Enterprise,
CustomNo = s.CustomNo
});
//海运进口
return TenantDb.UnionAll(new List<ISugarQueryable<SettlementDetailDto>> { query1 });
}
protected virtual Task<List<SettlementDetailGroup>> GetSettlementDetails(long id)
{
return Task.FromResult(new List<SettlementDetailDto>());
return Task.FromResult(new List<SettlementDetailGroup>());
}
}

@ -2077,7 +2077,9 @@ namespace DS.WMS.Core.TaskPlat.Method
bc.PROCESS_DATE,
bc.PRICE_CALCULATION_DATE
}).Distinct();
#if DEBUG
var sql = queryableTemp.ToSqlString();
#endif
result = await queryableTemp.ToQueryPageAsync(querySearch.PageCondition);
return result;
@ -2620,9 +2622,9 @@ namespace DS.WMS.Core.TaskPlat.Method
s.CntrTotal,
}).Distinct();
#if DEBUG
var sql = queryableTemp.ToSqlString();
#endif
result = await queryableTemp.ToQueryPageAsync(querySearch.PageCondition);
return result;
@ -2723,21 +2725,28 @@ namespace DS.WMS.Core.TaskPlat.Method
var taskTypeStr = taskType.ToString();
var taskStatusStr = TaskStatusEnum.Cancel.ToString();
long? parentId = null;
List<long>? orderParentIdList = null;
if (!string.IsNullOrEmpty(queryDto.BusinessNo))
{
var parentIdTemp = await queryable.Context.Queryable<SeaExport>().ClearFilter(typeof(IOrgId)).Where(x => x.HBLNO == queryDto.BusinessNo).Select(x => x.ParentId).FirstAsync();
parentId = parentIdTemp == 0 ? null : parentIdTemp;
orderParentIdList = (await queryable.Context.Queryable<SeaExport>()
.ClearFilter(typeof(IOrgId))
.Where(x => x.ParentId != 0 && x.HBLNO.Contains(queryDto.BusinessNo))
.Select(x => x.ParentId)
.ToListAsync())
.Distinct().ToList(); ;
}
var isHasOrderParentIdList = orderParentIdList != null;
queryable.Where(whereList)
.Where((t, a) => t.STATUS != taskStatusStr && t.Deleted == false)
.WhereIF(taskType != null, (t, a) => t.TASK_TYPE == taskTypeStr)
.WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, bc, s) => ((t.MBL_NO != null && queryDto.BusinessNo == t.MBL_NO) || (s.MBLNO != null && queryDto.BusinessNo == s.MBLNO))
|| queryDto.BusinessNo == s.CustomerNo
|| queryDto.BusinessNo == s.BookingNo
|| queryDto.BusinessNo == s.CustomerNum
|| (parentId != null && s.Id == parentId))
.WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, bc, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询
|| s.CustomerNo.Contains(queryDto.BusinessNo)
|| s.BookingNo.Contains(queryDto.BusinessNo)
|| s.CustomerNum.Contains(queryDto.BusinessNo)
|| t.TASK_NO.Contains(queryDto.BusinessNo)
|| (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id)))
.WhereIF(taskStatLevel == TaskStatLevelEnum.PUBLIC, (t, a) => t.IS_PUBLIC == 1 && t.STATUS == queryDto.Status)
.WhereIF(taskStatLevel == TaskStatLevelEnum.PERSON, (t, a) => t.IS_PUBLIC == 0
&& (a.UserId == userId) // 2024-8-14 只显示自己需要审批的任务自己创建的任务不显示所以去掉t.CreateBy == userId ||
@ -2787,25 +2796,31 @@ namespace DS.WMS.Core.TaskPlat.Method
var userId = long.Parse(user.UserId);
queryable.ClearFilter(typeof(IOrgId));
long? parentId = null;
List<long>? orderParentIdList = null;
var taskTypeStr = taskType.ToString();
var taskStatusStr = TaskStatusEnum.Cancel.ToString();
if (!string.IsNullOrEmpty(queryDto.BusinessNo))
{
var parentIdTemp = await queryable.Context.Queryable<SeaExport>().ClearFilter(typeof(IOrgId)).Where(x => x.HBLNO == queryDto.BusinessNo).Select(x => x.ParentId).FirstAsync();
parentId = parentIdTemp == 0 ? null : parentIdTemp;
orderParentIdList = (await queryable.Context.Queryable<SeaExport>()
.ClearFilter(typeof(IOrgId))
.Where(x => x.ParentId != 0 && x.HBLNO.Contains(queryDto.BusinessNo))
.Select(x => x.ParentId)
.ToListAsync())
.Distinct().ToList();
}
var isHasOrderParentIdList = orderParentIdList != null;
queryable.Where(whereList)
.Where((t, a) => t.STATUS != taskStatusStr && t.Deleted == false)
.WhereIF(taskType != null, (t, a) => t.TASK_TYPE == taskTypeStr)
.WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && queryDto.BusinessNo == s.MBLNO) || (string.IsNullOrEmpty(s.MBLNO) && queryDto.BusinessNo == t.MBL_NO))
|| queryDto.BusinessNo == s.CustomerNo
|| queryDto.BusinessNo == s.CustomerNum
|| queryDto.BusinessNo == s.BookingNo
|| (parentId != null && s.Id == parentId))
.WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询
|| s.CustomerNo.Contains(queryDto.BusinessNo)
|| s.CustomerNum.Contains(queryDto.BusinessNo)
|| s.BookingNo.Contains(queryDto.BusinessNo)
|| t.TASK_NO.Contains(queryDto.BusinessNo)
|| (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id)))
.WhereIF(!string.IsNullOrEmpty(queryDto.PortLoadCode), (t, a, s) => queryDto.PortLoadCode == s.LoadPortCode)
.WhereIF(!string.IsNullOrEmpty(queryDto.PortDischargeCode), (t, a, s) => queryDto.PortDischargeCode == s.DischargePortCode)
@ -2913,12 +2928,17 @@ namespace DS.WMS.Core.TaskPlat.Method
var userId = long.Parse(user.UserId);
var cancelStr = TaskStatusEnum.Cancel.ToString();
long? parentId = null;
List<long>? orderParentIdList = null;
if (!string.IsNullOrEmpty(queryDto.OtherQueryCondition.BusinessNo))
{
var parentIdTemp = await tenantDb.Queryable<SeaExport>().ClearFilter(typeof(IOrgId)).Where(x => x.HBLNO == queryDto.OtherQueryCondition.BusinessNo).Select(x => x.ParentId).FirstAsync();
parentId = parentIdTemp == 0 ? null : parentIdTemp;
orderParentIdList = (await tenantDb.Queryable<SeaExport>()
.ClearFilter(typeof(IOrgId))
.Where(x => x.ParentId != 0 && x.HBLNO.Contains(queryDto.OtherQueryCondition.BusinessNo))
.Select(x => x.ParentId)
.ToListAsync())
.Distinct().ToList();
}
var isHasOrderParentIdList = orderParentIdList != null;
long[]? portLoadTaskIdList = [];
if (!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode))
@ -2974,11 +2994,12 @@ namespace DS.WMS.Core.TaskPlat.Method
.LeftJoin<SeaExport>((a, t, s) => t.OUT_BS_NO == s.Id)
.Where(whereList)
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.BusinessNo),
(a, t, s) => ((!string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == s.MBLNO) || (string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == t.MBL_NO))
|| queryDto.OtherQueryCondition.BusinessNo == s.CustomerNo
|| queryDto.OtherQueryCondition.BusinessNo == s.BookingNo
|| queryDto.OtherQueryCondition.BusinessNo == s.CustomerNum
|| (parentId != null && s.Id == parentId))
(a, t, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.OtherQueryCondition.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.OtherQueryCondition.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询
|| s.CustomerNo.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| s.BookingNo.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| s.CustomerNum.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| t.TASK_NO.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id)))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode), (t, a, s) => queryDto.OtherQueryCondition.PortLoadCode == s.LoadPortCode || portLoadTaskIdList.Contains(t.Id))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortDischargeCode), (t, a, s) => queryDto.OtherQueryCondition.PortDischargeCode == s.DischargePortCode || portDischargeTaskIdList.Contains(t.Id))
.GroupBy((a, t) => new { t.TASK_TYPE, t.STATUS, a.Status, })
@ -2989,7 +3010,9 @@ namespace DS.WMS.Core.TaskPlat.Method
TStatus = t.STATUS,
AStatus = a.Status
});
#if DEBUG
var sql2 = underlingQueryable.ToSqlString();
#endif
underlingGroupList = await underlingQueryable.ToListAsync();
#region 下属
@ -3069,16 +3092,16 @@ namespace DS.WMS.Core.TaskPlat.Method
.LeftJoin<SeaExport>((t, a, s) => t.OUT_BS_NO == s.Id)
.Where(whereList)
.Where((t, a) => t.STATUS != cancelStr && t.Deleted == false)
.Where((t, a) => t.IS_PUBLIC == 1 || (t.IS_PUBLIC == 0 && a.Status != null && (a.UserId == userId))) // 2024-8-14 只显示自己需要审批的任务自己创建的任务不显示所以去掉t.CreateBy == userId ||
.Where((t, a) => t.IS_PUBLIC == 1 || (t.IS_PUBLIC == 0 && a.UserId == userId)) // 2024-8-14 只显示自己需要审批的任务自己创建的任务不显示所以去掉t.CreateBy == userId ||
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.BusinessNo),
(t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == s.MBLNO) || (string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == t.MBL_NO))
|| queryDto.OtherQueryCondition.BusinessNo == s.CustomerNo
|| queryDto.OtherQueryCondition.BusinessNo == s.BookingNo
|| queryDto.OtherQueryCondition.BusinessNo == s.CustomerNum
|| (parentId != null && s.Id == parentId))
(t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.OtherQueryCondition.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.OtherQueryCondition.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询
|| s.CustomerNo.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| s.BookingNo.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| s.CustomerNum.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| t.TASK_NO.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id)))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode), (t, a, s) => queryDto.OtherQueryCondition.PortLoadCode == s.LoadPortCode || portLoadTaskIdList.Contains(t.Id))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortDischargeCode), (t, a, s) => queryDto.OtherQueryCondition.PortDischargeCode == s.DischargePortCode || portDischargeTaskIdList.Contains(t.Id))
.GroupBy((t, a) => new { t.TASK_TYPE, t.STATUS, a.Status, t.IS_PUBLIC })
.Select((t, a) => new TaskGroupTotal()
{
@ -3089,8 +3112,9 @@ namespace DS.WMS.Core.TaskPlat.Method
//IsExcept = t.IS_EXCEPT,
IsPublic = t.IS_PUBLIC
});
#if DEBUG
var sql = queryable.ToSqlString();
#endif
var groupList = await queryable.ToListAsync();
//var exceptList = groupList

@ -34,7 +34,7 @@ namespace DS.WMS.FeeApi.Controllers
[Route("GetList")]
public async Task<DataResult<List<FeeRecordRes>>> GetListAsync([FromBody] PageRequest request)
{
return await _feeService.GetListByPageAsync(request);
return await _feeService.GetListAsync(request);
}
/// <summary>

@ -53,7 +53,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="id">结算单ID</param>
/// <returns></returns>
[HttpGet, Route("Get")]
public async Task<DataResult<ApplicationSettlementDto>> GetAsync(long id)
public async Task<DataResult<FreeSettlementDto>> GetAsync(long id)
{
return await _service.GetAsync(id);
}
@ -65,7 +65,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <returns></returns>
/// <remarks>注意需要指定结算单ID通过 OtherQueryCondition 传入</remarks>
[HttpPost, Route("GetDetails")]
public async Task<DataResult<FreeSettlement>> GetDetailsAsync(PageRequest<long> request)
public async Task<DataResult<FreeSettlementDto>> GetDetailsAsync(PageRequest<long> request)
{
return await _service.GetDetailsAsync(request);
}
@ -88,7 +88,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
[HttpPost, Route("GetCurrencies")]
public async Task<DataResult<List<FeeClient>>> GetCurrenciesAsync([FromBody] FeeClient[] items)
public async Task<DataResult<List<FeeClient>>> GetCurrenciesAsync([FromBody] List<FeeClient> items)
{
return await _service.GetCurrenciesAsync(items);
}

@ -53,7 +53,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <returns></returns>
/// <remarks>注意若要指定结算单ID通过 OtherQueryCondition 传入</remarks>
[HttpPost, Route("GetDetails")]
public async Task<DataResult<List<SettlementDetailDto>>> GetDetailsAsync(PageRequest<long> request)
public async Task<DataResult<List<SettlementDetailGroup>>> GetDetailsAsync(PageRequest<long> request)
{
return await _service.GetDetailsAsync(request);
}

@ -61,7 +61,7 @@ app.UsePublicMiddlewares();
app.UseHangfireServer();
app.UseJobMiddlewares();
JobMiddleware.RegisterJob<IFeeCustTemplateJobService>(j => j.GenerateFeesAsync(), Cron.Daily(23, 30));
//JobMiddleware.RegisterJob<IFeeCustTemplateJobService>(j => j.GenerateFeesAsync(), Cron.Daily(23, 30));
app.Run();

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\FeeApi</_PublishTargetUrl>
<History>True|2024-10-15T09:39:40.4090324Z||;True|2024-10-15T17:06:43.0181578+08:00||;True|2024-10-15T15:07:38.9601925+08:00||;True|2024-10-12T13:33:32.4412583+08:00||;True|2024-10-11T17:00:54.0916209+08:00||;True|2024-10-11T10:54:50.3307087+08:00||;True|2024-10-11T10:45:07.8181500+08:00||;True|2024-10-11T10:40:44.2066046+08:00||;True|2024-10-11T10:21:25.7226983+08:00||;True|2024-10-11T10:09:05.5257478+08:00||;True|2024-10-10T14:58:29.1228618+08:00||;True|2024-10-10T14:05:59.4501659+08:00||;True|2024-10-10T11:08:58.9765455+08:00||;True|2024-10-08T17:59:07.5583287+08:00||;True|2024-09-27T19:01:59.6945760+08:00||;True|2024-09-27T18:45:48.2812860+08:00||;True|2024-09-27T18:10:25.5697467+08:00||;True|2024-09-27T17:39:06.3169139+08:00||;True|2024-09-27T17:30:14.1043193+08:00||;True|2024-09-27T16:02:09.0703159+08:00||;True|2024-09-27T15:53:05.1789245+08:00||;True|2024-09-27T15:32:52.1934490+08:00||;True|2024-09-27T13:51:24.9197626+08:00||;True|2024-09-27T13:48:17.2817346+08:00||;True|2024-09-27T11:51:46.8193040+08:00||;True|2024-09-27T10:58:33.1059648+08:00||;True|2024-09-27T10:37:35.0336563+08:00||;False|2024-09-27T10:31:52.6302264+08:00||;True|2024-09-26T19:50:15.5513195+08:00||;True|2024-09-26T19:47:14.0781788+08:00||;True|2024-09-26T19:01:26.5428388+08:00||;True|2024-09-26T18:35:28.7455319+08:00||;True|2024-09-26T18:24:30.8084807+08:00||;True|2024-09-26T18:20:47.3005460+08:00||;True|2024-09-26T18:04:39.8012913+08:00||;True|2024-09-26T17:48:13.8526872+08:00||;True|2024-09-26T16:08:20.1746970+08:00||;True|2024-09-26T16:01:01.1501975+08:00||;False|2024-09-26T16:00:34.1516745+08:00||;True|2024-09-26T14:33:03.4007570+08:00||;True|2024-09-25T19:14:27.8906774+08:00||;True|2024-09-25T18:57:40.1435131+08:00||;True|2024-09-25T17:38:44.0915841+08:00||;True|2024-09-25T15:33:58.4630618+08:00||;True|2024-09-25T15:10:31.3022063+08:00||;False|2024-09-25T14:14:40.9640545+08:00||;True|2024-09-25T10:09:32.2558600+08:00||;True|2024-09-25T09:59:17.1525160+08:00||;False|2024-09-25T09:57:58.7265103+08:00||;False|2024-09-25T09:53:36.7732713+08:00||;False|2024-09-24T18:40:10.0166224+08:00||;True|2024-09-24T08:59:56.1995425+08:00||;True|2024-09-23T18:07:54.7222163+08:00||;True|2024-09-23T17:23:57.7568406+08:00||;True|2024-09-23T16:28:49.3169826+08:00||;True|2024-09-23T15:57:31.8052490+08:00||;True|2024-09-23T11:47:21.1445419+08:00||;True|2024-09-23T09:24:36.0732229+08:00||;True|2024-09-21T11:59:19.0549926+08:00||;True|2024-09-21T11:24:32.4451752+08:00||;True|2024-09-21T10:39:11.5297411+08:00||;True|2024-09-20T18:24:31.7827684+08:00||;True|2024-09-19T17:55:53.1666689+08:00||;True|2024-09-19T17:42:47.9061485+08:00||;True|2024-09-19T16:08:21.7225571+08:00||;False|2024-09-19T14:15:42.9318446+08:00||;True|2024-09-19T11:20:03.5567568+08:00||;True|2024-09-18T11:35:18.1509724+08:00||;True|2024-09-18T09:08:59.1152574+08:00||;True|2024-09-14T15:48:22.9374486+08:00||;True|2024-09-14T15:42:19.0503983+08:00||;True|2024-09-14T11:51:53.3339222+08:00||;True|2024-09-14T11:41:38.3542237+08:00||;True|2024-09-14T11:19:13.1037012+08:00||;True|2024-09-13T14:31:12.4598160+08:00||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;</History>
<History>True|2024-10-16T06:12:58.1754214Z||;True|2024-10-16T14:08:06.5805581+08:00||;True|2024-10-16T11:55:29.8273176+08:00||;True|2024-10-15T17:39:40.4090324+08:00||;True|2024-10-15T17:06:43.0181578+08:00||;True|2024-10-15T15:07:38.9601925+08:00||;True|2024-10-12T13:33:32.4412583+08:00||;True|2024-10-11T17:00:54.0916209+08:00||;True|2024-10-11T10:54:50.3307087+08:00||;True|2024-10-11T10:45:07.8181500+08:00||;True|2024-10-11T10:40:44.2066046+08:00||;True|2024-10-11T10:21:25.7226983+08:00||;True|2024-10-11T10:09:05.5257478+08:00||;True|2024-10-10T14:58:29.1228618+08:00||;True|2024-10-10T14:05:59.4501659+08:00||;True|2024-10-10T11:08:58.9765455+08:00||;True|2024-10-08T17:59:07.5583287+08:00||;True|2024-09-27T19:01:59.6945760+08:00||;True|2024-09-27T18:45:48.2812860+08:00||;True|2024-09-27T18:10:25.5697467+08:00||;True|2024-09-27T17:39:06.3169139+08:00||;True|2024-09-27T17:30:14.1043193+08:00||;True|2024-09-27T16:02:09.0703159+08:00||;True|2024-09-27T15:53:05.1789245+08:00||;True|2024-09-27T15:32:52.1934490+08:00||;True|2024-09-27T13:51:24.9197626+08:00||;True|2024-09-27T13:48:17.2817346+08:00||;True|2024-09-27T11:51:46.8193040+08:00||;True|2024-09-27T10:58:33.1059648+08:00||;True|2024-09-27T10:37:35.0336563+08:00||;False|2024-09-27T10:31:52.6302264+08:00||;True|2024-09-26T19:50:15.5513195+08:00||;True|2024-09-26T19:47:14.0781788+08:00||;True|2024-09-26T19:01:26.5428388+08:00||;True|2024-09-26T18:35:28.7455319+08:00||;True|2024-09-26T18:24:30.8084807+08:00||;True|2024-09-26T18:20:47.3005460+08:00||;True|2024-09-26T18:04:39.8012913+08:00||;True|2024-09-26T17:48:13.8526872+08:00||;True|2024-09-26T16:08:20.1746970+08:00||;True|2024-09-26T16:01:01.1501975+08:00||;False|2024-09-26T16:00:34.1516745+08:00||;True|2024-09-26T14:33:03.4007570+08:00||;True|2024-09-25T19:14:27.8906774+08:00||;True|2024-09-25T18:57:40.1435131+08:00||;True|2024-09-25T17:38:44.0915841+08:00||;True|2024-09-25T15:33:58.4630618+08:00||;True|2024-09-25T15:10:31.3022063+08:00||;False|2024-09-25T14:14:40.9640545+08:00||;True|2024-09-25T10:09:32.2558600+08:00||;True|2024-09-25T09:59:17.1525160+08:00||;False|2024-09-25T09:57:58.7265103+08:00||;False|2024-09-25T09:53:36.7732713+08:00||;False|2024-09-24T18:40:10.0166224+08:00||;True|2024-09-24T08:59:56.1995425+08:00||;True|2024-09-23T18:07:54.7222163+08:00||;True|2024-09-23T17:23:57.7568406+08:00||;True|2024-09-23T16:28:49.3169826+08:00||;True|2024-09-23T15:57:31.8052490+08:00||;True|2024-09-23T11:47:21.1445419+08:00||;True|2024-09-23T09:24:36.0732229+08:00||;True|2024-09-21T11:59:19.0549926+08:00||;True|2024-09-21T11:24:32.4451752+08:00||;True|2024-09-21T10:39:11.5297411+08:00||;True|2024-09-20T18:24:31.7827684+08:00||;True|2024-09-19T17:55:53.1666689+08:00||;True|2024-09-19T17:42:47.9061485+08:00||;True|2024-09-19T16:08:21.7225571+08:00||;False|2024-09-19T14:15:42.9318446+08:00||;True|2024-09-19T11:20:03.5567568+08:00||;True|2024-09-18T11:35:18.1509724+08:00||;True|2024-09-18T09:08:59.1152574+08:00||;True|2024-09-14T15:48:22.9374486+08:00||;True|2024-09-14T15:42:19.0503983+08:00||;True|2024-09-14T11:51:53.3339222+08:00||;True|2024-09-14T11:41:38.3542237+08:00||;True|2024-09-14T11:19:13.1037012+08:00||;True|2024-09-13T14:31:12.4598160+08:00||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save