费用报表修改

dev
嵇文龙 1 month ago
parent 99fb59ac15
commit 5169926ae6

@ -35,14 +35,19 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public DataResult? ErrorResult { get; set; }
/// <summary>
/// 业务ID
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 业务ID
/// 费用ID
/// </summary>
public long[] Ids { get; set; } = [];
public long[]? Ids { get; set; }
}
}

@ -117,10 +117,11 @@ public interface IFeeRecordService
/// 获取费用打印信息
/// </summary>
/// <param name="providerName">数据提供程序</param>
/// <param name="businessType">业务类型</param>
/// <param name="idArray">费用记录ID</param>
/// <param name="bsId">业务ID</param>
/// <param name="bsType">业务类型</param>
/// <param name="ids">费用记录ID</param>
/// <returns></returns>
Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray);
Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, long bsId, BusinessType bsType, params long[] ids);
/// <summary>
/// 设置发票启用状态

@ -1044,24 +1044,29 @@ namespace DS.WMS.Core.Fee.Method
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
/// <summary>
//// <summary>
/// 获取费用打印信息
/// </summary>
/// <param name="providerName"></param>
/// <param name="businessType">业务类型</param>
/// <param name="idArray">费用记录ID</param>
/// <param name="providerName">数据提供程序</param>
/// <param name="bsId">业务ID</param>
/// <param name="bsType">业务类型</param>
/// <param name="ids">费用记录ID</param>
/// <returns></returns>
public async Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray)
public async Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, long bsId, BusinessType bsType, params long[] ids)
{
Type type = Type.GetType(providerName, false);
if (type == null)
return DataResult<dynamic>.Failed("未能找到数据提供程序");
return DataResult<dynamic>.Failed("未能找到数据提供程序" + providerName);
var provider = Fasterflect.ConstructorExtensions.CreateInstance(type) as IReportProvider;
if (provider == null)
return DataResult<dynamic>.Failed("未能找到数据提供程序:" + providerName);
var context = new ReportContext
{
BusinessType = businessType,
Ids = idArray,
BusinessId = bsId,
BusinessType = bsType,
Ids = ids,
Db = Db,
TenantDb = TenantDb,
User = User,

@ -4,7 +4,6 @@ using DS.WMS.Core.Fee.Dtos.Report;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
@ -22,7 +21,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
switch (context.BusinessType)
{
case BusinessType.OceanShippingExport:
form = await GetOceanShippingExportAsync(context.TenantDb, context.Ids);
form = await GetOceanShippingExportAsync(context.TenantDb, context.BusinessId, context.Ids ?? []);
break;
case BusinessType.OceanShippingImport:
@ -35,8 +34,9 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null)
{
long UserId = long.Parse(context.User.UserId);
form.Creator = context.Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.UserName).First();
//long UserId = long.Parse(context.User.UserId);
//form.Creator = context.Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.UserName).First();
form.Creator = context.User.UserName;
form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
@ -63,60 +63,31 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
}
//获取海运出口打印数据
static async Task<CostAccounting> GetOceanShippingExportAsync(ISqlSugarClient tenantDb, params long[] idArray)
static async Task<CostAccounting?> GetOceanShippingExportAsync(ISqlSugarClient tenantDb, long bsId, params long[] ids)
{
CostAccounting form = null;
var list = await tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
.Where((x, y) => idArray.Contains(x.Id)
//&& x.FeeStatus == FeeStatus.SettlementCompleted
).Select((x, y) => new
CostAccounting? form = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == bsId)
.Select(x => new CostAccounting
{
x.FeeType,
x.FeeName,
x.Currency,
x.ExchangeRate,
x.Amount,
x.CustomerName,
y.CustomerNo, //业务编号
y.AccountDate, //会计期间
y.ETA,
y.ETD,
y.Voyno,
y.MBLNO,
y.Carrier,
y.LoadPort,
y.DischargePort,
y.CntrTotal, //Volume
y.IssueType //放单方式
}).ToListAsync();
BusinessNo = x.CustomerNo,
AccountingPeriod = x.AccountDate,
Voy = x.Voyno,
POL = x.LoadPort,
POD = x.DischargePort,
Volume = x.CntrTotal, //Volume
ReleaseType = x.IssueType, //放单方式
PrintTime = SqlFunc.GetDate(),
if (list.Count == 0)
return form;
var item = list[0];
form = new CostAccounting
{
BusinessNo = item.CustomerNo,
AccountingPeriod = item.AccountDate,
ETA = item.ETA,
ETD = item.ETD,
Voy = item.Voyno,
MBLNo = item.MBLNO,
Carrier = item.Carrier,
POL = item.LoadPort,
POD = item.DischargePort,
Volume = item.CntrTotal,
ReleaseType = item.IssueType,
PrintTime = DateTime.Now,
Details = list.Select(x => new CostAccountingDetail
{
Amount = x.Amount,
Currency = x.Currency,
CustomerName = x.CustomerName,
FeeName = x.FeeName,
Type = x.FeeType
}).ToList()
};
Details = SqlFunc.Subqueryable<FeeRecord>().Where(y => y.BusinessId == x.Id)
.WhereIF(ids.Length > 0, y => ids.Contains(y.Id))
.ToList(y => new CostAccountingDetail
{
Amount = y.Amount,
Currency = y.Currency,
CustomerName = y.CustomerName,
FeeName = y.FeeName,
Type = y.FeeType
})
}, true).FirstAsync();
return form;
}

