Merge branch 'master' of http://36.153.118.214:10080/nx.wms/u8-import
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
<Compile Include="Mom\MomOrderDAL.cs" />
|
||||
<Compile Include="Pmc\FinanceQuery.cs" />
|
||||
<Compile Include="Pmc\PmcQuery.cs" />
|
||||
<Compile Include="Pmc\PurchaseQuery.cs" />
|
||||
<Compile Include="Purchase\ArrivalDAL.cs" />
|
||||
<Compile Include="Sale\DispatchListDAL.cs" />
|
||||
<Compile Include="Store\BaseBill.cs" />
|
||||
|
||||
@@ -20,12 +20,17 @@ namespace NX.ERP.U8.Pmc
|
||||
public IEnumerable<NX.ERP.Model.PmcInventoryallRes> GetPmcInventoryallRes(NX.ERP.Model.Request.Inventoryall info)
|
||||
{
|
||||
string sql = $@"
|
||||
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
|
||||
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 '自制'
|
||||
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,0-(mas.wqty - isnull(ds.qty, 0) - ISNULL(prd.Rqty, 0)
|
||||
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0)) AS q
|
||||
|
||||
FROM Inventory c WITH (NOLOCK) LEFT JOIN
|
||||
(SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) wqty
|
||||
@@ -129,12 +134,17 @@ namespace NX.ERP.U8.Pmc
|
||||
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,
|
||||
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,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,
|
||||
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(ds.qty, 0) - ISNULL(prd.Rqty, 0)
|
||||
- ISNULL(omm.RQTY1, 0) - ISNULL(MX.MQTY, 0)- ISNULL(pu_App.RQTY3, 0) AS q, motype.description,
|
||||
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 '自制'
|
||||
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,
|
||||
ISNULL(OMM.RQTY1, 0) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, 0-(mas.wqty - 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,
|
||||
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
|
||||
mom_orderdetail md WITH (NOLOCK) ON m.MoId = md.MoId INNER JOIN
|
||||
@@ -242,12 +252,17 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
|
||||
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,
|
||||
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,dtyl.dtty, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll,mdsss.mdqty,shwl.shwl,sdwl.sdwl
|
||||
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 '自制'
|
||||
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,
|
||||
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(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) AS rqty1, ISNULL(pu_App.RQTY3, 0) AS rqty3,ISNULL(momq.momqty, 0) AS momqty, ISNULL(MX.MQTY, 0) MQTY, 0-(mas.wqty - 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,
|
||||
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
|
||||
mom_orderdetail md WITH (NOLOCK) ON m.MoId = md.MoId INNER JOIN
|
||||
@@ -658,7 +673,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,CONVER
|
||||
}
|
||||
if (!info1.byFinish)
|
||||
{
|
||||
where.Add(" isnull(zpurpotail.cbcloser,'') ='' ");
|
||||
where.Add(" isnull(zpurpotail.cbcloser,'') ='' and zpurpotail.ireceivedqty <> zpurpotail.iquantity ");
|
||||
}
|
||||
var aa = string.Join(" and ", where.ToArray());
|
||||
|
||||
|
||||
508
NX.ERP.U8/Pmc/PurchaseQuery.cs
Normal file
508
NX.ERP.U8/Pmc/PurchaseQuery.cs
Normal file
@@ -0,0 +1,508 @@
|
||||
using NX.ERP.U8.Purchase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Dapper;
|
||||
|
||||
|
||||
namespace NX.ERP.U8.Purchase
|
||||
|
||||
{
|
||||
public class PurchaseQuery
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="strWhere"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public IEnumerable<object> InventoryPoc(NX.ERP.Model.Request.PoOrderRequest info1)
|
||||
{
|
||||
|
||||
string sql = $@"
|
||||
select *from (
|
||||
select A.cpersonname ,A.cordercode , CONVERT(varchar(100), A.dpodate, 23) as dpodate , CONVERT(varchar(100), A.dArriveDate, 23) as dArriveDate ,
|
||||
A.cvenabbname , A.cinvcode , A.cinvname ,A.cinvstd ,cinvm_unit ,A.iquantity
|
||||
,(A.iquantity-isnull(b.YDH,0)) AS wjh,(A.iquantity-isnull(b.YDH,0)+isnull(E.fRealQuantity,0)) AS wrk ,isnull(d.iQuantity,0) AS xcl,isnull(F.iqty,0) AS qll,(isnull(d.iQuantity,0)- isnull(F.iqty,0)) AS bull, a0.iQuantity as iQuantity00 ,a1.iQuantity as iQuantity01 from (
|
||||
SELECT cpersonname,cordercode,dpodate,dArriveDate,cvencode,cvenabbname,cinvcode,cinvname,cinvstd,cinvm_unit,iquantity ,id from copypolist WITH (NOLOCK)
|
||||
where bposourcearr=1
|
||||
and bservice <> 1 and binvtype<>1
|
||||
|
||||
and (isnull(iquantity,0)>isnull(iarrqty,0) or (isnull(inum,0)>isnull(iarrnum,0) and iGroupType = 2 ))
|
||||
and isnull(cbustype,'')<>N'直运采购' and ((isnull(cVerifier,'')<>'' and isnull(cchanger,'')='') or (isnull(cchangverifier,'')<>'')) AND 1=1
|
||||
and bInvEntrust=0 AND isnull(cbustype,'')=N'普通采购' and 1=1 and iDiscountTaxType=0
|
||||
) A left join
|
||||
(
|
||||
select iPOsID,cInvCode,sum(iQuantity)AS YDH from PU_ArrivalVouchs WITH (NOLOCK) group by iPOsID,cInvCode
|
||||
) B on A.ID=B.iPOsID and a.cInvCode =B.cInvCode
|
||||
left join
|
||||
CurrentStock D WITH (NOLOCK) on A.cinvcode=D.cInvCode and d.cWhCode=2
|
||||
left join
|
||||
(
|
||||
select
|
||||
A.cInvCode ,
|
||||
A.fRealQuantity,
|
||||
B.cVenCode ,
|
||||
A.iPOsID
|
||||
from
|
||||
PU_ArrivalVouchs A WITH (NOLOCK) left join
|
||||
PU_ArrivalVouch B WITH (NOLOCK) on A.ID =B.ID
|
||||
where isnull(cbcloser,'')='' And iBillType =N'0' and cverifier is not null
|
||||
and (isnull(iQuantity,0)-isnull(fRefuseQuantity,0)>isnull(fValidInQuan,0) or ( isnull(inum,0)-isnull(frefusenum,0)>isnull(fvalidinnum,0))) )
|
||||
E on A.cinvcode=e.cInvCode and a.id=e.iPOsID
|
||||
left join
|
||||
(
|
||||
SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId
|
||||
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0
|
||||
GROUP BY ma.InvCode) F on A.cinvcode=F.InvCode
|
||||
left join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from (
|
||||
select a.cinvcode, 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)
|
||||
union all
|
||||
select a.cinvcode, 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)
|
||||
) a
|
||||
group by a.cinvcode
|
||||
) a0 on a.cInvCode=a0.cInvCode
|
||||
left join
|
||||
( select a.cinvcode, sum(a.iQuantity) as iQuantity from (
|
||||
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
|
||||
union all
|
||||
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
|
||||
) a
|
||||
group by a.cinvcode
|
||||
) a1 on a.cInvCode =a1.cInvCode
|
||||
) mmm
|
||||
|
||||
";
|
||||
|
||||
if (info1.BeginDate2 != null && info1.EndDate2 != null)
|
||||
{
|
||||
sql = $@"select *from (
|
||||
select A.cpersonname ,A.cordercode , CONVERT(varchar(100), A.dpodate, 23) as dpodate , CONVERT(varchar(100), A.dArriveDate, 23) as dArriveDate ,
|
||||
A.cvencode , A.cvenabbname , A.cinvcode , A.cinvname ,A.cinvstd ,cinvm_unit ,A.iquantity
|
||||
,(A.iquantity-isnull(b.YDH,0)) AS wjh,(A.iquantity-isnull(b.YDH,0)+isnull(E.fRealQuantity,0)) AS wrk ,isnull(d.iQuantity,0) AS xcl,isnull(F.iqty,0) AS qll,(isnull(d.iQuantity,0)- isnull(F.iqty,0)) AS bull, a0.iQuantity as iQuantity00 ,a1.iQuantity as iQuantity01 from (
|
||||
SELECT cpersonname,cordercode,dpodate,dArriveDate,cvencode,cvenabbname,cinvcode,cinvname,cinvstd,cinvm_unit,iquantity ,id from copypolist WITH (NOLOCK)
|
||||
where bposourcearr=1
|
||||
and bservice <> 1 and binvtype<>1
|
||||
|
||||
and (isnull(iquantity,0)>isnull(iarrqty,0) or (isnull(inum,0)>isnull(iarrnum,0) and iGroupType = 2 ))
|
||||
and isnull(cbustype,'')<>N'直运采购' and ((isnull(cVerifier,'')<>'' and isnull(cchanger,'')='') or (isnull(cchangverifier,'')<>'')) AND 1=1
|
||||
and bInvEntrust=0 AND isnull(cbustype,'')=N'普通采购' and 1=1 and iDiscountTaxType=0
|
||||
) A left join
|
||||
(
|
||||
select iPOsID,cInvCode,sum(iQuantity)AS YDH from PU_ArrivalVouchs WITH (NOLOCK) group by iPOsID,cInvCode
|
||||
) B on A.ID=B.iPOsID and a.cInvCode =B.cInvCode
|
||||
left join
|
||||
CurrentStock D WITH (NOLOCK) on A.cinvcode=D.cInvCode and d.cWhCode=2
|
||||
left join
|
||||
(
|
||||
select
|
||||
A.cInvCode ,
|
||||
A.fRealQuantity,
|
||||
B.cVenCode ,
|
||||
A.iPOsID
|
||||
from
|
||||
PU_ArrivalVouchs A WITH (NOLOCK) left join
|
||||
PU_ArrivalVouch B WITH (NOLOCK) on A.ID =B.ID
|
||||
where isnull(cbcloser,'')='' And iBillType =N'0' and cverifier is not null
|
||||
and (isnull(iQuantity,0)-isnull(fRefuseQuantity,0)>isnull(fValidInQuan,0) or ( isnull(inum,0)-isnull(frefusenum,0)>isnull(fvalidinnum,0))) )
|
||||
E on A.cinvcode=e.cInvCode and a.id=e.iPOsID
|
||||
left join
|
||||
(
|
||||
SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
|
||||
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
|
||||
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and mor.DueDate between @beginDate2 and @endDate2
|
||||
GROUP BY ma.InvCode) F on A.cinvcode=F.InvCode
|
||||
left join
|
||||
(select a.cinvcode, sum(a.iQuantity) as iQuantity from (
|
||||
select a.cinvcode, 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)
|
||||
union all
|
||||
select a.cinvcode, 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)
|
||||
) a
|
||||
group by a.cinvcode
|
||||
) a0 on a.cInvCode=a0.cInvCode
|
||||
left join
|
||||
( select a.cinvcode, sum(a.iQuantity) as iQuantity from (
|
||||
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
|
||||
union all
|
||||
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
|
||||
) a
|
||||
group by a.cinvcode
|
||||
) a1 on a.cInvCode =a1.cInvCode
|
||||
) mmm
|
||||
|
||||
";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
List<string> where = new List<string>();
|
||||
|
||||
if (info1.InvCodes != null)
|
||||
{
|
||||
where.Add(" mmm.cinvcode in @cinvcode");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(info1.InvStd))
|
||||
{
|
||||
where.Add(" mmm.cinvstd like @cInvStd ");
|
||||
}
|
||||
if (info1.PoCodes != null)
|
||||
{
|
||||
where.Add(" mmm.cordercode in @PoCodes ");
|
||||
}
|
||||
|
||||
|
||||
if (info1.BeginDate != null && info1.EndDate != null)
|
||||
{
|
||||
where.Add(" mmm.dPODate between @beginDate and @endDate ");
|
||||
|
||||
}
|
||||
|
||||
|
||||
var aa = string.Join(" and ", where.ToArray());
|
||||
|
||||
if (!string.IsNullOrEmpty(aa))
|
||||
{
|
||||
sql += "where " + aa;
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<object> Purchasesum(NX.ERP.Model.Request.PurchasesumRequest info)
|
||||
{
|
||||
string sql = $@"
|
||||
DECLARE @RdRecord table(
|
||||
cPsn_Num nvarchar(30),
|
||||
cpersonname nvarchar(30),
|
||||
puappnumall int,
|
||||
puappnum03 int,
|
||||
mommouth02 int,
|
||||
mommouth04 int
|
||||
)
|
||||
|
||||
DECLARE @RdRecord2 table(
|
||||
cpersonname nvarchar(30),
|
||||
puappnumall int
|
||||
)
|
||||
|
||||
DECLARE @RdRecord3 table(
|
||||
cpersonname nvarchar(30),
|
||||
puappnumall int
|
||||
)
|
||||
|
||||
DECLARE @RdRecord4 table(
|
||||
cpersonname nvarchar(30),
|
||||
puappnumall int
|
||||
)
|
||||
DECLARE @RdRecord5 table(
|
||||
cpersonname nvarchar(30),
|
||||
puappnumall int
|
||||
)
|
||||
|
||||
insert into @RdRecord
|
||||
select cPsn_Num, cPsn_Name,0,0,0,0 from hr_v_HR31_show where cDepCode ='52' and rEmployState ='在职'
|
||||
|
||||
insert into @RdRecord
|
||||
select 'qt999','其他',0,0,0,0
|
||||
|
||||
|
||||
|
||||
insert into @RdRecord2
|
||||
select cPsn_Num,sum(RQTY3) as puappnumall from (
|
||||
select RQTY3,isnull(cMaker,'其他') as cPsn_Num from
|
||||
(
|
||||
SELECT CINVCODE, SUM(RQTY) AS RQTY3
|
||||
FROM (
|
||||
SELECT ommds.cInvCode, 1 as RQTY
|
||||
FROM pu_AppHead omm WITH (nolock) INNER JOIN
|
||||
pu_appbody ommds WITH (nolock) ON omm.id = ommds.id LEFT JOIN
|
||||
(SELECT iAppIds, sum(iquantity) AS qty
|
||||
FROM PO_Podetails WITH (nolock)
|
||||
GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds
|
||||
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode
|
||||
) as tbl1
|
||||
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)
|
||||
as c where c.rownumber=1
|
||||
)
|
||||
as tbl on tbl1.cinvcode=tbl.cInvCode
|
||||
) q group by cPsn_Num
|
||||
|
||||
update a set a.puappnumall=b.puappnumall From @RdRecord a left join @RdRecord2 b on a.cpersonname =b.cpersonname
|
||||
|
||||
update a set a.puappnumall= a.puappnumall +b.puappnumall From @RdRecord a left join (
|
||||
select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord2 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname
|
||||
where a.cpersonname='其他'
|
||||
|
||||
insert into @RdRecord3
|
||||
select cPsn_Num,sum(RQTY3) as puappnumall from (
|
||||
select RQTY3,isnull(cMaker,'其他') as cPsn_Num from
|
||||
(
|
||||
SELECT CINVCODE, SUM(RQTY) AS RQTY3
|
||||
FROM (
|
||||
SELECT ommds.cInvCode, 1 as RQTY
|
||||
FROM pu_AppHead omm WITH (nolock) INNER JOIN
|
||||
pu_appbody ommds WITH (nolock) ON omm.id = ommds.id LEFT JOIN
|
||||
(SELECT iAppIds, sum(iquantity) AS qty
|
||||
FROM PO_Podetails WITH (nolock)
|
||||
GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds
|
||||
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND DATEDIFF(day,ddate ,GETDATE()) >=3 and
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
|
||||
GROUP BY cInvCode
|
||||
) as tbl1
|
||||
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)
|
||||
as c where c.rownumber=1
|
||||
)
|
||||
as tbl on tbl1.cinvcode=tbl.cInvCode
|
||||
) q group by cPsn_Num
|
||||
|
||||
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 (
|
||||
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='其他'
|
||||
|
||||
|
||||
|
||||
insert into @RdRecord4
|
||||
select cPsn_Num,sum(RQTY3) as puappnumall from (
|
||||
select RQTY3,isnull(cMaker,'其他') as cPsn_Num from
|
||||
(
|
||||
SELECT CINVCODE, SUM(RQTY) AS RQTY3
|
||||
FROM (
|
||||
select a.InvCode as CINVCODE ,1 as RQTY From (
|
||||
SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
|
||||
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
|
||||
|
||||
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and
|
||||
mor.DueDate between @beginDate and @endDate
|
||||
GROUP BY ma.InvCode
|
||||
) a left join
|
||||
CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM
|
||||
GROUP BY cInvCode
|
||||
) as tbl1
|
||||
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)
|
||||
as c where c.rownumber=1
|
||||
)
|
||||
as tbl on tbl1.cinvcode=tbl.cInvCode )
|
||||
q group by cPsn_Num
|
||||
|
||||
|
||||
update a set a.mommouth02=b.puappnumall From @RdRecord a left join @RdRecord4 b on a.cpersonname =b.cpersonname
|
||||
|
||||
update a set a.mommouth02= a.mommouth02 +b.mommouth02 From @RdRecord a left join (
|
||||
select '其他' as cpersonname ,sum(puappnumall) as mommouth02 from @RdRecord4 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname
|
||||
where a.cpersonname='其他'
|
||||
|
||||
|
||||
insert into @RdRecord5
|
||||
select cPsn_Num,sum(RQTY3) as puappnumall from (
|
||||
select RQTY3,isnull(cMaker,'其他') as cPsn_Num from
|
||||
(
|
||||
SELECT CINVCODE, SUM(RQTY) AS RQTY3
|
||||
FROM (
|
||||
select a.InvCode as CINVCODE ,1 as RQTY From (
|
||||
SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
|
||||
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
|
||||
|
||||
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and
|
||||
mor.DueDate between @beginDate2 and @endDate2
|
||||
GROUP BY ma.InvCode
|
||||
) a left join
|
||||
CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM
|
||||
GROUP BY cInvCode
|
||||
) as tbl1
|
||||
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)
|
||||
as c where c.rownumber=1
|
||||
)
|
||||
as tbl on tbl1.cinvcode=tbl.cInvCode )
|
||||
q group by cPsn_Num
|
||||
|
||||
|
||||
|
||||
|
||||
update a set a.mommouth04=b.puappnumall From @RdRecord a left join @RdRecord5 b on a.cpersonname =b.cpersonname
|
||||
|
||||
update a set a.mommouth04= a.mommouth04 +b.mommouth04 From @RdRecord a left join (
|
||||
select '其他' as cpersonname ,sum(puappnumall) as mommouth04 from @RdRecord5 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname
|
||||
where a.cpersonname='其他'
|
||||
|
||||
|
||||
select *from @RdRecord
|
||||
|
||||
|
||||
|
||||
";
|
||||
|
||||
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
|
||||
{
|
||||
return conn.Query<object>(sql, new { info.BeginDate, info.EndDate, info.BeginDate2, info.EndDate2 });
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<object> Purchasesumpuapp(NX.ERP.Model.Request.PurchasesumRequest info)
|
||||
{
|
||||
string sql = $@"
|
||||
select *from (
|
||||
SELECT omm.ccode, CONVERT(varchar(100), omm.ddate, 23) as dDatel, omm.ddate ,ommds.cInvCode,ommds.cinvname, ommds.cinvstd,ommds.fquantity - ISNULL(rds.qty, 0) as RQTY,isnull(f.cMaker,'其他') as cMaker
|
||||
FROM pu_AppHead omm WITH (nolock) INNER JOIN
|
||||
pu_appbody ommds WITH (nolock) ON omm.id = ommds.id LEFT JOIN
|
||||
(SELECT iAppIds, sum(iquantity) AS qty
|
||||
FROM PO_Podetails WITH (nolock)
|
||||
GROUP BY iAppIds) rds ON ommds.autoid = rds.iAppIds
|
||||
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)
|
||||
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
|
||||
ommds.fquantity - ISNULL(rds.qty, 0) > 0 ) puu
|
||||
";
|
||||
|
||||
List<string> where = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(info.cpersonname))
|
||||
{
|
||||
where.Add(" puu.cMaker = @cpersonname");
|
||||
}
|
||||
if (info.InvCodes != null)
|
||||
{
|
||||
where.Add(" puu.cInvCode in @InvCodes");
|
||||
}
|
||||
if (info.cday > 0)
|
||||
{
|
||||
where.Add(" DATEDIFF(day,puu.ddate ,GETDATE()) >=@cday");
|
||||
}
|
||||
var aa = string.Join(" and ", where.ToArray());
|
||||
|
||||
if (!string.IsNullOrEmpty(aa))
|
||||
{
|
||||
sql += "where " + aa;
|
||||
}
|
||||
|
||||
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
|
||||
{
|
||||
return conn.Query<object>(sql, new { info.cpersonname, info.InvCodes, info.cday });
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<object> Purchasesummom(NX.ERP.Model.Request.PurchasesumRequest info)
|
||||
{
|
||||
string sql = $@"
|
||||
DECLARE @RdRecord table(
|
||||
CINVCODE nvarchar(200),
|
||||
RQTY int,
|
||||
iqty int,
|
||||
iQuantity int,
|
||||
bull int,
|
||||
cpersonname nvarchar(200),
|
||||
cInvName nvarchar(200),
|
||||
cInvStd nvarchar(500)
|
||||
)
|
||||
insert into @RdRecord
|
||||
select *from (
|
||||
select a.*,isnull(f.cMaker,'其他') as cpersonname ,inv.cInvName,inv.cInvStd from (
|
||||
select a.InvCode as CINVCODE ,1 as RQTY , iqty,cur.iQuantity, (cur.iQuantity-iqty) as bull From (
|
||||
SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
|
||||
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
|
||||
|
||||
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and
|
||||
mor.DueDate between @beginDate and @endDate
|
||||
GROUP BY ma.InvCode
|
||||
) a left join
|
||||
CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0
|
||||
) a left join
|
||||
(select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a WITH (NOLOCK), PO_Podetails b WITH (NOLOCK) where a.poid=b.poid)
|
||||
as c where c.rownumber=1) f on a.CINVCODE=f.cInvCode
|
||||
left join Inventory inv WITH (NOLOCK) on a.CINVCODE=inv.cInvCode )pumo
|
||||
|
||||
update @RdRecord set cpersonname ='其他' where cpersonname not in ( select cPsn_Name from hr_v_HR31_show where cDepCode ='52' and rEmployState ='在职')
|
||||
|
||||
|
||||
select *From @RdRecord
|
||||
";
|
||||
|
||||
List<string> where = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(info.cpersonname))
|
||||
{
|
||||
where.Add(" cpersonname = @cpersonname");
|
||||
}
|
||||
if (info.InvCodes != null)
|
||||
{
|
||||
where.Add(" cInvCode = @InvCodes");
|
||||
}
|
||||
|
||||
var aa = string.Join(" and ", where.ToArray());
|
||||
|
||||
if (!string.IsNullOrEmpty(aa))
|
||||
{
|
||||
sql += "where " + aa;
|
||||
}
|
||||
|
||||
|
||||
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
|
||||
|
||||
{
|
||||
return conn.Query<object>(sql, new { info.cpersonname, info.InvCodes, info.cday, info.BeginDate, info.EndDate });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user