|
|
|
@ -74,11 +74,11 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取给定任务的下一任务类型
|
|
|
|
|
/// 获取给定任务的下一默认任务类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="current">任务信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal static TaskBaseTypeEnum? GetNextType(BusinessTask current)
|
|
|
|
|
internal static TaskBaseTypeEnum? GetDefaultNextType(BusinessTask current)
|
|
|
|
|
{
|
|
|
|
|
if (current.TaskType == TaskBaseTypeEnum.NOT_SPECIFIED || current.TaskType == TaskBaseTypeEnum.WAIT_CHECKOUT_BILL) //流程的最后一步
|
|
|
|
|
return null;
|
|
|
|
@ -252,8 +252,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();
|
|
|
|
@ -289,12 +289,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (request.RecvUserIdList == null || request.RecvUserIdList.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
//根据配置获取默认接收人
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersFromConfig(request.BusinessId, request.BusinessType, request.TaskType);
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(request.BusinessId, request.BusinessType, request.TaskType);
|
|
|
|
|
if (info.Main.RecvUserInfoList == null || info.Main.RecvUserInfoList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
if (AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsers(long.Parse(User.UserId));
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(long.Parse(User.UserId));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -304,7 +304,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsers(request.RecvUserIdList);
|
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(request.RecvUserIdList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info.Main.TaskTitle.IsNullOrEmpty())
|
|
|
|
@ -341,7 +341,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
CreateBy = long.Parse(User.UserId),
|
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
task.NextType = GetNextType(task);
|
|
|
|
|
task.NextType = GetDefaultNextType(task);
|
|
|
|
|
await TenantDb.Insertable(task).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
//审核任务需创建工作流
|
|
|
|
@ -374,53 +374,17 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal async Task<bool> ShouldSkipAsync(TaskRequest request)
|
|
|
|
|
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<ContitionContent>(x.MatchCondition) }).ToList();
|
|
|
|
|
HashSet<string> fields = [];
|
|
|
|
|
var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject<ConditionContent>(x.MatchCondition) }).ToList();
|
|
|
|
|
foreach (var item in conditionList)
|
|
|
|
|
{
|
|
|
|
|
if (item.MatchCondition.Conditions != null)
|
|
|
|
|
fields.AddRange(item.MatchCondition.Conditions.Select(x => x.Field));
|
|
|
|
|
item.MatchCondition.SourceName = item.SourceName;
|
|
|
|
|
|
|
|
|
|
if (item.MatchCondition.Groups != null)
|
|
|
|
|
fields.AddRange(item.MatchCondition.Groups.SelectMany(x => x.Conditions.Select(x => x.Field)));
|
|
|
|
|
}
|
|
|
|
|
var biz = ActionService.Value.GetBusinessData(request.BusinessId, request.BusinessType, fields.ToArray());
|
|
|
|
|
if (biz != null)
|
|
|
|
|
{
|
|
|
|
|
//循环匹配
|
|
|
|
|
foreach (var item in configList)
|
|
|
|
|
{
|
|
|
|
|
var content = conditionList.Find(x => x.Id == item.Id)?.MatchCondition;
|
|
|
|
|
if (content == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
content.SourceName = item.SourceName;
|
|
|
|
|
TaskFlowDataContext dataContext = new(
|
|
|
|
|
(TaskFlowDataNameConst.Business, biz)
|
|
|
|
|
);
|
|
|
|
|
if (ConditionHelper.IsPass(content, 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 = $"符合设定条件({item.Id}),已跳过任务的创建"
|
|
|
|
|
};
|
|
|
|
|
await LogService.WriteLogAsync(logEntity);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return await ActionService.Value.IsMatchAsync(request, conditionList.Select(x => x.MatchCondition));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -459,7 +423,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
{
|
|
|
|
|
string[] ids = FlowInstanceService.GetMarkers(instance);
|
|
|
|
|
//变更任务接收人为所有审批执行人
|
|
|
|
|
var users = await GetRecvUsers(ids.Select(long.Parse).ToArray());
|
|
|
|
|
var users = await GetRecvUsersAsync(ids.Select(long.Parse).ToArray());
|
|
|
|
|
result = await ManagerService.TransferTask(task.BusinessId, task.TaskType, users);
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
{
|
|
|
|
@ -546,8 +510,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 ? GetNextType(task) : null);
|
|
|
|
|
ActionService.Value.TriggerAction(task);
|
|
|
|
|
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? GetDefaultNextType(task) : null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -580,7 +544,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
ArgumentNullException.ThrowIfNull(callback, nameof(callback));
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
|
var users = await GetRecvUsers(userId);
|
|
|
|
|
var users = await GetRecvUsersAsync(userId);
|
|
|
|
|
var dt = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var taskType = TypeMappings.Where(x => x.Value == callback.Type.GetValueOrDefault()).Select(x => x.Key).FirstOrDefault();
|
|
|
|
@ -630,7 +594,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
await SetTaskStatusAsync(req);
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
|
var users = await GetRecvUsers(userId);
|
|
|
|
|
var users = await GetRecvUsersAsync(userId);
|
|
|
|
|
string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription();
|
|
|
|
|
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
@ -685,10 +649,29 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<List<RecvUserInfo>?> GetRecvUsersFromConfig(long id, BusinessType businessType, TaskBaseTypeEnum taskType)
|
|
|
|
|
protected internal async Task<List<RecvUserInfo>> GetRecvUsersAsync(long id, BusinessType businessType, TaskBaseTypeEnum taskType)
|
|
|
|
|
{
|
|
|
|
|
//var biz = ActionService.Value.GetBusinessDataAsync(id, businessType);
|
|
|
|
|
//var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskType, id, new TaskFlowDataContext(
|
|
|
|
|
// (TaskFlowDataNameConst.Business, biz)
|
|
|
|
|
// ));
|
|
|
|
|
//return result.Succeeded ? result.Data : [];
|
|
|
|
|
|
|
|
|
|
var dic = await GetRecvUsersAsync(id, businessType, [taskType]);
|
|
|
|
|
return dic?.Count > 0 ? dic.FirstOrDefault().Value : [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从任务配置中获取接收用户列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="taskTypes">任务类型</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>> GetRecvUsersAsync(long id, BusinessType businessType, List<TaskBaseTypeEnum> taskTypes)
|
|
|
|
|
{
|
|
|
|
|
var biz = ActionService.Value.GetBusinessData(id, businessType);
|
|
|
|
|
var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskType, id, new TaskFlowDataContext(
|
|
|
|
|
var biz = ActionService.Value.GetBusinessDataAsync(id, businessType);
|
|
|
|
|
var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskTypes, id, new TaskFlowDataContext(
|
|
|
|
|
(TaskFlowDataNameConst.Business, biz)
|
|
|
|
|
));
|
|
|
|
|
return result.Succeeded ? result.Data : [];
|
|
|
|
@ -699,7 +682,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">用户ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<List<RecvUserInfo>> GetRecvUsers(params long[] ids)
|
|
|
|
|
protected internal async Task<List<RecvUserInfo>> GetRecvUsersAsync(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
return await Db.Queryable<SysUser>().Where(x => ids.Contains(x.Id)).Select(
|
|
|
|
|
x => new RecvUserInfo { RecvUserId = x.Id, RecvUserName = x.UserName }).ToListAsync();
|
|
|
|
|