增加领料申请接口
This commit is contained in:
@@ -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(),
|
||||
DomBody = new DOMDocumentClass()
|
||||
};
|
||||
DOMDocument domHead = voucherParameter.DomHead;
|
||||
DOMDocument domBody = voucherParameter.DomBody;
|
||||
voucherParameter.DomHead.loadXML(HeadTemplate);
|
||||
voucherParameter.DomBody.loadXML(BodyTemplate);
|
||||
return "";
|
||||
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
DomBody = new DOMDocumentClass(),
|
||||
cnnFrom = u8DbHelper.Conn
|
||||
};
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user