1
This commit is contained in:
@@ -852,15 +852,15 @@ select *from tempdb..tablepzck20210526
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<NX.ERP.Model.PmcInventoryallsaleRes> InventorySale(NX.ERP.Model.Request.SaleinvRequest info1)
|
||||
public NX.ERP.Model.saleRes InventorySale(NX.ERP.Model.Request.SaleinvRequest info1)
|
||||
{
|
||||
string sql = $@"
|
||||
select *from (
|
||||
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,b.cCloser
|
||||
select *from (
|
||||
select f.cCusAbbName,CONVERT(varchar(100),b.dDate, 23) as dDate ,b.cSOCode,a.cInvCode,a.cInvName,g.cInvStd, FLOOR(a.iQuantity - isnull(d.cqty,0)) as wfiQuantity,b.cCloser
|
||||
,
|
||||
isnull(cs.qty,0) as xcl,
|
||||
FLOOR(isnull(cs.qty,0)) as xcl,
|
||||
b.cVerifier
|
||||
,case when (
|
||||
,FLOOR(case when (
|
||||
isnull(
|
||||
(SELECT isnull(SUM(iquantity),0) qty
|
||||
FROM currentstock WITH (nolock) where cInvCode=a.cInvCode
|
||||
@@ -884,7 +884,7 @@ select *from tempdb..tablepzck20210526
|
||||
GROUP BY ipesodid) dd on isnull(dd.ipesodid,'')=isnull(aa.iSOsID ,'')
|
||||
where aa.cInvCode=a.cInvCode and isnull( bb.cCloser ,'') =''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
|
||||
) ) end as kcyl
|
||||
) ) end )as kcyl
|
||||
,
|
||||
CONVERT(varchar(100),a.dPreDate, 23) as dPreDate , a.cMemo,
|
||||
CASE
|
||||
@@ -908,6 +908,7 @@ select *from tempdb..tablepzck20210526
|
||||
left join Inventory g WITH (nolock) on g.cInvCode=a.cInvCode ) mm
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -996,14 +997,18 @@ select *from tempdb..tablepzck20210526
|
||||
{
|
||||
if (info1.kcyl2 == "1")
|
||||
{
|
||||
where.Add(" mm.kcyl <= 0 ");
|
||||
where.Add(" mm.kcyl < 0 ");
|
||||
}
|
||||
else if (info1.kcyl2 == "2")
|
||||
if (info1.kcyl2 == "2")
|
||||
{
|
||||
where.Add(" mm.kcyl > 0 ");
|
||||
where.Add(" mm.kcyl >= 0 ");
|
||||
}
|
||||
else if (info1.kcyl2 == "3")
|
||||
{
|
||||
where.Add(" 1=1 ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(info1.datewaring))
|
||||
{
|
||||
@@ -1080,10 +1085,32 @@ select *from tempdb..tablepzck20210526
|
||||
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
{
|
||||
try { return conn.Query<NX.ERP.Model.PmcInventoryallsaleRes>(sql, new { cCusAbbName = $"%{info1.cCusAbbName}%", dDate = info1.dDate, dPreDate = info1.dPreDate, cSOCode = $"%{info1.cSOCode}%" , cInvCode = $"%{info1.cInvCode}%", cInvName = $"%{info1.cInvName}%", cInvStd = $"%{info1.cInvStd}%", cMemo = $"%{info1.cMemo}%", SoCodes = info1.SoCodes, info1.jandate, info1.wfiQuantity, info1.kcyl, }); }
|
||||
catch { return null; }
|
||||
|
||||
var res= conn.Query<NX.ERP.Model.PmcInventoryallsaleRes>(sql, new { cCusAbbName = $"%{info1.cCusAbbName}%", dDate = info1.dDate, dPreDate = info1.dPreDate, cSOCode = $"%{info1.cSOCode}%" , cInvCode = $"%{info1.cInvCode}%", cInvName = $"%{info1.cInvName}%", cInvStd = $"%{info1.cInvStd}%", cMemo = $"%{info1.cMemo}%", SoCodes = info1.SoCodes, info1.jandate, info1.wfiQuantity, info1.kcyl, });
|
||||
|
||||
|
||||
var resall = new NX.ERP.Model.saleRes();
|
||||
|
||||
resall.wfdetails = res;
|
||||
|
||||
var a1 = res.Sum(m =>long.Parse( m.WfiQuantity));
|
||||
var a2 = res.GroupBy(m => m.CInvCode);//.Sum(m=>m.Max(n=>long.Parse(n.Xcl)));
|
||||
resall.sumWfiQuantity = 0;
|
||||
foreach (var item in a2)
|
||||
{
|
||||
var xuq = item.Sum(m => long.Parse( m.WfiQuantity));
|
||||
var kucun = item.Max(m =>long.Parse( m.Xcl));
|
||||
resall.sumWfiQuantity += Math.Min(kucun - xuq, 0);
|
||||
}
|
||||
|
||||
return resall;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<object> InventoryPo(NX.ERP.Model.Request.PoOrderRequest info1)
|
||||
|
||||
Reference in New Issue
Block a user