修改服务加载,增加日志记录

optimize
jianghaiqing 1 year ago
parent 16904ad985
commit a0f68015f4

@ -1,6 +1,7 @@
using Furion.DistributedIDGenerator;
using Myshipping.Application.Entity.TrackingSystem;
using Myshipping.Core;
using NPOI.HSSF.Record.AutoFilter;
using SqlSugar;
using System;
using System.Collections.Generic;
@ -19,13 +20,6 @@ namespace Myshipping.Application.Entity
[Tenant(CommonConst.MasterDb)]
public class ServiceWorkFlowRunLogInfo
{
public ServiceWorkFlowRunLogInfo()
{
PK_ID = IDGen.NextID().ToString();
CreatedTime = DateTime.Now;
}
/// <summary>
/// 主键
/// </summary>
@ -37,6 +31,11 @@ namespace Myshipping.Application.Entity
/// </summary>
public string BATCH_NO { get; set; }
/// <summary>
/// 操作类型 PUSH_PROJECT 推送服务CANCEL_PROJECT 取消服务PUSH_STATUS 推送状态CANCEL_STATUS 取消状态
/// </summary>
public string OPER_TYPE { get; set; }
/// <summary>
/// 服务流程运行主表ID
/// </summary>
@ -107,6 +106,11 @@ namespace Myshipping.Application.Entity
/// </summary>
public Nullable<DateTime> ACT_DATE { get; set; }
/// <summary>
/// 活动备注
/// </summary>
public string ACT_REMARK { get; set; }
/// <summary>
/// 下一个活动ID
/// </summary>

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 服务项目运行操作枚举
/// </summary>
public enum TrackingRunOperTypeEnum
{
/// <summary>
/// 推送服务
/// </summary>
[Description("推送服务")]
PUSH_PROJECT,
/// <summary>
/// 取消服务
/// </summary>
[Description("取消服务")]
CANCEL_PROJECT,
/// <summary>
/// 推送状态
/// </summary>
[Description("推送状态")]
PUSH_STATUS,
/// <summary>
/// 取消状态
/// </summary>
[Description("取消状态")]
CANCEL_STATUS
}
}

@ -178,5 +178,10 @@ namespace Myshipping.Application
/// 计算排序值
/// </summary>
public decimal CalcSortNo { get; set; }
/// <summary>
/// 是否结束
/// </summary>
public bool IsEnd { get; set; }
}
}

@ -12,6 +12,7 @@ using Microsoft.Extensions.Options;
using Myshipping.Application.Entity;
using Myshipping.Core;
using Myshipping.Core.Entity;
using Npoi.Mapper;
using NPOI.OpenXmlFormats.Vml;
using NPOI.SS.Formula.Functions;
using NPOI.SS.Formula.PTG;
@ -202,6 +203,18 @@ namespace Myshipping.Application
};
await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo);
#region 写入运行日志
var runLog = serviceWorkFlowRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = serviceWorkFlowRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_PROJECT.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Insert";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
}
else if (tsk.OperType == "Update")
{
@ -216,6 +229,18 @@ namespace Myshipping.Application
it.ACT_DATE,
it.IS_YIELD,
}).ExecuteCommandAsync();
#region 写入运行日志
var runLog = runInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = runInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_PROJECT.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Update";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
}
});
@ -326,6 +351,18 @@ namespace Myshipping.Application
//写入run主表
await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo);
#region 写入运行日志
var runLog = serviceWorkFlowRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = serviceWorkFlowRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Insert";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
//获取状态最大数
int endNum = rt.StatusList.Max(sku => sku.ActSortNo);
@ -388,6 +425,19 @@ namespace Myshipping.Application
//写入run活动表
await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesRunInfo);
#region 写入运行日志
var runLog = activitiesRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = activitiesRunInfo.RUN_ID;
runLog.RUN_DETAIL_ID = activitiesRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Insert";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
if (sku.SubStatusList != null && sku.SubStatusList.Count > 0)
{
string lastSubActId = string.Empty;
@ -451,6 +501,19 @@ namespace Myshipping.Application
await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesSubRunInfo);
#region 写入运行日志
var runLog = activitiesSubRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = activitiesSubRunInfo.RUN_ID;
runLog.RUN_DETAIL_ID = activitiesSubRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Insert";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
lastSubActId = activitiesSubRunInfo.PK_ID;
});
@ -484,6 +547,18 @@ namespace Myshipping.Application
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
#region 写入运行日志
var runLog = runEntity.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = runEntity.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Update";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
}
//批量写入活动表
@ -550,6 +625,19 @@ namespace Myshipping.Application
//写入run活动表
await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesRunInfo);
#region 写入运行日志
var runLog = activitiesRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = activitiesRunInfo.RUN_ID;
runLog.RUN_DETAIL_ID = activitiesRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Insert";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
if (sku.SubStatusList != null && sku.SubStatusList.Count > 0)
{
string lastSubActId = string.Empty;
@ -614,6 +702,19 @@ namespace Myshipping.Application
await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesSubRunInfo);
#region 写入运行日志
var runLog = activitiesSubRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = activitiesSubRunInfo.RUN_ID;
runLog.RUN_DETAIL_ID = activitiesSubRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Insert";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
lastSubActId = activitiesSubRunInfo.PK_ID;
});
@ -644,6 +745,18 @@ namespace Myshipping.Application
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
#region 写入运行日志
var runLog = runEntity.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = runEntity.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Update";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
}
//只需要更新完成标记和完成时间
rt.StatusList.ForEach(async sku =>
@ -694,6 +807,19 @@ namespace Myshipping.Application
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
#region 写入运行日志
var runLog = activitiesRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = activitiesRunInfo.RUN_ID;
runLog.RUN_DETAIL_ID = activitiesRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Update";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
}
if (sku.SubStatusList != null && sku.SubStatusList.Count > 0)
@ -747,6 +873,19 @@ namespace Myshipping.Application
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
#region 写入运行日志
var runLog = activitiesSubRunInfo.Adapt<ServiceWorkFlowRunLogInfo>();
runLog.PK_ID = IDGen.NextID().ToString();
runLog.RUN_ID = activitiesSubRunInfo.RUN_ID;
runLog.RUN_DETAIL_ID = activitiesSubRunInfo.PK_ID;
runLog.BATCH_NO = batchNo;
runLog.OPER_TYPE = TrackingRunOperTypeEnum.PUSH_STATUS.ToString();
runLog.EXEC_RESULT = "SUCC";
runLog.EXEC_NOTE = "Update";
await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog);
#endregion
}
});
}
@ -1533,6 +1672,7 @@ namespace Myshipping.Application
int lastWFSortNo = 0;
int calcNum = 1;
var resultList = statuList.Join(runList, l => l.WFPKId, r => r.WFPKId,
(l, r) => {
@ -1610,6 +1750,11 @@ namespace Myshipping.Application
}
}
if (rltList != null && rltList.Count > 0)
{
var maxSort = rltList.Max(t => t.CalcSortNo);
rltList.FirstOrDefault(t => t.CalcSortNo == maxSort).IsEnd = true;
}
return rltList;
}).SelectMany(b => b).OrderBy(b => b.WFSortNo).Select(b => {
if(lastWFSortNo == 0)

Loading…
Cancel
Save