|
|
|
|
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;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Flow.Method;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>⻧<EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
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,
|
|
|
|
|
BusinessType = req.BusinessType,
|
|
|
|
|
PermissionId = template.PermissionId,
|
|
|
|
|
ColumnView = template.ColumnView,
|
|
|
|
|
Content = template.Content,
|
|
|
|
|
MakerNotifyURL = template.MakerNotifyURL,
|
|
|
|
|
CallbackURL = template.CallbackURL,
|
|
|
|
|
Type = template.AuditType
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string GetForkNodeMakers(FlowRuntime 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 FlowRuntime CreateRuntimeService(FlowInstance instance)
|
|
|
|
|
{
|
|
|
|
|
return new FlowRuntime(instance, Db, saasService, User);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="businessId">ҵ<><D2B5>ID</param>
|
|
|
|
|
/// <param name="businessType">ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult<List<FlowInstanceRes>> GetFlowInstances(long businessId, BusinessType? businessType)
|
|
|
|
|
{
|
|
|
|
|
var query = Db.Queryable<FlowInstance>().Where(x => x.BusinessId == businessId && x.FlowStatus != FlowStatusEnum.Running);
|
|
|
|
|
if (businessType.HasValue)
|
|
|
|
|
query = query.Where(x => x.BusinessType == businessType.Value);
|
|
|
|
|
|
|
|
|
|
var list = query.OrderBy(x => x.CreateTime).Select(x => new FlowInstance
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
Content = x.Content,
|
|
|
|
|
Type = x.Type,
|
|
|
|
|
//CreateBy = x.CreateBy,
|
|
|
|
|
//CreateTime = x.CreateTime
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
var list2 = list.Select(x => x.Adapt<FlowInstanceRes>()).ToList();
|
|
|
|
|
foreach (var item in list2)
|
|
|
|
|
{
|
|
|
|
|
item.AuditTypeName = item.AuditType?.ToEnum<AuditType>().GetDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<List<FlowInstanceRes>>.Success(list2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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)
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|