各小需求,修订

This commit is contained in:
杰 朱
2021-05-26 17:05:28 +08:00
parent 9b3826f6cd
commit 7fa83f7752
12 changed files with 399 additions and 89 deletions

View File

@@ -12,6 +12,10 @@ namespace NX.ERP.Model.Request
public IEnumerable<string> AppCodes { get; set; } public IEnumerable<string> AppCodes { get; set; }
public string InvStd { get; set; } public string InvStd { get; set; }
public string cMaker { get; set; }
public string vendor { get; set; }
public IEnumerable<string> InvCodes { get; set; } public IEnumerable<string> InvCodes { get; set; }

View File

@@ -41,6 +41,10 @@ namespace NX.ERP.Model
public double q { get; set; } public double q { get; set; }
public string cVenAbbName { get; set; }
public string cMaker { get; set; }
} }
} }

View File

@@ -39,6 +39,9 @@ namespace NX.ERP.Model
public double wwc { get; set; } public double wwc { get; set; }
public string StartDate { get; set; } public string StartDate { get; set; }
public string Remark { get; set; }
public string DueDate { get; set; } public string DueDate { get; set; }
public string jandete { get; set; } public string jandete { get; set; }
public double dtty { get; set; } public double dtty { get; set; }

View File

@@ -20,7 +20,7 @@ namespace NX.ERP.U8.Pmc
public IEnumerable<NX.ERP.Model.PmcInventoryallRes> GetPmcInventoryallRes(NX.ERP.Model.Request.Inventoryall info) public IEnumerable<NX.ERP.Model.PmcInventoryallRes> GetPmcInventoryallRes(NX.ERP.Model.Request.Inventoryall info)
{ {
string sql = $@" string sql = $@"
SELECT c.cInvCode invcode1, SELECT c.cInvCode invcode1,
c.cInvName cinvname1, c.cInvStd cinvstd1,LL.cComUnitName, CASE 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 '委外'
@@ -29,8 +29,8 @@ namespace NX.ERP.U8.Pmc
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 '其它' 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, 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,0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) 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)
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q ,ven.cVenAbbName, cma.cMaker
FROM Inventory c WITH (NOLOCK) LEFT JOIN FROM Inventory c WITH (NOLOCK) LEFT JOIN
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty (SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
@@ -88,10 +88,28 @@ namespace NX.ERP.U8.Pmc
GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
GROUP BY cInvCode) pu_App ON c.cInvCode = pu_App.CINVCODE LEFT JOIN GROUP BY cInvCode) pu_App ON c.cInvCode = pu_App.CINVCODE
(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 left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
left join (
select a.*,b.cVenAbbName From (
select cInvCode,cVenCode from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cVenCode
from PO_Pomain a WITH (nolock), PO_Podetails b WITH (nolock) where a.poid=b.poid)
as c where c.rownumber=1 ) a left join Vendor b WITH (nolock) on a.cVenCode= b.cVenCode ) ven on c.cInvCode = ven.cInvCode
left join (
select cInvCode, ISNULL(b.cPsn_Name,'其他') as cMaker from
(
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) a left join (
select cPsn_Num, cPsn_Name from hr_v_HR31_show WITH (nolock) where cDepCode ='52' and rEmployState ='在职') b on a.cMaker =b.cPsn_Name
) cma on c.cInvCode = cma.cInvCode
"; ";
List<string> where = new List<string>(); List<string> where = new List<string>();
@@ -133,7 +151,7 @@ namespace NX.ERP.U8.Pmc
string sql = $@" string sql = $@"
select *from ( select *from (
SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,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, 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 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 '委外'
@@ -143,7 +161,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
ELSE '其它' ELSE '其它'
END AS std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl 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, ,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(MX.MQTY, 0) momqty, 0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(MX.MQTY, 0) momqty, 0-(isnull(mas.wqty,0) - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0)
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q, motype.description, - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q, motype.description,
CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status
FROM mom_order m WITH (NOLOCK) INNER JOIN FROM mom_order m WITH (NOLOCK) INNER JOIN
@@ -251,7 +269,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
sql = $@" sql = $@"
select *from ( select *from (
SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,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, 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 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 '委外'
@@ -261,7 +279,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
ELSE '其它' ELSE '其它'
END AS std,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl 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, ,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(MX.MQTY, 0) momqty, 0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0) ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(MX.MQTY, 0) momqty, 0-(isnull(mas.wqty,0) - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0)
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q, motype.description, - ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q, motype.description,
CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status
FROM mom_order m WITH (NOLOCK) INNER JOIN FROM mom_order m WITH (NOLOCK) INNER JOIN
@@ -411,77 +429,266 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
public IEnumerable<object> Inventorymonth(NX.ERP.Model.Request.Inventoryall info1) public IEnumerable<object> Inventorymonth(NX.ERP.Model.Request.Inventoryall info1)
{ {
string sql = $@" string sql = $@"
select a.cInvCode,c.cInvName,c.cInvStd,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 create table #tablepzck20210526 (
,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, cInvCode nvarchar(120),
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) cInvName nvarchar(120),
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0) AS q,isnull(a0.iQuantity,0) as iQuantity00 ,isnull(a1.iQuantity,0) as iQuantity01, cInvStd nvarchar(120),
isnull(a2.iQuantity,0) as iQuantity02,isnull(a3.iQuantity,0) as iQuantity03,isnull(a4.iQuantity,0) as iQuantity04,isnull(a5.iQuantity,0) as iQuantity05 cComUnitName nvarchar(120),
from std nvarchar(120),
(select a.cinvcode from rdrecords11 a WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id wqty decimal(28, 6),
cqty decimal(28, 6),
issqty decimal(28, 6),
dqty decimal(28, 6),
rqty decimal(28, 6),
rqty1 decimal(28, 6),
rqty3 decimal(28, 6),
momqty decimal(28, 6),
q decimal(28, 6),
iQuantity00 decimal(28, 6),
iQuantity01 decimal(28, 6),
iQuantity02 decimal(28, 6),
iQuantity03 decimal(28, 6),
iQuantity04 decimal(28, 6),
iQuantity05 decimal(28, 6)
)
insert into #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 '自制'
ELSE '其它'
END AS std,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0 from
(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) 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) and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112)
group by a.cinvcode) a full join 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
(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 insert into #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 '自制'
ELSE '其它'
END AS std,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0 from
(select a.cinvcode 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(getdate()),dateadd(month,1,getdate())),112)
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)
insert into #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 '自制'
ELSE '其它'
END AS std,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0 from
(select a.cinvcode 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(getdate()),dateadd(month,1,getdate())),112)
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)
update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from #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) 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) and convert(varchar,dateadd(day,-day(getdate()),dateadd(month,1,getdate())),112)
group by a.cinvcode group by a.cinvcode
) a0 on a.cInvCode=a0.cInvCode ) a0 on isnull(a.cInvCode,'') =isnull(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 WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id update a set a.iQuantity00=a.iQuantity00+isnull(a0.iQuantity,0) from #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
(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
(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) 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) and convert(varchar,dateadd(day,-day(dateadd(month,-1,getdate())),dateadd(month,1,dateadd(month,-1,getdate()))),112)
group by a.cinvcode group by a.cinvcode
) a1 on a.cInvCode =a1.cInvCode ) a1 on isnull(a.cInvCode,'') =isnull(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 WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id update a set a.iQuantity01=a.iQuantity01+isnull(a1.iQuantity,0) from #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
(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
(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
(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
(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)
group by a.cinvcode
) a2 on isnull(a.cInvCode,'') =isnull(a2.cInvCode,'')
update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #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) 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) and convert(varchar,dateadd(day,-day(dateadd(month,-3,getdate())),dateadd(month,1,dateadd(month,-3,getdate()))),112)
group by a.cinvcode group by a.cinvcode
) a3 on a.cInvCode =a3.cInvCode ) a3 on a.cInvCode =a3.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 WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #tablepzck20210526 a inner join
where convert(varchar,b.dDate,112) between convert(varchar,dateadd(day,-day(dateadd(month,-2,getdate()))+1,dateadd(month,-2,getdate())),112) (select a.cinvcode, sum(a.iQuantity) as iQuantity from rdrecords32 a WITH (nolock) left join rdrecord32 b WITH (nolock) on a.id=b.id
and convert(varchar,dateadd(day,-day(dateadd(month,-2,getdate())),dateadd(month,1,dateadd(month,-2,getdate()))),112) 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 group by a.cinvcode
) a2 on a.cInvCode =a2.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 WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id update a set a.iQuantity03=a.iQuantity03+isnull(a3.iQuantity,0) from #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)
group by a.cinvcode
) a3 on a.cInvCode =a3.cInvCode
update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from #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) 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) and convert(varchar,dateadd(day,-day(dateadd(month,-4,getdate())),dateadd(month,1,dateadd(month,-4,getdate()))),112)
group by a.cinvcode group by a.cinvcode
) a4 on a.cInvCode =a4.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 WITH (nolock) left join rdrecord11 b WITH (nolock) on a.id=b.id update a set a.iQuantity04=a.iQuantity04+isnull(a4.iQuantity,0) from #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
(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
(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) 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) and convert(varchar,dateadd(day,-day(dateadd(month,-5,getdate())),dateadd(month,1,dateadd(month,-5,getdate()))),112)
group by a.cinvcode group by a.cinvcode
) a5 on a.cInvCode =a5.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 update a set a.iQuantity05=a.iQuantity05+isnull(a5.iQuantity,0) from #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
(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
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
FROM mom_moallocate ma WITH (nolock) INNER JOIN FROM mom_moallocate ma WITH (nolock) INNER JOIN
mom_orderdetail md WITH (nolock) ON ma.MoDId = md.MoDId mom_orderdetail md WITH (nolock) ON ma.MoDId = md.MoDId
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0
GROUP BY ma.InvCode) mas ON c.cInvCode = mas.InvCode LEFT JOIN GROUP BY ma.InvCode) mas ON a.cInvCode = mas.InvCode
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
update a set a.issqty=a.issqty+isnull(misss.issqty,0) from #tablepzck20210526 a inner join
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
FROM mom_moallocate ma WITH (nolock) INNER JOIN FROM mom_moallocate ma WITH (nolock) INNER JOIN
mom_orderdetail md WITH (nolock) ON ma.MoDId = md.MoDId mom_orderdetail md WITH (nolock) ON ma.MoDId = md.MoDId
WHERE md.Status <> 4 WHERE md.Status <> 4
GROUP BY ma.InvCode) misss ON c.cInvCode = misss.InvCode LEFT JOIN GROUP BY ma.InvCode) misss ON a.cInvCode = misss.InvCode
(SELECT cinvcode, SUM(iquantity) qty update a set a.issqty=a.issqty+isnull(misss.issqty,0) from #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
(SELECT cinvcode, SUM(iquantity) qty
FROM currentstock WITH (nolock) FROM currentstock WITH (nolock)
GROUP BY cInvCode) cs ON c.cInvCode = cs.cInvCode GROUP BY cInvCode) cs ON a.cInvCode = cs.cInvCode
LEFT JOIN LEFT JOIN
(SELECT cinvcode, SUM(iquantity) qty (SELECT cinvcode, SUM(iquantity) qty
FROM InvPositionSum WITH (nolock) 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 GROUP BY cInvCode) ds ON a.cInvCode = ds.cInvCode
LEFT JOIN
update a set a.momqty=a.momqty+isnull(MX.MQTY,0)
from #tablepzck20210526 a inner join
(SELECT MD.INVCODE, SUM(MD.QTY - ISNULL(MD.QUALIFIEDINQTY, 0)) AS MQTY (SELECT MD.INVCODE, SUM(MD.QTY - ISNULL(MD.QUALIFIEDINQTY, 0)) AS MQTY
FROM mom_orderdetail MD WITH (nolock) FROM mom_orderdetail MD WITH (nolock)
GROUP BY MD.INVCODE) MX ON c.cInvCode = MX.InvCode LEFT JOIN GROUP BY MD.INVCODE) MX ON a.cInvCode = MX.InvCode
update a set a.rqty=a.rqty+isnull(prd.rqty,0)
from #tablepzck20210526 a inner join
(SELECT cinvcode, SUM(rqty) AS rqty (SELECT cinvcode, SUM(rqty) AS rqty
FROM (SELECT PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty FROM (SELECT PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty
FROM PO_Pomain PM WITH (NOLOCK) INNER JOIN FROM PO_Pomain PM WITH (NOLOCK) INNER JOIN
@@ -493,7 +700,11 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
GROUP BY IPOSID) RDS ON PDS.ID = RDS.iPOsID GROUP BY IPOSID) RDS ON PDS.ID = RDS.iPOsID
WHERE ISNULL(PM.CCLOSER, N'') = N'' AND ISNULL(PDS.CBCLOSER, N'') = N'' AND WHERE ISNULL(PM.CCLOSER, N'') = N'' AND ISNULL(PDS.CBCLOSER, N'') = N'' AND
pds.iQuantity - ISNULL(rds.qty, 0) > 0) x pds.iQuantity - ISNULL(rds.qty, 0) > 0) x
GROUP BY cInvCode) prd ON c.cInvCode = prd.cInvCode LEFT JOIN GROUP BY cInvCode) prd ON a.cInvCode = prd.cInvCode
update a set a.rqty1=a.rqty1+isnull(OMM.RQTY1,0)
from #tablepzck20210526 a inner join
(SELECT CINVCODE, SUM(RQTY) AS RQTY1 (SELECT CINVCODE, SUM(RQTY) AS RQTY1
FROM (SELECT ommds.cInvCode, ommds.iQuantity - ISNULL(rds.qty, 0) AS rqty FROM (SELECT ommds.cInvCode, ommds.iQuantity - ISNULL(rds.qty, 0) AS rqty
FROM OM_MOMain omm WITH (nolock) INNER JOIN FROM OM_MOMain omm WITH (nolock) INNER JOIN
@@ -503,7 +714,9 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
GROUP BY iOMoDID) rds ON ommds.MODetailsID = rds.iOMoDID GROUP BY iOMoDID) rds ON ommds.MODetailsID = rds.iOMoDID
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
ommds.iQuantity - ISNULL(rds.qty, 0) > 0) OM ommds.iQuantity - ISNULL(rds.qty, 0) > 0) OM
GROUP BY cInvCode) OMM ON c.cInvCode = OMM.CINVCODE LEFT JOIN 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
(SELECT CINVCODE, SUM(RQTY) AS RQTY3 (SELECT CINVCODE, SUM(RQTY) AS RQTY3
FROM (SELECT ommds.cInvCode, ommds.fquantity - ISNULL(rds.qty, 0) AS rqty FROM (SELECT ommds.cInvCode, ommds.fquantity - ISNULL(rds.qty, 0) AS rqty
FROM pu_AppHead omm WITH (nolock) INNER JOIN FROM pu_AppHead omm WITH (nolock) INNER JOIN
@@ -513,10 +726,16 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
GROUP BY cInvCode) pu_App ON c.cInvCode = pu_App.CINVCODE LEFT JOIN GROUP BY cInvCode) pu_App ON a.cInvCode = pu_App.CINVCODE
(select InvCode,sum(qty) as momqty from mom_orderdetail WITH (nolock) where Status=3 group by InvCode) momq on c.cInvCode = momq.InvCode
update #tablepzck20210526 set q=isnull(wqty,0) - isnull(dqty, 0) - ISNULL(rqty, 0) - ISNULL(rqty1, 0)- ISNULL(rqty3, 0)- ISNULL(momqty, 0)
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
select *from #tablepzck20210526
drop table #tablepzck20210526
"; ";
@@ -616,8 +835,8 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
public IEnumerable<object> InventoryPo(NX.ERP.Model.Request.PoOrderRequest info1) public IEnumerable<object> InventoryPo(NX.ERP.Model.Request.PoOrderRequest info1)
{ {
string sql = $@" string sql = $@"
Select cpoid,CONVERT(varchar(100),dpodate, 23) as dpodate,zpurpoheader.cvenabbname,zpurpotail.cinvcode,zpurpotail.cinvname,zpurpotail.cinvstd,zpurpotail.cinvm_unit,zpurpotail.ireceivedqty, Select cpoid,zpurpoheader.cmaker,CONVERT(varchar(100),dpodate, 23) as dpodate,zpurpoheader.cvenabbname,zpurpotail.cinvcode,zpurpotail.cinvname,zpurpotail.cinvstd,zpurpotail.cinvm_unit,zpurpotail.ireceivedqty,
zpurpotail.iquantity,prd.rqty,CONVERT(varchar(100), zpurpotail.darrivedate, 23) as darrivedate,cupsocode, CONVERT(varchar(100), d.ddate, 23) as ddate, CONVERT(varchar(100), c.drequirdate, 23) as drequirdate, zpurpotail.iquantity,prd.rqty,prd2.rqty as rqty2 ,CONVERT(varchar(100), zpurpotail.darrivedate, 23) as darrivedate,cupsocode, CONVERT(varchar(100), d.ddate, 23) as ddate, CONVERT(varchar(100), c.drequirdate, 23) as drequirdate,
zpurpotail.cbcloser,zpurpoheader.ccloser zpurpotail.cbcloser,zpurpoheader.ccloser
From zpurpoheader with(nolock) inner join zpurpotail with(nolock) on zpurpoheader.poid=zpurpotail.poid From zpurpoheader with(nolock) inner join zpurpotail with(nolock) on zpurpoheader.poid=zpurpotail.poid
left join pu_appbody c with(nolock) on zpurpotail.iAppIds =c.autoid left join pu_appbody c with(nolock) on zpurpotail.iAppIds =c.autoid
@@ -636,9 +855,20 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
pds.iQuantity - ISNULL(rds.qty, 0) > 0) x pds.iQuantity - ISNULL(rds.qty, 0) > 0) x
GROUP BY cInvCode) prd ON zpurpotail.cinvcode = prd.CINVCODE GROUP BY cInvCode) prd ON zpurpotail.cinvcode = prd.CINVCODE
LEFT JOIN
(SELECT ID, cinvcode, SUM(rqty) AS rqty
FROM (SELECT PDS.ID,PDS.cInvCode, PDS.iQuantity - ISNULL(rds.qty, 0) AS Rqty
FROM PO_Pomain PM WITH (NOLOCK) INNER JOIN
PO_Podetails PDS WITH (NOLOCK) ON PM.POID = PDS.POID LEFT JOIN
(SELECT IPOSID, SUM(IQUANTITY) AS QTY
FROM rdrecords01 rds WITH (NOLOCK) INNER JOIN
RdRecord01 rd WITH (nolock) ON rds.ID = rd.ID
WHERE CBUSTYPE = '普通采购'
GROUP BY IPOSID) RDS ON PDS.ID = RDS.iPOsID
WHERE ISNULL(PM.CCLOSER, N'') = N'' AND ISNULL(PDS.CBCLOSER, N'') = N'' AND
pds.iQuantity - ISNULL(rds.qty, 0) > 0) x
GROUP BY ID,cInvCode) prd2 ON zpurpotail.cinvcode = prd2.CINVCODE and prd2.ID =zpurpotail.id
"; ";

