You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
5.5 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DS.Module.Core;
using DS.Module.DjyServiceStatus;
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.Extensions.Logging;
namespace DS.WMS.Core.TaskPlat.Method
{
/// <summary>
/// 任务台-BC子任务
/// </summary>
public class TaskManageBCService : TaskManageBaseService<TaskManageBCService>, ITaskManageBCService
{
public TaskManageBCService(IUser user,
ILogger<TaskManageBCService> logger,
ISaasDbService saasDbService,
IServiceProvider serviceProvider,
IWebHostEnvironment environment)
: base(user, logger, saasDbService, serviceProvider, 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>().Where(a => a.P_ID == bcOrder.Id).ToListAsync();
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
//await SetTaskStatus([taskId], x => x.IS_PUBLIC == 1, x => x.IS_EXCEPT == 0);
//await SetTaskOwner([taskId], new List<RecvUserInfo>()
//{
// new RecvUserInfo(111,"231312321"),
// new RecvUserInfo(222,"affsdfdsf"),
//});
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);
}
//public virtual async Task<(bool canCompelete, string? msg)> CompleteAsync(long taskId)
//{
// return (true, null);
//}
}
}