|
|
|
@ -31,6 +31,7 @@ using NPOI.POIFS.Crypt.Dsig;
|
|
|
|
|
using NPOI.SS.Formula.Eval;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
using NPOI.XSSF.Model;
|
|
|
|
|
using Org.BouncyCastle.Asn1.X500;
|
|
|
|
|
using SixLabors.ImageSharp.Processing.Processors.Transforms;
|
|
|
|
@ -3154,38 +3155,105 @@ namespace Myshipping.Application
|
|
|
|
|
if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.VGM_COMPARE.ToString())
|
|
|
|
|
throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.VGM_COMPARE.GetDescription()}");
|
|
|
|
|
|
|
|
|
|
//取订舱详情(包含集装箱)
|
|
|
|
|
var bookOrderList = _bookingOrderRepository.EntityContext.Queryable<BookingOrder>()
|
|
|
|
|
.InnerJoin<BookingCtn>((bk, ctn) => bk.Id == ctn.BILLID)
|
|
|
|
|
.LeftJoin(_bookingOrderRepository.EntityContext.Queryable<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>();
|
|
|
|
|
List<BookingCtn> orderCtnList = new List<BookingCtn>();
|
|
|
|
|
|
|
|
|
|
await _bookingOrderRepository.AsUpdateable(mdBookingOrder).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.ParentId,
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
//这里是左连接查询,解决集装箱为空的情况
|
|
|
|
|
if (bookOrderList.Any(t => t.ctn.Id > 0))
|
|
|
|
|
orderCtnList = bookOrderList.Select(t => t.ctn).ToList();
|
|
|
|
|
|
|
|
|
|
var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync();
|
|
|
|
|
var contaList = _taskVGMFeedBackInfoRepository.AsQueryable().Where(t => t.TASK_PKID == taskInfo.PK_ID).ToList();
|
|
|
|
|
|
|
|
|
|
var si2orderCtnList = contaList.GroupJoin(orderCtnList, l => l.CONTA_NO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => {
|
|
|
|
|
var currInfo = r.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
//更新订舱的集装箱信息
|
|
|
|
|
ctnlist.ForEach(async ctn => {
|
|
|
|
|
var contaInfo = l.Adapt<BookingCtn>();
|
|
|
|
|
|
|
|
|
|
await _bookingOrderContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new
|
|
|
|
|
if (currInfo == null)
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
});
|
|
|
|
|
contaInfo.BILLID = orderInfo.Id;
|
|
|
|
|
contaInfo.CreatedTime = DateTime.Now;
|
|
|
|
|
contaInfo.CreatedUserId = UserManager.UserId;
|
|
|
|
|
contaInfo.CreatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
contaInfo.UpdatedTime = contaInfo.CreatedTime;
|
|
|
|
|
contaInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
contaInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
return new { OperType = "insert", obj = contaInfo };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currInfo.Id = contaInfo.Id;
|
|
|
|
|
currInfo.BILLID = contaInfo.BILLID;
|
|
|
|
|
currInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
currInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
currInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
return new { OperType = "update", obj = currInfo };
|
|
|
|
|
}
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var delList = orderCtnList.GroupJoin(contaList, l => l.CNTRNO?.Trim(), r => r.CONTA_NO?.Trim(), (l, r) => {
|
|
|
|
|
var currInfo = r.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (currInfo == null)
|
|
|
|
|
{
|
|
|
|
|
l.UpdatedTime = DateTime.Now;
|
|
|
|
|
l.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
l.UpdatedUserName = UserManager.Name;
|
|
|
|
|
return new { OperType = "delete", obj = l };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new { OperType = string.Empty, obj = l };
|
|
|
|
|
}).Where(t => t.OperType != string.Empty).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (delList.Count > 0)
|
|
|
|
|
si2orderCtnList.AddRange(delList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (si2orderCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
si2orderCtnList.ForEach(async ctn =>
|
|
|
|
|
{
|
|
|
|
|
if (ctn.OperType == "insert")
|
|
|
|
|
{
|
|
|
|
|
//插入
|
|
|
|
|
await _bookingOrderContaRepository.InsertAsync(ctn.obj);
|
|
|
|
|
}
|
|
|
|
|
else if (ctn.OperType == "update")
|
|
|
|
|
{
|
|
|
|
|
//更新
|
|
|
|
|
await _bookingOrderContaRepository.AsUpdateable(ctn.obj).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.CTNALL,
|
|
|
|
|
it.SEALNO,
|
|
|
|
|
it.PKGS,
|
|
|
|
|
it.KGS,
|
|
|
|
|
it.CBM,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else if (ctn.OperType == "delete")
|
|
|
|
|
{
|
|
|
|
|
await _bookingOrderContaRepository.DeleteAsync(x => x.Id == ctn.obj.Id);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "更新订舱成功";
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|