2021-05-11 19:35:30 +08:00
|
|
|
|
using MSXML2;
|
|
|
|
|
|
using NX.ERP.U8.Store;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using UFIDA.U8.U8APIFramework;
|
|
|
|
|
|
using UFIDA.U8.U8MOMAPIFramework;
|
2021-06-01 11:44:55 +08:00
|
|
|
|
using Dapper;
|
2021-05-11 19:35:30 +08:00
|
|
|
|
namespace NX.ERP.U8.AP
|
|
|
|
|
|
{
|
2021-05-29 10:18:22 +08:00
|
|
|
|
public class APVouch : STVoucherBase
|
2021-05-11 19:35:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
public APVouch() : base("应付单", "U8API/APVouch")
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override string AddUrl
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{BaseUrl}/SaveVouch";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override string LoadUrl
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{BaseUrl}/GetVouchData";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override string UpdateUrl
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{BaseUrl}/SaveVouch";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-01 11:44:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-29 10:18:22 +08:00
|
|
|
|
protected override void LoadRdVoucher(STVoucherParameter para)
|
2021-05-11 19:35:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
U8EnvContext u8EnvContext = new U8EnvContext();
|
|
|
|
|
|
u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin;
|
|
|
|
|
|
U8ApiAddress apiAddress = new U8ApiAddress(this.LoadUrl);
|
|
|
|
|
|
U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext);
|
2021-05-22 16:37:58 +08:00
|
|
|
|
u8EnvContext.SetApiContext("VouchType", this.VoucherID);
|
|
|
|
|
|
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("linkid", "");
|
2021-05-11 19:35:30 +08:00
|
|
|
|
|
|
|
|
|
|
if (!u8ApiBroker.Invoke())
|
|
|
|
|
|
{
|
|
|
|
|
|
Exception exception = u8ApiBroker.GetException();
|
|
|
|
|
|
if (exception != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (exception is MomSysException)
|
|
|
|
|
|
{
|
|
|
|
|
|
MomSysException ex = exception as MomSysException;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (exception is MomBizException)
|
|
|
|
|
|
{
|
|
|
|
|
|
MomBizException ex2 = exception as MomBizException;
|
|
|
|
|
|
}
|
|
|
|
|
|
string exceptionString = u8ApiBroker.GetExceptionString();
|
|
|
|
|
|
if (exceptionString.Length != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
para.ReturnValue = false;
|
|
|
|
|
|
u8ApiBroker.Release();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
DOMDocument dOMDocument = u8ApiBroker.GetResult("ohead") as DOMDocument;
|
|
|
|
|
|
if (dOMDocument != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
para.DomHead = new DOMDocumentClass();
|
|
|
|
|
|
para.DomHead.loadXML(dOMDocument.xml);
|
|
|
|
|
|
}
|
|
|
|
|
|
DOMDocument dOMDocument2 = u8ApiBroker.GetResult("obody") as DOMDocument;
|
|
|
|
|
|
if (dOMDocument2 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
para.DomBody = new DOMDocumentClass();
|
|
|
|
|
|
para.DomBody.loadXML(dOMDocument2.xml);
|
|
|
|
|
|
}
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
|
|
|
|
|
|
para.ErrMsg = u8ApiBroker.GetResult("xmlmsg") as string;
|
|
|
|
|
|
u8ApiBroker.Release();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception err)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw err;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-29 10:18:22 +08:00
|
|
|
|
protected override string AddRdVoucher(STVoucherParameter para)
|
2021-05-11 19:35:30 +08:00
|
|
|
|
{
|
2021-05-26 10:15:12 +08:00
|
|
|
|
U8EnvContext u8EnvContext = new U8EnvContext
|
|
|
|
|
|
{
|
|
|
|
|
|
U8Login = U8LoginContext.Instance.ClsLogin
|
|
|
|
|
|
};
|
|
|
|
|
|
U8ApiAddress apiAddress = new U8ApiAddress(this.AddUrl);
|
|
|
|
|
|
U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext);
|
2021-05-11 19:35:30 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-05-26 10:15:12 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
u8EnvContext.SetApiContext("VouchType", this.VoucherID);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("ohead", para.DomHead);
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("obody", para.DomBody);
|
|
|
|
|
|
//给普通参数isadd赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示true新增,false修改
|
2021-05-22 16:37:58 +08:00
|
|
|
|
u8ApiBroker.AssignNormalValue("isadd", true);
|
2021-05-11 19:35:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (para.DOMMsg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("xmlmsg", para.DOMMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
u8ApiBroker.AssignNormalValue("xmlmsg", new DOMDocumentClass());
|
|
|
|
|
|
}
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
if (!u8ApiBroker.Invoke())
|
|
|
|
|
|
{
|
|
|
|
|
|
Exception exception = u8ApiBroker.GetException();
|
|
|
|
|
|
if (exception != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (exception is MomSysException)
|
|
|
|
|
|
{
|
|
|
|
|
|
MomSysException ex = exception as MomSysException;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (exception is MomBizException)
|
|
|
|
|
|
{
|
|
|
|
|
|
MomBizException ex2 = exception as MomBizException;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
string exceptionString = u8ApiBroker.GetExceptionString();
|
|
|
|
|
|
if (exceptionString.Length != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
para.ReturnValue = false;
|
|
|
|
|
|
|
2021-05-26 10:15:12 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
|
|
|
|
|
|
para.ErrMsg = u8ApiBroker.GetResult("xmlmsg") as string;
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-26 10:15:12 +08:00
|
|
|
|
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
|
|
|
|
|
if (!para.ReturnValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception(para.ErrMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception err)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
throw err;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
2021-05-26 10:15:12 +08:00
|
|
|
|
u8ApiBroker.Release();
|
2021-05-11 19:35:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-22 16:37:58 +08:00
|
|
|
|
public string AddVocher(NX.ERP.Model.Request.ApVouch ApVouch)
|
2021-05-11 19:35:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2021-06-01 11:44:55 +08:00
|
|
|
|
var id = Guid.NewGuid().ToString().Replace("-", "");
|
2021-05-29 10:18:22 +08:00
|
|
|
|
STVoucherParameter voucherParameter = new STVoucherParameter
|
2021-05-11 19:35:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
VoucherType = this.VoucherID,
|
|
|
|
|
|
DomHead = new DOMDocumentClass(),
|
|
|
|
|
|
DomBody = new DOMDocumentClass()
|
|
|
|
|
|
};
|
|
|
|
|
|
DOMDocument domHead = voucherParameter.DomHead;
|
|
|
|
|
|
DOMDocument domBody = voucherParameter.DomBody;
|
|
|
|
|
|
voucherParameter.DomHead.loadXML(HeadTemplate);
|
|
|
|
|
|
voucherParameter.DomBody.loadXML(BodyTemplate);
|
|
|
|
|
|
IXMLDOMElement headXml = domHead.createElement("z:row");
|
2021-05-26 10:15:12 +08:00
|
|
|
|
// headXml.setAttribute("cVenAbbName", "无锡市鑫奥");
|
2021-05-22 16:37:58 +08:00
|
|
|
|
headXml.setAttribute("cDwCode", ApVouch.supplierCode);
|
2021-05-26 10:15:12 +08:00
|
|
|
|
headXml.setAttribute("dVouchDate", ApVouch.Date);
|
2021-05-22 16:37:58 +08:00
|
|
|
|
headXml.setAttribute("iExchRate", 1);
|
2021-05-26 10:15:12 +08:00
|
|
|
|
headXml.setAttribute("iAmount_f", ApVouch.Amount);
|
2021-05-22 16:37:58 +08:00
|
|
|
|
headXml.setAttribute("iRAmount", ApVouch.Amount);
|
|
|
|
|
|
headXml.setAttribute("cVouchType", "P0");
|
|
|
|
|
|
headXml.setAttribute("cTypeName", "其他应付单");
|
|
|
|
|
|
headXml.setAttribute("cCode", "220201");
|
|
|
|
|
|
headXml.setAttribute("cexch_name", "人民币");
|
|
|
|
|
|
headXml.setAttribute("VT_ID", 8056);
|
|
|
|
|
|
headXml.setAttribute("bd_c", false);
|
|
|
|
|
|
headXml.setAttribute("bStartFlag", false);
|
2021-06-01 11:44:55 +08:00
|
|
|
|
headXml.setAttribute("cVouchID", "");
|
2021-05-22 16:37:58 +08:00
|
|
|
|
headXml.setAttribute("cFlag", "AP");
|
|
|
|
|
|
headXml.setAttribute("cDeptCode", ApVouch.DeptCode);
|
|
|
|
|
|
headXml.setAttribute("cDigest", ApVouch.Digest);
|
2021-06-01 11:44:55 +08:00
|
|
|
|
headXml.setAttribute("cDefine10", id);
|
|
|
|
|
|
// headXml.setAttribute("cLink", "");
|
2021-05-11 19:35:30 +08:00
|
|
|
|
IXMLDOMElement bodyXml;
|
2021-05-22 16:37:58 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
//for (var n = 0; n < storeIn.details.Count(); n++)
|
|
|
|
|
|
//{
|
2021-05-22 16:37:58 +08:00
|
|
|
|
//var detail = storeIn.details[n];
|
|
|
|
|
|
bodyXml = domBody.createElement("z:row");
|
|
|
|
|
|
|
|
|
|
|
|
bodyXml.setAttribute("cDeptCode", ApVouch.DeptCode);
|
|
|
|
|
|
bodyXml.setAttribute("cCode", "");
|
|
|
|
|
|
bodyXml.setAttribute("iExchRate", 1);
|
|
|
|
|
|
bodyXml.setAttribute("cexch_name", "人民币");
|
|
|
|
|
|
bodyXml.setAttribute("iAmount", ApVouch.Amount);
|
|
|
|
|
|
bodyXml.setAttribute("iAmount_f", ApVouch.Amount);
|
|
|
|
|
|
bodyXml.setAttribute("iAmt_s", 0);
|
2021-06-01 11:44:55 +08:00
|
|
|
|
// bodyXml.setAttribute("cLink", "");
|
2021-05-22 16:37:58 +08:00
|
|
|
|
headXml.setAttribute("cDwCode", ApVouch.supplierCode);
|
|
|
|
|
|
bodyXml.setAttribute("bd_c", true);
|
|
|
|
|
|
|
|
|
|
|
|
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
2021-05-11 19:35:30 +08:00
|
|
|
|
//}
|
|
|
|
|
|
domHead.selectSingleNode("//rs:data").appendChild(headXml);
|
2021-06-01 11:44:55 +08:00
|
|
|
|
|
2021-05-11 19:35:30 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-06-01 11:44:55 +08:00
|
|
|
|
AddRdVoucher(voucherParameter);
|
|
|
|
|
|
var number = new NX.ERP.U8.VoucherHistory();
|
2021-05-26 14:47:17 +08:00
|
|
|
|
number.IncNumber("P0", "单据日期", ApVouch.Date.ToString("yyyyMM"));
|
2021-06-01 11:44:55 +08:00
|
|
|
|
var strsql = "select Auto_ID from AP_ApVouch where cDefine10=@id";
|
|
|
|
|
|
string code = "";
|
|
|
|
|
|
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
|
|
|
|
|
{
|
|
|
|
|
|
code = conn.ExecuteScalar<string>(strsql, new { id }, null, 30, System.Data.CommandType.Text);
|
|
|
|
|
|
}
|
|
|
|
|
|
return code;
|
2021-05-11 19:35:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception err)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw err;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|