From f33377f904fe95d67930bc96b7e2f170a5bb66e9 Mon Sep 17 00:00:00 2001 From: yuyubo <1870149533@qq.com> Date: Sat, 26 Jul 2025 16:29:45 +0800 Subject: [PATCH] 11 --- Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs | 28 ++++++++++++++++++++----- Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs b/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs index 3d90217..bd411dd 100644 --- a/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs +++ b/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs @@ -400,6 +400,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire //自动匹配 if (e.BarItemKey.ToString().Equals("MBBA_tbButton_2")) { + //this.View.ShowMessage("1"); if (status11 == 1) { this.View.ShowWarnningMessage("请先过滤一次数据后再点击[自动核销]"); @@ -484,9 +485,9 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire join u in ReceiveBILLLIST on new { q.FClient, q.FDAMOUNT,q.FBiBie } equals new { u.FClient, u.FDAMOUNT,u.FBiBie } select new { q.FClient, q.FBIllNO, q.FCONTRACTNUMBER, u.FDAMOUNT, UFbillNo = u.FBIllNO, u.FBiBie }).ToList(); //var dasdsas = oneToOneTemp.Where(h => h.FBIllNO == "PL-XSDD20250400471").FirstOrDefault(); - var saleList1 = oneToOneTemp.Select(t => t.FBIllNO).Distinct().ToList(); + var saleList1 = oneToOneTemp.Select(t => t.FBIllNO).Distinct().OrderByDescending(t=>t).ToList(); var ReceiveList1 = oneToOneTemp.Select(t => t.UFbillNo).Distinct().ToList(); - if (saleList1.Count() > ReceiveList1.Count()) + if (SaleBILLLISNew.Count() > ReceiveBILLLIST.Count()) { List deleteFBIllNOList = new List(); ReceiveList1.ForEach(t => @@ -501,11 +502,20 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire DateTime fdate = DateTime.Parse(ReceiveBILLLIST2.FirstOrDefault(h => h.FBIllNO == t).FDate); DateTime begin = fdate.AddDays(-5).Date; DateTime end = fdate.AddDays(6).Date; - var list = SaleBILLLIS.Where(h => DateTime.Parse(h.FDate) >= begin && DateTime.Parse(h.FDate) < end && FBIllNOList.Contains(h.FBIllNO)).OrderByDescending(h => h.FDate).ToList(); + var list = SaleBILLLIS.Where(h => DateTime.Parse(h.FDate) >= begin && DateTime.Parse(h.FDate) < end && FBIllNOList.Contains(h.FBIllNO)) + .OrderByDescending(h => h.FDate).ToList(); if (list.Count > 0) { fbillno = list.FirstOrDefault().FBIllNO; } + else + { + list = SaleBILLLIS.Where(h => FBIllNOList.Contains(h.FBIllNO)).OrderByDescending(h => h.FDate).ToList(); + if (list.Count > 0) + { + fbillno = list.FirstOrDefault().FBIllNO; + } + } } else { @@ -549,7 +559,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire List deleteFBIllNOList = new List(); saleList1.ForEach(t => { - var tempList = oneToOneTemp.Where(h => h.UFbillNo == t && !deleteFBIllNOList.Contains(h.UFbillNo)).ToList(); + var tempList = oneToOneTemp.Where(h => h.FBIllNO == t && !deleteFBIllNOList.Contains(h.UFbillNo)).ToList(); if (tempList.Count > 0) { var FBIllNOList = tempList.Select(h => h.UFbillNo).ToList(); @@ -565,10 +575,18 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire { fbillno = list.FirstOrDefault().FBIllNO; } + else + { + list = ReceiveBILLLIST.Where(h => FBIllNOList.Contains(h.FBIllNO)).OrderByDescending(h => h.FDate).ToList(); + if (list.Count > 0) + { + fbillno = list.FirstOrDefault().FBIllNO; + } + } } else { - fbillno = tempList.FirstOrDefault().FBIllNO; + fbillno = tempList.FirstOrDefault().UFbillNo; } diff --git a/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs b/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs index 99962e0..812a694 100644 --- a/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs +++ b/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs @@ -39,7 +39,7 @@ namespace Pilot_KD_Parino.SQL WHERE A.FDOCUMENTSTATUS = 'C' AND A.FISINIT != '1' AND A.FRECAMOUNTFOR > A.F_AMOUNT {where} - order by FCONTACTUNIT,A.FID desc ", FORGID); + order by FCONTACTUNIT,FDATE desc ", FORGID); return DBServiceHelper.ExecuteDynamicObject(ctx, sql.ToString(), null, null, CommandType.Text, null); }