申请类审核任务

dev
嵇文龙 2 weeks ago
parent 4c95576cf4
commit 58eb8ee764

@ -24,7 +24,7 @@ namespace DS.WMS.Core.Application.Method
public abstract TaskBaseTypeEnum AuditType { get; }
readonly IClientFlowInstanceService flowService;
readonly IAuditTaskService taskService;
readonly IApplicationTaskService taskService;
/// <summary>
/// 初始化
@ -33,7 +33,7 @@ namespace DS.WMS.Core.Application.Method
public ApplicationAuditService(IServiceProvider serviceProvider) : base(serviceProvider)
{
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
taskService = serviceProvider.GetRequiredService<IAuditTaskService>();
taskService = serviceProvider.GetRequiredService<IApplicationTaskService>();
}
/// <summary>

@ -97,7 +97,7 @@ namespace DS.WMS.Core.Application.Method
protected override DataResult PreAudit(List<InvoiceApplication> applications)
{
if (applications.Exists(x => x.Status != InvoiceApplicationStatus.AuditSubmittd))
if (applications.Exists(x => x.Status != InvoiceApplicationStatus.AuditSubmittd && x.Status != InvoiceApplicationStatus.AuditPassed))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.ApplicationIsNotAuditing));
return DataResult.Success;

@ -289,7 +289,7 @@ namespace DS.WMS.Core.Application.Method
protected override DataResult PreAudit(List<PaymentApplication> applications)
{
if (applications.Exists(x => x.Status != PaymentApplicationStatus.AuditSubmittd))
if (applications.Exists(x => x.Status != PaymentApplicationStatus.AuditSubmittd && x.Status != PaymentApplicationStatus.AuditPassed))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.ApplicationIsNotAuditing));
return DataResult.Success;

@ -908,13 +908,15 @@ namespace DS.WMS.Core.Fee.Method
if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
{
if (entity.BillAuditStatus != BillAuditStatus.Pending && entity.BillAuditStatus != BillAuditStatus.RecvRejected)
if (entity.BillAuditStatus == BillAuditStatus.PaySubmitted || entity.BillAuditStatus == BillAuditStatus.PayRejected)
taskType = TaskBaseTypeEnum.BILL_PAY_AUDIT;
else if (entity.BillAuditStatus != BillAuditStatus.Pending && entity.BillAuditStatus != BillAuditStatus.RecvRejected)
return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription()));
}
else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted || entity.BillAuditStatus != BillAuditStatus.PayRejected)
if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted && entity.BillAuditStatus != BillAuditStatus.PayRejected)
return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription()));
}
@ -985,11 +987,6 @@ namespace DS.WMS.Core.Fee.Method
x.ARFeeStatus,
x.APFeeStatus
}).ExecuteCommandAsync();
//修改关联费用状态为提交审核
await TenantDb.Updateable<FeeRecord>().Where(x => x.BusinessId == bid && x.BusinessType == type &&
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.Withdraw || x.FeeStatus == FeeStatus.RejectSubmission))
.SetColumns(x => x.FeeStatus == FeeStatus.AuditSubmitted).ExecuteCommandAsync();
}
else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
@ -1000,6 +997,11 @@ namespace DS.WMS.Core.Fee.Method
}).ExecuteCommandAsync();
}
//修改关联费用状态为提交审核
await TenantDb.Updateable<FeeRecord>().Where(x => x.BusinessId == bid && x.BusinessType == type &&
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.Withdraw || x.FeeStatus == FeeStatus.RejectSubmission))
.SetColumns(x => x.FeeStatus == FeeStatus.AuditSubmitted).ExecuteCommandAsync();
if (useTransaction)
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
@ -1039,7 +1041,9 @@ namespace DS.WMS.Core.Fee.Method
if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
{
if (entity.BillAuditStatus != BillAuditStatus.RecvSubmitted)
if (entity.BillAuditStatus == BillAuditStatus.PaySubmitted)
taskType = TaskBaseTypeEnum.BILL_PAY_AUDIT;
else if (entity.BillAuditStatus != BillAuditStatus.RecvSubmitted)
return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BusinessStatusError)), entity.BillAuditStatus.GetDescription()));
}

@ -11,15 +11,23 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
/// <summary>
/// 费用确认单
/// </summary>
public class DebitNoteReport : IReportProvider
public class DebitNoteReport : ServiceBase, IReportProvider
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public DebitNoteReport(IServiceProvider provider) : base(provider)
{
}
public async Task<dynamic?> GetDataAsync(ReportContext context)
{
DebitNote? form = null;
switch (context.BusinessType)
{
case BusinessType.OceanShippingExport:
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == context.BusinessId).Select<DebitNote>().FirstAsync();
form = await AsQueryable<SeaExport>().Where(s => s.Id == context.BusinessId).Select<DebitNote>().FirstAsync();
break;
case BusinessType.OceanShippingImport:
@ -32,7 +40,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null)
{
form.Items = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType)
form.Items = await AsQueryable<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
{

@ -12,17 +12,25 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
/// <summary>
/// 利润核算单
/// </summary>
public class ProfitAccountingReport : IReportProvider
public class ProfitAccountingReport : ServiceBase, IReportProvider
{
internal static readonly string[] CustomerTypes = ["booking", "controller", "shippercn", "yard", "truck", "custom"];
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public ProfitAccountingReport(IServiceProvider provider) : base(provider)
{
}
public async Task<dynamic?> GetDataAsync(ReportContext context)
{
ProfitAccounting? form = null;
switch (context.BusinessType)
{
case BusinessType.OceanShippingExport:
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == context.BusinessId)
form = await AsQueryable<SeaExport>().Where(s => s.Id == context.BusinessId)
.Select(s => new ProfitAccounting
{
ETDValue = s.ETD,
@ -71,7 +79,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
form.CabinRemark = string.Join(delimiter, remarks.Where(x => x.RemarkType == "2").Select(x => x.Remark));
form.BookingRemark = string.Join(delimiter, remarks.Where(x => x.RemarkType == "3").Select(x => x.Remark));
var list = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType)
var list = await AsQueryable<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))
.OrderByDescending(x => x.Currency).Select<FeeRecordRes>().ToListAsync();
if (list.Count > 0)

@ -7,6 +7,8 @@ using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SqlSugar;
@ -24,12 +26,14 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
api = new ApiFox();
}
ILogger<FlowInstanceService> logger;
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public FlowInstanceService(IServiceProvider serviceProvider) : base(serviceProvider)
{
logger = serviceProvider.GetRequiredService<ILogger<FlowInstanceService>>();
}
/// <summary>
@ -615,7 +619,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
}
else
{
await new ApplicationException($"访问回调URL{instance.CallbackURL} 时返回了错误:" + result.Message).LogAsync(Db);
logger.LogError($"访问回调URL{instance?.CallbackURL} 时返回了错误:" + result?.Message);
}
}
catch (Exception ex)

