diff --git a/NX.ERP.Model/Request/SaleOrderRequest.cs b/NX.ERP.Model/Request/SaleOrderRequest.cs index 74dcb99..95e8048 100644 --- a/NX.ERP.Model/Request/SaleOrderRequest.cs +++ b/NX.ERP.Model/Request/SaleOrderRequest.cs @@ -20,6 +20,8 @@ namespace NX.ERP.Model.Request public bool byFinish { get; set; } + public IEnumerable flag { get; set; } + } } diff --git a/NX.ERP.U8/Pmc/PmcQuery.cs b/NX.ERP.U8/Pmc/PmcQuery.cs index c8c5f6f..e195194 100644 --- a/NX.ERP.U8/Pmc/PmcQuery.cs +++ b/NX.ERP.U8/Pmc/PmcQuery.cs @@ -851,6 +851,121 @@ select *from tempdb..tablepzck20210526 } } + + public IEnumerable InventorySale(NX.ERP.Model.Request.SaleOrderRequest info1) + { + string sql = $@" + + select f.cCusAbbName,CONVERT(varchar(100),b.dDate, 23) as dDate ,b.cSOCode,a.cInvCode,a.cInvName,g.cInvStd, a.iQuantity - isnull(d.cqty,0) as wfiQuantity + , + isnull(cs.qty,0) as xcl + , + isnull( + (SELECT isnull(SUM(iquantity),0) qty + FROM currentstock WITH (nolock) where cInvCode=a.cInvCode + GROUP BY cInvCode + ),0)-( select sum(aa.iQuantity - isnull(dd.cqty,0)) as swfiQuantity from SO_SODetails aa WITH (nolock) LEFT JOIN + SO_SOMain bb WITH (nolock) on aa.ID=bb.id left join + (SELECT ipesodid, sum(iQuantity) AS cqty + FROM rdrecords32 WITH (nolock) + GROUP BY ipesodid) dd on isnull(dd.ipesodid,'')=isnull(aa.iSOsID ,'') + where aa.cInvCode=a.cInvCode and bb.cVerifier is not null and isnull(CONVERT(varchar(100),aa.dPreDate, 23),'1900-01-01')<=isnull(CONVERT(varchar(100),a.dPreDate, 23),'1900-01-01') and (aa.iQuantity - isnull(dd.cqty,0))>0 + group by aa.cInvCode + ) as kcyl + , + CONVERT(varchar(100),a.dPreDate, 23) as dPreDate , a.cMemo, + CASE + WHEN DATEDIFF(day,a.dPreDate,GETDATE()) > -15 AND DATEDIFF(day,a.dPreDate,GETDATE()) < 0 THEN '15天内发货' + WHEN DATEDIFF(day,a.dPreDate,GETDATE()) <= -15 THEN '15天以上发货' + WHEN DATEDIFF(day,a.dPreDate,GETDATE()) >=0 THEN '超期' + END AS datewaring, + DATEDIFF(day,a.dPreDate,GETDATE()) as jandate + from SO_SODetails a WITH (nolock) left join SO_SOMain b WITH (nolock) on a.ID=b.id + + LEFT JOIN + (SELECT ipesodid, sum(iQuantity) AS cqty + FROM rdrecords32 WITH (nolock) + GROUP BY ipesodid) d on d.ipesodid=a.iSOsID + left join + (SELECT cinvcode, SUM(iquantity) qty + FROM currentstock WITH (nolock) + GROUP BY cInvCode) cs ON a.cInvCode = cs.cInvCode + + left join Customer f WITH (nolock) on b.cCusCode=f.cCusCode + left join Inventory g WITH (nolock) on g.cInvCode=a.cInvCode + + + + "; + + + List where = new List(); + + where.Add(" a.iQuantity - isnull(d.cqty,0) >0 and b.cVerifier is not null "); + + if (info1.InvCodes != null) + { + where.Add(" a.cinvcode in @cinvcode"); + } + if (!string.IsNullOrEmpty(info1.InvStd)) + { + where.Add(" g.cInvStd like @cInvStd "); + } + if (info1.SoCodes != null) + { + where.Add(" b.cSOCode in @cSOCode "); + } + + if (info1.BeginDate != null && info1.EndDate != null) + { + where.Add(" b.dDate between @beginDate and @endDate "); + + } + + if (info1.flag != null) + { + List str = new List(); + + + foreach (var item in info1.flag) + { + if (item == "1") + { + str.Add(" (DATEDIFF(day,a.dPreDate,GETDATE()) > -15 AND DATEDIFF(day,a.dPreDate,GETDATE()) < 0) "); + } + else if (item == "2") + { + str.Add(" (DATEDIFF(day,a.dPreDate,GETDATE()) <= -15) "); + } + else + { + str.Add(" (DATEDIFF(day, a.dPreDate, GETDATE()) >= 0) "); + } + + } + + + var strs = string.Join(" or ", str.ToArray()); + + strs = " ( " + strs + " ) "; + + where.Add(strs); + } + + + 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}%", cSOCode = info1.SoCodes, info1.BeginDate, info1.EndDate }); + } + } + public IEnumerable InventoryPo(NX.ERP.Model.Request.PoOrderRequest info1) { string sql = $@" diff --git a/NX.ERP.WebAPi/Controllers/Pmc/PmcController.cs b/NX.ERP.WebAPi/Controllers/Pmc/PmcController.cs index 902feaa..44e1563 100644 --- a/NX.ERP.WebAPi/Controllers/Pmc/PmcController.cs +++ b/NX.ERP.WebAPi/Controllers/Pmc/PmcController.cs @@ -44,6 +44,14 @@ namespace NX.ERP.WebAPi.Controllers var PmcQuery = new NX.ERP.U8.Pmc.PmcQuery(); return PmcQuery.Inventorysocode(info); } + + [HttpPost] + [Route("api/Pmc/InventorySale")] + public IEnumerable InventorySale(NX.ERP.Model.Request.SaleOrderRequest info1) + { + var PmcQuery = new NX.ERP.U8.Pmc.PmcQuery(); + return PmcQuery.InventorySale(info1); + } [Obsolete] [HttpPost] [Route("api/Pmc/InventoryPocode")]