|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
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 Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Flow.Method;
|
|
|
|
|
|
|
|
public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanceService
|
|
|
|
{
|
|
|
|
readonly ISaasDbService saasService;
|
|
|
|
|
|
|
|
|
|
|
|
public ClientFlowInstanceService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
|
|
{
|
|
|
|
saasService = serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override FlowInstance BuildInstance(CreateFlowInstanceReq req)
|
|
|
|
{
|
|
|
|
if(string.IsNullOrEmpty(req.TemplateId.ToString()))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
FlowTemplateTenant template = db.Queryable<FlowTemplateTenant>().First(x => x.Id == req.TemplateId);
|
|
|
|
|
|
|
|
return template == null ? null : new FlowInstance
|
|
|
|
{
|
|
|
|
CustomName = template.Name,
|
|
|
|
TemplateId = template.Id,
|
|
|
|
BusinessId = req.BusinessId,
|
|
|
|
PermissionId = template.PermissionId,
|
|
|
|
ColumnView = template.ColumnView,
|
|
|
|
Content = template.Content,
|
|
|
|
CallbackURL = template.CallbackURL
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string GetForkNodeMakers(FlowRuntimeService wfruntime, string forkNodeId)
|
|
|
|
{
|
|
|
|
string makerList = "";
|
|
|
|
|
|
|
|
var nextNode = wfruntime.NextNode;
|
|
|
|
|
|
|
|
var nextConditionNodeId = wfruntime.GetClientNextConditionNodeId(nextNode);
|
|
|
|
var nextConditionNode = wfruntime.ChildNodes.First(x => x.Id == nextConditionNodeId);
|
|
|
|
if (nextConditionNode.AssigneeType == "role")
|
|
|
|
{
|
|
|
|
var users = db.Queryable<SysRoleUser>().Where(x =>
|
|
|
|
nextConditionNode.Roles.Contains(x.RoleId.ToString()))
|
|
|
|
.Select(x => x.UserId).Distinct().ToList();
|
|
|
|
makerList = GenericHelper.ArrayToString(users, makerList);
|
|
|
|
}
|
|
|
|
else if (nextConditionNode.AssigneeType == "user")
|
|
|
|
{
|
|
|
|
makerList = string.Join(",", nextConditionNode.Users);
|
|
|
|
}
|
|
|
|
|
|
|
|
return makerList;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override FlowRuntimeService CreateRuntimeService(FlowInstance instance)
|
|
|
|
{
|
|
|
|
return new FlowRuntimeService(instance, db, saasService, user);
|
|
|
|
}
|
|
|
|
}
|