材料出库更新

This commit is contained in:
gongxh
2021-03-15 11:13:19 +08:00
parent bd8fb8ca93
commit 1821b74993
5 changed files with 240 additions and 147 deletions

View File

@@ -7,6 +7,20 @@ namespace NX.ERP.BLL.Model
{ {
public class Inbound : NX.ERP.Model.BaseModel public class Inbound : NX.ERP.Model.BaseModel
{ {
private int id;
/// <summary>
/// 单据ID
/// </summary>
public int Id
{
get { return id; }
set { id = value; }
}
public string InboundNo { get; set; } public string InboundNo { get; set; }
//[Newtonsoft.Json.JsonConverter(typeof(NX.ERP.Model.TimestampConverter))] //[Newtonsoft.Json.JsonConverter(typeof(NX.ERP.Model.TimestampConverter))]
public DateTime InboundDate { get; set; } public DateTime InboundDate { get; set; }

View File

@@ -136,10 +136,99 @@ namespace NX.ERP.U8.Store
throw err; throw err;
} }
}
public bool UpdateVocher(Model.Request.MaterialStoreOut storeOut)
{
VoucherParameter voucherParameter = this.LoadVoucher($"cCode='{storeOut.Code}'");
DOMDocument domBody = voucherParameter.DomBody;
if (storeOut.Source == "生产订单")
{
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode);
if (Order == null)
{
throw new Exception($"未知订单:{storeOut.SourceCode}");
}
string lastProductNo = null;
//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 明细
bodyXml = domBody.createElement("z:row"); //bodyXml.setAttribute("autoid", n);
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
} }
} }
try
{
return base.UpdateRdVoucher(voucherParameter);
}
catch (Exception err)
{
throw err;
}
}
}
} }

View File

