|
|
@ -87,30 +87,57 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 工作流设置任务在个人下的状态
|
|
|
|
/// 工作流设置任务在个人下的状态
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="bsno">业务主键</param>
|
|
|
|
/// <param name="bsno">主业务主键</param>
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
/// <param name="taskBaseTypeEnum">主业务类型</param>
|
|
|
|
/// <param name="taskStatusEnum">业务状态</param>
|
|
|
|
/// <param name="taskStatusEnum">业务状态</param>
|
|
|
|
/// <param name="statusTime">状态发生时间</param>
|
|
|
|
/// <param name="statusTime">状态发生时间</param>
|
|
|
|
/// <param name="userInfos">要设置任务状态的人员列表</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);
|
|
|
|
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)
|
|
|
|
.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)));
|
|
|
|
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 userIdList = userInfos.Select(x => x.RecvUserId).ToList();
|
|
|
|
var taskBaseAllocationList = await tenantDb.Queryable<TaskBaseAllocation>()
|
|
|
|
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();
|
|
|
|
.ToListAsync();
|
|
|
|
if (taskBaseAllocationList.Any())
|
|
|
|
if (taskBaseAllocationList.Any())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -142,53 +169,103 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
/// <param name="taskStatusEnum">业务状态</param>
|
|
|
|
/// <param name="taskStatusEnum">业务状态</param>
|
|
|
|
/// <param name="statusTime">状态发生时间</param>
|
|
|
|
/// <param name="statusTime">状态发生时间</param>
|
|
|
|
|
|
|
|
/// <param name="isCheckAllChildTaskComplete">完成任务前是否检查所有子任务是否完成</param>
|
|
|
|
/// <param name="taskDesc">任务描述</param>
|
|
|
|
/// <param name="taskDesc">任务描述</param>
|
|
|
|
/// <param name="userIdList">用户Id列表,用于筛选指定用户下的任务</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="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);
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
if (userIdList == null || userIdList.Count() == 0)
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
{
|
|
|
|
|
|
|
|
TaskBaseInfo taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
// 表示修改子任务的状态
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
if (childBsno != null)
|
|
|
|
.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 taskIdList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
var taskId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskTypeStr)
|
|
|
|
.Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString())
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
.Select(x => x.Id)
|
|
|
|
.Select(t => new { t.Id })
|
|
|
|
.ToListAsync();
|
|
|
|
.FirstAsync();
|
|
|
|
if (taskIdList.Count() == 0)
|
|
|
|
if (taskId == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var log = $"设置子任务状态时未查询到父任务(父任务BSNO:{bsno},父任务TaskBaseTypeEnum:{taskBaseTypeEnum}";
|
|
|
|
|
|
|
|
logger.LogInformation(log);
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
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 childTaskTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
var taskInfoList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId)).Where(x => waitSetStatusTaskIdList.Contains(x.Id)).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var resultList = new List<bool>();
|
|
|
|
var childTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
foreach (var item in taskInfoList)
|
|
|
|
.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);
|
|
|
|
var log = $"设置子任务状态时未查询到子任务(父任务BSNO:{bsno},父任务TaskBaseTypeEnum:{taskBaseTypeEnum},子任务childBsno:{childBsno},子任务childTaskBaseTypeEnum:{childTaskBaseTypeEnum}";
|
|
|
|
resultList.Add(itemResult.Succeeded);
|
|
|
|
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
|
|
|
|
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="bsno">业务主键</param>
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
/// <param name="taskBaseTypeEnum">业务类型</param>
|
|
|
|
/// <param name="userInfos">要转交的人员信息列表</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);
|
|
|
|
tenantDb ??= saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogInformation("接收到任务转交报文 bsno={bsno} taskBaseTypeEnum={taskBaseTypeEnum} 转交人员列表={userinfo} childBsno={childBsno} childTaskBaseTypeEnum={childTaskBaseTypeEnum}",
|
|
|
|
|
|
|
|
bsno,
|
|
|
|
|
|
|
|
taskBaseTypeEnum,
|
|
|
|
|
|
|
|
JsonConvert.SerializeObject(userInfos),
|
|
|
|
|
|
|
|
childBsno,
|
|
|
|
|
|
|
|
childTaskBaseTypeEnum);
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
var childTaskTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
var task = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
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)
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
.Select(t => new { t.Id, t.IS_PUBLIC })
|
|
|
|
.Select(t => new { t.Id, t.IS_PUBLIC })
|
|
|
|
.FirstAsync();
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (task == null)
|
|
|
|
if (task == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到任务");
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到父任务");
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string? completedBusinessStatusCode = "";
|
|
|
|
logger.LogInformation("接收到任务转交报文 任务主键={id} 转交人员列表={userinfo}", task.Id, JsonConvert.SerializeObject(userInfos));
|
|
|
|
if (childBsno != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
var completedBusinessStatusCode = await tenantDb.Queryable<TaskFlowModule>()
|
|
|
|
var childTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
.Where(x => x.ModuleType == 2 && x.TaskType == taskBaseTypeEnum.ToString())
|
|
|
|
.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)
|
|
|
|
.Select(x => x.CompletedBusinessStatusCode)
|
|
|
|
.FirstAsync();
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
|
@ -277,13 +385,19 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 工作流设置任务对象属性
|
|
|
|
/// 工作流设置任务对象属性
|
|
|
|
/// </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);
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var taskTypeStr = taskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
var childTaskTypeStr = childTaskBaseTypeEnum.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
long? taskInfoId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
long? taskInfoId = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
.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)
|
|
|
|
.Select(t => t.Id)
|
|
|
|
.FirstAsync();
|
|
|
|
.FirstAsync();
|
|
|
|
if (taskInfoId == null || taskInfoId == 0)
|
|
|
|
if (taskInfoId == null || taskInfoId == 0)
|
|
|
@ -295,6 +409,24 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogInformation($"根据bsno:【{bsno}】,查询出taskInfoId=【{taskInfoId}】");
|
|
|
|
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>();
|
|
|
|
var updateable = tenantDb.Updateable<TaskBaseInfo>();
|
|
|
|
foreach (var item in columns)
|
|
|
|
foreach (var item in columns)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -311,6 +443,10 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static object ImportLockObj = new object();
|
|
|
|
private static object ImportLockObj = new object();
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 创建任务公共方法
|
|
|
|
/// 创建任务公共方法
|
|
|
@ -327,6 +463,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
//Monitor.Enter(ImportLockObj);
|
|
|
|
//Monitor.Enter(ImportLockObj);
|
|
|
|
logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, JsonConvert.SerializeObject(info));
|
|
|
|
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);
|
|
|
|
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
// 人员信息测试用
|
|
|
|
// 人员信息测试用
|
|
|
@ -340,70 +481,106 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
TaskBaseInfo taskInfo = null;
|
|
|
|
TaskBaseInfo taskInfo = null;
|
|
|
|
|
|
|
|
|
|
|
|
var taskTypeStr = info.Main.TaskType.ToString();
|
|
|
|
var taskTypeStr = info.Main.TaskType.ToString();
|
|
|
|
|
|
|
|
var childTaskTypeStr = info.Main.ChildTaskType.ToString();
|
|
|
|
var createStatusStr = TaskStatusEnum.Create.ToString();
|
|
|
|
var createStatusStr = TaskStatusEnum.Create.ToString();
|
|
|
|
var pendingStatusStr = TaskStatusEnum.Pending.ToString();
|
|
|
|
var pendingStatusStr = TaskStatusEnum.Pending.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
// 特殊处理:费用审核、修改、删除(明细)相关的审核,同一单子可以有多条费用审核及特殊费用审核任务,所属人
|
|
|
|
long parentTaskId = 0;
|
|
|
|
if ((info.Main.TaskType
|
|
|
|
if (info.Head.IsChild)
|
|
|
|
is TaskBaseTypeEnum.FEE_AUDIT
|
|
|
|
{
|
|
|
|
or TaskBaseTypeEnum.FEE_REJECTED
|
|
|
|
// 根据BSNO查现有任务的主键
|
|
|
|
or TaskBaseTypeEnum.FEE_MODIFY_AUDIT
|
|
|
|
var parentTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
or TaskBaseTypeEnum.FEE_MODIFY_REJECTED
|
|
|
|
.Where(x => x.OUT_BS_NO == info.Head.BSNO && x.TASK_TYPE == taskTypeStr && x.IsChild == false)
|
|
|
|
or TaskBaseTypeEnum.FEE_DELETE_AUDIT
|
|
|
|
.OrderByDescending(x => x.Id)
|
|
|
|
or TaskBaseTypeEnum.FEE_DELETE_REJECTED)
|
|
|
|
.Select(x => new { x.Id })
|
|
|
|
&& info.Main.RecvUserInfoList?.Count > 0)
|
|
|
|
.FirstAsync();
|
|
|
|
{
|
|
|
|
if (parentTask == null)
|
|
|
|
// 先查此订单在任务台账是否有指定类型的待处理的任务,如果有,查这些任务的归属人里是否已经包含了任务接收人
|
|
|
|
|
|
|
|
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);
|
|
|
|
throw new Exception($"创建子任务时根据未查询到父任务(父任务BSNO:{info.Head.BSNO},父任务TaskBaseTypeEnum:{taskTypeStr}");
|
|
|
|
var recvUser = info.Main.RecvUserInfoList.First();
|
|
|
|
}
|
|
|
|
var existsRecvUser = await tenantDb.Queryable<TaskBaseAllocation>().Where(x => existsTaskIdList.Contains(x.TaskId) && x.UserId == recvUser.RecvUserId).AnyAsync();
|
|
|
|
parentTaskId = parentTask.Id;
|
|
|
|
if (existsRecvUser)
|
|
|
|
|
|
|
|
{
|
|
|
|
// 判断子任务是否重复
|
|
|
|
string log = $"订单Id:{info.Head.BSNO}业务类型:{taskTypeStr}已有接收人:{recvUser.RecvUserId}/{recvUser.RecvUserName},跳过创建";
|
|
|
|
var existsChildTask = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
// 回写任务号
|
|
|
|
.Where(x => x.IsChild == true
|
|
|
|
return await Task.FromResult(new DataResult(ResultCode.Success, log, data: existsTaskList.Select(x => x.TASK_NO)));
|
|
|
|
//&& 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
|
|
|
|
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)
|
|
|
|
var existsTaskList = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
.Where(t => t.TASK_SOURCE == TaskSourceEnum.WORK_FLOW.ToString()
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
&& t.OUT_BS_NO == info.Head.BSNO
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
&& t.TASK_TYPE == taskTypeStr
|
|
|
|
{
|
|
|
|
&& (t.STATUS == createStatusStr || t.STATUS == pendingStatusStr))
|
|
|
|
Id = x.Id,
|
|
|
|
.Select(x => new { x.Id, x.TASK_NO })
|
|
|
|
STATUS = x.STATUS
|
|
|
|
.ToListAsync();
|
|
|
|
})
|
|
|
|
|
|
|
|
.FirstAsync();
|
|
|
|
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
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
// 如果业务主键不为空,则通过业务主键进行重复判断
|
|
|
|
.Where(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}")
|
|
|
|
if (info.Head.BSNO is not (null or 0))
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
{
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
.Where(t => t.OUT_BS_NO == info.Head.BSNO)
|
|
|
|
{
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == taskTypeStr)
|
|
|
|
Id = x.Id,
|
|
|
|
.OrderByDescending(a => a.Id)
|
|
|
|
STATUS = x.STATUS
|
|
|
|
.Select(x => new TaskBaseInfo()
|
|
|
|
})
|
|
|
|
{
|
|
|
|
.FirstAsync();
|
|
|
|
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.Cancel.ToString()
|
|
|
|
&& taskInfo.STATUS != TaskStatusEnum.Complete.ToString())
|
|
|
|
&& taskInfo.STATUS != TaskStatusEnum.Complete.ToString())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogInformation("批次={no} 状态已存在,不能重复创建任务 status={status}", batchNo, taskInfo.STATUS);
|
|
|
|
var allotUserList = await allocationService.Value.GetAllotUserList(tenantDb, taskInfo.Id);
|
|
|
|
throw new Exception($"状态已存在,不能重复创建任务");
|
|
|
|
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 ? "不存在" : "存在");
|
|
|
|
logger.LogInformation("批次={no} 接收到创建任务报文 结束查询任务 {msg}", batchNo, taskInfo == null ? "不存在" : "存在");
|
|
|
@ -493,9 +673,12 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
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))
|
|
|
|
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();
|
|
|
|
taskInfo.TASK_TYPE_NAME = ((TaskBaseTypeEnum)taskTypeTemp).EnumDescription();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (info.Main.ExtData != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
taskInfo.ExtData = info.Main.ExtData.ToJson();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果船公司主键不为空,则直接保存船公司主键、Code、Name等信息(如果Name为空,查询一下再赋值)
|
|
|
|
// 如果船公司主键不为空,则直接保存船公司主键、Code、Name等信息(如果Name为空,查询一下再赋值)
|
|
|
|
if (taskInfo.CARRIER_ID != null)
|
|
|
|
if (taskInfo.CARRIER_ID != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -601,7 +789,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogError(ex, "任务创建时,设置订单业务状态的过程中发生异常,orderId={0},taskType={1}", (long)info.Head.BSNO, taskInfo.TASK_TYPE);
|
|
|
|
logger.LogError(ex, "任务创建时,设置订单业务状态的过程中发生异常,orderId={0},taskType={1}", (long)info.Head.BSNO, taskInfo.TASK_TYPE);
|
|
|
|
throw;
|
|
|
|
//throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -617,7 +805,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogError(ex, "任务创建时,设置订单的货物状态时发生异常,orderId={0},taskType={1}", (long)info.Head.BSNO, taskInfo.TASK_TYPE);
|
|
|
|
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(),
|
|
|
|
Status = TaskStatusEnum.Create.ToString(),
|
|
|
|
StatusName = TaskStatusEnum.Create.EnumDescription(),
|
|
|
|
StatusName = TaskStatusEnum.Create.EnumDescription(),
|
|
|
|
StatusTime = DateTime.Now,
|
|
|
|
StatusTime = DateTime.Now,
|
|
|
|
BusinessId = taskInfo.OUT_BS_NO,
|
|
|
|
BusinessId = info.Head.IsChild ? taskInfo.CHILD_OUT_BS_NO : taskInfo.OUT_BS_NO,
|
|
|
|
GoodStatusCode = completedBusinessStatusCode,
|
|
|
|
GoodStatusCode = completedBusinessStatusCode,
|
|
|
|
OrgId = userWithOrgMap.FirstOrDefault(m => m.Id == x.RecvUserId)?.DefaultOrgId ?? 0
|
|
|
|
OrgId = userWithOrgMap.FirstOrDefault(m => m.Id == x.RecvUserId)?.DefaultOrgId ?? 0
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -1900,6 +2088,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 任务台台账列表查询
|
|
|
|
/// 任务台台账列表查询
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -2676,7 +2865,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
item.RecvUserList = recvUserList;
|
|
|
|
item.RecvUserList = recvUserList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2.部分字段值覆盖:提单号、ETD、船公司(如果订单的号码不为空则采用订单的号码)
|
|
|
|
// 2.部分字段值覆盖:提单号、ETD、船公司、委托编号(如果订单的号码不为空则采用订单的号码)
|
|
|
|
if (!string.IsNullOrEmpty(item.orderMBLNO))
|
|
|
|
if (!string.IsNullOrEmpty(item.orderMBLNO))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.MBL_NO = item.orderMBLNO;
|
|
|
|
item.MBL_NO = item.orderMBLNO;
|
|
|
@ -2691,6 +2880,10 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
item.CARRIER_ID = item.orderCarrierId;
|
|
|
|
item.CARRIER_ID = item.orderCarrierId;
|
|
|
|
item.CARRIER_NAME = null;
|
|
|
|
item.CARRIER_NAME = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(item.customerNo))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item.customeR_NO = item.customerNo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3.ExtData字段从Data转为对象
|
|
|
|
// 3.ExtData字段从Data转为对象
|
|
|
|
if (!string.IsNullOrEmpty(item.ExtData))
|
|
|
|
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>
|
|
|
|
/// 完成任务(可批量)
|
|
|
|
/// 完成任务(可批量)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|