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 @@

采购查询汇总

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