工作流迁移至租户数据库

dev
嵇文龙 3 weeks ago
parent 6c6e695848
commit eb46c50626

@ -93,7 +93,7 @@ namespace DS.WMS.Core.Application.Method
}
else
{
var flows = await flowService.GetInstanceByBSIdAsync(AuditType, null, request.Ids);
var flows = await flowService.GetInstancesAsync(AuditType, null, request.Ids);
if (flows.Count != request.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));

@ -508,7 +508,7 @@ namespace DS.WMS.Core.Application.Method
var list2 = list.Select(x => new TEntity { Id = x.Id, Status = x.Status }).ToList();
foreach (var item in list2)
{
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
result = await flowService.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = item.Id,
TemplateId = template.Id
@ -517,7 +517,7 @@ namespace DS.WMS.Core.Application.Method
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
result = await flowService.StartAsync(instance.Id);
OnSubmitApproval(item);
entities.Add(item);
@ -575,7 +575,7 @@ namespace DS.WMS.Core.Application.Method
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
//未在审批状态中
if (!await flowService.Exists(ids: ids))
if (!await flowService.ExistsAsync(ids: ids))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
DataResult result;

@ -390,7 +390,7 @@ namespace DS.WMS.Core.Fee.Method
}).ToListAsync();
pendingAudit.IsPositiveProfit = fees.Where(x => x.FeeType == FeeType.Receivable).Sum(x => x.Amount * (x.ExchangeRate ?? 1))
- fees.Where(x => x.FeeType == FeeType.Payable).Sum(x => x.Amount * (x.ExchangeRate ?? 1)) > 0;
pendingAudit.IsBusinessAudit = await flowService.Exists(TaskBaseTypeEnum.BILL_RECV_AUDIT, request.BusinessType, null, request.Id);
pendingAudit.IsBusinessAudit = await flowService.ExistsAsync(TaskBaseTypeEnum.BILL_RECV_AUDIT, request.BusinessType, null, request.Id);
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
.InnerJoin<SeaExport>((f, s) => f.BusinessId == s.Id)
@ -567,7 +567,7 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
//未在审批状态中
if (!await flowService.Exists(ids: idArray))
if (!await flowService.ExistsAsync(ids: idArray))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
List<Tuple<TaskBaseTypeEnum, long>> taskTypes = [];
@ -609,7 +609,7 @@ namespace DS.WMS.Core.Fee.Method
}
else
{
var instances = await flowService.GetInstanceByBSIdAsync(g.Key, null, ids);
var instances = await flowService.GetInstancesAsync(g.Key, null, ids);
foreach (var item in instances)
{
result = await flowService.AuditAsync(new FlowAuditInfo
@ -733,7 +733,7 @@ namespace DS.WMS.Core.Fee.Method
}
else
{
var flows = await flowService.GetInstanceByBSIdAsync(request.TaskType, request.BusinessType, request.Ids);
var flows = await flowService.GetInstancesAsync(request.TaskType, request.BusinessType, request.Ids);
if (flows.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));

@ -502,7 +502,7 @@ namespace DS.WMS.Core.Fee.Method
if (await IsFeeLockedAsync(bid, bType))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeLocked));
if (await flowService.IsRunning(auditType, null, ids))
if (await flowService.IsRunningAsync(auditType, null, ids))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeRecordIsAuditing));
if (fees.Any(x => x.FeeStatus == FeeStatus.PartialSettlement || x.FeeStatus == FeeStatus.SettlementCompleted))
@ -593,7 +593,7 @@ namespace DS.WMS.Core.Fee.Method
foreach (var item in fees)
{
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
result = await flowService.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = item.Id,
BusinessType = item.BusinessType,
@ -602,7 +602,7 @@ namespace DS.WMS.Core.Fee.Method
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
result = await flowService.StartAsync(instance.Id);
//变更状态为提交审核
item.FeeStatus = FeeStatus.AuditSubmitted;
@ -663,7 +663,7 @@ namespace DS.WMS.Core.Fee.Method
foreach (var item in fees)
{
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
result = await flowService.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = item.Id,
BusinessType = item.BusinessType,
@ -672,7 +672,7 @@ namespace DS.WMS.Core.Fee.Method
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
result = await flowService.StartAsync(instance.Id);
//变更状态为申请删除
item.FeeStatus = FeeStatus.ApplyDeletion;
@ -748,7 +748,7 @@ namespace DS.WMS.Core.Fee.Method
foreach (var fee in fees)
{
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
result = await flowService.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = fee.Id,
BusinessType = fee.BusinessType,
@ -757,7 +757,7 @@ namespace DS.WMS.Core.Fee.Method
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
result = await flowService.StartAsync(instance.Id);
//变更状态为申请修改
fee.FeeStatus = FeeStatus.ApplyModification;
@ -857,7 +857,7 @@ namespace DS.WMS.Core.Fee.Method
else
{
//未在审批状态中
if (!await flowService.Exists(ids: ids))
if (!await flowService.ExistsAsync(ids: ids))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
foreach (var g in groups)
@ -925,7 +925,7 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotSupported));
}
if (await flowService.IsRunning(taskType, type, bid))
if (await flowService.IsRunningAsync(taskType, type, bid))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeRecordIsAuditing));
if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => x.BusinessId == bid && x.BusinessType == type &&
@ -961,7 +961,7 @@ namespace DS.WMS.Core.Fee.Method
if (template == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound));
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
result = await flowService.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = entity.Id,
BusinessType = entity.BusinessType,
@ -969,7 +969,7 @@ namespace DS.WMS.Core.Fee.Method
});
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
result = await flowService.StartAsync(instance.Id);
}
if (!result.Succeeded)
@ -1073,7 +1073,7 @@ namespace DS.WMS.Core.Fee.Method
else
{
//未在审批状态中
if (!await flowService.Exists(type: taskType, businessType: type, ids: [bid]))
if (!await flowService.ExistsAsync(type: taskType, businessType: type, ids: [bid]))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
result = await flowService.WithdrawAsync(taskType, [bid], type);

@ -556,7 +556,7 @@ namespace DS.WMS.Core.Fee.Method
});
}
var list = await flowService.Value.GetInstanceByBSIdAsync(TaskBaseTypeEnum.ReimbursementApproval, ids: request.Ids);
var list = await flowService.Value.GetInstancesAsync(TaskBaseTypeEnum.ReimbursementApproval, ids: request.Ids);
if (list.Count != request.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));

