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.
220 lines
8.5 KiB
C#
220 lines
8.5 KiB
C#
using Furion.DynamicApiController;
|
|
using Furion.FriendlyException;
|
|
using Furion.JsonSerialization;
|
|
using ICSharpCode.SharpZipLib.Zip;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using Myshipping.Application.Entity;
|
|
using Myshipping.Core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Myshipping.Application
|
|
{
|
|
/// <summary>
|
|
/// 截单回执
|
|
/// </summary>
|
|
[ApiDescriptionSettings("Application", Name = "TaskManageSISubmitted", Order = 10)]
|
|
public class TaskManageSISubmittedService : ITaskManageSISubmittedService, IDynamicApiController
|
|
{
|
|
private readonly SqlSugarRepository<TaskSISubmitted> _taskSISubmittedRepository;
|
|
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
private readonly ILogger<TaskManageSISubmittedService> _logger;
|
|
private readonly IBookingValueAddedService _bookingValueAddedService;
|
|
|
|
public TaskManageSISubmittedService(ILogger<TaskManageSISubmittedService> logger,
|
|
SqlSugarRepository<TaskSISubmitted> taskSISubmittedRepository,
|
|
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository,
|
|
IBookingValueAddedService bookingValueAddedService)
|
|
{
|
|
_logger = logger;
|
|
_taskSISubmittedRepository = taskSISubmittedRepository;
|
|
_taskBaseRepository = taskBaseRepository;
|
|
_bookingOrderRepository = bookingOrderRepository;
|
|
_bookingValueAddedService = bookingValueAddedService;
|
|
}
|
|
|
|
#region 获取截单回执详情
|
|
/// <summary>
|
|
/// 获取截单回执详情
|
|
/// </summary>
|
|
/// <param name="pkId">截单回执主键</param>
|
|
/// <returns>返回回执</returns>
|
|
[HttpGet("/TaskManageSISubmitted/GetInfo")]
|
|
public async Task<TaskSISubmittedShowDto> GetInfo(string pkId)
|
|
{
|
|
TaskSISubmittedShowDto dto = new TaskSISubmittedShowDto();
|
|
|
|
var siSubmitted = _taskSISubmittedRepository.AsQueryable().First(a => a.PK_ID == pkId);
|
|
|
|
if (siSubmitted == null)
|
|
throw Oops.Oh($"截单回执主键{pkId}无法获取业务信息");
|
|
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == siSubmitted.TASK_ID);
|
|
|
|
if (taskBase == null)
|
|
throw Oops.Oh($"任务主键无法获取业务信息");
|
|
|
|
dto = siSubmitted.Adapt<TaskSISubmittedShowDto>();
|
|
|
|
if (dto != null)
|
|
{
|
|
dto.IsComplete = taskBase.IS_COMPLETE == 1 ? true : false;
|
|
dto.CompleteTime = taskBase.COMPLETE_DATE;
|
|
}
|
|
|
|
return dto;
|
|
}
|
|
#endregion
|
|
|
|
#region 通过任务主键获取截单回执详情
|
|
/// <summary>
|
|
/// 通过任务主键获取截单回执详情
|
|
/// </summary>
|
|
/// <param name="taskPkId">截单回执任务主键</param>
|
|
/// <returns>返回回执</returns>
|
|
[HttpGet("/TaskManageSISubmitted/GetInfoByTaskId")]
|
|
public async Task<TaskSISubmittedShowDto> GetInfoByTaskId(string taskPkId)
|
|
{
|
|
TaskSISubmittedShowDto dto = new TaskSISubmittedShowDto();
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
|
|
|
|
if (taskBase == null)
|
|
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
|
|
|
|
var siSubmitted = _taskSISubmittedRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
|
|
|
|
if (siSubmitted == null)
|
|
throw Oops.Oh($"截单回执主键{taskPkId}无法获取业务信息");
|
|
|
|
dto = siSubmitted.Adapt<TaskSISubmittedShowDto>();
|
|
|
|
if (dto != null)
|
|
{
|
|
dto.IsComplete = taskBase.IS_COMPLETE == 1 ? true : false;
|
|
dto.CompleteTime = taskBase.COMPLETE_DATE;
|
|
}
|
|
|
|
return dto;
|
|
}
|
|
#endregion
|
|
|
|
#region 同步更新订舱订单的截单状态
|
|
/// <summary>
|
|
/// 同步更新订舱订单的截单状态
|
|
/// </summary>
|
|
/// <param name="taskPkId">截单回执任务主键</param>
|
|
/// <returns>返回回执</returns>
|
|
[HttpGet("/TaskManageSISubmitted/SyncBookingSIStatus")]
|
|
public async Task<TaskManageOrderResultDto> SyncBookingSIStatus(string taskPkId)
|
|
{
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
|
|
|
|
if (taskBase == null)
|
|
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
|
|
|
|
var siSubmitted = _taskSISubmittedRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
|
|
|
|
if (siSubmitted == null)
|
|
throw Oops.Oh($"截单回执主键{taskPkId}无法获取业务信息");
|
|
|
|
if(!siSubmitted.BOOKING_ID.HasValue|| siSubmitted.BOOKING_ID.Value < 1)
|
|
throw Oops.Oh($"当前截单回执未匹配到对应的订舱订单,请重对应截单");
|
|
|
|
var bookingOrder = _bookingOrderRepository.AsQueryable()
|
|
.FirstAsync(a => a.Id == siSubmitted.BOOKING_ID.Value);
|
|
|
|
if (bookingOrder == null)
|
|
throw Oops.Oh($"订舱订单信息获取失败");
|
|
|
|
//推送截单货物状态
|
|
var pushModel = new ModifyServiceProjectStatusDto
|
|
{
|
|
BookingId = bookingOrder.Id,
|
|
SourceType = TrackingSourceTypeEnum.AUTO,
|
|
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
|
|
new ModifyServiceProjectStatusDetailDto { StatusCode = "JD" } }
|
|
};
|
|
|
|
if (siSubmitted.NOTICE_DATE.HasValue)
|
|
{
|
|
pushModel.StatusCodes[0].SetActDate = siSubmitted.NOTICE_DATE.Value;
|
|
}
|
|
|
|
var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(pushModel);
|
|
|
|
_logger.LogInformation("请求JSON={json} 异步推送服务状态[JD 截单]完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt));
|
|
|
|
result.succ = true;
|
|
result.msg = "成功";
|
|
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 重新处理截单任务
|
|
/// <summary>
|
|
/// 重新处理截单任务
|
|
/// 对未匹配订舱订单的任务记录重新对应订单订单
|
|
/// </summary>
|
|
/// <param name="taskPkId">截单回执任务主键</param>
|
|
/// <returns>返回回执</returns>
|
|
[HttpGet("/TaskManageSISubmitted/SearchAndConnectBookingInfo")]
|
|
public async Task<TaskManageOrderResultDto> SearchAndConnectBookingInfo(string taskPkId)
|
|
{
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
|
|
|
|
if (taskBase == null)
|
|
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
|
|
|
|
var siSubmitted = _taskSISubmittedRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
|
|
|
|
if (siSubmitted == null)
|
|
throw Oops.Oh($"截单回执主键{taskPkId}无法获取业务信息");
|
|
|
|
if (siSubmitted.BOOKING_ID.HasValue)
|
|
throw Oops.Oh($"当前截单回执已有匹配的订舱订单");
|
|
|
|
string mblNo = siSubmitted.MBL_NO.ToUpper().Trim();
|
|
|
|
var bookingInfo = _bookingOrderRepository.AsQueryable().Filter(null, true)
|
|
.FirstAsync(a => a.MBLNO == mblNo && a.IsDeleted == false && (a.ParentId == null || a.ParentId == 0));
|
|
|
|
if(bookingInfo == null)
|
|
throw Oops.Oh($"提单号{mblNo}未提取有效的订舱订单");
|
|
|
|
siSubmitted.BOOKING_ID = bookingInfo.Id;
|
|
siSubmitted.UpdatedUserId = UserManager.UserId;
|
|
siSubmitted.UpdatedUserName = UserManager.Name;
|
|
|
|
//更新任务BC
|
|
await _taskSISubmittedRepository.AsUpdateable(siSubmitted).UpdateColumns(it => new
|
|
{
|
|
it.BOOKING_ID,
|
|
it.UpdatedTime,
|
|
it.UpdatedUserId,
|
|
it.UpdatedUserName
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
result.succ = true;
|
|
result.msg = "成功";
|
|
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|