修复受流程控制不受控制的问题(益邦)

This commit is contained in:
qmj
2025-05-08 22:39:36 +08:00
parent 46c20e2895
commit 9e01715ea2
8 changed files with 210 additions and 112 deletions
@@ -49,5 +49,17 @@ namespace UFIDA.U8.Framework.Api.Common.Entity
[SugarColumn(ColumnDescription = "是否输出DOM")] [SugarColumn(ColumnDescription = "是否输出DOM")]
public bool bPrintDom { get; set; } public bool bPrintDom { get; set; }
/// <summary>
/// 是否流程控制
/// </summary>
[SugarColumn(ColumnDescription = "是否流程控制")]
public bool iswfcontrolled { get; set; }
/// <summary>
/// 流程控制字段
/// </summary>
[SugarColumn(ColumnDescription = "流程控制字段")]
public string cFlowFieldName { get; set; }
} }
} }
@@ -1,8 +1,10 @@
using ADODB; using ADODB;
using log4net; using log4net;
using Microsoft.VisualBasic;
using MSXML2; using MSXML2;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Emit; using System.Reflection.Emit;
using System.Text; using System.Text;
@@ -61,8 +63,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
/// <param name="codeKey"></param> /// <param name="codeKey"></param>
/// <param name="bAudit"></param> /// <param name="bAudit"></param>
/// <param name="bPrintDom"></param> /// <param name="bPrintDom"></param>
/// <param name="iswfcontrolled"></param>
/// <param name="cFlowFieldName"></param>
/// <returns></returns> /// <returns></returns>
public async Task<BaseResult<string>> VoucherSave(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, vouchertype enmVoucherType, bool bPositive = true, string sBillType = null, string sBusType = null, int VoucherState = 2, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool bPrintDom = false) public async Task<BaseResult<string>> VoucherSave(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, vouchertype enmVoucherType, bool bPositive = true, string sBillType = null, string sBusType = null, int VoucherState = 2, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool bPrintDom = false,bool iswfcontrolled=false,string cFlowFieldName= "IsWfControlled")
{ {
try try
{ {
@@ -129,9 +133,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
IXMLDOMDocument2 domMsg = new DOMDocument(); IXMLDOMDocument2 domMsg = new DOMDocument();
IXMLDOMDocument2 curDom = new DOMDocument(); IXMLDOMDocument2 curDom = new DOMDocument();
co.bOutTrans = true;
baseLogin.Connection.BeginTrans();
logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
@@ -140,11 +143,24 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
var res = new BaseResult<string>(); var res = new BaseResult<string>();
if (bAudit)
{
logInfo.Debug("开始事务...");
co.bOutTrans = true;
baseLogin.Connection.BeginTrans();
}
try try
{ {
logInfo.Debug("开始保存..."); logInfo.Debug("开始保存...");
errorMsg = co.VoucherSave(ref domHead, ref domBody, VoucherState, ref vouchId, ref curDom, UserMode, sOverDetailsXml, ref domMsg);
errorMsg = bAudit
? (string)co.VoucherSave2(ref domHead, ref domBody, VoucherState, ref vouchId, sOverDetailsXml, ref domMsg)
: (string)co.VoucherSave(ref domHead, ref domBody, VoucherState, ref vouchId, ref curDom, UserMode, sOverDetailsXml, ref domMsg);
logInfo.Debug("保存结束..."); logInfo.Debug("保存结束...");
logInfo.Debug(errorMsg); logInfo.Debug(errorMsg);
logInfo.Debug($"{vouchId}"); logInfo.Debug($"{vouchId}");
@@ -153,15 +169,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
if (!res.bSuccess) if (!res.bSuccess)
{ {
try
{
baseLogin.Connection.RollbackTrans();
}
catch (Exception ex)
{
logInfo.Error(ex.Message, ex);
}
if (!string.IsNullOrWhiteSpace(errorMsg)) if (!string.IsNullOrWhiteSpace(errorMsg))
{ {
throw new Exception(errorMsg); throw new Exception(errorMsg);
@@ -177,8 +184,20 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
throw new Exception(curDom.xml); throw new Exception(curDom.xml);
} }
throw new Exception("未知错误");
} }
if (iswfcontrolled == false && VoucherState == 2)
{
var strSql = $"UPDATE {vouchers.cBTTblName} SET {cFlowFieldName} = 0 WHERE {vouchers.voucherIdFieldName}={vouchId}";
object rsts = new Recordset();
baseLogin.Connection.Execute(strSql,out rsts);
}
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers); res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
res.voucherId = $"{vouchId}"; res.voucherId = $"{vouchId}";
res.result = errorMsg; res.result = errorMsg;
@@ -186,7 +205,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
} }
catch (Exception) catch (Exception)
{ {
baseLogin.Connection.RollbackTrans(); try
{
if (bAudit)
baseLogin.Connection.RollbackTrans();
}
catch(Exception ex)
{
Trace.WriteLine(ex.Message);
}
throw; throw;
} }
@@ -194,7 +222,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
if (!res.bSuccess) if (!res.bSuccess)
{ {
res.message = "保存失败"; res.message = "保存失败";
baseLogin.Connection.RollbackTrans(); if (bAudit)
baseLogin.Connection.RollbackTrans();
return res; return res;
} }
@@ -225,9 +254,15 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
} }
} }
logInfo.Debug("提交事务...");
baseLogin.Connection.CommitTrans();
if (bAudit)
{
logInfo.Debug("提交事务...");
baseLogin.Connection.CommitTrans();
}
return res; return res;
@@ -122,6 +122,9 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
IXMLDOMDocument2 domMsg = new DOMDocument(); IXMLDOMDocument2 domMsg = new DOMDocument();
errorMsg = ""; errorMsg = "";
var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum);
baseLogin.Connection.BeginTrans(); baseLogin.Connection.BeginTrans();
object vouchId = ""; object vouchId = "";
@@ -140,125 +143,71 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
} }
logInfo.Debug("执行插入操作..."); logInfo.Debug("执行插入操作...");
//var cmd = new Command
//{
// CommandText = "Select '开始执行插入操作'",
// ActiveConnection = baseLogin.Connection
//};
//object rsts = new Recordset();
//cmd.Execute(out rsts);
res.bSuccess = co.Insert(sVouchType, domHead, domBody, null, ref errorMsg, baseLogin.Connection, ref vouchId, ref domMsg, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote); res.bSuccess = co.Insert(sVouchType, domHead, domBody, null, ref errorMsg, baseLogin.Connection, ref vouchId, ref domMsg, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote);
if (res.bSuccess) if (res.bSuccess)
{ {
res.voucherId = $"{vouchId}"; res.voucherId = $"{vouchId}";
logInfo.Debug($"操作完成,操作结果:成功!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]"); logInfo.Debug($"操作完成,操作结果:成功!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
if (bAudit)
{
var res2 = co.Verify(sVouchType, vouchId, ref errorMsg, baseLogin.Connection, null, ref domMsg);
if (!res2)
{
baseLogin.Connection.RollbackTrans();
if (!string.IsNullOrWhiteSpace(errorMsg))
throw new Exception(errorMsg);
if (!string.IsNullOrWhiteSpace(domMsg.xml))
throw new Exception(domMsg.xml);
throw new Exception("审核单据时发生异常,请检查数据");
}
baseLogin.Connection.CommitTrans();
res.message = "新增成功";
}
res.message = "新增成功";
} }
else else
{ {
logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]"); logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
baseLogin.Connection.RollbackTrans();
if (!string.IsNullOrWhiteSpace(errorMsg))
throw new Exception(errorMsg);
if (!string.IsNullOrWhiteSpace(domMsg.xml))
throw new Exception(domMsg.xml);
throw new Exception("新增单据时发生异常,请检查数据");
} }
} }
catch (Exception) catch (Exception)
{ {
baseLogin.Connection.RollbackTrans(); baseLogin.Connection.RollbackTrans();
await Task.Delay(1);
throw; throw;
} }
res.message = errorMsg;
if (res.bSuccess && bAudit)
{
errorMsg = "";
try
{
if (!co.Verify(sVouchType, vouchId, ref errorMsg, baseLogin.Connection, null, ref domMsg))
{
baseLogin.Connection.RollbackTrans();
if (!string.IsNullOrWhiteSpace(errorMsg))
throw new Exception(errorMsg);
throw new Exception("审核单据时发生异常,请检查数据");
}
}
catch (Exception)
{
baseLogin.Connection.RollbackTrans();
res.bSuccess = false;
throw;
}
}
if (!res.bSuccess)
{
baseLogin.Connection.RollbackTrans();
if (!string.IsNullOrWhiteSpace(errorMsg))
throw new Exception(errorMsg);
throw new Exception(domMsg.xml);
}
baseLogin.Connection.CommitTrans();
var rst = new Recordset();
rst.Open($"SELECT CardNumber,BTTblName,BTQName,BWTblName,BWQName,VchListQName,VchTblPrimarykeyNames,ReceiptNOFieldName FROM dbo.vouchers WITH(NOLOCK) WHERE CardNumber='{cCardNum}'", baseLogin.Connection);
if (rst.BOF || rst.EOF)
{
res.bSuccess = false;
res.result = $"已在U8生成单据ID为{vouchId}的单据,但是未能查询到该单据的配置信息!";
}
else
{
rst.MoveFirst();
var fieldName = $"{rst.Fields["c"].Value}";
var codeName = $"{rst.Fields["ReceiptNOFieldName"].Value}";
if (string.IsNullOrWhiteSpace(fieldName) || string.IsNullOrWhiteSpace(codeName))
{
res.voucherCode = $"{res.voucherId}";
}
else
{
if (codeName.Contains("{##}"))
{
codeName = codeName.Split('{', '#', '#', '}')[0];
}
var strSql = $"SELECT {codeName} AS cCode FROM {rst.Fields["BTTblName"].Value} WITH(NOLOCK) WHERE {fieldName}='{vouchId}'";
rst.Close();
rst.Open(strSql, baseLogin.Connection);
if (rst.EOF || rst.BOF)
{
res.voucherCode = "";
}
else
{
rst.MoveFirst();
res.voucherCode = $"{rst.Fields["cCode"].Value}";
}
}
}
res.message = "新增成功";
res.result = $"{vouchId}";
return res; return res;
//var bodys = dictionary.TryGetValue() dictionary["body"];
} }
catch (Exception ex) catch (Exception ex)
{ {
logInfo.Error(ex.Message, ex); logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
Binary file not shown.
+84
View File
@@ -765,6 +765,90 @@
<param name="sOverDetailsXml">为空</param> <param name="sOverDetailsXml">为空</param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.PUController.CancelConfirm(System.String,System.String,System.String,System.Boolean,System.String,System.String,UFIDA.U8.Framework.Api.ControlObject.PU.UseMode,System.String)">
<summary>
弃审单据(单号)
</summary>
<param name="cAccId">系统号</param>
<param name="cCardNum">单据类型编码</param>
<param name="cCode">单号</param>
<param name="bPositive">红蓝标识:True,蓝字</param>
<param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
<param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
<param name="UserMode">CS 0,BS 1;一般CS</param>
<param name="sOverDetailsXml">为空</param>
<returns></returns>
</member>
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.PUController.CancelConfirm(System.String,System.String,System.Int64,System.Boolean,System.String,System.String,UFIDA.U8.Framework.Api.ControlObject.PU.UseMode,System.String)">
<summary>
弃审单据(ID)
</summary>
<param name="cAccId">系统号</param>
<param name="cCardNum">单据类型编码</param>
<param name="voucherId">单据ID</param>
<param name="bPositive">红蓝标识:True,蓝字</param>
<param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
<param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
<param name="UserMode">CS 0,BS 1;一般CS</param>
<param name="sOverDetailsXml">为空</param>
<returns></returns>
</member>
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.PUController.CancelConfirm(System.String,System.String,UFIDA.U8.Framework.Api.Models.STInput,System.Boolean,System.String,System.String,UFIDA.U8.Framework.Api.ControlObject.PU.UseMode,System.String)">
<summary>
弃审单据(批量)
</summary>
<param name="cAccId">系统号</param>
<param name="cCardNum">单据类型编码</param>
<param name="input">报文</param>
<param name="bPositive">红蓝标识:True,蓝字</param>
<param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
<param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
<param name="UserMode">CS 0,BS 1;一般CS</param>
<param name="sOverDetailsXml">为空</param>
<returns></returns>
</member>
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.PUController.Delete(System.String,System.String,System.String,System.Boolean,System.String,System.String,UFIDA.U8.Framework.Api.ControlObject.PU.UseMode,System.String)">
<summary>
删除单据(单号)
</summary>
<param name="cAccId">系统号</param>
<param name="cCardNum">单据类型编码</param>
<param name="cCode">单号</param>
<param name="bPositive">红蓝标识:True,蓝字</param>
<param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
<param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
<param name="UserMode">CS 0,BS 1;一般CS</param>
<param name="sOverDetailsXml">为空</param>
<returns></returns>
</member>
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.PUController.Delete(System.String,System.String,System.Int64,System.Boolean,System.String,System.String,UFIDA.U8.Framework.Api.ControlObject.PU.UseMode,System.String)">
<summary>
删除单据(ID)
</summary>
<param name="cAccId">系统号</param>
<param name="cCardNum">单据类型编码</param>
<param name="voucherId">单据ID</param>
<param name="bPositive">红蓝标识:True,蓝字</param>
<param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
<param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
<param name="UserMode">CS 0,BS 1;一般CS</param>
<param name="sOverDetailsXml">为空</param>
<returns></returns>
</member>
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.PUController.Delete(System.String,System.String,UFIDA.U8.Framework.Api.Models.STInput,System.Boolean,System.String,System.String,UFIDA.U8.Framework.Api.ControlObject.PU.UseMode,System.String)">
<summary>
删除单据(批量)
</summary>
<param name="cAccId">系统号</param>
<param name="cCardNum">单据类型编码</param>
<param name="input">报文</param>
<param name="bPositive">红蓝标识:True,蓝字</param>
<param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
<param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
<param name="UserMode">CS 0,BS 1;一般CS</param>
<param name="sOverDetailsXml">为空</param>
<returns></returns>
</member>
<member name="T:UFIDA.U8.Framework.Api.Controllers.U8.SFCController"> <member name="T:UFIDA.U8.Framework.Api.Controllers.U8.SFCController">
<summary> <summary>
车间管理 车间管理
@@ -0,0 +1,17 @@
{
"ddate": "2025-05-08",
"ccode": "0000000001",
"cbustype": "普通采购",
"cmaker": "demo",
"iswfcontrolled": 0,
"body": [
{
"cinvcode": "01019002063",
"fquantity": 3,
"editprop": "A",
"drequirdate": "2025-05-08",
"darrivedate": "2025-05-08",
"iexchrate": 1
}
]
}
@@ -148,7 +148,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
var co = new clsVoucherCO_PU(); var co = new clsVoucherCO_PU();
var res = await co.VoucherSave(baseLogin, input, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), bPositive, sBillType, sBusType, VoucherState, UserMode, sOverDetailsXml, bGetCode, codeKey, voucherInfo.bVerify, voucherInfo.bPrintDom); var res = await co.VoucherSave(baseLogin, input, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), bPositive, sBillType, sBusType, VoucherState, UserMode, sOverDetailsXml, bGetCode, codeKey, voucherInfo.bVerify, voucherInfo.bPrintDom,voucherInfo.iswfcontrolled,voucherInfo.cFlowFieldName);
return res; return res;
} }
@@ -485,6 +485,7 @@
</Content> </Content>
<Content Include="App_Data\采购入库单模板.json" /> <Content Include="App_Data\采购入库单模板.json" />
<Content Include="App_Data\票据录入模板.json" /> <Content Include="App_Data\票据录入模板.json" />
<Content Include="App_Data\请购单模板.json" />
<None Include="Oracle.DataAccess.Common.Configuration.Section.xsd"> <None Include="Oracle.DataAccess.Common.Configuration.Section.xsd">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>