修改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;
var resultInfo = siFeedBackInfo.Adapt<TaskSIFeedBackResultBusiDto>();
siFeedBackInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt<TaskSIFeedBackResultContaDto>()).ToList(); resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt<TaskSIFeedBackResultContaDto>()).ToList();
model.BusiInfo = siFeedBackInfo; 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)) var compareField = new string[] { "SHIPPER", "CONSIGNEE", "NOTIFYPARTY", "MARKS", "DESCRIPTION", "BLFRT", "SERVICE", "ISSUETYPE", "PORTLOAD", "PORTDISCHARGE",
// { "TRANSPORT", "DESTINATION", "PKGS", "KGS", "CBM", "KINDPKGS", "THIRDPAYADDR" };
// string st1 = bookVal as string;
// string st2 = feedVal as string; var bookProps = typeof(BookingOrder).GetProperties();
// st1 = ProcessString(st1); var feedProps = typeof(TaskSIFeedBackInfo).GetProperties();
// st2 = ProcessString(st2);
resultList = bookProps.GroupJoin(feedProps, l => l.Name.ToUpper(),
// if (st1 != st2) r => r.Name.ToUpper(), (l, r) =>
// { {
// listDiffField.Add(prop); if (compareField.Any(x => x.Equals(l.Name, StringComparison.OrdinalIgnoreCase)))
// } {
// } var currList = r.ToList();
// else if (pBook.PropertyType == typeof(int?))
// { if (currList.Count > 0)
// var dt1 = bookVal as int?; {
// var dt2 = feedVal as int?; var si = r.FirstOrDefault();
// if (dt1 != dt2)
// { var bkVal = l.GetValue(bookingOrder);
// listDiffField.Add(prop); var siVal = si.GetValue(taskSIFeedBackInfo);
// }
// } if (l.PropertyType == typeof(string))
// else if (pBook.PropertyType == typeof(decimal?)) {
// { string st1 = (bkVal as string).AdjustString();
// var dt1 = bookVal as decimal?; string st2 = (siVal as string).AdjustString();
// var dt2 = feedVal as decimal?;
// if (dt1 != dt2) if (!st1.Equals(st2))
// { {
// listDiffField.Add(prop); return l.Name.ToUpper();
// } }
// }
// } return string.Empty;
}
// ViewData["DiffFields"] = listDiffField; else if (l.PropertyType == typeof(int?))
//#endregion {
var dt1 = bkVal as int?;
// #region 箱信息对比 var dt2 = siVal as int?;
// var listDiffCtn = new List<string>();
// var ctns = bookingDB.Ctns.Where(c => c.ORDNO == bill.order.ORDNO).ToList(); if (!dt1.Equals(dt2))
// foreach (var cc in feedbackCtn) {
// { return l.Name.ToUpper();
// var ctnB = ctns.FirstOrDefault(c => c.CNTRNO == cc.CNTRNO); }
// if (ctnB == null)
// { return string.Empty;
// listDiffCtn.Add(cc.CNTRNO); }
// } else if (l.PropertyType == typeof(decimal?))
// else {
// { var dt1 = bkVal as decimal?;
// if (cc.KGS != ctnB.KGS var dt2 = siVal as decimal?;
// || cc.PKGS != ctnB.PKGS
// || cc.SEALNO != ctnB.SEALNO if (!dt1.Equals(dt2))
// || cc.CTNALL != ctnB.CTNALL {
// || cc.CBM != ctnB.CBM) return l.Name.ToUpper();
// { }
// listDiffCtn.Add(cc.CNTRNO);
// } return string.Empty;
// } }
// } }
// ViewData["DiffCtns"] = listDiffCtn;
// } 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