View File

@@ -165,6 +165,14 @@ namespace NX.ERP.U8.Purchase
List<string> where = new List<string>(); List<string> where = new List<string>();
if (!string.IsNullOrEmpty(info1.cMaker))
{
where.Add(" mmm.cpersonname like @cMaker");
}
if (!string.IsNullOrEmpty(info1.vendor))
{
where.Add(" mmm.cvenabbname like @vendor ");
}
if (info1.InvCodes != null) if (info1.InvCodes != null)
{ {
@@ -196,7 +204,7 @@ namespace NX.ERP.U8.Purchase
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection) using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
{ {
return conn.Query<object>(sql, new { cinvcode = info1.InvCodes, cInvStd = $"%{info1.InvStd}%", info1.PoCodes, info1.AppCodes, info1.BeginDate, info1.EndDate, info1.BeginDate2, info1.EndDate2 }); return conn.Query<object>(sql, new { cinvcode = info1.InvCodes, info1.cMaker, info1.vendor, cInvStd = $"%{info1.InvStd}%", info1.PoCodes, info1.AppCodes, info1.BeginDate, info1.EndDate, info1.BeginDate2, info1.EndDate2 });
} }
} }
@@ -232,7 +240,7 @@ namespace NX.ERP.U8.Purchase
) )
insert into @RdRecord insert into @RdRecord
select cPsn_Num, cPsn_Name,0,0,0,0 from hr_v_HR31_show where cDepCode ='52' and rEmployState ='在职' select cPsn_Num, cPsn_Name,0,0,0,0 from hr_v_HR31_show WITH (nolock) where cDepCode ='52' and rEmployState ='在职' and cPsn_Name <>'朱华英'
insert into @RdRecord insert into @RdRecord
select 'qt999','其他',0,0,0,0 select 'qt999','其他',0,0,0,0
@@ -259,7 +267,7 @@ namespace NX.ERP.U8.Purchase
( (
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, PO_Podetails b where a.poid=b.poid) 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 as c where c.rownumber=1
) )
as tbl on tbl1.cinvcode=tbl.cInvCode as tbl on tbl1.cinvcode=tbl.cInvCode
@@ -291,7 +299,7 @@ namespace NX.ERP.U8.Purchase
( (
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, PO_Podetails b where a.poid=b.poid) 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 as c where c.rownumber=1
) )
as tbl on tbl1.cinvcode=tbl.cInvCode as tbl on tbl1.cinvcode=tbl.cInvCode
@@ -299,7 +307,7 @@ namespace NX.ERP.U8.Purchase
update a set a.puappnum03=b.puappnumall From @RdRecord a left join @RdRecord3 b on a.cpersonname =b.cpersonname update a set a.puappnum03=b.puappnumall From @RdRecord a left join @RdRecord3 b on a.cpersonname =b.cpersonname
update a set a.puappnum03= a.puappnumall +b.puappnumall From @RdRecord a left join ( update a set a.puappnum03= a.puappnum03 +b.puappnumall From @RdRecord a left join (
select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord3 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord3 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname
where a.cpersonname='其他' where a.cpersonname='其他'
@@ -328,7 +336,7 @@ namespace NX.ERP.U8.Purchase
( (
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, PO_Podetails b where a.poid=b.poid) 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 as c where c.rownumber=1
) )
as tbl on tbl1.cinvcode=tbl.cInvCode ) as tbl on tbl1.cinvcode=tbl.cInvCode )
@@ -365,7 +373,7 @@ namespace NX.ERP.U8.Purchase
( (
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, PO_Podetails b where a.poid=b.poid) 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 as c where c.rownumber=1
) )
as tbl on tbl1.cinvcode=tbl.cInvCode ) as tbl on tbl1.cinvcode=tbl.cInvCode )
@@ -407,7 +415,7 @@ namespace NX.ERP.U8.Purchase
FROM PO_Podetails WITH (nolock) FROM PO_Podetails WITH (nolock)
GROUP BY iAppIds) rds ON isnull(ommds.autoid,'') = isnull(rds.iAppIds,'') GROUP BY iAppIds) rds ON isnull(ommds.autoid,'') = isnull(rds.iAppIds,'')
left join 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, PO_Podetails b where a.poid=b.poid) (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 ommds.cInvCode =f.cInvCode as c where c.rownumber=1) f on ommds.cInvCode =f.cInvCode
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND ISNULL(rds.qty, 0)=0 and ommds.iReceivedQTY=0 AND WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND ISNULL(rds.qty, 0)=0 and ommds.iReceivedQTY=0 AND
ommds.fquantity - ISNULL(rds.qty, 0) > 0 ) puu ommds.fquantity - ISNULL(rds.qty, 0) > 0 ) puu

