You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.2 KiB
C#

6 months ago
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
6 months ago
{
readonly ISaasDbService saasService;
6 months ago
public ClientFlowInstanceService(IServiceProvider serviceProvider) : base(serviceProvider)
6 months ago
{
saasService = serviceProvider.GetRequiredService<ISaasDbService>();
6 months ago
}
protected override FlowInstance BuildInstance(CreateFlowInstanceReq req)
6 months ago
{
if(string.IsNullOrEmpty(req.TemplateId.ToString()))
return null;
6 months ago
FlowTemplateTenant template = db.Queryable<FlowTemplateTenant>().First(x => x.Id == req.TemplateId);
6 months ago
return template == null ? null : new FlowInstance
6 months ago
{
CustomName = template.Name,
TemplateId = template.Id,
BusinessId = req.BusinessId,
PermissionId = template.PermissionId,
ColumnView = template.ColumnView,
Content = template.Content,
CallbackURL = template.CallbackURL
6 months ago
};
}
protected override string GetForkNodeMakers(FlowRuntimeService wfruntime, string forkNodeId)
6 months ago
{
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)
6 months ago
{
return new FlowRuntimeService(instance, db, saasService, user);
6 months ago
}
}