@ -140,7 +140,7 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns>
protected internal ISugarQueryable<FlowInstance> GetCurrentFlowsQuery(params TaskBaseTypeEnum[] auditTypes)
{
return Db.Queryable<FlowInstance>().Where(x => x.FlowStatus == FlowStatusEnum.Running
return TenantDb.Queryable<FlowInstance>().Where(x => x.FlowStatus == FlowStatusEnum.Running
&& SqlFunc.SplitIn(x.MakerList, User.UserId) && auditTypes.Contains(x.AuditType.Value))
.Select(x => new FlowInstance { Id = x.Id, BusinessId = x.BusinessId, BusinessType = x.BusinessType });
}

@ -5,11 +5,12 @@ using DS.WMS.Core.Op.Entity;
using SqlSugar;
namespace DS.WMS.Core.Flow.Entity;
/// <summary>
/// 工作流实例
/// </summary>
[SugarTable("sys_flow_instance")]
public class FlowInstance : BaseTenantModel<long>
public class FlowInstance : BaseModelV2<long>
{
/// <summary>
/// 业务Id
@ -33,7 +34,7 @@ public class FlowInstance : BaseTenantModel<long>
/// 引用模板
/// </summary>
[Navigate(NavigateType.OneToOne, nameof(TemplateId))]
public FlowTemplateTenant? Template { get; set; }
public FlowTemplate? Template { get; set; }
/// <summary>
/// 客户自定义名称

@ -7,14 +7,14 @@ namespace DS.WMS.Core.Flow.Entity;
/// 工作流实例操作历史
/// </summary>
[SqlSugar.SugarTable("sys_flow_instance_history")]
public class FlowInstanceHistory: BaseTenantModel<long>
public class FlowInstanceHistory : BaseModelV2<long>
{
/// <summary>
/// 实例Id
/// </summary>
[Description("实例Id")]
public long InstanceId { get; set; }
/// <summary>
/// 操作内容
/// </summary>

@ -9,7 +9,7 @@ namespace DS.WMS.Core.Flow.Entity;
/// 工作流模板
/// </summary>
[SugarTable("sys_flow_template")]
public class FlowTemplate : BaseTenantModelV2<long>
public class FlowTemplate : BaseModelV2<long>
{
/// <summary>
/// 模板名称
@ -49,7 +49,7 @@ public class FlowTemplate : BaseTenantModelV2<long>
/// 执行人变更回调地址
/// </summary>
[SugarColumn(ColumnDescription = "执行人变更回调地址", IsNullable = true, Length = 255)]
public string? MakerNotifyURL { get; set; }
public string? MarkerNotifyURL { get; set; }
/// <summary>
/// 回调地址

@ -1,65 +0,0 @@
using System.ComponentModel;
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Flow.Entity;
/// <summary>
/// 工作流模板-租户
/// </summary>
[SugarTable("sys_flow_template_tenant")]
public class FlowTemplateTenant : BaseTenantModelV2<long>
{
/// <summary>
/// 模板名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 模块Id
/// </summary>
public long PermissionId { get; set; }
/// <summary>
///中文视图名;设计打印方案时,提供中文快捷按钮的视图来源
/// </summary>
[Description("中文视图名;设计方案时,提供中文字段的视图来源")]
public string? ColumnView { get; set; }
/// <summary>
/// 流程内容
/// </summary>
[SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; }
/// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 状态
/// </summary>
[SugarColumn(ColumnDescription = "状态")]
public StatusEnum Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 执行人变更回调地址
/// </summary>
[SugarColumn(ColumnDescription = "执行人变更回调地址", IsNullable = true, Length = 255)]
public string? MarkerNotifyURL { get; set; }
/// <summary>
/// 回调地址
/// </summary>
[SugarColumn(ColumnDescription = "回调地址", IsNullable = true, Length = 255)]
public string? CallbackURL { get; set; }
/// <summary>
/// 审批类型
/// </summary>
[SugarColumn(ColumnDescription = "审批类型", IsNullable = true, Length = 50)]
public TaskBaseTypeEnum? AuditType { get; set; }
}

@ -27,7 +27,7 @@ public interface IClientFlowInstanceService
/// <param name="businessType">业务类型</param>
/// <param name="ids">业务ID</param>
/// <returns></returns>
Task<bool> IsRunning(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids);
Task<bool> IsRunningAsync(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids);
/// <summary>
/// 确定工作流是否存在
@ -37,7 +37,7 @@ public interface IClientFlowInstanceService
/// <param name="expression">自定义查询条件</param>
/// <param name="ids">业务ID</param>
/// <returns></returns>
Task<bool> Exists(TaskBaseTypeEnum? type = null, BusinessType? businessType = null, Expression<Func<FlowInstance, bool>>? expression = null, params long[] ids);
Task<bool> ExistsAsync(TaskBaseTypeEnum? type = null, BusinessType? businessType = null, Expression<Func<FlowInstance, bool>>? expression = null, params long[] ids);
/// <summary>
/// 根据业务ID获取关联工作流
@ -46,41 +46,51 @@ public interface IClientFlowInstanceService
/// <param name="businessType">业务类型</param>
/// <param name="ids">业务ID</param>
/// <returns></returns>
Task<List<FlowInstance>> GetInstanceByBSIdAsync(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids);
Task<List<FlowInstance>> GetInstancesAsync(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids);
/// <summary>
/// 获取工作流实例信息
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="types">审批类型</param>
/// <returns></returns>
Task<DataResult<List<FlowInstanceRes>>> GetInstancesByBizAsync(long businessId, BusinessType? businessType, params TaskBaseTypeEnum[]? types);
/// <summary>
/// 列表查询
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<FlowInstanceRes>> GetListByPage(PageRequest request);
Task<DataResult<List<FlowInstanceRes>>> GetListAsync(PageRequest request);
/// <summary>
/// 添加编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult EditFlowInstance(FlowInstanceReq req);
Task<DataResult> EditAsync(FlowInstanceReq req);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<FlowInstanceRes> GetFlowInstanceInfo(string id);
Task<DataResult<FlowInstanceRes>> GetAsync(long id);
/// <summary>
/// 启动实例
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult StartFlowInstance(string id);
Task<DataResult> StartAsync(long id);
/// <summary>
/// 创建工作流实例
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult CreateFlowInstance(CreateFlowInstanceReq req);
Task<DataResult> CreateAsync(CreateFlowInstanceReq req);
/// <summary>
/// 工作流审批
@ -96,13 +106,6 @@ public interface IClientFlowInstanceService
/// <returns></returns>
Task<DataResult> AuditAsync(FlowAuditInfo info);
/// <summary>
/// 撤销工作流
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult WithdrawFlowInstance(CancelFlowInstanceReq req);
/// <summary>
/// 撤销工作流
/// </summary>
@ -132,27 +135,11 @@ public interface IClientFlowInstanceService
/// <returns></returns>
Task<DataResult> RunCallbackAsync(TaskBaseTypeEnum taskType, long bsId, BusinessType? businessType = null, string? callbackURL = null);
/// <summary>
/// 获取流程操作历史
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<List<FlowInstanceHistoryRes>> GetFlowInstanceHistoryList(string id);
/// <summary>
/// 获取流程操作历史
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="bsType">bsType</param>
/// <returns></returns>
DataResult<List<FlowInstanceHistoryRes>> GetFlowInstanceHistoryList(long bsId, BusinessType? bsType);
/// <summary>
/// 获取工作流实例信息
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="types">审批类型</param>
/// <returns></returns>
DataResult<List<FlowInstanceRes>> GetFlowInstances(long businessId, BusinessType? businessType, params TaskBaseTypeEnum[]? types);
Task<DataResult<List<FlowInstanceHistoryRes>>> GetHistoriesAsync(long bsId, BusinessType? bsType);
}

@ -3,6 +3,9 @@ using DS.WMS.Core.Flow.Dtos;
namespace DS.WMS.Core.Flow.Interface;
/// <summary>
/// 工作流模板
/// </summary>
public interface IClientFlowTemplateService
{
/// <summary>
@ -26,14 +29,6 @@ public interface IClientFlowTemplateService
/// <returns></returns>
DataResult<FlowTemplateRes> GetClientFlowTemplateInfo(string id);
/// <summary>
/// 引入工作流模板
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult ImportFlowTemplate(string id);
/// <summary>
/// 删除模板
/// </summary>
@ -41,10 +36,4 @@ public interface IClientFlowTemplateService
/// <returns></returns>
DataResult DelFlowTemplate(string id);
/// <summary>
/// 获取模板列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<FlowTemplateRes>> GetFlowTemplateList(PageRequest request);
}

@ -1,5 +1,6 @@
using System.Linq.Expressions;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
@ -8,20 +9,32 @@ using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Mapster;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SqlSugar;
namespace DS.WMS.Core.Flow.Method;
/// <summary>
/// 租户端工作流实例管理
/// </summary>
public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanceService
public class ClientFlowInstanceService : ServiceBase, IClientFlowInstanceService
{
static readonly ApiFox api;
static ClientFlowInstanceService()
{
api = new ApiFox();
}
ILogger<ClientFlowInstanceService> logger;
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public ClientFlowInstanceService(IServiceProvider serviceProvider) : base(serviceProvider)
{
logger = serviceProvider.GetRequiredService<ILogger<ClientFlowInstanceService>>();
}
/// <summary>
@ -31,9 +44,9 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
/// <param name="businessType">业务类型</param>
/// <param name="ids">业务ID</param>
/// <returns></returns>
public async Task<bool> IsRunning(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids)
public async Task<bool> IsRunningAsync(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids)
{
return await Exists(type, businessType,
return await ExistsAsync(type, businessType,
x => x.FlowStatus == FlowStatusEnum.Ready || x.FlowStatus == FlowStatusEnum.Running, ids);
}
@ -45,15 +58,13 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
/// <param name="expression">自定义查询条件</param>
/// <param name="ids">业务ID</param>
/// <returns></returns>
public async Task<bool> Exists(TaskBaseTypeEnum? type = null,
BusinessType? businessType = null,
Expression<Func<FlowInstance, bool>>? expression = null,
params long[] ids)
public async Task<bool> ExistsAsync(TaskBaseTypeEnum? type = null, BusinessType? businessType = null,
Expression<Func<FlowInstance, bool>>? expression = null, params long[] ids)
{
if (ids == null || ids.Length == 0)
return false;
return await Db.Queryable<FlowInstance>().Where(x => ids.Contains(x.BusinessId))
return await TenantDb.Queryable<FlowInstance>().Where(x => ids.Contains(x.BusinessId))
.WhereIF(type.HasValue, x => x.AuditType == type)
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
.WhereIF(expression != null, expression)
@ -67,24 +78,111 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
/// /// <param name="businessType">业务类型</param>
/// <param name="ids">业务ID</param>
/// <returns></returns>
public async Task<List<FlowInstance>> GetInstanceByBSIdAsync(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids)
public async Task<List<FlowInstance>> GetInstancesAsync(TaskBaseTypeEnum type, BusinessType? businessType = null, params long[] ids)
{
if (ids == null || ids.Length == 0)
return [];
return await Db.Queryable<FlowInstance>().Where(x => x.AuditType == type && ids.Contains(x.BusinessId) &&
return await TenantDb.Queryable<FlowInstance>().Where(x => x.AuditType == type && ids.Contains(x.BusinessId) &&
(x.FlowStatus == FlowStatusEnum.Ready || x.FlowStatus == FlowStatusEnum.Running))
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
.OrderByDescending(x => x.CreateTime).Take(1).ToListAsync();
}
protected override FlowInstance? BuildInstance(CreateFlowInstanceReq req)
/// <summary>
/// 获取工作流实例信息
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="types">审批类型</param>
/// <returns></returns>
public async Task<DataResult<List<FlowInstanceRes>>> GetInstancesByBizAsync(long businessId, BusinessType? businessType, params TaskBaseTypeEnum[]? types)
{
var query = TenantDb.Queryable<FlowInstance>().Where(x => x.BusinessId == businessId && x.FlowStatus != FlowStatusEnum.Ready)
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType.Value)
.WhereIF(types != null && types.Length > 0, x => types.Contains(x.AuditType.Value));
var list = await query.Select(x => new FlowInstance
{
Id = x.Id,
Content = x.Content,
AuditType = x.AuditType,
FlowStatus = x.FlowStatus
}).ToListAsync();
var list2 = list.Select(x => x.Adapt<FlowInstanceRes>()).ToList();
foreach (var item in list2)
{
item.AuditTypeName = item.AuditType?.GetDescription();
}
return DataResult<List<FlowInstanceRes>>.Success(list2);
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<FlowInstanceRes>>> GetListAsync(PageRequest request)
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
var data = await TenantDb.Queryable<FlowInstance>().Where(a => a.MakerList == "" || a.MakerList.Contains(User.UserId))
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Select((a, b) => new FlowInstanceRes
{
CreateTime = a.CreateTime,
}, true)
.Where(whereList).ToQueryPageAsync(request.PageCondition);
return data;
}
/// <summary>
/// 确定是否为最后审批人
/// </summary>
/// <param name="taskType">任务类型</param>
/// <param name="bsId">业务ID</param>
/// <param name="bsType">业务类型</param>
/// <returns></returns>
public DataResult<bool> IsLastMarker(TaskBaseTypeEnum taskType, long bsId, BusinessType? bsType)
{
var flow = TenantDb.Queryable<FlowInstance>().Where(x => x.AuditType == taskType && x.BusinessId == bsId && x.BusinessType == bsType && x.FlowStatus == FlowStatusEnum.Running)
.Select(x => new { x.Id, x.MakerList }).First();
bool isLastMarker = default;
if (flow != null && flow.MakerList == User.UserId)
isLastMarker = true;
return DataResult<bool>.Success(isLastMarker);
}
public async Task<DataResult> EditAsync(FlowInstanceReq req)
{
if (req.Id == 0)
{
return DataResult.Failed("非法请求!", MultiLanguageConst.IllegalRequest);
}
else
{
var info = await TenantDb.Queryable<FlowInstance>().Where(x => x.Id == req.Id).FirstAsync();
if (!(info.FlowStatus == FlowStatusEnum.Draft || info.FlowStatus == FlowStatusEnum.Ready))
{
return DataResult.Failed("只能修改【就绪】和【撤销】状态的流程", MultiLanguageConst.FlowEditOnlyReadyAndCancel);
}
info = req.Adapt(info);
await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
protected virtual async Task<FlowInstance?> BuildInstanceAsync(CreateFlowInstanceReq req)
{
if (string.IsNullOrEmpty(req.TemplateId.ToString()))
return null;
FlowTemplateTenant template = Db.Queryable<FlowTemplateTenant>().First(x => x.Id == req.TemplateId);
FlowTemplate template = await TenantDb.Queryable<FlowTemplate>().FirstAsync(x => x.Id == req.TemplateId);
return template == null ? null : new FlowInstance
{
CustomName = template.Name,
@ -100,16 +198,581 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
};
}
protected override string GetForkNodeMakers(FlowRuntime wfruntime, string forkNodeId)
/// <summary>
/// 创建工作流实例
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult> CreateAsync(CreateFlowInstanceReq req)
{
var instance = await BuildInstanceAsync(req);
if (instance == null)
return DataResult.Failed("该流程模板已不存在,请重新设计流程!", MultiLanguageConst.FlowTemplateNotExist);
string userName = User.UserName;
//创建运行实例
var runtime = CreateRuntimeService(instance);
if (runtime.ShouldSkip)
{
instance.FlowStatus = FlowStatusEnum.Approve;
instance.Note = "已设置为自动跳过工作流执行";
await TenantDb.Insertable(instance).ExecuteCommandAsync();
var history1 = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【创建】"
+ userName
+ "创建了一个流程进程【"
+ instance.CustomName + "】",
UserName = userName
};
var history2 = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【审核】"
+ userName
+ "流程条件触发自动审核【"
+ instance.CustomName + "】",
UserName = userName
};
FlowInstanceHistory[] histories = [history1, history2];
await TenantDb.Insertable(histories).ExecuteCommandAsync();
if (!string.IsNullOrEmpty(instance.CallbackURL))
await RunCallbackAsync(instance);
var result = DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
return result;
}
if (runtime.CurrentNode is { AssigneeType: "user", Users.Count: > 0 })
{
if (!runtime.CurrentNode.Users.Contains(User.UserId))
{
return DataResult.Failed("该工作流指定用户非本人,没有发起审批的权限", MultiLanguageConst.FlowInstanceAssignUser);
}
}
if (runtime.CurrentNode is { AssigneeType: "role", Roles.Count: > 0 })
{
var userRoles = Db.Queryable<SysRoleUser>().Where(x => x.UserId == long.Parse(User.UserId))
.Select(n => n.RoleId.ToString()).ToList();
var intersectRoles = runtime.CurrentNode.Roles.Intersect(userRoles).ToList();
if (intersectRoles.Count == 0)
{
return DataResult.Failed("该工作流指定角色非本人,没有发起审批的权限", MultiLanguageConst.FlowInstanceAssignRole);
}
}
#region 根据运行实例改变当前节点状态
instance.ActivityId = runtime.CurrentNodeId;
instance.ActivityType = runtime.GetNodeType(runtime.StartNodeId);
instance.ActivityName = runtime.CurrentNode.Name;
instance.PreviousId = "";
instance.MakerList = GetCurrentMakers(runtime);
instance.FlowStatus = FlowStatusEnum.Ready;
#endregion 根据运行实例改变当前节点状态
await TenantDb.Insertable(instance).ExecuteCommandAsync();
//流程==4为结束执行回调URL
if (runtime.GetNextNodeType() == 4 && !instance.CallbackURL.IsNullOrEmpty())
await RunCallbackAsync(instance);
var history = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【创建】"
+ userName
+ "创建了一个流程进程【"
+ instance.CustomName + "】",
UserName = userName
};
await TenantDb.Insertable(history).ExecuteCommandAsync();
return DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
}
/// <summary>
/// 获取流程操作历史
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="bsType">bsType</param>
/// <returns></returns>
public async Task<DataResult<List<FlowInstanceHistoryRes>>> GetHistoriesAsync(long bsId, BusinessType? bsType)
{
var data = await TenantDb.Queryable<FlowInstanceHistory>()
.Where(x => SqlFunc.Subqueryable<FlowInstance>().Where(y => x.InstanceId == y.Id && y.BusinessId == bsId)
.WhereIF(bsType.HasValue, y => y.BusinessType == bsType.Value)
.Any())
.Select<FlowInstanceHistoryRes>()
.ToListAsync();
return DataResult<List<FlowInstanceHistoryRes>>.Success(data);
}
/// <summary>
/// 启动
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult> StartAsync(long id)
{
var instance = await TenantDb.Queryable<FlowInstance>().FirstAsync(x => x.Id == id);
if (instance == null)
return DataResult.Failed("该工作流不存在!", MultiLanguageConst.FlowInstanceNotExist);
if (instance.FlowStatus == FlowStatusEnum.Approve)
return DataResult.Failed("该工作流已完成!", MultiLanguageConst.FlowInstanceFinished);
//创建运行实例
var wfruntime = CreateRuntimeService(instance);
#region 根据运行实例改变当前节点状态
instance.ActivityId = wfruntime.NextNodeId;
instance.ActivityType = wfruntime.GetNextNodeType();
instance.ActivityName = wfruntime.NextNode.Name;
instance.PreviousId = wfruntime.CurrentNodeId;
instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "";
instance.FlowStatus = wfruntime.GetNextNodeType() == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running;
#endregion 根据运行实例改变当前节点状态
if (string.IsNullOrEmpty(instance.MakerList))
{
instance.FlowStatus = FlowStatusEnum.Approve;
var template = await TenantDb.Queryable<FlowTemplate>().Where(x => x.Id == instance.TemplateId)
.Select(x => new { x.MarkerNotifyURL, x.CallbackURL }).FirstAsync();
instance.MarkerNotifyURL = template.MarkerNotifyURL;
instance.CallbackURL = template.CallbackURL;
}
await TenantDb.Updateable(instance).ExecuteCommandAsync();
//流程==4为结束执行回调URL
if (wfruntime.GetNextNodeType() == 4 || instance.FlowStatus == FlowStatusEnum.Approve || instance.FlowStatus == FlowStatusEnum.Reject)
await RunCallbackAsync(instance);
var history = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = $"【启动】由{User.UserName}启动该流程。",
UserName = User.UserName
};
Db.Insertable(history).ExecuteCommand();
return DataResult.Successed("更新成功!", instance, MultiLanguageConst.FlowInstanceUpdateSuccess);
}
/// <summary>
/// 审核工作流实例
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult> AuditAsync(FlowInstanceAuditReq req)
{
var instance = await TenantDb.Queryable<FlowInstance>().Where(x => x.Id == req.Id)
.InnerJoin<FlowTemplate>((f, ft) => f.TemplateId == ft.Id).Select((f, ft) => new FlowInstance
{
ActivityId = f.ActivityId,
ActivityName = f.ActivityName,
ActivityType = f.ActivityType,
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
CallbackURL = ft.CallbackURL,
MarkerNotifyURL = ft.MarkerNotifyURL,
ColumnView = f.ColumnView,
Content = f.Content,
FlowStatus = f.FlowStatus,
Id = f.Id,
MakerList = f.MakerList,
PreviousId = f.PreviousId,
PermissionId = f.PermissionId,
AuditType = ft.AuditType
}).FirstAsync();
if (instance == null)
{
return DataResult.Failed("该工作流不存在!", MultiLanguageConst.FlowInstanceNotExist);
}
else if (instance.FlowStatus == FlowStatusEnum.Approve)
{
return DataResult.Failed("该工作流已完成!", MultiLanguageConst.FlowInstanceFinished);
}
return await AuditCoreAsync(req.Status, req.AuditNote, instance);
}
/// <summary>
/// 工作流实例审核实现
/// </summary>
/// <param name="status">1=通过2=驳回</param>
/// <param name="auditNote">审核备注</param>
/// <param name="instance"></param>
/// <returns></returns>
protected virtual async Task<DataResult> AuditCoreAsync(int status, string auditNote, FlowInstance instance)
{
ArgumentNullException.ThrowIfNull(instance, nameof(instance));
if (!instance.MakerList.Contains(User.UserId))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.AuditUnauthorization));
var tag = new FlowTag
{
UserName = User.UserName,
UserId = User.UserId,
Description = auditNote,
Taged = status
};
var runtime = CreateRuntimeService(instance);
if (runtime.CurrentNodeId != instance.ActivityId)
return DataResult.Failed("该工作流审批节点与当前节点不一致!", MultiLanguageConst.FlowInstanceNodeIdConflict);
#region 会签
if (instance.ActivityType == 0) //当前节点是会签节点
{
//会签时的【当前节点】一直是会签开始节点
runtime.MakeTagNode(runtime.CurrentNodeId, tag); //标记审核节点状态
var res = runtime.NodeConfluence(runtime.CurrentNodeId, tag);
if (res == ((int)TagState.No).ToString()) //驳回
{
instance.FlowStatus = FlowStatusEnum.Reject;
if (runtime.NextNodeType == 4)
{
instance.PreviousId = instance.ActivityId;
instance.ActivityId = runtime.NextNodeId;
instance.ActivityType = runtime.NextNodeType;
instance.ActivityName = runtime.NextNode.Name;
instance.MakerList = runtime.NextNodeType == 4 ? string.Empty : GetNextMakers(runtime);
}
}
else if (!string.IsNullOrEmpty(res)) //通过
{
if (runtime.NextNodeType == 5)
{
instance.MakerList = runtime.GetOtherUsers(tag);
}
else
{
instance.PreviousId = instance.ActivityId;
instance.ActivityId = runtime.NextNodeId;
instance.ActivityType = runtime.NextNodeType;
instance.ActivityName = runtime.NextNode.Name;
instance.FlowStatus = runtime.NextNodeType == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running;
instance.MakerList = runtime.NextNodeType == 4 ? string.Empty : GetNextMakers(runtime);
}
}
else //继续审批
{
//会签过程中,需要更新用户
instance.MakerList = GetForkNodeMakers(runtime, runtime.CurrentNodeId);
}
var marker = FlowInstanceService.GetNextMarkers(instance);
//获取会签下一执行人,进行通知
if (!string.IsNullOrEmpty(marker) && !instance.MarkerNotifyURL.IsNullOrEmpty())
{
Task.Factory.StartNew(() => NotifyMarkerChangedAsync(status, instance, long.Parse(marker)));
}
}
#endregion 会签
#region 或签
else
{
runtime.MakeTagNode(runtime.CurrentNodeId, tag);
if (tag.Taged == (int)TagState.Ok)
{
instance.PreviousId = instance.ActivityId;
instance.ActivityId = runtime.NextNodeId;
instance.ActivityType = runtime.NextNodeType;
instance.ActivityName = runtime.NextNode.Name;
instance.MakerList = runtime.NextNodeType == 4 ? "1" : GetNextMakers(runtime);
instance.FlowStatus = runtime.NextNodeType == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running;
}
else
{
instance.FlowStatus = FlowStatusEnum.Reject; //表示该节点不同意
runtime.NextNodeId = string.Empty;
runtime.NextNodeType = 4;
}
}
#endregion 或签
int nextNodeType = runtime.GetNextNodeType();
await TenantDb.Ado.BeginTranAsync();
try
{
//流程=4为结束执行回调URL
if (runtime.NextNodeType != 5 && (nextNodeType == 4 || nextNodeType == -1))
{
instance.FlowStatus = status == 1 ? FlowStatusEnum.Approve : FlowStatusEnum.Reject;
if (!string.IsNullOrEmpty(instance.CallbackURL))
await RunCallbackAsync(instance);
}
//var serializerSettings = new JsonSerializerSettings
//{
// // 设置为驼峰命名
// ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
//};
//instance.Content = JsonConvert.SerializeObject(runtime.ToFlowRoot(), Formatting.None, serializerSettings);
instance.Note = auditNote;
await TenantDb.Updateable(instance).ExecuteCommandAsync();
var history = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【" + runtime.CurrentNode.Name
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
+ "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
+ tag.Description,
UserName = User.UserName,
Result = status,
Note = auditNote
};
await TenantDb.Insertable(history).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync();
return DataResult.Successed("审核成功!", MultiLanguageConst.FlowInstanceAuditSuccess);
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.Failed(ex.Message, nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>
/// 运行执行人变更回调
/// </summary>
/// <param name="status">审批结果</param>
/// <param name="instance">运行实例</param>
/// <param name="nextUserId">下一执行人ID</param>
/// <returns></returns>
protected virtual async Task NotifyMarkerChangedAsync(int status, FlowInstance instance, params long[] nextUserId)
{
ArgumentNullException.ThrowIfNull(instance, nameof(instance));
//请求参数设置
var callback = new MarkerChangedCallback
{
InstanceId = instance.Id,
BusinessId = instance.BusinessId,
BusinessType = instance.BusinessType,
AuditType = instance.AuditType,
Status = status == 1 ? FlowStatusEnum.Approve : FlowStatusEnum.Reject,
NextUserId = nextUserId
};
if (api.DefaultHeaders.Contains("Authorization"))
api.DefaultHeaders.Remove("Authorization");
api.DefaultHeaders.Add("Authorization", "Bearer " + User.GetToken());
await api.PostAsync<DataResult>(instance.MarkerNotifyURL, callback);
}
/// <summary>
/// 对指定的回调URL发起异步请求
/// </summary>
/// <param name="instance">运行实例</param>
protected virtual async Task RunCallbackAsync(FlowInstance instance)
{
ArgumentNullException.ThrowIfNull(instance, nameof(instance));
if (string.IsNullOrEmpty(instance.CallbackURL))
return;
//请求参数设置
var callback = new FlowCallback
{
InstanceId = instance.Id,
BusinessId = instance.BusinessId,
BusinessType = instance.BusinessType,
AuditType = instance.AuditType,
FlowStatus = instance.FlowStatus,
RejectReason = instance.Note
};
if (api.DefaultHeaders.Contains("Authorization"))
api.DefaultHeaders.Remove("Authorization");
api.DefaultHeaders.Add("Authorization", "Bearer " + User.GetToken());
try
{
var result = await api.PostAsync<DataResult>(instance.CallbackURL, callback);
if (result.Succeeded)
{
//更新回调执行标识
instance.IsCallbackExecuted = true;
await TenantDb.Updateable(instance).UpdateColumns(x => x.IsCallbackExecuted).ExecuteCommandAsync();
}
else
{
logger.LogError($"访问回调URL{instance?.CallbackURL} 时返回了错误:" + result?.Message);
}
}
catch (Exception ex)
{
await ex.LogAsync(Db);
}
}
/// <summary>
/// 运行回调更新
/// </summary>
/// <param name="taskType">审核类型</param>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="callbackURL">指定的回调URL</param>
/// <returns></returns>
public async Task<DataResult> RunCallbackAsync(TaskBaseTypeEnum taskType,
long bsId, BusinessType? businessType = null,
string? callbackURL = null)
{
var instance = await TenantDb.Queryable<FlowInstance>().Where(x => x.AuditType == taskType && x.BusinessId == bsId)
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
.InnerJoin<FlowTemplate>((f, ft) => f.TemplateId == ft.Id).Select((f, ft) => new FlowInstance
{
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
CallbackURL = ft.CallbackURL,
MarkerNotifyURL = ft.MarkerNotifyURL,
FlowStatus = f.FlowStatus,
Id = f.Id,
AuditType = ft.AuditType
}).OrderByDescending(f => f.CreateTime).FirstAsync();
if (instance == null)
return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData);
if (!string.IsNullOrEmpty(callbackURL))
instance.CallbackURL = callbackURL;
await RunCallbackAsync(instance);
return DataResult.Success;
}
/// <summary>
/// 创建工作流运行时
/// </summary>
/// <param name="instance"></param>
/// <returns></returns>
protected virtual FlowRuntime CreateRuntimeService(FlowInstance instance)
{
return new FlowRuntime(instance, Db, TenantDb);
}
/// <summary>
/// 获取工作流
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult<FlowInstanceRes>> GetAsync(long id)
{
var data = await TenantDb.Queryable<FlowInstance>()
.Where(a => a.Id == id)
.Select<FlowInstanceRes>()
.FirstAsync();
return DataResult<FlowInstanceRes>.Success(data);
}
// 寻找下一步的执行人
// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
internal string GetCurrentMakers(FlowRuntime wfruntime, CreateFlowInstanceReq? request = null)
{
string makerList = "";
if (wfruntime.NextNodeId == "-1")
throw new ApplicationException("无法寻找到下一个节点");
var nextNode = wfruntime.NextNode;
if (wfruntime.CurrentNodeType == 0) //如果是会签节点
{
makerList = GetForkNodeMakers(wfruntime, wfruntime.NextNodeId);
}
else if (wfruntime.CurrentNode.AssigneeType == "role")
{
var users = Db.Queryable<SysRoleUser>().Where(x =>
wfruntime.CurrentNode.Roles.Contains(x.RoleId.ToString()))
.Select(x => x.UserId).Distinct().ToList();
makerList = string.Join(',', users);
}
else if (wfruntime.CurrentNode.AssigneeType == "user")
{
makerList = string.Join(",", wfruntime.CurrentNode.Users);
}
else if (wfruntime.CurrentNode.AssigneeType == FlowChild.Dynamic)
{
makerList = GetDynamicMarkers(wfruntime.CurrentNode, wfruntime);
}
else
{
makerList = GetNodeMarkers(wfruntime.CurrentNode);
if (string.IsNullOrEmpty(makerList))
{
throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
}
}
return makerList;
}
// 寻找下一步的执行人
// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
internal string GetNextMakers(FlowRuntime wfruntime, CreateFlowInstanceReq? request = null)
{
string makerList = "";
if (wfruntime.NextNodeId == "-1")
throw new ApplicationException("无法寻找到下一个节点");
if (wfruntime.NextNode.AssigneeType == "role")
{
var users = Db.Queryable<SysRoleUser>().Where(x =>
wfruntime.NextNode.Roles.Contains(x.RoleId.ToString()))
.Select(x => x.UserId).Distinct().ToList();
makerList = string.Join(",", users);
}
else if (wfruntime.NextNode.AssigneeType == "user")
{
makerList = string.Join(",", wfruntime.NextNode.Users);
}
else if (wfruntime.NextNode.AssigneeType == FlowChild.Dynamic)
{
makerList = GetDynamicMarkers(wfruntime.NextNode, wfruntime);
}
else
{
makerList = GetNodeMarkers(wfruntime.NextNode);
if (string.IsNullOrEmpty(makerList))
{
throw new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!");
}
}
return makerList;
}
// 获取会签开始节点的所有可执行者
internal string GetForkNodeMakers(FlowRuntime wfruntime, string forkNodeId)
{
string makerList = "";
var nextNode = wfruntime.NextNode;
var nextConditionNodeId = wfruntime.GetNextConditionNodeId(nextNode);
var nextConditionNode = wfruntime.ChildNodes.Find(x => x.Id == nextConditionNodeId);
if (nextConditionNode == null)
return makerList;
var nextConditionNode = wfruntime.ChildNodes.First(x => x.Id == nextConditionNodeId);
if (nextConditionNode.AssigneeType == "role")
{
@ -122,43 +785,64 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
{
makerList = string.Join(",", nextConditionNode.Users);
}
else if (nextConditionNode.AssigneeType == FlowChild.Dynamic)
{
makerList = GetDynamicMarkers(nextConditionNode, wfruntime);
}
return makerList;
}
protected override FlowRuntime CreateRuntimeService(FlowInstance instance)
// 寻找该节点执行人
internal string GetNodeMarkers(FlowChild node, string flowinstanceCreateUserId = "")
{
return new FlowRuntime(instance, Db, TenantDb);
string makerList = "";
if (node.Type == FlowChild.START && (!string.IsNullOrEmpty(flowinstanceCreateUserId))) //如果是开始节点,通常情况下是驳回到开始了
{
makerList = flowinstanceCreateUserId;
}
else if (node.AssigneeType != null)
{
if (node.AssigneeType == "role")
{
var users = Db.Queryable<SysRoleUser>().Where(x =>
node.Roles.Contains(x.RoleId.ToString()))
.Select(x => x.UserId).Distinct().ToList();
makerList = string.Join(",", users);
}
else if (node.AssigneeType == "user")
{
makerList = node.Users.ToString();
}
}
else //如果没有设置节点信息,默认所有人都可以审核
{
makerList = "";
}
return makerList;
}
/// <summary>
/// 获取工作流实例信息
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="types">审批类型</param>
/// <returns></returns>
public DataResult<List<FlowInstanceRes>> GetFlowInstances(long businessId, BusinessType? businessType, params TaskBaseTypeEnum[]? types)
//获取动态节点的执行人
internal string GetDynamicMarkers(FlowChild flowNode, FlowRuntime runtime)
{
var query = Db.Queryable<FlowInstance>().Where(x => x.BusinessId == businessId && x.FlowStatus != FlowStatusEnum.Ready)
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType.Value)
.WhereIF(types != null && types.Length > 0, x => types.Contains(x.AuditType.Value));
var list = query.Select(x => new FlowInstance
{
Id = x.Id,
Content = x.Content,
AuditType = x.AuditType,
FlowStatus = x.FlowStatus
}).ToList();
if (flowNode == null || string.IsNullOrEmpty(flowNode.MarkerSQLText) || runtime == null)
return string.Empty;
var list2 = list.Select(x => x.Adapt<FlowInstanceRes>()).ToList();
foreach (var item in list2)
List<string> markers = [];
using (var reader = TenantDb.Ado.GetDataReader(flowNode.MarkerSQLText, new SugarParameter($"@{nameof(BaseModel<long>.Id)}", runtime.BusinessId)))
{
item.AuditTypeName = item.AuditType?.GetDescription();
while (reader.Read())
markers.Add(reader.GetString(0));
}
return DataResult<List<FlowInstanceRes>>.Success(list2);
string markerList = string.Join(",", markers);
if (string.IsNullOrEmpty(markerList))
throw new ApplicationException("未能根据动态节点设置的查询语句获取工作流执行人,请检查模板配置");
TenantDb.Updateable<FlowInstance>()
.SetColumns(x => x.MakerList == markerList).Where(x => x.Id == runtime.InstanceId)
.ExecuteCommand();
return markerList;
}
/// <summary>
@ -176,10 +860,10 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
if (info.Instance.FlowStatus == FlowStatusEnum.Approve)
return DataResult.Failed("该工作流已完成!", MultiLanguageConst.FlowInstanceFinished);
if (info.Instance.CallbackURL.IsNullOrEmpty())
if (string.IsNullOrEmpty(info.Instance.CallbackURL))
{
var template = Db.Queryable<FlowTemplateTenant>().Where(x => x.Id == info.Instance.TemplateId)
.Select(x => new { x.MarkerNotifyURL, x.CallbackURL }).First();
var template = await TenantDb.Queryable<FlowTemplate>().Where(x => x.Id == info.Instance.TemplateId)
.Select(x => new { x.MarkerNotifyURL, x.CallbackURL }).FirstAsync();
info.Instance.CallbackURL = template.CallbackURL;
info.Instance.MarkerNotifyURL = template.MarkerNotifyURL;
@ -199,7 +883,7 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
public async Task<DataResult> WithdrawAsync(TaskBaseTypeEnum taskType, long[] bsIds,
BusinessType? businessType = null, string? note = null)
{
var instances = await GetInstanceByBSIdAsync(taskType, businessType, bsIds);
var instances = await GetInstancesAsync(taskType, businessType, bsIds);
return await WithdrawCoreAsync(instances, note);
}
@ -217,11 +901,7 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
ActivityId = FlowChild.END,
MakerList = string.Empty,
FlowStatus = FlowStatusEnum.Draft,
Note = note,
//Deleted = true,
//DeleteBy = userId,
//DeleteTime = dt,
//DeleteUserName = userInfo.UserName
Note = note
}).ToList();
return await WithdrawCoreAsync(instances, note);
}
@ -229,42 +909,33 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
internal async Task<DataResult> WithdrawCoreAsync(List<FlowInstance> instances, string? note = null)
{
ArgumentNullException.ThrowIfNull(instances, nameof(instances));
long userId = long.Parse(User.UserId);
var userInfo = await Db.Queryable<SysUser>().Where(x => x.Id == userId).Select(x => new { x.Id, x.UserName }).FirstAsync();
//DateTime dt = DateTime.Now;
await Db.Ado.BeginTranAsync();
await TenantDb.Ado.BeginTranAsync();
try
{
await Db.Updateable(instances).UpdateColumns(x => new
await TenantDb.Updateable(instances).UpdateColumns(x => new
{
x.ActivityId,
x.MakerList,
x.FlowStatus,
x.Note,
//x.Deleted,
//x.DeleteBy,
//x.DeleteTime,
//x.DeleteUserName
x.Note
}).ExecuteCommandAsync();
var historys = instances.Select(x => new FlowInstanceHistory
{
InstanceId = x.Id,
Content = $"【撤销】由{userInfo.UserName}撤销,备注:{note}",
Content = $"【撤销】由{User.UserName}撤销,备注:{note}",
Result = -1,
UserName = userInfo.UserName
UserName = User.UserName
}).ToList();
await Db.Insertable(historys).ExecuteCommandAsync();
await Db.Ado.CommitTranAsync();
await TenantDb.Insertable(historys).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync();
return DataResult.Successed("撤销成功!", MultiLanguageConst.FlowInstanceCancelSuccess);
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
await Db.Ado.RollbackTranAsync();
return DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
}
}

@ -1,44 +1,31 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.UserModule;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.Flow.Method;
/// <summary>
///
/// 工作流模板
/// </summary>
public class ClientFlowTemplateService : IClientFlowTemplateService
public class ClientFlowTemplateService : ServiceBase, IClientFlowTemplateService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ICommonService _commonService;
/// <summary>
///
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public ClientFlowTemplateService(IServiceProvider serviceProvider)
public ClientFlowTemplateService(IServiceProvider serviceProvider) : base(serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
_commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
public DataResult<List<FlowTemplateRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<FlowTemplateTenant>()
var whereList = request.GetConditionalModels(Db);
var data = TenantDb.Queryable<FlowTemplate>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Select<FlowTemplateRes>()
.Where(whereList).ToQueryPage(request.PageCondition);
@ -63,71 +50,46 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
if (req.Id == 0)
{
var isExist = db.Queryable<FlowTemplateTenant>().Where(x => x.Name == req.Name).First();
var isExist = TenantDb.Queryable<FlowTemplate>().Where(x => x.Name == req.Name).First();
if (isExist != null)
return DataResult.Failed("流程模板名称已存在!");
var data = req.Adapt<FlowTemplateTenant>();
var entity = db.Insertable(data).ExecuteReturnEntity();
var data = req.Adapt<FlowTemplate>();
var entity = TenantDb.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id);
}
else
{
var info = db.Queryable<FlowTemplateTenant>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
var info = TenantDb.Queryable<FlowTemplate>().Where(x => x.Id == req.Id).First();
TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!");
}
}
public DataResult<FlowTemplateRes> GetClientFlowTemplateInfo(string id)
{
var data = db.Queryable<FlowTemplateTenant>()
var data = TenantDb.Queryable<FlowTemplate>()
.Where(a => a.Id == long.Parse(id))
.Select<FlowTemplateRes>()
.First();
return DataResult<FlowTemplateRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
public DataResult ImportFlowTemplate(string id)
{
var info = db.Queryable<FlowTemplate>().Where(x => x.Id == long.Parse(id)).First();
if (info == null)
{
return DataResult.Failed("流程模板不存在!",MultiLanguageConst.FlowTemplateImportNotExist);
}
var data = info.Adapt<FlowTemplateTenant>();
data.Id = 0;
db.Insertable(data).ExecuteCommand();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
return DataResult<FlowTemplateRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
public DataResult DelFlowTemplate(string id)
{
var info = db.Queryable<FlowTemplateTenant>().Where(x => x.Id == long.Parse(id)).First();
var info = TenantDb.Queryable<FlowTemplate>().Where(x => x.Id == long.Parse(id)).First();
if (info == null)
{
return DataResult.Failed("流程模板不存在!",MultiLanguageConst.FlowTemplateNotExist);
return DataResult.Failed("流程模板不存在!", MultiLanguageConst.FlowTemplateNotExist);
}
if (db.Queryable<FlowInstance>().Where(x=>x.TemplateId == long.Parse(id)).Any())
if (TenantDb.Queryable<FlowInstance>().Where(x => x.TemplateId == long.Parse(id)).Any())
{
return DataResult.Failed("工作流实例存在引用的流程模板不能删除!",MultiLanguageConst.FlowTemplateDelExistImport);
return DataResult.Failed("工作流实例存在引用的流程模板不能删除!", MultiLanguageConst.FlowTemplateDelExistImport);
}
db.Deleteable(info).ExecuteCommand();
return DataResult.Successed("删除成功!",MultiLanguageConst.DataDelSuccess);
}
public DataResult<List<FlowTemplateRes>> GetFlowTemplateList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<FlowTemplate>().Where(a=>a.Status == StatusEnum.Enable)
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Select<FlowTemplateRes>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
TenantDb.Deleteable(info).ExecuteCommand();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
}

@ -134,7 +134,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
PermissionId = template.PermissionId,
ColumnView = template.ColumnView,
Content = template.Content,
MarkerNotifyURL = template.MakerNotifyURL,
MarkerNotifyURL = template.MarkerNotifyURL,
CallbackURL = template.CallbackURL,
AuditType = template.AuditType
};
@ -364,7 +364,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
if (string.IsNullOrEmpty(instance.MakerList))
{
instance.FlowStatus = FlowStatusEnum.Approve;
var template = Db.Queryable<FlowTemplateTenant>().Where(x => x.Id == instance.TemplateId)
var template = Db.Queryable<FlowTemplate>().Where(x => x.Id == instance.TemplateId)
.Select(x => new { x.MarkerNotifyURL, x.CallbackURL }).First();
instance.MarkerNotifyURL = template.MarkerNotifyURL;
instance.CallbackURL = template.CallbackURL;
@ -651,7 +651,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
{
var instance = await Db.Queryable<FlowInstance>().Where(x => x.AuditType == taskType && x.BusinessId == bsId)
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
.InnerJoin<FlowTemplateTenant>((f, ft) => f.TemplateId == ft.Id).Select((f, ft) => new FlowInstance
.InnerJoin<FlowTemplate>((f, ft) => f.TemplateId == ft.Id).Select((f, ft) => new FlowInstance
{
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
@ -680,7 +680,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
public FlowInstance GetFlowInstance(long id)
{
return Db.Queryable<FlowInstance>().Where(x => x.Id == id)
.InnerJoin<FlowTemplateTenant>((f, ft) => f.TemplateId == ft.Id).Select((f, ft) => new FlowInstance
.InnerJoin<FlowTemplate>((f, ft) => f.TemplateId == ft.Id).Select((f, ft) => new FlowInstance
{
ActivityId = f.ActivityId,
ActivityName = f.ActivityName,

@ -9,7 +9,7 @@ using SqlSugar;
namespace DS.WMS.Core.Flow.Method;
/// <summary>
///
/// 工作流运行时
/// </summary>
public class FlowRuntime
{
@ -20,19 +20,22 @@ public class FlowRuntime
/// 构造函数
/// </summary>
/// <param name="instance"></param>
/// <param name="_db"></param>
public FlowRuntime(FlowInstance instance, ISqlSugarClient _db) : this(instance, _db, null)
/// <param name="db"></param>
public FlowRuntime(FlowInstance instance, ISqlSugarClient db) : this(instance, db, null)
{
}
/// <summary>
/// 构造函数
/// </summary>
public FlowRuntime(FlowInstance instance, ISqlSugarClient _db, ISqlSugarClient? tenantDb)
/// <param name="instance"></param>
/// <param name="db"></param>
/// <param name="tenantDb"></param>
public FlowRuntime(FlowInstance instance, ISqlSugarClient db, ISqlSugarClient? tenantDb)
{
ArgumentNullException.ThrowIfNull(instance, nameof(instance));
db = _db;
this.db = db;
this.tenantDb = tenantDb;
InstanceId = instance.Id;

@ -115,7 +115,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
for (int i = 0; i < idModel.Ids.Length; i++)
{
var id = idModel.Ids[i];
var result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
var result = await flowService.Value.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = id,
TemplateId = template.Id
@ -123,7 +123,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
if (!result.Succeeded || result.Data is not FlowInstance instance)
return result;
result = flowService.Value.StartFlowInstance(instance.Id.ToString());
result = await flowService.Value.StartAsync(instance.Id);
if (!result.Succeeded)
return result;
}
@ -151,7 +151,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
});
}
var list = await flowService.Value.GetInstanceByBSIdAsync(INFO_CLIENT_TASK, ids: request.Ids);
var list = await flowService.Value.GetInstancesAsync(INFO_CLIENT_TASK, ids: request.Ids);
if (list.Count != request.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
@ -213,7 +213,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
}
}
var list = await flowService.Value.GetInstanceByBSIdAsync(INFO_CLIENT_TASK, ids: idModel.Ids);
var list = await flowService.Value.GetInstancesAsync(INFO_CLIENT_TASK, ids: idModel.Ids);
if (list.Count != idModel.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));

@ -145,7 +145,7 @@ namespace DS.WMS.Core.Info.Method
foreach (var item in list)
{
var result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
var result = await flowService.Value.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = item.Id,
TemplateId = template.Id
@ -153,7 +153,7 @@ namespace DS.WMS.Core.Info.Method
if (!result.Succeeded || result.Data is not FlowInstance instance)
return result;
result = flowService.Value.StartFlowInstance(instance.Id.ToString());
result = await flowService.Value.StartAsync(instance.Id);
if (!result.Succeeded)
return result;
}
@ -182,7 +182,7 @@ namespace DS.WMS.Core.Info.Method
});
}
var list = await flowService.Value.GetInstanceByBSIdAsync(CLIENT_STAKEHOLDER_TASK, ids: request.Ids);
var list = await flowService.Value.GetInstancesAsync(CLIENT_STAKEHOLDER_TASK, ids: request.Ids);
if (list.Count != request.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
@ -243,7 +243,7 @@ namespace DS.WMS.Core.Info.Method
}
}
var list = await flowService.Value.GetInstanceByBSIdAsync(CLIENT_STAKEHOLDER_TASK, ids: idModel.Ids);
var list = await flowService.Value.GetInstancesAsync(CLIENT_STAKEHOLDER_TASK, ids: idModel.Ids);
if (list.Count != idModel.Ids.Length)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));

@ -78,11 +78,11 @@ namespace DS.WMS.Core
/// </summary>
/// <param name="auditType">审批类型</param>
/// <returns></returns>
protected internal async Task<FlowTemplateTenant> FindTemplateAsync(TaskBaseTypeEnum auditType)
protected internal async Task<FlowTemplate> FindTemplateAsync(TaskBaseTypeEnum auditType)
{
long tid = long.Parse(User.TenantId);
return await Db.Queryable<FlowTemplateTenant>().OrderByDescending(x => x.CreateTime).Take(1)
.FirstAsync(x => x.TenantId == tid && x.Status == StatusEnum.Enable && x.AuditType == auditType);
return await TenantDb.Queryable<FlowTemplate>().OrderByDescending(x => x.CreateTime).Take(1)
.FirstAsync(x => x.Status == StatusEnum.Enable && x.AuditType == auditType);
}
}
}

