我的任务-修改VGM保存

optimize
jianghaiqing 2 years ago
parent 3fba428988
commit 5f235fef63

@ -59,5 +59,10 @@ namespace Myshipping.Application.Entity
/// 称重方式
/// </summary>
public string WEIGHTYPE { get; set; }
/// <summary>
/// 主单号
/// </summary>
public string MBL_NO { get; set; }
}
}

@ -72,7 +72,8 @@ namespace Myshipping.Application
.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);
.Map(dest => dest.WEIGHTYPE, src => src.WEIGHTYPE)
.Map(dest => dest.MBL_NO, src => src.MBLNo);
config.ForType<TaskBaseInfo, TaskBaseInfoDto>()
@ -397,7 +398,8 @@ namespace Myshipping.Application
.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);
.Map(dest => dest.WeighType, src => src.WEIGHTYPE)
.Map(dest => dest.MBLNo, src => src.MBL_NO);
config.ForType<TaskVGMFeedBackInfo, TaskVgmCompareDto>()
@ -408,7 +410,8 @@ namespace Myshipping.Application
.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);
.Map(dest => dest.WeighType, src => src.WEIGHTYPE)
.Map(dest => dest.MBLNo, src => src.MBL_NO);
config.ForType<BookingCtn, TaskVgmCompareDto>()
@ -571,6 +574,17 @@ namespace Myshipping.Application
.Map(dest => dest.LANECODE, src => src.LaneCode)
.Map(dest => dest.LANENAME, src => src.LaneName)
.Map(dest => dest.FREIGHTPAYER, src => src.FreightPayer);
config.ForType<TaskVGMFeedBackInfo, BookingCtn>()
.Map(dest => dest.CTNCODE, src => src.CONTA_TYPE)
.Map(dest => dest.CTNALL, src => src.CONTA_TYPE_NAME)
.Map(dest => dest.CNTRNO, src => src.CONTA_NO)
.Map(dest => dest.SEALNO, src => src.SEAL_NO)
.Map(dest => dest.KGS, src => src.KGS)
.Map(dest => dest.TAREWEIGHT, src => src.TAREWEIGHT)
.Map(dest => dest.WEIGHTYPE, src => src.WEIGHTYPE)
.Map(dest => dest.WEIGHKGS, src => src.WEIGHKGS);
}
}

@ -50,5 +50,11 @@ namespace Myshipping.Application
/// 称重方式
/// </summary>
public string WEIGHTYPE { get; set; }
/// <summary>
/// 主单号
/// </summary>
public string MBLNo { get; set; }
}
}

@ -50,5 +50,10 @@ namespace Myshipping.Application
/// 称重方式
/// </summary>
public string WeighType { get; set; }
/// <summary>
/// 主单号
/// </summary>
public string MBLNo { get; set; }
}
}

@ -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)
{

Loading…
Cancel
Save