增加审核参数
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user