From 3f18fdbff0048e4b8c14b7c14dcc363b9cfe5cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=B0=20=E6=9C=B1?= <501697962@qq.com> Date: Tue, 25 May 2021 00:40:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=87=87=E8=B4=AD=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.Model/NX.ERP.Model.csproj | 1 + NX.ERP.Model/Request/PurchasesumRequest.cs | 27 ++ NX.ERP.U8/NX.ERP.U8.csproj | 1 + NX.ERP.U8/Pmc/PmcQuery.cs | 51 +- NX.ERP.U8/Pmc/PurchaseQuery.cs | 445 ++++++++++++++++++ .../Controllers/Pmc/PurchaseController.cs | 43 ++ NX.ERP.WebAPi/NX.ERP.WebAPi.csproj | 1 + NX.ERP.WebAPi/Web.config | 4 +- NX.ERP.Webapp/src/App.vue | 4 +- NX.ERP.Webapp/src/api/Purchase.js | 19 + NX.ERP.Webapp/src/route/index.js | 7 +- NX.ERP.Webapp/src/views/Purchasesum.vue | 312 ++++++++++++ NX.ERP.Webapp/src/views/inventory-po.vue | 6 +- NX.ERP.Webapp/src/views/inventory-poc.vue | 335 +++++++++++++ 14 files changed, 1231 insertions(+), 25 deletions(-) create mode 100644 NX.ERP.Model/Request/PurchasesumRequest.cs create mode 100644 NX.ERP.U8/Pmc/PurchaseQuery.cs create mode 100644 NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs create mode 100644 NX.ERP.Webapp/src/api/Purchase.js create mode 100644 NX.ERP.Webapp/src/views/Purchasesum.vue create mode 100644 NX.ERP.Webapp/src/views/inventory-poc.vue diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index 5d033ae..183d32e 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -75,6 +75,7 @@ + diff --git a/NX.ERP.Model/Request/PurchasesumRequest.cs b/NX.ERP.Model/Request/PurchasesumRequest.cs new file mode 100644 index 0000000..66fd4c8 --- /dev/null +++ b/NX.ERP.Model/Request/PurchasesumRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Request +{ + public class PurchasesumRequest + { + + public IEnumerable AppCodes { get; set; } + public string InvStd { get; set; } + + public IEnumerable InvCodes { get; set; } + + public string cpersonname { get; set; } + + public int cday { get; set; } + + + + + + + + } +} diff --git a/NX.ERP.U8/NX.ERP.U8.csproj b/NX.ERP.U8/NX.ERP.U8.csproj index 9392e45..82e1b81 100644 --- a/NX.ERP.U8/NX.ERP.U8.csproj +++ b/NX.ERP.U8/NX.ERP.U8.csproj @@ -50,6 +50,7 @@ + diff --git a/NX.ERP.U8/Pmc/PmcQuery.cs b/NX.ERP.U8/Pmc/PmcQuery.cs index df559ec..9201427 100644 --- a/NX.ERP.U8/Pmc/PmcQuery.cs +++ b/NX.ERP.U8/Pmc/PmcQuery.cs @@ -20,12 +20,17 @@ namespace NX.ERP.U8.Pmc public IEnumerable GetPmcInventoryallRes(NX.ERP.Model.Request.Inventoryall info) { string sql = $@" - SELECT c.cInvCode invcode1, - c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName, CASE WHEN c.bPurchase = 1 AND - c.bProxyForeign = 1 THEN '委外' WHEN c.bPurchase = 1 THEN '外购' WHEN c.bself = 1 THEN '自制' ELSE '其它' END AS - std, isnull(mas.wqty,0) wqty, ISNULL(cs.qty, 0) cqty,ISNULL(misss.issqty, 0) issqty , ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty, - ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, isnull(mas.wqty,0) - isnull(cs.qty, 0) - ISNULL(prd.Rqty, 0) - - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0) AS q + SELECT c.cInvCode invcode1, + c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName, CASE + WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制' + WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外' + WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购' + WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制' + WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制' + ELSE '其它' + END AS std, isnull(mas.wqty,0) wqty, ISNULL(cs.qty, 0) cqty,ISNULL(misss.issqty, 0) issqty , ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty, + ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) + - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q FROM Inventory c WITH (NOLOCK) LEFT JOIN (SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty @@ -129,12 +134,17 @@ namespace NX.ERP.U8.Pmc select *from ( SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVERT(varchar(100), mor.DueDate, 23) as DueDate ,DATEDIFF(day,GETDATE(),mor.DueDate) AS jandete , md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty,(md.Qty-md.QualifiedInQty) as wwc, ma.InvCode invcode1, - c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName as cComUnitName1, CASE WHEN c.bPurchase = 1 AND - c.bProxyForeign = 1 THEN '委外' WHEN c.bPurchase = 1 THEN '外购' WHEN c.bself = 1 THEN '自制' ELSE '其它' END AS - std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl - ,mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty, - ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) - - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0) AS q, motype.description, + c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName as cComUnitName1, CASE + WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制' + WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外' + WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购' + WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制' + WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制' + ELSE '其它' + END AS std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl + ,mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty, + ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, 0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) + - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q, motype.description, CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status FROM mom_order m WITH (NOLOCK) INNER JOIN mom_orderdetail md WITH (NOLOCK) ON m.MoId = md.MoId INNER JOIN @@ -242,12 +252,17 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER select *from ( SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVERT(varchar(100), mor.DueDate, 23) as DueDate ,DATEDIFF(day,GETDATE(),mor.DueDate) AS jandete , md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty,(md.Qty-md.QualifiedInQty) as wwc, ma.InvCode invcode1, - c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName as cComUnitName1, CASE WHEN c.bPurchase = 1 AND - c.bProxyForeign = 1 THEN '委外' WHEN c.bPurchase = 1 THEN '外购' WHEN c.bself = 1 THEN '自制' ELSE '其它' END AS - std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl + c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName as cComUnitName1,CASE + WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制' + WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外' + WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购' + WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制' + WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制' + ELSE '其它' + END AS std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl ,mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty, - ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) - - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0) AS q, motype.description, + ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, 0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) + - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q, motype.description, CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status FROM mom_order m WITH (NOLOCK) INNER JOIN mom_orderdetail md WITH (NOLOCK) ON m.MoId = md.MoId INNER JOIN @@ -658,7 +673,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER } if (!info1.byFinish) { - where.Add(" isnull(zpurpotail.cbcloser,'') ='' "); + where.Add(" isnull(zpurpotail.cbcloser,'') ='' and zpurpotail.ireceivedqty <> zpurpotail.iquantity "); } var aa = string.Join(" and ", where.ToArray()); diff --git a/NX.ERP.U8/Pmc/PurchaseQuery.cs b/NX.ERP.U8/Pmc/PurchaseQuery.cs new file mode 100644 index 0000000..a19e151 --- /dev/null +++ b/NX.ERP.U8/Pmc/PurchaseQuery.cs @@ -0,0 +1,445 @@ +using NX.ERP.U8.Purchase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Dapper; + + +namespace NX.ERP.U8.Purchase + +{ + public class PurchaseQuery + { + /// + /// + /// + /// + /// + /// + + public IEnumerable InventoryPoc(NX.ERP.Model.Request.PoOrderRequest info1) + { + + string sql = $@" + select *from ( + select A.cpersonname ,A.cordercode , CONVERT(varchar(100), A.dpodate, 23) as dpodate , CONVERT(varchar(100), A.dArriveDate, 23) as dArriveDate , + A.cvenabbname , A.cinvcode , A.cinvname ,A.cinvstd ,cinvm_unit ,A.iquantity + ,(A.iquantity-isnull(b.YDH,0)) AS wjh,(A.iquantity-isnull(b.YDH,0)+isnull(E.fRealQuantity,0)) AS wrk ,isnull(d.iQuantity,0) AS xcl,isnull(F.iqty,0) AS qll,(isnull(d.iQuantity,0)- isnull(F.iqty,0)) AS bull, a0.iQuantity as iQuantity00 ,a1.iQuantity as iQuantity01 from ( + SELECT cpersonname,cordercode,dpodate,dArriveDate,cvencode,cvenabbname,cinvcode,cinvname,cinvstd,cinvm_unit,iquantity ,id from copypolist WITH (NOLOCK) + where bposourcearr=1 + and bservice <> 1 and binvtype<>1 + + and (isnull(iquantity,0)>isnull(iarrqty,0) or (isnull(inum,0)>isnull(iarrnum,0) and iGroupType = 2 )) + and isnull(cbustype,'')<>N'直运采购' and ((isnull(cVerifier,'')<>'' and isnull(cchanger,'')='') or (isnull(cchangverifier,'')<>'')) AND 1=1 + and bInvEntrust=0 AND isnull(cbustype,'')=N'普通采购' and 1=1 and iDiscountTaxType=0 + ) A left join + ( + select iPOsID,cInvCode,sum(iQuantity)AS YDH from PU_ArrivalVouchs WITH (NOLOCK) group by iPOsID,cInvCode + ) B on A.ID=B.iPOsID and a.cInvCode =B.cInvCode + left join + CurrentStock D WITH (NOLOCK) on A.cinvcode=D.cInvCode and d.cWhCode=2 + left join + ( + select + A.cInvCode , + A.fRealQuantity, + B.cVenCode , + A.iPOsID + from + PU_ArrivalVouchs A WITH (NOLOCK) left join + PU_ArrivalVouch B WITH (NOLOCK) on A.ID =B.ID + where isnull(cbcloser,'')='' And iBillType =N'0' and cverifier is not null + and (isnull(iQuantity,0)-isnull(fRefuseQuantity,0)>isnull(fValidInQuan,0) or ( isnull(inum,0)-isnull(frefusenum,0)>isnull(fvalidinnum,0))) ) + E on A.cinvcode=e.cInvCode and a.id=e.iPOsID + left join + ( + SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty + FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN + mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId + WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 + GROUP BY ma.InvCode) F on A.cinvcode=F.InvCode + left join + (select a.cinvcode, sum(a.iQuantity) as iQuantity from ( + select a.cinvcode, iQuantity from rdrecords11 a WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(getdate())+1,getdate()),112) + and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112) + union all + select a.cinvcode, iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(getdate())+1,getdate()),112) + and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112) + ) a + group by a.cinvcode + ) a0 on a.cInvCode=a0.cInvCode + left join + ( select a.cinvcode, sum(a.iQuantity) as iQuantity from ( + select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate()))+1,dateadd(month,-1,getdate())),112) + and convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate())),dateadd(month,1,dateadd(month,-1,getdate()))),112) + group by a.cinvcode + union all + select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate()))+1,dateadd(month,-1,getdate())),112) + and convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate())),dateadd(month,1,dateadd(month,-1,getdate()))),112) + group by a.cinvcode + ) a + group by a.cinvcode + ) a1 on a.cInvCode =a1.cInvCode + ) mmm + + "; + + if (info1.BeginDate2 != null && info1.EndDate2 != null) + { + sql = $@"select *from ( + select A.cpersonname ,A.cordercode , CONVERT(varchar(100), A.dpodate, 23) as dpodate , CONVERT(varchar(100), A.dArriveDate, 23) as dArriveDate , + A.cvencode , A.cvenabbname , A.cinvcode , A.cinvname ,A.cinvstd ,cinvm_unit ,A.iquantity + ,(A.iquantity-isnull(b.YDH,0)) AS wjh,(A.iquantity-isnull(b.YDH,0)+isnull(E.fRealQuantity,0)) AS wrk ,isnull(d.iQuantity,0) AS xcl,isnull(F.iqty,0) AS qll,(isnull(d.iQuantity,0)- isnull(F.iqty,0)) AS bull, a0.iQuantity as iQuantity00 ,a1.iQuantity as iQuantity01 from ( + SELECT cpersonname,cordercode,dpodate,dArriveDate,cvencode,cvenabbname,cinvcode,cinvname,cinvstd,cinvm_unit,iquantity ,id from copypolist WITH (NOLOCK) + where bposourcearr=1 + and bservice <> 1 and binvtype<>1 + + and (isnull(iquantity,0)>isnull(iarrqty,0) or (isnull(inum,0)>isnull(iarrnum,0) and iGroupType = 2 )) + and isnull(cbustype,'')<>N'直运采购' and ((isnull(cVerifier,'')<>'' and isnull(cchanger,'')='') or (isnull(cchangverifier,'')<>'')) AND 1=1 + and bInvEntrust=0 AND isnull(cbustype,'')=N'普通采购' and 1=1 and iDiscountTaxType=0 + ) A left join + ( + select iPOsID,cInvCode,sum(iQuantity)AS YDH from PU_ArrivalVouchs WITH (NOLOCK) group by iPOsID,cInvCode + ) B on A.ID=B.iPOsID and a.cInvCode =B.cInvCode + left join + CurrentStock D WITH (NOLOCK) on A.cinvcode=D.cInvCode and d.cWhCode=2 + left join + ( + select + A.cInvCode , + A.fRealQuantity, + B.cVenCode , + A.iPOsID + from + PU_ArrivalVouchs A WITH (NOLOCK) left join + PU_ArrivalVouch B WITH (NOLOCK) on A.ID =B.ID + where isnull(cbcloser,'')='' And iBillType =N'0' and cverifier is not null + and (isnull(iQuantity,0)-isnull(fRefuseQuantity,0)>isnull(fValidInQuan,0) or ( isnull(inum,0)-isnull(frefusenum,0)>isnull(fvalidinnum,0))) ) + E on A.cinvcode=e.cInvCode and a.id=e.iPOsID + left join + ( + SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty + FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN + mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join + mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId + WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and mor.DueDate between @beginDate2 and @endDate2 + GROUP BY ma.InvCode) F on A.cinvcode=F.InvCode + left join + (select a.cinvcode, sum(a.iQuantity) as iQuantity from ( + select a.cinvcode, iQuantity from rdrecords11 a WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(getdate())+1,getdate()),112) + and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112) + union all + select a.cinvcode, iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(getdate())+1,getdate()),112) + and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112) + ) a + group by a.cinvcode + ) a0 on a.cInvCode=a0.cInvCode + left join + ( select a.cinvcode, sum(a.iQuantity) as iQuantity from ( + select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate()))+1,dateadd(month,-1,getdate())),112) + and convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate())),dateadd(month,1,dateadd(month,-1,getdate()))),112) + group by a.cinvcode + union all + select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id + where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate()))+1,dateadd(month,-1,getdate())),112) + and convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate())),dateadd(month,1,dateadd(month,-1,getdate()))),112) + group by a.cinvcode + ) a + group by a.cinvcode + ) a1 on a.cInvCode =a1.cInvCode + ) mmm + + "; + + + + } + + + List where = new List(); + + if (info1.InvCodes != null) + { + where.Add(" mmm.cinvcode in @cinvcode"); + } + if (!string.IsNullOrEmpty(info1.InvStd)) + { + where.Add(" mmm.cinvstd like @cInvStd "); + } + if (info1.PoCodes != null) + { + where.Add(" mmm.cordercode in @PoCodes "); + } + + + if (info1.BeginDate != null && info1.EndDate != null) + { + where.Add(" mmm.dPODate between @beginDate and @endDate "); + + } + + + var aa = string.Join(" and ", where.ToArray()); + + if (!string.IsNullOrEmpty(aa)) + { + sql += "where " + aa; + } + + using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection) + { + return conn.Query(sql, new { cinvcode = info1.InvCodes, cInvStd = $"%{info1.InvStd}%", info1.PoCodes, info1.AppCodes, info1.BeginDate, info1.EndDate, info1.BeginDate2, info1.EndDate2 }); + } + } + + public IEnumerable Purchasesum() + { + string sql = $@" + DECLARE @RdRecord table( + cPsn_Num nvarchar(30), + cpersonname nvarchar(30), + puappnumall int, + puappnum03 int, + mommouth02 int, + mommouth04 int + ) + + DECLARE @RdRecord2 table( + cpersonname nvarchar(30), + puappnumall int + ) + + DECLARE @RdRecord3 table( + cpersonname nvarchar(30), + puappnumall int + ) + + DECLARE @RdRecord4 table( + cpersonname nvarchar(30), + puappnumall int + ) + DECLARE @RdRecord5 table( + cpersonname nvarchar(30), + puappnumall int + ) + + insert into @RdRecord + select cPsn_Num, cPsn_Name,0,0,0,0 from hr_v_HR31_show where cDepCode ='52' and rEmployState ='在职' + + insert into @RdRecord + select 'qt999','其他',0,0,0,0 + + + + insert into @RdRecord2 + select cPsn_Num,sum(RQTY3) as puappnumall from ( + select RQTY3,isnull(cMaker,'其他') as cPsn_Num from + ( + SELECT CINVCODE, SUM(RQTY) AS RQTY3 + FROM ( + SELECT ommds.cInvCode, 1 as RQTY + FROM pu_AppHead omm WITH (nolock) INNER JOIN + pu_appbody ommds WITH (nolock) ON omm.id = ommds.id LEFT JOIN + (SELECT iAppIds, sum(iquantity) AS qty + FROM PO_Podetails WITH (nolock) + GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds + WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND + ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM + GROUP BY cInvCode + ) as tbl1 + left join + + ( + + select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a, PO_Podetails b where a.poid=b.poid) + as c where c.rownumber=1 + ) + as tbl on tbl1.cinvcode=tbl.cInvCode + ) q group by cPsn_Num + + update a set a.puappnumall=b.puappnumall From @RdRecord a left join @RdRecord2 b on a.cpersonname =b.cpersonname + + update a set a.puappnumall= a.puappnumall +b.puappnumall From @RdRecord a left join ( + select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord2 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname + where a.cpersonname='其他' + + insert into @RdRecord3 + select cPsn_Num,sum(RQTY3) as puappnumall from ( + select RQTY3,isnull(cMaker,'其他') as cPsn_Num from + ( + SELECT CINVCODE, SUM(RQTY) AS RQTY3 + FROM ( + SELECT ommds.cInvCode, 1 as RQTY + FROM pu_AppHead omm WITH (nolock) INNER JOIN + pu_appbody ommds WITH (nolock) ON omm.id = ommds.id LEFT JOIN + (SELECT iAppIds, sum(iquantity) AS qty + FROM PO_Podetails WITH (nolock) + GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds + WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND DATEDIFF(day,ddate ,GETDATE()) >=3 and + ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM + GROUP BY cInvCode + ) as tbl1 + left join + + ( + + select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a, PO_Podetails b where a.poid=b.poid) + as c where c.rownumber=1 + ) + as tbl on tbl1.cinvcode=tbl.cInvCode + ) q group by cPsn_Num + + update a set a.puappnum03=b.puappnumall From @RdRecord a left join @RdRecord3 b on a.cpersonname =b.cpersonname + + update a set a.puappnum03= a.puappnumall +b.puappnumall From @RdRecord a left join ( + select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord3 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname + where a.cpersonname='其他' + + + + insert into @RdRecord4 + select cPsn_Num,sum(RQTY3) as puappnumall from ( + select RQTY3,isnull(cMaker,'其他') as cPsn_Num from + ( + SELECT CINVCODE, SUM(RQTY) AS RQTY3 + FROM ( + select a.InvCode as CINVCODE ,1 as RQTY From ( + SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty + FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN + mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join + mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId + + WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and + convert(varchar,mor.DueDate,112) < convert(varchar,dateadd(day,-day(getdate()),dateadd(month,3,getdate())),112) + GROUP BY ma.InvCode + ) a left join + CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM + GROUP BY cInvCode + ) as tbl1 + left join + + ( + + select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a, PO_Podetails b where a.poid=b.poid) + as c where c.rownumber=1 + ) + as tbl on tbl1.cinvcode=tbl.cInvCode ) + q group by cPsn_Num + + + update a set a.mommouth02=b.puappnumall From @RdRecord a left join @RdRecord4 b on a.cpersonname =b.cpersonname + + update a set a.mommouth02= a.puappnumall +b.puappnumall From @RdRecord a left join ( + select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord4 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname + where a.cpersonname='其他' + + + insert into @RdRecord5 + select cPsn_Num,sum(RQTY3) as puappnumall from ( + select RQTY3,isnull(cMaker,'其他') as cPsn_Num from + ( + SELECT CINVCODE, SUM(RQTY) AS RQTY3 + FROM ( + select a.InvCode as CINVCODE ,1 as RQTY From ( + SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty + FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN + mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join + mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId + + WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and + convert(varchar,mor.DueDate,112) < convert(varchar,dateadd(day,-day(getdate()),dateadd(month,5,getdate())),112) + GROUP BY ma.InvCode + ) a left join + CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM + GROUP BY cInvCode + ) as tbl1 + left join + + ( + + select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a, PO_Podetails b where a.poid=b.poid) + as c where c.rownumber=1 + ) + as tbl on tbl1.cinvcode=tbl.cInvCode ) + q group by cPsn_Num + + + + + update a set a.mommouth04=b.puappnumall From @RdRecord a left join @RdRecord5 b on a.cpersonname =b.cpersonname + + update a set a.mommouth04= a.puappnumall +b.puappnumall From @RdRecord a left join ( + select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord5 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname + where a.cpersonname='其他' + + + select *from @RdRecord + + + + + "; + + + using (var conn = new System.Data.SqlClient.SqlConnection("Data Source =127.0.0.1;Initial Catalog =UFDATA_002_2019;User Id = sa;Password =123;")) + + { + return conn.Query(sql, new { }); + } + } + + public IEnumerable Purchasesumpuapp(NX.ERP.Model.Request.PurchasesumRequest info) + { + string sql = $@" + select *from ( + SELECT omm.ccode, CONVERT(varchar(100), omm.ddate, 23) as dDatel, omm.ddate ,ommds.cInvCode,ommds.cinvname, ommds.cinvstd,ommds.fquantity - ISNULL(rds.qty, 0) as RQTY,isnull(f.cMaker,'其他') as cMaker + FROM pu_AppHead omm WITH (nolock) INNER JOIN + pu_appbody ommds WITH (nolock) ON omm.id = ommds.id LEFT JOIN + (SELECT iAppIds, sum(iquantity) AS qty + FROM PO_Podetails WITH (nolock) + GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds + left join + (select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a, PO_Podetails b where a.poid=b.poid) + as c where c.rownumber=1) f on ommds.cInvCode =f.cInvCode + WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND + ommds.fquantity - ISNULL(rds.qty, 0) > 0 ) puu + "; + + List where = new List(); + + if (!string.IsNullOrEmpty(info.cpersonname)) + { + where.Add(" puu.cMaker = @cpersonname"); + } + if (info.InvCodes != null) + { + where.Add(" puu.cInvCode = @InvCodes"); + } + if (info.cday > 0) + { + where.Add(" DATEDIFF(day,puu.ddate ,GETDATE()) >=@cday"); + } + var aa = string.Join(" and ", where.ToArray()); + + if (!string.IsNullOrEmpty(aa)) + { + sql += "where " + aa; + } + + + using (var conn = new System.Data.SqlClient.SqlConnection("Data Source =127.0.0.1;Initial Catalog =UFDATA_002_2019;User Id = sa;Password =123;")) + + { + return conn.Query(sql, new { info.cpersonname, info.InvCodes, info.cday }); + } + } + } +} diff --git a/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs b/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs new file mode 100644 index 0000000..83a111b --- /dev/null +++ b/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs @@ -0,0 +1,43 @@ +using NX.ERP.U8.Purchase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +using System.Web.Http; + +namespace NX.ERP.WebAPi.Controllers +{ + public class PurchaseController : ApiController + { + [Obsolete] + [HttpPost] + [Route("api/Purchase/InventoryPoc")] + public IEnumerable InventoryPoc(NX.ERP.Model.Request.PoOrderRequest info) + { + var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery(); + return PurchaseQuery.InventoryPoc(info); + } + + + + [HttpPost] + [Route("api/Purchase/Purchasesum")] + public IEnumerable Purchasesum() + { + var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery(); + return PurchaseQuery.Purchasesum(); + } + + [HttpPost] + [Route("api/Purchase/Purchasesumpuapp")] + public IEnumerable Purchasesumpuapp(NX.ERP.Model.Request.PurchasesumRequest info) + { + var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery(); + return PurchaseQuery.Purchasesumpuapp(info); + } + + + + } +} \ No newline at end of file diff --git a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj index f41b012..e132505 100644 --- a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj +++ b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj @@ -160,6 +160,7 @@ + diff --git a/NX.ERP.WebAPi/Web.config b/NX.ERP.WebAPi/Web.config index 972b8ee..60073c3 100644 --- a/NX.ERP.WebAPi/Web.config +++ b/NX.ERP.WebAPi/Web.config @@ -5,8 +5,8 @@ --> - - + + diff --git a/NX.ERP.Webapp/src/App.vue b/NX.ERP.Webapp/src/App.vue index 542a0aa..7563d1d 100644 --- a/NX.ERP.Webapp/src/App.vue +++ b/NX.ERP.Webapp/src/App.vue @@ -13,7 +13,9 @@ 销售订单表 序列号查询 补料量查询 - 采购订单列表 + 采购订单列表(PMC) + 采购跟进表(采购部) + 采购查询汇总 diff --git a/NX.ERP.Webapp/src/api/Purchase.js b/NX.ERP.Webapp/src/api/Purchase.js new file mode 100644 index 0000000..f8ddb7c --- /dev/null +++ b/NX.ERP.Webapp/src/api/Purchase.js @@ -0,0 +1,19 @@ +import axios from 'axios' + + +export const InventoryPoc = (info) => { + return axios.post('/api/Purchase/InventoryPoc', info) +} + +export const Userrole = (info) => { + return axios.post('/api/System/Userrole', info) +} + +export const Purchasesum = (info) => { + return axios.post('/api/Purchase/Purchasesum', info) +} + +export const Purchasesumpuapp = (info) => { + return axios.post('/api/Purchase/Purchasesumpuapp', info) +} + diff --git a/NX.ERP.Webapp/src/route/index.js b/NX.ERP.Webapp/src/route/index.js index 3bd02e9..7586828 100644 --- a/NX.ERP.Webapp/src/route/index.js +++ b/NX.ERP.Webapp/src/route/index.js @@ -6,6 +6,9 @@ import InventorySo from '@/views/inventory-so.vue' import inventorySNDetail from '@/views/inventory-SNDetail.vue' import inventorybu from '@/views/inventory-bu.vue' import inventorypo from '@/views/inventory-po.vue' +import inventorypoc from '@/views/inventory-poc.vue' +import Purchasesum from '@/views/Purchasesum.vue' + export default [ { path: '/', @@ -19,5 +22,7 @@ export default [ { path: '/inventory-SNDetail', component: inventorySNDetail }, { path: '/InventorySo', component: InventorySo }, { path: '/inventorybu', component: inventorybu }, - { path: '/inventorypo', component: inventorypo } + { path: '/inventorypo', component: inventorypo }, + { path: '/inventorypoc', component: inventorypoc }, + { path: '/Purchasesum', component: Purchasesum } ] diff --git a/NX.ERP.Webapp/src/views/Purchasesum.vue b/NX.ERP.Webapp/src/views/Purchasesum.vue new file mode 100644 index 0000000..1780c05 --- /dev/null +++ b/NX.ERP.Webapp/src/views/Purchasesum.vue @@ -0,0 +1,312 @@ + + + + + + + \ No newline at end of file diff --git a/NX.ERP.Webapp/src/views/inventory-po.vue b/NX.ERP.Webapp/src/views/inventory-po.vue index 6fd8e88..41bd020 100644 --- a/NX.ERP.Webapp/src/views/inventory-po.vue +++ b/NX.ERP.Webapp/src/views/inventory-po.vue @@ -105,16 +105,16 @@ export default { inv_std: "", po_codes: "", app_codes: "", - dates: [getMonth("s", -1), getMonth("e", 0)], + dates: [getMonth("s", -6), getMonth("e", 0)], dates2: [], by_finish: false - }, + }, columns: [ { title: "采购订单号", align: "center", key: "cpoid", - width: 110, + }, { diff --git a/NX.ERP.Webapp/src/views/inventory-poc.vue b/NX.ERP.Webapp/src/views/inventory-poc.vue new file mode 100644 index 0000000..89953fd --- /dev/null +++ b/NX.ERP.Webapp/src/views/inventory-poc.vue @@ -0,0 +1,335 @@ + + + + + + + \ No newline at end of file From 9f8d2a177aac5f829d5ff302317a0229d6daf853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=B0=20=E6=9C=B1?= <501697962@qq.com> Date: Tue, 25 May 2021 11:59:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=B1=87=E6=80=BB=20=E6=9F=A5=E8=AF=A2=E7=9A=84=20=E6=98=8E?= =?UTF-8?q?=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.Model/Request/PurchasesumRequest.cs | 9 +- NX.ERP.U8/Pmc/PurchaseQuery.cs | 73 ++++- .../Controllers/Pmc/PurchaseController.cs | 12 +- NX.ERP.Webapp/src/api/Purchase.js | 4 + NX.ERP.Webapp/src/views/Purchasesum.vue | 273 ++++++++++++++++-- 5 files changed, 329 insertions(+), 42 deletions(-) diff --git a/NX.ERP.Model/Request/PurchasesumRequest.cs b/NX.ERP.Model/Request/PurchasesumRequest.cs index 66fd4c8..36b99b9 100644 --- a/NX.ERP.Model/Request/PurchasesumRequest.cs +++ b/NX.ERP.Model/Request/PurchasesumRequest.cs @@ -16,7 +16,14 @@ namespace NX.ERP.Model.Request public string cpersonname { get; set; } public int cday { get; set; } - + public int mouth { get; set; } + + + public DateTime? BeginDate { get; set; } + public DateTime? EndDate { get; set; } + + public DateTime? BeginDate2 { get; set; } + public DateTime? EndDate2 { get; set; } diff --git a/NX.ERP.U8/Pmc/PurchaseQuery.cs b/NX.ERP.U8/Pmc/PurchaseQuery.cs index a19e151..3ccae41 100644 --- a/NX.ERP.U8/Pmc/PurchaseQuery.cs +++ b/NX.ERP.U8/Pmc/PurchaseQuery.cs @@ -200,10 +200,10 @@ namespace NX.ERP.U8.Purchase } } - public IEnumerable Purchasesum() + public IEnumerable Purchasesum(NX.ERP.Model.Request.PurchasesumRequest info) { string sql = $@" - DECLARE @RdRecord table( + DECLARE @RdRecord table( cPsn_Num nvarchar(30), cpersonname nvarchar(30), puappnumall int, @@ -318,7 +318,7 @@ namespace NX.ERP.U8.Purchase mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and - convert(varchar,mor.DueDate,112) < convert(varchar,dateadd(day,-day(getdate()),dateadd(month,3,getdate())),112) + mor.DueDate between @beginDate and @endDate GROUP BY ma.InvCode ) a left join CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM @@ -337,8 +337,8 @@ namespace NX.ERP.U8.Purchase update a set a.mommouth02=b.puappnumall From @RdRecord a left join @RdRecord4 b on a.cpersonname =b.cpersonname - update a set a.mommouth02= a.puappnumall +b.puappnumall From @RdRecord a left join ( - select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord4 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname + update a set a.mommouth02= a.mommouth02 +b.mommouth02 From @RdRecord a left join ( + select '其他' as cpersonname ,sum(puappnumall) as mommouth02 from @RdRecord4 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname where a.cpersonname='其他' @@ -355,7 +355,7 @@ namespace NX.ERP.U8.Purchase mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and - convert(varchar,mor.DueDate,112) < convert(varchar,dateadd(day,-day(getdate()),dateadd(month,5,getdate())),112) + mor.DueDate between @beginDate2 and @endDate2 GROUP BY ma.InvCode ) a left join CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM @@ -376,8 +376,8 @@ namespace NX.ERP.U8.Purchase update a set a.mommouth04=b.puappnumall From @RdRecord a left join @RdRecord5 b on a.cpersonname =b.cpersonname - update a set a.mommouth04= a.puappnumall +b.puappnumall From @RdRecord a left join ( - select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord5 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname + update a set a.mommouth04= a.mommouth04 +b.mommouth04 From @RdRecord a left join ( + select '其他' as cpersonname ,sum(puappnumall) as mommouth04 from @RdRecord5 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname where a.cpersonname='其他' @@ -385,14 +385,13 @@ namespace NX.ERP.U8.Purchase - "; - using (var conn = new System.Data.SqlClient.SqlConnection("Data Source =127.0.0.1;Initial Catalog =UFDATA_002_2019;User Id = sa;Password =123;")) + using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection) { - return conn.Query(sql, new { }); + return conn.Query(sql, new { info.BeginDate, info.EndDate, info.BeginDate2, info.EndDate2 }); } } @@ -421,7 +420,7 @@ namespace NX.ERP.U8.Purchase } if (info.InvCodes != null) { - where.Add(" puu.cInvCode = @InvCodes"); + where.Add(" puu.cInvCode in @InvCodes"); } if (info.cday > 0) { @@ -435,11 +434,59 @@ namespace NX.ERP.U8.Purchase } - using (var conn = new System.Data.SqlClient.SqlConnection("Data Source =127.0.0.1;Initial Catalog =UFDATA_002_2019;User Id = sa;Password =123;")) + using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection) { return conn.Query(sql, new { info.cpersonname, info.InvCodes, info.cday }); } } + + public IEnumerable Purchasesummom(NX.ERP.Model.Request.PurchasesumRequest info) + { + string sql = $@" + select *from ( + select a.*,isnull(f.cMaker,'其他') as cpersonname ,inv.cInvName,inv.cInvStd from ( + select a.InvCode as CINVCODE ,1 as RQTY , iqty,cur.iQuantity, (cur.iQuantity-iqty) as bull From ( + SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty + FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN + mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join + mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId + + WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and + mor.DueDate between @beginDate and @endDate + GROUP BY ma.InvCode + ) a left join + CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0 + ) a left join + (select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a WITH (NOLOCK), PO_Podetails b WITH (NOLOCK) where a.poid=b.poid) + as c where c.rownumber=1) f on a.CINVCODE=f.cInvCode + left join Inventory inv WITH (NOLOCK) on a.CINVCODE=inv.cInvCode )pumo + "; + + List where = new List(); + + if (!string.IsNullOrEmpty(info.cpersonname)) + { + where.Add(" pumo.cpersonname = @cpersonname"); + } + if (info.InvCodes != null) + { + where.Add(" pumo.cInvCode = @InvCodes"); + } + + var aa = string.Join(" and ", where.ToArray()); + + if (!string.IsNullOrEmpty(aa)) + { + sql += "where " + aa; + } + + + using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection) + + { + return conn.Query(sql, new { info.cpersonname, info.InvCodes, info.cday, info.BeginDate, info.EndDate }); + } + } } } diff --git a/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs b/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs index 83a111b..ff703fb 100644 --- a/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs +++ b/NX.ERP.WebAPi/Controllers/Pmc/PurchaseController.cs @@ -23,10 +23,10 @@ namespace NX.ERP.WebAPi.Controllers [HttpPost] [Route("api/Purchase/Purchasesum")] - public IEnumerable Purchasesum() + public IEnumerable Purchasesum(NX.ERP.Model.Request.PurchasesumRequest info) { var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery(); - return PurchaseQuery.Purchasesum(); + return PurchaseQuery.Purchasesum( info); } [HttpPost] @@ -37,6 +37,14 @@ namespace NX.ERP.WebAPi.Controllers return PurchaseQuery.Purchasesumpuapp(info); } + [HttpPost] + [Route("api/Purchase/Purchasesummom")] + public IEnumerable Purchasesummom(NX.ERP.Model.Request.PurchasesumRequest info) + { + var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery(); + return PurchaseQuery.Purchasesummom(info); + } + } diff --git a/NX.ERP.Webapp/src/api/Purchase.js b/NX.ERP.Webapp/src/api/Purchase.js index f8ddb7c..73bb080 100644 --- a/NX.ERP.Webapp/src/api/Purchase.js +++ b/NX.ERP.Webapp/src/api/Purchase.js @@ -17,3 +17,7 @@ export const Purchasesumpuapp = (info) => { return axios.post('/api/Purchase/Purchasesumpuapp', info) } +export const Purchasesummom = (info) => { + return axios.post('/api/Purchase/Purchasesummom', info) +} + diff --git a/NX.ERP.Webapp/src/views/Purchasesum.vue b/NX.ERP.Webapp/src/views/Purchasesum.vue index 1780c05..0f08241 100644 --- a/NX.ERP.Webapp/src/views/Purchasesum.vue +++ b/NX.ERP.Webapp/src/views/Purchasesum.vue @@ -3,18 +3,17 @@

采购查询汇总

- - - -
-
+ + +
+ +
+ + + +
+ +
+ + + + +
+
+ + + + + +
+
+