|
|
@ -1,16 +1,22 @@
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
using Furion;
|
|
|
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
using Myshipping.Core;
|
|
|
|
using Myshipping.Core;
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
namespace Myshipping.Application
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -27,16 +33,22 @@ namespace Myshipping.Application
|
|
|
|
private readonly SqlSugarRepository<TaskBCCTNInfo> _taskBCCTNInfoRepository;
|
|
|
|
private readonly SqlSugarRepository<TaskBCCTNInfo> _taskBCCTNInfoRepository;
|
|
|
|
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
|
|
|
|
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
|
|
|
|
private readonly SqlSugarRepository<TaskFileInfo> _taskFileRepository;
|
|
|
|
private readonly SqlSugarRepository<TaskFileInfo> _taskFileRepository;
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _bookingCtnRepository;
|
|
|
|
|
|
|
|
|
|
|
|
public TaskManageBCService(SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
|
|
|
|
public TaskManageBCService(SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
|
|
|
|
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
|
|
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
|
|
SqlSugarRepository<TaskBCCTNInfo> taskBCCTNInfoRepository,
|
|
|
|
SqlSugarRepository<TaskBCCTNInfo> taskBCCTNInfoRepository,
|
|
|
|
SqlSugarRepository<TaskFileInfo> taskFileRepository)
|
|
|
|
SqlSugarRepository<TaskFileInfo> taskFileRepository,
|
|
|
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository,
|
|
|
|
|
|
|
|
SqlSugarRepository<BookingCtn> bookingCtnRepository)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_taskBaseRepository = taskBaseRepository;
|
|
|
|
_taskBaseRepository = taskBaseRepository;
|
|
|
|
_taskBCInfoRepository = taskBCInfoRepository;
|
|
|
|
_taskBCInfoRepository = taskBCInfoRepository;
|
|
|
|
_taskBCCTNInfoRepository = taskBCCTNInfoRepository;
|
|
|
|
_taskBCCTNInfoRepository = taskBCCTNInfoRepository;
|
|
|
|
_taskFileRepository = taskFileRepository;
|
|
|
|
_taskFileRepository = taskFileRepository;
|
|
|
|
|
|
|
|
_bookingOrderRepository = bookingOrderRepository;
|
|
|
|
|
|
|
|
_bookingCtnRepository = bookingCtnRepository;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取BC详情
|
|
|
|
#region 获取BC详情
|
|
|
@ -73,11 +85,31 @@ namespace Myshipping.Application
|
|
|
|
result.succ = true;
|
|
|
|
result.succ = true;
|
|
|
|
result.ext = model;
|
|
|
|
result.ext = model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前BC有对应记录,则读取订舱详情
|
|
|
|
|
|
|
|
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)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result.succ = false;
|
|
|
|
result.succ = false;
|
|
|
|
result.msg = $"获取派车详情异常,原因:{ex.Message}";
|
|
|
|
result.msg = $"获取BC详情异常,原因:{ex.Message}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
@ -119,18 +151,113 @@ namespace Myshipping.Application
|
|
|
|
if (fileList.Count > 0)
|
|
|
|
if (fileList.Count > 0)
|
|
|
|
model.FileList = fileList.Adapt<List<TaskFileDto>>();
|
|
|
|
model.FileList = fileList.Adapt<List<TaskFileDto>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
result.succ = true;
|
|
|
|
result.ext = model;
|
|
|
|
result.ext = model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前BC有对应记录,则读取订舱详情
|
|
|
|
|
|
|
|
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)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result.succ = false;
|
|
|
|
result.succ = false;
|
|
|
|
result.msg = $"获取派车详情异常,原因:{ex.Message}";
|
|
|
|
result.msg = $"获取BC详情异常,原因:{ex.Message}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 获取待处理的BC任务(来自邮件解析需要对应订舱,系统会根据用户的订舱台账预配)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GetToDoBCList()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1、优先匹配提单号一致的
|
|
|
|
|
|
|
|
2、判断船名航次一致的
|
|
|
|
|
|
|
|
3、
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//获取所有待处理的BC任务
|
|
|
|
|
|
|
|
var taskList = await _taskBCInfoRepository.AsQueryable().InnerJoin<TaskBCInfo>((a,b)=>a.TASK_ID == b.PK_ID)
|
|
|
|
|
|
|
|
.Where((a, b)=> !a.BOOKING_ORDER_ID.HasValue && b.STATUS == TaskStatusEnum.Create.ToString())
|
|
|
|
|
|
|
|
.Select((a,b)=>new { BC = a,TSK = b }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (taskList.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"获取派车详情异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 任务ID下载附件
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="taskPKId">BC任务主键</param>
|
|
|
|
|
|
|
|
/// <returns>返回数据流</returns>
|
|
|
|
|
|
|
|
[HttpGet("/TaskManageBC/DownloadFile")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> DownloadFile(string taskPKId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
|
|
|
|
|
|
|
|
if (bcTaskInfo == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileInfo = await _taskFileRepository.AsQueryable().FirstAsync(u => u.TASK_PKID == taskPKId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fileInfo == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId}没有可下载的附件");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileFullPath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
|
|
|
|
|
|
|
|
if (!File.Exists(fileFullPath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId} 附件下载请求失败,请确认文件是否存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode(fileInfo.FILE_NAME, Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
|
|
|
var result = new FileStreamResult(new FileStream(fileFullPath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|