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.

101 lines
3.6 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.Op.Entity;
6 months ago
using DS.WMS.Core.Sys.Entity;
using Mapster;
6 months ago
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,
BusinessType = req.BusinessType,
6 months ago
PermissionId = template.PermissionId,
ColumnView = template.ColumnView,
Content = template.Content,
CallbackURL = template.CallbackURL,
AuditType = template.AuditType
6 months ago
};
}
protected override string GetForkNodeMakers(FlowRuntime 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 FlowRuntime CreateRuntimeService(FlowInstance instance)
{
return new FlowRuntime(instance, db, saasService, user);
}
6 months ago
/// <summary>
/// <20><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD><EFBFBD>͵Ĺ<CDB5><C4B9><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
/// </summary>
/// <param name="businessId">ҵ<><D2B5>ID</param>
/// <param name="businessType">ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="type">ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <returns></returns>
public DataResult<FlowInstanceRes> GetFlowInstance(long businessId, BusinessType businessType, string type)
6 months ago
{
var entity = db.Queryable<FlowInstance>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType && x.AuditType == type)
.OrderByDescending(x => x.CreateTime).First();
var result = entity == null ? null : entity.Adapt<FlowInstanceRes>();
return DataResult<FlowInstanceRes>.Success(result);
6 months ago
}
6 months ago
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="info"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5></param>
/// <returns></returns>
public DataResult AuditFlowInstance(FlowAuditInfo info)
{
if (info == null)
return DataResult.Failed("<22>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", MultiLanguageConst.FlowInstanceNotExist);
if (info.Instance.FlowStatus == FlowStatusEnum.Approve.ToEnumInt())
return DataResult.Failed("<22>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", MultiLanguageConst.FlowInstanceFinished);
return AuditFlowCore(info.Status, info.AuditNote, info.Instance);
}
6 months ago
}