|
|
|
@ -87,30 +87,57 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流设置任务在个人下的状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bsno">业务主键</param>
|
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
|
/// <param name="bsno">主业务主键</param>
|
|
|
|
|
/// <param name="taskBaseTypeEnum">主业务类型</param>
|
|
|
|
|
/// <param name="taskStatusEnum">业务状态</param>
|
|
|
|
|
/// <param name="statusTime">状态发生时间</param>
|
|
|
|
|
/// <param name="userInfos">要设置任务状态的人员列表</param>
|
|
|
|
|
public async Task<DataResult> SetTaskUserStatus(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, List<RecvUserInfo> userInfos)
|
|
|
|
|
/// <param name="childBsno">子业务主键[可选,当不为空时表示设置子任务的个人状态]</param>
|
|
|
|
|
/// <param name="childTaskBaseTypeEnum">子业务类型</param>
|
|
|
|
|
public async Task<DataResult> SetTaskUserStatus(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, List<RecvUserInfo> userInfos,
|
|
|
|
|
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation("接收到任务个人状态修改报文 bsno={bsno} 状态设置={status} 人员列表={userList} childBsno={childBsno} childTaskBaseTypeEnum={childTaskBaseTypeEnum}", bsno, taskStatusEnum.ToString(), JsonConvert.SerializeObject(userInfos), childBsno, childTaskBaseTypeEnum);
|
|
|
|
|
|
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
TaskBaseInfo taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
|
|
var taskId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.FirstAsync(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString());
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.Select(t => new { t.Id })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (taskInfo == null)
|
|
|
|
|
if (taskId == null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到任务");
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskTypeStr}】未查询到任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.LogInformation("接收到任务个人状态修改报文 任务主键={id} 状态设置={status} 人员列表={userList}", taskInfo.Id, taskStatusEnum.ToString(), JsonConvert.SerializeObject(userInfos));
|
|
|
|
|
long waitSetTaskId = taskId.Id;
|
|
|
|
|
|
|
|
|
|
if (childBsno != null)
|
|
|
|
|
{
|
|
|
|
|
var childTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
|
var childTaskId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Where(t => t.CHILD_OUT_BS_NO == childBsno && t.TASK_TYPE == childTypeStr && t.ParentTaskId == taskId.Id)
|
|
|
|
|
.Select(t => new { t.Id })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (childTaskId == null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据childBsno:【{childBsno}】,childTaskBaseTypeEnum:【{childTypeStr}】未查询到任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
waitSetTaskId = childTaskId.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userIdList = userInfos.Select(x => x.RecvUserId).ToList();
|
|
|
|
|
var taskBaseAllocationList = await tenantDb.Queryable<TaskBaseAllocation>()
|
|
|
|
|
.Where(x => x.TaskId == taskInfo.Id && userIdList.Contains(x.UserId))
|
|
|
|
|
.Where(x => x.TaskId == waitSetTaskId && userIdList.Contains(x.UserId))
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
if (taskBaseAllocationList.Any())
|
|
|
|
|
{
|
|
|
|
@ -142,53 +169,103 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
|
/// <param name="taskStatusEnum">业务状态</param>
|
|
|
|
|
/// <param name="statusTime">状态发生时间</param>
|
|
|
|
|
/// <param name="isCheckAllChildTaskComplete">完成任务前是否检查所有子任务是否完成</param>
|
|
|
|
|
/// <param name="taskDesc">任务描述</param>
|
|
|
|
|
/// <param name="userIdList">用户Id列表,用于筛选指定用户下的任务</param>
|
|
|
|
|
public async Task<DataResult> SetTaskStatusWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, string? taskDesc = null, List<long>? userIdList = null)
|
|
|
|
|
/// <param name="userIdList">用户Id列表,用于筛选指定用户下的任务[可选,当不为空时会设置此用户列表涉及到的相关任务的状态]</param>
|
|
|
|
|
/// <param name="childBsno">子业务主键[可选,当不为空时表示设置子任务的状态]</param>
|
|
|
|
|
/// <param name="childTaskBaseTypeEnum">子业务类型</param>
|
|
|
|
|
public async Task<DataResult> SetTaskStatusWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, bool isCheckAllChildTaskComplete, string? taskDesc = null, List<long>? userIdList = null,
|
|
|
|
|
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null)
|
|
|
|
|
{
|
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
if (userIdList == null || userIdList.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
TaskBaseInfo taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.FirstAsync(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString());
|
|
|
|
|
if (taskInfo == null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
return await SetTaskStatus(taskInfo, taskStatusEnum, statusTime, bsno, taskDesc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
|
|
// 表示修改子任务的状态
|
|
|
|
|
if (childBsno != null)
|
|
|
|
|
{
|
|
|
|
|
var taskIdList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString())
|
|
|
|
|
.Select(x => x.Id)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
if (taskIdList.Count() == 0)
|
|
|
|
|
var taskId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Select(t => new { t.Id })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (taskId == null)
|
|
|
|
|
{
|
|
|
|
|
var log = $"设置子任务状态时未查询到父任务(父任务BSNO:{bsno},父任务TaskBaseTypeEnum:{taskBaseTypeEnum}";
|
|
|
|
|
logger.LogInformation(log);
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var waitSetStatusTaskIdList = await tenantDb.Queryable<TaskBaseAllocation>().Where(x => taskIdList.Contains(x.TaskId) && userIdList.Contains(x.UserId)).Select(x => x.TaskId).Distinct().ToListAsync();
|
|
|
|
|
|
|
|
|
|
var taskInfoList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId)).Where(x => waitSetStatusTaskIdList.Contains(x.Id)).ToListAsync();
|
|
|
|
|
var childTaskTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
|
|
var resultList = new List<bool>();
|
|
|
|
|
foreach (var item in taskInfoList)
|
|
|
|
|
var childTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(x => x.IsChild == true
|
|
|
|
|
&& x.TASK_TYPE == childTaskTypeStr
|
|
|
|
|
&& x.CHILD_OUT_BS_NO == childBsno)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (childTask == null)
|
|
|
|
|
{
|
|
|
|
|
var itemResult = await SetTaskStatus(item, taskStatusEnum, statusTime, bsno, taskDesc);
|
|
|
|
|
resultList.Add(itemResult.Succeeded);
|
|
|
|
|
var log = $"设置子任务状态时未查询到子任务(父任务BSNO:{bsno},父任务TaskBaseTypeEnum:{taskBaseTypeEnum},子任务childBsno:{childBsno},子任务childTaskBaseTypeEnum:{childTaskBaseTypeEnum}";
|
|
|
|
|
logger.LogInformation(log);
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
if (resultList.Any(x => !x))
|
|
|
|
|
|
|
|
|
|
return await SetTaskStatus(childTask, taskStatusEnum, statusTime, isCheckAllChildTaskComplete, bsno, taskDesc);
|
|
|
|
|
}
|
|
|
|
|
// 表示修改主任务的状态
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 表示修改主任务的状态
|
|
|
|
|
if (userIdList == null || userIdList.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
TaskBaseInfo taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(t => t.Id)
|
|
|
|
|
.FirstAsync(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr);
|
|
|
|
|
if (taskInfo == null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
return await SetTaskStatus(taskInfo, taskStatusEnum, statusTime, isCheckAllChildTaskComplete, bsno, taskDesc);
|
|
|
|
|
}
|
|
|
|
|
// 表示修改主任务的状态,但是通过用户列表做进一步筛选
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataUpdateSuccess)));
|
|
|
|
|
var taskIdList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(t => t.Id)
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.Select(x => x.Id)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
if (taskIdList.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var waitSetStatusTaskIdList = await tenantDb.Queryable<TaskBaseAllocation>()
|
|
|
|
|
.Where(x => taskIdList.Contains(x.TaskId) && userIdList.Contains(x.UserId))
|
|
|
|
|
.Select(x => x.TaskId)
|
|
|
|
|
.Distinct()
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var taskInfoList = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(x => waitSetStatusTaskIdList.Contains(x.Id))
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var resultList = new List<bool>();
|
|
|
|
|
foreach (var item in taskInfoList)
|
|
|
|
|
{
|
|
|
|
|
var itemResult = await SetTaskStatus(item, taskStatusEnum, statusTime, isCheckAllChildTaskComplete, bsno, taskDesc);
|
|
|
|
|
resultList.Add(itemResult.Succeeded);
|
|
|
|
|
}
|
|
|
|
|
if (resultList.Any(x => !x))
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataUpdateSuccess)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -199,29 +276,60 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <param name="bsno">业务主键</param>
|
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
|
/// <param name="userInfos">要转交的人员信息列表</param>
|
|
|
|
|
public async Task<DataResult> TransferTask(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, List<RecvUserInfo> userInfos, SqlSugarScopeProvider? tenantDb = null)
|
|
|
|
|
/// <param name="childBsno">子业务主键[可选,当不为空时表示设置子任务的状态]</param>
|
|
|
|
|
/// <param name="childTaskBaseTypeEnum">子业务类型</param>
|
|
|
|
|
public async Task<DataResult> TransferTask(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, List<RecvUserInfo> userInfos, SqlSugarScopeProvider? tenantDb = null,
|
|
|
|
|
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null)
|
|
|
|
|
{
|
|
|
|
|
tenantDb ??= saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
logger.LogInformation("接收到任务转交报文 bsno={bsno} taskBaseTypeEnum={taskBaseTypeEnum} 转交人员列表={userinfo} childBsno={childBsno} childTaskBaseTypeEnum={childTaskBaseTypeEnum}",
|
|
|
|
|
bsno,
|
|
|
|
|
taskBaseTypeEnum,
|
|
|
|
|
JsonConvert.SerializeObject(userInfos),
|
|
|
|
|
childBsno,
|
|
|
|
|
childTaskBaseTypeEnum);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
|
var childTaskTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
|
var task = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString())
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Select(t => new { t.Id, t.IS_PUBLIC })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (task == null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到任务");
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到父任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.LogInformation("接收到任务转交报文 任务主键={id} 转交人员列表={userinfo}", task.Id, JsonConvert.SerializeObject(userInfos));
|
|
|
|
|
|
|
|
|
|
var completedBusinessStatusCode = await tenantDb.Queryable<TaskFlowModule>()
|
|
|
|
|
.Where(x => x.ModuleType == 2 && x.TaskType == taskBaseTypeEnum.ToString())
|
|
|
|
|
string? completedBusinessStatusCode = "";
|
|
|
|
|
if (childBsno != null)
|
|
|
|
|
{
|
|
|
|
|
var childTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(x => x.IsChild == true
|
|
|
|
|
&& x.TASK_TYPE == childTaskTypeStr
|
|
|
|
|
&& x.CHILD_OUT_BS_NO == childBsno)
|
|
|
|
|
.Select(t => new { t.Id, t.IS_PUBLIC })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (childTask == null)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据childBsno:【{childBsno}】,childTaskTypeStr:【{childTaskTypeStr}】未查询到子任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
task = childTask;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
completedBusinessStatusCode = await tenantDb.Queryable<TaskFlowModule>()
|
|
|
|
|
.Where(x => x.ModuleType == 2 && x.TaskType == taskTypeStr)
|
|
|
|
|
.Select(x => x.CompletedBusinessStatusCode)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
@ -277,13 +385,19 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流设置任务对象属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<DataResult> SetTaskBaseInfoPropertyWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, params Expression<Func<TaskBaseInfo, bool>>[] columns)
|
|
|
|
|
public async Task<DataResult> SetTaskBaseInfoPropertyWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum,
|
|
|
|
|
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null,
|
|
|
|
|
params Expression<Func<TaskBaseInfo, bool>>[] columns)
|
|
|
|
|
{
|
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
|
var childTaskTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
|
|
long? taskInfoId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString())
|
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.Select(t => t.Id)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (taskInfoId == null || taskInfoId == 0)
|
|
|
|
@ -295,6 +409,24 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,查询出taskInfoId=【{taskInfoId}】");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (childBsno != null)
|
|
|
|
|
{
|
|
|
|
|
long? childTaskId = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(x => x.IsChild == true
|
|
|
|
|
&& x.TASK_TYPE == childTaskTypeStr
|
|
|
|
|
&& x.CHILD_OUT_BS_NO == childBsno)
|
|
|
|
|
.Select(t => t.Id)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (childTaskId == null || childTaskId == 0)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation($"根据childBsno:【{childBsno}】,childTaskTypeStr:【{childTaskTypeStr}】未查询到子任务");
|
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
|
}
|
|
|
|
|
taskInfoId = childTaskId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var updateable = tenantDb.Updateable<TaskBaseInfo>();
|
|
|
|
|
foreach (var item in columns)
|
|
|
|
|
{
|
|
|
|
@ -311,6 +443,10 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static object ImportLockObj = new object();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建任务公共方法
|
|
|
|
@ -327,6 +463,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
//Monitor.Enter(ImportLockObj);
|
|
|
|
|
logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, JsonConvert.SerializeObject(info));
|
|
|
|
|
|
|
|
|
|
if (info.Head.IsChild && info.Head.ChildBSNO == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("创建子任务需要指定子任务的业务主键[info.Head.ChildBSNO]");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
// 人员信息测试用
|
|
|
|
@ -340,70 +481,106 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
TaskBaseInfo taskInfo = null;
|
|
|
|
|
|
|
|
|
|
var taskTypeStr = info.Main.TaskType.ToString();
|
|
|
|
|
var childTaskTypeStr = info.Main.ChildTaskType.ToString();
|
|
|
|
|
var createStatusStr = TaskStatusEnum.Create.ToString();
|
|
|
|
|
var pendingStatusStr = TaskStatusEnum.Pending.ToString();
|
|
|
|
|
|
|
|
|
|
// 特殊处理:费用审核、修改、删除(明细)相关的审核,同一单子可以有多条费用审核及特殊费用审核任务,所属人
|
|
|
|
|
if ((info.Main.TaskType
|
|
|
|
|
is TaskBaseTypeEnum.FEE_AUDIT
|
|
|
|
|
or TaskBaseTypeEnum.FEE_REJECTED
|
|
|
|
|
or TaskBaseTypeEnum.FEE_MODIFY_AUDIT
|
|
|
|
|
or TaskBaseTypeEnum.FEE_MODIFY_REJECTED
|
|
|
|
|
or TaskBaseTypeEnum.FEE_DELETE_AUDIT
|
|
|
|
|
or TaskBaseTypeEnum.FEE_DELETE_REJECTED)
|
|
|
|
|
&& info.Main.RecvUserInfoList?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// 先查此订单在任务台账是否有指定类型的待处理的任务,如果有,查这些任务的归属人里是否已经包含了任务接收人
|
|
|
|
|
var existsTaskList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.TASK_SOURCE == TaskSourceEnum.WORK_FLOW.ToString()
|
|
|
|
|
&& t.OUT_BS_NO == info.Head.BSNO
|
|
|
|
|
&& t.TASK_TYPE == taskTypeStr
|
|
|
|
|
&& (t.STATUS == createStatusStr || t.STATUS == pendingStatusStr))
|
|
|
|
|
.Select(x => new { x.Id, x.TASK_NO })
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (existsTaskList.Count > 0)
|
|
|
|
|
long parentTaskId = 0;
|
|
|
|
|
if (info.Head.IsChild)
|
|
|
|
|
{
|
|
|
|
|
// 根据BSNO查现有任务的主键
|
|
|
|
|
var parentTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(x => x.OUT_BS_NO == info.Head.BSNO && x.TASK_TYPE == taskTypeStr && x.IsChild == false)
|
|
|
|
|
.OrderByDescending(x => x.Id)
|
|
|
|
|
.Select(x => new { x.Id })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (parentTask == null)
|
|
|
|
|
{
|
|
|
|
|
var existsTaskIdList = existsTaskList.Select(x => x.Id);
|
|
|
|
|
var recvUser = info.Main.RecvUserInfoList.First();
|
|
|
|
|
var existsRecvUser = await tenantDb.Queryable<TaskBaseAllocation>().Where(x => existsTaskIdList.Contains(x.TaskId) && x.UserId == recvUser.RecvUserId).AnyAsync();
|
|
|
|
|
if (existsRecvUser)
|
|
|
|
|
{
|
|
|
|
|
string log = $"订单Id:{info.Head.BSNO}业务类型:{taskTypeStr}已有接收人:{recvUser.RecvUserId}/{recvUser.RecvUserName},跳过创建";
|
|
|
|
|
// 回写任务号
|
|
|
|
|
return await Task.FromResult(new DataResult(ResultCode.Success, log, data: existsTaskList.Select(x => x.TASK_NO)));
|
|
|
|
|
}
|
|
|
|
|
throw new Exception($"创建子任务时根据未查询到父任务(父任务BSNO:{info.Head.BSNO},父任务TaskBaseTypeEnum:{taskTypeStr}");
|
|
|
|
|
}
|
|
|
|
|
parentTaskId = parentTask.Id;
|
|
|
|
|
|
|
|
|
|
// 判断子任务是否重复
|
|
|
|
|
var existsChildTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(x => x.IsChild == true
|
|
|
|
|
//&& x.ParentTaskId == parentTask.Id
|
|
|
|
|
&& x.TASK_TYPE == childTaskTypeStr
|
|
|
|
|
&& x.CHILD_OUT_BS_NO == info.Head.ChildBSNO
|
|
|
|
|
&& (x.STATUS == createStatusStr || x.STATUS == pendingStatusStr))
|
|
|
|
|
.Select(x => new { x.Id, x.TASK_NO })
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (existsChildTask != null)
|
|
|
|
|
{
|
|
|
|
|
var allotUserList = await allocationService.Value.GetAllotUserList(tenantDb, existsChildTask.Id);
|
|
|
|
|
var allotUserName = allotUserList.Select(x => x.userName);
|
|
|
|
|
var log = $"同一业务下已存在同任务类型的指定状态(待处理或挂起中)的子任务,不能重复创建(任务流水号:{existsChildTask.TASK_NO},接收人:{string.Join("、", allotUserName)})";
|
|
|
|
|
throw new Exception(log);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 如果业务主键不为空,则通过业务主键进行重复判断
|
|
|
|
|
if (info.Head.BSNO is not (null or 0))
|
|
|
|
|
// 特殊处理:费用审核、修改、删除(明细)相关的审核,同一单子可以有多条费用审核及特殊费用审核任务,所属人
|
|
|
|
|
if ((info.Main.TaskType
|
|
|
|
|
is TaskBaseTypeEnum.FEE_AUDIT
|
|
|
|
|
or TaskBaseTypeEnum.FEE_REJECTED
|
|
|
|
|
or TaskBaseTypeEnum.FEE_MODIFY_AUDIT
|
|
|
|
|
or TaskBaseTypeEnum.FEE_MODIFY_REJECTED
|
|
|
|
|
or TaskBaseTypeEnum.FEE_DELETE_AUDIT
|
|
|
|
|
or TaskBaseTypeEnum.FEE_DELETE_REJECTED)
|
|
|
|
|
&& info.Main.RecvUserInfoList?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.OUT_BS_NO == info.Head.BSNO)
|
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
STATUS = x.STATUS
|
|
|
|
|
})
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
// 先查此订单在任务台账是否有指定类型的待处理的任务,如果有,查这些任务的归属人里是否已经包含了任务接收人
|
|
|
|
|
var existsTaskList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.TASK_SOURCE == TaskSourceEnum.WORK_FLOW.ToString()
|
|
|
|
|
&& t.OUT_BS_NO == info.Head.BSNO
|
|
|
|
|
&& t.TASK_TYPE == taskTypeStr
|
|
|
|
|
&& (t.STATUS == createStatusStr || t.STATUS == pendingStatusStr))
|
|
|
|
|
.Select(x => new { x.Id, x.TASK_NO })
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (existsTaskList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var existsTaskIdList = existsTaskList.Select(x => x.Id);
|
|
|
|
|
var recvUser = info.Main.RecvUserInfoList.First();
|
|
|
|
|
var existsRecvUser = await tenantDb.Queryable<TaskBaseAllocation>().Where(x => existsTaskIdList.Contains(x.TaskId) && x.UserId == recvUser.RecvUserId).AnyAsync();
|
|
|
|
|
if (existsRecvUser)
|
|
|
|
|
{
|
|
|
|
|
string log = $"订单Id:{info.Head.BSNO}业务类型:{taskTypeStr}已有接收人:{recvUser.RecvUserId}/{recvUser.RecvUserName},跳过创建";
|
|
|
|
|
// 回写任务号
|
|
|
|
|
return await Task.FromResult(new DataResult(ResultCode.Success, log, data: existsTaskList.Select(x => x.TASK_NO)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 否则通过Head.GID进行判断
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}")
|
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
STATUS = x.STATUS
|
|
|
|
|
})
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
// 如果业务主键不为空,则通过业务主键进行重复判断
|
|
|
|
|
if (info.Head.BSNO is not (null or 0))
|
|
|
|
|
{
|
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.OUT_BS_NO == info.Head.BSNO)
|
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
STATUS = x.STATUS
|
|
|
|
|
})
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
// 否则通过Head.GID进行判断
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
.Where(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}")
|
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
STATUS = x.STATUS
|
|
|
|
|
})
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -412,8 +589,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
&& taskInfo.STATUS != TaskStatusEnum.Cancel.ToString()
|
|
|
|
|
&& taskInfo.STATUS != TaskStatusEnum.Complete.ToString())
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation("批次={no} 状态已存在,不能重复创建任务 status={status}", batchNo, taskInfo.STATUS);
|
|
|
|
|
throw new Exception($"状态已存在,不能重复创建任务");
|
|
|
|
|
var allotUserList = await allocationService.Value.GetAllotUserList(tenantDb, taskInfo.Id);
|
|
|
|
|
var allotUserName = allotUserList.Select(x => x.userName);
|
|
|
|
|
|
|
|
|
|
var log = $"同一业务下已存在同任务类型的指定状态(待处理或挂起中)的任务,不能重复创建(任务流水号:{taskInfo.TASK_NO},接收人:{string.Join("、", allotUserName)})";
|
|
|
|
|
throw new Exception(log);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.LogInformation("批次={no} 接收到创建任务报文 结束查询任务 {msg}", batchNo, taskInfo == null ? "不存在" : "存在");
|
|
|
|
@ -493,9 +673,12 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (info.Main.ExtData != null)
|
|
|
|
|
if (info.Head.IsChild)
|
|
|
|
|
{
|
|
|
|
|
taskInfo.ExtData = info.Main.ExtData.ToJson();
|
|
|
|
|
taskInfo.IsChild = true;
|
|
|
|
|
taskInfo.ParentTaskId = parentTaskId;
|
|
|
|
|
taskInfo.CHILD_OUT_BS_NO = info.Head.ChildBSNO;
|
|
|
|
|
taskInfo.TASK_TYPE = childTaskTypeStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Enum.TryParse(typeof(TaskBaseTypeEnum), taskInfo.TASK_TYPE, out object? taskTypeTemp))
|
|
|
|
@ -503,6 +686,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
taskInfo.TASK_TYPE_NAME = ((TaskBaseTypeEnum)taskTypeTemp).EnumDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info.Main.ExtData != null)
|
|
|
|
|
{
|
|
|
|
|
taskInfo.ExtData = info.Main.ExtData.ToJson();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果船公司主键不为空,则直接保存船公司主键、Code、Name等信息(如果Name为空,查询一下再赋值)
|
|
|
|
|
if (taskInfo.CARRIER_ID != null)
|
|
|
|
|
{
|
|
|
|
@ -601,7 +789,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.LogError(ex, "任务创建时,设置订单业务状态的过程中发生异常,orderId={0},taskType={1}", (long)info.Head.BSNO, taskInfo.TASK_TYPE);
|
|
|
|
|
throw;
|
|
|
|
|
//throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
@ -617,7 +805,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.LogError(ex, "任务创建时,设置订单的货物状态时发生异常,orderId={0},taskType={1}", (long)info.Head.BSNO, taskInfo.TASK_TYPE);
|
|
|
|
|
throw;
|
|
|
|
|
//throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -644,7 +832,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
Status = TaskStatusEnum.Create.ToString(),
|
|
|
|
|
StatusName = TaskStatusEnum.Create.EnumDescription(),
|
|
|
|
|
StatusTime = DateTime.Now,
|
|
|
|
|
BusinessId = taskInfo.OUT_BS_NO,
|
|
|
|
|
BusinessId = info.Head.IsChild ? taskInfo.CHILD_OUT_BS_NO : taskInfo.OUT_BS_NO,
|
|
|
|
|
GoodStatusCode = completedBusinessStatusCode,
|
|
|
|
|
OrgId = userWithOrgMap.FirstOrDefault(m => m.Id == x.RecvUserId)?.DefaultOrgId ?? 0
|
|
|
|
|
};
|
|
|
|
@ -1900,6 +2088,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务台台账列表查询
|
|
|
|
|
/// </summary>
|
|
|
|
@ -2676,7 +2865,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
item.RecvUserList = recvUserList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2.部分字段值覆盖:提单号、ETD、船公司(如果订单的号码不为空则采用订单的号码)
|
|
|
|
|
// 2.部分字段值覆盖:提单号、ETD、船公司、委托编号(如果订单的号码不为空则采用订单的号码)
|
|
|
|
|
if (!string.IsNullOrEmpty(item.orderMBLNO))
|
|
|
|
|
{
|
|
|
|
|
item.MBL_NO = item.orderMBLNO;
|
|
|
|
@ -2691,6 +2880,10 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
item.CARRIER_ID = item.orderCarrierId;
|
|
|
|
|
item.CARRIER_NAME = null;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(item.customerNo))
|
|
|
|
|
{
|
|
|
|
|
item.customeR_NO = item.customerNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3.ExtData字段从Data转为对象
|
|
|
|
|
if (!string.IsNullOrEmpty(item.ExtData))
|
|
|
|
@ -3327,6 +3520,133 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务台台账子任务列表查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<DataResult<List<dynamic>>> GetChildTaskList(long taskId)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
tenantDb.QueryFilter.Clear();
|
|
|
|
|
|
|
|
|
|
var userId = long.Parse(user.UserId);
|
|
|
|
|
|
|
|
|
|
var queryable = tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.LeftJoin<TaskBaseAllocation>((t, a) => t.Id == a.TaskId && a.Deleted == false)
|
|
|
|
|
.LeftJoin<SeaExport>((t, a, s) => t.OUT_BS_NO == s.Id)
|
|
|
|
|
.Where(t => t.IsChild == true && t.ParentTaskId == taskId);
|
|
|
|
|
|
|
|
|
|
ISugarQueryable<dynamic> queryableTemp = queryable.Select<dynamic>((t, a, s) => new
|
|
|
|
|
{
|
|
|
|
|
PK_ID = t.Id.SelectAll(),
|
|
|
|
|
|
|
|
|
|
orderMBLNO = s.MBLNO,
|
|
|
|
|
orderETD = s.ETD,
|
|
|
|
|
orderCarrier = s.Carrier,
|
|
|
|
|
orderCarrierId = s.CarrierId,
|
|
|
|
|
|
|
|
|
|
s.CustomerNo,
|
|
|
|
|
s.CustomerNum,
|
|
|
|
|
s.BookingNo,
|
|
|
|
|
s.HBLNO,
|
|
|
|
|
|
|
|
|
|
s.CustomerName,
|
|
|
|
|
s.Sale,
|
|
|
|
|
s.CustomerServiceName,
|
|
|
|
|
s.OperatorName,
|
|
|
|
|
|
|
|
|
|
s.LoadPortCode,
|
|
|
|
|
s.LoadPort,
|
|
|
|
|
s.DischargePortCode,
|
|
|
|
|
s.DischargePort,
|
|
|
|
|
|
|
|
|
|
s.CntrTotal,
|
|
|
|
|
}).Distinct();
|
|
|
|
|
|
|
|
|
|
List<dynamic> data = await queryableTemp.ToListAsync();
|
|
|
|
|
var result = DataResult<List<dynamic>>.Success(data);
|
|
|
|
|
|
|
|
|
|
if (result.Data?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// 查询任务接收人列表
|
|
|
|
|
var taskIdList = result.Data.Select(x => (long)x.Id).ToList();
|
|
|
|
|
|
|
|
|
|
var allRecvUserList = await tenantDb.Queryable<TaskBaseAllocation>()
|
|
|
|
|
.Where(x => taskIdList.Contains(x.TaskId))
|
|
|
|
|
.Select(x => new RecvUserInfo()
|
|
|
|
|
{
|
|
|
|
|
TaskId = x.TaskId,
|
|
|
|
|
RecvUserId = x.UserId,
|
|
|
|
|
RecvUserName = x.UserName,
|
|
|
|
|
RecvUserStatus = x.Status,
|
|
|
|
|
RecvUserStatusName = x.StatusName,
|
|
|
|
|
RecvUserStatusTime = x.StatusTime
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
// 一些特殊处理
|
|
|
|
|
foreach (var item in result.Data)
|
|
|
|
|
{
|
|
|
|
|
// 1.任务接收人赋值
|
|
|
|
|
if (allRecvUserList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var recvUserList = allRecvUserList.Where(x => x.TaskId == item.Id).ToList();
|
|
|
|
|
|
|
|
|
|
var currentUserStatus = recvUserList.FirstOrDefault(x => x.RecvUserId == userId);
|
|
|
|
|
if (currentUserStatus != null)
|
|
|
|
|
{
|
|
|
|
|
var n = recvUserList.IndexOf(currentUserStatus);
|
|
|
|
|
if (n != 0)
|
|
|
|
|
{
|
|
|
|
|
recvUserList.RemoveAt(n);
|
|
|
|
|
recvUserList.Insert(0, currentUserStatus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.TASK_USER_STATUS = currentUserStatus.RecvUserStatus;
|
|
|
|
|
item.TASK_USER_STATUS_NAME = currentUserStatus.RecvUserStatusName;
|
|
|
|
|
item.TASK_USER_STATUS_TIME = currentUserStatus.RecvUserStatusTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.RecvUserList = recvUserList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2.部分字段值覆盖:提单号、ETD、船公司、委托编号(如果订单的号码不为空则采用订单的号码)
|
|
|
|
|
if (!string.IsNullOrEmpty(item.orderMBLNO))
|
|
|
|
|
{
|
|
|
|
|
item.MBL_NO = item.orderMBLNO;
|
|
|
|
|
}
|
|
|
|
|
if (item.orderETD != null)
|
|
|
|
|
{
|
|
|
|
|
item.ETD = item.orderETD;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(item.orderCarrier))
|
|
|
|
|
{
|
|
|
|
|
item.CARRIER_CODE = item.orderCarrier;
|
|
|
|
|
item.CARRIER_ID = item.orderCarrierId;
|
|
|
|
|
item.CARRIER_NAME = null;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CustomerNo))
|
|
|
|
|
{
|
|
|
|
|
item.CUSTOMER_NO = item.CustomerNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3.ExtData字段从Data转为对象
|
|
|
|
|
if (!string.IsNullOrEmpty(item.ExtData))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
item.ExtData = JObject.Parse(item.ExtData);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
item.ExtData = new { ParseError = true, ParseMessage = "ExtData为非标准Json,导致解析异常" };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 完成任务(可批量)
|
|
|
|
|
/// </summary>
|
|
|
|
|