优化历史操作记录

This commit is contained in:
yubaolee 2025-01-13 14:56:47 +08:00
parent 24aa7ec643
commit fe37f200c0
2 changed files with 27 additions and 55 deletions

View File

@ -216,7 +216,7 @@ namespace OpenAuth.App.Flow
var content =
$"{user.Account}-{DateTime.Now:yyyy-MM-dd HH:mm}审批了【{Nodes[canCheckId].name}】" +
$"结果:{(tag.Taged == 1 ? "" : "")},备注:{tag.Description}";
AddOperationHis(tag, content);
SaveOperationHis(content);
MakeTagNode(canCheckId, tag); //标记审核节点状态
@ -402,21 +402,32 @@ namespace OpenAuth.App.Flow
};
}
public void AddOperationHis(Tag tag, string content)
public void SaveOperationHis(string userId, string userName, string opHis)
{
FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory
{
InstanceId = flowInstanceId,
CreateUserId = tag.UserId,
CreateUserName = tag.UserName,
CreateUserId = userId,
CreateUserName = userName,
CreateDate = DateTime.Now,
Content = content
Content = opHis
}; //操作记录
var SugarClient = AutofacContainerModule.GetService<ISqlSugarClient>();
SugarClient.Insertable(flowInstanceOperationHistory).ExecuteCommand();
}
/// <summary>
/// 添加工作流实例操作记录
/// <para>操作人为当前的登录用户</para>
/// </summary>
/// <param name="opHis"></param>
public void SaveOperationHis(string opHis)
{
var user = AutofacContainerModule.GetService<IAuth>().GetCurrentUser().User;
SaveOperationHis(user.Id, user.Name, opHis);
}
/// <summary>
/// 保存本次扭转记录
/// </summary>
@ -709,12 +720,12 @@ namespace OpenAuth.App.Flow
/// 运行实例的Id
/// </summary>
private string flowInstanceId { get; set; }
/// <summary>
/// 上一个节点
/// </summary>
private string previousId { get; set; }
/// <summary>
/// 流程实例中所有的线段
/// </summary>
@ -729,12 +740,12 @@ namespace OpenAuth.App.Flow
/// 到达节点的线段集合
/// </summary>
private Dictionary<string, List<FlowLine>> ToNodeLines { get; set; }
/// <summary>
/// 当前节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
/// </summary>
private int currentNodeType { get; set; }
/// <summary>
/// 表单数据
/// </summary>

View File

@ -197,19 +197,7 @@ namespace OpenAuth.App
#endregion
#region
FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.User.Id,
CreateUserName = user.User.Name,
CreateDate = DateTime.Now,
Content = $"【创建】{user.User.Name}创建了流程实例【{addFlowInstanceReq.CustomName}】"
};
SugarClient.Insertable(processOperationHistoryEntity).ExecuteCommand();
#endregion
wfruntime.SaveOperationHis($"【创建】{user.User.Name}创建了流程实例【{addFlowInstanceReq.CustomName}】");
wfruntime.SaveTransitionHis();
SugarClient.Ado.CommitTran();
@ -351,7 +339,7 @@ namespace OpenAuth.App
private void CounterSign(FlowRuntime wfruntime, Tag tag, FlowInstance flowInstance)
{
string res = wfruntime.NodeConfluence(_httpClientFactory.CreateClient(), tag);
if (res == TagState.No.ToString("D"))
{
flowInstance.IsFinish = FlowInstanceStatus.Disagree;
@ -478,7 +466,7 @@ namespace OpenAuth.App
var content =
$"{user.Account}-{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}审批了【{wfruntime.currentNode.name}】" +
$"结果:{(tag.Taged == 1 ? "" : "")},备注:{tag.Description}";
wfruntime.AddOperationHis(tag, content);
wfruntime.SaveOperationHis(tag.UserId, tag.UserName, content);
if (flowInstance.IsFinish == 1)
{
@ -557,15 +545,8 @@ namespace OpenAuth.App
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
SugarClient.Updateable(flowInstance).ExecuteCommand();
SugarClient.Insertable(new FlowInstanceOperationHistory
{
InstanceId = reqest.FlowInstanceId,
CreateUserId = user.Id,
CreateUserName = user.Name,
CreateDate = DateTime.Now,
Content =
$"【{wfruntime.currentNode.name}】【{DateTime.Now:yyyy-MM-dd HH:mm}】驳回,备注:{reqest.VerificationOpinion}"
}).ExecuteCommand();
wfruntime.SaveOperationHis(
$"{user.Account}-{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}驳回了【{wfruntime.currentNode.name}】");
//给流程创建人发送通知信息
_messageApp.SendMsgTo(flowInstance.CreateUserId,
@ -776,14 +757,7 @@ namespace OpenAuth.App
SugarClient.Updateable(flowInstance).ExecuteCommand();
SugarClient.Insertable(new FlowInstanceOperationHistory
{
InstanceId = request.FlowInstanceId,
CreateUserId = user.Id,
CreateUserName = user.Name,
CreateDate = DateTime.Now,
Content = $"【撤销】由{user.Name}撤销,备注:{request.Description}"
}).ExecuteCommand();
wfruntime.SaveOperationHis($"【撤回】由{user.Name}撤回,备注:{request.Description}");
SugarClient.Ado.CommitTran();
}
@ -824,20 +798,7 @@ namespace OpenAuth.App
#endregion
#region
FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.User.Id,
CreateUserName = user.User.Name,
CreateDate = DateTime.Now,
Content = $"【启动】由用户{user.User.Name}启动"
};
SugarClient.Insertable(processOperationHistoryEntity).ExecuteCommand();
#endregion
wfruntime.SaveOperationHis($"【启动】由用户{user.User.Name}启动");
wfruntime.SaveTransitionHis();
SugarClient.Ado.CommitTran();
}