|
|
|
@ -1,12 +1,10 @@
|
|
|
|
|
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 Mapster;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
@ -15,13 +13,11 @@ namespace DS.WMS.Core.Flow.Method;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
public class FlowInstanceService : ServiceBase, IFlowInstanceService
|
|
|
|
|
{
|
|
|
|
|
static readonly ApiFox api;
|
|
|
|
|
protected readonly ISqlSugarClient Db;
|
|
|
|
|
protected readonly IUser User;
|
|
|
|
|
|
|
|
|
|
static FlowInstanceService()
|
|
|
|
|
static FlowInstanceService()
|
|
|
|
|
{
|
|
|
|
|
api = new ApiFox();
|
|
|
|
|
}
|
|
|
|
@ -30,10 +26,8 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
|
|
public FlowInstanceService(IServiceProvider serviceProvider)
|
|
|
|
|
public FlowInstanceService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
Db = serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
User = serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -106,7 +100,7 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
PermissionId = template.PermissionId,
|
|
|
|
|
ColumnView = template.ColumnView,
|
|
|
|
|
Content = template.Content,
|
|
|
|
|
MakerNotifyURL = template.MakerNotifyURL,
|
|
|
|
|
MarkerNotifyURL = template.MakerNotifyURL,
|
|
|
|
|
CallbackURL = template.CallbackURL,
|
|
|
|
|
Type = template.AuditType
|
|
|
|
|
};
|
|
|
|
@ -304,15 +298,20 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
return DataResult.Successed("更新成功!", instance, MultiLanguageConst.FlowInstanceUpdateSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 审核工作流实例
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult AuditFlowInstance(FlowInstanceAuditReq req)
|
|
|
|
|
{
|
|
|
|
|
var instance = Db.Queryable<FlowInstance>().First(x => x.Id == req.Id);
|
|
|
|
|
var instance = GetFlowInstance(req.Id);
|
|
|
|
|
|
|
|
|
|
if (instance.IsNull())
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("该工作流不存在!", MultiLanguageConst.FlowInstanceNotExist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (instance.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
else if (instance.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("该工作流已完成!", MultiLanguageConst.FlowInstanceFinished);
|
|
|
|
|
}
|
|
|
|
@ -320,6 +319,13 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
return AuditFlowCore(req.Status, req.AuditNote, instance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流实例审核实现
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="status"></param>
|
|
|
|
|
/// <param name="auditNote"></param>
|
|
|
|
|
/// <param name="instance"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected virtual DataResult AuditFlowCore(int status, string auditNote, FlowInstance instance)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(instance, nameof(instance));
|
|
|
|
@ -376,7 +382,7 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
|
|
|
|
|
var markers = GetNextMarkers(instance);
|
|
|
|
|
//获取会签下一执行人,进行通知
|
|
|
|
|
if (markers?.Length > 0 && !instance.MakerNotifyURL.IsNullOrEmpty())
|
|
|
|
|
if (markers?.Length > 0 && !instance.MarkerNotifyURL.IsNullOrEmpty() && markers?.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Task.Factory.StartNew(() => NotifyMakerChangedAsync(instance, [long.Parse(markers[0])]));
|
|
|
|
|
}
|
|
|
|
@ -467,7 +473,7 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
api.DefaultHeaders.Remove("Authorization");
|
|
|
|
|
|
|
|
|
|
api.DefaultHeaders.Add("Authorization", "Bearer " + User.GetToken());
|
|
|
|
|
await api.PostAsync<DataResult>(instance.MakerNotifyURL, callback);
|
|
|
|
|
await api.PostAsync<DataResult>(instance.MarkerNotifyURL, callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -505,6 +511,34 @@ public class FlowInstanceService : IFlowInstanceService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取运行实例信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
Type = f.Type
|
|
|
|
|
}).First();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual FlowRuntime CreateRuntimeService(FlowInstance instance)
|
|
|
|
|
{
|
|
|
|
|
return new FlowRuntime(instance, Db, null, User);
|
|
|
|
|