修改VGM比较

optimize
jianghaiqing 2 years ago
parent d8101c1233
commit 881df3dced

@ -387,6 +387,39 @@ namespace Myshipping.Application
.Map(dest => dest.CBM, src => src.CBM) .Map(dest => dest.CBM, src => src.CBM)
.Map(dest => dest.ContaType, src => src.CONTA_TYPE) .Map(dest => dest.ContaType, src => src.CONTA_TYPE)
.Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME); .Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME);
config.ForType<TaskVGMFeedBackInfo, TaskVGMFeedBackDto>()
.Map(dest => dest.ContaNo, src => src.CONTA_NO)
.Map(dest => dest.SealNo, src => src.SEAL_NO)
.Map(dest => dest.ContaType, src => src.CONTA_TYPE)
.Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME)
.Map(dest => dest.KGS, src => src.KGS)
.Map(dest => dest.TareWeight, src => src.TAREWEIGHT)
.Map(dest => dest.WeighKGs, src => src.WEIGHKGS)
.Map(dest => dest.WeighType, src => src.WEIGHTYPE);
config.ForType<TaskVGMFeedBackInfo, TaskVgmCompareDto>()
.Map(dest => dest.ContaNo, src => src.CONTA_NO)
.Map(dest => dest.SealNo, src => src.SEAL_NO)
.Map(dest => dest.ContaType, src => src.CONTA_TYPE)
.Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME)
.Map(dest => dest.KGS, src => src.KGS)
.Map(dest => dest.TareWeight, src => src.TAREWEIGHT)
.Map(dest => dest.WeighKGs, src => src.WEIGHKGS)
.Map(dest => dest.WeighType, src => src.WEIGHTYPE);
config.ForType<BookingCtn, TaskVgmCompareDto>()
.Map(dest => dest.ContaNo, src => src.CNTRNO)
.Map(dest => dest.SealNo, src => src.SEALNO)
.Map(dest => dest.ContaType, src => src.CTNCODE)
.Map(dest => dest.ContaTypeName, src => src.CTNALL)
.Map(dest => dest.KGS, src => src.KGS)
.Map(dest => dest.TareWeight, src => src.TAREWEIGHT)
.Map(dest => dest.WeighKGs, src => src.WEIGHKGS)
.Map(dest => dest.WeighType, src => src.WEIGHTYPE);
} }
} }

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// VGM反馈
/// </summary>
public class TaskVGMFeedBackDto
{
/// <summary>
/// 集装箱号
/// </summary>
public string ContaNo { get; set; }
/// <summary>
/// 铅封号
/// </summary>
public string SealNo { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
public string ContaType { get; set; }
/// <summary>
/// 箱型
/// </summary>
public string ContaTypeName { get; set; }
/// <summary>
/// 重量
/// </summary>
public decimal? KGS { get; set; }
/// <summary>
/// 皮重
/// </summary>
public decimal? TareWeight { get; set; }
/// <summary>
/// 称重重量
/// </summary>
public decimal? WeighKGs { get; set; }
/// <summary>
/// 称重方式
/// </summary>
public string WeighType { get; set; }
}
}

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskVgmCompareDto : TaskVGMFeedBackDto
{
/// <summary>
/// 比对差异字段
/// </summary>
public List<string> compareDiffList { get; set; }
}
public class TaskVgmCompareResultDto
{
/// <summary>
/// 订舱与VGM反馈差异对比
/// </summary>
public List<TaskVgmCompareDto> bookOrderCompareList { get; set; }
/// <summary>
/// VGM反馈与订舱差异比对
/// </summary>
public List<TaskVgmCompareDto> vgmCompareList { get; set; }
}
}

@ -190,7 +190,19 @@ namespace Myshipping.Application
/// <returns>返回结果</returns> /// <returns>返回结果</returns>
Task<TaskSIFeedBackResultDto> GetSIFeedBackInfo(string taskPKId); Task<TaskSIFeedBackResultDto> GetSIFeedBackInfo(string taskPKId);
/// <summary>
/// 获取VGM比较结果
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
Task<TaskVgmCompareResultDto> GetVGMCompareResult(string taskPKId);
/// <summary>
/// 更新订舱VGM比较更新
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> SaveBookingVGM(string taskPKId);
} }
} }

