diff --git a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs b/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
deleted file mode 100644
index 5bdf242..0000000
--- a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using Kingdee.BOS;
-using Kingdee.BOS.Core.DynamicForm.PlugIn;
-using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
-using Kingdee.BOS.Log;
-using Kingdee.BOS.Orm;
-using Kingdee.BOS.Orm.DataEntity;
-using Kingdee.BOS.ServiceHelper;
-using Kingdee.BOS.Util;
-using System;
-using System.ComponentModel;
-using System.Dynamic;
-
-namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
-{
- [HotUpdate, Description("销售增值税专用发票_保存后事件")]
- public class AfterSave : AbstractOperationServicePlugIn
- {
- public override void OnPreparePropertys(PreparePropertysEventArgs e)
- {
- base.OnPreparePropertys(e);
- // 根据日志中的实际实体属性名来添加
- e.FieldKeys.Add("FIDD");
- e.FieldKeys.Add("FSEQQ");
- e.FieldKeys.Add("SRCBILLTYPEID"); // 实体属性名(没有F前缀)
- e.FieldKeys.Add("SRCBILLNO"); // 实体属性名(没有F前缀)
- e.FieldKeys.Add("SEQ");
- e.FieldKeys.Add("BILLNO"); // 单据编号(主表字段)
- }
-
-
- public override void EndOperationTransaction(EndOperationTransactionArgs e)
- {
- base.EndOperationTransaction(e);
- foreach (var dataEntity in e.DataEntitys)
- {
- var billObj = dataEntity as DynamicObject;
- if (billObj == null)
- continue;
-
- // 获取单据体
- var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
- if (entrys == null || entrys.Count == 0)
- continue;
-
- foreach (var entry in entrys)
- {
- // 使用 Id 获取主键值
- var entryId = Convert.ToInt64(entry.GetPrimaryKeyValue());
- var fidd = entry["FIDD"];
- var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
-
- if (fiddValue > 0)
- {
- // FIDD > 0 时,判断是否需要回写
- var srcBillNo = entry["SRCBILLNO"]?.ToString() ?? "";
-
- // 判断条件:FIDD != 当前行ID 且 源单编号为空
- if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
- {
- // 从当前单据主表获取单据编号(实体属性名:BILLNO)
- var billNo = billObj["BILLNO"]?.ToString() ?? "";
- // 固定源单类型为"销售增值税专用发票"
- var srcBillType = "IV_SALESIC";
-
- // 回写当前单据体:源单类型、源单编号
- // 这里使用数据库字段名(带F前缀)
- var updateSql = $@"/*dialect*/
-UPDATE T_IV_SALESICENTRY
-SET FSRCBILLTYPEID = '{srcBillType.Replace("'", "''")}',
- FSRCBILLNO = '{billNo.Replace("'", "''")}'
-WHERE FENTRYID = {entryId}";
- Logger.Error("销售增值税专用发票", updateSql, new Exception());
- Logger.Error("销售增值税专用发票", "78", new Exception());
- DBServiceHelper.Execute(this.Context, updateSql);
- }
- }
- else
- {
- // FIDD <= 0 时,把当前行FID赋值给FIDD,同时把FSEQ赋值给FSEQQ
- var seq = entry["SEQ"]?.ToString() ?? "0";
- var updateSql = $@"/*dialect*/
-UPDATE T_IV_SALESICENTRY
-SET FIDD = {entryId},
- FSEQQ = '{seq.Replace("'", "''")}'
-WHERE FENTRYID = {entryId}";
- Logger.Error("销售增值税专用发票", updateSql, new Exception());
- Logger.Error("销售增值税专用发票", "78", new Exception());
- DBServiceHelper.Execute(this.Context, updateSql);
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj
index 6b51fa1..7ab925c 100644
--- a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj
+++ b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj
@@ -89,7 +89,6 @@
-
@@ -107,6 +106,7 @@
+
diff --git a/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs b/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
index 7b0fa4a..b8aaaf3 100644
--- a/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
+++ b/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
@@ -9,7 +9,7 @@ using Kingdee.BOS.Util;
using System;
using System.ComponentModel;
-namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
+namespace Pilot_KD_Parino.AR_SalesVATInvoice.ServicePlugIn
{
[HotUpdate, Description("销售增值税专用发票_保存后事件")]
public class AfterSave : AbstractOperationServicePlugIn
@@ -58,20 +58,34 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
// 判断条件:FIDD != 当前行ID 且 源单编号为空
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
{
- // 从当前单据主表获取单据编号(实体属性名:BILLNO)
- var billNo = billObj["BILLNO"]?.ToString() ?? "";
+ // 通过源分录ID(FIDD)查询源单据的单据编号
+ string srcBillNoFromSource = "";
+
+ var querySql = $@"/*dialect*/
+SELECT A.FBILLNO
+FROM T_IV_SALESIC A
+INNER JOIN T_IV_SALESICENTRY B ON A.FID = B.FID
+WHERE B.FENTRYID = {fiddValue}";
+
+ var result = DBServiceHelper.ExecuteDynamicObject(this.Context, querySql);
+ if (result != null && result.Count > 0)
+ {
+ srcBillNoFromSource = result[0]["FBILLNO"]?.ToString() ?? "";
+ }
+
+
+
// 固定源单类型为"销售增值税专用发票"
var srcBillType = "IV_SALESIC";
- // 回写当前单据体:源单类型、源单编号
+ // 回写当前单据体:源单类型、源单编号(使用源单据的编号)
// 这里使用数据库字段名(带F前缀)
var updateSql = $@"/*dialect*/
UPDATE T_IV_SALESICENTRY
SET FSRCBILLTYPEID = '{srcBillType.Replace("'", "''")}',
- FSRCBILLNO = '{billNo.Replace("'", "''")}'
+ FSRCBILLNO = '{srcBillNoFromSource.Replace("'", "''")}'
WHERE FENTRYID = {entryId}";
- Logger.Error("销售增值税专用发票", updateSql, new Exception());
- Logger.Error("销售增值税专用发票", "78", new Exception());
+ Logger.Error("销售增值税专用发票_回写源单信息", updateSql, new Exception());
DBServiceHelper.Execute(this.Context, updateSql);
}
}
@@ -95,6 +109,7 @@ WHERE FENTRYID = {entryId}";
{
Logger.Error("销售增值税专用发票出错了:", ex.Message, new Exception());
}
+
}
}
-}
\ No newline at end of file
+}
diff --git a/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs b/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs
index 63c059c..4aa926c 100644
--- a/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs
+++ b/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs
@@ -7,6 +7,7 @@ using Kingdee.BOS.Log;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
+using NPOI.Util;
using Pilot_KD_Parino.Common;
using System;
using System.ComponentModel;
@@ -153,8 +154,11 @@ namespace Pilot_KD_Parino.Sal_Order
if (FSaleOrderEntry_Link.Count > 0)
{
var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection;
- //string sdas=JsonHelper.ToJson(details);
- // Logger.Error("销售订单上游订单的xx ", sdas, new Exception());
+ string sdas = JsonHelper.ToJson(details);
+ Logger.Error("销售订单上游订单的xx ", sdas, new Exception());
+
+
+
//var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry_Link");
//var FbiLLNO = this.View.Model.GetValue("FID");
@@ -164,7 +168,7 @@ namespace Pilot_KD_Parino.Sal_Order
if (entrys != null && entrys.Count > 0)
{
- string yuanF_contractnumber = FEntity["F_contractnumber"].ToString();
+ string yuanF_contractnumber = "";
int i = 0;
foreach (var entry in entrys)
{
@@ -173,14 +177,26 @@ namespace Pilot_KD_Parino.Sal_Order
i++;
var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int();
+ //销售订单找到上游的销售订单
+ string getSourceSql = $@"/*dialect*/select F_CONTRACTNUMBER from T_SAL_ORDER where fid={sBillId} ";
+ var dt333 = DBServiceHelper.ExecuteDynamicObject(this.Context, getSourceSql);
+ if (dt333 == null || dt333.Count == 0)
+ {
+ return;
+ }
+ else
+ {
+ yuanF_contractnumber = dt333.FirstOrDefault()["F_CONTRACTNUMBER"].ToString();
+ }
+
//获取退货类型字段
var F_Returntype = FEntity["F_Returntype"];
//获取纸质合同号
string F_contractnumber = FEntity["F_contractnumber"].ToString();
- Logger.Error("销售订单上游订单的合同号", yuanF_contractnumber, new Exception());
+ Logger.Error("销售订单上游订单的合同号"+ i.ToString(), yuanF_contractnumber, new Exception());
int dashPosition;
if (F_contractnumber.Contains("-TH"))
{
diff --git a/修改合同号一些列订单.txt b/修改合同号一些列订单.txt
new file mode 100644
index 0000000..6d8b2b2
--- /dev/null
+++ b/修改合同号一些列订单.txt
@@ -0,0 +1,42 @@
+select F_CONTRACTNUMBER, * from T_SAL_ORDER
+where fbillno='PL-XSDD20251200583'
+
+--update T_SAL_ORDER set F_CONTRACTNUMBER='P202512090017-HH01'
+--where fbillno='PL-XSDD20251200583'
+
+
+select F_Papercontract, * from T_SAL_DELIVERYNOTICE
+where FBillNo='SEOUT25121086'
+
+--update T_SAL_DELIVERYNOTICE set F_Papercontract='P202512090017-HH01'
+--where FBillNo='SEOUT25121086'
+
+select F_contractnumber,* from T_SAL_OUTSTOCK
+where FBillNo='PL-XSCKD20251200647'
+
+--update T_SAL_OUTSTOCK set F_contractnumber='P202512090017-HH01'
+--where FBillNo='PL-XSCKD20251200647'
+
+
+select F_Paperpro,* from T_AR_RECEIVABLE
+where FBillNo='PL-XSCKD20251200647'
+
+
+--update T_AR_RECEIVABLE set F_Paperpro='P202512090017-HH01'
+--where FBillNo='PL-XSCKD20251200647'
+
+select F_Paper,* from T_AR_RECEIVABLEENTRY
+where fid=129824
+
+--update T_AR_RECEIVABLEENTRY set F_Paper='P202512090017-HH01'
+--where fid=129824
+
+select * from T_PRD_MO a
+where FBillNo='PL-MO20251201392'
+
+
+select F_ZZHTH,* from T_PRD_MOENTRY b
+where fid=129745
+
+--update T_PRD_MOENTRY set F_ZZHTH='P202512090017-HH01'
+--where fid=129745