@@ -16,7 +16,14 @@ namespace NX.ERP.U8.Store
{ {
} }
private VoucherParameter BuildVocher(Model.Request.PuStoreIn puStoreIn, string EditType)
/// <summary>
/// 保存一个采购到货单
/// </summary>
/// <param name="puStoreIn"></param>
public string AddVocher(Model.Request.PuStoreIn puStoreIn)
{
try
{ {
VoucherParameter voucherParameter = new VoucherParameter VoucherParameter voucherParameter = new VoucherParameter
{ {
@@ -41,7 +48,7 @@ namespace NX.ERP.U8.Store
headXml.setAttribute("csource", puStoreIn.Source); //DomHead[0]["csource"] = ""; //单据来源,int类型 headXml.setAttribute("csource", puStoreIn.Source); //DomHead[0]["csource"] = ""; //单据来源,int类型
headXml.setAttribute("cmaker", puStoreIn.Maker);//DomHead[0]["cmaker"] = ""; //制单人,string类型 headXml.setAttribute("cmaker", puStoreIn.Maker);//DomHead[0]["cmaker"] = ""; //制单人,string类型
headXml.setAttribute("vt_id", new VT().GetDefaltVTID("24")); headXml.setAttribute("vt_id", new VT().GetDefaltVTID("24"));
headXml.setAttribute("editprop", EditType); headXml.setAttribute("editprop", "A");
headXml.setAttribute("cdepcode", puStoreIn.Deptcode); headXml.setAttribute("cdepcode", puStoreIn.Deptcode);
headXml.setAttribute("cpersoncode", puStoreIn.PersonCode); headXml.setAttribute("cpersoncode", puStoreIn.PersonCode);
headXml.setAttribute("crdcode", "101" /*puStoreIn.RdCode*/); headXml.setAttribute("crdcode", "101" /*puStoreIn.RdCode*/);
@@ -69,12 +76,10 @@ namespace NX.ERP.U8.Store
var detail = puStoreIn.Details[n]; var detail = puStoreIn.Details[n];
var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; }); var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; });
headXml.setAttribute("cordercode", arrivalDetail.OrderCode); headXml.setAttribute("cordercode", arrivalDetail.OrderCode);
// headXml.setAttribute("ipurorderid", arrivalDetail.PoId);
bodyXml = domBody.createElement("z:row"); bodyXml = domBody.createElement("z:row");
if (arrivalDetail.cunitid != 0) //需要做辅助计量单位 if (arrivalDetail.cunitid != 0) //需要做辅助计量单位
{ {
var _inum = detail.Quantity / arrivalDetail.inspecexchrate; var _inum = detail.Quantity / arrivalDetail.inspecexchrate;
//bodyXml.setAttribute("innum", arrivalDetail.inum);
bodyXml.setAttribute("inum", _inum); bodyXml.setAttribute("inum", _inum);
bodyXml.setAttribute("cinva_unit", arrivalDetail.cinva_unit); bodyXml.setAttribute("cinva_unit", arrivalDetail.cinva_unit);
bodyXml.setAttribute("cassunit", arrivalDetail.cunitid); bodyXml.setAttribute("cassunit", arrivalDetail.cunitid);
@@ -85,11 +90,10 @@ namespace NX.ERP.U8.Store
} }
bodyXml.setAttribute("cinvcode", detail.Invcode); bodyXml.setAttribute("cinvcode", detail.Invcode);
bodyXml.setAttribute("iquantity", detail.Quantity); bodyXml.setAttribute("iquantity", detail.Quantity);
bodyXml.setAttribute("irowno", n + 1);
bodyXml.setAttribute("cbvencode", "10001"); bodyXml.setAttribute("cbvencode", "10001");
bodyXml.setAttribute("inquantity", detail.Quantity); //应收数量,double类型 bodyXml.setAttribute("inquantity", detail.Quantity); //应收数量,double类型
bodyXml.setAttribute("cbatch", detail.Batch); bodyXml.setAttribute("cbatch", detail.Batch);
bodyXml.setAttribute("cposition", detail.Position); bodyXml.setAttribute("cposition", detail.Position);
bodyXml.setAttribute("cbarvcode", Arrival.ArrivalNo); bodyXml.setAttribute("cbarvcode", Arrival.ArrivalNo);
bodyXml.setAttribute("ipurarriveid", Arrival.ArrivalId); bodyXml.setAttribute("ipurarriveid", Arrival.ArrivalId);
@@ -113,21 +117,12 @@ namespace NX.ERP.U8.Store
bodyXml.setAttribute("iorimoney", iorimoney2); bodyXml.setAttribute("iorimoney", iorimoney2);
bodyXml.setAttribute("ioritaxprice", ioritaxprice2); bodyXml.setAttribute("ioritaxprice", ioritaxprice2);
bodyXml.setAttribute("iorisum", iorisum2); bodyXml.setAttribute("iorisum", iorisum2);
bodyXml.setAttribute("irowno", domBody.selectSingleNode("//rs:data").childNodes.length + 1);
domBody.selectSingleNode("//rs:data").appendChild(bodyXml); domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
} }
} }
domHead.selectSingleNode("//rs:data").appendChild(headXml); domHead.selectSingleNode("//rs:data").appendChild(headXml);
return voucherParameter;
}
/// <summary>
/// 保存一个采购到货单
/// </summary>
/// <param name="puStoreIn"></param>
public string AddVocher(Model.Request.PuStoreIn puStoreIn)
{
try
{
var voucherParameter = BuildVocher(puStoreIn, "A");
return AddRdVoucher(voucherParameter); return AddRdVoucher(voucherParameter);
} }
catch (Exception err) catch (Exception err)
@@ -137,14 +132,15 @@ namespace NX.ERP.U8.Store
} }
} }
public string UpdateVocher(Model.Request.PuStoreIn puStoreIn)
public bool UpdateVocher(Model.Request.PuStoreIn puStoreIn)
{ {
try try
{ {
// var voucherParameter = BuildVocher(puStoreIn, "M");
var voucherParameter = this.LoadVoucher($"cCode='{puStoreIn.Code}'"); var voucherParameter = this.LoadVoucher($"cCode='{puStoreIn.Code}'");
//添加一條 //添加一條
DOMDocument domBody = voucherParameter.DomBody; DOMDocument domBody = voucherParameter.DomBody;
if (puStoreIn.Source == "采购到货单") if (puStoreIn.Source == "采购到货单")
@@ -154,19 +150,15 @@ namespace NX.ERP.U8.Store
{ {
throw new Exception("未知采购到货单,或到货单已经入库完成"); throw new Exception("未知采购到货单,或到货单已经入库完成");
} }
IXMLDOMElement bodyXml; IXMLDOMElement bodyXml;
for (var n = 0; n < puStoreIn.Details.Count; n++) for (var n = 0; n < puStoreIn.Details.Count; n++)
{ {
var detail = puStoreIn.Details[n]; var detail = puStoreIn.Details[n];
var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; }); var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; });
// headXml.setAttribute("ipurorderid", arrivalDetail.PoId);
bodyXml = domBody.createElement("z:row"); bodyXml = domBody.createElement("z:row");
if (arrivalDetail.cunitid != 0) //需要做辅助计量单位 if (arrivalDetail.cunitid != 0) //需要做辅助计量单位
{ {
var _inum = detail.Quantity / arrivalDetail.inspecexchrate; var _inum = detail.Quantity / arrivalDetail.inspecexchrate;
//bodyXml.setAttribute("innum", arrivalDetail.inum);
bodyXml.setAttribute("inum", _inum); bodyXml.setAttribute("inum", _inum);
bodyXml.setAttribute("cinva_unit", arrivalDetail.cinva_unit); bodyXml.setAttribute("cinva_unit", arrivalDetail.cinva_unit);
bodyXml.setAttribute("cassunit", arrivalDetail.cunitid); bodyXml.setAttribute("cassunit", arrivalDetail.cunitid);
@@ -177,7 +169,7 @@ namespace NX.ERP.U8.Store
} }
bodyXml.setAttribute("cinvcode", detail.Invcode); bodyXml.setAttribute("cinvcode", detail.Invcode);
bodyXml.setAttribute("iquantity", detail.Quantity); bodyXml.setAttribute("iquantity", detail.Quantity);
bodyXml.setAttribute("irowno", domBody.childNodes.length + n + 1);
bodyXml.setAttribute("cbvencode", "10001"); bodyXml.setAttribute("cbvencode", "10001");
bodyXml.setAttribute("inquantity", detail.Quantity); //应收数量,double类型 bodyXml.setAttribute("inquantity", detail.Quantity); //应收数量,double类型
bodyXml.setAttribute("cbatch", detail.Batch); bodyXml.setAttribute("cbatch", detail.Batch);
@@ -205,6 +197,8 @@ namespace NX.ERP.U8.Store
bodyXml.setAttribute("iorimoney", iorimoney2); bodyXml.setAttribute("iorimoney", iorimoney2);
bodyXml.setAttribute("ioritaxprice", ioritaxprice2); bodyXml.setAttribute("ioritaxprice", ioritaxprice2);
bodyXml.setAttribute("iorisum", iorisum2); bodyXml.setAttribute("iorisum", iorisum2);
bodyXml.setAttribute("irowno", domBody.selectSingleNode("//rs:data").childNodes.length + 1);
domBody.selectSingleNode("//rs:data").appendChild(bodyXml); domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
} }
} }

