任务审核自动通过

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";
[Description("任务邮件必须设置发件人")]
public const string TaskMailSenderNotNull = "Task_Mail_Sender_Not_Null";
[Description("驳回成功")]
public const string TaskRejected = "Task_Rejected";
#endregion
#region 任务台相关

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

@ -127,8 +127,45 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
if (instance == null)
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);
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 })
{
@ -158,8 +195,6 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.MakerList = GetCurrentMakers(runtime);
instance.FlowStatus = FlowStatusEnum.Ready;
runtime.FlowInstanceId = instance.Id;
#endregion 根据运行实例改变当前节点状态
Db.Insertable(instance).ExecuteCommand();
@ -170,22 +205,18 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
Task.Factory.StartNew(() => RunCallbackAsync(instance));
}
var userInfo = Db.Queryable<SysUser>().First(x => x.Id == long.Parse(User.UserId));
var history = new FlowInstanceHistory
{
InstanceId = instance.Id,
Content = "【创建】"
+ userInfo.UserName
+ userName
+ "创建了一个流程进程【"
+ instance.CustomName + "】",
UserName = userInfo.UserName
UserName = userName
};
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);
}
@ -219,11 +250,9 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.ActivityId = startNodeId;
instance.ActivityType = wfruntime.GetNodeType(startNodeId);
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;
wfruntime.FlowInstanceId = instance.Id;
#endregion 根据运行实例改变当前节点状态
var serializerSettings = new JsonSerializerSettings
{
@ -289,8 +318,6 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.MakerList = wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "1";
instance.FlowStatus = (wfruntime.GetNextNodeType() == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running);
wfruntime.FlowInstanceId = instance.Id;
#endregion 根据运行实例改变当前节点状态
Db.Updateable(instance).ExecuteCommand();

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

@ -410,9 +410,22 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
task.FlowId = instance.Id;
task.FlowId = instance!.Id;
await TenantDb.Updateable(task).UpdateColumns(x => x.FlowId).ExecuteCommandAsync();
if (instance.FlowStatus == FlowStatusEnum.Approve)
{
await SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
RejectReason = instance.Note,
TaskTypeName = task.TaskType.ToString(),
TaskStatus = TaskStatusEnum.Complete
}, false);
}
else
{
result = FlowService.Value.StartFlowInstance(instance.Id.ToString());
instance = result.Data as FlowInstance;
@ -428,6 +441,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
await TenantDb.Updateable(task).UpdateColumns(x => x.RecvUsers).ExecuteCommandAsync();
}
}
}
result.Data = instance;
}
@ -774,8 +788,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
Instance = instance
});
if (result.Succeeded)
{
if (!result.Succeeded)
return result;
var req = new TaskUpdateRequest
{
BusinessId = instance.BusinessId,
@ -788,11 +803,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//根据审批结果更新任务状态
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"]);
builder.Path = configuration["FeeService:GenerateFees"];
UriBuilder builder = new(configuration["FeeService:BaseUrl"])
{
Path = configuration["FeeService:GenerateFees"]
};
string url = builder.ToString();
if (string.IsNullOrEmpty(url))
{
@ -808,6 +827,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
Api.SendRequestAsync(HttpMethod.Post, url, json);
}
}
else if (instance.FlowStatus == FlowStatusEnum.Reject)
{
result.Message = MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskRejected));
}
if (IsOrderType(request.TaskType))
result.Data = new { instance.IsCompleted, instance.FlowStatus };

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

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

Loading…
Cancel
Save