Files
U8-Import/NX.ERP.U8/Store/MaterielStoreOutDAL.cs

134 lines
5.4 KiB
C#
Raw Normal View History

2021-01-12 14:45:59 +08:00
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
{
2021-01-13 12:37:27 +08:00
public MaterielStoreOutDAL() : base("11", "U8API/MaterialOut")
2021-01-12 14:45:59 +08:00
{
}
2021-01-13 13:30:24 +08:00
2021-01-12 14:45:59 +08:00
2021-01-15 09:26:17 +08:00
public string AddVocher(Model.Request.MaterielStoreOut storeOut)
2021-01-12 14:45:59 +08:00
{
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("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);
2021-01-18 16:44:18 +08:00
headXml.setAttribute("vt_id", new VT().GetDefaltVTID("0412"));
2021-01-12 14:45:59 +08:00
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", "领料");
2021-01-13 10:21:56 +08:00
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode);
2021-01-15 10:22:35 +08:00
if (Order == null)
{
throw new Exception($"未知订单:{storeOut.SourceCode}");
}
2021-01-12 14:45:59 +08:00
headXml.setAttribute("iproorderid", Order.Id);
headXml.setAttribute("cmpocode", Order.Code);
2021-01-15 10:22:35 +08:00
headXml.setAttribute("cpspcode", "");
2021-01-12 14:45:59 +08:00
headXml.setAttribute("crdname", "材料出库");
headXml.setAttribute("cdepcode", "24");
2021-01-15 10:22:35 +08:00
//headXml.setAttribute("cdepname", "研发LA组");
2021-01-12 14:45:59 +08:00
IXMLDOMElement bodyXml;
for (var n = 0; n < storeOut.Details.Count(); n++)
{
var detail = storeOut.Details[n];
2021-01-15 10:22:35 +08:00
var alllocate = Order.Allocates.FirstOrDefault(m => { return m.Id == detail.SorceDetailId; });
if (alllocate == null)
{
throw new Exception($"未知订单明细行:{detail.SorceDetailId}");
}
if (alllocate.InvCode != detail.InvCode)
{
throw new Exception($"订单明细存货编号与出库存货编号不符:{detail.InvCode}");
}
var moomDetail = Order.Details.FirstOrDefault(m => { return m.Id == alllocate.ModId; });
2021-01-12 14:45:59 +08:00
bodyXml = domBody.createElement("z:row");
bodyXml.setAttribute("autoid", n);
2021-01-15 10:22:35 +08:00
bodyXml.setAttribute("cinvcode", detail.InvCode);
2021-01-12 14:45:59 +08:00
bodyXml.setAttribute("iquantity", detail.Quantity);
2021-01-13 13:30:24 +08:00
bodyXml.setAttribute("irowno", n + 1);
2021-01-12 14:45:59 +08:00
bodyXml.setAttribute("cbatch", "");
bodyXml.setAttribute("cvmivencode", "");
2021-01-15 09:26:17 +08:00
bodyXml.setAttribute("cposition", detail.Position);
2021-01-12 14:45:59 +08:00
bodyXml.setAttribute("editprop", "A");
bodyXml.setAttribute("innum", 10);
bodyXml.setAttribute("autoid", storeOut.Id);
bodyXml.setAttribute("id", storeOut.Id);
2021-01-15 10:22:35 +08:00
bodyXml.setAttribute("impoids", detail.SorceDetailId);
2021-01-12 14:45:59 +08:00
bodyXml.setAttribute("cmocode", Order.Code);
2021-01-13 13:30:24 +08:00
bodyXml.setAttribute("invcode", "904008");//产品编码
2021-01-12 14:45:59 +08:00
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
{
2021-01-13 13:30:24 +08:00
return AddRdVoucher(voucherParameter);
2021-01-12 14:45:59 +08:00
}
catch (Exception err)
{
throw err;
}
}
}
}