View File

@@ -204,9 +204,9 @@ namespace NX.ERP.U8.Store
protected string UpdateRdVoucher(VoucherParameter para) protected bool UpdateRdVoucher(VoucherParameter para)
{ {
string VoucherId;
try try
{ {
@@ -214,14 +214,6 @@ namespace NX.ERP.U8.Store
u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin; u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin;
U8ApiAddress apiAddress = new U8ApiAddress(this.UpdateUrl); U8ApiAddress apiAddress = new U8ApiAddress(this.UpdateUrl);
U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext); U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext);
u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType); u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType);
u8ApiBroker.AssignNormalValue("DomHead", para.DomHead); u8ApiBroker.AssignNormalValue("DomHead", para.DomHead);
u8ApiBroker.AssignNormalValue("domBody", para.DomBody); u8ApiBroker.AssignNormalValue("domBody", para.DomBody);
@@ -273,20 +265,13 @@ namespace NX.ERP.U8.Store
} }
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue()); para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
para.DOMMsg = u8ApiBroker.GetResult("domMsg") as DOMDocument; para.DOMMsg = u8ApiBroker.GetResult("domMsg") as DOMDocument;
para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string; para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string;
if (para.ReturnValue) if (!para.ReturnValue)
{ {
}
else
{
throw new Exception(para.ErrMsg); throw new Exception(para.ErrMsg);
} }
u8ApiBroker.Release(); u8ApiBroker.Release();
return ""; return true;
} }
catch (Exception ex3) catch (Exception ex3)
{ {

View File

@@ -9,7 +9,7 @@ namespace NX.ERP.WebAPi.Controllers.Store
public class MaterialStoreOutController:ApiController public class MaterialStoreOutController:ApiController
{ {
[Obsolete]
[Route("api/MaterialOut/Add")] [Route("api/MaterialOut/Add")]
[HttpPost] [HttpPost]
@@ -18,5 +18,16 @@ namespace NX.ERP.WebAPi.Controllers.Store
var dal = new NX.ERP.U8.Store.MaterialStoreOutDAL(); var dal = new NX.ERP.U8.Store.MaterialStoreOutDAL();
return dal.AddVocher(storeIn); return dal.AddVocher(storeIn);
} }
[Route("api/MaterialOut/Update")]
[HttpPost]
public bool UpdateVoucher([FromBody] Model.Request.MaterialStoreOut storeIn)
{
var dal = new NX.ERP.U8.Store.MaterialStoreOutDAL();
return dal.UpdateVocher(storeIn);
}
} }
} }