|
|
|
@ -1,7 +1,15 @@
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
|
|
using NPOI.XWPF.UserModel;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
@ -19,29 +27,221 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly ILogger<TaskManageRollingNominationService> _logger;
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskRollingNominationInfo> _taskRollingNominationInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskRollingNominationShipInfo> _taskRollingNominationShipInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskRollingNominationDetailInfo> _taskRollingNominationDetailInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskRollingNominationDispatchInfo> _taskRollingNominationDispatchInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskShareLinkInfo> _taskShareLinkInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _bookingCtnRepository;
|
|
|
|
|
|
|
|
|
|
public TaskManageRollingNominationService(SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
|
|
|
SqlSugarRepository<TaskRollingNominationInfo> taskRollingNominationInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskRollingNominationDetailInfo> taskRollingNominationDetailInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskRollingNominationDispatchInfo> taskRollingNominationDispatchInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskRollingNominationShipInfo> taskRollingNominationShipInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskShareLinkInfo> taskShareLinkInfoRepository,
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository,
|
|
|
|
|
SqlSugarRepository<BookingCtn> bookingCtnRepository)
|
|
|
|
|
{
|
|
|
|
|
_taskBaseRepository = taskBaseRepository;
|
|
|
|
|
_taskRollingNominationInfoRepository = taskRollingNominationInfoRepository;
|
|
|
|
|
_taskRollingNominationDetailInfoRepository = taskRollingNominationDetailInfoRepository;
|
|
|
|
|
_taskRollingNominationDispatchInfoRepository = taskRollingNominationDispatchInfoRepository;
|
|
|
|
|
_taskRollingNominationShipInfoRepository = taskRollingNominationShipInfoRepository;
|
|
|
|
|
_taskShareLinkInfoRepository = taskShareLinkInfoRepository;
|
|
|
|
|
_bookingOrderRepository = bookingOrderRepository;
|
|
|
|
|
_bookingCtnRepository = bookingCtnRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 获取预甩详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取预甩详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pkId">预甩主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GetInfo(string pkId)
|
|
|
|
|
[HttpGet("/TaskManageRollingNomination/GetInfo")]
|
|
|
|
|
public async Task<TaskRollingNominationShowDto> GetInfo(string pkId)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
TaskRollingNominationShowDto model = null;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var rollModel = _taskRollingNominationInfoRepository.AsQueryable()
|
|
|
|
|
.First(a => a.PK_ID == pkId && !a.IsDeleted);
|
|
|
|
|
|
|
|
|
|
if (rollModel == null)
|
|
|
|
|
throw Oops.Oh($"预甩货主键{pkId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
model = await InnerGetInfo(rollModel);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"获取预甩详情异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 通过任务主键获取预甩详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过任务主键获取预甩详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskPkId">预甩任务主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GetInfoByTaskId(string taskPkId)
|
|
|
|
|
[HttpGet("/TaskManageRollingNomination/GetInfoByTaskId")]
|
|
|
|
|
public async Task<TaskRollingNominationShowDto> GetInfoByTaskId(string taskPkId)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
TaskRollingNominationShowDto model = null;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId && !a.IsDeleted);
|
|
|
|
|
|
|
|
|
|
if (taskBase == null)
|
|
|
|
|
throw Oops.Oh($"预甩货任务主键{taskPkId}无法获取任务信息");
|
|
|
|
|
|
|
|
|
|
var rollModel = _taskRollingNominationInfoRepository.AsQueryable()
|
|
|
|
|
.First(a => a.TASK_ID == taskBase.PK_ID && !a.IsDeleted);
|
|
|
|
|
|
|
|
|
|
if (rollModel == null)
|
|
|
|
|
throw Oops.Oh($"预甩货任务主键{taskBase.PK_ID}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
model = await InnerGetInfo(rollModel);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"获取预甩详情异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取预甩详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取预甩详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="rollModel">预甩货详情实体类</param>
|
|
|
|
|
/// <returns>返回详情</returns>
|
|
|
|
|
private async Task<TaskRollingNominationShowDto> InnerGetInfo(TaskRollingNominationInfo rollModel)
|
|
|
|
|
{
|
|
|
|
|
TaskRollingNominationShowDto model = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<string> rollingPlanList = new List<string>();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(rollModel.PLAN_TXT))
|
|
|
|
|
{
|
|
|
|
|
rollingPlanList = rollModel.PLAN_TXT.Split("\\n").ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model = new TaskRollingNominationShowDto
|
|
|
|
|
{
|
|
|
|
|
PlanType = rollModel.PLAN_TYPE,
|
|
|
|
|
CarrierId = rollModel.CARRIERID,
|
|
|
|
|
Carrier = rollModel.CARRIER,
|
|
|
|
|
ConfirmDeadLine = rollModel.CONFIRM_DEAD_LINE,
|
|
|
|
|
CreateTime = rollModel.READ_CREATE_TIME,
|
|
|
|
|
RollingTouchDoubleRollRemark = rollModel.ROLL_DOUBLE_REMARK,
|
|
|
|
|
LoadDetailList = new List<TaskRollingNominationShipDetailShowDto>(),
|
|
|
|
|
RollingPlanList = rollingPlanList,
|
|
|
|
|
PreBillList = new List<TaskRollingNominationShipPreBillShowDto>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var shipList = _taskRollingNominationShipInfoRepository.AsQueryable()
|
|
|
|
|
.Where(a => a.NOM_ID == rollModel.PK_ID && a.GROUP_INDX == 1 && !a.IsDeleted).ToList();
|
|
|
|
|
|
|
|
|
|
var fromEntity = shipList.FirstOrDefault(a =>
|
|
|
|
|
a.SHIP_TYPE.Equals("From", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (fromEntity != null)
|
|
|
|
|
model.From = fromEntity.Adapt<TaskRollingNominationShipDto>();
|
|
|
|
|
|
|
|
|
|
var toEntity = shipList.FirstOrDefault(a =>
|
|
|
|
|
a.SHIP_TYPE.Equals("To", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (toEntity != null)
|
|
|
|
|
model.To = toEntity.Adapt<TaskRollingNominationShipDto>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
|
.Where((detail, dispatch) => detail.NOM_ID == rollModel.PK_ID && detail.IsDeleted == false
|
|
|
|
|
&& (string.IsNullOrWhiteSpace(dispatch.PK_ID) || (!string.IsNullOrWhiteSpace(dispatch.PK_ID) && dispatch.IsDeleted == false)))
|
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
model.PreBillList = withDispatchList.Where(a=>
|
|
|
|
|
a.Dispatch != null || (a.Dispatch == null && !a.Detail.NOM_STATUS_NOTE.Equals("Load",StringComparison.OrdinalIgnoreCase)))
|
|
|
|
|
.GroupBy(a => a.Detail.CUSTOMERID)
|
|
|
|
|
.SelectMany((a,idx) => {
|
|
|
|
|
var cArg = a.ToList();
|
|
|
|
|
|
|
|
|
|
return a.GroupBy(b=> b.Detail.SHIPMENT).Select(
|
|
|
|
|
b => {
|
|
|
|
|
|
|
|
|
|
var preBillArg = b.ToList();
|
|
|
|
|
|
|
|
|
|
var preBillDetail = preBillArg.FirstOrDefault().Detail;
|
|
|
|
|
var preBillDispatch = preBillArg.FirstOrDefault().Dispatch;
|
|
|
|
|
|
|
|
|
|
string ctnStat = string.Join(",", preBillArg.GroupBy(x => x.Detail.CTNALL)
|
|
|
|
|
.Select(x =>
|
|
|
|
|
$"{x.Key}*{x.Sum(t => t.Detail.CTNNUM)}").ToArray());
|
|
|
|
|
|
|
|
|
|
TaskRollingNominationShipPreBillShowDto preBillInfo = new TaskRollingNominationShipPreBillShowDto
|
|
|
|
|
{
|
|
|
|
|
Bookedby = preBillDetail.BOOKED_BY,
|
|
|
|
|
ConfirmDate = preBillDispatch?.CONFIRM_DATE,
|
|
|
|
|
ConfirmDeadLine = preBillDispatch?.CONFIRM_DEAD_LINE,
|
|
|
|
|
CtnStat = ctnStat,
|
|
|
|
|
CustomerId = preBillDetail.CUSTOMERID,
|
|
|
|
|
CustomerName = preBillDetail.CUSTOMERNAME,
|
|
|
|
|
ContractualName = preBillDetail.CONTRACTUAL_NAME,
|
|
|
|
|
CreateShareLinkDate = preBillDispatch?.CREATE_SHARE_LINK_DATE,
|
|
|
|
|
DischargePortName = preBillDetail.DISCHARGEPORT_NAME,
|
|
|
|
|
IsSend = preBillDispatch != null ? preBillDispatch.IS_SEND : false,
|
|
|
|
|
IsUserManual = preBillDispatch != null ? preBillDispatch.IS_USER_MANUAL : false,
|
|
|
|
|
LoadPortName = preBillDetail.LOADPORT_NAME,
|
|
|
|
|
PlaceOfDelivery = preBillDetail.PLACEOF_DELIVERY,
|
|
|
|
|
PlaceOfReceipt = preBillDetail.PLACEOF_RECEIPT,
|
|
|
|
|
Shipment = preBillDetail.SHIPMENT,
|
|
|
|
|
Status = preBillDispatch?.STATUS,
|
|
|
|
|
ShareLinkKey = preBillDispatch?.SHARE_LINK_KEY,
|
|
|
|
|
UserOpinion = preBillDispatch?.USER_OPINION,
|
|
|
|
|
UserOpinionTxt = preBillDispatch?.USER_OPINION_TXT,
|
|
|
|
|
BatchId = preBillDispatch?.BATCH_ID,
|
|
|
|
|
BookingId = preBillDetail.BOOKING_ID,
|
|
|
|
|
GroupName = $"CUST_{idx + 1}",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return preBillInfo;
|
|
|
|
|
}).ToList();
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
if(withDispatchList.Any(a=>a.Dispatch == null
|
|
|
|
|
&& a.Detail.NOM_STATUS_NOTE.Equals("Load", StringComparison.OrdinalIgnoreCase)))
|
|
|
|
|
{
|
|
|
|
|
model.LoadDetailList = withDispatchList.Where(a => a.Dispatch == null
|
|
|
|
|
&& a.Detail.NOM_STATUS_NOTE.Equals("Load", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.Select(a => a.Detail.Adapt<TaskRollingNominationShipDetailShowDto>()).ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"获取预甩详情异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成预甩货客户访问链接
|
|
|
|
|