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
|
|
|
|
|
|
{
|
2021-05-19 15:19:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 材料出库单
|
|
|
|
|
|
/// </summary>
|
2021-05-29 10:18:22 +08:00
|
|
|
|
public class MaterialStoreOutDAL : STVoucherBase
|
2021-01-12 14:45:59 +08:00
|
|
|
|
{
|
2021-05-19 15:19:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-01-28 10:10:32 +08:00
|
|
|
|
public MaterialStoreOutDAL() : base("11", "U8API/MaterialOut")
|
2021-01-12 14:45:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-19 15:19:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 按领料单出库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="storeOut"></param>
|
|
|
|
|
|
/// <param name="headXml"></param>
|
|
|
|
|
|
/// <param name="domBody"></param>
|
2021-05-17 15:40:43 +08:00
|
|
|
|
private void ByMaterialApp(Model.Request.MaterialStoreOut storeOut, IXMLDOMElement headXml, DOMDocument domBody)
|
|
|
|
|
|
{
|
2021-05-19 20:09:44 +08:00
|
|
|
|
var metailApp = new U8.Store.MaterialAppDAL().GetModel(storeOut.SourceCode);
|
2021-05-17 15:40:43 +08:00
|
|
|
|
if (metailApp == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("未知的领料申请单");
|
|
|
|
|
|
}
|
|
|
|
|
|
headXml.setAttribute("cbustype", "领料");
|
2021-05-19 15:19:27 +08:00
|
|
|
|
headXml.setAttribute("cbuscode", metailApp.Code);
|
2021-05-20 11:17:06 +08:00
|
|
|
|
|
|
|
|
|
|
string lastProductNo = null;
|
|
|
|
|
|
decimal moqty = 0;
|
|
|
|
|
|
string DeptName = "";
|
|
|
|
|
|
string moCode = "";
|
|
|
|
|
|
string DeptCode = "";
|
2021-05-17 15:40:43 +08:00
|
|
|
|
IXMLDOMElement bodyXml;
|
|
|
|
|
|
for (var n = 0; n < storeOut.Details.Count(); n++)
|
|
|
|
|
|
{
|
2021-05-19 16:33:45 +08:00
|
|
|
|
var detail = storeOut.Details[n];
|
|
|
|
|
|
var materialAppDetail = metailApp.MaterialAppVouchsLst.FirstOrDefault(m => m.MaterialAppDtlId== detail.SorceDetailId);
|
|
|
|
|
|
if (materialAppDetail == null)
|
2021-05-19 15:19:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("未知明细");
|
|
|
|
|
|
}
|
2021-05-20 11:17:06 +08:00
|
|
|
|
|
|
|
|
|
|
if (lastProductNo == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = materialAppDetail.ProductNo;
|
|
|
|
|
|
moqty = materialAppDetail.MoQuantity;
|
|
|
|
|
|
DeptName = materialAppDetail.DeptName;
|
|
|
|
|
|
DeptCode = materialAppDetail.DeptCode;
|
|
|
|
|
|
moCode = materialAppDetail.MoCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (lastProductNo != "" && lastProductNo != materialAppDetail.ProductNo)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = "";
|
|
|
|
|
|
moqty = 0;
|
|
|
|
|
|
}
|
2021-05-17 15:40:43 +08:00
|
|
|
|
bodyXml = domBody.createElement("z:row");
|
2021-05-19 16:33:45 +08:00
|
|
|
|
var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost);
|
|
|
|
|
|
bodyXml.setAttribute("iunitcost", _cost);
|
2021-05-20 09:47:35 +08:00
|
|
|
|
bodyXml.setAttribute("imaids", materialAppDetail.MaterialAppDtlId);//
|
2021-05-19 16:33:45 +08:00
|
|
|
|
var info = new Account.Accinformation();
|
|
|
|
|
|
bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity));
|
|
|
|
|
|
bodyXml.setAttribute("cinvcode", detail.InvCode);
|
|
|
|
|
|
bodyXml.setAttribute("iquantity", detail.Quantity);
|
|
|
|
|
|
bodyXml.setAttribute("irowno", n + 1);
|
|
|
|
|
|
bodyXml.setAttribute("cbatch", "");
|
|
|
|
|
|
bodyXml.setAttribute("cvmivencode", "");
|
|
|
|
|
|
bodyXml.setAttribute("cposition", detail.Position);
|
|
|
|
|
|
bodyXml.setAttribute("editprop", "A");
|
|
|
|
|
|
bodyXml.setAttribute("innum", 10);
|
|
|
|
|
|
bodyXml.setAttribute("imoseq", materialAppDetail.Moseq);
|
2021-05-20 09:47:35 +08:00
|
|
|
|
bodyXml.setAttribute("inquantity", materialAppDetail.Quantit- materialAppDetail.OutQuantity);
|
2021-05-19 16:33:45 +08:00
|
|
|
|
bodyXml.setAttribute("crejectcode", materialAppDetail.RejectCode);
|
|
|
|
|
|
bodyXml.setAttribute("iOMoMID", materialAppDetail.OmomId);
|
|
|
|
|
|
bodyXml.setAttribute("iopseq", materialAppDetail.OpSeq);
|
|
|
|
|
|
bodyXml.setAttribute("copdesc", materialAppDetail.OpDesc);
|
|
|
|
|
|
bodyXml.setAttribute("invcode", materialAppDetail.MaterialCode);
|
|
|
|
|
|
bodyXml.setAttribute("cMoLotCode", materialAppDetail.MoLotCode);
|
|
|
|
|
|
bodyXml.setAttribute("cmocode", materialAppDetail.MoCode);
|
|
|
|
|
|
bodyXml.setAttribute("iMPoIds", materialAppDetail.MPoIds);
|
|
|
|
|
|
bodyXml.setAttribute("comcode", materialAppDetail.OmCode);
|
|
|
|
|
|
bodyXml.setAttribute("iOMoDID", materialAppDetail.OMoDId);
|
|
|
|
|
|
bodyXml.setAttribute("cciqbookcode", materialAppDetail.ciqBookCode);
|
|
|
|
|
|
bodyXml.setAttribute("cmworkcentercode", materialAppDetail.mWorkCenterCode);
|
|
|
|
|
|
bodyXml.setAttribute("cservicecode", materialAppDetail.ServiceCode);
|
|
|
|
|
|
bodyXml.setAttribute("isotype", materialAppDetail.SoType);
|
|
|
|
|
|
bodyXml.setAttribute("csocode", materialAppDetail.SoCode);
|
|
|
|
|
|
bodyXml.setAttribute("isodid", materialAppDetail.SodId);
|
|
|
|
|
|
bodyXml.setAttribute("isoseq", materialAppDetail.SoSeq);
|
|
|
|
|
|
bodyXml.setAttribute("iordertype", materialAppDetail.OrderType);
|
|
|
|
|
|
bodyXml.setAttribute("iordercode", materialAppDetail.OrderCode);
|
|
|
|
|
|
bodyXml.setAttribute("iorderdid", materialAppDetail.OrderdId);
|
|
|
|
|
|
bodyXml.setAttribute("iorderseq", materialAppDetail.OrderSeq);
|
|
|
|
|
|
bodyXml.setAttribute("ipesotype", materialAppDetail.PesoType);
|
|
|
|
|
|
bodyXml.setAttribute("cpesocode", materialAppDetail.PesoCode);
|
|
|
|
|
|
bodyXml.setAttribute("ipesodid", materialAppDetail.PesodId);
|
|
|
|
|
|
bodyXml.setAttribute("ipesoseq", materialAppDetail.PesoSeq);
|
2021-05-17 15:40:43 +08:00
|
|
|
|
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
headXml.setAttribute("cpspcode", lastProductNo);
|
2021-05-20 11:17:06 +08:00
|
|
|
|
headXml.setAttribute("imquantity", moqty);
|
|
|
|
|
|
headXml.setAttribute("cdepname", DeptName);
|
|
|
|
|
|
headXml.setAttribute("cdepcode", DeptCode);
|
|
|
|
|
|
headXml.setAttribute("cmpocode", moCode);
|
2021-05-17 15:40:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生产订单出库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="storeOut"></param>
|
|
|
|
|
|
/// <param name="headXml"></param>
|
|
|
|
|
|
/// <param name="domBody"></param>
|
|
|
|
|
|
private void ByMomOrder(Model.Request.MaterialStoreOut storeOut, IXMLDOMElement headXml, DOMDocument domBody)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
headXml.setAttribute("cbustype", "领料");
|
|
|
|
|
|
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode);
|
|
|
|
|
|
if (Order == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"未知订单:{storeOut.SourceCode}");
|
|
|
|
|
|
}
|
|
|
|
|
|
headXml.setAttribute("iproorderid", Order.ProductOrderId);
|
|
|
|
|
|
headXml.setAttribute("cmpocode", Order.ProductOrderNo);
|
|
|
|
|
|
string lastProductNo = null;
|
|
|
|
|
|
headXml.setAttribute("crdname", "材料出库");
|
|
|
|
|
|
IXMLDOMElement bodyXml;
|
|
|
|
|
|
for (var n = 0; n < storeOut.Details.Count(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var detail = storeOut.Details[n];
|
|
|
|
|
|
var alllocate = Order.Allocates.FirstOrDefault(m => { return m.AllocateId == detail.SorceDetailId; });
|
|
|
|
|
|
if (alllocate == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"未知订单明细行:{detail.SorceDetailId}");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-11-03 09:14:10 +08:00
|
|
|
|
|
|
|
|
|
|
//var U8INV = new NX.ERP.U8.MaterialDAL();
|
|
|
|
|
|
///var invd = U8INV.GetModel(detail.InvCode);
|
|
|
|
|
|
if (alllocate.MaterialCode.ToUpper() != detail.InvCode.ToUpper())
|
2021-05-17 15:40:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"订单明细存货编号与出库存货编号不符:{detail.InvCode}");
|
|
|
|
|
|
}
|
|
|
|
|
|
var moomDetail = Order.ProductDtlLst.FirstOrDefault(m => { return m.ProductOrderDtlId == alllocate.ProductOrderDtlId; });
|
|
|
|
|
|
if (lastProductNo == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = moomDetail.ProductCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (lastProductNo != "" && lastProductNo != moomDetail.ProductCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
headXml.setAttribute("cdepcode", alllocate.momDetail.MDeptCode);
|
|
|
|
|
|
#region 明细
|
|
|
|
|
|
|
|
|
|
|
|
bodyXml = domBody.createElement("z:row");
|
|
|
|
|
|
var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost);
|
|
|
|
|
|
bodyXml.setAttribute("iunitcost", _cost);
|
|
|
|
|
|
var info = new Account.Accinformation();
|
|
|
|
|
|
bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity));
|
|
|
|
|
|
bodyXml.setAttribute("cinvcode", detail.InvCode);
|
|
|
|
|
|
bodyXml.setAttribute("iquantity", detail.Quantity);
|
|
|
|
|
|
bodyXml.setAttribute("irowno", n + 1);
|
|
|
|
|
|
bodyXml.setAttribute("cbatch", "");
|
|
|
|
|
|
bodyXml.setAttribute("cvmivencode", "");
|
|
|
|
|
|
bodyXml.setAttribute("cposition", detail.Position);
|
|
|
|
|
|
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.ProductOrderNo);
|
|
|
|
|
|
bodyXml.setAttribute("invcode", moomDetail.ProductCode);//产品编码
|
|
|
|
|
|
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);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
headXml.setAttribute("cpspcode", lastProductNo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-20 09:47:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="storeOut"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-01-28 10:10:32 +08:00
|
|
|
|
public string AddVocher(Model.Request.MaterialStoreOut storeOut)
|
2021-01-12 14:45:59 +08:00
|
|
|
|
{
|
2021-05-29 10:18:22 +08:00
|
|
|
|
STVoucherParameter voucherParameter = new STVoucherParameter
|
2021-01-12 14:45:59 +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-07-10 16:01:19 +08:00
|
|
|
|
headXml.setAttribute("ccode","AAA"/* storeOut.Code*/); //DomHead[0]["ccode"] = ""; //入库单号,string类型
|
2021-01-12 14:45:59 +08:00
|
|
|
|
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);
|
2021-01-22 15:57:04 +08:00
|
|
|
|
headXml.setAttribute("cmaker", storeOut.Maker);
|
2021-01-12 14:45:59 +08:00
|
|
|
|
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("crdcode", "201");
|
|
|
|
|
|
headXml.setAttribute("cwhcode", storeOut.Whcode);
|
|
|
|
|
|
headXml.setAttribute("csource", storeOut.Source);
|
|
|
|
|
|
if (storeOut.Source == "生产订单")
|
|
|
|
|
|
{
|
2021-05-17 15:40:43 +08:00
|
|
|
|
ByMomOrder(storeOut, headXml, domBody);
|
|
|
|
|
|
}
|
2021-05-19 17:04:12 +08:00
|
|
|
|
else if (storeOut.Source == "领料申请单")
|
2021-05-17 15:40:43 +08:00
|
|
|
|
{
|
2021-03-26 09:48:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-05-17 15:40:43 +08:00
|
|
|
|
ByMaterialApp(storeOut, headXml, domBody);
|
2021-03-26 09:48:36 +08:00
|
|
|
|
|
2021-05-17 15:40:43 +08:00
|
|
|
|
}
|
2021-03-26 09:48:36 +08:00
|
|
|
|
|
2021-01-12 14:45:59 +08:00
|
|
|
|
|
2021-02-06 09:38:11 +08:00
|
|
|
|
|
2021-01-12 14:45:59 +08:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
2021-03-15 11:13:19 +08:00
|
|
|
|
}
|
2021-01-12 14:45:59 +08:00
|
|
|
|
|
2021-05-20 09:47:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="storeOut"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-03-15 15:50:14 +08:00
|
|
|
|
public string SaveVoucher(Model.Request.MaterialStoreOut storeOut)
|
|
|
|
|
|
{
|
|
|
|
|
|
var voucherParameter = this.LoadVoucher($"id='{storeOut.Id}'");
|
|
|
|
|
|
if (voucherParameter.DomHead.selectSingleNode("//rs:data").childNodes.length == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.AddVocher(storeOut);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.UpdateVocher(storeOut, voucherParameter))
|
|
|
|
|
|
{
|
|
|
|
|
|
return storeOut.Id.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("保存错误");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-20 09:47:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="storeOut"></param>
|
|
|
|
|
|
/// <param name="voucherParameter"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-05-29 10:18:22 +08:00
|
|
|
|
public bool UpdateVocher(Model.Request.MaterialStoreOut storeOut, STVoucherParameter voucherParameter = null)
|
2021-03-15 11:13:19 +08:00
|
|
|
|
{
|
2021-03-15 15:50:14 +08:00
|
|
|
|
if (voucherParameter == null)
|
|
|
|
|
|
{
|
2021-03-15 13:34:02 +08:00
|
|
|
|
|
2021-03-15 15:50:14 +08:00
|
|
|
|
voucherParameter = this.LoadVoucher($"Id='{storeOut.Id}'");
|
|
|
|
|
|
}
|
2021-03-15 11:13:19 +08:00
|
|
|
|
DOMDocument domBody = voucherParameter.DomBody;
|
|
|
|
|
|
if (storeOut.Source == "生产订单")
|
|
|
|
|
|
{
|
2021-03-15 13:34:02 +08:00
|
|
|
|
|
2021-03-15 11:13:19 +08:00
|
|
|
|
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode);
|
|
|
|
|
|
if (Order == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"未知订单:{storeOut.SourceCode}");
|
|
|
|
|
|
}
|
2021-03-15 13:34:02 +08:00
|
|
|
|
|
2021-03-15 11:13:19 +08:00
|
|
|
|
string lastProductNo = null;
|
2021-03-15 13:34:02 +08:00
|
|
|
|
|
2021-03-15 11:13:19 +08:00
|
|
|
|
//headXml.setAttribute("cdepname", "研发LA组");
|
|
|
|
|
|
IXMLDOMElement bodyXml;
|
|
|
|
|
|
for (var n = 0; n < storeOut.Details.Count(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var detail = storeOut.Details[n];
|
|
|
|
|
|
var alllocate = Order.Allocates.FirstOrDefault(m => { return m.AllocateId == detail.SorceDetailId; });
|
|
|
|
|
|
if (alllocate == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"未知订单明细行:{detail.SorceDetailId}");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (alllocate.MaterialCode != detail.InvCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"订单明细存货编号与出库存货编号不符:{detail.InvCode}");
|
|
|
|
|
|
}
|
|
|
|
|
|
var moomDetail = Order.ProductDtlLst.FirstOrDefault(m => { return m.ProductOrderDtlId == alllocate.ProductOrderDtlId; });
|
|
|
|
|
|
if (lastProductNo == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = moomDetail.ProductCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (lastProductNo != "" && lastProductNo != moomDetail.ProductCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 明细
|
|
|
|
|
|
|
2021-03-26 09:48:36 +08:00
|
|
|
|
bodyXml = domBody.createElement("z:row");
|
|
|
|
|
|
var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost);
|
|
|
|
|
|
bodyXml.setAttribute("iunitcost", _cost);
|
|
|
|
|
|
var info = new Account.Accinformation();
|
|
|
|
|
|
bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity));
|
2021-05-17 15:40:43 +08:00
|
|
|
|
|
2021-03-15 11:13:19 +08:00
|
|
|
|
bodyXml.setAttribute("cinvcode", detail.InvCode);
|
|
|
|
|
|
bodyXml.setAttribute("iquantity", detail.Quantity);
|
|
|
|
|
|
bodyXml.setAttribute("irowno", n + 1);
|
|
|
|
|
|
bodyXml.setAttribute("cbatch", "");
|
|
|
|
|
|
bodyXml.setAttribute("cvmivencode", "");
|
|
|
|
|
|
bodyXml.setAttribute("cposition", detail.Position);
|
|
|
|
|
|
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.ProductOrderNo);
|
|
|
|
|
|
bodyXml.setAttribute("invcode", moomDetail.ProductCode);//产品编码
|
|
|
|
|
|
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", "");
|
|
|
|
|
|
bodyXml.setAttribute("irowno", domBody.selectSingleNode("//rs:data").childNodes.length + 1);
|
|
|
|
|
|
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-15 13:34:02 +08:00
|
|
|
|
|
2021-07-10 16:01:19 +08:00
|
|
|
|
} else if (storeOut.Source=="领料申请单")
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var metailApp = new U8.Store.MaterialAppDAL().GetModel(storeOut.SourceCode);
|
|
|
|
|
|
if (metailApp == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("未知的领料申请单");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string lastProductNo = null;
|
|
|
|
|
|
decimal moqty = 0;
|
|
|
|
|
|
string DeptName = "";
|
|
|
|
|
|
string moCode = "";
|
|
|
|
|
|
string DeptCode = "";
|
|
|
|
|
|
IXMLDOMElement bodyXml;
|
|
|
|
|
|
for (var n = 0; n < storeOut.Details.Count(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var detail = storeOut.Details[n];
|
|
|
|
|
|
var materialAppDetail = metailApp.MaterialAppVouchsLst.FirstOrDefault(m => m.MaterialAppDtlId == detail.SorceDetailId);
|
|
|
|
|
|
if (materialAppDetail == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("未知明细");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lastProductNo == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = materialAppDetail.ProductNo;
|
|
|
|
|
|
moqty = materialAppDetail.MoQuantity;
|
|
|
|
|
|
DeptName = materialAppDetail.DeptName;
|
|
|
|
|
|
DeptCode = materialAppDetail.DeptCode;
|
|
|
|
|
|
moCode = materialAppDetail.MoCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (lastProductNo != "" && lastProductNo != materialAppDetail.ProductNo)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastProductNo = "";
|
|
|
|
|
|
moqty = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
bodyXml = domBody.createElement("z:row");
|
|
|
|
|
|
var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost);
|
|
|
|
|
|
bodyXml.setAttribute("iunitcost", _cost);
|
|
|
|
|
|
bodyXml.setAttribute("imaids", materialAppDetail.MaterialAppDtlId);//
|
|
|
|
|
|
var info = new Account.Accinformation();
|
|
|
|
|
|
bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity));
|
|
|
|
|
|
bodyXml.setAttribute("cinvcode", detail.InvCode);
|
|
|
|
|
|
bodyXml.setAttribute("iquantity", detail.Quantity);
|
|
|
|
|
|
bodyXml.setAttribute("irowno", domBody.selectSingleNode("//rs:data").childNodes.length + 1);
|
|
|
|
|
|
bodyXml.setAttribute("cbatch", "");
|
|
|
|
|
|
bodyXml.setAttribute("cvmivencode", "");
|
|
|
|
|
|
bodyXml.setAttribute("cposition", detail.Position);
|
|
|
|
|
|
bodyXml.setAttribute("editprop", "A");
|
|
|
|
|
|
bodyXml.setAttribute("innum", 10);
|
|
|
|
|
|
bodyXml.setAttribute("imoseq", materialAppDetail.Moseq);
|
|
|
|
|
|
bodyXml.setAttribute("inquantity", materialAppDetail.Quantit - materialAppDetail.OutQuantity);
|
|
|
|
|
|
bodyXml.setAttribute("crejectcode", materialAppDetail.RejectCode);
|
|
|
|
|
|
bodyXml.setAttribute("iOMoMID", materialAppDetail.OmomId);
|
|
|
|
|
|
bodyXml.setAttribute("iopseq", materialAppDetail.OpSeq);
|
|
|
|
|
|
bodyXml.setAttribute("copdesc", materialAppDetail.OpDesc);
|
|
|
|
|
|
bodyXml.setAttribute("invcode", materialAppDetail.MaterialCode);
|
|
|
|
|
|
bodyXml.setAttribute("cMoLotCode", materialAppDetail.MoLotCode);
|
|
|
|
|
|
bodyXml.setAttribute("cmocode", materialAppDetail.MoCode);
|
|
|
|
|
|
bodyXml.setAttribute("iMPoIds", materialAppDetail.MPoIds);
|
|
|
|
|
|
bodyXml.setAttribute("comcode", materialAppDetail.OmCode);
|
|
|
|
|
|
bodyXml.setAttribute("iOMoDID", materialAppDetail.OMoDId);
|
|
|
|
|
|
bodyXml.setAttribute("cciqbookcode", materialAppDetail.ciqBookCode);
|
|
|
|
|
|
bodyXml.setAttribute("cmworkcentercode", materialAppDetail.mWorkCenterCode);
|
|
|
|
|
|
bodyXml.setAttribute("cservicecode", materialAppDetail.ServiceCode);
|
|
|
|
|
|
bodyXml.setAttribute("isotype", materialAppDetail.SoType);
|
|
|
|
|
|
bodyXml.setAttribute("csocode", materialAppDetail.SoCode);
|
|
|
|
|
|
bodyXml.setAttribute("isodid", materialAppDetail.SodId);
|
|
|
|
|
|
bodyXml.setAttribute("isoseq", materialAppDetail.SoSeq);
|
|
|
|
|
|
bodyXml.setAttribute("iordertype", materialAppDetail.OrderType);
|
|
|
|
|
|
bodyXml.setAttribute("iordercode", materialAppDetail.OrderCode);
|
|
|
|
|
|
bodyXml.setAttribute("iorderdid", materialAppDetail.OrderdId);
|
|
|
|
|
|
bodyXml.setAttribute("iorderseq", materialAppDetail.OrderSeq);
|
|
|
|
|
|
bodyXml.setAttribute("ipesotype", materialAppDetail.PesoType);
|
|
|
|
|
|
bodyXml.setAttribute("cpesocode", materialAppDetail.PesoCode);
|
|
|
|
|
|
bodyXml.setAttribute("ipesodid", materialAppDetail.PesodId);
|
|
|
|
|
|
bodyXml.setAttribute("ipesoseq", materialAppDetail.PesoSeq);
|
|
|
|
|
|
|
|
|
|
|
|
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-15 11:13:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-15 13:34:02 +08:00
|
|
|
|
|
2021-03-15 11:13:19 +08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.UpdateRdVoucher(voucherParameter);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception err)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
throw err;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-01-12 14:45:59 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|