@ -5,7 +5,6 @@ using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Entity;
using Masuit.Tools.Systems;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method.ReportProviders
{
@ -17,11 +16,10 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
public async Task<dynamic?> GetDataAsync(ReportContext context)
{
DebitNote? form = null;
long id = context.Ids[0];
switch (context.BusinessType)
{
case BusinessType.OceanShippingExport:
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == id).Select<DebitNote>().FirstAsync();
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == context.BusinessId).Select<DebitNote>().FirstAsync();
break;
case BusinessType.OceanShippingImport:
@ -34,7 +32,8 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null)
{
form.Items = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == id && x.BusinessType == context.BusinessType)
form.Items = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType)
.WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id))
.Select(x => new DebitNoteItem
{
FeeName = x.FeeName,

@ -20,11 +20,10 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
public async Task<dynamic?> GetDataAsync(ReportContext context)
{
ProfitAccounting? form = null;
long id = context.Ids[0];
switch (context.BusinessType)
{
case BusinessType.OceanShippingExport:
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == id)
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == context.BusinessId)
.LeftJoin<InfoClient>((s, c) => s.CustomerId == c.Id)
.Select((s, c) => new ProfitAccounting
{
@ -48,7 +47,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null)
{
var contacts = await context.TenantDb.Queryable<BusinessOrderContact>().Where(c1 => c1.BusinessId == id && CustomerTypes.Contains(c1.CustomerType))
var contacts = await context.TenantDb.Queryable<BusinessOrderContact>().Where(c1 => c1.BusinessId == context.BusinessId && CustomerTypes.Contains(c1.CustomerType))
.Select(x => new Contact
{
Name = x.Name,
@ -64,7 +63,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
form.TruckerContact = contacts.Find(x => x.CustomerType == "truck");
form.CustomserContact = contacts.Find(x => x.CustomerType == "custom");
var remarks = await context.TenantDb.Queryable<SeaExportRemark>().Where(x => x.Pid == id)
var remarks = await context.TenantDb.Queryable<SeaExportRemark>().Where(x => x.Pid == context.BusinessId)
.Select(x => new
{
x.RemarkType,
@ -74,7 +73,8 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
form.CabinRemark = remarks.Find(x => x.RemarkType == "2")?.Remark;
form.BookingRemark = remarks.Find(x => x.RemarkType == "3")?.Remark;
var list = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == id && x.BusinessType == context.BusinessType)
var list = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType)
.WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id))
.Select<FeeRecordRes>().ToListAsync();
if (list.Count > 0)
{

@ -241,19 +241,22 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary>
/// 获取费用打印数据
/// </summary>
/// <param name="model">费用记录ID</param>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost, Route("GetPrintInfo")]
public async Task<DataResult<dynamic>> GetPrintInfoAsync([FromBody] IdModel model)
{
if (model == null || model.Ids?.Length == 0)
if (model == null || !long.TryParse(model.Id, out long bsId))
return DataResult<dynamic>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
string? providerName = model.Value?.ToString();
if (string.IsNullOrEmpty(providerName))
providerName = typeof(CostAccountingReport).AssemblyQualifiedName;
return await _feeService.GetPrintInfoAsync(providerName, (BusinessType)model.BusinessType.Value, model.Ids);
if (!providerName.Contains('.'))
providerName = "DS.WMS.Core.Fee.Method.ReportProviders." + providerName;
return await _feeService.GetPrintInfoAsync(providerName, bsId, (BusinessType)model.BusinessType.Value, model.Ids);
}
/// <summary>

Loading…
Cancel
Save