增加审核参数

This commit is contained in:
qmj
2025-08-28 00:44:34 +08:00
parent b2121a1afb
commit 0720f7a904
24 changed files with 3549 additions and 140 deletions
@@ -864,5 +864,35 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
var cDefWhere = vouchers.cDefWhere;
return $"{cDefWhere} AND {tableName}.{fieldName}='{voucherId}'";
}
public static string GetQuerySql(VouchersInfo vouchers, Dictionary<string, object> input, string cCardPostion="H")
{
var cBTQName = vouchers.cBTQName;
var cBWQName = vouchers.cBWQName;
var voucherIdFieldName = vouchers.voucherIdFieldName;
var tableName = cBTQName;
if (cCardPostion == "H")
{
tableName = cBWQName;
}
if (cCardPostion == "B")
{
tableName = cBWQName;
}
var cDefWhere = vouchers.cDefWhere;
if (string.IsNullOrWhiteSpace(cDefWhere))
{
cDefWhere = "1=1";
}
var strSql = $"SELECT DISTINCT {tableName}.* FROM {cBTQName} {cBTQName} LEFT JOIN {cBWQName} {cBWQName} ON {cBTQName}.[{voucherIdFieldName}]={cBWQName}.[{voucherIdFieldName}] WHERE {cDefWhere} ";
return strSql;
}
}
}
@@ -24,7 +24,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
/// </summary>
public class clsVoucherCO_PU
{
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
protected readonly ILog _logInfo = LogManager.GetLogger("logInfo");
private dynamic InitCo(BaseLogin login, vouchertype enmVoucherType, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
{
@@ -71,8 +71,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
try
{
var errorMsg = "";
logInfo.Debug("开始输出登录信息");
logInfo.Debug(baseLogin._vbLogin.userToken);
_logInfo.Debug("开始输出登录信息");
_logInfo.Debug(baseLogin._vbLogin.userToken);
var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
@@ -80,10 +80,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domCur = new DOMDocument();
logInfo.Debug("开始获取单据默认模板...");
_logInfo.Debug("开始获取单据默认模板...");
co.GetVoucherData(ref domHead, ref domBody, "1=2");
logInfo.Debug("填充表头DOM...");
_logInfo.Debug("填充表头DOM...");
domHead = dictionary.ToDocument2(domHead);
@@ -109,7 +109,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
throw new Exception(errorMsg);
}
logInfo.Debug($"获取新单号:{newCode}");
_logInfo.Debug($"获取新单号:{newCode}");
if (!string.IsNullOrWhiteSpace(newCode))
{
@@ -117,16 +117,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
}
}
logInfo.Debug("填充表体DOM...");
_logInfo.Debug("填充表体DOM...");
domBody = dictionarys.ToDocument2(domBody);
if (bPrintDom)
{
logInfo.Debug("开始输入DOM...");
_logInfo.Debug("开始输入DOM...");
logInfo.Debug(domHead.xml);
_logInfo.Debug(domHead.xml);
logInfo.Debug(domBody.xml);
_logInfo.Debug(domBody.xml);
}
object vouchId = "";
@@ -136,16 +136,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
_logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
logInfo.Debug("开始查询单据配置...");
_logInfo.Debug("开始查询单据配置...");
var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cardNumber);
var res = new BaseResult<string>();
if (bAudit)
{
logInfo.Debug("开始事务...");
_logInfo.Debug("开始事务...");
co.bOutTrans = true;
baseLogin.Connection.BeginTrans();
@@ -154,16 +154,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
try
{
logInfo.Debug("开始保存...");
_logInfo.Debug("开始保存...");
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(errorMsg);
logInfo.Debug($"{vouchId}");
_logInfo.Debug("保存结束...");
_logInfo.Debug(errorMsg);
_logInfo.Debug($"{vouchId}");
res.bSuccess = string.IsNullOrWhiteSpace(errorMsg) && !string.IsNullOrWhiteSpace($"{vouchId}");
@@ -229,7 +229,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
res.message = "保存成功";
logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
_logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
var strWhere = CommonHelper.GetVoucherWhereSqlById(vouchers, vouchId);
@@ -258,7 +258,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
if (bAudit)
{
logInfo.Debug("提交事务...");
_logInfo.Debug("提交事务...");
baseLogin.Connection.CommitTrans();
}
@@ -270,7 +270,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
}
catch (Exception ex)
{
logInfo.Error(ex.Message, ex);
_logInfo.Error(ex.Message, ex);
await Task.Delay(1);
@@ -294,8 +294,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
/// <exception cref="Exception"></exception>
public async Task<List<BaseResult<string>>> Confirm(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, List<string> cCodes, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
{
logInfo.Debug("开始输出登录信息");
logInfo.Debug(baseLogin._vbLogin.userToken);
_logInfo.Debug("开始输出登录信息");
_logInfo.Debug(baseLogin._vbLogin.userToken);
var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
@@ -320,7 +320,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
catch (Exception ex)
{
await Task.Delay(1);
logInfo.Error(ex.Message, ex);
_logInfo.Error(ex.Message, ex);
}
}
@@ -445,7 +445,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domMsg = new DOMDocument();
logInfo.Debug("开始获取单据数据...");
_logInfo.Debug("开始获取单据数据...");
voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere);
var res = new BaseResult<string>
@@ -525,8 +525,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
/// <exception cref="Exception"></exception>
public async Task<List<BaseResult<string>>> CancelConfirm(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, List<string> cCodes, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
{
logInfo.Debug("开始输出登录信息");
logInfo.Debug(baseLogin._vbLogin.userToken);
_logInfo.Debug("开始输出登录信息");
_logInfo.Debug(baseLogin._vbLogin.userToken);
var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
@@ -551,7 +551,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
catch (Exception ex)
{
await Task.Delay(1);
logInfo.Error(ex.Message, ex);
_logInfo.Error(ex.Message, ex);
}
}
@@ -673,7 +673,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domMsg = new DOMDocument();
logInfo.Debug("开始获取单据数据...");
_logInfo.Debug("开始获取单据数据...");
voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere);
var res = new BaseResult<string>
@@ -749,8 +749,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
/// <exception cref="Exception"></exception>
public async Task<List<BaseResult<string>>> Delete(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, List<string> cCodes, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
{
logInfo.Debug("开始输出登录信息");
logInfo.Debug(baseLogin._vbLogin.userToken);
_logInfo.Debug("开始输出登录信息");
_logInfo.Debug(baseLogin._vbLogin.userToken);
var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
@@ -775,7 +775,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
catch (Exception ex)
{
await Task.Delay(1);
logInfo.Error(ex.Message, ex);
_logInfo.Error(ex.Message, ex);
}
}
@@ -897,7 +897,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domMsg = new DOMDocument();
logInfo.Debug("开始获取单据数据...");
_logInfo.Debug("开始获取单据数据...");
voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere);
var res = new BaseResult<string>
@@ -1,11 +1,15 @@
using log4net;
using ADODB;
using log4net;
using MSXML2;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using UFGeneralFilterOCX;
using UFIDA.U8.Framework.Api.ControlObject.Common;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
using UFIDA.U8.Framework.Api.ControlObject.PU;
using UFIDA.U8.Framework.Api.ControlObject.U8M;
@@ -17,32 +21,241 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA
/// </summary>
public class ClsVoucherCO_SA
{
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
protected readonly ILog _logInfo = LogManager.GetLogger("logInfo");
public async Task<BaseResult<string>> Save(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, string VoucherState, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled")
private dynamic InitCo(BaseLogin login, int enmVoucherType)
{
var errorMsg = "";
dynamic objr = new object();
var aaa = "";
var co = "VoucherCO_Sa.ClsVoucherCO_SA".GetComObject();
co.Init(enmVoucherType: enmVoucherType, oLogin: ref login._vbLogin, oConn: ref login.Connection);
return co;
}
public async Task<BaseResult<string>> Save(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, VoucherTypeSA enmVoucherType,int VoucherState=0, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled")
{
try
{
var errorMsg = "";
logInfo.Debug("开始输出登录信息");
logInfo.Debug(baseLogin._vbLogin.userToken);
_logInfo.Debug("开始输出登录信息");
_logInfo.Debug(baseLogin._vbLogin.userToken);
//var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
var co = InitCo(baseLogin, (int)enmVoucherType);
IXMLDOMDocument2 domHead = new DOMDocument();
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domCur = new DOMDocument();
return new BaseResult<string>();
_logInfo.Debug("开始获取单据默认模板...");
co.GetVoucherData(ref domHead, ref domBody, null, true, "1=2");
_logInfo.Debug("填充表头DOM...");
domHead = dictionary.ToDocument2(domHead);
if (!dictionary.TryGetValue("body", out var bodys))
{
await Task.Delay(1);
throw new Exception("无法获取表体数据");
}
if (!(bodys is List<Dictionary<string, object>> dictionarys) || dictionarys.Count <= 0)
{
await Task.Delay(1);
throw new Exception("无法获取表体数据");
}
if (bGetCode)
{
errorMsg = "";
var newCode = "";
if (!co.GetVoucherNO(ref domHead, ref newCode, ref errorMsg))
{
throw new Exception(errorMsg);
}
_logInfo.Debug($"获取新单号:{newCode}");
if (!string.IsNullOrWhiteSpace(newCode))
{
domHead.SetDomKeyValue(codeKey, newCode);
}
}
_logInfo.Debug("填充表体DOM...");
domBody = dictionarys.ToDocument2(domBody);
object vouchId = "";
IXMLDOMDocument2 domMsg = new DOMDocument();
IXMLDOMDocument2 curDom = new DOMDocument();
_logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
_logInfo.Debug("开始查询单据配置...");
var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cardNumber);
var res = new BaseResult<string>();
baseLogin.Connection.BeginTrans();
try
{
_logInfo.Debug("开始保存...");
errorMsg = co.Save(ref domHead, ref domBody, VoucherState, ref vouchId,ref domCur);
_logInfo.Debug("保存结束...");
_logInfo.Debug(errorMsg);
_logInfo.Debug($"{vouchId}");
res.bSuccess = string.IsNullOrWhiteSpace(errorMsg) && !string.IsNullOrWhiteSpace($"{vouchId}");
if (!res.bSuccess)
{
if (!string.IsNullOrWhiteSpace(errorMsg))
{
throw new Exception(errorMsg);
}
if (!string.IsNullOrWhiteSpace(domMsg.xml))
{
throw new Exception(domMsg.xml);
}
if (!string.IsNullOrWhiteSpace(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.voucherId = $"{vouchId}";
res.result = errorMsg;
}
catch (Exception)
{
try
{
if (bAudit)
baseLogin.Connection.RollbackTrans();
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
throw;
}
if (!res.bSuccess)
{
res.message = "保存失败";
if (bAudit)
baseLogin.Connection.RollbackTrans();
return res;
}
res.message = "保存成功";
_logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
var strWhere = CommonHelper.GetVoucherWhereSqlById(vouchers, vouchId);
if (res.bSuccess && bAudit)
{
try
{
errorMsg = VerifyVouch(co, baseLogin.Connection, enmVoucherType, res.voucherCode, res.voucherId, strWhere, true);
if (!string.IsNullOrWhiteSpace(errorMsg))
{
baseLogin.Connection.RollbackTrans();
throw new Exception(errorMsg);
}
}
catch (Exception)
{
baseLogin.Connection.RollbackTrans();
res.bSuccess = false;
throw;
}
}
_logInfo.Debug("提交事务...");
baseLogin.Connection.CommitTrans();
return res;
}
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 };
}
}
public async Task<BaseResult<string>> VerifyVouch(dynamic voucherCO, Connection conn, VoucherTypeSA sVouchType, string cCode, object vouchId, string strWhere,bool bVerify)
{
IXMLDOMDocument2 domHead = new DOMDocument();
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domMsg = new DOMDocument();
_logInfo.Debug("开始获取单据数据...");
voucherCO.GetVoucherData(ref domHead, ref domBody, vouchId, true, strWhere);
var res = new BaseResult<string>
{
voucherCode = cCode,
voucherId = $"{vouchId}"
};
var errorMsg = voucherCO.VerifyVouch(ref domHead, bVerify);
res.bSuccess = string.IsNullOrWhiteSpace(errorMsg);
if (res.bSuccess)
{
res.message = "审核成功";
res.result = res.voucherId;
}
else
{
res.message = "审核失败";
res.result = string.IsNullOrWhiteSpace(errorMsg) ? domMsg.xml : errorMsg;
}
return res;
}
}
}
@@ -12,5 +12,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA
/// 发货单蓝字
/// </summary>
DispatchBlue=9,
SaleBillCommBlue = 2,
SaleBillCommRed = 3,
SaleBillDirect = 4,
SaleBillSpecBlue = 0,
SaleBillSpecRed = 1
}
}
@@ -67,8 +67,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
{
logInfo.Debug("开始获取单据默认模板...");
if (!co.GetDefaultVoucherDom(sVouchType, cCardNum, ref domHead, ref domBody, ref domPosition,
ref errorMsg) || !string.IsNullOrWhiteSpace(errorMsg))
if (!co.GetDefaultVoucherDom(sVouchType, cCardNum, ref domHead, ref domBody, ref domPosition, ref errorMsg) || !string.IsNullOrWhiteSpace(errorMsg))
{
throw new Exception(errorMsg);
}
@@ -158,8 +157,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
if (!res2)
{
baseLogin.Connection.RollbackTrans();
if (!string.IsNullOrWhiteSpace(errorMsg))
throw new Exception(errorMsg);
@@ -168,12 +165,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
throw new Exception("审核单据时发生异常,请检查数据");
}
baseLogin.Connection.CommitTrans();
res.message = "新增成功";
}
baseLogin.Connection.CommitTrans();
res.message = "新增成功";
}
@@ -181,8 +176,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
{
logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
baseLogin.Connection.RollbackTrans();
if (!string.IsNullOrWhiteSpace(errorMsg))
throw new Exception(errorMsg);
@@ -249,11 +249,28 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
#endif
}
_vbLogin = new VBLogin();
_vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{_netLogin.userToken}");
_vbLogin.ConstructLogin(_netLogin.userToken);
if (_netLogin != null)
{
_vbLogin = new VBLogin();
_vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{_netLogin.userToken}");
_vbLogin.ConstructLogin(_netLogin.userToken);
}
else if(_vbLogin==null)
{
_vbLogin = new VBLogin();
_vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}");
if (!_vbLogin.Login(paramter.pSubId, paramter.pAccId, paramter.pYearId, paramter.pUserId, paramter.pPassword, paramter.pDate, paramter.cSrv, paramter.cSerial) && string.IsNullOrWhiteSpace(_vbLogin.userToken))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
}
}
var taskId = DateTime.Now.Ticks.ToString();
_logInfo.Debug($"VB--设置参数:{taskId}");
@@ -2,6 +2,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UFIDA.U8.Framework.Api.ControlObject.Common;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
using UFIDA.U8.Framework.Api.ControlObject.Json;
@@ -174,6 +176,31 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
}
public BaseResult<dynamic> LoadData(string cCardNum, List<int> inputs)
{
try
{
var dataSet = new MOrderDs();
if (inputs == null || inputs.Count <= 0)
throw new Exception("查询未返回任何结果");
foreach (var ds in inputs.Select(input => MOMExecutor.BFMOrder_LoadData("LoadById", input, new DefaultContextContainer())))
{
dataSet.Merge(ds);
}
return new BaseResult<dynamic>() { bSuccess = true, message = "查询成功", result = dataSet };
}
catch (Exception ex)
{
logInfo.Error(ex.Message, ex);
return new BaseResult<dynamic>() { bSuccess = false, message = "删除失败", result = ex.Message };
}
}
//public BaseResult<dynamic> Verify(string cCardNum, List<string> inputs)
//{
// try