@ -2646,7 +2646,7 @@ namespace Myshipping.Application
.Select((si, ctn) => new { si = si, ctn = ctn }).ToList(); .Select((si, ctn) => new { si = si, ctn = ctn }).ToList();
if (siFeedBackList.Count == 0) if (siFeedBackList.Count == 0)
Oops.Oh($"SI反馈信息不存在"); throw Oops.Oh($"SI反馈信息不存在");
var siFeedBackInfo = siFeedBackList.FirstOrDefault().si; var siFeedBackInfo = siFeedBackList.FirstOrDefault().si;
@ -2866,6 +2866,220 @@ namespace Myshipping.Application
return resultList; return resultList;
} }
#endregion #endregion
/// <summary>
/// 获取VGM比较结果
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
[HttpGet("/TaskManage/GetVGMCompareResult")]
public async Task<TaskVgmCompareResultDto> GetVGMCompareResult(string taskPKId)
{
TaskVgmCompareResultDto model = new TaskVgmCompareResultDto();
List<TaskVgmCompareDto> list = new List<TaskVgmCompareDto>();
List<TaskVgmCompareDto> list2 = new List<TaskVgmCompareDto>();
try
{
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId);
if (taskInfo == null)
throw Oops.Oh($"任务信息获取失败");
if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO))
throw Oops.Oh($"任务信息的订舱主键不存在");
if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.VGM_COMPARE.ToString())
throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.VGM_COMPARE.GetDescription()}");
var vgmList = _taskVGMFeedBackInfoRepository.AsQueryable().Where(t => t.TASK_PKID == taskInfo.PK_ID)
.ToList();
if(vgmList.Count == 0)
throw Oops.Oh($"VGM反馈信息不存在");
var contaList = _bookingOrderContaRepository.AsQueryable().Where(t => t.BILLID == long.Parse(taskInfo.BOOK_ORDER_NO)).ToList();
list = contaList.GroupJoin(vgmList, l => l.CNTRNO?.Trim(), r => r.CONTA_NO?.Trim(), (l, r) => {
var currInfo = r.FirstOrDefault();
TaskVgmCompareDto md = l.Adapt<TaskVgmCompareDto>();
if (currInfo != null)
{
if(!l.SEALNO.Equals(currInfo.SEAL_NO))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo));
}
if (!l.CTNCODE.Equals(currInfo.CONTA_TYPE))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType));
}
if (!l.CTNALL.Equals(currInfo.CONTA_TYPE_NAME))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName));
}
if (!l.KGS.Equals(currInfo.KGS))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS));
}
if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight));
}
if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs));
}
if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType));
}
}
else
{
md.compareDiffList = new List<string> { nameof(TaskVgmCompareDto.ContaNo),
nameof(TaskVgmCompareDto.SealNo),
nameof(TaskVgmCompareDto.ContaType),
nameof(TaskVgmCompareDto.ContaTypeName),
nameof(TaskVgmCompareDto.KGS),
nameof(TaskVgmCompareDto.TareWeight),
nameof(TaskVgmCompareDto.WeighKGs),
nameof(TaskVgmCompareDto.WeighType),
};
}
return md;
}).ToList();
model.bookOrderCompareList = list;
list2 = vgmList.GroupJoin(contaList, l => l.CONTA_NO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => {
var currInfo = r.FirstOrDefault();
TaskVgmCompareDto md = l.Adapt<TaskVgmCompareDto>();
if (currInfo != null)
{
if (!l.SEAL_NO.Equals(currInfo.SEALNO))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo));
}
if (!l.CONTA_TYPE.Equals(currInfo.CTNCODE))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType));
}
if (!l.CONTA_TYPE_NAME.Equals(currInfo.CTNALL))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName));
}
if (!l.KGS.Equals(currInfo.KGS))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS));
}
if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight));
}
if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs));
}
if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE))
{
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType));
}
}
else
{
md.compareDiffList = new List<string> { nameof(TaskVgmCompareDto.ContaNo),
nameof(TaskVgmCompareDto.SealNo),
nameof(TaskVgmCompareDto.ContaType),
nameof(TaskVgmCompareDto.ContaTypeName),
nameof(TaskVgmCompareDto.KGS),
nameof(TaskVgmCompareDto.TareWeight),
nameof(TaskVgmCompareDto.WeighKGs),
nameof(TaskVgmCompareDto.WeighType),
};
}
return md;
}).ToList();
model.vgmCompareList = list2;
}
catch (Exception ex)
{
throw Oops.Bah($"获取VGM比较结果异常,{0}", ex.Message);
}
return model;
}
/// <summary>
/// 更新订舱VGM比较更新
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
[HttpPost("/TaskManage/SaveBookingVGM")]
public async Task<TaskManageOrderResultDto> SaveBookingVGM(string taskPKId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId);
if (taskInfo == null)
throw Oops.Oh($"任务信息获取失败");
if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO))
throw Oops.Oh($"任务信息的订舱主键不存在");
if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString())
throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}");
var bookOrderList = _bookingOrderRepository.EntityContext.Queryable<BookingOrder>()
.InnerJoin<BookingCtn>((bk, ctn) => bk.Id == ctn.BILLID)
.Where((bk, ctn) => bk.Id == long.Parse(taskInfo.BOOK_ORDER_NO) && bk.TenantId == UserManager.TENANT_ID)
.Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList();
var orderInfo = bookOrderList.FirstOrDefault().bk;
//比对差异,更新订舱主信息
var mdBookingOrder = orderInfo.Adapt<BookingOrder>();
await _bookingOrderRepository.AsUpdateable(mdBookingOrder).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync();
//更新订舱的集装箱信息
ctnlist.ForEach(async ctn => {
await _bookingOrderContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new
{
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
});
}
catch(Exception ex)
{
throw Oops.Bah($"更新订舱VGM比较更新异常,{0}", ex.Message);
}
return result;
}
} }
#region 样本业务提取帮助类 #region 样本业务提取帮助类

Loading…
Cancel
Save