|
|
|
@ -207,10 +207,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
public async Task<DataResult> InitTaskJob(TaskManageOrderMessageInfo info, IFormFile file = null, IFormFile modifyFile = null)
|
|
|
|
|
{
|
|
|
|
|
string batchNo = Guid.NewGuid().ToString();
|
|
|
|
|
//var a = user.UserId;
|
|
|
|
|
//var b = user.UserName;
|
|
|
|
|
//var c = user.TenantId;
|
|
|
|
|
//var d = user.OrgId;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, JsonConvert.SerializeObject(info));
|
|
|
|
@ -223,15 +220,19 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
if (info.Head.BSNO is not null or 0)
|
|
|
|
|
{
|
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(t => t.OUT_BS_NO == info.Head.BSNO)
|
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == info.Main.TaskType.ToString())
|
|
|
|
|
.OrderByDescending(a => a.CreateTime)
|
|
|
|
|
.FirstAsync(t => t.OUT_BS_NO == info.Head.BSNO);
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
// 否则通过Head.GID进行判断
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
taskInfo = await tenantDb.Queryable<TaskBaseInfo>()
|
|
|
|
|
.Where(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}")
|
|
|
|
|
.WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == info.Main.TaskType.ToString())
|
|
|
|
|
.OrderByDescending(a => a.CreateTime)
|
|
|
|
|
.FirstAsync(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}");
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1845,5 +1846,126 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
//var sql = queryable.Select<dynamic>(t => t).Distinct().ToSqlString();
|
|
|
|
|
//.WhereIF(taskStatLevel == TaskStatLevelEnum.EXCPTION, (t, a) => t.IS_EXCEPT == 1)
|
|
|
|
|
}
|
|
|
|
|
#region 任务分配相关
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务分配保存列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="carrierId">船公司Id(可选)</param>
|
|
|
|
|
public async Task<DataResult<List<TaskAllocationtSet>>> GetTaskAllocationSettingList(long? carrierId)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
var list = await tenantDb.Queryable<TaskAllocationtSet>()
|
|
|
|
|
.WhereIF(carrierId != null, x => x.CarrierId == carrierId)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
return DataResult<List<TaskAllocationtSet>>.Success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务分配表中已存在的船公司列表(用于查询)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<DataResult<List<CarrierInfoDto>>> GetTaskAllocationSettingCarrierList()
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
var carrierList = await tenantDb.Queryable<TaskAllocationtSet>().Select(x => new CarrierInfoDto()
|
|
|
|
|
{
|
|
|
|
|
CarrierId = x.CarrierId,
|
|
|
|
|
Carrier = x.Carrier,
|
|
|
|
|
CarrierCode = x.CarrierCode
|
|
|
|
|
}).Distinct().ToListAsync();
|
|
|
|
|
|
|
|
|
|
return DataResult<List<CarrierInfoDto>>.Success(carrierList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存任务分配设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<DataResult> SaveTaskAllocationSetting(SaveTaskAllocationSettingDto saveDto)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(saveDto.CarrierCode))
|
|
|
|
|
{
|
|
|
|
|
saveDto.CarrierCode = null;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(saveDto.Carrier))
|
|
|
|
|
{
|
|
|
|
|
saveDto.Carrier = null;
|
|
|
|
|
}
|
|
|
|
|
if (saveDto.CarrierId == 0)
|
|
|
|
|
{
|
|
|
|
|
saveDto.CarrierId = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fieldName = saveDto.AllocationTargetCode switch
|
|
|
|
|
{
|
|
|
|
|
"Operator" => nameof(TaskAllocationtSet.IsAllotOperator),
|
|
|
|
|
"VouchingClerk" => nameof(TaskAllocationtSet.IsAllotVouchingClerk),
|
|
|
|
|
"Sale" => nameof(TaskAllocationtSet.IsAllotSale),
|
|
|
|
|
"Custom" => nameof(TaskAllocationtSet.IsAllotCustom),
|
|
|
|
|
"FinancialStaff" => nameof(TaskAllocationtSet.IsAllotFinancialStaff),
|
|
|
|
|
"CustomerService" => nameof(TaskAllocationtSet.IsAllotCustomerService),
|
|
|
|
|
"Driver" => nameof(TaskAllocationtSet.IsAllotDriver),
|
|
|
|
|
"Dispatcher" => nameof(TaskAllocationtSet.IsAllotDispatcher),
|
|
|
|
|
_ => throw new NotImplementedException(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 先查出来已有的、指定船公司的配置
|
|
|
|
|
var oldSettingList = await tenantDb.Queryable<TaskAllocationtSet>().Where(x => x.CarrierId == saveDto.CarrierId).Select(x => new { x.Id, x.TaskTypeCode }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var oldSettingIdList = oldSettingList.Select(x => x.Id);
|
|
|
|
|
var oldSettingTypeCodeList = oldSettingList.Select(x => x.TaskTypeCode);
|
|
|
|
|
|
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
// 将原有的状态设置为未分配
|
|
|
|
|
await tenantDb.Updateable<TaskAllocationtSet>()
|
|
|
|
|
.SetColumns(fieldName, false)
|
|
|
|
|
.Where(x => oldSettingIdList.Contains(x.Id))
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// 补充缺少的任务类型
|
|
|
|
|
if (saveDto.TaskTypeList?.Any() == true)
|
|
|
|
|
{
|
|
|
|
|
var waitAddTypeCodeList = saveDto.TaskTypeList.Select(x => x.TaskTypeCode).Except(oldSettingTypeCodeList).ToList();
|
|
|
|
|
|
|
|
|
|
if (waitAddTypeCodeList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
waitAddTypeCodeList.Select(x => new TaskAllocationtSet()
|
|
|
|
|
{
|
|
|
|
|
CarrierId = saveDto.CarrierId,
|
|
|
|
|
Carrier = saveDto.Carrier,
|
|
|
|
|
CarrierCode = saveDto.CarrierCode,
|
|
|
|
|
TaskTypeCode = x,
|
|
|
|
|
TaskTypeName = saveDto.TaskTypeList.First(t => t.TaskTypeCode == x).TaskTypeName,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await tenantDb.Insertable(waitAddTypeCodeList).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var setTaskCodeList = saveDto.TaskTypeList.Select(x => x.TaskTypeCode);
|
|
|
|
|
|
|
|
|
|
// 更新指定船公司的配置
|
|
|
|
|
await tenantDb.Updateable<TaskAllocationtSet>()
|
|
|
|
|
.SetColumns(fieldName, true)
|
|
|
|
|
.Where(x => x.CarrierId == saveDto.CarrierId && setTaskCodeList.Contains(x.TaskTypeCode))
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await tenantDb.Ado.CommitTranAsync();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await tenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
logger.LogError(ex, "保存任务分配设置异常");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataUpdateSuccess)));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|