增加领料申请接口

This commit is contained in:
gongxh
2021-05-28 12:03:27 +08:00
parent aa9153e25b
commit f87905fd06
8 changed files with 357 additions and 15 deletions

View File

@@ -71,6 +71,7 @@
<Compile Include="Request\Bom.cs" /> <Compile Include="Request\Bom.cs" />
<Compile Include="Request\Inventorybu.cs" /> <Compile Include="Request\Inventorybu.cs" />
<Compile Include="Request\Inventoryall.cs" /> <Compile Include="Request\Inventoryall.cs" />
<Compile Include="Request\MaterialApp.cs" />
<Compile Include="Request\MaterialAppProvide.cs" /> <Compile Include="Request\MaterialAppProvide.cs" />
<Compile Include="Request\MaterialAppVouch.cs" /> <Compile Include="Request\MaterialAppVouch.cs" />
<Compile Include="Request\MomOrderRequest.cs" /> <Compile Include="Request\MomOrderRequest.cs" />

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Request
{
public class MaterialAppDetail
{
public string MaterialCode { get; set; }
public decimal Qty { get; set; }
public DateTime Duedate { get; set; }
public int SourceDetailId { get; set; }
}
public class MaterialApp
{
/// <summary>
/// 生单日期
/// </summary>
public DateTime Date { get; set; }
public string source { get; set; }
public string SourceCode { get; set; }
public IEnumerable<MaterialAppDetail> MaterialAppDetails = new List<MaterialAppDetail>();
}
}

View File

@@ -68,6 +68,7 @@
<Compile Include="Base\SupplierDAL.cs" /> <Compile Include="Base\SupplierDAL.cs" />
<Compile Include="Account\Accinformation.cs" /> <Compile Include="Account\Accinformation.cs" />
<Compile Include="System\User.cs" /> <Compile Include="System\User.cs" />
<Compile Include="U8DbHelper.cs" />
<Compile Include="U8LoginContext.cs" /> <Compile Include="U8LoginContext.cs" />
<Compile Include="Base\UnitDAL.cs" /> <Compile Include="Base\UnitDAL.cs" />
<Compile Include="Base\WarehouseDAL.cs" /> <Compile Include="Base\WarehouseDAL.cs" />

View File

@@ -16,19 +16,104 @@ namespace NX.ERP.U8.Store
} }
public string AddVoucher(object param) public string AddVoucher(NX.ERP.Model.Request.MaterialApp param)
{ {
VoucherParameter voucherParameter = new VoucherParameter //conn=new AccessViolationException
U8DbHelper u8DbHelper = new U8DbHelper(NX.ERP.U8.U8LoginContext.Instance.Constr);
u8DbHelper.BeginTrans();
try
{ {
VoucherType = this.VoucherID,
DomHead = new DOMDocumentClass(), VoucherParameter voucherParameter = new VoucherParameter
DomBody = new DOMDocumentClass() {
}; VoucherType = this.VoucherID,
DOMDocument domHead = voucherParameter.DomHead; DomHead = new DOMDocumentClass(),
DOMDocument domBody = voucherParameter.DomBody; DomBody = new DOMDocumentClass(),
voucherParameter.DomHead.loadXML(HeadTemplate); cnnFrom = u8DbHelper.Conn
voucherParameter.DomBody.loadXML(BodyTemplate); };
return ""; DOMDocument domHead = voucherParameter.DomHead;
DOMDocument domBody = voucherParameter.DomBody;
voucherParameter.DomHead.loadXML(HeadTemplate);
voucherParameter.DomBody.loadXML(BodyTemplate);
IXMLDOMElement headXml = domHead.createElement("z:row");
headXml.setAttribute("id", "0");
headXml.setAttribute("ccode", "AAAAA");
headXml.setAttribute("ddate", param.Date);
headXml.setAttribute("vt_id", "30718");
headXml.setAttribute("csource", param.source);
headXml.setAttribute("cRdCode", "206");
headXml.setAttribute("cDepCode", "5401");
Model.MOM.MomOrder Order = null;
if (param.source == "生产订单")
{
Order = new Mom.MomOrderDAL().GetModel(param.SourceCode);
}
foreach (var item in param.MaterialAppDetails)
{
var bodyXml = domBody.createElement("z:row");
bodyXml.setAttribute("autoid", 0);
bodyXml.setAttribute("cinvcode", item.MaterialCode);
bodyXml.setAttribute("iquantity", item.Qty);
bodyXml.setAttribute("dduedate", item.Duedate);
if (param.source == "生产订单")
{
var detail = Order.Allocates.FirstOrDefault(m => m.AllocateId == item.SourceDetailId);
if (detail == null)
{
throw new Exception("未知的明细项");
}
//
bodyXml.setAttribute("invcode", detail.momDetail.ProductCode);
bodyXml.setAttribute("cmocode", param.SourceCode);
bodyXml.setAttribute("imoseq", detail.momDetail.SortSeq);
bodyXml.setAttribute("iposeq", "000");
bodyXml.setAttribute("iorderdid", 0);
bodyXml.setAttribute("iMPoIds", item.SourceDetailId);
bodyXml.setAttribute("ipesodid", item.SourceDetailId);
bodyXml.setAttribute("ipesotype", 7);
bodyXml.setAttribute("cpesocode", param.SourceCode);
bodyXml.setAttribute("ipesoseq", detail.momDetail.SortSeq);
///下面更新
///
// var strsql = "update mom_moallocate set RequisitionIssQty=RequisitionIssQty+" + item.Qty + " where AllocateId=" + item.SourceDetailId;
//var row= u8DbHelper.U8ExcuteNoneQuery(strsql);
// if (row==0)
// {
// throw new Exception("未知明细");
// }
}
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
}
domHead.selectSingleNode("//rs:data").appendChild(headXml);
var code = this.AddRdVoucher(voucherParameter);
u8DbHelper.CommitTrans();
return code;
}
catch (Exception err)
{
u8DbHelper.RollbackTrans();
throw err;
}
finally
{
u8DbHelper.Dispose();
}
} }

