采购接口功能全部完成
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
using ADODB;
|
||||
using log4net;
|
||||
using MSXML2;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.AP
|
||||
{
|
||||
public class clsVouchFacade
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
public async Task<BaseResult<string>> SaveVouch(BaseLogin login, Dictionary<string, object> input,string VouchClass,bool bGetCode=false,string codeKey="",bool bPrintDom=false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var clsVouchFacade = $"UFAPBO.clsVouchFacade".GetComObject();
|
||||
|
||||
clsVouchFacade.Init(VouchClass, login._vbLogin, login.Connection);
|
||||
|
||||
IXMLDOMDocument2 domHead = new DOMDocument();
|
||||
IXMLDOMDocument2 domBody = new DOMDocument();
|
||||
|
||||
var errMsg = "";
|
||||
|
||||
//if (!clsVouchFacade.GetVouchData("0", ref domHead, ref domBody, ref errMsg))
|
||||
//{
|
||||
// throw new Exception(errMsg);
|
||||
//}
|
||||
|
||||
domHead = input.ToDocument2(domHead);
|
||||
|
||||
if (!input.TryGetValue("body", out var bodys))
|
||||
{
|
||||
await Task.Delay(1);
|
||||
throw new Exception("无法获取表体数据");
|
||||
}
|
||||
|
||||
if (!(bodys is List<Dictionary<string, object>> dictionarys) || dictionarys.Count <= 0)
|
||||
{
|
||||
throw new Exception("无法获取表体数据");
|
||||
}
|
||||
|
||||
if (bGetCode)
|
||||
{
|
||||
var cardNum = "";
|
||||
|
||||
switch (VouchClass)
|
||||
{
|
||||
case "收款单":
|
||||
cardNum = "AR48";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
var clsBillComponent = "UFBillComponent.clsBillComponent".GetComObject();
|
||||
|
||||
if (!clsBillComponent.InitBill(login._vbLogin.UfDbName, cardNum))
|
||||
{
|
||||
throw new Exception("初始化单据编号组件失败");
|
||||
}
|
||||
|
||||
var newCode = clsBillComponent.GetNumber(clsBillComponent.GetBillFormat());
|
||||
|
||||
logInfo.Debug($"获取新单号:{newCode}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(newCode))
|
||||
{
|
||||
CommonHelper.SetDomKeyValue(domHead, codeKey, newCode);
|
||||
}
|
||||
|
||||
input[codeKey] = newCode;
|
||||
}
|
||||
|
||||
logInfo.Debug("填充表体DOM...");
|
||||
domBody = dictionarys.ToDocument2(domBody);
|
||||
|
||||
if (bPrintDom)
|
||||
{
|
||||
logInfo.Debug("开始输入DOM...");
|
||||
|
||||
logInfo.Debug(domHead.xml);
|
||||
|
||||
logInfo.Debug(domBody.xml);
|
||||
}
|
||||
|
||||
var res = new BaseResult<string>();
|
||||
|
||||
clsVouchFacade.bOutTrans = true;
|
||||
|
||||
res.bSuccess = clsVouchFacade.SaveVouch(domHead, domBody, ref errMsg);
|
||||
|
||||
if (!res.bSuccess)
|
||||
{
|
||||
throw new Exception(errMsg);
|
||||
}
|
||||
|
||||
res.message = "保存成功";
|
||||
res.voucherCode = "";
|
||||
res.voucherId = "";
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "保存失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user