This commit is contained in:
gongxh
2021-08-16 14:25:14 +08:00
21 changed files with 1831 additions and 127 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -22,8 +22,8 @@ namespace NX.ERP.U8.Finance
public IEnumerable<object> InventorySNDetail(NX.ERP.Model.Request.SnOrderRequest info1)
{
string sql = $@"
select a.cInvCode,e.cInvName,b.cCode as Cprk, b.dDate as rkrq,c.cWhName,
b.cMPoCode,d.cDepName,a.cInvSN,k.iUnitCost,
select a.cInvCode,e.cInvName,b.cCode as Cprk, b.dDate as rkrq,c.cWhName,
b.cMPoCode,d.cDepName,a.cInvSN,a.csnmemo,k.iUnitCost,
g.cCode as Clck,g.dDate as ckrq,h.cCusAbbName,f.cInvSN as ckcInvSN
from ST_SNDetail_PROIN a WITH(NOLOCK)
left join rdrecord10 b WITH(NOLOCK) on a.iVouchID=b.id

View File

@@ -168,7 +168,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,md.Rem
mom_moallocate ma WITH (NOLOCK) ON md.MoDId = ma.MoDId
left JOIN
mom_motype motype WITH (NOLOCK) ON motype.MoTypeId = md.MoTypeId
INNER JOIN
left 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
@@ -199,12 +199,14 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate ,md.Rem
WHERE md.Status = 3
GROUP BY ma.InvCode) shwl ON ma.InvCode = shwl.InvCode LEFT JOIN
(SELECT mom.MoCode, ma.invcode,round(SUM(isnull(ma.qty, 0))/md.Qty,3) dtty
(select a.MoCode ,a.InvCode ,a.MoDId ,(a.dtty/b.Qty) as dtty from (
SELECT mom.MoCode, ma.invcode,round(SUM(isnull(ma.qty, 0)),3) dtty, md.MoDId
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
mom_order mom WITH (NOLOCK) on md.MoId=mom.MoId
GROUP BY ma.InvCode,mom.MoCode,md.Qty ) dtyl ON ma.InvCode = dtyl.InvCode and dtyl.MoCode=m.MoCode LEFT JOIN
mom_order mom WITH (NOLOCK) on md.MoId=mom.MoId
GROUP BY ma.InvCode,mom.MoCode, md.MoDId ) a left join mom_orderdetail b WITH (NOLOCK) ON a.MoDId = b.MoDId ) dtyl ON ma.InvCode = dtyl.InvCode and dtyl.MoCode=m.MoCode and md.MoDId= dtyl.MoDId
LEFT JOIN
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
@@ -288,7 +290,7 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate,md.Rema
mom_moallocate ma WITH (NOLOCK) ON md.MoDId = ma.MoDId
left JOIN
mom_motype motype WITH (NOLOCK) ON motype.MoTypeId = md.MoTypeId
INNER JOIN
left 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
@@ -321,11 +323,14 @@ SELECT m..mocode,CONVERT(varchar(100), mor.StartDate, 23) as StartDate,md.Rema
GROUP BY ma.InvCode) shwl ON ma.InvCode = shwl.InvCode LEFT JOIN
(SELECT mom.MoCode, ma.invcode,round(SUM(isnull(ma.qty, 0))/md.Qty,3) dtty
(select a.MoCode ,a.InvCode ,a.MoDId ,(a.dtty/b.Qty) as dtty from (
SELECT mom.MoCode, ma.invcode,round(SUM(isnull(ma.qty, 0)),3) dtty, md.MoDId
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
mom_order mom WITH (NOLOCK) on md.MoId=mom.MoId
GROUP BY ma.InvCode,mom.MoCode,md.Qty ) dtyl ON ma.InvCode = dtyl.InvCode and dtyl.MoCode=m.MoCode LEFT JOIN
mom_order mom WITH (NOLOCK) on md.MoId=mom.MoId
GROUP BY ma.InvCode,mom.MoCode, md.MoDId ) a left join mom_orderdetail b WITH (NOLOCK) ON a.MoDId = b.MoDId ) dtyl ON ma.InvCode = dtyl.InvCode and dtyl.MoCode=m.MoCode and md.MoDId= dtyl.MoDId
LEFT JOIN
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN

View File