View File

@@ -10,7 +10,7 @@ namespace NX.ERP.WebAPi.Controllers
{ {
public class PurchaseController : ApiController public class PurchaseController : ApiController
{ {
[Obsolete]
[HttpPost] [HttpPost]
[Route("api/Purchase/InventoryPoc")] [Route("api/Purchase/InventoryPoc")]
public IEnumerable<object> InventoryPoc(NX.ERP.Model.Request.PoOrderRequest info) public IEnumerable<object> InventoryPoc(NX.ERP.Model.Request.PoOrderRequest info)

View File

@@ -7,7 +7,7 @@
<appSettings> <appSettings>
<add key="server" value="10.0.0.12" /> <add key="server" value="10.0.0.12" />
<add key="AccId" value="u8-2@001" /> <add key="AccId" value="u8-2@001" />
<add key="UserId" value="wx899" /> <add key="UserId" value="wx994" />
<add key="Password" value="1" /> <add key="Password" value="1" />
<add key="EaiPort" value="80" /> <add key="EaiPort" value="80" />
<add key="EaiPath" value="U8EAI/import.asp" /> <add key="EaiPath" value="U8EAI/import.asp" />

View File

@@ -350,6 +350,12 @@ export default {
key: "jandete", key: "jandete",
width: 90, width: 90,
}, },
{
title: "备注",
align: "center",
key: "remark",
width: 120,
},
], ],
}; };
}, },

