From bd8fb8ca9305e0c55486d45f7b48e75df95259b2 Mon Sep 17 00:00:00 2001 From: gongxh Date: Mon, 15 Mar 2021 09:50:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=AE=E6=94=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.BLL/NX.ERP.BLL.csproj | 1 + NX.ERP.Model/BaseBill.cs | 11 ++ NX.ERP.Model/NX.ERP.Model.csproj | 1 + NX.ERP.Model/Request/PuStoreIn.cs | 6 +- NX.ERP.Model/Request/PuStoreInDetail.cs | 4 +- NX.ERP.U8/NX.ERP.U8.csproj | 16 ++- NX.ERP.U8/Store/BaseBill.cs | 11 ++ NX.ERP.U8/Store/MaterielStoreOutDAL.cs | 2 +- NX.ERP.U8/Store/PuStoreInDAL.cs | 118 +++++++++++---- NX.ERP.U8/Store/VoucherBase.cs | 135 +++++++++++++++++- .../Controllers/Store/PuStoreInController.cs | 11 +- NX.ERP.WebAPi/Web.config | 2 +- 12 files changed, 277 insertions(+), 41 deletions(-) create mode 100644 NX.ERP.Model/BaseBill.cs create mode 100644 NX.ERP.U8/Store/BaseBill.cs diff --git a/NX.ERP.BLL/NX.ERP.BLL.csproj b/NX.ERP.BLL/NX.ERP.BLL.csproj index b40e051..df16ec1 100644 --- a/NX.ERP.BLL/NX.ERP.BLL.csproj +++ b/NX.ERP.BLL/NX.ERP.BLL.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + x86 pdbonly diff --git a/NX.ERP.Model/BaseBill.cs b/NX.ERP.Model/BaseBill.cs new file mode 100644 index 0000000..5dc2146 --- /dev/null +++ b/NX.ERP.Model/BaseBill.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.U8.Store +{ + public class BaseBill + { + } +} diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index 0d6ee2f..fa7f83f 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -60,6 +60,7 @@ + diff --git a/NX.ERP.Model/Request/PuStoreIn.cs b/NX.ERP.Model/Request/PuStoreIn.cs index 3b26541..6c45d7e 100644 --- a/NX.ERP.Model/Request/PuStoreIn.cs +++ b/NX.ERP.Model/Request/PuStoreIn.cs @@ -13,9 +13,10 @@ namespace NX.ERP.Model.Request private string depcode; private string whcode; private IList puStoreInDetails = new List(); - private string _puCode; + private string maker; private string personCode; + public IList Details { get => puStoreInDetails; set => puStoreInDetails = value; } public int Id { get => id; set => id = value; } public string Code { get => code; set => code = value; } @@ -34,8 +35,5 @@ namespace NX.ERP.Model.Request /// public string SourceCode { get; set; } - - - } } diff --git a/NX.ERP.Model/Request/PuStoreInDetail.cs b/NX.ERP.Model/Request/PuStoreInDetail.cs index 5694883..305b7dd 100644 --- a/NX.ERP.Model/Request/PuStoreInDetail.cs +++ b/NX.ERP.Model/Request/PuStoreInDetail.cs @@ -8,9 +8,9 @@ namespace NX.ERP.Model.Request public class PuStoreInDetail { private int id; - private int puStoreInId; + private string invcode; - private string unit; + private double quantity; public string Batch { get; set; } diff --git a/NX.ERP.U8/NX.ERP.U8.csproj b/NX.ERP.U8/NX.ERP.U8.csproj index 39f35c7..aab9b9b 100644 --- a/NX.ERP.U8/NX.ERP.U8.csproj +++ b/NX.ERP.U8/NX.ERP.U8.csproj @@ -22,7 +22,7 @@ DEBUG;TRACE prompt 4 - AnyCPU + x86 pdbonly @@ -45,6 +45,7 @@ + @@ -71,7 +72,7 @@ ..\packages\Dapper.1.42\lib\net35\Dapper.dll - D:\U8SOFT\Interop\Interop.MSXML2.dll + E:\U8SOFT\Interop\Interop.MSXML2.dll True @@ -83,16 +84,17 @@ - D:\U8SOFT\UFMOM\U8APIFramework\UFIDA.U8.MomServiceCommon.dll + E:\U8SOFT\UFMOM\U8APIFramework\UFIDA.U8.MomServiceCommon.dll - D:\U8SOFT\UFMOM\U8APIFramework\UFIDA.U8.U8APIFramework.dll + E:\U8SOFT\UFMOM\U8APIFramework\UFIDA.U8.U8APIFramework.dll - D:\U8SOFT\UFMOM\U8APIFramework\UFIDA.U8.U8MOMAPIFramework.dll + E:\U8SOFT\UFMOM\U8APIFramework\UFIDA.U8.U8MOMAPIFramework.dll - - D:\U8SOFT\Framework\UFSoft.U8.Framework.Login.UI.dll + + False + E:\U8SOFT\Framework\UFSoft.U8.Framework.Login.UI.dll False diff --git a/NX.ERP.U8/Store/BaseBill.cs b/NX.ERP.U8/Store/BaseBill.cs new file mode 100644 index 0000000..5dc2146 --- /dev/null +++ b/NX.ERP.U8/Store/BaseBill.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.U8.Store +{ + public class BaseBill + { + } +} diff --git a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs index f8b72df..095f685 100644 --- a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs +++ b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs @@ -93,7 +93,7 @@ namespace NX.ERP.U8.Store #region 明细 bodyXml = domBody.createElement("z:row"); - bodyXml.setAttribute("autoid", n); + //bodyXml.setAttribute("autoid", n); bodyXml.setAttribute("cinvcode", detail.InvCode); bodyXml.setAttribute("iquantity", detail.Quantity); bodyXml.setAttribute("irowno", n + 1); diff --git a/NX.ERP.U8/Store/PuStoreInDAL.cs b/NX.ERP.U8/Store/PuStoreInDAL.cs index 4668304..106df0e 100644 --- a/NX.ERP.U8/Store/PuStoreInDAL.cs +++ b/NX.ERP.U8/Store/PuStoreInDAL.cs @@ -15,13 +15,9 @@ namespace NX.ERP.U8.Store public PuStoreInDAL() : base("01", "U8API/PuStoreIn") { } - /// - /// 保存一个采购到货单 - /// - /// - public string AddVocher(Model.Request.PuStoreIn puStoreIn) - { + private VoucherParameter BuildVocher(Model.Request.PuStoreIn puStoreIn, string EditType) + { VoucherParameter voucherParameter = new VoucherParameter { VoucherType = this.VoucherID, @@ -36,7 +32,7 @@ namespace NX.ERP.U8.Store headXml.setAttribute("cvouchtype", this.VoucherID);//DomHead[0]["cvouchtype"] = ""; //单据类型,string类型 headXml.setAttribute("id", puStoreIn.Id); //DomHead[0]["id"] = ""; //主关键字段,int类型 headXml.setAttribute("bomfirst", "0"); //DomHead[0]["bomfirst"] = ""; //委外期初标志,string类型 - headXml.setAttribute("ccode", "190700000050"); //DomHead[0]["ccode"] = ""; //入库单号,string类型 + headXml.setAttribute("ccode", puStoreIn.Code); //DomHead[0]["ccode"] = ""; //入库单号,string类型 headXml.setAttribute("ddate", System.DateTime.Now.ToString("G")); //DomHead[0]["ddate"] = ""; //入库日期,DateTime类型 headXml.setAttribute("iverifystate", 0); //DomHead[0]["iverifystate"] = ""; //iverifystate,int类型 headXml.setAttribute("iswfcontrolled", 0); //DomHead[0]["iswfcontrolled"] = ""; //iswfcontrolled,int类型 @@ -45,7 +41,7 @@ namespace NX.ERP.U8.Store headXml.setAttribute("csource", puStoreIn.Source); //DomHead[0]["csource"] = ""; //单据来源,int类型 headXml.setAttribute("cmaker", puStoreIn.Maker);//DomHead[0]["cmaker"] = ""; //制单人,string类型 headXml.setAttribute("vt_id", new VT().GetDefaltVTID("24")); - headXml.setAttribute("editprop", "A"); + headXml.setAttribute("editprop", EditType); headXml.setAttribute("cdepcode", puStoreIn.Deptcode); headXml.setAttribute("cpersoncode", puStoreIn.PersonCode); headXml.setAttribute("crdcode", "101" /*puStoreIn.RdCode*/); @@ -56,7 +52,7 @@ namespace NX.ERP.U8.Store var Arrival = new Purchase.ArrivalDAL().GetModel(puStoreIn.SourceCode); if (Arrival == null) { - throw new Exception("未知采购到货单,或到货单已经入库完成"); + throw new Exception("未知采购到货单,或到货单已经入库完成"); } headXml.setAttribute("cbustype", Arrival.BusType); headXml.setAttribute("iexchrate", Arrival.ExchRate); @@ -67,20 +63,14 @@ namespace NX.ERP.U8.Store headXml.setAttribute("darvdate", Arrival.ArrivalDate); headXml.setAttribute("itaxrate", Arrival.TaxRate); headXml.setAttribute("cptcode", Arrival.PTCode); - IXMLDOMElement bodyXml; for (var n = 0; n < puStoreIn.Details.Count; n++) { var detail = puStoreIn.Details[n]; var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; }); - - headXml.setAttribute("cordercode", arrivalDetail.OrderCode); // headXml.setAttribute("ipurorderid", arrivalDetail.PoId); bodyXml = domBody.createElement("z:row"); - - - if (arrivalDetail.cunitid != 0) //需要做辅助计量单位 { var _inum = detail.Quantity / arrivalDetail.inspecexchrate; @@ -93,9 +83,6 @@ namespace NX.ERP.U8.Store { bodyXml.setAttribute("innum", 0); } - - - bodyXml.setAttribute("cinvcode", detail.Invcode); bodyXml.setAttribute("iquantity", detail.Quantity); bodyXml.setAttribute("irowno", n + 1); @@ -104,8 +91,6 @@ namespace NX.ERP.U8.Store bodyXml.setAttribute("cbatch", detail.Batch); bodyXml.setAttribute("cposition", detail.Position); - // bodyXml.setAttribute("cposname", "B1Y1H001"); //货位,string类型 - //iXMLDOMElement.setAttribute("carvcode", Arrival.ArrivalCode); bodyXml.setAttribute("cbarvcode", Arrival.ArrivalNo); bodyXml.setAttribute("ipurarriveid", Arrival.ArrivalId); bodyXml.setAttribute("iarrsid", detail.SorceDetailId); @@ -132,10 +117,17 @@ namespace NX.ERP.U8.Store } } domHead.selectSingleNode("//rs:data").appendChild(headXml); - - + return voucherParameter; + } + /// + /// 保存一个采购到货单 + /// + /// + public string AddVocher(Model.Request.PuStoreIn puStoreIn) + { try { + var voucherParameter = BuildVocher(puStoreIn, "A"); return AddRdVoucher(voucherParameter); } catch (Exception err) @@ -143,11 +135,89 @@ namespace NX.ERP.U8.Store throw err; } - - } + public string UpdateVocher(Model.Request.PuStoreIn puStoreIn) + { + try + { + + // var voucherParameter = BuildVocher(puStoreIn, "M"); + var voucherParameter = this.LoadVoucher($"cCode='{puStoreIn.Code}'"); + + //添加一條 + DOMDocument domBody = voucherParameter.DomBody; + if (puStoreIn.Source == "采购到货单") + { + var Arrival = new Purchase.ArrivalDAL().GetModel(puStoreIn.SourceCode); + if (Arrival == null) + { + throw new Exception("未知采购到货单,或到货单已经入库完成"); + } + + IXMLDOMElement bodyXml; + for (var n = 0; n < puStoreIn.Details.Count; n++) + { + var detail = puStoreIn.Details[n]; + var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; }); + + // headXml.setAttribute("ipurorderid", arrivalDetail.PoId); + bodyXml = domBody.createElement("z:row"); + if (arrivalDetail.cunitid != 0) //需要做辅助计量单位 + { + var _inum = detail.Quantity / arrivalDetail.inspecexchrate; + //bodyXml.setAttribute("innum", arrivalDetail.inum); + bodyXml.setAttribute("inum", _inum); + bodyXml.setAttribute("cinva_unit", arrivalDetail.cinva_unit); + bodyXml.setAttribute("cassunit", arrivalDetail.cunitid); + } + else + { + bodyXml.setAttribute("innum", 0); + } + bodyXml.setAttribute("cinvcode", detail.Invcode); + bodyXml.setAttribute("iquantity", detail.Quantity); + bodyXml.setAttribute("irowno", domBody.childNodes.length + n + 1); + bodyXml.setAttribute("cbvencode", "10001"); + bodyXml.setAttribute("inquantity", detail.Quantity); //应收数量,double类型 + bodyXml.setAttribute("cbatch", detail.Batch); + + bodyXml.setAttribute("cposition", detail.Position); + bodyXml.setAttribute("cbarvcode", Arrival.ArrivalNo); + bodyXml.setAttribute("ipurarriveid", Arrival.ArrivalId); + bodyXml.setAttribute("iarrsid", detail.SorceDetailId); + bodyXml.setAttribute("darvdate", DateTime.Today.ToShortDateString()); + bodyXml.setAttribute("editprop", "A"); + bodyXml.setAttribute("cpoid", arrivalDetail.OrderCode); + bodyXml.setAttribute("iposid", arrivalDetail.posId); + bodyXml.setAttribute("itaxrate", Arrival.TaxRate); + var info = new Account.Accinformation(); + FormatHelp.GetUnitPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, Arrival.ExchRate, out double iprice2, out double itaxprice2, out double isum2); + bodyXml.setAttribute("iunitcost", arrivalDetail.cost); + bodyXml.setAttribute("iprice", iprice2); + bodyXml.setAttribute("facost", arrivalDetail.cost); + bodyXml.setAttribute("iaprice", iprice2); + bodyXml.setAttribute("itaxprice", itaxprice2); + bodyXml.setAttribute("isum", isum2); + FormatHelp.GetOriPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, out double iorimoney2, out double ioritaxprice2, out double iorisum2, out double iunitcost2); + bodyXml.setAttribute("ioricost", arrivalDetail.oricost); + bodyXml.setAttribute("ioritaxcost", arrivalDetail.oritaxcost); + bodyXml.setAttribute("iorimoney", iorimoney2); + bodyXml.setAttribute("ioritaxprice", ioritaxprice2); + bodyXml.setAttribute("iorisum", iorisum2); + domBody.selectSingleNode("//rs:data").appendChild(bodyXml); + } + } + + return UpdateRdVoucher(voucherParameter); + } + catch (Exception err) + { + + throw err; + } + } } } diff --git a/NX.ERP.U8/Store/VoucherBase.cs b/NX.ERP.U8/Store/VoucherBase.cs index b7bb5a4..e0bc86e 100644 --- a/NX.ERP.U8/Store/VoucherBase.cs +++ b/NX.ERP.U8/Store/VoucherBase.cs @@ -66,6 +66,17 @@ namespace NX.ERP.U8.Store } } + protected string UpdateUrl + { + get + { + return $"{BaseUrl}/Update"; + } + } + + + + protected string VoucherID { get @@ -189,9 +200,111 @@ namespace NX.ERP.U8.Store } + + + + + protected string UpdateRdVoucher(VoucherParameter para) + { + string VoucherId; + + try + { + U8EnvContext u8EnvContext = new U8EnvContext(); + u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin; + U8ApiAddress apiAddress = new U8ApiAddress(this.UpdateUrl); + U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext); + + + + + + + + + u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType); + u8ApiBroker.AssignNormalValue("DomHead", para.DomHead); + u8ApiBroker.AssignNormalValue("domBody", para.DomBody); + if (para.DomPosition != null && para.DomPosition.selectNodes("//z:row").length != 0) + { + u8ApiBroker.AssignNormalValue("domPosition", para.DomPosition); + } + + u8ApiBroker.AssignNormalValue("cnnFrom", null); + if (para.DOMMsg != null) + { + u8ApiBroker.AssignNormalValue("domMsg", para.DOMMsg); + } + else + { + u8ApiBroker.AssignNormalValue("domMsg", new DOMDocumentClass()); + } + u8ApiBroker.AssignNormalValue("bCheck", para.IsCheck); + u8ApiBroker.AssignNormalValue("bBeforCheckStock", para.IsBeforCheckStock); + u8ApiBroker.AssignNormalValue("bIsRedVouch", para.IsRedVouch); + u8ApiBroker.AssignNormalValue("sAddedState", para.AddedState); + u8ApiBroker.AssignNormalValue("bUpdateNeedEas", true); + // u8ApiBroker.AssignNormalValue("bReMote", para.IsReMote); + if (!u8ApiBroker.Invoke()) + { + Exception exception = u8ApiBroker.GetException(); + if (exception != null) + { + if (exception is MomSysException) + { + MomSysException ex = exception as MomSysException; + + } + else if (exception is MomBizException) + { + MomBizException ex2 = exception as MomBizException; + + } + string exceptionString = u8ApiBroker.GetExceptionString(); + if (exceptionString.Length != 0) + { + + } + } + para.ReturnValue = false; + + u8ApiBroker.Release(); + + } + para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue()); + para.DOMMsg = u8ApiBroker.GetResult("domMsg") as DOMDocument; + + para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string; + if (para.ReturnValue) + { + + + } + else + { + + throw new Exception(para.ErrMsg); + } + u8ApiBroker.Release(); + return ""; + } + catch (Exception ex3) + { + + throw ex3; + } + finally + { + + } + + } + + protected string AddRdVoucher(VoucherParameter para) { string VoucherId; + try { U8EnvContext u8EnvContext = new U8EnvContext(); @@ -219,7 +332,8 @@ namespace NX.ERP.U8.Store u8ApiBroker.AssignNormalValue("bBeforCheckStock", para.IsBeforCheckStock); u8ApiBroker.AssignNormalValue("bIsRedVouch", para.IsRedVouch); u8ApiBroker.AssignNormalValue("sAddedState", para.AddedState); - u8ApiBroker.AssignNormalValue("bReMote", para.IsReMote); + + // u8ApiBroker.AssignNormalValue("bReMote", para.IsReMote); if (!u8ApiBroker.Invoke()) { Exception exception = u8ApiBroker.GetException(); @@ -276,6 +390,25 @@ namespace NX.ERP.U8.Store + protected VoucherParameter LoadVoucher(string where) + { + var rdVoucherParameter = new VoucherParameter + { + VoucherType = this.VoucherID, + IsGetBlank = false, + StrWhere = where + + }; + this.LoadRdVoucher(rdVoucherParameter); + return rdVoucherParameter; + + + } + + + + + private void LoadTemplate() { VoucherParameter rdVoucherParameter = null; diff --git a/NX.ERP.WebAPi/Controllers/Store/PuStoreInController.cs b/NX.ERP.WebAPi/Controllers/Store/PuStoreInController.cs index 7640953..40458f0 100644 --- a/NX.ERP.WebAPi/Controllers/Store/PuStoreInController.cs +++ b/NX.ERP.WebAPi/Controllers/Store/PuStoreInController.cs @@ -9,7 +9,7 @@ namespace NX.ERP.WebAPi.Controllers.Store public class PuStoreInController : ApiController { - [Obsolete] + [Route("api/PuStoreIn/Add")] [HttpPost] public object AddVoucher([FromBody] Model.Request.PuStoreIn storeIn) @@ -17,5 +17,14 @@ namespace NX.ERP.WebAPi.Controllers.Store var dal = new NX.ERP.U8.Store.PuStoreInDAL(); return new { Id = dal.AddVocher(storeIn) }; } + + + [Route("api/PuStoreIn/Update")] + [HttpPost] + public object UpdateVoucher([FromBody] Model.Request.PuStoreIn storeIn) + { + var dal = new NX.ERP.U8.Store.PuStoreInDAL(); + return new { Id = dal.UpdateVocher(storeIn) }; + } } } \ No newline at end of file diff --git a/NX.ERP.WebAPi/Web.config b/NX.ERP.WebAPi/Web.config index 872ec07..3c461db 100644 --- a/NX.ERP.WebAPi/Web.config +++ b/NX.ERP.WebAPi/Web.config @@ -7,7 +7,7 @@ - +