@@ -211,7 +211,7 @@ namespace NX.ERP.U8.Purchase
public IEnumerable<object> Purchasesum(NX.ERP.Model.Request.PurchasesumRequest info)
{
string sql = $@"
DECLARE @RdRecord table(
DECLARE @RdRecord table(
cPsn_Num nvarchar(30),
cpersonname nvarchar(30),
puappnumall int,
@@ -259,7 +259,7 @@ namespace NX.ERP.U8.Purchase
(SELECT iAppIds, sum(iquantity) AS qty
FROM PO_Podetails WITH (nolock)
GROUP BY iAppIds) rds ON isnull(ommds.autoid,'') = isnull(rds.iAppIds,'')
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, 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(omm.cverifier, N'') <> N'' AND ISNULL(rds.qty, 0)=0 and ommds.iReceivedQTY=0 and
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
GROUP BY cInvCode
) as tbl1
@@ -273,11 +273,15 @@ namespace NX.ERP.U8.Purchase
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.cpersonname=b.receive From @RdRecord2 a left join CGBB2021_0001_E001 b WITH (NOLOCK) on a.cpersonname =b.quit
where b.quit is not null
update a set a.puappnumall= a.puappnumall +b.puappnumall From @RdRecord a left join (
update a set a.puappnumall=isnull(b.puappnumall,0) From @RdRecord a left join
(select cpersonname,sum(puappnumall) as puappnumall from @RdRecord2 group by cpersonname ) b on a.cpersonname =b.cpersonname
update a set a.puappnumall= isnull(a.puappnumall,0) +isnull(b.puappnumall,0) 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='其他'
where a.cpersonname='其他'
insert into @RdRecord3
select cPsn_Num,sum(RQTY3) as puappnumall from (
@@ -291,7 +295,7 @@ namespace NX.ERP.U8.Purchase
(SELECT iAppIds, sum(iquantity) AS qty
FROM PO_Podetails WITH (nolock)
GROUP BY iAppIds) rds ON isnull(ommds.autoid,'') = isnull(rds.iAppIds,'')
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND ISNULL(rds.qty, 0)=0 and ommds.iReceivedQTY=0 and DATEDIFF(day,ddate ,GETDATE()) >=3 and
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND ISNULL(omm.cverifier, N'') <> N'' AND ISNULL(rds.qty, 0)=0 and ommds.iReceivedQTY=0 and DATEDIFF(day,ddate ,GETDATE()) >=3 and
ommds.fquantity - ISNULL(rds.qty, 0) > 0) OM
GROUP BY cInvCode
) as tbl1
@@ -305,9 +309,13 @@ namespace NX.ERP.U8.Purchase
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.cpersonname=b.receive From @RdRecord3 a left join CGBB2021_0001_E001 b WITH (NOLOCK) on a.cpersonname =b.quit
where b.quit is not null
update a set a.puappnum03= a.puappnum03 +b.puappnumall From @RdRecord a left join (
update a set a.puappnum03=isnull(b.puappnumall,0) From @RdRecord a left join
(select cpersonname,sum(puappnumall) as puappnumall from @RdRecord3 group by cpersonname) b on a.cpersonname =b.cpersonname
update a set a.puappnum03= isnull(a.puappnum03,0) +isnull(b.puappnumall,0) 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='其他'
@@ -342,10 +350,14 @@ namespace NX.ERP.U8.Purchase
as tbl on tbl1.cinvcode=tbl.cInvCode )
q group by cPsn_Num
update a set a.cpersonname=b.receive From @RdRecord4 a left join CGBB2021_0001_E001 b WITH (NOLOCK) on a.cpersonname =b.quit
where b.quit is not null
update a set a.mommouth02=b.puappnumall From @RdRecord a left join @RdRecord4 b on a.cpersonname =b.cpersonname
update a set a.mommouth02=isnull(b.puappnumall,0) From @RdRecord a left join
(select cpersonname,sum(puappnumall) as puappnumall from @RdRecord4 group by cpersonname
) b on a.cpersonname =b.cpersonname
update a set a.mommouth02= a.mommouth02 +b.mommouth02 From @RdRecord a left join (
update a set a.mommouth02= isnull(a.mommouth02,0) +isnull(b.mommouth02,0) 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='其他'
@@ -379,21 +391,27 @@ namespace NX.ERP.U8.Purchase
as tbl on tbl1.cinvcode=tbl.cInvCode )
q group by cPsn_Num
update a set a.cpersonname=b.receive From @RdRecord5 a left join CGBB2021_0001_E001 b WITH (NOLOCK) on a.cpersonname =b.quit
where b.quit is not null
update a set a.mommouth04=b.puappnumall From @RdRecord a left join @RdRecord5 b on a.cpersonname =b.cpersonname
update a set a.mommouth04=isnull(b.puappnumall,0) From @RdRecord a left join (
select cpersonname,sum(puappnumall) as puappnumall from @RdRecord5 group by cpersonname) b on a.cpersonname =b.cpersonname
update a set a.mommouth04= a.mommouth04 +b.mommouth04 From @RdRecord a left join (
update a set a.mommouth04= isnull(a.mommouth04,0) +isnull(b.mommouth04,0) 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='其他'
delete from @RdRecord where cpersonname in (select quit from CGBB2021_0001_E001)
select *from @RdRecord
";
@@ -407,8 +425,24 @@ namespace NX.ERP.U8.Purchase
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
IF EXISTS (SELECT NAME FROM tempdb..SYSOBJECTS WHERE NAME ='tablepuapp20210625' AND Xtype='U') DROP Table tempdb..tablepuapp20210625
create table tempdb..tablepuapp20210625 (
ccode nvarchar(200),
dDatel nvarchar(200),
ddate datetime,
cInvCode nvarchar(200),
cinvname nvarchar(500),
cinvstd nvarchar(500),
RQTY decimal(28, 6),
cMaker nvarchar(200)
)
CREATE INDEX IX_test ON tempdb..tablepuapp20210625 (cinvcode)
insert into tempdb..tablepuapp20210625
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(isnull(k.receive ,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
@@ -417,8 +451,15 @@ namespace NX.ERP.U8.Purchase
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 ommds.cInvCode =f.cInvCode
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, 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
left join CGBB2021_0001_E001 k WITH (NOLOCK) on f.cMaker =k.quit
WHERE ISNULL(OMM.cCloser, N'') = N'' AND ISNULL(ommds.cbCloser, N'') = N'' AND ISNULL(omm.cverifier, N'') <> N'' AND ISNULL(rds.qty, 0)=0 and ommds.iReceivedQTY=0 AND
ommds.fquantity - ISNULL(rds.qty, 0) > 0 ) puapp
update tempdb..tablepuapp20210625 set cmaker='其他' where cMaker not in ( select cPsn_Name from hr_v_HR31_show WITH (NOLOCK) where cDepCode ='52' and rEmployState ='在职')
and cMaker not in (select quit from CGBB2021_0001_E001 WITH (NOLOCK))
select *From tempdb..tablepuapp20210625 puu
";
List<string> where = new List<string>();
@@ -453,8 +494,9 @@ namespace NX.ERP.U8.Purchase
public IEnumerable<object> Purchasesummom(NX.ERP.Model.Request.PurchasesumRequest info)
{
string sql = $@"
DECLARE @RdRecord table(
CINVCODE nvarchar(200),
IF EXISTS (SELECT NAME FROM tempdb..SYSOBJECTS WHERE NAME ='tablemom20210625' AND Xtype='U') DROP Table tempdb..tablemom20210625
create table tempdb..tablemom20210625 (
CINVCODE nvarchar(200),
RQTY int,
iqty int,
iQuantity int,
@@ -462,10 +504,12 @@ namespace NX.ERP.U8.Purchase
cpersonname nvarchar(200),
cInvName nvarchar(200),
cInvStd nvarchar(500)
)
insert into @RdRecord
)
insert into tempdb..tablemom20210625
select *from (
select a.*,isnull(f.cMaker,'其他') as cpersonname ,inv.cInvName,inv.cInvStd from (
select a.*,isnull(isnull(k.receive ,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
@@ -480,12 +524,14 @@ namespace NX.ERP.U8.Purchase
) 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 CGBB2021_0001_E001 k WITH (NOLOCK) on f.cMaker =k.quit
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 ='在职')
update tempdb..tablemom20210625 set cpersonname ='其他' where cpersonname not in ( select cPsn_Name from hr_v_HR31_show WITH (NOLOCK) where cDepCode ='52' and rEmployState ='在职')
and cpersonname not in (select quit from CGBB2021_0001_E001 WITH (NOLOCK))
select *From @RdRecord
select *From tempdb..tablemom20210625
";
List<string> where = new List<string>();

View File

@@ -51,7 +51,7 @@ select a.id AS ArrivalId,a.cCode as ArrivalCode,a.cpersoncode,a.cpersonname,A.c
, PO_Podetails C WITH (NOLOCK)
Where ( (1>0) AND (1>0) ) AND ( 1>0 ) and (isnull(cbustype,'')<>'委外加工') -- and ( isnull (b.cInvCode,'')=isnull(Pos.cInvCode,''))
And (1=1) and isnull(b.cbcloser,N'')=N'' And isnull(a.cverifier,'')<>'' and a.id=b.id and b.cinvcode=inventory.cinvcode1 and B.iPOsID = C.ID
And (1=1) and isnull(b.cbcloser,N'')=N'' and a.id=b.id and b.cinvcode=inventory.cinvcode1 and B.iPOsID = C.ID
And a.iBillType =N'0' and isnull(b.bGsp,N'')=N'0' and (isnull(b.iQuantity,0)-isnull(b.fRefuseQuantity,0)>isnull(b.fValidInQuan,0) or (b.igrouptype=2
and isnull(b.inum,0)-isnull(b.frefusenum,0)>isnull(b.fvalidinnum,0))) and isnull(a.bStorageArrivalOrder,1)=1 and 1=1

View File

@@ -45,7 +45,7 @@ namespace NX.ERP.U8.Store
headXml.setAttribute("cDepCode", param.DepCode);
headXml.setAttribute("cMaker", param.Maker);
headXml.setAttribute("cPersonCode", param.PersonCode);
Model.MOM.MomOrder Order = null;
Model.MOM.MomOrder Order = null;
if (param.source == "生产订单")
{
Order = new Mom.MomOrderDAL().GetModel(param.SourceCode);
@@ -251,5 +251,113 @@ FROM MaterialAppVouch a
}
/// <summary>
/// 根据领料单号查询 带库位
/// </summary>
/// <param name="Code"></param>
/// <returns></returns>
public IEnumerable<Model.Response.Store.MaterialAppVouchAndPostName> GetModelAndPost(string OrderCode, string invCode)
{
if (!string.IsNullOrEmpty(OrderCode) && !string.IsNullOrEmpty(invCode))
{
return this.GetListAndPost(" MA.cCode=@OrderCode AND MAS.cInvCode = @invCode ", new { OrderCode, invCode });
}
else
if (!string.IsNullOrEmpty(OrderCode))
{
return this.GetListAndPost(" MA.cCode=@OrderCode", new { OrderCode });
}
else if (!string.IsNullOrEmpty(invCode))
{
return this.GetListAndPost(" MAS.cInvCode = @invCode ", new { invCode });
}
else
{
return this.GetListAndPost();
}
}
/// <summary>
/// 查询领料信息 带库位
/// </summary>
/// <param name="strWhere"></param>
/// <param name="Params"></param>
/// <returns></returns>
public IEnumerable<Model.Response.Store.MaterialAppVouchAndPostName> GetListAndPost(string strWhere = null, object Params = null)
{
var strSQL = @"SELECT
MA.cCode AS AppVouchOrderNo,--领料申请单号
MAS.cInvCode MaterialCode,--物料编码
INV.cInvName MaterialName,--物料名称
INV.cInvStd MaterialSpec,--物料规格
UNT.cComUnitName Unit,--单位
MAS.iQuantity Qty,--数量
CONVERT(varchar(100), MA.dDate, 23) DemandDate,--需求日期
wh.cWhName WarehouseName,--仓库名称
MAS.cpesocode ProductOrderNo,--生产单号
MAS.ipesoseq ProductOrderLineNo,--生产单行号
MAS.invcode ProductCode,--产品编码,
PDT.cInvName ProductName,--产品名称
PDT.cInvStd ProductSpec,--产品规格
POST.cPosName [Position]--库位
FROM
MaterialAppVouch MA
LEFT JOIN MaterialAppVouchs MAS ON MA.ID = MAS.ID
LEFT JOIN Inventory INV ON MAS.cInvCode = INV.cInvCode
LEFT JOIN Warehouse wh ON WH.cwhcode = MAS.cwhcode
LEFT JOIN ComputationUnit UNT ON INV.ccomunitcode = UNT.ccomunitcode
LEFT JOIN Inventory PDT ON MAS.invcode = PDT.cInvCode
LEFT JOIN (
SELECT
cinvcode,
STUFF(
(
SELECT
',' + cPosName
FROM
(
SELECT
b.cPosName,
a.cInvCode,
a.iQuantity
FROM
InvPositionSum a WITH ( NOLOCK ),
POSITION b WITH ( NOLOCK )
WHERE
a.iQuantity <> 0
AND a.cPosCode= b.cPosCode
) a
WHERE
b.cinvcode = a.cinvcode
ORDER BY
a.iQuantity DESC FOR XML PATH ( '' )
),
1,
1,
''
) cPosName
FROM
InvPositionSum b
GROUP BY
cinvcode
) AS post ON INV.cinvcode = post.cinvcode
WHERE MAS.iQuantity > ISNULL(MAS.foutquantity,0)
";
if (!string.IsNullOrEmpty(strWhere))
{
strSQL += $" AND {strWhere} ";
}
using (var conn = U8LoginContext.Instance.Connection)
{
var list = conn.Query<Model.Response.Store.MaterialAppVouchAndPostName>(strSQL, Params);
return list;
}
}
}
}