View File

@@ -303,7 +303,14 @@ namespace NX.ERP.U8.Store
{ {
u8ApiBroker.AssignNormalValue("domPosition", para.DomPosition); u8ApiBroker.AssignNormalValue("domPosition", para.DomPosition);
} }
if (para.cnnFrom != null)
{
u8ApiBroker.AssignNormalValue("cnnFrom", para.cnnFrom);
}
else
{
u8ApiBroker.AssignNormalValue("cnnFrom", null);
}
u8ApiBroker.AssignNormalValue("cnnFrom", null); u8ApiBroker.AssignNormalValue("cnnFrom", null);
if (para.DOMMsg != null) if (para.DOMMsg != null)
{ {

201
NX.ERP.U8/U8DbHelper.cs Normal file
View File

@@ -0,0 +1,201 @@
using ADODB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.U8
{
public class U8DbHelper:IDisposable
{
public string _connstring;
private string string_0;
public bool _DbErr;
public Connection Conn;
public string ConnectionString
{
get
{
return _connstring;
}
set
{
_connstring = value;
}
}
public string ErrMsg
{
get
{
return string_0;
}
}
public U8DbHelper(string connstr)
{
_connstring = connstr;
if (_connstring != null && !(_connstring == string.Empty))
{
Conn = new ConnectionClass();
Conn.ConnectionString = _connstring;
try
{
Conn.Open();
_DbErr = false;
}
catch (Exception)
{
_DbErr = true;
string_0 = "数据连接配置错误,无法从指定的数据连接字符串打开数据库,请检查WEB.CONFIG文件";
throw new Exception(ErrMsg);
}
}
else
{
_DbErr = true;
string_0 = "数据连接配置错误,没有配置数据连接";
}
}
public U8DbHelper(Connection cnt)
{
_connstring = cnt.ConnectionString;
Conn = cnt;
try
{
if (Conn.State != 1)
{
Conn.Open();
_DbErr = false;
}
}
catch (Exception)
{
_DbErr = true;
string_0 = "数据连接配置错误,无法从指定的数据连接字符串打开数据库,请检查WEB.CONFIG文件";
throw new Exception(ErrMsg);
}
}
public static bool IsConn(string connectionString)
{
Connection connection = new ConnectionClass();
try
{
connection.ConnectionString = connectionString;
connection.Open();
}
catch
{
return false;
}
finally
{
if (connection.State == 1)
{
connection.Close();
}
connection = null;
}
return true;
}
public Recordset U8ExcuteRecord(string strSQL)
{
try
{
object RecordsAffected;
return Conn.Execute(strSQL, out RecordsAffected);
}
catch (Exception)
{
throw;
}
}
public int U8ExcuteNoneQuery(string strSQL)
{
try
{
object RecordsAffected;
Conn.Execute(strSQL, out RecordsAffected);
return (int)RecordsAffected;
}
catch (Exception)
{
throw;
}
}
public void BeginTrans()
{
try
{
if (Conn != null)
{
Conn.BeginTrans();
}
}
catch (Exception)
{
throw;
}
}
public void RollbackTrans()
{
try
{
if (Conn != null)
{
Conn.RollbackTrans();
}
}
catch (Exception)
{
throw;
}
}
public void CommitTrans()
{
try
{
if (Conn != null)
{
Conn.CommitTrans();
}
}
catch (Exception)
{
throw;
}
}
public void Dispose()
{
try
{
if (Conn != null)
{
if (Conn.State == 1)
{
Conn.Close();
}
Conn = null;
}
}
catch (Exception)
{
throw;
}
}
}
}

View File

@@ -46,6 +46,10 @@ namespace NX.ERP.U8
private string sBodyWhere_Order; private string sBodyWhere_Order;
public ADODB.Connection cnnFrom { get; set; } = null;
public string SBodyWhere_Order public string SBodyWhere_Order
{ {
get get

View File

@@ -77,12 +77,12 @@ namespace NX.ERP.WebAPi.Controllers.Store
} }
[Route("api/MaterialApp/Add")] [Route("api/MaterialApp/Add")]
[HttpGet] [HttpPost]
public string Add() public string Add([FromBody]NX.ERP.Model.Request.MaterialApp param)
{ {
var dal = new NX.ERP.U8.Store.MaterialAppDAL(); var dal = new NX.ERP.U8.Store.MaterialAppDAL();
return dal.AddVoucher(null); return dal.AddVoucher(param);
} }