@ -44,7 +44,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
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();
var flowInstances = await TenantDb.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
foreach (var instance in flowInstances)
{
result = await FlowService.Value.AuditAsync(new FlowAuditInfo

@ -269,7 +269,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
try
{
var flowIds = tasks.Select(x => x.FlowId.Value);
var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
var flowInstances = await TenantDb.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
foreach (var instance in flowInstances)
{
result = await FlowService.Value.AuditAsync(new FlowAuditInfo

@ -283,7 +283,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
try
{
var flowIds = tasks.Select(x => x.FlowId.Value);
var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
var flowInstances = await TenantDb.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
foreach (var instance in flowInstances)
{
result = await FlowService.Value.AuditAsync(new FlowAuditInfo

@ -375,7 +375,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
if (template == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound));
var result = FlowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
var result = await FlowService.Value.CreateAsync(new CreateFlowInstanceReq
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
@ -401,7 +401,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
}
else
{
result = FlowService.Value.StartFlowInstance(instance.Id.ToString());
result = await FlowService.Value.StartAsync(instance.Id);
instance = result.Data as FlowInstance;
if (result.Succeeded && changeMarker)
@ -964,7 +964,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
try
{
var flowIds = tasks.Where(x => !AuditTaskTypesManualReject.Contains(x.TaskType)).Select(x => x.FlowId.Value);
var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
var flowInstances = await TenantDb.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
foreach (var instance in flowInstances)
{
//如果当前审批为终审,则调用规则库进行校验
@ -1356,7 +1356,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
await TenantDb.Ado.BeginTranAsync();
try
{
rows = await Db.Deleteable<FlowInstance>().Where(x => x.BusinessId == id)
rows = await TenantDb.Deleteable<FlowInstance>().Where(x => x.BusinessId == id)
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
.WhereIF(taskTypes != null && taskTypes.Length > 0, x => taskTypes.Contains(x.AuditType.Value))
.ExecuteCommandAsync();

@ -44,7 +44,7 @@ public class ClientFlowInstanceController : ApiController
[Route("GetFlowInstanceList")]
public DataResult<List<FlowInstanceRes>> GetListByPage([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
var res = _invokeService.GetListAsync(request);
return res;
}
@ -57,7 +57,7 @@ public class ClientFlowInstanceController : ApiController
[Route("EditFlowInstance")]
public DataResult EditFlowInstance([FromBody] FlowInstanceReq model)
{
var res = _invokeService.EditFlowInstance(model);
var res = _invokeService.EditAsync(model);
return res;
}
@ -96,7 +96,7 @@ public class ClientFlowInstanceController : ApiController
[Route("CreateFlowInstance")]
public DataResult CreateFlowInstance([FromBody] CreateFlowInstanceReq req)
{
var res = _invokeService.CreateFlowInstance(req);
var res = _invokeService.CreateAsync(req);
return res;
}
@ -112,18 +112,6 @@ public class ClientFlowInstanceController : ApiController
return _invokeService.AuditAsync(req);
}
/// <summary>
/// 获取流程操作历史
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet, Route("GetFlowInstanceHistoryList"), Obsolete]
public DataResult<List<FlowInstanceHistoryRes>> GetFlowInstanceHistoryList([FromQuery] string id)
{
var res = _invokeService.GetFlowInstanceHistoryList(id);
return res;
}
/// <summary>
/// 根据业务获取流程操作历史
/// </summary>
@ -133,7 +121,7 @@ public class ClientFlowInstanceController : ApiController
[HttpGet, Route("GetFlowHistoriesByBiz")]
public DataResult<List<FlowInstanceHistoryRes>> GetFlowInstanceHistoryList([FromQuery] long bsId, [FromQuery] BusinessType? bsType)
{
return _invokeService.GetFlowInstanceHistoryList(bsId, bsType);
return _invokeService.GetHistoriesAsync(bsId, bsType);
}
/// <summary>
@ -164,7 +152,7 @@ public class ClientFlowInstanceController : ApiController
[FromQuery] BusinessType? businessType,
[FromQuery] params TaskBaseTypeEnum[]? types)
{
var result = _invokeService.GetFlowInstances(businessId, businessType, types);
var result = _invokeService.GetInstancesByBizAsync(businessId, businessType, types);
return result;
}
}

@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.MainApi.Controllers;
/// <summary>
/// 工作流模板-客户
/// 工作流模板
/// </summary>
public class ClientFlowTemplateController : ApiController
{
@ -58,18 +58,7 @@ public class ClientFlowTemplateController : ApiController
var res = _invokeService.GetClientFlowTemplateInfo(id);
return res;
}
/// <summary>
/// 导入模板
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("ImportFlowTemplate")]
public DataResult ImportFlowTemplate([FromQuery] string id)
{
var res = _invokeService.ImportFlowTemplate(id);
return res;
}
/// <summary>
/// 删除模板
/// </summary>
@ -82,17 +71,4 @@ public class ClientFlowTemplateController : ApiController
var res = _invokeService.DelFlowTemplate(id);
return res;
}
/// <summary>
/// 获取模板列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetFlowTemplateList")]
public DataResult<List<FlowTemplateRes>> GetFlowTemplateList([FromBody] PageRequest request)
{
var res = _invokeService.GetFlowTemplateList(request);
return res;
}
}

Loading…
Cancel
Save