任务审核自动通过

dev
嵇文龙 2 months ago
parent 9910d4e0db
commit da05ffac25

@ -1529,6 +1529,8 @@ public static class MultiLanguageConst
public const string TaskMailReceiverNotNull = "Task_Mail_Receiver_Not_Null"; public const string TaskMailReceiverNotNull = "Task_Mail_Receiver_Not_Null";
[Description("任务邮件必须设置发件人")] [Description("任务邮件必须设置发件人")]
public const string TaskMailSenderNotNull = "Task_Mail_Sender_Not_Null"; public const string TaskMailSenderNotNull = "Task_Mail_Sender_Not_Null";
[Description("驳回成功")]
public const string TaskRejected = "Task_Rejected";
#endregion #endregion
#region 任务台相关 #region 任务台相关

@ -1,5 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using System.Net.Http;
using System.Reflection; using System.Reflection;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;

@ -127,8 +127,45 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
if (instance == null) if (instance == null)
return DataResult.Failed("该流程模板已不存在,请重新设计流程!", MultiLanguageConst.FlowTemplateNotExist); return DataResult.Failed("该流程模板已不存在,请重新设计流程!", MultiLanguageConst.FlowTemplateNotExist);
var userName = Db.Queryable<SysUser>().Where(x => x.Id == long.Parse(User.UserId)).Select(x => x.UserName).First();
//创建运行实例 //创建运行实例
var runtime = CreateRuntimeService(instance); var runtime = CreateRuntimeService(instance);
if (runtime.ShouldSkip)
{
instance.FlowStatus = FlowStatusEnum.Approve;
instance.Note = "已设置为自动跳过工作流执行";
Db.Insertable(instance).ExecuteCommand();
var history1 = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【创建】"
+ userName
+ "创建了一个流程进程【"
+ instance.CustomName + "】",
UserName = userName
};
var history2 = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【审核】"
+ userName
+ "流程条件触发自动审核【"
+ instance.CustomName + "】",
UserName = userName
};
FlowInstanceHistory[] histories = [history1, history2];
Db.Insertable(histories).ExecuteCommand();
if (!string.IsNullOrEmpty(instance.CallbackURL))
Task.Factory.StartNew(() => RunCallbackAsync(instance));
var result = DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
return result;
}
if (runtime.CurrentNode is { AssigneeType: "user", Users.Count: > 0 }) if (runtime.CurrentNode is { AssigneeType: "user", Users.Count: > 0 })
{ {
@ -158,8 +195,6 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.MakerList = GetCurrentMakers(runtime); instance.MakerList = GetCurrentMakers(runtime);
instance.FlowStatus = FlowStatusEnum.Ready; instance.FlowStatus = FlowStatusEnum.Ready;
runtime.FlowInstanceId = instance.Id;
#endregion 根据运行实例改变当前节点状态 #endregion 根据运行实例改变当前节点状态
Db.Insertable(instance).ExecuteCommand(); Db.Insertable(instance).ExecuteCommand();
@ -170,22 +205,18 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
Task.Factory.StartNew(() => RunCallbackAsync(instance)); Task.Factory.StartNew(() => RunCallbackAsync(instance));
} }
var userInfo = Db.Queryable<SysUser>().First(x => x.Id == long.Parse(User.UserId));
var history = new FlowInstanceHistory var history = new FlowInstanceHistory
{ {
InstanceId = instance.Id, InstanceId = instance.Id,
Content = "【创建】" Content = "【创建】"
+ userInfo.UserName + userName
+ "创建了一个流程进程【" + "创建了一个流程进程【"
+ instance.CustomName + "】", + instance.CustomName + "】",
UserName = userInfo.UserName UserName = userName
}; };
Db.Insertable(history).ExecuteCommand(); Db.Insertable(history).ExecuteCommand();
// var info = db.Queryable<FlowInstance>().Where(x => x.Id == req.Id).First();
//
// info = req.Adapt(info);
//
// db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess); return DataResult.Successed("创建工作流实例成功!", instance, MultiLanguageConst.FlowInstanceCreateSuccess);
} }
@ -219,11 +250,9 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.ActivityId = startNodeId; instance.ActivityId = startNodeId;
instance.ActivityType = wfruntime.GetNodeType(startNodeId); instance.ActivityType = wfruntime.GetNodeType(startNodeId);
instance.ActivityName = wfruntime.ChildNodes.First(x => x.Id == startNodeId).Name; instance.ActivityName = wfruntime.ChildNodes.First(x => x.Id == startNodeId).Name;
instance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1"); instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1";
instance.FlowStatus = FlowStatusEnum.Draft; instance.FlowStatus = FlowStatusEnum.Draft;
wfruntime.FlowInstanceId = instance.Id;
#endregion 根据运行实例改变当前节点状态 #endregion 根据运行实例改变当前节点状态
var serializerSettings = new JsonSerializerSettings var serializerSettings = new JsonSerializerSettings
{ {
@ -289,8 +318,6 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "1"; instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "1";
instance.FlowStatus = (wfruntime.GetNextNodeType() == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running); instance.FlowStatus = (wfruntime.GetNextNodeType() == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running);
wfruntime.FlowInstanceId = instance.Id;
#endregion 根据运行实例改变当前节点状态 #endregion 根据运行实例改变当前节点状态
Db.Updateable(instance).ExecuteCommand(); Db.Updateable(instance).ExecuteCommand();

@ -33,7 +33,6 @@ public class FlowRuntime
CurrentNodeId = instance.ActivityId == "" ? StartNodeId : instance.ActivityId; CurrentNodeId = instance.ActivityId == "" ? StartNodeId : instance.ActivityId;
CurrentNodeType = GetNodeType(CurrentNodeId); CurrentNodeType = GetNodeType(CurrentNodeId);
PreviousId = instance.PreviousId; PreviousId = instance.PreviousId;
FlowInstanceId = instance.Id;
//会签开始节点和流程结束节点没有下一步 //会签开始节点和流程结束节点没有下一步
if (CurrentNodeType == 0 || CurrentNodeType == 4) if (CurrentNodeType == 0 || CurrentNodeType == 4)
@ -49,7 +48,15 @@ public class FlowRuntime
else else
{ {
NextNodeId = GetNextNodeId(CurrentNodeId); //下一个节点 NextNodeId = GetNextNodeId(CurrentNodeId); //下一个节点
NextNodeType = GetNodeType(NextNodeId); if (string.IsNullOrEmpty(NextNodeId) && CurrentNodeType == 3)
{
//当前节点类型为开始节点,且没有下一级节点,则认为应跳出工作流
ShouldSkip = true;
}
else
{
NextNodeType = GetNodeType(NextNodeId);
}
} }
} }
@ -61,9 +68,14 @@ public class FlowRuntime
IUser user { get; set; } IUser user { get; set; }
/// <summary> /// <summary>
/// 运行实例的Id /// 是否应跳过工作流执行
/// </summary> /// </summary>
public long FlowInstanceId { get; set; } public bool ShouldSkip { get; private set; }
///// <summary>
///// 运行实例的Id
///// </summary>
//public long FlowInstanceId { get; set; }
/// <summary> /// <summary>
/// 开始节点的ID /// 开始节点的ID
@ -209,7 +221,6 @@ public class FlowRuntime
{ {
return ChildNodes.Where(x => x.Id == "end").First().Id; return ChildNodes.Where(x => x.Id == "end").First().Id;
} }
// return ChildNodes.Where(x => x.Pid == nodeId).First().Id;
} }
} }
@ -218,7 +229,7 @@ public class FlowRuntime
/// </summary> /// </summary>
/// <param name="parent"></param> /// <param name="parent"></param>
/// <returns></returns> /// <returns></returns>
public string GetNextConditionNodeId(FlowChild parent) public string? GetNextConditionNodeId(FlowChild parent)
{ {
var conditionNodes = GetFlowConditions(parent); var conditionNodes = GetFlowConditions(parent);
var conditionId = string.Empty; var conditionId = string.Empty;
@ -226,7 +237,6 @@ public class FlowRuntime
{ {
if (i == conditionNodes.Count - 1) if (i == conditionNodes.Count - 1)
{ {
// return ChildNodes.Where(x => x.Pid == conditionNodes[i].Id).First().Id;
conditionId = conditionNodes[i].Id; conditionId = conditionNodes[i].Id;
} }
else else
@ -301,7 +311,8 @@ public class FlowRuntime
} }
} }
return ChildNodes.Where(x => x.Pid == conditionId).FirstOrDefault()?.Id; var node = ChildNodes.Find(x => x.Pid == conditionId);
return node?.Id;
} }
/// <summary> /// <summary>

