费用报表修改

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

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

@ -117,10 +117,11 @@ public interface IFeeRecordService
/// 获取费用打印信息 /// 获取费用打印信息
/// </summary> /// </summary>
/// <param name="providerName">数据提供程序</param> /// <param name="providerName">数据提供程序</param>
/// <param name="businessType">业务类型</param> /// <param name="bsId">业务ID</param>
/// <param name="idArray">费用记录ID</param> /// <param name="bsType">业务类型</param>
/// <param name="ids">费用记录ID</param>
/// <returns></returns> /// <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> /// <summary>
/// 设置发票启用状态 /// 设置发票启用状态

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

@ -4,7 +4,6 @@ using DS.WMS.Core.Fee.Dtos.Report;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Masuit.Tools.Systems; using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
@ -22,7 +21,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
switch (context.BusinessType) switch (context.BusinessType)
{ {
case BusinessType.OceanShippingExport: case BusinessType.OceanShippingExport:
form = await GetOceanShippingExportAsync(context.TenantDb, context.Ids); form = await GetOceanShippingExportAsync(context.TenantDb, context.BusinessId, context.Ids ?? []);
break; break;
case BusinessType.OceanShippingImport: case BusinessType.OceanShippingImport:
@ -35,8 +34,9 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null) if (form != null)
{ {
long UserId = long.Parse(context.User.UserId); //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.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.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); 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; CostAccounting? form = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == bsId)
var list = await tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id) .Select(x => new CostAccounting
.Where((x, y) => idArray.Contains(x.Id)
//&& x.FeeStatus == FeeStatus.SettlementCompleted
).Select((x, y) => new
{ {
x.FeeType, BusinessNo = x.CustomerNo,
x.FeeName, AccountingPeriod = x.AccountDate,
x.Currency, Voy = x.Voyno,
x.ExchangeRate, POL = x.LoadPort,
x.Amount, POD = x.DischargePort,
x.CustomerName, Volume = x.CntrTotal, //Volume
y.CustomerNo, //业务编号 ReleaseType = x.IssueType, //放单方式
y.AccountDate, //会计期间 PrintTime = SqlFunc.GetDate(),
y.ETA,
y.ETD,
y.Voyno,
y.MBLNO,
y.Carrier,
y.LoadPort,
y.DischargePort,
y.CntrTotal, //Volume
y.IssueType //放单方式
}).ToListAsync();
if (list.Count == 0) Details = SqlFunc.Subqueryable<FeeRecord>().Where(y => y.BusinessId == x.Id)
return form; .WhereIF(ids.Length > 0, y => ids.Contains(y.Id))
.ToList(y => new CostAccountingDetail
var item = list[0];
form = new CostAccounting
{ {
BusinessNo = item.CustomerNo, Amount = y.Amount,
AccountingPeriod = item.AccountDate, Currency = y.Currency,
ETA = item.ETA, CustomerName = y.CustomerName,
ETD = item.ETD, FeeName = y.FeeName,
Voy = item.Voyno, Type = y.FeeType
MBLNo = item.MBLNO, })
Carrier = item.Carrier, }, true).FirstAsync();
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()
};
return form; return form;
} }

@ -5,7 +5,6 @@ using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using Masuit.Tools.Systems; using Masuit.Tools.Systems;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method.ReportProviders 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) public async Task<dynamic?> GetDataAsync(ReportContext context)
{ {
DebitNote? form = null; DebitNote? form = null;
long id = context.Ids[0];
switch (context.BusinessType) switch (context.BusinessType)
{ {
case BusinessType.OceanShippingExport: 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; break;
case BusinessType.OceanShippingImport: case BusinessType.OceanShippingImport:
@ -34,7 +32,8 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null) 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 .Select(x => new DebitNoteItem
{ {
FeeName = x.FeeName, FeeName = x.FeeName,

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

@ -241,19 +241,22 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary> /// <summary>
/// 获取费用打印数据 /// 获取费用打印数据
/// </summary> /// </summary>
/// <param name="model">费用记录ID</param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost, Route("GetPrintInfo")] [HttpPost, Route("GetPrintInfo")]
public async Task<DataResult<dynamic>> GetPrintInfoAsync([FromBody] IdModel model) 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); return DataResult<dynamic>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
string? providerName = model.Value?.ToString(); string? providerName = model.Value?.ToString();
if (string.IsNullOrEmpty(providerName)) if (string.IsNullOrEmpty(providerName))
providerName = typeof(CostAccountingReport).AssemblyQualifiedName; 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> /// <summary>

Loading…
Cancel
Save