|
|
|
@ -4,6 +4,7 @@ using Furion.DistributedIDGenerator;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
|
using Furion.Localization;
|
|
|
|
|
using Furion.RemoteRequest;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using Mapster;
|
|
|
|
@ -25,9 +26,12 @@ using Newtonsoft.Json.Linq;
|
|
|
|
|
using Npoi.Mapper;
|
|
|
|
|
using NPOI.HPSF;
|
|
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
using NPOI.OpenXmlFormats;
|
|
|
|
|
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;
|
|
|
|
@ -2435,7 +2439,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="pageSize">页码容量</param>
|
|
|
|
|
/// <param name="descSort">排序方法,默认降序</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpGet("/TaskManage/GetLaraPaperRecordPage")]
|
|
|
|
|
[HttpGet("/TaskManage/LaraPaperRecordExport")]
|
|
|
|
|
public async Task<IActionResult> LaraPaperRecordExport([FromQuery] string sortField,[FromQuery] int pageNo = 1, [FromQuery] int pageSize = 30, [FromQuery] bool descSort = true)
|
|
|
|
|
{
|
|
|
|
|
QueryTaskManageBaseDto querySearch = new QueryTaskManageBaseDto
|
|
|
|
@ -2465,6 +2469,7 @@ namespace Myshipping.Application
|
|
|
|
|
return new FileStreamResult(ms, "application/vnd.ms-excel") { FileDownloadName = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}_LaraPaperRecord.xls" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 导出提单纸登记记录生成Excel
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出提单纸登记记录生成Excel
|
|
|
|
|
/// </summary>
|
|
|
|
@ -2529,6 +2534,735 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
return ms;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存SI信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存SI信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">订舱信息</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpPost("/TaskManage/SaveBookingSI")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SaveBookingSI(TaskBookingOrderDto model)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
1、比较原始数据和修改数据内容,记录差异。
|
|
|
|
|
2、更新订舱主信息和集装箱信息。
|
|
|
|
|
3、写入本地历史记录表。
|
|
|
|
|
*/
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.TaskBaseInfo.PKId))
|
|
|
|
|
throw Oops.Oh($"任务主键TaskBaseInfo.PKId不能为空");
|
|
|
|
|
|
|
|
|
|
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == model.TaskBaseInfo.PKId);
|
|
|
|
|
|
|
|
|
|
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>()
|
|
|
|
|
.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;
|
|
|
|
|
|
|
|
|
|
List<BookingCtn> orderCtnList = new List<BookingCtn>();
|
|
|
|
|
|
|
|
|
|
//这里是左连接查询,解决集装箱为空的情况
|
|
|
|
|
if(bookOrderList.Any(t=>t.ctn.Id > 0))
|
|
|
|
|
orderCtnList = bookOrderList.Select(t => t.ctn).ToList();
|
|
|
|
|
|
|
|
|
|
var mdBookingOrder = model.Adapt<BookingOrder>();
|
|
|
|
|
|
|
|
|
|
mdBookingOrder.Id = orderInfo.Id;
|
|
|
|
|
mdBookingOrder.UpdatedTime = DateTime.Now;
|
|
|
|
|
mdBookingOrder.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
mdBookingOrder.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
//比对主订舱信息
|
|
|
|
|
var orderDiff = InnerCompare(orderInfo, mdBookingOrder);
|
|
|
|
|
|
|
|
|
|
//比对箱信息
|
|
|
|
|
var contaList = model.ContaList.Select(x => x.Adapt<BookingCtn>()).ToList();
|
|
|
|
|
|
|
|
|
|
/**/
|
|
|
|
|
//这里参考原有的更新逻辑,只更新了SI回执有的字段信息,其他字段不更新,如果后期有调整可以自行增加更新字段
|
|
|
|
|
await _bookingOrderRepository.AsUpdateable(mdBookingOrder).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
it.SHIPPER,
|
|
|
|
|
it.CONSIGNEE,
|
|
|
|
|
it.NOTIFYPARTY,
|
|
|
|
|
it.MARKS,
|
|
|
|
|
it.DESCRIPTION,
|
|
|
|
|
it.BLFRT,
|
|
|
|
|
it.SERVICE,
|
|
|
|
|
it.ISSUETYPE,
|
|
|
|
|
it.PORTLOADID,
|
|
|
|
|
it.PORTLOAD,
|
|
|
|
|
it.PORTDISCHARGEID,
|
|
|
|
|
it.PORTDISCHARGE,
|
|
|
|
|
it.TRANSPORTID,
|
|
|
|
|
it.TRANSPORT,
|
|
|
|
|
it.DESTINATIONID,
|
|
|
|
|
it.DESTINATION,
|
|
|
|
|
it.PKGS,
|
|
|
|
|
it.KINDPKGS,
|
|
|
|
|
it.KGS,
|
|
|
|
|
it.CBM,
|
|
|
|
|
it.THIRDPAYADDR,
|
|
|
|
|
it.SIREMARK
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var si2orderCtnList = contaList.GroupJoin(ctnlist, l => l.CNTRNO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => {
|
|
|
|
|
var currInfo = r.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if(currInfo == null)
|
|
|
|
|
{
|
|
|
|
|
l.BILLID = orderInfo.Id;
|
|
|
|
|
l.CreatedTime = DateTime.Now;
|
|
|
|
|
l.CreatedUserId = UserManager.UserId;
|
|
|
|
|
l.CreatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
l.UpdatedTime = l.CreatedTime;
|
|
|
|
|
l.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
l.UpdatedUserName = UserManager.Name;
|
|
|
|
|
return new { OperType = "insert", obj = l };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currInfo.Id = l.Id;
|
|
|
|
|
currInfo.BILLID = l.BILLID;
|
|
|
|
|
currInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
currInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
currInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
return new { OperType = "update", obj = currInfo };
|
|
|
|
|
}
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var delList = ctnlist.GroupJoin(contaList, l => l.CNTRNO?.Trim(), r => r.CNTRNO?.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 = "保存SI信息成功";
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"保存SI信息异常,{0}", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取SI反馈信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取SI反馈信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskPKId">任务主键</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpGet("/TaskManage/GetSIFeedBackInfo")]
|
|
|
|
|
public async Task<TaskSIFeedBackResultDto> GetSIFeedBackInfo(string taskPKId)
|
|
|
|
|
{
|
|
|
|
|
TaskSIFeedBackResultDto model = new TaskSIFeedBackResultDto();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
model.TaskId = taskInfo.PK_ID;
|
|
|
|
|
|
|
|
|
|
var siFeedBackList = _taskSIFeedBackInfoRepository.EntityContext.Queryable<TaskSIFeedBackInfo>()
|
|
|
|
|
.InnerJoin<TaskSIFeedBackContaInfo>((si, ctn) => si.PK_ID == ctn.P_PKID)
|
|
|
|
|
.Where((si, ctn) => si.TASK_PKID == model.TaskId && si.TenantId == UserManager.TENANT_ID)
|
|
|
|
|
.Select((si, ctn) => new { si = si, ctn = ctn }).ToList();
|
|
|
|
|
|
|
|
|
|
if (siFeedBackList.Count == 0)
|
|
|
|
|
throw Oops.Oh($"SI反馈信息不存在");
|
|
|
|
|
|
|
|
|
|
var siFeedBackInfo = siFeedBackList.FirstOrDefault().si;
|
|
|
|
|
|
|
|
|
|
var resultInfo = siFeedBackInfo.Adapt<TaskSIFeedBackResultBusiDto>();
|
|
|
|
|
|
|
|
|
|
resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt<TaskSIFeedBackResultContaDto>()).ToList();
|
|
|
|
|
|
|
|
|
|
model.BusiInfo = resultInfo;
|
|
|
|
|
|
|
|
|
|
if (orderInfo != null)
|
|
|
|
|
{
|
|
|
|
|
//订舱
|
|
|
|
|
model.BookingOrder = orderInfo.Adapt<TaskBookingOrderDto>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//进行数据比对确认差异字段KEY
|
|
|
|
|
var mainDiff = await InnerCompareMainInfoDiff(orderInfo, siFeedBackInfo);
|
|
|
|
|
|
|
|
|
|
model.SICompareOrderKeyList = mainDiff;
|
|
|
|
|
|
|
|
|
|
var contaDiff = await InnerCompareContaInfoDiff(bookOrderList.Select(t=>t.ctn).ToList(),
|
|
|
|
|
siFeedBackList.Select(t=>t.ctn).ToList());
|
|
|
|
|
|
|
|
|
|
model.SICompareOrderContaKeyList = contaDiff;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"获取获取单票账单详情异常,{0}", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private List<TaskCompareResultDto> InnerCompare(object srcModel,object targetModel)
|
|
|
|
|
{
|
|
|
|
|
List<TaskCompareResultDto> list = new List<TaskCompareResultDto>();
|
|
|
|
|
|
|
|
|
|
if(srcModel is BookingOrder)
|
|
|
|
|
{
|
|
|
|
|
var srcBK = (BookingOrder)srcModel;
|
|
|
|
|
var targetBK = (BookingOrder)targetModel;
|
|
|
|
|
|
|
|
|
|
var bookProps = typeof(BookingOrder).GetProperties();
|
|
|
|
|
|
|
|
|
|
list = bookProps.Select(prop =>
|
|
|
|
|
{
|
|
|
|
|
var bk1Val = prop.GetValue(srcBK);
|
|
|
|
|
var bk2Val = prop.GetValue(targetBK);
|
|
|
|
|
|
|
|
|
|
if (prop.PropertyType == typeof(string))
|
|
|
|
|
{
|
|
|
|
|
string st1 = (bk1Val as string).AdjustString();
|
|
|
|
|
string st2 = (bk2Val as string).AdjustString();
|
|
|
|
|
|
|
|
|
|
if (st1 != st2)
|
|
|
|
|
{
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = false, ValType = prop.PropertyType };
|
|
|
|
|
}
|
|
|
|
|
else if (prop.PropertyType == typeof(int?))
|
|
|
|
|
{
|
|
|
|
|
var dt1 = bk1Val as int?;
|
|
|
|
|
var dt2 = bk2Val as int?;
|
|
|
|
|
|
|
|
|
|
if (dt1 != dt2)
|
|
|
|
|
{
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType };
|
|
|
|
|
}
|
|
|
|
|
else if (prop.PropertyType == typeof(decimal?))
|
|
|
|
|
{
|
|
|
|
|
var dt1 = bk1Val as decimal?;
|
|
|
|
|
var dt2 = bk2Val as decimal?;
|
|
|
|
|
|
|
|
|
|
if (dt1 != dt2)
|
|
|
|
|
{
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bk1Val != bk2Val)
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = false, ValType = prop.PropertyType };
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 比较主信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 比较主信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingOrder">订舱详情</param>
|
|
|
|
|
/// <param name="taskSIFeedBackInfo">SI反馈详情</param>
|
|
|
|
|
/// <returns>返回差异</returns>
|
|
|
|
|
private async Task<List<string>> InnerCompareMainInfoDiff(BookingOrder bookingOrder, TaskSIFeedBackInfo taskSIFeedBackInfo)
|
|
|
|
|
{
|
|
|
|
|
List<string> resultList = new List<string>();
|
|
|
|
|
|
|
|
|
|
//需要比对的字段
|
|
|
|
|
var compareField = new string[] { "SHIPPER", "CONSIGNEE", "NOTIFYPARTY", "MARKS", "DESCRIPTION", "BLFRT", "SERVICE", "ISSUETYPE", "PORTLOAD", "PORTDISCHARGE",
|
|
|
|
|
"TRANSPORT", "DESTINATION", "PKGS", "KGS", "CBM", "KINDPKGS", "THIRDPAYADDR" };
|
|
|
|
|
|
|
|
|
|
var bookProps = typeof(BookingOrder).GetProperties();
|
|
|
|
|
var feedProps = typeof(TaskSIFeedBackInfo).GetProperties();
|
|
|
|
|
|
|
|
|
|
resultList = bookProps.GroupJoin(feedProps, l => l.Name.ToUpper(),
|
|
|
|
|
r => r.Name.ToUpper(), (l, r) =>
|
|
|
|
|
{
|
|
|
|
|
if (compareField.Any(x => x.Equals(l.Name, StringComparison.OrdinalIgnoreCase)))
|
|
|
|
|
{
|
|
|
|
|
var currList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (currList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var si = r.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
var bkVal = l.GetValue(bookingOrder);
|
|
|
|
|
var siVal = si.GetValue(taskSIFeedBackInfo);
|
|
|
|
|
|
|
|
|
|
if (l.PropertyType == typeof(string))
|
|
|
|
|
{
|
|
|
|
|
string st1 = (bkVal as string).AdjustString();
|
|
|
|
|
string st2 = (siVal as string).AdjustString();
|
|
|
|
|
|
|
|
|
|
if (!st1.Equals(st2))
|
|
|
|
|
{
|
|
|
|
|
return l.Name.ToUpper();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else if (l.PropertyType == typeof(int?))
|
|
|
|
|
{
|
|
|
|
|
var dt1 = bkVal as int?;
|
|
|
|
|
var dt2 = siVal as int?;
|
|
|
|
|
|
|
|
|
|
if (!dt1.Equals(dt2))
|
|
|
|
|
{
|
|
|
|
|
return l.Name.ToUpper();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else if (l.PropertyType == typeof(decimal?))
|
|
|
|
|
{
|
|
|
|
|
var dt1 = bkVal as decimal?;
|
|
|
|
|
var dt2 = siVal as decimal?;
|
|
|
|
|
|
|
|
|
|
if (!dt1.Equals(dt2))
|
|
|
|
|
{
|
|
|
|
|
return l.Name.ToUpper();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToList();
|
|
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 比较箱信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 比较箱信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookContaList">订舱箱信息</param>
|
|
|
|
|
/// <param name="siContaList">SI反馈箱信息</param>
|
|
|
|
|
/// <returns>返回差异</returns>
|
|
|
|
|
private async Task<List<string>> InnerCompareContaInfoDiff(List<BookingCtn> bookContaList,List<TaskSIFeedBackContaInfo> siContaList)
|
|
|
|
|
{
|
|
|
|
|
List<string> resultList = new List<string>();
|
|
|
|
|
|
|
|
|
|
var bookProps = typeof(BookingCtn).GetProperties();
|
|
|
|
|
var feedProps = typeof(TaskSIFeedBackContaInfo).GetProperties();
|
|
|
|
|
|
|
|
|
|
resultList = siContaList.GroupJoin(bookContaList, l => l.CONTA_NO, r => r.CNTRNO, (l, r) =>
|
|
|
|
|
{
|
|
|
|
|
var currList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (currList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var bkCtn = currList.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (!l.KGS.Equals(bkCtn.KGS)
|
|
|
|
|
|| !l.PKGS.Equals(bkCtn.PKGS)
|
|
|
|
|
|| !l.SEAL_NO.Equals(bkCtn.SEALNO)
|
|
|
|
|
|| !l.CONTA_TYPE.Equals(bkCtn.CTNALL)
|
|
|
|
|
|| !l.CBM.Equals(bkCtn.CBM))
|
|
|
|
|
{
|
|
|
|
|
return l.CONTA_NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return String.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return l.CONTA_NO;
|
|
|
|
|
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToList();
|
|
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取VGM比较结果
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 更新订舱(VGM比较更新)
|
|
|
|
|
/// <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.VGM_COMPARE.ToString())
|
|
|
|
|
throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.VGM_COMPARE.GetDescription()}");
|
|
|
|
|
|
|
|
|
|
//取订舱详情(包含集装箱)
|
|
|
|
|
var bookOrderList = _bookingOrderRepository.EntityContext.Queryable<BookingOrder>()
|
|
|
|
|
.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;
|
|
|
|
|
|
|
|
|
|
List<BookingCtn> orderCtnList = new List<BookingCtn>();
|
|
|
|
|
|
|
|
|
|
//这里是左连接查询,解决集装箱为空的情况
|
|
|
|
|
if (bookOrderList.Any(t => t.ctn.Id > 0))
|
|
|
|
|
orderCtnList = bookOrderList.Select(t => t.ctn).ToList();
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
var contaInfo = l.Adapt<BookingCtn>();
|
|
|
|
|
|
|
|
|
|
if (currInfo == null)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"更新订舱(VGM比较更新)异常,{0}", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 样本业务提取帮助类
|
|
|
|
@ -2555,4 +3289,28 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 整理文本数据
|
|
|
|
|
public static class CompareObjExtension
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整理文本数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">文本</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string AdjustString(this string str)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
return str;
|
|
|
|
|
|
|
|
|
|
var rtn = str.Replace("\r\n", "\n").Trim();
|
|
|
|
|
if (rtn.EndsWith("\n"))
|
|
|
|
|
{
|
|
|
|
|
rtn = rtn.Substring(0, rtn.Length - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rtn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|