View File

@@ -90,7 +90,7 @@ export default {
title: "规格", title: "规格",
align: "center", align: "center",
key: "cInvStd", key: "cInvStd",
width: "220", width: "160",
}, },
{ {
title: "单位", title: "单位",
@@ -100,7 +100,7 @@ export default {
}, },
{ {
title: "属性", title: "属性",
width: 70, width: 100,
align: "center", align: "center",
key: "std", key: "std",
}, },
@@ -145,6 +145,11 @@ export default {
align: "center", align: "center",
key: "momqty", key: "momqty",
}, },
{
title: "净存",
align: "center",
key: "q",
},
{ {
title: title:
new Date().getFullYear() + new Date().getFullYear() +

View File

@@ -107,14 +107,21 @@ export default {
app_codes: "", app_codes: "",
dates: [getMonth("s", -6), getMonth("e", 0)], dates: [getMonth("s", -6), getMonth("e", 0)],
dates2: [], dates2: [],
by_finish: false by_finish: false,
}, },
columns: [ columns: [
{
title: "业务员",
align: "center",
key: "cmaker",
width: 90,
},
{ {
title: "采购订单号", title: "采购订单号",
align: "center", align: "center",
key: "cpoid", key: "cpoid",
width: 135,
}, },
{ {
@@ -148,6 +155,13 @@ export default {
title: "单位", title: "单位",
align: "center", align: "center",
key: "cinvm_unit", key: "cinvm_unit",
width: 80,
},
{
title: "订单数量",
align: "center",
key: "iquantity",
width: 100,
}, },
{ {
title: "累计到货", title: "累计到货",
@@ -155,19 +169,19 @@ export default {
key: "ireceivedqty", key: "ireceivedqty",
width: 100, width: 100,
}, },
{ {
title: "订单数量", title: "在途",
align: "center", align: "center",
key: "iquantity", key: "rqty2",
width: 100,
}, },
{ {
title: "合计在途", title: "合计在途",
align: "center", align: "center",
key: "rqty", key: "rqty",
width: 100, width: 100,
}, },
{ {
title: "预计到货日期", title: "预计到货日期",
align: "center", align: "center",
@@ -177,6 +191,7 @@ export default {
title: "请购单号", title: "请购单号",
align: "center", align: "center",
key: "cupsocode", key: "cupsocode",
width: 135,
}, },
{ {
title: "请购日期", title: "请购日期",
@@ -192,17 +207,14 @@ export default {
title: "行关闭人", title: "行关闭人",
align: "center", align: "center",
key: "cbcloser", key: "cbcloser",
width: 100, width: 100,
}, },
{ {
title: "订单关闭人", title: "订单关闭人",
align: "center", align: "center",
key: "ccloser", key: "ccloser",
width: 100, width: 100,
}, },
], ],
}; };
}, },
@@ -265,7 +277,7 @@ export default {
end_date: _endDate, end_date: _endDate,
begin_date2: _beginDate2, begin_date2: _beginDate2,
end_date2: _endDate2, end_date2: _endDate2,
by_finish: this.filter.by_finish by_finish: this.filter.by_finish,
}; };
this.loading = true; this.loading = true;
let resp = await getInventorypo(_filert); let resp = await getInventorypo(_filert);

