mom 修改
This commit is contained in:
@@ -20,37 +20,37 @@ namespace NX.ERP.U8.Pmc
|
||||
public IEnumerable<NX.ERP.Model.PmcInventoryallRes> GetPmcInventoryallRes(NX.ERP.Model.Request.Inventoryall info)
|
||||
{
|
||||
string sql = $@"
|
||||
SELECT c.cInvCode invcode1,
|
||||
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
|
||||
|
||||
FROM Inventory c LEFT JOIN
|
||||
FROM Inventory c WITH (NOLOCK) LEFT JOIN
|
||||
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
|
||||
FROM mom_moallocate ma INNER JOIN
|
||||
mom_orderdetail md ON ma.MoDId = md.MoDId
|
||||
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) mas ON c.cInvCode = mas.InvCode LEFT JOIN
|
||||
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
|
||||
FROM mom_moallocate ma INNER JOIN
|
||||
mom_orderdetail md ON ma.MoDId = md.MoDId
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId
|
||||
WHERE md.Status <> 4
|
||||
GROUP BY ma.InvCode) misss ON c.cInvCode = misss.InvCode LEFT JOIN
|
||||
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM currentstock
|
||||
FROM currentstock WITH (NOLOCK)
|
||||
GROUP BY cInvCode) cs ON c.cInvCode = cs.cInvCode
|
||||
LEFT JOIN
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM InvPositionSum where cPosCode not in ('00701','00801','09001')
|
||||
FROM InvPositionSum WITH (NOLOCK) where cPosCode not in ('00701','00801','09001')
|
||||
GROUP BY cInvCode) ds ON c.cInvCode = ds.cInvCode
|
||||
LEFT JOIN
|
||||
|
||||
|
||||
(SELECT MD.INVCODE, SUM(MD.QTY - ISNULL(MD.QUALIFIEDINQTY, 0)) AS MQTY
|
||||
FROM mom_orderdetail MD
|
||||
FROM mom_orderdetail MD WITH (NOLOCK)
|
||||
GROUP BY MD.INVCODE) MX ON c.cInvCode = MX.InvCode LEFT JOIN
|
||||
(SELECT cinvcode, SUM(rqty) AS rqty
|
||||
FROM (SELECT PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty
|
||||
@@ -84,7 +84,7 @@ namespace NX.ERP.U8.Pmc
|
||||
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode) pu_App ON c.cInvCode = pu_App.CINVCODE LEFT JOIN
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail where Status=3 group by InvCode) momq on c.cInvCode = momq.InvCode
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail WITH (nolock) where Status=3 group by InvCode) momq on c.cInvCode = momq.InvCode
|
||||
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
";
|
||||
@@ -126,39 +126,48 @@ namespace NX.ERP.U8.Pmc
|
||||
public IEnumerable<object> Inventorymom(List<string> moCodes)
|
||||
{
|
||||
string sql = $@"
|
||||
SELECT m..mocode, md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty, ma.InvCode invcode1,
|
||||
SELECT m..mocode, md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty, 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, ma.Qty qty1, ma.IssQty issqty, mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty,
|
||||
std, ma.Qty qty1, ma.IssQty issqty,mdsss.mdqty, 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(cs.qty, 0) - ISNULL(prd.Rqty, 0)
|
||||
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0) AS q,
|
||||
CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st
|
||||
FROM mom_order m INNER JOIN
|
||||
mom_orderdetail md ON m.MoId = md.MoId INNER JOIN
|
||||
mom_moallocate ma ON md.MoDId = ma.MoDId
|
||||
FROM mom_order m WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON m.MoId = md.MoId INNER JOIN
|
||||
mom_moallocate ma WITH (NOLOCK) ON md.MoDId = ma.MoDId
|
||||
INNER JOIN
|
||||
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
|
||||
FROM mom_moallocate ma INNER JOIN
|
||||
mom_orderdetail md ON ma.MoDId = md.MoDId
|
||||
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) mas ON ma.InvCode = mas.InvCode LEFT JOIN
|
||||
|
||||
(SELECT ma.invcode,SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) mdqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
|
||||
mom_order mom WITH (NOLOCK) on md.MoId=mom.MoId
|
||||
|
||||
WHERE md.Status <> 4 and MoCode in @moCodes
|
||||
GROUP BY ma.InvCode) mdsss ON ma.InvCode = mdsss.InvCode LEFT JOIN
|
||||
|
||||
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
|
||||
FROM mom_moallocate ma INNER JOIN
|
||||
mom_orderdetail md ON ma.MoDId = md.MoDId
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId
|
||||
WHERE md.Status <> 4
|
||||
GROUP BY ma.InvCode) misss ON ma.InvCode = misss.InvCode LEFT JOIN
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM currentstock
|
||||
FROM currentstock WITH (NOLOCK)
|
||||
GROUP BY cInvCode) cs ON ma.InvCode = cs.cInvCode
|
||||
LEFT JOIN
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM InvPositionSum where cPosCode not in ('00701','00801','09001')
|
||||
FROM InvPositionSum WITH (NOLOCK) where cPosCode not in ('00701','00801','09001')
|
||||
GROUP BY cInvCode) ds ON ma.InvCode = ds.cInvCode
|
||||
INNER JOIN
|
||||
Inventory p ON md.InvCode = p.cInvCode INNER JOIN
|
||||
Inventory c ON ma.InvCode = c.cInvCode LEFT JOIN
|
||||
Inventory p WITH (NOLOCK) ON md.InvCode = p.cInvCode INNER JOIN
|
||||
Inventory c WITH (NOLOCK) ON ma.InvCode = c.cInvCode LEFT JOIN
|
||||
(SELECT MD.INVCODE, SUM(MD.QTY - ISNULL(MD.QUALIFIEDINQTY, 0)) AS MQTY
|
||||
FROM mom_orderdetail MD
|
||||
FROM mom_orderdetail MD WITH (NOLOCK)
|
||||
GROUP BY MD.INVCODE) MX ON MA.InvCode = MX.InvCode LEFT JOIN
|
||||
(SELECT cinvcode, SUM(rqty) AS rqty
|
||||
FROM (SELECT PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty
|
||||
@@ -192,12 +201,12 @@ namespace NX.ERP.U8.Pmc
|
||||
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode) pu_App ON MA.INVCODE = pu_App.CINVCODE LEFT JOIN
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail where Status=3 group by InvCode) momq on MA.INVCODE = momq.InvCode
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail WITH (NOLOCK) where Status=3 group by InvCode) momq on MA.INVCODE = momq.InvCode
|
||||
left join ComputationUnit kk WITH (nolock) on p.cComUnitCode=kk.cComunitCode
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
WHERE md.Status <> 4 AND ma.Qty - IsNull(ma.IssQty, 0) > 0
|
||||
and m..mocode in @moCodes
|
||||
order by m.mocode
|
||||
and m.mocode in @moCodes
|
||||
order by m.mocode,md.SortSeq, ma.InvCode
|
||||
";
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
{
|
||||
@@ -215,70 +224,70 @@ namespace NX.ERP.U8.Pmc
|
||||
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0) AS q,isnull(a0.iQuantity,0) as iQuantity00 ,isnull(a1.iQuantity,0) as iQuantity01,
|
||||
isnull(a2.iQuantity,0) as iQuantity02,isnull(a3.iQuantity,0) as iQuantity03,isnull(a4.iQuantity,0) as iQuantity04,isnull(a5.iQuantity,0) as iQuantity05
|
||||
from
|
||||
(select a.cinvcode from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select a.cinvcode 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(dateadd(month,-5,getdate()))+1,dateadd(month,-5,getdate())),112)
|
||||
and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112)
|
||||
group by a.cinvcode) a full join
|
||||
|
||||
(select left(convert(varchar,getdate(),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select left(convert(varchar,getdate(),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as 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)
|
||||
group by a.cinvcode
|
||||
) a0 on a.cInvCode=a0.cInvCode
|
||||
full join
|
||||
(select left(convert(varchar,dateadd(month,-1,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select left(convert(varchar,dateadd(month,-1,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as 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(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
|
||||
) a1 on a.cInvCode =a1.cInvCode
|
||||
full join
|
||||
(select left(convert(varchar,dateadd(month,-3,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select left(convert(varchar,dateadd(month,-3,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as 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(dateadd(month,-3,getdate()))+1,dateadd(month,-3,getdate())),112)
|
||||
and convert(varchar,dateadd(day,-day(dateadd(month,-3,getdate())),dateadd(month,1,dateadd(month,-3,getdate()))),112)
|
||||
group by a.cinvcode
|
||||
) a2 on a.cInvCode =a2.cInvCode
|
||||
full join
|
||||
(select left(convert(varchar,dateadd(month,-2,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select left(convert(varchar,dateadd(month,-2,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as 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(dateadd(month,-2,getdate()))+1,dateadd(month,-2,getdate())),112)
|
||||
and convert(varchar,dateadd(day,-day(dateadd(month,-2,getdate())),dateadd(month,1,dateadd(month,-2,getdate()))),112)
|
||||
group by a.cinvcode
|
||||
) a3 on a.cInvCode =a3.cInvCode
|
||||
full join
|
||||
(select left(convert(varchar,dateadd(month,-4,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select left(convert(varchar,dateadd(month,-4,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as 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(dateadd(month,-4,getdate()))+1,dateadd(month,-4,getdate())),112)
|
||||
and convert(varchar,dateadd(day,-day(dateadd(month,-4,getdate())),dateadd(month,1,dateadd(month,-4,getdate()))),112)
|
||||
group by a.cinvcode
|
||||
) a4 on a.cInvCode =a4.cInvCode
|
||||
full join
|
||||
(select left(convert(varchar,dateadd(month,-5,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords11 a left join rdrecord11 b on a.id=b.id
|
||||
(select left(convert(varchar,dateadd(month,-5,getdate()),112),6) as month1 , a.cinvcode, sum(a.iQuantity) as 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(dateadd(month,-5,getdate()))+1,dateadd(month,-5,getdate())),112)
|
||||
and convert(varchar,dateadd(day,-day(dateadd(month,-5,getdate())),dateadd(month,1,dateadd(month,-5,getdate()))),112)
|
||||
group by a.cinvcode
|
||||
) a5 on a.cInvCode =a5.cInvCode
|
||||
left join Inventory c WITH (nolock) on a.cInvCode=c.cInvCode left join
|
||||
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
|
||||
FROM mom_moallocate ma INNER JOIN
|
||||
mom_orderdetail md ON ma.MoDId = md.MoDId
|
||||
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) mas ON c.cInvCode = mas.InvCode LEFT JOIN
|
||||
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
|
||||
FROM mom_moallocate ma INNER JOIN
|
||||
mom_orderdetail md ON ma.MoDId = md.MoDId
|
||||
FROM mom_moallocate ma WITH (nolock) INNER JOIN
|
||||
mom_orderdetail md WITH (nolock) ON ma.MoDId = md.MoDId
|
||||
WHERE md.Status <> 4
|
||||
GROUP BY ma.InvCode) misss ON c.cInvCode = misss.InvCode LEFT JOIN
|
||||
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM currentstock
|
||||
FROM currentstock WITH (nolock)
|
||||
GROUP BY cInvCode) cs ON c.cInvCode = cs.cInvCode
|
||||
LEFT JOIN
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM InvPositionSum where cPosCode not in ('00701','00801','09001')
|
||||
FROM InvPositionSum WITH (nolock) where cPosCode not in ('00701','00801','09001')
|
||||
GROUP BY cInvCode) ds ON c.cInvCode = ds.cInvCode
|
||||
LEFT JOIN
|
||||
|
||||
|
||||
(SELECT MD.INVCODE, SUM(MD.QTY - ISNULL(MD.QUALIFIEDINQTY, 0)) AS MQTY
|
||||
FROM mom_orderdetail MD
|
||||
FROM mom_orderdetail MD WITH (nolock)
|
||||
GROUP BY MD.INVCODE) MX ON c.cInvCode = MX.InvCode LEFT JOIN
|
||||
(SELECT cinvcode, SUM(rqty) AS rqty
|
||||
FROM (SELECT PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty
|
||||
@@ -312,7 +321,7 @@ namespace NX.ERP.U8.Pmc
|
||||
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode) pu_App ON c.cInvCode = pu_App.CINVCODE LEFT JOIN
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail where Status=3 group by InvCode) momq on c.cInvCode = momq.InvCode
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail WITH (nolock) where Status=3 group by InvCode) momq on c.cInvCode = momq.InvCode
|
||||
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user