|
|
|
@ -3,19 +3,16 @@ 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
|
|
|
|
@ -195,15 +192,16 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
bool isLoad = false;
|
|
|
|
|
|
|
|
|
|
if (isFromCache)
|
|
|
|
|
{
|
|
|
|
|
var rlt = await sysCacheService.GetAllCommonCodeFromCache<TaskAllocationtSetDto>(SysCacheCategoryEnum.TaskAllocationtSet, "DS8");
|
|
|
|
|
// 因为设置界面还没有实现,所以先注释掉,防止改库后数据不变
|
|
|
|
|
//if (isFromCache)
|
|
|
|
|
//{
|
|
|
|
|
// var rlt = await sysCacheService.GetAllCommonCodeFromCache<TaskAllocationtSetDto>(SysCacheCategoryEnum.TaskAllocationtSet, "DS8");
|
|
|
|
|
|
|
|
|
|
if (rlt.Succeeded)
|
|
|
|
|
return rlt;
|
|
|
|
|
// if (rlt.Succeeded)
|
|
|
|
|
// return rlt;
|
|
|
|
|
|
|
|
|
|
isLoad = true;
|
|
|
|
|
}
|
|
|
|
|
// isLoad = true;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
@ -225,7 +223,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据任务类型+海运出口订单Id查询任务分配的人员列表
|
|
|
|
|
/// (单个任务类型)根据任务类型+海运出口订单Id查询任务分配的人员列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
|
/// <param name="seaExportId">海运出口订单Id</param>
|
|
|
|
@ -271,24 +269,33 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查出涉及到的订单
|
|
|
|
|
SeaExport? order = null;
|
|
|
|
|
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 (dataContext.ContainsKey(TaskFlowDataNameConst.Business))
|
|
|
|
|
{
|
|
|
|
|
order = dataContext.Get<SeaExport>(TaskFlowDataNameConst.Business);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
order = await tenantDb.Queryable<SeaExport>()
|
|
|
|
|
.Where(x => x.Id == seaExportId)
|
|
|
|
|
.Select(x => new SeaExport
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
MBLNO = x.MBLNO,
|
|
|
|
|
OperatorId = x.OperatorId,
|
|
|
|
|
OperatorName = x.OperatorName,
|
|
|
|
|
Doc = x.Doc,
|
|
|
|
|
DocName = x.DocName,
|
|
|
|
|
SaleId = x.SaleId,
|
|
|
|
|
Sale = x.Sale,
|
|
|
|
|
CustomerService = x.CustomerService,
|
|
|
|
|
CustomerServiceName = x.CustomerServiceName,
|
|
|
|
|
ForeignCustomerService = x.ForeignCustomerService,
|
|
|
|
|
ForeignCustomerServiceName = x.ForeignCustomerServiceName
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<List<RecvUserInfo>>.Success($"根据海运出口订单Id{seaExportId}未查询到海运出口订单", [], MultiLanguageConst.DataQueryNoData);
|
|
|
|
@ -334,5 +341,139 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
return DataResult<List<RecvUserInfo>>.Success($"查询成功", result, MultiLanguageConst.OperationSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// (多个任务类型)根据任务类型列表+海运出口订单Id查询任务分配的人员列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskTypeList">任务类型列表</param>
|
|
|
|
|
/// <param name="seaExportId">海运出口订单Id</param>
|
|
|
|
|
/// <param name="dataContext">数据上下文(规则匹配时用到的数据来源)</param>
|
|
|
|
|
/// <returns>指定任务类型对应的任务接收人列表</returns>
|
|
|
|
|
public async Task<DataResult<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>>> GetAllotUserBySeaExportId(List<TaskBaseTypeEnum> taskTypeList, long seaExportId, TaskFlowDataContext? dataContext = null)
|
|
|
|
|
{
|
|
|
|
|
var allotSetList = await GetAllList();
|
|
|
|
|
|
|
|
|
|
if (!allotSetList.Succeeded || allotSetList.Data?.Any() != true)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>>.Success($"未查询到任一类型的任务分配规则", [], MultiLanguageConst.DataQueryNoData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (taskTypeList == null || taskTypeList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>>.Success($"任务列表为空", [], MultiLanguageConst.DataQueryNoData);
|
|
|
|
|
}
|
|
|
|
|
taskTypeList = taskTypeList.Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
var taskTypeStrList = taskTypeList.Select(x => x.ToString());
|
|
|
|
|
var allotList = allotSetList.Data.Where(x => taskTypeStrList.Contains(x.TaskTypeCode)).OrderBy(x => x.Id).ToList();
|
|
|
|
|
if (allotList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>>.Success($"对于任务列表:{string.Join(',', taskTypeStrList)}未配置任务分配规则", [], MultiLanguageConst.DataQueryNoData);
|
|
|
|
|
}
|
|
|
|
|
var groupAllotList = allotList.GroupBy(x => x.TaskTypeCode);
|
|
|
|
|
|
|
|
|
|
// 匹配分配规则
|
|
|
|
|
Dictionary<TaskBaseTypeEnum, List<TaskAllocationtSetDto>> allotTargetList = new();
|
|
|
|
|
foreach (var groupAllotItem in groupAllotList)
|
|
|
|
|
{
|
|
|
|
|
var itemResult = new List<TaskAllocationtSetDto>();
|
|
|
|
|
foreach (var allotItem in groupAllotItem)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(allotItem.Condition) || dataContext == null)
|
|
|
|
|
{
|
|
|
|
|
itemResult.Add(allotItem);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var contitionContent = JsonConvert.DeserializeObject<ContitionContent>(allotItem.Condition)!;
|
|
|
|
|
if (ConditionHelper.IsPass(contitionContent, dataContext))
|
|
|
|
|
{
|
|
|
|
|
itemResult.Add(allotItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (itemResult.Count != 0 && Enum.TryParse(typeof(TaskBaseTypeEnum), groupAllotItem.Key, out object? type))
|
|
|
|
|
{
|
|
|
|
|
allotTargetList.Add((TaskBaseTypeEnum)type, itemResult); // 因为前面做了去重,所以这里可以直接用Add
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查出涉及到的订单
|
|
|
|
|
SeaExport? order = null;
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
if (dataContext.ContainsKey(TaskFlowDataNameConst.Business))
|
|
|
|
|
{
|
|
|
|
|
order = dataContext.Get<SeaExport>(TaskFlowDataNameConst.Business);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
order = await tenantDb.Queryable<SeaExport>()
|
|
|
|
|
.Where(x => x.Id == seaExportId)
|
|
|
|
|
.Select(x => new SeaExport
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
MBLNO = x.MBLNO,
|
|
|
|
|
OperatorId = x.OperatorId,
|
|
|
|
|
OperatorName = x.OperatorName,
|
|
|
|
|
Doc = x.Doc,
|
|
|
|
|
DocName = x.DocName,
|
|
|
|
|
SaleId = x.SaleId,
|
|
|
|
|
Sale = x.Sale,
|
|
|
|
|
CustomerService = x.CustomerService,
|
|
|
|
|
CustomerServiceName = x.CustomerServiceName,
|
|
|
|
|
ForeignCustomerService = x.ForeignCustomerService,
|
|
|
|
|
ForeignCustomerServiceName = x.ForeignCustomerServiceName
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>>.Success($"根据海运出口订单Id{seaExportId}未查询到海运出口订单", [], MultiLanguageConst.DataQueryNoData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = new Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>();
|
|
|
|
|
foreach (var targetList in allotTargetList)
|
|
|
|
|
{
|
|
|
|
|
var userList = new List<RecvUserInfo>();
|
|
|
|
|
foreach (var setItem in targetList.Value)
|
|
|
|
|
{
|
|
|
|
|
// 根据分配规则+订单,生成人员列表作为结果
|
|
|
|
|
if (setItem.IsAllotCustomerService)
|
|
|
|
|
{
|
|
|
|
|
if (order.CustomerService != 0 && !string.IsNullOrEmpty(order.CustomerServiceName))
|
|
|
|
|
{
|
|
|
|
|
userList.Add(new RecvUserInfo(order.CustomerService, order.CustomerServiceName));
|
|
|
|
|
}
|
|
|
|
|
if (order.ForeignCustomerService != 0 && !string.IsNullOrEmpty(order.ForeignCustomerServiceName))
|
|
|
|
|
{
|
|
|
|
|
userList.Add(new RecvUserInfo(order.ForeignCustomerService, order.ForeignCustomerServiceName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (setItem.IsAllotOperator
|
|
|
|
|
&& order.OperatorId != 0 && !string.IsNullOrEmpty(order.OperatorName))
|
|
|
|
|
{
|
|
|
|
|
userList.Add(new RecvUserInfo(order.OperatorId, order.OperatorName));
|
|
|
|
|
}
|
|
|
|
|
if (setItem.IsAllotSale
|
|
|
|
|
&& order.SaleId != 0 && !string.IsNullOrEmpty(order.Sale))
|
|
|
|
|
{
|
|
|
|
|
userList.Add(new RecvUserInfo(order.SaleId, order.Sale));
|
|
|
|
|
}
|
|
|
|
|
if (setItem.IsAllotVouchingClerk
|
|
|
|
|
&& order.Doc != 0 && !string.IsNullOrEmpty(order.DocName))
|
|
|
|
|
{
|
|
|
|
|
userList.Add(new RecvUserInfo(order.Doc, order.DocName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// (后期实现)如果设置了角色Id列表,则将角色对应的人员列表合并到结果中
|
|
|
|
|
}
|
|
|
|
|
if (userList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
result.Add(targetList.Key, userList.DistinctBy(x => x.RecvUserId).ToList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<Dictionary<TaskBaseTypeEnum, List<RecvUserInfo>>>.Success($"查询成功", result, MultiLanguageConst.OperationSuccess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|