View File

@@ -3,7 +3,7 @@
<h4>采购订单跟进表</h4> <h4>采购订单跟进表</h4>
<div> <div>
<Row :gutter="16"> <Row :gutter="16">
<Col span="4"> <Col span="3">
<label>采购订单编号</label> <label>采购订单编号</label>
<Input autosize type="textarea" v-model="filter.po_codes" /> <Input autosize type="textarea" v-model="filter.po_codes" />
</Col> </Col>
@@ -23,6 +23,15 @@
<Input v-model="filter.inv_std" /> <Input v-model="filter.inv_std" />
</Col> </Col>
<Col span="3">
<label>业务员</label>
<Input v-model="filter.cMaker" />
</Col>
<Col span="3">
<label>供应商</label>
<Input v-model="filter.vendor" />
</Col>
<Col span="3"> <Col span="3">
<label>生产订单期间</label> <label>生产订单期间</label>
@@ -31,7 +40,7 @@
</div> </div>
</Col> </Col>
<Col span="4"> <Col span="3">
<Button <Button
size="large" size="large"
type="primary" type="primary"
@@ -85,7 +94,7 @@ import {
export default { export default {
data() { data() {
return { return {
PageSizeOpts: [10, 15, 20, 30], PageSizeOpts: [10, 15, 20, 50,200],
pageNo: 1, pageNo: 1,
loading: false, loading: false,
strfilter: "", strfilter: "",
@@ -95,6 +104,8 @@ export default {
filter: { filter: {
inv_codes: "", inv_codes: "",
inv_std: "", inv_std: "",
cMaker:"",
vendor:"",
po_codes: "", po_codes: "",
app_codes: "", app_codes: "",
dates: [getMonth("s", -6), getMonth("e", 0)], dates: [getMonth("s", -6), getMonth("e", 0)],
@@ -112,6 +123,7 @@ export default {
title: "订单号", title: "订单号",
align: "center", align: "center",
key: "cordercode", key: "cordercode",
sortable: true,
}, },
@@ -119,11 +131,13 @@ export default {
title: "订单日期", title: "订单日期",
align: "center", align: "center",
key: "dpodate", key: "dpodate",
sortable: true,
}, },
{ {
title: "预计到货日期", title: "预计到货日期",
align: "center", align: "center",
key: "dArriveDate", key: "dArriveDate",
sortable: true,
}, },
{ {
title: "供应商", title: "供应商",
@@ -134,6 +148,7 @@ export default {
title: "存货编码", title: "存货编码",
align: "center", align: "center",
key: "cinvcode", key: "cinvcode",
sortable: true,
}, },
{ {
title: "存货名称", title: "存货名称",
@@ -158,36 +173,42 @@ export default {
align: "center", align: "center",
key: "iquantity", key: "iquantity",
width: 100, width: 100,
sortable: true,
}, },
{ {
title: "未交量", title: "未交量",
align: "center", align: "center",
key: "wjh", key: "wjh",
width: 100, width: 100,
sortable: true,
}, },
{ {
title: "未入库", title: "未入库",
align: "center", align: "center",
key: "wrk", key: "wrk",
width: 100, width: 100,
sortable: true,
}, },
{ {
title: "现存量", title: "现存量",
align: "center", align: "center",
key: "xcl", key: "xcl",
width: 100, width: 100,
sortable: true,
}, },
{ {
title: "缺料量", title: "缺料量",
align: "center", align: "center",
key: "qll", key: "qll",
width: 100, width: 100,
sortable: true,
}, },
{ {
title: "补料量", title: "补料量",
align: "center", align: "center",
key: "bull", key: "bull",
width: 100, width: 100,
sortable: true,
}, },
{ {
title: "本月出库", title: "本月出库",
@@ -268,7 +289,9 @@ export default {
end_date: _endDate, end_date: _endDate,
begin_date2: _beginDate2, begin_date2: _beginDate2,
end_date2: _endDate2, end_date2: _endDate2,
by_finish: this.filter.by_finish by_finish: this.filter.by_finish,
vendor:this.filter.vendor,
c_maker:this.filter.cMaker,
}; };
this.loading = true; this.loading = true;
let resp = await InventoryPoc(_filert); let resp = await InventoryPoc(_filert);

View File

@@ -149,6 +149,21 @@ export default {
align: "center", align: "center",
key: "momqty", key: "momqty",
}, },
{
title: "净存",
align: "center",
key: "q",
},
{
title: "供应商",
align: "center",
key: "c_ven_abb_name",
},
{
title: "业务员",
align: "center",
key: "c_maker",
},
], ],
}; };
}, },