|
|
@ -133,6 +133,8 @@ namespace Myshipping.Application
|
|
|
|
SqlSugarRepository<TaskStoreMsgInfo> taskStoreMsgInfoRepository,
|
|
|
|
SqlSugarRepository<TaskStoreMsgInfo> taskStoreMsgInfoRepository,
|
|
|
|
SqlSugarRepository<TaskChangeShipHisInfo> taskChangeShipHisInfoRepository,
|
|
|
|
SqlSugarRepository<TaskChangeShipHisInfo> taskChangeShipHisInfoRepository,
|
|
|
|
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
|
|
|
|
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
|
|
|
|
|
|
|
|
SqlSugarRepository<TaskTruckInfo> taskTruckInfoRepository,
|
|
|
|
|
|
|
|
SqlSugarRepository<TaskTruckCtn> taskTruckCtnRepository,
|
|
|
|
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
|
|
|
|
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
|
|
|
|
IDjyWebsiteAccountConfigService webAccountConfig,
|
|
|
|
IDjyWebsiteAccountConfigService webAccountConfig,
|
|
|
|
ISysCacheService cache,
|
|
|
|
ISysCacheService cache,
|
|
|
@ -159,6 +161,8 @@ namespace Myshipping.Application
|
|
|
|
_taskStoreMsgInfoRepository = taskStoreMsgInfoRepository;
|
|
|
|
_taskStoreMsgInfoRepository = taskStoreMsgInfoRepository;
|
|
|
|
_taskChangeShipHisInfoRepository = taskChangeShipHisInfoRepository;
|
|
|
|
_taskChangeShipHisInfoRepository = taskChangeShipHisInfoRepository;
|
|
|
|
_bookingOrderContactRepository = bookingOrderContactRepository;
|
|
|
|
_bookingOrderContactRepository = bookingOrderContactRepository;
|
|
|
|
|
|
|
|
_taskTruckInfoRepository = taskTruckInfoRepository;
|
|
|
|
|
|
|
|
_taskTruckCtnRepository = taskTruckCtnRepository;
|
|
|
|
|
|
|
|
|
|
|
|
_namedBookingOrderServiceProvider = namedBookingOrderServiceProvider;
|
|
|
|
_namedBookingOrderServiceProvider = namedBookingOrderServiceProvider;
|
|
|
|
|
|
|
|
|
|
|
@ -199,16 +203,21 @@ namespace Myshipping.Application
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info">任务详情</param>
|
|
|
|
/// <param name="info">任务详情</param>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
private async Task<TaskManageOrderResultDto> InitTaskJob(TaskManageOrderMessageInfo info)
|
|
|
|
private async Task<TaskManageOrderResultDto> InitTaskJob(TaskManageOrderMessageInfo info)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}");
|
|
|
|
var taskInfo = _taskBaseInfoRepository.AsQueryable().OrderByDescending(a=>a.CreatedTime)
|
|
|
|
|
|
|
|
.First(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}");
|
|
|
|
|
|
|
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
/*
|
|
|
|
throw Oops.Oh($"任务已经存在不能重复提交");
|
|
|
|
只要任务最后一次处理任务的状态是已取消、已完成,就可以重入新的任务
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(taskInfo != null && taskInfo.STATUS != TaskStatusEnum.Cancel.ToString() && taskInfo.STATUS != TaskStatusEnum.Complete.ToString())
|
|
|
|
|
|
|
|
throw Oops.Oh($"状态已存在,不能重复创建任务");
|
|
|
|
|
|
|
|
|
|
|
|
taskInfo = new TaskBaseInfo
|
|
|
|
taskInfo = new TaskBaseInfo
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -222,26 +231,19 @@ namespace Myshipping.Application
|
|
|
|
CARRIER_ID = info.Main.CarrierId?.Trim(),
|
|
|
|
CARRIER_ID = info.Main.CarrierId?.Trim(),
|
|
|
|
IS_PUBLIC = string.IsNullOrWhiteSpace(info.Main.TaskUserId) ? 1 : 0,
|
|
|
|
IS_PUBLIC = string.IsNullOrWhiteSpace(info.Main.TaskUserId) ? 1 : 0,
|
|
|
|
BOOK_ORDER_NO = info.Main.BookingOrderNo,
|
|
|
|
BOOK_ORDER_NO = info.Main.BookingOrderNo,
|
|
|
|
OUT_BUSI_NO = info.Head.GID,
|
|
|
|
OUT_BUSI_NO = $"{info.Head.SenderId}_{info.Head.GID}",
|
|
|
|
TASK_TITLE = info.Main.TaskTitle,
|
|
|
|
TASK_TITLE = info.Main.TaskTitle,
|
|
|
|
TASK_DESP = info.Main.TaskDesp,
|
|
|
|
TASK_DESP = info.Main.TaskDesp,
|
|
|
|
TASK_SOURCE = info.Main.TaskSource.ToString(),
|
|
|
|
TASK_SOURCE = info.Main.TaskSource.ToString(),
|
|
|
|
TASK_TYPE = info.Main.TaskType.ToString(),
|
|
|
|
TASK_TYPE = info.Main.TaskType.ToString(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//这里因为接口是不做授权验证的,所以这里直接写的动态sql提取了用户和租户信息
|
|
|
|
UserTendDto userTendInfo = GetUserTendInfo(info.Main.TaskUserId);
|
|
|
|
var userTendInfo = await _sysUserRepository.EntityContext.Queryable<dynamic>("user").AS("sys_user")
|
|
|
|
|
|
|
|
.AddJoinInfo("sys_tenant", "ten", "user.TenantId=ten.Id")
|
|
|
|
|
|
|
|
.Where("user.Id=@id", new { id = long.Parse(info.Main.TaskUserId) })
|
|
|
|
|
|
|
|
.Select("user.Id as UserId,user.Name as UserName,ten.Id as TendId,ten.Name as TendName").FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userTendInfo == null || userTendInfo.TendId == null)
|
|
|
|
taskInfo.CreatedUserId = userTendInfo.userId;
|
|
|
|
throw Oops.Oh("当前用户详情获取失败,请确认{0}赋值是否准确",nameof(TaskManageOrderMessageInfo.Main.TaskUserId));
|
|
|
|
taskInfo.CreatedUserName = userTendInfo.userName;
|
|
|
|
|
|
|
|
taskInfo.TenantId = userTendInfo.tendId;
|
|
|
|
taskInfo.CreatedUserId = long.Parse(userTendInfo.UserId.ToString());
|
|
|
|
taskInfo.TenantName = userTendInfo.tenantName;
|
|
|
|
taskInfo.CreatedUserName = userTendInfo.UserName.ToString();
|
|
|
|
|
|
|
|
taskInfo.TenantId = long.Parse(userTendInfo.TendId.ToString());
|
|
|
|
|
|
|
|
taskInfo.TenantName = userTendInfo.TendName.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskInfo.CreatedTime = DateTime.Now;
|
|
|
|
taskInfo.CreatedTime = DateTime.Now;
|
|
|
|
taskInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
|
taskInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
@ -257,7 +259,7 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//新增
|
|
|
|
//新增
|
|
|
|
await _taskBaseInfoRepository.InsertAsync(taskInfo);
|
|
|
|
_taskBaseInfoRepository.Insert(taskInfo);
|
|
|
|
|
|
|
|
|
|
|
|
#region 附件
|
|
|
|
#region 附件
|
|
|
|
//附件
|
|
|
|
//附件
|
|
|
@ -493,8 +495,6 @@ namespace Myshipping.Application
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//异步集装箱
|
|
|
|
//异步集装箱
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
@ -521,8 +521,9 @@ namespace Myshipping.Application
|
|
|
|
result.succ = true;
|
|
|
|
result.succ = true;
|
|
|
|
result.msg = "新增任务成功";
|
|
|
|
result.msg = "新增任务成功";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var md = _taskBaseInfoRepository.AsQueryable().First(a => a.PK_ID == taskInfo.PK_ID);
|
|
|
|
//回写任务号
|
|
|
|
//回写任务号
|
|
|
|
result.ext = taskInfo.TASK_NO;
|
|
|
|
result.ext = md?.TASK_NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -533,6 +534,35 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 查询订舱表查询用户和租户信息
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
private UserTendDto GetUserTendInfo(string userId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
UserTendDto userTendDto = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//这里因为接口是不做授权验证的,所以这里直接写的动态sql提取了用户和租户信息
|
|
|
|
|
|
|
|
var userTendInfo = _sysUserRepository.EntityContext.Queryable<dynamic>("user").AS("sys_user")
|
|
|
|
|
|
|
|
.AddJoinInfo("sys_tenant", "ten", "user.TenantId=ten.Id")
|
|
|
|
|
|
|
|
.Where("user.Id=@id", new { id = long.Parse(userId) })
|
|
|
|
|
|
|
|
.Select("user.Id as UserId,user.Name as UserName,ten.Id as TendId,ten.Name as TendName").First();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userTendInfo == null || userTendInfo.TendId == null)
|
|
|
|
|
|
|
|
throw Oops.Oh("当前用户详情获取失败,请确认{0}赋值是否准确", nameof(TaskManageOrderMessageInfo.Main.TaskUserId));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userTendDto = new UserTendDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
userId = long.Parse(userTendInfo.UserId.ToString()),
|
|
|
|
|
|
|
|
userName = userTendInfo.UserName.ToString(),
|
|
|
|
|
|
|
|
tendId = long.Parse(userTendInfo.TendId.ToString()),
|
|
|
|
|
|
|
|
tenantName = userTendInfo.TendName.ToString()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return userTendDto;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取查询参数
|
|
|
|
#region 获取查询参数
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取查询参数
|
|
|
|
/// 获取查询参数
|
|
|
@ -4435,12 +4465,75 @@ namespace Myshipping.Application
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1、通过Head.GID检索任务表。
|
|
|
|
|
|
|
|
2、任务不存在提示检索失败。
|
|
|
|
|
|
|
|
3、任务存在判断当前状态已完成、已取消、已挂起不能撤销。
|
|
|
|
|
|
|
|
4、派车任务业务状态是SEND_DISPATCH不能撤销。
|
|
|
|
|
|
|
|
5、更新任务状态、更新派车任务状态。
|
|
|
|
|
|
|
|
6、返回结果
|
|
|
|
|
|
|
|
*/
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var taskInfo = _taskBaseInfoRepository.AsQueryable()
|
|
|
|
|
|
|
|
.First(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(taskInfo == null)
|
|
|
|
|
|
|
|
throw Oops.Oh($"任务不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(new string[] { TaskStatusEnum.Complete.ToString(), TaskStatusEnum.Pending.ToString(),TaskStatusEnum.Pending.ToString() }
|
|
|
|
|
|
|
|
.Contains(taskInfo.STATUS))
|
|
|
|
|
|
|
|
throw Oops.Oh($"任务状态是已完成/已挂起/已取消的不能撤销");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var truckInfo = _taskTruckInfoRepository.AsQueryable().First(a => a.TASK_ID == taskInfo.PK_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (truckInfo == null)
|
|
|
|
|
|
|
|
throw Oops.Oh($"派车任务不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(truckInfo.Status == BookingTruckStatus.SEND_DISPATCH.ToString())
|
|
|
|
|
|
|
|
throw Oops.Oh($"派车任务状态是已派车不能撤销");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
truckInfo.Status = BookingTruckStatus.CANCELED.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserTendDto userTendInfo = GetUserTendInfo(info.Main.TaskUserId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
truckInfo.UpdatedUserId = userTendInfo.userId;
|
|
|
|
|
|
|
|
truckInfo.UpdatedUserName = userTendInfo.userName;
|
|
|
|
|
|
|
|
truckInfo.UpdatedTime = nowDate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新派车任务
|
|
|
|
|
|
|
|
await _taskTruckInfoRepository.AsUpdateable(truckInfo).UpdateColumns(it => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
|
|
|
it.Status,
|
|
|
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
|
|
|
it.UpdatedTime
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskInfo.UpdatedUserId = userTendInfo.userId;
|
|
|
|
|
|
|
|
taskInfo.UpdatedUserName = userTendInfo.userName;
|
|
|
|
|
|
|
|
taskInfo.UpdatedTime = nowDate;
|
|
|
|
|
|
|
|
taskInfo.STATUS = TaskStatusEnum.Cancel.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新任务
|
|
|
|
|
|
|
|
await _taskBaseInfoRepository.AsUpdateable(taskInfo).UpdateColumns(it => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
|
|
|
it.STATUS,
|
|
|
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
|
|
|
it.UpdatedTime
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
|
|
|
result.msg = "撤销成功";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError("撤销任务异常,原因:{error}", ex.Message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"{ex.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|