|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Condition;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
@ -18,7 +17,6 @@ using DS.WMS.Core.TaskPlat.Interface;
|
|
|
|
|
using Masuit.Tools;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
@ -74,6 +72,23 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
ActionService = new Lazy<IActionManagerService>(provider.GetRequiredService<IActionManagerService>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取给定任务的下一默认任务类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="current">任务信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal static async Task<TaskBaseTypeEnum?> GetDefaultNextTypeAsync(BusinessTask current)
|
|
|
|
|
{
|
|
|
|
|
if (current.TaskType == TaskBaseTypeEnum.NOT_SPECIFIED || current.TaskType == TaskBaseTypeEnum.WAIT_CHECKOUT_BILL) //流程的最后一步
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
int currentTypeVal = (int)current.TaskType;
|
|
|
|
|
if (currentTypeVal >= 300) //300开始的枚举值为可选服务项目,不存在前后关联性
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return (TaskBaseTypeEnum)(currentTypeVal + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取给定任务的下一任务类型
|
|
|
|
|
/// </summary>
|
|
|
|
@ -83,8 +98,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
{
|
|
|
|
|
TaskFlowRuner flowRuner = new TaskFlowRuner(TenantDb, ServiceProvider);
|
|
|
|
|
|
|
|
|
|
var result = await flowRuner.GetWorkFlowNextConfig(new TaskFlowDataContext(
|
|
|
|
|
|
|
|
|
|
var result = await flowRuner.GetWorkFlowNextConfig(TaskBaseTypeEnum.WORK_FLOW_MAIN, new TaskFlowDataContext(
|
|
|
|
|
|
|
|
|
|
), current.NextId);
|
|
|
|
|
|
|
|
|
|
if (result.HasValue)
|
|
|
|
@ -202,6 +217,53 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskStatusNotSupported));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 撤销审核任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(TaskRequest request)
|
|
|
|
|
{
|
|
|
|
|
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
|
|
|
|
|
if (task == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//同时删除工作流
|
|
|
|
|
if (task.FlowId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
//long userId = long.Parse(User.UserId);
|
|
|
|
|
//await Db.Updateable(new FlowInstance
|
|
|
|
|
//{
|
|
|
|
|
// Id = task.FlowId.Value,
|
|
|
|
|
// DeleteBy = long.Parse(User.UserId),
|
|
|
|
|
// DeleteTime = DateTime.Now,
|
|
|
|
|
// Deleted = true
|
|
|
|
|
//}).UpdateColumns(x => new { x.DeleteBy, x.DeleteTime, x.Deleted }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await Db.Deleteable<FlowInstance>().Where(x => x.Id == task.FlowId.Value).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Deleteable<BusinessTask>().Where(x => x.BusinessId == request.BusinessId && x.BusinessType == request.BusinessType && x.TaskType == request.TaskType)
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
//记录日志
|
|
|
|
|
await LogService.WriteLogAsync(task, "撤销审核");
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务审核
|
|
|
|
|
/// </summary>
|
|
|
|
@ -258,8 +320,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (task != null && task.TaskStatus != TaskStatusEnum.Cancel)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
|
|
|
|
|
|
|
|
|
|
if (await ShouldSkipAsync(request))
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
//if (await ShouldSkipAsync(request))
|
|
|
|
|
// return DataResult.Success;
|
|
|
|
|
|
|
|
|
|
long tenatId = long.Parse(User.TenantId);
|
|
|
|
|
string tenatName = Db.Queryable<SysTenant>().Where(x => x.Id == tenatId).Select(x => x.Name).First();
|
|
|
|
@ -299,13 +361,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (info.Main.RecvUserInfoList == null || info.Main.RecvUserInfoList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
if (AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(long.Parse(User.UserId));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskReceiverNotFound));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -313,6 +369,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(request.RecvUserIdList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info.Main.RecvUserInfoList == null || info.Main.RecvUserInfoList.Count == 0)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskReceiverNotFound));
|
|
|
|
|
|
|
|
|
|
if (info.Main.TaskTitle.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var biz = await TenantDb.Queryable<SeaExport>().Select(x => new
|
|
|
|
@ -347,7 +406,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
CreateBy = long.Parse(User.UserId),
|
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
task.NextType = await GetNextTypeAsync(task);
|
|
|
|
|
task.NextType = await GetDefaultNextTypeAsync(task);
|
|
|
|
|
await TenantDb.Insertable(task).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
//审核任务需创建工作流
|
|
|
|
@ -380,21 +439,21 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal async Task<bool> ShouldSkipAsync(TaskRequest request)
|
|
|
|
|
{
|
|
|
|
|
var configList = await TenantDb.Queryable<BusinessTaskConfig>().Where(x => x.TaskType == request.TaskType && x.IsSkip)
|
|
|
|
|
.Select(x => new { x.Id, x.SourceName, x.MatchCondition }).ToListAsync();
|
|
|
|
|
if (configList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject<ConditionContent>(x.MatchCondition) }).ToList();
|
|
|
|
|
foreach (var item in conditionList)
|
|
|
|
|
item.MatchCondition.SourceName = item.SourceName;
|
|
|
|
|
//internal async Task<bool> ShouldSkipAsync(TaskRequest request)
|
|
|
|
|
//{
|
|
|
|
|
// var configList = await TenantDb.Queryable<BusinessTaskConfig>().Where(x => x.TaskType == request.TaskType && x.IsSkip)
|
|
|
|
|
// .Select(x => new { x.Id, x.SourceName, x.MatchCondition }).ToListAsync();
|
|
|
|
|
// if (configList.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject<ConditionContent>(x.MatchCondition) }).ToList();
|
|
|
|
|
// foreach (var item in conditionList)
|
|
|
|
|
// item.MatchCondition.SourceName = item.SourceName;
|
|
|
|
|
|
|
|
|
|
return await ActionService.Value.IsMatchAsync(request, conditionList.Select(x => x.MatchCondition));
|
|
|
|
|
}
|
|
|
|
|
// return await ActionService.Value.IsMatchAsync(request, conditionList.Select(x => x.MatchCondition));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// return false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建并启动审批工作流
|
|
|
|
@ -516,8 +575,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
ActionService.Value.TriggerAction(task);
|
|
|
|
|
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null);
|
|
|
|
|
//ActionService.Value.TriggerAction(task);
|
|
|
|
|
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetDefaultNextTypeAsync(task) : null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -676,7 +735,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>> GetRecvUsersAsync(long id, BusinessType businessType, List<TaskBaseTypeEnum> taskTypes)
|
|
|
|
|
{
|
|
|
|
|
var biz = ActionService.Value.GetBusinessDataAsync(id, businessType);
|
|
|
|
|
var biz = await ActionService.Value.GetBusinessDataAsync(id, businessType);
|
|
|
|
|
var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskTypes, id, new TaskFlowDataContext(
|
|
|
|
|
(TaskFlowDataNameConst.Business, biz)
|
|
|
|
|
));
|
|
|
|
|