|
|
using DS.Module.Core;
|
|
|
using DS.Module.Core.Data;
|
|
|
using DS.Module.Core.Helpers;
|
|
|
using DS.Module.SqlSugar;
|
|
|
using DS.Module.UserModule;
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
|
using DS.WMS.Core.TaskPlat.Interface;
|
|
|
using Mapster;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
using SqlSugar;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using DS.Module.Core.Extensions;
|
|
|
using DS.Module.DjyServiceStatus;
|
|
|
using LanguageExt.Common;
|
|
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 任务台-BC子任务
|
|
|
/// </summary>
|
|
|
public class TaskManageBCService : ITaskManageBCService
|
|
|
{
|
|
|
private readonly ILogger<TaskManageBCService> _logger;
|
|
|
private readonly IUser user;
|
|
|
private readonly ISaasDbService saasDbService;
|
|
|
private readonly IServiceProvider serviceProvider;
|
|
|
private readonly IWebHostEnvironment environment;
|
|
|
|
|
|
public TaskManageBCService(ILogger<TaskManageBCService> logger,
|
|
|
ISaasDbService saasDbService,
|
|
|
IServiceProvider serviceProvider,
|
|
|
IUser user,
|
|
|
IWebHostEnvironment environment)
|
|
|
{
|
|
|
_logger = logger;
|
|
|
this.saasDbService = saasDbService;
|
|
|
this.serviceProvider = serviceProvider;
|
|
|
this.user = user;
|
|
|
this.environment = environment;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 通过任务主键获取BC详情
|
|
|
/// </summary>
|
|
|
/// <param name="taskId">BC任务主键</param>
|
|
|
public async Task<DataResult<TaskManageOrderResultDto>> GetInfoByTaskId(long taskId)
|
|
|
{
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
try
|
|
|
{
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
var taskBase = await tenantDb.Queryable<TaskBaseInfo>().FirstAsync(a => a.Id == taskId);
|
|
|
|
|
|
if (taskBase == null)
|
|
|
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskBaseEmpty)));
|
|
|
|
|
|
var bcOrder = await tenantDb.Queryable<TaskBCInfo>().FirstAsync(a => a.TASK_ID == taskId);
|
|
|
|
|
|
if (bcOrder == null)
|
|
|
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskBCInfoEmpty)));
|
|
|
|
|
|
var bcCtnList = await tenantDb.Queryable<TaskBCCTNInfo>().ToListAsync(a => a.P_ID == bcOrder.Id);
|
|
|
|
|
|
TaskBCShowBaseDto model = bcOrder.Adapt<TaskBCShowBaseDto>();
|
|
|
|
|
|
if (bcCtnList.Count > 0)
|
|
|
model.CtnList = bcCtnList.Adapt<List<TaskBCCTNInfoDto>>();
|
|
|
|
|
|
var fileList = await tenantDb.Queryable <TaskFileInfo>().Where(a => a.TASK_PKID == bcOrder.TASK_ID).ToListAsync();
|
|
|
|
|
|
if (fileList.Count > 0)
|
|
|
model.FileList = fileList.Adapt<List<TaskFileDto>>();
|
|
|
|
|
|
model.taskStatus = taskBase.STATUS;
|
|
|
|
|
|
//生成关键信息
|
|
|
#region 生成关键信息
|
|
|
model.Keywords = new List<TaskBCShowBaseKeywordDto>();
|
|
|
|
|
|
if (bcOrder.CARRIAGE_TYPE == "DIRECT_SHIP")
|
|
|
{
|
|
|
model.Keywords.Add(new TaskBCShowBaseKeywordDto() { Name = $"承运方式:{bcOrder.CARRIAGE_TYPE_NAME}", Background = "#FFFF80", Icon = "icon-yunshu1" });
|
|
|
}
|
|
|
else if (bcOrder.CARRIAGE_TYPE == "TRANSFER_SHIP")
|
|
|
{
|
|
|
model.Keywords.Add(new TaskBCShowBaseKeywordDto() { Name = $"承运方式:{bcOrder.CARRIAGE_TYPE_NAME}", Background = "#CAF982", Icon = "icon-shuaxin" });
|
|
|
}
|
|
|
|
|
|
if (bcOrder.BOOKING_SLOT_TYPE == "CONTRACT_ORDER")
|
|
|
{
|
|
|
model.Keywords.Add(new TaskBCShowBaseKeywordDto() { Name = $"订舱方式:{bcOrder.BOOKING_SLOT_TYPE_NAME}", Background = "#81D3F8", Icon = "icon-touzijilu" });
|
|
|
}
|
|
|
else if (bcOrder.BOOKING_SLOT_TYPE == "SPOT_ORDER")
|
|
|
{
|
|
|
model.Keywords.Add(new TaskBCShowBaseKeywordDto() { Name = $"订舱方式:{bcOrder.BOOKING_SLOT_TYPE_NAME}", Background = "#FACD91", Icon = "icon-beizhu1" });
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
result.succ = true;
|
|
|
result.ext = model;
|
|
|
|
|
|
//如果当前BC有对应记录,则读取订舱详情
|
|
|
//0726:经确认页面上没有用到订舱详情,所以暂时不返回
|
|
|
//if (bcOrder.BOOKING_ORDER_ID.HasValue)
|
|
|
//{
|
|
|
// var bkOrder = await _bookingOrderRepository.AsQueryable().
|
|
|
// FirstAsync(a => a.Id == bcOrder.BOOKING_ORDER_ID.Value);
|
|
|
|
|
|
// if (bkOrder != null)
|
|
|
// {
|
|
|
// var showBKOrder = bkOrder.Adapt<BookingOrderOutput>();
|
|
|
|
|
|
// var ctnList = await _bookingCtnRepository.AsQueryable().
|
|
|
// Where(a => a.BILLID == bkOrder.Id).ToListAsync();
|
|
|
|
|
|
// if (ctnList.Count > 0)
|
|
|
// showBKOrder.ctnInputs = ctnList.Adapt<List<BookingCtnDto>>();
|
|
|
|
|
|
// result.ext2 = showBKOrder;
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result.succ = false;
|
|
|
result.msg = $"获取BC详情异常,原因:{ex.Message}";
|
|
|
}
|
|
|
|
|
|
return DataResult<TaskManageOrderResultDto>.Success(result);
|
|
|
}
|
|
|
}
|
|
|
}
|