This commit is contained in:
2025-06-09 18:48:05 +08:00
parent ef80abc9fa
commit d41b16306e
7 changed files with 274 additions and 180 deletions

View File

@@ -14,9 +14,11 @@ using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Msg;
using Kingdee.BOS.Core.Report.PlugIn.Args;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Log;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Exceptions;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
@@ -348,7 +350,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("FBILLNO", SaleBILLLIS[i].FBIllNO, i);
//日期
this.View.Model.SetValue("FDate", SaleBILLLIS[i].FDate, i);
//金额
//订单含税金额(本位币)
this.View.Model.SetValue("F_MBBA_Decimal_c1c", SaleBILLLIS[i].FALLAMOUNT, i);
//类型
this.View.Model.SetValue("FType", SaleBILLLIS[i].FType, i);
@@ -356,9 +358,9 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("FCONTRACTNUMBER", SaleBILLLIS[i].FCONTRACTNUMBER, i);
//客户名称
this.View.Model.SetValue("FClient", SaleBILLLIS[i].FClient, i);
//已核销金额
//已核销金额(原币)
this.View.Model.SetValue("F_MBBA_Decimal_vb1", SaleBILLLIS[i].FYAMOUNT, i);
//待核销金额
//待核销金额(原币)
this.View.Model.SetValue("F_MBBA_Decimal_emq", SaleBILLLIS[i].FDAMOUNT, i);
//单据编号(收款单)
this.View.Model.SetValue("FSKBILLNO", SaleBILLLIS[i].FSKBIllNO, i);
@@ -427,13 +429,18 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FWeiYi = item["FWeiYi"]?.ToString(),
FaHuoAmount30Days = Convert.ToDouble( item["FaHuoAmount30Days"].ToString()),
FInvoiceAmount30Days= Convert.ToDouble(item["FInvoiceAmount30Days"].ToString()),
FHuiLv = Convert.ToDouble(item["FHuiLv"]),
FBiBie = Convert.ToString(item["FBiBie"]),
FYunZaFei_YuanBi = Convert.ToDouble(item["FYunZaFei_YuanBi"]),
FALLAMOUNTY = Convert.ToDouble(item["FJiaShuiHeJi_YuanBi"]),
}).ToList();
var SaleBILLLISNew = SaleBILLLIS.Where(a => a.FISHX != "已核销配对").ToList();
var ReceiveBILLLIST2 = new List<CombinaClass>();
//获取收款单单据体数据
DynamicObjectCollection FEntity2 = this.View.Model.DataObject["FEntity2"] as DynamicObjectCollection;
//string sdsad = JsonConvert.SerializeObject(FEntity2);
//Logger.Error("", "442"+ sdsad, new Exception());
ReceiveBILLLIST2 = FEntity2.Select(item => new CombinaClass
{
FBIllNO = item["FBILLNO2"]?.ToString(),
@@ -447,8 +454,13 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FSalesman = Convert.ToInt32(item["FSalesman2_Id"]),
FCONTRACTNUMBER = item["FCONTRACTNUMBER2"]?.ToString(),
FRow = Convert.ToInt32(item["Seq"]) - 1,
F_RowNew = Convert.ToInt32(item["F_RowNew"])
F_RowNew = Convert.ToInt32(item["F_RowNew"]),
FHuiLv = Convert.ToDouble(item["FHuiLv2"]),
FBiBie = Convert.ToString(item["FBiBie2"]),
FALLAMOUNTY = Convert.ToDouble(item["FShouKuanJinE_YuanBi"]),
}).ToList();
//Logger.Error("","462",new Exception());
//重置并只取父级树形数据
ReceiveBILLLIST = new List<CombinaClass>();
ReceiveBILLLIST = ReceiveBILLLIST2.Where(a => a.F_RowNew == 1 && a.FISHX != "已核销配对").OrderBy(t => t.FClient).ThenBy(t => t.FCONTRACTNUMBER).ThenBy(t => t.FDate).ToList();
@@ -467,10 +479,10 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
Dictionary<string, double> shouKuanDetail = new Dictionary<string, double>();
//先挑1张收款单对应一张销售订单
//1、收款单的待核销金额与订单的待核销金额
//1、收款单的待核销金额与订单的待核销金额, 2025-06-09 增加结算币别也要相等
var oneToOneTemp = (from q in SaleBILLLIS2Sal
join u in ReceiveBILLLIST on new { q.FClient, q.FDAMOUNT } equals new { u.FClient, u.FDAMOUNT }
select new { q.FClient, q.FBIllNO, q.FCONTRACTNUMBER, u.FDAMOUNT, UFbillNo = u.FBIllNO }).ToList();
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 ReceiveList1 = oneToOneTemp.Select(t => t.UFbillNo).Distinct().ToList();
@@ -636,13 +648,13 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
if (SourceType == 0) //只有销售单有这两种匹配逻辑
{
//3、收款单的待核销金额与订单的待最近30天开票金额(客户说只有医院客户,但是代码不做客户名称判断)
//3、收款单的待核销金额与订单的待最近30天开票金额(客户说只有医院客户,但是代码不做客户名称判断), 2025-06-09 增加结算币别也要相等
var SaleBILLLIS2Sa333 = SaleBILLLISNew.Where(t => t.FISHX != "已核销配对" && t.FDAMOUNT > 0).OrderBy(t => t.FClient).ThenByDescending(t => t.FDate).ToList();
ReceiveBILLLIST = ReceiveBILLLIST2.Where(a => a.F_RowNew == 1 && a.FISHX != "已核销配对" && a.FDAMOUNT > 0).OrderBy(t => t.FClient).ThenByDescending(t => t.FDate).ToList();
var oneToOneTemp3 = (from q in SaleBILLLIS2Sa333
join u in ReceiveBILLLIST on new { q.FClient, FDAMOUNT = q.FInvoiceAmount30Days } equals new { u.FClient, u.FDAMOUNT }
select new { q.FClient, q.FBIllNO, q.FCONTRACTNUMBER, u.FDAMOUNT, UFbillNo = u.FBIllNO }).ToList();
join u in ReceiveBILLLIST on new { q.FClient, FDAMOUNT = q.FInvoiceAmount30Days ,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 saleList33 = oneToOneTemp3.Select(t => t.FBIllNO).Distinct().ToList();
var ReceiveList33 = oneToOneTemp3.Select(t => t.UFbillNo).Distinct().ToList();
@@ -727,7 +739,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
ReceiveBILLLIST.ForEach(t =>
{
var tempList = SaleBILLLIS2Sa2.Where(h => h.FClient == t.FClient && h.FISHX != "已核销配对" && t.FDAMOUNT > 0).OrderByDescending(h => h.FDate).ToList();
var tempList = SaleBILLLIS2Sa2.Where(h =>h.FBiBie==t.FBiBie && h.FClient == t.FClient && h.FISHX != "已核销配对" && t.FDAMOUNT > 0).OrderByDescending(h => h.FDate).ToList();
var FDAMOUNT = t.FDAMOUNT;
List<string> heTongList = new List<string>();
@@ -927,7 +939,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
{
this.View.Model.SetValue("FDate2", DateTime.Now.AddDays(-1 * Convert.ToInt32(tempList2[i].FDate)).ToString("yyyy-MM-dd"), Rowindex + i);
}
this.View.Model.SetValue("F_MBBA_Decimal_imu", tempList2[i].FALLAMOUNT, Rowindex + i);
this.View.Model.SetValue("F_MBBA_Decimal_imu", tempList2[i].FALLAMOUNT+ tempList2[i].FYunZaFei_YuanBi * tempList2[i].FHuiLv, Rowindex + i);
this.View.Model.SetValue("FClient2", tempList2[i].FClient, Rowindex + i);
this.View.Model.SetValue("F_RowNew", 2, Rowindex + i);
this.View.Model.SetValue("FCreated2", tempList2[i].FCreated, Rowindex );
@@ -938,6 +950,12 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("F_BenCi", benci, Rowindex + i);
this.View.Model.SetValue("F_MBBA_Decimal_3iy", tempList2[i].FYAMOUNT, Rowindex + i );
this.View.Model.SetValue("F_ISHX", false, Rowindex + i);
this.View.Model.SetValue("FBiBie2", tempList2[i].FBiBie, Rowindex + i);
this.View.Model.SetValue("FHuiLv2", tempList2[i].FHuiLv, Rowindex + i);
this.View.Model.SetValue("FShouKuanJinE_YuanBi", tempList2[i].FALLAMOUNTY + tempList2[i].FYunZaFei_YuanBi, Rowindex + i);
//Logger.Error("", "956", new Exception());
}
@@ -1583,6 +1601,10 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FInvoiceAmount = Convert.ToDecimal(item["FInvoiceAmount"]),
FaHuoAmount30Days = Convert.ToDouble(item["FaHuoAmount30Days"]),
FInvoiceAmount30Days = Convert.ToDouble(item["FInvoiceAmount30Days"]),
FHuiLv= Convert.ToDouble(item["FHuiLv"]),
FBiBie = Convert.ToString(item["FBiBie"]),
FYunZaFei_YuanBi = Convert.ToDouble(item["F_EXPENSES"]),
FALLAMOUNTY= Convert.ToDouble(item["FALLAMOUNTY"]),
}).ToList();
@@ -1600,6 +1622,9 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FSalesman = Convert.ToInt32(item["FSALEERID"]),
F_RowNew = 1,
BenCi = 0,
FHuiLv = Convert.ToDouble(item["FHuiLv"]),
FBiBie = Convert.ToString(item["FBiBie"]),
FALLAMOUNTY = Convert.ToDouble(item["FALLAMOUNTY"]),
}).ToList();
var kehu = ReceiveBILLLIST.Select(t => t.FClient).Distinct().ToList();
@@ -1637,6 +1662,10 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("FInvoiceAmount", SaleBILLLIS2[i].FInvoiceAmount, i);
this.View.Model.SetValue("FInvoiceAmount30Days", SaleBILLLIS2[i].FInvoiceAmount30Days, i);
this.View.Model.SetValue("FaHuoAmount30Days", SaleBILLLIS2[i].FaHuoAmount30Days, i);
this.View.Model.SetValue("FBiBie", SaleBILLLIS2[i].FBiBie, i);
this.View.Model.SetValue("FHuiLv", SaleBILLLIS2[i].FHuiLv, i);
this.View.Model.SetValue("FYunZaFei_YuanBi", SaleBILLLIS2[i].FYunZaFei_YuanBi, i);
this.View.Model.SetValue("FJiaShuiHeJi_YuanBi", SaleBILLLIS2[i].FALLAMOUNTY, i);
//FaHuoAmount30Days = Convert.ToDouble(item["FaHuoAmount30Days"]),
//FInvoiceAmount30Days = Convert.ToDouble(item["FInvoiceAmount30Days"]),
@@ -1666,6 +1695,11 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("F_RowNew", ReceiveBILLLIST[i].F_RowNew, RowindexNew);
this.View.Model.SetValue("F_ISHX", false, RowindexNew);
this.View.Model.SetValue("FBiBie2", ReceiveBILLLIST[i].FBiBie, i);
this.View.Model.SetValue("FHuiLv2", ReceiveBILLLIST[i].FHuiLv, i);
this.View.Model.SetValue("FYunZaFei_YuanBi2", ReceiveBILLLIST[i].FYunZaFei_YuanBi, RowindexNew);
this.View.Model.SetValue("FShouKuanJinE_YuanBi", ReceiveBILLLIST[i].FALLAMOUNTY, RowindexNew);
//Logger.Error("", "1701", new Exception());
}
this.View.UpdateView("FEntity2");
}