This commit is contained in:
余宇波 2025-04-18 10:10:08 +08:00
parent 8dcb23d7ee
commit 1ee535273b
5 changed files with 300 additions and 83 deletions

View File

@ -1017,6 +1017,7 @@ namespace Pilot_KD_Parino.Common
{
FBILLNO = "";
Id = "";
// 调用保存操作
IOperationResult saveResult = BusinessDataServiceHelper.Save(
ctx,

View File

@ -330,6 +330,7 @@
<Compile Include="QPHY_AutoWrire\SearchWriteRecord.cs" />
<Compile Include="ReceivablesDetails\ReceivablesPlugIn.cs" />
<Compile Include="Sal_Order\Bill.cs" />
<Compile Include="Sal_Order\PushSaleOutBillPlugIn.cs" />
<Compile Include="Sal_Order\YJAuditPlugIn.cs" />
<Compile Include="SQL\SqlManage_yuyubo.cs" />
<Compile Include="SQL\SqlManage.cs" />

View File

@ -2,6 +2,7 @@
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
using Kingdee.BOS.App.Core.Utils;
using Kingdee.BOS.BusinessEntity.BusinessFlow;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
@ -51,6 +52,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var showParameter = new DynamicFormShowParameter();
showParameter.FormId = "NAAD_ZiDongHeXiao";
showParameter.ParentPageId = this.View.PageId;
showParameter.PageId = this.View.PageId + "_Filter";
showParameter.OpenStyle.CacheId = this.View.PageId;
this.View.ShowForm(showParameter, action => FilterCallBack(action));
return;
/*
SaleBILLLIS = new List<CombinaClass>();
ReceiveBILLLIST = new List<CombinaClass>();
List<CombinaClass> SaleBILLLISnew = new List<CombinaClass>();
@ -58,10 +69,10 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//删除四个单据体
this.View.Model.DeleteEntryData("FEntity");
this.View.Model.DeleteEntryData("FEntity2");
var FOrgId = this.Context.CurrentOrganizationInfo.ID;
var FShuaXin = this.View.Model.GetValue("FShuaXin");
//调用SQL获取数据
var WriteOrderDate = SQL.SqlManage_yuyubo.GetWriteOrderDate3(this.Context, Convert.ToString(FOrgId));
var WriteReceiveDate = SQL.SqlManage_yuyubo.GetWriteReceiveDate3(this.Context, Convert.ToString(FOrgId));
@ -165,6 +176,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
}
this.View.UpdateView("FEntity2");
*/
}
/// <summary>
@ -368,6 +380,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
{
base.AfterBarItemClick(e);
//点击过滤按钮,弹出过滤窗体
if (e.BarItemKey.Equals("MBBA_tbButton", StringComparison.OrdinalIgnoreCase))
{
var showParameter = new DynamicFormShowParameter();
showParameter.FormId = "NAAD_ZiDongHeXiao";
showParameter.ParentPageId = this.View.PageId;
showParameter.PageId = this.View.PageId + "_Filter";
showParameter.OpenStyle.CacheId = this.View.PageId;
this.View.ShowForm(showParameter, action => FilterCallBack(action));
}
//自动匹配
if (e.BarItemKey.ToString().Equals("MBBA_tbButton_2"))
{
@ -649,7 +671,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("F_PendingAmount", item.FDAMOUNT, item.FRow);
this.View.Model.SetValue("F_BenCi", item.BenCi, item.FRow);
this.View.Model.SetValue("F_MBBA_Decimal_3iy", item.FYAMOUNT, item.FRow);
this.View.Model.SetValue("F_ISHX",true, item.FRow);
this.View.Model.SetValue("F_ISHX", false, item.FRow);
List<string> strings = new List<string>();
if (item.FCONTRACTNUMBER != null)
strings = item.FCONTRACTNUMBER.Split(',').ToList();
@ -685,7 +707,7 @@ 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", true, Rowindex + i);
this.View.Model.SetValue("F_ISHX", false, Rowindex + i);
}
@ -838,8 +860,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FPARENTROWID = Convert.ToString(item["PARENTROWID"]),
});
var shouKuanList = ReceiveBILLLIST2.Where(t => t.F_RowNew == 1).ToList();
List<string> errorList = new List<string>();
var eee = ReceiveBILLLIST2.Where(t => t.FDAMOUNT < t.BenCi).ToList();
if (eee.Count > 0)
{
string kk =string.Join(",", eee.Select(t => t.FBIllNO).ToList());
errorList.Add("这些订单的本次核销金额大于待核销金额"+ kk);
}
var shouKuanList = ReceiveBILLLIST2.Where(t => t.F_RowNew == 1).ToList();
shouKuanList.ForEach(item =>
{
var sales = ReceiveBILLLIST2.Where(t => t.FPARENTROWID == item.FROWID && t.FROWID != item.FROWID).ToList();
@ -896,17 +926,12 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
return;
}
#endregion
//用于存储生成成功的收款单
List<string> strings1 = new List<string>();
List<string> successFbillNo = new List<string>();
int ISXSNUM = 0;
errorList = new List<string>();
//循环收款单/新增核销记录
@ -989,6 +1014,8 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
});
}
}
#region DataChanged()
/// <summary>
/// 单据体值更新事件
@ -1262,5 +1289,183 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
ExpandWaiting = 64,///0000 0100 0000包含展开等待数据请求行
Summary = 128///0001 0000 000汇总类型数据行 
}
public void FilterCallBack(FormResult action)
{
if (action.ReturnData != null)
{
FilterParameter returnData = action.ReturnData as FilterParameter;//过滤框返回的数据
DynamicObject dyObj = returnData.CustomFilter as DynamicObject;
//获取组织FID
DynamicObject FSaleOrg = dyObj["F_ZhuZhi2"] as DynamicObject;
string FSaleOrgId = "";
string where1 = " and 1=1";
string where2 = " and 1=1";
if (FSaleOrg != null)
{
FSaleOrgId = Convert.ToString(FSaleOrg["ID"]);
where1 += $@" AND A.FSALEORGID = {FSaleOrgId}";
where2 += $@" AND A.FSALEORGID = {FSaleOrgId}";
}
////获取客户单位
//DynamicObject CUST = dyObj["FClient"] as DynamicObject;
//string CustFid = "";
//if (CUST != null)
//{
// CustFid = Convert.ToString(CUST["ID"]);
// where1 += $@" and A.FCUSTID = '{CustFid}'";
// where2 += $@" and A.FCONTACTUNIT = '{CustFid}'";
//}
//获取多选客户单位
var ZZS = returnData.CustomFilter["FClientList"] as DynamicObjectCollection;
string CustFid = "";
if (ZZS.Count > 0)
{
List<string> zzList = new List<string>();
//循环获取多选组织FID
foreach (DynamicObject dobj in ZZS)
{
DynamicObject dynamic = dobj["FClientList"] as DynamicObject;
zzList.Add(dynamic["ID"].ToString());
}
CustFid = string.Join("','", zzList);
where1 += $@" and A.FCUSTID in ('{CustFid}')";
where2 += $@" and A.FCONTACTUNIT in ('{CustFid}')";
}
//获取收款日期
var FSDate = Convert.ToString(dyObj["F_ShouKuan1"]);
if (!string.IsNullOrWhiteSpace(FSDate))
{
where2 += $@" and A.FDATE >='{FSDate}'";
}
//获取收款结束日期
var FEDate = Convert.ToString(dyObj["F_ShouKuan2"]);
if (!string.IsNullOrWhiteSpace(FEDate))
{
DateTime end = DateTime.Parse(FEDate).Date.AddDays(1);
where2 += $@" and A.FDATE < '{end}'";
}
SaleBILLLIS = new List<CombinaClass>();
ReceiveBILLLIST = new List<CombinaClass>();
List<CombinaClass> SaleBILLLISnew = new List<CombinaClass>();
List<CombinaClass> ReceiveBILLLISTNew = new List<CombinaClass>();
//删除四个单据体
this.View.Model.DeleteEntryData("FEntity");
this.View.Model.DeleteEntryData("FEntity2");
//var FShuaXin = this.View.Model.GetValue("FShuaXin");
//调用SQL获取数据
var WriteOrderDate = SQL.SqlManage_yuyubo.GetWriteOrderDate3(this.Context, FSaleOrgId, where1);
var WriteReceiveDate = SQL.SqlManage_yuyubo.GetWriteReceiveDate3(this.Context, FSaleOrgId, where2);
SaleBILLLIS = WriteOrderDate.Select(item => new CombinaClass
{
Fid = Convert.ToInt32(item["FID"]),
FBIllNO = Convert.ToString(item["FBIllNO"]),
FCONTRACTNUMBER = Convert.ToString(item["F_CONTRACTNUMBER"]),
FClient = Convert.ToInt32(item["FCUSTID"]),
FDate = Convert.ToString(item["FDate"]),
FALLAMOUNT = Convert.ToDouble(item["FALLAMOUNT"]),
FYAMOUNT = Convert.ToDouble(item["FYAMOUNT"]),
FDAMOUNT = Convert.ToDouble(item["FDAMOUNT"]),
FCreated = Convert.ToInt32(item["FCREATORID"]),
FSalesman = Convert.ToInt32(item["FSALERID"]),
FIs30 = Convert.ToBoolean(item["FIs30"]),
FType = Convert.ToString(item["FType"]),
BenCi = Convert.ToDouble(item["BenCi"]),
F_Ordercategory2 = Convert.ToString(item["F_Ordercategory2"]),
F_Ordercategory = Convert.ToString(item["F_Ordercategory"]),
FInvoiceAmount = Convert.ToDecimal(item["FInvoiceAmount"]),
}).ToList();
ReceiveBILLLIST = WriteReceiveDate.Select(item => new CombinaClass
{
Fid = Convert.ToInt32(item["FID"]),
FBIllNO = Convert.ToString(item["FBIllNO"]),
FDate = Convert.ToString(item["FDate"]),
FALLAMOUNT = Convert.ToDouble(item["FALLAMOUNT"]),
FYAMOUNT = Convert.ToDouble(item["FYAMOUNT"]),
FDAMOUNT = Convert.ToDouble(item["FDAMOUNT"]),
FClient = Convert.ToInt32(item["FCONTACTUNIT"]),
FCreated = Convert.ToInt32(item["FCREATORID"]),
FRemark = Convert.ToString(item["FREMARK"]),
FSalesman = Convert.ToInt32(item["FSALEERID"]),
F_RowNew = 1,
BenCi = 0,
}).ToList();
var kehu = ReceiveBILLLIST.Select(t => t.FClient).Distinct().ToList();
SaleBILLLIS = SaleBILLLIS.Where(t => kehu.Contains(t.FClient)).ToList();
SaleBILLLIS2 = SaleBILLLIS.ToList();
//绑定销售订单数据
for (int i = 0; i < SaleBILLLIS2.Count; i++)
{
int rowindex = this.View.Model.GetEntryRowCount("FEntity");
this.View.Model.CreateNewEntryRow("FEntity");
//单据编号
this.View.Model.SetValue("FBILLNO", SaleBILLLIS2[i].FBIllNO, i);
//日期
this.View.Model.SetValue("FDate", DateTime.Now.AddDays(-1 * Convert.ToInt32(SaleBILLLIS2[i].FDate)).ToString("yyyy-MM-dd"), i);
//金额
this.View.Model.SetValue("F_MBBA_Decimal_c1c", SaleBILLLIS2[i].FALLAMOUNT, i);
//类型
this.View.Model.SetValue("FType", SaleBILLLIS2[i].FType, i);
//纸质合同号
this.View.Model.SetValue("FCONTRACTNUMBER", SaleBILLLIS2[i].FCONTRACTNUMBER, i);
//客户名称
this.View.Model.SetValue("FClient", SaleBILLLIS2[i].FClient, i);
//已核销金额
this.View.Model.SetValue("F_MBBA_Decimal_vb1", SaleBILLLIS2[i].FYAMOUNT, i);
//待核销金额
this.View.Model.SetValue("F_MBBA_Decimal_emq", SaleBILLLIS2[i].FDAMOUNT, i);
//商务人员
this.View.Model.SetValue("FCreated", SaleBILLLIS2[i].FCreated, i);
//销售员
this.View.Model.SetValue("FSalesman", SaleBILLLIS2[i].FSalesman, i);
//合同类型、累计开票金额
this.View.Model.SetValue("F_Ordercategory2", SaleBILLLIS2[i].F_Ordercategory2, i);
this.View.Model.SetValue("F_Ordercategory", SaleBILLLIS2[i].F_Ordercategory, i);
this.View.Model.SetValue("FInvoiceAmount", SaleBILLLIS2[i].FInvoiceAmount, i);
}
this.View.UpdateView("FEntity");
for (int i = 0; i < ReceiveBILLLIST.Count; i++)
{
int Rowindex = this.View.Model.GetEntryRowCount("FEntity2");
int RowindexNew = Rowindex;
this.View.Model.CreateNewEntryRow("FEntity2");
string FROWID = SequentialGuid.NewGuid().ToString();
this.View.Model.SetValue("FROWID", FROWID, RowindexNew);
this.View.Model.SetValue("FPARENTROWID", FROWID, RowindexNew);
this.View.Model.SetValue("FBILLNO2", ReceiveBILLLIST[i].FBIllNO, RowindexNew);
this.View.Model.SetValue("F_BenCi", ReceiveBILLLIST[i].BenCi, RowindexNew);
this.View.Model.SetValue("F_PendingAmount", ReceiveBILLLIST[i].FDAMOUNT, RowindexNew);
this.View.Model.SetValue("FDATE2", DateTime.Now.AddDays(-1 * Convert.ToInt32(ReceiveBILLLIST[i].FDate)).ToString("yyyy-MM-dd"), RowindexNew);
this.View.Model.SetValue("F_MBBA_Decimal_imu", ReceiveBILLLIST[i].FALLAMOUNT, RowindexNew);
this.View.Model.SetValue("FClient2", ReceiveBILLLIST[i].FClient, RowindexNew);
this.View.Model.SetValue("FRemark", ReceiveBILLLIST[i].FRemark, RowindexNew);
this.View.Model.SetValue("F_MBBA_Decimal_3iy", ReceiveBILLLIST[i].FYAMOUNT, RowindexNew);
this.View.Model.SetValue("F_MBBA_Decimal_lsn", ReceiveBILLLIST[i].FDAMOUNT, RowindexNew);
this.View.Model.SetValue("FCreated2", ReceiveBILLLIST[i].FCreated, RowindexNew);
this.View.Model.SetValue("FSalesman2", ReceiveBILLLIST[i].FSalesman, RowindexNew);
this.View.Model.SetValue("F_RowNew", ReceiveBILLLIST[i].F_RowNew, RowindexNew);
this.View.Model.SetValue("F_ISHX", false, RowindexNew);
}
this.View.UpdateView("FEntity2");
}
}
}
}