@ -410,22 +410,36 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (result.Succeeded) if (result.Succeeded)
{ {
var instance = result.Data as FlowInstance; var instance = result.Data as FlowInstance;
task.FlowId = instance.Id; task.FlowId = instance!.Id;
await TenantDb.Updateable(task).UpdateColumns(x => x.FlowId).ExecuteCommandAsync(); await TenantDb.Updateable(task).UpdateColumns(x => x.FlowId).ExecuteCommandAsync();
result = FlowService.Value.StartFlowInstance(instance.Id.ToString()); if (instance.FlowStatus == FlowStatusEnum.Approve)
instance = result.Data as FlowInstance;
if (result.Succeeded && changeMarker)
{ {
string[] ids = FlowInstanceService.GetMarkers(instance); await SetTaskStatusAsync(new TaskUpdateRequest
//变更任务接收人为所有审批执行人 {
var users = await FillInUserInfoAsync(ids.Select(long.Parse).ToArray()); BusinessId = task.BusinessId,
result = await ManagerService.TransferTask(task.BusinessId, task.TaskType, users, TenantDb); BusinessType = task.BusinessType,
if (result.Succeeded) RejectReason = instance.Note,
TaskTypeName = task.TaskType.ToString(),
TaskStatus = TaskStatusEnum.Complete
}, false);
}
else
{
result = FlowService.Value.StartFlowInstance(instance.Id.ToString());
instance = result.Data as FlowInstance;
if (result.Succeeded && changeMarker)
{ {
task.RecvUsers = string.Join(",", ids); string[] ids = FlowInstanceService.GetMarkers(instance);
await TenantDb.Updateable(task).UpdateColumns(x => x.RecvUsers).ExecuteCommandAsync(); //变更任务接收人为所有审批执行人
var users = await FillInUserInfoAsync(ids.Select(long.Parse).ToArray());
result = await ManagerService.TransferTask(task.BusinessId, task.TaskType, users, TenantDb);
if (result.Succeeded)
{
task.RecvUsers = string.Join(",", ids);
await TenantDb.Updateable(task).UpdateColumns(x => x.RecvUsers).ExecuteCommandAsync();
}
} }
} }
@ -774,25 +788,30 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
Instance = instance Instance = instance
}); });
if (result.Succeeded) if (!result.Succeeded)
return result;
var req = new TaskUpdateRequest
{ {
var req = new TaskUpdateRequest BusinessId = instance.BusinessId,
{ BusinessType = instance.BusinessType,
BusinessId = instance.BusinessId, RejectReason = request.Remark,
BusinessType = instance.BusinessType, TaskTypeName = request.TaskType.ToString(),
RejectReason = request.Remark, TaskStatus = request.Result == 1 ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
TaskTypeName = request.TaskType.ToString(), AutoCreateNext = true
TaskStatus = request.Result == 1 ? TaskStatusEnum.Complete : TaskStatusEnum.Pending, };
AutoCreateNext = true //根据审批结果更新任务状态
}; await SetTaskStatusAsync(req);
//根据审批结果更新任务状态
await SetTaskStatusAsync(req);
if (instance.FlowStatus == FlowStatusEnum.Approve)
{
//终审通过且任务类型为审单,则生成费用 //终审通过且任务类型为审单,则生成费用
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.FlowStatus == FlowStatusEnum.Approve && instance.IsCompleted) if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.IsCompleted)
{ {
UriBuilder builder = new UriBuilder(configuration["FeeService:BaseUrl"]); UriBuilder builder = new(configuration["FeeService:BaseUrl"])
builder.Path = configuration["FeeService:GenerateFees"]; {
Path = configuration["FeeService:GenerateFees"]
};
string url = builder.ToString(); string url = builder.ToString();
if (string.IsNullOrEmpty(url)) if (string.IsNullOrEmpty(url))
{ {
@ -808,6 +827,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
Api.SendRequestAsync(HttpMethod.Post, url, json); Api.SendRequestAsync(HttpMethod.Post, url, json);
} }
} }
else if (instance.FlowStatus == FlowStatusEnum.Reject)
{
result.Message = MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskRejected));
}
if (IsOrderType(request.TaskType)) if (IsOrderType(request.TaskType))
result.Data = new { instance.IsCompleted, instance.FlowStatus }; result.Data = new { instance.IsCompleted, instance.FlowStatus };

