修改订

This commit is contained in:
杰 朱
2021-05-25 12:09:57 +08:00
parent 9f8d2a177a
commit f953c9576e
2 changed files with 38 additions and 22 deletions

View File

@@ -444,34 +444,50 @@ namespace NX.ERP.U8.Purchase
public IEnumerable<object> 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
DECLARE @RdRecord table(
CINVCODE nvarchar(200),
RQTY int,
iqty int,
iQuantity int,
bull int,
cpersonname nvarchar(200),
cInvName nvarchar(200),
cInvStd nvarchar(500)
)
insert into @RdRecord
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
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
update @RdRecord set cpersonname ='其他' where cpersonname not in ( select cPsn_Name from hr_v_HR31_show where cDepCode ='52' and rEmployState ='在职')
select *From @RdRecord
";
List<string> where = new List<string>();
if (!string.IsNullOrEmpty(info.cpersonname))
{
where.Add(" pumo.cpersonname = @cpersonname");
where.Add(" cpersonname = @cpersonname");
}
if (info.InvCodes != null)
{
where.Add(" pumo.cInvCode = @InvCodes");
where.Add(" cInvCode = @InvCodes");
}
var aa = string.Join(" and ", where.ToArray());