修改SI与订舱数据比较

optimize
jianghaiqing 2 years ago
parent eb88d749b2
commit f5755a4cf0

@ -377,6 +377,16 @@ namespace Myshipping.Application
.Map(dest => dest.KindPKGS, src => src.KIND_PKGS) .Map(dest => dest.KindPKGS, src => src.KIND_PKGS)
.Map(dest => dest.PKGS, src => src.PKGS) .Map(dest => dest.PKGS, src => src.PKGS)
.Map(dest => dest.ThirdPayAddr, src => src.THIRDPAYADDR); .Map(dest => dest.ThirdPayAddr, src => src.THIRDPAYADDR);
config.ForType<TaskSIFeedBackContaInfo, TaskSIFeedBackResultContaDto>()
.Map(dest => dest.ContaNo, src => src.CONTA_NO)
.Map(dest => dest.SealNo, src => src.SEAL_NO)
.Map(dest => dest.PKGS, src => src.PKGS)
.Map(dest => dest.KGS, src => src.KGS)
.Map(dest => dest.CBM, src => src.CBM)
.Map(dest => dest.ContaType, src => src.CONTA_TYPE)
.Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME);
} }
} }

@ -26,6 +26,7 @@ using Npoi.Mapper;
using NPOI.HPSF; using NPOI.HPSF;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.POIFS.Crypt.Dsig; using NPOI.POIFS.Crypt.Dsig;
using NPOI.SS.Formula.Eval;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.Model; using NPOI.XSSF.Model;
@ -2578,8 +2579,13 @@ namespace Myshipping.Application
if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString())
Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}");
var orderInfo = _bookingOrderRepository.AsQueryable()
.First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO)); 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; model.TaskId = taskInfo.PK_ID;
@ -2591,11 +2597,13 @@ namespace Myshipping.Application
if (siFeedBackList.Count == 0) if (siFeedBackList.Count == 0)
Oops.Oh($"SI反馈信息不存在"); Oops.Oh($"SI反馈信息不存在");
var siFeedBackInfo = siFeedBackList.FirstOrDefault().si.Adapt<TaskSIFeedBackResultBusiDto>(); var siFeedBackInfo = siFeedBackList.FirstOrDefault().si;
siFeedBackInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt<TaskSIFeedBackResultContaDto>()).ToList(); var resultInfo = siFeedBackInfo.Adapt<TaskSIFeedBackResultBusiDto>();
model.BusiInfo = siFeedBackInfo; resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt<TaskSIFeedBackResultContaDto>()).ToList();
model.BusiInfo = resultInfo;
if (orderInfo != null) if (orderInfo != null)
{ {
@ -2604,6 +2612,14 @@ namespace Myshipping.Application
} }
//进行数据比对确认差异字段KEY //进行数据比对确认差异字段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) catch (Exception ex)
{ {
@ -2612,77 +2628,125 @@ namespace Myshipping.Application
return model; return model;
} }
// private async Task<string> InnerCompareDiff() #region 比较主信息
// { /// <summary>
// var compareField = new string[] { "SHIPPER", "CONSIGNEE", "NOTIFYPARTY", "MARKS", "DESCRIPTION", "BLFRT", "SERVICE", "ISSUETYPE", "PORTLOAD", "PORTDISCHARGE", "TRANSPORT", "DESTINATION", "PKGS", "KGS", "CBM", "KINDPKGS", "THIRDPAYADDR" }; /// 比较主信息
// var listDiffField = new List<string>(); /// </summary>
// var bookProps = typeof(OP_SEAE_ORDER).GetProperties(); /// <param name="bookingOrder">订舱详情</param>
// var feedProps = typeof(OP_SEAE_SI_FEEDBACK).GetProperties(); /// <param name="taskSIFeedBackInfo">SI反馈详情</param>
// foreach (var prop in compareField) /// <returns>返回差异</returns>
// { private async Task<List<string>> InnerCompareMainInfoDiff(BookingOrder bookingOrder, TaskSIFeedBackInfo taskSIFeedBackInfo)
// var pBook = bookProps.First(p => p.Name == prop); {
// var bookVal = pBook.GetValue(bill.order); List<string> resultList = new List<string>();
// var pFeed = feedProps.First(p => p.Name == prop);
// var feedVal = pFeed.GetValue(siFeedback);
// if (pBook.PropertyType == typeof(string))
// {
// string st1 = bookVal as string;
// string st2 = feedVal as string;
// st1 = ProcessString(st1);
// st2 = ProcessString(st2);
// if (st1 != st2) //需要比对的字段
// { var compareField = new string[] { "SHIPPER", "CONSIGNEE", "NOTIFYPARTY", "MARKS", "DESCRIPTION", "BLFRT", "SERVICE", "ISSUETYPE", "PORTLOAD", "PORTDISCHARGE",
// listDiffField.Add(prop); "TRANSPORT", "DESTINATION", "PKGS", "KGS", "CBM", "KINDPKGS", "THIRDPAYADDR" };
// }
// }
// else if (pBook.PropertyType == typeof(int?))
// {
// var dt1 = bookVal as int?;
// var dt2 = feedVal as int?;
// if (dt1 != dt2)
// {
// listDiffField.Add(prop);
// }
// }
// else if (pBook.PropertyType == typeof(decimal?))
// {
// var dt1 = bookVal as decimal?;
// var dt2 = feedVal as decimal?;
// if (dt1 != dt2)
// {
// listDiffField.Add(prop);
// }
// }
// }
// ViewData["DiffFields"] = listDiffField; var bookProps = typeof(BookingOrder).GetProperties();
//#endregion var feedProps = typeof(TaskSIFeedBackInfo).GetProperties();
// #region 箱信息对比 resultList = bookProps.GroupJoin(feedProps, l => l.Name.ToUpper(),
// var listDiffCtn = new List<string>(); r => r.Name.ToUpper(), (l, r) =>
// var ctns = bookingDB.Ctns.Where(c => c.ORDNO == bill.order.ORDNO).ToList(); {
// foreach (var cc in feedbackCtn) if (compareField.Any(x => x.Equals(l.Name, StringComparison.OrdinalIgnoreCase)))
// { {
// var ctnB = ctns.FirstOrDefault(c => c.CNTRNO == cc.CNTRNO); var currList = r.ToList();
// if (ctnB == null)
// { if (currList.Count > 0)
// listDiffCtn.Add(cc.CNTRNO); {
// } var si = r.FirstOrDefault();
// else
// { var bkVal = l.GetValue(bookingOrder);
// if (cc.KGS != ctnB.KGS var siVal = si.GetValue(taskSIFeedBackInfo);
// || cc.PKGS != ctnB.PKGS
// || cc.SEALNO != ctnB.SEALNO if (l.PropertyType == typeof(string))
// || cc.CTNALL != ctnB.CTNALL {
// || cc.CBM != ctnB.CBM) string st1 = (bkVal as string).AdjustString();
// { string st2 = (siVal as string).AdjustString();
// listDiffCtn.Add(cc.CNTRNO);
// } if (!st1.Equals(st2))
// } {
// } return l.Name.ToUpper();
// ViewData["DiffCtns"] = listDiffCtn; }
// }
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();
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 l.CONTA_NO;
});
return resultList;
}
#endregion
} }
#region 样本业务提取帮助类 #region 样本业务提取帮助类
@ -2709,4 +2773,26 @@ namespace Myshipping.Application
} }
} }
#endregion #endregion
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;
}
}
} }

Loading…
Cancel
Save