小问题 修订
This commit is contained in:
@@ -22,11 +22,13 @@ namespace NX.ERP.U8.Pmc
|
||||
string sql = $@"
|
||||
SELECT c.cInvCode invcode1,
|
||||
c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName, CASE
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '外购,委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '外购,委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and 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(MX.MQTY, 0) as momqty,0-(isnull(mas.wqty,0) - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0)
|
||||
@@ -153,11 +155,13 @@ select *from (
|
||||
|
||||
SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,md.Remark,CONVERT(varchar(100), mor.DueDate, 23) as DueDate ,DATEDIFF(day,GETDATE(),mor.DueDate) AS jandete , md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty,(md.Qty-md.QualifiedInQty) as wwc, ma.InvCode invcode1,
|
||||
c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName as cComUnitName1, CASE
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '外购,委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '外购,委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself <> 1 THEN '委外'
|
||||
ELSE '其它'
|
||||
END AS std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl
|
||||
,mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty,
|
||||
@@ -271,11 +275,13 @@ select *from (
|
||||
|
||||
SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate,md.Remark ,CONVERT(varchar(100), mor.DueDate, 23) as DueDate ,DATEDIFF(day,GETDATE(),mor.DueDate) AS jandete , md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty,(md.Qty-md.QualifiedInQty) as wwc, ma.InvCode invcode1,
|
||||
c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName as cComUnitName1,CASE
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '外购,委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '外购,委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself <> 1 THEN '委外'
|
||||
ELSE '其它'
|
||||
END AS std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl
|
||||
,mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty,
|
||||
@@ -429,7 +435,8 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate,md.Rema
|
||||
public IEnumerable<object> Inventorymonth(NX.ERP.Model.Request.Inventoryall info1)
|
||||
{
|
||||
string sql = $@"
|
||||
create table #tablepzck20210526 (
|
||||
IF EXISTS (SELECT NAME FROM tempdb..SYSOBJECTS WHERE NAME ='tablepzck20210526' AND Xtype='U') DROP Table tempdb..tablepzck20210526
|
||||
create table tempdb..tablepzck20210526 (
|
||||
cInvCode nvarchar(120),
|
||||
cInvName nvarchar(120),
|
||||
cInvStd nvarchar(120),
|
||||
@@ -452,14 +459,16 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate,md.Rema
|
||||
iQuantity05 decimal(28, 6)
|
||||
)
|
||||
|
||||
insert into #tablepzck20210526
|
||||
insert into tempdb..tablepzck20210526
|
||||
select a.cInvCode,c.cInvName,c.cInvStd,LL.cComUnitName ,
|
||||
CASE
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '外购,委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '外购,委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself <> 1 THEN '委外'
|
||||
ELSE '其它'
|
||||
END AS std,
|
||||
0,0,0,
|
||||
@@ -474,14 +483,16 @@ select a.cInvCode,c.cInvName,c.cInvStd,LL.cComUnitName ,
|
||||
left join Inventory c WITH (nolock) on a.cInvCode=c.cInvCode
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
|
||||
insert into #tablepzck20210526
|
||||
insert into tempdb..tablepzck20210526
|
||||
select a.cInvCode,c.cInvName,c.cInvStd,LL.cComUnitName ,
|
||||
CASE
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '外购,委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '外购,委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself <> 1 THEN '委外'
|
||||
ELSE '其它'
|
||||
END AS std,
|
||||
0,0,0,
|
||||
@@ -495,16 +506,18 @@ select a.cInvCode,c.cInvName,c.cInvStd,LL.cComUnitName ,
|
||||
group by a.cinvcode) a
|
||||
left join Inventory c WITH (nolock) on a.cInvCode=c.cInvCode
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
and a.cInvCode not in (select cInvCode from #tablepzck20210526)
|
||||
and a.cInvCode not in (select cInvCode from tempdb..tablepzck20210526)
|
||||
|
||||
insert into #tablepzck20210526
|
||||
insert into tempdb..tablepzck20210526
|
||||
select a.cInvCode,c.cInvName,c.cInvStd,LL.cComUnitName ,
|
||||
CASE
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '外购,委外,自制'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign = 1 and c.bself <>1 THEN '外购,委外'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself <> 1 THEN '外购'
|
||||
WHEN c.bPurchase = 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '外购,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign <> 1 and c.bself = 1 THEN '自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself = 1 THEN '委外,自制'
|
||||
WHEN c.bPurchase <> 1 AND c.bProxyForeign = 1 and c.bself <> 1 THEN '委外'
|
||||
ELSE '其它'
|
||||
END AS std,
|
||||
0,0,0,
|
||||
@@ -518,65 +531,65 @@ select a.cInvCode,c.cInvName,c.cInvStd,LL.cComUnitName ,
|
||||
group by a.cinvcode) a
|
||||
left join Inventory c WITH (nolock) on a.cInvCode=c.cInvCode
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
and a.cInvCode not in (select cInvCode from #tablepzck20210526)
|
||||
and a.cInvCode not in (select cInvCode from tempdb..tablepzck20210526)
|
||||
|
||||
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select 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 isnull(a.cInvCode,'') =isnull(a0.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 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 isnull(a.cInvCode,'') =isnull(a0.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords09 a WITH (nolock) left join rdrecord09 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 isnull(a.cInvCode,'') =isnull(a0.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select 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 isnull(a.cInvCode,'') =isnull(a1.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 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 isnull(a.cInvCode,'') =isnull(a1.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords09 a WITH (nolock) left join rdrecord09 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 isnull(a.cInvCode,'') =isnull(a1.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select 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
|
||||
) a2 on isnull(a.cInvCode,'') =isnull(a2.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 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
|
||||
) a2 on isnull(a.cInvCode,'') =isnull(a2.cInvCode,'')
|
||||
|
||||
update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords09 a WITH (nolock) left join rdrecord09 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)
|
||||
@@ -584,21 +597,21 @@ update a set a.iQuantity02=a.iQuantity02+isnull(a2.iQuantity,0) from #tablep
|
||||
) a2 on isnull(a.cInvCode,'') =isnull(a2.cInvCode,'')
|
||||
|
||||
|
||||
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select 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
|
||||
) a3 on a.cInvCode =a3.cInvCode
|
||||
|
||||
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 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
|
||||
) a3 on a.cInvCode =a3.cInvCode
|
||||
|
||||
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords09 a WITH (nolock) left join rdrecord09 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)
|
||||
@@ -606,49 +619,49 @@ update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #tablep
|
||||
) a3 on a.cInvCode =a3.cInvCode
|
||||
|
||||
|
||||
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(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
|
||||
|
||||
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 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
|
||||
|
||||
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords09 a WITH (nolock) left join rdrecord09 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
|
||||
|
||||
update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select 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
|
||||
|
||||
update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 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
|
||||
|
||||
update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from #tablepzck20210526 a inner join
|
||||
update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from tempdb..tablepzck20210526 a inner join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords09 a WITH (nolock) left join rdrecord09 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
|
||||
|
||||
update a set a.wqty=a.wqty+isnull(mas.wqty,0) from #tablepzck20210526 a inner join
|
||||
update a set a.wqty=a.wqty+isnull(mas.wqty,0) from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
|
||||
FROM mom_moallocate ma WITH (nolock) INNER JOIN
|
||||
mom_orderdetail md WITH (nolock) ON ma.MoDId = md.MoDId
|
||||
@@ -656,21 +669,21 @@ update a set a.wqty=a.wqty+isnull(mas.wqty,0) from #tablepzck20210526 a inne
|
||||
GROUP BY ma.InvCode) mas ON a.cInvCode = mas.InvCode
|
||||
|
||||
|
||||
update a set a.issqty=a.issqty+isnull(misss.issqty,0) from #tablepzck20210526 a inner join
|
||||
update a set a.issqty=a.issqty+isnull(misss.issqty,0) from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
|
||||
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 a.cInvCode = misss.InvCode
|
||||
|
||||
update a set a.issqty=a.issqty+isnull(misss.issqty,0) from #tablepzck20210526 a inner join
|
||||
update a set a.issqty=a.issqty+isnull(misss.issqty,0) from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
|
||||
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 a.cInvCode = misss.InvCode
|
||||
|
||||
update a set a.dqty=a.dqty+isnull(ds.qty,0),a.cqty=a.cqty+isnull(cs.qty,0) from #tablepzck20210526 a inner join
|
||||
update a set a.dqty=a.dqty+isnull(ds.qty,0),a.cqty=a.cqty+isnull(cs.qty,0) from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT cinvcode, SUM(iquantity) qty
|
||||
FROM currentstock WITH (nolock)
|
||||
GROUP BY cInvCode) cs ON a.cInvCode = cs.cInvCode
|
||||
@@ -680,7 +693,7 @@ update a set a.dqty=a.dqty+isnull(ds.qty,0),a.cqty=a.cqty+isnull(cs.qty,0) fro
|
||||
GROUP BY cInvCode) ds ON a.cInvCode = ds.cInvCode
|
||||
|
||||
update a set a.momqty=a.momqty+isnull(MX.MQTY,0)
|
||||
from #tablepzck20210526 a inner join
|
||||
from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT MD.INVCODE, SUM(MD.QTY - ISNULL(MD.QUALIFIEDINQTY, 0)) AS MQTY
|
||||
FROM mom_orderdetail MD WITH (nolock)
|
||||
GROUP BY MD.INVCODE) MX ON a.cInvCode = MX.InvCode
|
||||
@@ -688,7 +701,7 @@ from #tablepzck20210526 a inner join
|
||||
|
||||
update a set a.rqty=a.rqty+isnull(prd.rqty,0)
|
||||
|
||||
from #tablepzck20210526 a inner join
|
||||
from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT cinvcode, SUM(rqty) AS rqty
|
||||
FROM (SELECT PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty
|
||||
FROM PO_Pomain PM WITH (NOLOCK) INNER JOIN
|
||||
@@ -704,7 +717,7 @@ from #tablepzck20210526 a inner join
|
||||
|
||||
update a set a.rqty1=a.rqty1+isnull(OMM.RQTY1,0)
|
||||
|
||||
from #tablepzck20210526 a inner join
|
||||
from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT CINVCODE, SUM(RQTY) AS RQTY1
|
||||
FROM (SELECT ommds.cInvCode, ommds.iQuantity - ISNULL(rds.qty, 0) AS rqty
|
||||
FROM OM_MOMain omm WITH (nolock) INNER JOIN
|
||||
@@ -716,7 +729,7 @@ from #tablepzck20210526 a inner join
|
||||
ommds.iQuantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode) OMM ON a.cInvCode = OMM.CINVCODE
|
||||
update a set a.rqty3=a.rqty3+isnull(pu_App.RQTY3,0)
|
||||
from #tablepzck20210526 a inner join
|
||||
from tempdb..tablepzck20210526 a inner join
|
||||
(SELECT CINVCODE, SUM(RQTY) AS RQTY3
|
||||
FROM (SELECT ommds.cInvCode, ommds.fquantity - ISNULL(rds.qty, 0) AS rqty
|
||||
FROM pu_AppHead omm WITH (nolock) INNER JOIN
|
||||
@@ -728,12 +741,9 @@ from #tablepzck20210526 a inner join
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode) pu_App ON a.cInvCode = pu_App.CINVCODE
|
||||
|
||||
update #tablepzck20210526 set q=isnull(wqty,0) - isnull(dqty, 0) - ISNULL(rqty, 0) - ISNULL(rqty1, 0)- ISNULL(rqty3, 0)- ISNULL(momqty, 0)
|
||||
update tempdb..tablepzck20210526 set q=isnull(wqty,0) - isnull(dqty, 0) - ISNULL(rqty, 0) - ISNULL(rqty1, 0)- ISNULL(rqty3, 0)- ISNULL(momqty, 0)
|
||||
|
||||
select *from #tablepzck20210526
|
||||
|
||||
|
||||
drop table #tablepzck20210526
|
||||
select *from tempdb..tablepzck20210526
|
||||
|
||||
|
||||
|
||||
@@ -744,7 +754,7 @@ drop table #tablepzck20210526
|
||||
|
||||
if (info1.InvCodes != null)
|
||||
{
|
||||
where.Add(" c.cinvcode in @cinvcode");
|
||||
where.Add(" cinvcode in @cinvcode");
|
||||
}
|
||||
|
||||
|
||||
@@ -752,7 +762,7 @@ drop table #tablepzck20210526
|
||||
|
||||
if (!string.IsNullOrEmpty(aa))
|
||||
{
|
||||
sql += "where " + aa;
|
||||
sql += " where " + aa;
|
||||
}
|
||||
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
@@ -823,7 +833,7 @@ drop table #tablepzck20210526
|
||||
|
||||
if (!string.IsNullOrEmpty(aa))
|
||||
{
|
||||
sql += "where " + aa;
|
||||
sql += " where " + aa;
|
||||
}
|
||||
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
|
||||
Reference in New Issue
Block a user