@ -66,7 +66,7 @@ namespace DS.WMS.Core.Op.Entity
/// Desc:是否费用锁定
/// </summary>
[SugarColumn(ColumnDescription = "是否费用锁定", DefaultValue = "0")]
public bool? IsFeeLocking { get; set; } = false;
public bool? IsFeeLocking { get; set; } = false;
/// <summary>
/// 整单费用审核状态

@ -0,0 +1,10 @@
namespace DS.WMS.Core.TaskInteraction.Interface
{
/// <summary>
/// 申请类审核任务
/// </summary>
public interface IApplicationTaskService : IAuditTaskService
{
}
}

@ -0,0 +1,102 @@
using DS.Module.Core;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Entity;
using DS.WMS.Core.TaskInteraction.Interface;
namespace DS.WMS.Core.TaskInteraction.Method
{
/// <summary>
/// 申请类审核任务
/// </summary>
public class ApplicationTaskService : TaskService, IApplicationTaskService
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public ApplicationTaskService(IServiceProvider provider) : base(provider)
{
}
public async override Task<DataResult> AuditAsync(TaskAuditRequest request)
{
var tasksList = await TenantDb.Queryable<BusinessTask>().Where(x => x.TaskType == request.TaskType && request.Ids.Contains(x.BusinessId))
.WhereIF(request.BusinessType.HasValue, x => x.BusinessType == request.BusinessType.Value).ToListAsync();
if (tasksList.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (tasksList.Count != request.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCountNotMatch));
if (tasksList.Exists(x => x.TaskStatus != TaskStatusEnum.Create && x.TaskStatus != TaskStatusEnum.Pending && x.TaskStatus != TaskStatusEnum.Complete))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskAuditStatusError));
DataResult result = DataResult.Success;
var tasks = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Create);
var task2 = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Complete);
await TenantDb.Ado.BeginTranAsync();
try
{
//状态待审核的任务
if (tasks.Count > 0)
{
var flowIds = tasks.Select(x => x.FlowId.Value);
var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
foreach (var instance in flowInstances)
{
result = await FlowService.Value.AuditAsync(new FlowAuditInfo
{
AuditNote = request.Remark,
Status = request.Result,
Instance = instance
});
if (!result.Succeeded)
return result;
var req = new TaskUpdateRequest
{
BusinessId = instance.BusinessId,
BusinessType = instance.BusinessType,
RejectReason = request.Remark,
TaskTypeName = request.TaskType.ToString(),
TaskStatus = request.Result == 1 ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
AutoCreateNext = true
};
//根据审批结果更新任务状态
await SetTaskStatusAsync(req, false);
if (instance.FlowStatus == FlowStatusEnum.Reject)
result.Message = request.Remark!;
}
}
//已完成审核的任务
if (task2.Count > 0)
{
switch (request.TaskType)
{
case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT:
break;
case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT:
break;
default:
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
await TenantDb.Ado.CommitTranAsync();
return result;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
}
}

@ -66,8 +66,8 @@ namespace DS.WMS.Core.TaskInteraction.Method
BusinessType = x.BusinessType,
BillAuditStatus = x.BillAuditStatus,
BillFeeStatusTime = x.BillFeeStatusTime,
ProfitMargin = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Receivable).Sum(f => f.Amount)
- SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Payable).Sum(f => f.Amount)
ProfitMargin = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Receivable).Sum(f => f.Amount * SqlFunc.IsNull(f.ExchangeRate.Value, 1))
- SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Payable).Sum(f => f.Amount * SqlFunc.IsNull(f.ExchangeRate.Value, 1))
}).FirstAsync();
if (biz == null)
return;
@ -173,7 +173,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
{
if (biz.ProfitMargin > 0)
{
biz.IsBusinessLocking = true;
biz.IsFeeLocking = true;
await SetLockAsync(biz);
}
else //如果为非正利润则生成锁单任务
@ -345,6 +345,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
BusinessType = callback.BusinessType,
TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString()!,
TaskTitle = $"【{callback.AuditType.GetDescription()}】【{callback.BusinessType.GetDescription()}】{business.CustomerNo}",
TaskDescription = "审核备注:" + callback.RejectReason,
RecvUserIdList = [task.CreateBy] //通知任务发起人
};
//创建驳回任务以进行通知

Loading…
Cancel
Save