|
|
@ -11,6 +11,7 @@ using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
using DS.WMS.Core.Op.Interface.TaskInteraction;
|
|
|
|
using DS.WMS.Core.Op.Interface.TaskInteraction;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
|
|
|
using DS.WMS.Core.TaskPlat;
|
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
|
|
using DS.WMS.Core.TaskPlat.Interface;
|
|
|
|
using DS.WMS.Core.TaskPlat.Interface;
|
|
|
@ -76,18 +77,23 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取给定任务的下一任务类型
|
|
|
|
/// 获取给定任务的下一任务类型
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="current">任务信息</param>
|
|
|
|
/// <param name="current"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
internal static TaskBaseTypeEnum? GetNextType(BusinessTask current)
|
|
|
|
public async Task<TaskBaseTypeEnum?> GetNextTypeAsync(BusinessTask current)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (current.TaskType == TaskBaseTypeEnum.NOT_SPECIFIED || current.TaskType == TaskBaseTypeEnum.WAIT_CHECKOUT_BILL) //流程的最后一步
|
|
|
|
TaskFlowRuner flowRuner = new TaskFlowRuner(TenantDb, ServiceProvider);
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int currentTypeVal = (int)current.TaskType;
|
|
|
|
var result = await flowRuner.GetWorkFlowNextConfig(new TaskFlowDataContext(
|
|
|
|
if (currentTypeVal >= 300) //300开始的枚举值为可选服务项目,不存在前后关联性
|
|
|
|
|
|
|
|
return null;
|
|
|
|
), current.NextId);
|
|
|
|
|
|
|
|
|
|
|
|
return (TaskBaseTypeEnum)(currentTypeVal + 1);
|
|
|
|
if (result.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
current.NextId = result.Value.configId;
|
|
|
|
|
|
|
|
return result.Value.taskType;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -252,8 +258,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
if (task != null && task.TaskStatus != TaskStatusEnum.Cancel)
|
|
|
|
if (task != null && task.TaskStatus != TaskStatusEnum.Cancel)
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
|
|
|
|
|
|
|
|
|
|
|
|
//if (await ShouldSkipAsync(request))
|
|
|
|
if (await ShouldSkipAsync(request))
|
|
|
|
// return DataResult.Success;
|
|
|
|
return DataResult.Success;
|
|
|
|
|
|
|
|
|
|
|
|
long tenatId = long.Parse(User.TenantId);
|
|
|
|
long tenatId = long.Parse(User.TenantId);
|
|
|
|
string tenatName = Db.Queryable<SysTenant>().Where(x => x.Id == tenatId).Select(x => x.Name).First();
|
|
|
|
string tenatName = Db.Queryable<SysTenant>().Where(x => x.Id == tenatId).Select(x => x.Name).First();
|
|
|
@ -289,12 +295,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
if (request.RecvUserIdList == null || request.RecvUserIdList.Length == 0)
|
|
|
|
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 (info.Main.RecvUserInfoList == null || info.Main.RecvUserInfoList.Count == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
if (AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsers(long.Parse(User.UserId));
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(long.Parse(User.UserId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -304,7 +310,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsers(request.RecvUserIdList);
|
|
|
|
info.Main.RecvUserInfoList = await GetRecvUsersAsync(request.RecvUserIdList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (info.Main.TaskTitle.IsNullOrEmpty())
|
|
|
|
if (info.Main.TaskTitle.IsNullOrEmpty())
|
|
|
@ -341,7 +347,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
CreateBy = long.Parse(User.UserId),
|
|
|
|
CreateBy = long.Parse(User.UserId),
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
};
|
|
|
|
};
|
|
|
|
task.NextType = GetNextType(task);
|
|
|
|
task.NextType = await GetNextTypeAsync(task);
|
|
|
|
await TenantDb.Insertable(task).ExecuteCommandAsync();
|
|
|
|
await TenantDb.Insertable(task).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
//审核任务需创建工作流
|
|
|
|
//审核任务需创建工作流
|
|
|
@ -374,53 +380,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)
|
|
|
|
var configList = await TenantDb.Queryable<BusinessTaskConfig>().Where(x => x.TaskType == request.TaskType && x.IsSkip)
|
|
|
|
.Select(x => new { x.Id, x.SourceName, x.MatchCondition }).ToListAsync();
|
|
|
|
.Select(x => new { x.Id, x.SourceName, x.MatchCondition }).ToListAsync();
|
|
|
|
if (configList.Count > 0)
|
|
|
|
if (configList.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject<ContitionContent>(x.MatchCondition) }).ToList();
|
|
|
|
var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject<ConditionContent>(x.MatchCondition) }).ToList();
|
|
|
|
HashSet<string> fields = [];
|
|
|
|
|
|
|
|
foreach (var item in conditionList)
|
|
|
|
foreach (var item in conditionList)
|
|
|
|
{
|
|
|
|
item.MatchCondition.SourceName = item.SourceName;
|
|
|
|
if (item.MatchCondition.Conditions != null)
|
|
|
|
|
|
|
|
fields.AddRange(item.MatchCondition.Conditions.Select(x => x.Field));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item.MatchCondition.Groups != null)
|
|
|
|
return await ActionService.Value.IsMatchAsync(request, conditionList.Select(x => x.MatchCondition));
|
|
|
|
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 false;
|
|
|
|
return false;
|
|
|
@ -459,7 +429,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string[] ids = FlowInstanceService.GetMarkers(instance);
|
|
|
|
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);
|
|
|
|
result = await ManagerService.TransferTask(task.BusinessId, task.TaskType, users);
|
|
|
|
if (result.Succeeded)
|
|
|
|
if (result.Succeeded)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -546,8 +516,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
if (useTransaction)
|
|
|
|
if (useTransaction)
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
|
|
//ActionService.Value.TriggerAction(task);
|
|
|
|
ActionService.Value.TriggerAction(task);
|
|
|
|
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? GetNextType(task) : null);
|
|
|
|
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -580,7 +550,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
ArgumentNullException.ThrowIfNull(callback, nameof(callback));
|
|
|
|
ArgumentNullException.ThrowIfNull(callback, nameof(callback));
|
|
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
var users = await GetRecvUsers(userId);
|
|
|
|
var users = await GetRecvUsersAsync(userId);
|
|
|
|
var dt = DateTime.Now;
|
|
|
|
var dt = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
var taskType = TypeMappings.Where(x => x.Value == callback.Type.GetValueOrDefault()).Select(x => x.Key).FirstOrDefault();
|
|
|
|
var taskType = TypeMappings.Where(x => x.Value == callback.Type.GetValueOrDefault()).Select(x => x.Key).FirstOrDefault();
|
|
|
@ -630,7 +600,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
await SetTaskStatusAsync(req);
|
|
|
|
await SetTaskStatusAsync(req);
|
|
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
var users = await GetRecvUsers(userId);
|
|
|
|
var users = await GetRecvUsersAsync(userId);
|
|
|
|
string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription();
|
|
|
|
string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription();
|
|
|
|
|
|
|
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
@ -685,10 +655,29 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <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 biz = ActionService.Value.GetBusinessDataAsync(id, businessType);
|
|
|
|
var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskType, id, new TaskFlowDataContext(
|
|
|
|
var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskTypes, id, new TaskFlowDataContext(
|
|
|
|
(TaskFlowDataNameConst.Business, biz)
|
|
|
|
(TaskFlowDataNameConst.Business, biz)
|
|
|
|
));
|
|
|
|
));
|
|
|
|
return result.Succeeded ? result.Data : [];
|
|
|
|
return result.Succeeded ? result.Data : [];
|
|
|
@ -699,7 +688,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ids">用户ID</param>
|
|
|
|
/// <param name="ids">用户ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <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(
|
|
|
|
return await Db.Queryable<SysUser>().Where(x => ids.Contains(x.Id)).Select(
|
|
|
|
x => new RecvUserInfo { RecvUserId = x.Id, RecvUserName = x.UserName }).ToListAsync();
|
|
|
|
x => new RecvUserInfo { RecvUserId = x.Id, RecvUserName = x.UserName }).ToListAsync();
|
|
|
|