View File

@ -111,10 +111,10 @@ namespace Pilot_KD_Parino.SQL
/// 获取核销收款单信息
/// </summary>
/// <returns></returns>
public static DynamicObjectCollection GetWriteReceiveDate3(Context ctx, string FORGID)
public static DynamicObjectCollection GetWriteReceiveDate3(Context ctx, string FORGID,string where )
{
//定义SQL,调用物料视图
string sql = string.Format(@"/*dialect*/
string sql = string.Format($@"/*dialect*/
SELECT A.FID,
A.FSALEERID,
A.FCONTACTUNIT,
@ -130,9 +130,9 @@ namespace Pilot_KD_Parino.SQL
FROM T_AR_RECEIVEBILL A
WHERE A.FDOCUMENTSTATUS = 'C'
AND A.FISINIT != '1'
AND A.FSALEORGID = {0}
AND A.FRECAMOUNT != A.F_AMOUNT
AND A.FRECAMOUNT >= A.F_AMOUNT
AND A.FRECAMOUNT >= A.F_AMOUNT {where}
order by FCONTACTUNIT,A.FID desc ", FORGID);
return DBServiceHelper.ExecuteDynamicObject(ctx, sql.ToString(), null, null, CommandType.Text, null);
}
@ -216,7 +216,7 @@ namespace Pilot_KD_Parino.SQL
/// 获取核销销售订单信息
/// </summary>
/// <returns></returns>
public static DynamicObjectCollection GetWriteOrderDate3(Context ctx, string FORGID)
public static DynamicObjectCollection GetWriteOrderDate3(Context ctx, string FORGID,string where )
{
//定义SQL,调用物料视图
string sql = string.Format($@"/*dialect*/
@ -240,15 +240,25 @@ namespace Pilot_KD_Parino.SQL
0.00 AS BenCi,
CASE WHEN A.F_Ordercategory ='670cca03263357' THEN 'P类合同' else 'P类合同' end as F_Ordercategory2,
A.F_Ordercategory AS F_Ordercategory,
0.00 as FInvoiceAmount
(
SELECT SUM(F_GeneralInvoice) AS '' FROM (
SELECT F_PaperNumber, t0.FSALEORGID,
CASE WHEN F_ORDERCATEGORY ='67283ced82f38d' THEN FAFTERTOTALTAX
WHEN F_ORDERCATEGORY !='67283ced82f38d' AND F_GENERALINVOICE='Y' THEN 0 ELSE FAFTERTOTALTAX END AS F_GeneralInvoice
--FAFTERTOTALTAX
FROM T_IV_SALESIC t0 WITH(NOLOCK)
INNER JOIN T_SAL_ORDER aa1 WITH(NOLOCK) ON t0.F_PAPERNUMBER=aa1.F_contractnumber AND t0.FSETTLEORGID=aa1.FSALEORGID
--WHERE F_PaperNumber='P202502070004'
) AD WHERE AD.F_PaperNumber = A.F_contractnumber AND ad.FSALEORGID=a.FSALEORGID
GROUP BY F_PaperNumber, FSALEORGID
) as FInvoiceAmount
FROM T_SAL_ORDER A
INNER JOIN T_SAL_ORDERFIN C ON C.FID =A.FID
WHERE
C.FBILLALLAMOUNT_LC <>0
AND A.FSALEORGID = {FORGID}
AND A.FDOCUMENTSTATUS = 'C' AND ISNULL(A.F_CONTRACTNUMBER,'')!=''
AND (A.F_AMOUNT < C.FBILLALLAMOUNT_LC
or A.F_AMOUNT IS NULL) AND A.FBusinessType='NORMAL'
or A.F_AMOUNT IS NULL) AND A.FBusinessType='NORMAL' {where}
) A ORDER BY A.FCUSTID,a.FID desc ");
return DBServiceHelper.ExecuteDynamicObject(ctx, sql.ToString(), null, null, CommandType.Text, null);
}

Binary file not shown.