|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|