Compare commits
3 Commits
dceb51cc5e
...
c7156ef7ce
| Author | SHA1 | Date | |
|---|---|---|---|
| c7156ef7ce | |||
| 419de835cf | |||
| 78894e4703 |
File diff suppressed because one or more lines are too long
@ -0,0 +1,96 @@
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
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("FENTRYID");
|
||||
e.FieldKeys.Add("FIDD");
|
||||
e.FieldKeys.Add("FSEQQ");
|
||||
e.FieldKeys.Add("FSRCBILLTYPEID");
|
||||
e.FieldKeys.Add("FSRCBILLNO");
|
||||
}
|
||||
|
||||
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
|
||||
{
|
||||
base.AfterExecuteOperationTransaction(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)
|
||||
{
|
||||
var entryId = Convert.ToInt64(entry["Id"]);
|
||||
var fidd = entry["FIDD"];
|
||||
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
||||
|
||||
if (fiddValue > 0)
|
||||
{
|
||||
// FIDD > 0 时,判断是否需要回写
|
||||
var srcBillNo = entry["FSRCBILLNO"]?.ToString() ?? "";
|
||||
|
||||
// FIDD != 当前行FENTRYID 且 源单编号为空 时才回写
|
||||
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
||||
{
|
||||
// 查询源单据体信息(主键=FIDD的明细行)
|
||||
var sql = $@"/*dialect*/
|
||||
SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ
|
||||
FROM T_IV_SALESICENTRY
|
||||
WHERE FENTRYID = {fiddValue}";
|
||||
|
||||
var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
||||
if (result == null || result.Count == 0)
|
||||
continue;
|
||||
|
||||
var srcData = result[0];
|
||||
var srcBillTypeId = srcData["FSRCBILLTYPEID"];
|
||||
var srcBillNoValue = srcData["FSRCBILLNO"];
|
||||
|
||||
// 回写当前单据体:源单类型、源单编号
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FSRCBILLTYPEID = '{srcBillTypeId}',
|
||||
FSRCBILLNO = '{srcBillNoValue}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIDD <= 0 时,把当前行FENTRYID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FIDD = FENTRYID,
|
||||
FSEQQ = FSEQ
|
||||
WHERE FENTRYID = {entryId}";
|
||||
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,6 +102,6 @@
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy $(TargetPath) "E:\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin"</PostBuildEvent>
|
||||
<PostBuildEvent>copy $(TargetPath) "D:\Program Files (x86)\Kingdee\K3Cloud\WebSite\Bin\$(TargetFileName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
BIN
Gatedge.K3.Pilot.PlugIn/bin/Debug/Oracle.DataAccess.dll
Normal file
BIN
Gatedge.K3.Pilot.PlugIn/bin/Debug/Oracle.DataAccess.dll
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
Pilot_KD_Parino.zip
Normal file
BIN
Pilot_KD_Parino.zip
Normal file
Binary file not shown.
102
Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
Normal file
102
Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Log;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Util;
|
||||
using Pilot_KD_Parino.Common;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Pilot_KD_Parino.AR_SalesVATInvoice.ServicePlugIn
|
||||
{
|
||||
[HotUpdate, Description("销售增值税专用发票_保存后事件")]
|
||||
public class AfterSave : AbstractOperationServicePlugIn
|
||||
{
|
||||
public override void OnPreparePropertys(PreparePropertysEventArgs e)
|
||||
{
|
||||
base.OnPreparePropertys(e);
|
||||
// 添加需要加载的字段
|
||||
e.FieldKeys.Add("FENTRYID");
|
||||
e.FieldKeys.Add("FIDD");
|
||||
e.FieldKeys.Add("FSEQQ");
|
||||
e.FieldKeys.Add("FSRCBILLTYPEID");
|
||||
e.FieldKeys.Add("FSRCBILLNO");
|
||||
}
|
||||
|
||||
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
|
||||
{
|
||||
base.AfterExecuteOperationTransaction(e);
|
||||
|
||||
|
||||
foreach (var dataEntity in e.DataEntitys)
|
||||
{
|
||||
var billObj = dataEntity as DynamicObject;
|
||||
if (billObj == null)
|
||||
continue;
|
||||
var sdsas = JsonHelper.ToJson(billObj);
|
||||
Logger.Error("销售增值税专用发票", sdsas, new Exception());
|
||||
// 获取单据体
|
||||
var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
|
||||
if (entrys == null || entrys.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var entryId = Convert.ToInt64(entry["FENTRYID"]);
|
||||
var fidd = entry["FIDD"];
|
||||
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
||||
|
||||
if (fiddValue > 0)
|
||||
{
|
||||
// FIDD > 0 时,判断是否需要回写
|
||||
var srcBillNo = entry["FSRCBILLNO"]?.ToString() ?? "";
|
||||
Logger.Error("销售增值税专用发票", "56", new Exception());
|
||||
// FIDD != 当前行FENTRYID 且 源单编号为空 时才回写
|
||||
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
||||
{
|
||||
// 查询源单据体信息(主键=FIDD的明细行)
|
||||
var sql = $@"/*dialect*/
|
||||
SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ
|
||||
FROM T_IV_SALESICENTRY
|
||||
WHERE FENTRYID = {fiddValue}";
|
||||
Logger.Error("销售增值税专用发票", sql, new Exception());
|
||||
var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
||||
if (result == null || result.Count == 0)
|
||||
continue;
|
||||
Logger.Error("销售增值税专用发票", "69", new Exception());
|
||||
var srcData = result[0];
|
||||
var srcBillTypeId = srcData["FSRCBILLTYPEID"];
|
||||
var srcBillNoValue = srcData["FSRCBILLNO"];
|
||||
|
||||
// 回写当前单据体:源单类型、源单编号
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FSRCBILLTYPEID = '{srcBillTypeId}',
|
||||
FSRCBILLNO = '{srcBillNoValue}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "80", new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error("销售增值税专用发票", "", new Exception());
|
||||
// FIDD <= 0 时,把当前行FENTRYID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FIDD = FENTRYID,
|
||||
FSEQQ = FSEQ
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票", "93", new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,6 +322,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AR_SalesVATInvoice\ServicePlugIn\AfterSave.cs" />
|
||||
<Compile Include="Common\BOSCommon.cs" />
|
||||
<Compile Include="Common\CombinaAddClass1.cs" />
|
||||
<Compile Include="Common\CombinaClass.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user