Files
U8-Import/NX.ERP.U8/Store/MaterielStoreOutDAL.cs
2021-01-13 10:21:56 +08:00

135 lines
4.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using MSXML2;
using NX.ERP.Model.Store;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UFIDA.U8.U8APIFramework;
using UFIDA.U8.U8APIFramework.Parameter;
using UFIDA.U8.U8MOMAPIFramework;
namespace NX.ERP.U8.Store
{
public class MaterielStoreOutDAL : VoucherBase
{
public MaterielStoreOutDAL() : base("11")
{
}
public string AddVocher(MaterielStoreOut storeOut)
{
VoucherParameter voucherParameter = new VoucherParameter
{
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");
//headXml.setAttribute("id", storeOut.Id);
headXml.setAttribute("ccode", storeOut.Code); //DomHead[0]["ccode"] = ""; //入库单号,string类型
headXml.setAttribute("ddate", storeOut.Date.ToShortDateString()); //DomHead[0]["ddate"] = ""; //入库日期,DateTime类型
headXml.setAttribute("bpufirst", "0");
headXml.setAttribute("bisstqc", "0");
headXml.setAttribute("bomfirst", "0");
headXml.setAttribute("biafirst", "0");
headXml.setAttribute("brdflag", 0);
headXml.setAttribute("cmaker", "");
headXml.setAttribute("cvouchtype", this.VoucherID);
headXml.setAttribute("vt_id", "65");
headXml.setAttribute("editprop", "A");
headXml.setAttribute("cdepcode", "1");
headXml.setAttribute("crdcode", "201");
headXml.setAttribute("cpersoncode", "it");
headXml.setAttribute("cwhcode", storeOut.Whcode);
headXml.setAttribute("csource", storeOut.Source);
if (storeOut.Source == "生产订单")
{
headXml.setAttribute("cbustype", "领料");
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode);
headXml.setAttribute("iproorderid", Order.Id);
headXml.setAttribute("cmpocode", Order.Code);
headXml.setAttribute("cpspcode", "904008");
headXml.setAttribute("crdname", "材料出库");
headXml.setAttribute("cdepcode", "24");
headXml.setAttribute("cdepname", "研发LA组");
IXMLDOMElement bodyXml;
for (var n = 0; n < storeOut.Details.Count(); n++)
{
var detail = storeOut.Details[n];
var alllocate = Order.moAllocates.First(m => { return m.Id == detail.sorceDetailId; });
var moomDetail = Order.momDetails.First(m => { return m.Id == alllocate.ModId; });
bodyXml = domBody.createElement("z:row");
bodyXml.setAttribute("autoid", n);
bodyXml.setAttribute("cinvcode", detail.Cinvcode);
bodyXml.setAttribute("iquantity", detail.Quantity);
bodyXml.setAttribute("irowno", n+1);
bodyXml.setAttribute("cbatch", "");
bodyXml.setAttribute("cvmivencode", "");
bodyXml.setAttribute("cposition", detail.BinCode);
bodyXml.setAttribute("editprop", "A");
bodyXml.setAttribute("innum", 10);
bodyXml.setAttribute("autoid", storeOut.Id);
bodyXml.setAttribute("id", storeOut.Id);
bodyXml.setAttribute("impoids", detail.sorceDetailId);
bodyXml.setAttribute("cmocode", Order.Code);
bodyXml.setAttribute("invcode", "904008");
bodyXml.setAttribute("cwhcode", storeOut.Whcode);
bodyXml.setAttribute("imoseq", 1);
bodyXml.setAttribute("ipesotype", "7");
bodyXml.setAttribute("cpesocode", "");
bodyXml.setAttribute("ipesodid", "");
bodyXml.setAttribute("ipesoseq", "");
bodyXml.setAttribute("isotype", "");
bodyXml.setAttribute("csocode", "");
bodyXml.setAttribute("isodid", "");
bodyXml.setAttribute("isoseq", "");
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
}
}
domHead.selectSingleNode("//rs:data").appendChild(headXml);
try
{
return U8LoginContext.Instance.AddRdVoucher("U8API/MaterialOut/Add", voucherParameter);
}
catch (Exception err)
{
throw err;
}
}
}
}