cjy 3 months ago
commit 0ba3af5fac

@ -106,6 +106,16 @@ namespace DS.WMS.Core.TaskPlat.Dtos
/// </summary>
public bool IsAllotCustomerService { get; set; }
/// <summary>
/// 分配至指定角色的角色Id列表
/// </summary>
public string? RoleIds { get; set; }
/// <summary>
/// 匹配条件
/// </summary>
public string? Condition { get; set; }
///// <summary>
///// 是否分配至报关员
///// </summary>

@ -63,25 +63,35 @@ namespace DS.WMS.Core.TaskPlat.Entity
[SugarColumn(ColumnDescription = "是否分配至客服", IsNullable = false)]
public bool IsAllotCustomerService { get; set; }
/// <summary>
/// 分配至指定角色的角色Id列表
/// </summary>
[SugarColumn(ColumnDescription = "分配至指定角色的角色Id列表", IsNullable = true, Length = 4000)]
public string? RoleIds { get; set; }
/// <summary>
/// 匹配条件
/// </summary>
[SugarColumn(ColumnDescription = "匹配条件", IsNullable = true, Length = 4000)]
public string? Condition { get; set; }
///// <summary>
///// 是否分配至报关员
///// </summary>
//[SugarColumn(ColumnDescription = "是否分配至报关员", IsNullable = false)]
//public bool IsAllotCustom { get; set; }
///// <summary>
///// 是否分配至财务
///// </summary>
//[SugarColumn(ColumnDescription = "是否分配至财务", IsNullable = false)]
//public bool IsAllotFinancialStaff { get; set; }
///// <summary>
///// 是否分配至司机
///// </summary>
//[SugarColumn(ColumnDescription = "是否分配至司机", IsNullable = false)]
//public bool IsAllotDriver { get; set; }
///// <summary>
///// 是否分配至派车调度人员
///// </summary>

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity;
@ -26,5 +27,14 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <param name="isFromCache">是否从缓存提取 true-从缓存读取 false-从数据库读取</param>
/// <returns>返回任务分配数据列表</returns>
Task<DataResult<List<TaskAllocationtSetDto>>> GetAllList(bool isFromCache = true);
/// <summary>
/// 根据任务类型+海运出口订单Id查询任务分配的人员列表
/// </summary>
/// <param name="taskType">任务类型</param>
/// <param name="seaExportId">海运出口订单Id</param>
/// <param name="dataContext">数据上下文(规则匹配时用到的数据来源)</param>
/// <returns>任务接收人列表</returns>
Task<DataResult<List<RecvUserInfo>>> GetAllotUserBySeaExportId(TaskBaseTypeEnum taskType, long seaExportId, TaskFlowDataContext? dataContext = null);
}
}

