申请类审核任务

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

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

@ -97,7 +97,7 @@ namespace DS.WMS.Core.Application.Method
protected override DataResult PreAudit(List<InvoiceApplication> applications) 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.FailedWithDesc(nameof(MultiLanguageConst.ApplicationIsNotAuditing));
return DataResult.Success; return DataResult.Success;

@ -289,7 +289,7 @@ namespace DS.WMS.Core.Application.Method
protected override DataResult PreAudit(List<PaymentApplication> applications) 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.FailedWithDesc(nameof(MultiLanguageConst.ApplicationIsNotAuditing));
return DataResult.Success; return DataResult.Success;

@ -908,13 +908,15 @@ namespace DS.WMS.Core.Fee.Method
if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT) 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( return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription())); MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription()));
} }
else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT) 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( return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription())); MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription()));
} }
@ -985,11 +987,6 @@ namespace DS.WMS.Core.Fee.Method
x.ARFeeStatus, x.ARFeeStatus,
x.APFeeStatus x.APFeeStatus
}).ExecuteCommandAsync(); }).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) else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{ {
@ -1000,6 +997,11 @@ namespace DS.WMS.Core.Fee.Method
}).ExecuteCommandAsync(); }).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) if (useTransaction)
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Success; return DataResult.Success;
@ -1039,7 +1041,9 @@ namespace DS.WMS.Core.Fee.Method
if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT) 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( return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BusinessStatusError)), entity.BillAuditStatus.GetDescription())); MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BusinessStatusError)), entity.BillAuditStatus.GetDescription()));
} }

@ -11,15 +11,23 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
/// <summary> /// <summary>
/// 费用确认单 /// 费用确认单
/// </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) public async Task<dynamic?> GetDataAsync(ReportContext context)
{ {
DebitNote? form = null; DebitNote? form = null;
switch (context.BusinessType) switch (context.BusinessType)
{ {
case BusinessType.OceanShippingExport: 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; break;
case BusinessType.OceanShippingImport: case BusinessType.OceanShippingImport:
@ -32,7 +40,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
if (form != null) 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)) .WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id))
.Select(x => new DebitNoteItem .Select(x => new DebitNoteItem
{ {

@ -12,17 +12,25 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
/// <summary> /// <summary>
/// 利润核算单 /// 利润核算单
/// </summary> /// </summary>
public class ProfitAccountingReport : IReportProvider public class ProfitAccountingReport : ServiceBase, IReportProvider
{ {
internal static readonly string[] CustomerTypes = ["booking", "controller", "shippercn", "yard", "truck", "custom"]; 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) public async Task<dynamic?> GetDataAsync(ReportContext context)
{ {
ProfitAccounting? form = null; ProfitAccounting? form = null;
switch (context.BusinessType) switch (context.BusinessType)
{ {
case BusinessType.OceanShippingExport: 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 .Select(s => new ProfitAccounting
{ {
ETDValue = s.ETD, 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.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)); 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)) .WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id))
.OrderByDescending(x => x.Currency).Select<FeeRecordRes>().ToListAsync(); .OrderByDescending(x => x.Currency).Select<FeeRecordRes>().ToListAsync();
if (list.Count > 0) if (list.Count > 0)

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

@ -66,7 +66,7 @@ namespace DS.WMS.Core.Op.Entity
/// Desc:是否费用锁定 /// Desc:是否费用锁定
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "是否费用锁定", DefaultValue = "0")] [SugarColumn(ColumnDescription = "是否费用锁定", DefaultValue = "0")]
public bool? IsFeeLocking { get; set; } = false; public bool? IsFeeLocking { get; set; } = false;
/// <summary> /// <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, BusinessType = x.BusinessType,
BillAuditStatus = x.BillAuditStatus, BillAuditStatus = x.BillAuditStatus,
BillFeeStatusTime = x.BillFeeStatusTime, 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) 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.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(); }).FirstAsync();
if (biz == null) if (biz == null)
return; return;
@ -173,7 +173,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
{ {
if (biz.ProfitMargin > 0) if (biz.ProfitMargin > 0)
{ {
biz.IsBusinessLocking = true; biz.IsFeeLocking = true;
await SetLockAsync(biz); await SetLockAsync(biz);
} }
else //如果为非正利润则生成锁单任务 else //如果为非正利润则生成锁单任务
@ -345,6 +345,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
BusinessType = callback.BusinessType, BusinessType = callback.BusinessType,
TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString()!, TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString()!,
TaskTitle = $"【{callback.AuditType.GetDescription()}】【{callback.BusinessType.GetDescription()}】{business.CustomerNo}", TaskTitle = $"【{callback.AuditType.GetDescription()}】【{callback.BusinessType.GetDescription()}】{business.CustomerNo}",
TaskDescription = "审核备注:" + callback.RejectReason,
RecvUserIdList = [task.CreateBy] //通知任务发起人 RecvUserIdList = [task.CreateBy] //通知任务发起人
}; };
//创建驳回任务以进行通知 //创建驳回任务以进行通知

Loading…
Cancel
Save