@ -2,7 +2,6 @@
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Application.Entity; using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Settlement.Entity; using DS.WMS.Core.Settlement.Entity;
@ -35,8 +34,10 @@ namespace DS.WMS.Core.Settlement.Method
var result = await TenantDb.Queryable<InvoiceApplication>() var result = await TenantDb.Queryable<InvoiceApplication>()
.InnerJoin<ApplicationDetail>((a, d) => a.Id == d.ApplicationId && d.OriginalAmount - d.OriginalProcessedAmount != 0) .InnerJoin<ApplicationDetail>((a, d) => a.Id == d.ApplicationId && d.OriginalAmount - d.OriginalProcessedAmount != 0)
.InnerJoin<FeeRecord>((a, d, f) => d.RecordId == f.Id && .InnerJoin<FeeRecord>((a, d, f) => d.RecordId == f.Id &&
(f.Amount > 0 && d.OriginalAmount - d.OriginalSettlementAmount <= f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount) || ((f.Amount > 0 && d.OriginalAmount - d.OriginalSettlementAmount <= f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount) ||
(f.Amount < 0 && d.OriginalAmount - d.OriginalSettlementAmount >= f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount)) (f.Amount < 0 && d.OriginalAmount - d.OriginalSettlementAmount >= f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount))
)
.GroupBy((a, d, f) => a.Id)
.Select((a, d, f) => new InvoiceApplicationDto .Select((a, d, f) => new InvoiceApplicationDto
{ {

@ -1,11 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ActiveDebugProfile>http</ActiveDebugProfile> <NameOfLastUsedPublishProfile>D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
<NameOfLastUsedPublishProfile>D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID> <Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath> <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save