|
|
@ -13,6 +13,7 @@ using Fasterflect;
|
|
|
|
using Masuit.Tools;
|
|
|
|
using Masuit.Tools;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using static AnyDiff.DifferenceLines;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -35,38 +36,38 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 根据指定条件返回是否匹配的结果
|
|
|
|
/// 根据指定条件返回是否匹配的结果
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request">任务请求</param>
|
|
|
|
/// <param name="source">要对比的数据源</param>
|
|
|
|
|
|
|
|
/// <param name="condition">匹配条件</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public bool IsMatch(object source, ConditionContent condition)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(source, nameof(source));
|
|
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(condition, nameof(condition));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, source));
|
|
|
|
|
|
|
|
return ConditionHelper.IsPass(condition, dataContext);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 根据指定条件返回是否匹配的结果
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bsId">业务ID</param>
|
|
|
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="conditions">匹配条件</param>
|
|
|
|
/// <param name="conditions">匹配条件</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<bool> IsMatchAsync(TaskRequest request, IEnumerable<ConditionContent> conditions)
|
|
|
|
public async Task<bool> IsMatchAsync(long bsId, BusinessType businessType, IEnumerable<ConditionContent> conditions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ArgumentNullException.ThrowIfNull(request, nameof(request));
|
|
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(conditions, nameof(conditions));
|
|
|
|
ArgumentNullException.ThrowIfNull(conditions, nameof(conditions));
|
|
|
|
|
|
|
|
|
|
|
|
var biz = await GetBusinessDataAsync(request.BusinessId, request.BusinessType, conditions);
|
|
|
|
var biz = await GetBusinessDataAsync(bsId, businessType, conditions);
|
|
|
|
if (biz != null)
|
|
|
|
if (biz != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskFlowDataContext dataContext = new(
|
|
|
|
TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, biz));
|
|
|
|
(TaskFlowDataNameConst.Business, biz)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
//循环匹配
|
|
|
|
//循环匹配
|
|
|
|
foreach (var item in conditions)
|
|
|
|
foreach (var item in conditions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ConditionHelper.IsPass(item, dataContext))
|
|
|
|
if (ConditionHelper.IsPass(item, dataContext))
|
|
|
|
{
|
|
|
|
|
|
|
|
//var logEntity = new BusinessTaskLog
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// ActionType = ActionType.Create,
|
|
|
|
|
|
|
|
// BusinessId = request.BusinessId,
|
|
|
|
|
|
|
|
// BusinessType = request.BusinessType,
|
|
|
|
|
|
|
|
// TaskType = request.TaskType,
|
|
|
|
|
|
|
|
// CreateBy = long.Parse(User.UserId),
|
|
|
|
|
|
|
|
// CreateTime = DateTime.Now,
|
|
|
|
|
|
|
|
// Remark = $"符合设定条件,已跳过任务的创建"
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
//await LogService.WriteLogAsync(logEntity);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -134,53 +135,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
return biz;
|
|
|
|
return biz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 触发任务执行动作
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="dataContext"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task TriggerActionAsync(TaskFlowDataContext dataContext)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(dataContext, nameof(dataContext));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long businessId = dataContext.GetOrDefault<long>(TaskFlowDataNameConst.BusinessId);
|
|
|
|
|
|
|
|
BusinessType businessType = BusinessType.OceanShippingExport;
|
|
|
|
|
|
|
|
if (dataContext.TryGetValue(nameof(businessType), out object? value) && value != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (value is string strValue)
|
|
|
|
|
|
|
|
businessType = Enum.Parse<BusinessType>(strValue);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
businessType = (BusinessType)Convert.ChangeType(value, typeof(BusinessType));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskBaseTypeEnum taskType = TaskBaseTypeEnum.WAIT_SPACE_RELEASE;
|
|
|
|
|
|
|
|
if (dataContext.TryGetValue(nameof(taskType), out object? value2) && value2 != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (value2 is string strValue)
|
|
|
|
|
|
|
|
taskType = Enum.Parse<TaskBaseTypeEnum>(strValue);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
taskType = (TaskBaseTypeEnum)Convert.ChangeType(value2, typeof(TaskBaseTypeEnum));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TriggerActionAsync(businessId, businessType, taskType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 触发任务执行动作
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="businessId">业务ID</param>
|
|
|
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task TriggerActionAsync(long businessId, BusinessType businessType, TaskBaseTypeEnum taskType)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var businessTask = await TenantDb.Queryable<BusinessTask>().Where(
|
|
|
|
|
|
|
|
x => x.BusinessId == businessId && x.BusinessType == businessType && x.TaskType == taskType).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (businessTask != null)
|
|
|
|
|
|
|
|
await TriggerActionAsync(businessTask);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 执行放舱任务(任务台使用)
|
|
|
|
/// 执行放舱任务(任务台使用)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|