@ -1,15 +1,21 @@
using DS.Module.Core;
using DS.Module.Core.Condition;
using DS.Module.Core.Data;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Interface;
using DS.WMS.Core.Sys.Method;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity;
using DS.WMS.Core.TaskPlat.Interface;
using LanguageExt.Common;
using LanguageExt.Pipes;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SqlSugar;
using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.TaskPlat.Method
@ -116,7 +122,7 @@ namespace DS.WMS.Core.TaskPlat.Method
//"FinancialStaff" => nameof(TaskAllocationtSet.IsAllotFinancialStaff),
//"Driver" => nameof(TaskAllocationtSet.IsAllotDriver),
//"Dispatcher" => nameof(TaskAllocationtSet.IsAllotDispatcher),
_ => throw new NotImplementedException(),
};
@ -217,5 +223,116 @@ namespace DS.WMS.Core.TaskPlat.Method
return DataResult<List<TaskAllocationtSetDto>>.FailedData(list);
}
/// <summary>
/// 根据任务类型+海运出口订单Id查询任务分配的人员列表
/// </summary>
/// <param name="taskType">任务类型</param>
/// <param name="seaExportId">海运出口订单Id</param>
/// <param name="dataContext">数据上下文(规则匹配时用到的数据来源)</param>
/// <returns>任务接收人列表</returns>
public async Task<DataResult<List<RecvUserInfo>>> GetAllotUserBySeaExportId(TaskBaseTypeEnum taskType, long seaExportId, TaskFlowDataContext? dataContext = null)
{
var allotSetList = await GetAllList();
if (!allotSetList.Succeeded || allotSetList.Data?.Any() != true)
{
return DataResult<List<RecvUserInfo>>.Success($"未查询到任一类型的任务分配规则", [], MultiLanguageConst.DataQueryNoData);
}
var allotList = allotSetList.Data.Where(x => x.TaskTypeCode == taskType.ToString()).OrderBy(x => x.Id).ToList();
if (allotList.Count == 0)
{
return DataResult<List<RecvUserInfo>>.Success($"对于{taskType}任务未配置任务分配规则", [], MultiLanguageConst.DataQueryNoData);
}
// 匹配分配规则
List<TaskAllocationtSetDto> allotTargetList = new();
foreach (var item in allotList)
{
if (string.IsNullOrEmpty(item.Condition) || dataContext == null)
{
allotTargetList.Add(item);
}
else
{
var contitionContent = JsonConvert.DeserializeObject<ContitionContent>(item.Condition)!;
if (ConditionHelper.IsPass(contitionContent, dataContext))
{
allotTargetList.Add(item);
}
}
}
allotTargetList = allotTargetList.DistinctBy(x => x.Id).ToList();
if (allotTargetList.Count == 0)
{
return DataResult<List<RecvUserInfo>>.Success($"对于{taskType}任务未匹配到任务分配规则", [], MultiLanguageConst.DataQueryNoData);
}
// 查出涉及到的订单
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
var order = await tenantDb.Queryable<SeaExport>()
.Where(x => x.Id == seaExportId)
.Select(x => new
{
x.Id,
x.MBLNO,
x.OperatorId,
x.OperatorName,
x.Doc,
x.DocName,
x.SaleId,
x.Sale,
x.CustomerService,
x.CustomerServiceName,
x.ForeignCustomerService,
x.ForeignCustomerServiceName
}).FirstAsync();
if (order == null)
{
return DataResult<List<RecvUserInfo>>.Success($"根据海运出口订单Id{seaExportId}未查询到海运出口订单", [], MultiLanguageConst.DataQueryNoData);
}
List<RecvUserInfo> result = new();
foreach (TaskAllocationtSetDto item in allotTargetList)
{
// 根据分配规则+订单,生成人员列表作为结果
if (item.IsAllotCustomerService)
{
if (order.CustomerService != 0 && !string.IsNullOrEmpty(order.CustomerServiceName))
{
result.Add(new RecvUserInfo(order.CustomerService, order.CustomerServiceName));
}
if (order.ForeignCustomerService != 0 && !string.IsNullOrEmpty(order.ForeignCustomerServiceName))
{
result.Add(new RecvUserInfo(order.ForeignCustomerService, order.ForeignCustomerServiceName));
}
}
if (item.IsAllotOperator
&& order.OperatorId != 0 && !string.IsNullOrEmpty(order.OperatorName))
{
result.Add(new RecvUserInfo(order.OperatorId, order.OperatorName));
}
if (item.IsAllotSale
&& order.SaleId != 0 && !string.IsNullOrEmpty(order.Sale))
{
result.Add(new RecvUserInfo(order.SaleId, order.Sale));
}
if (item.IsAllotVouchingClerk
&& order.Doc != 0 && !string.IsNullOrEmpty(order.DocName))
{
result.Add(new RecvUserInfo(order.Doc, order.DocName));
}
// 后期实现如果设置了角色Id列表则将角色对应的人员列表合并到结果中
}
// 人员列表去重
result = result.DistinctBy(x => x.RecvUserId).ToList();
return DataResult<List<RecvUserInfo>>.Success($"查询成功", result, MultiLanguageConst.OperationSuccess);
}
}
}

Loading…
Cancel
Save