This commit is contained in:
ehkang
2021-06-10 14:32:16 +08:00
10 changed files with 375 additions and 11 deletions

View File

@@ -83,6 +83,54 @@ namespace NX.ERP.U8.Finance
}
}
public IEnumerable<object> Voucherror(NX.ERP.Model.Request.VouchererrorRequest info)
{
string sql = $@"
select *from (
select c.MoCode,b.SortSeq,b.InvCode,d.cInvName,a.InvCode as InvCode1, t.cInvName as cInvName1,t.cInvStd,a.Qty , a.IssQty ,'超领' as error from mom_moallocate a WITH (NOLOCK)
left join mom_orderdetail b WITH (NOLOCK) on a.MoDId= b.MoDId
left join mom_order c WITH (NOLOCK) on b.MoId= c.MoId
left join Inventory d WITH (NOLOCK) on b.InvCode= d.cInvCode
left join Inventory t WITH (NOLOCK) on a.InvCode= t.cInvCode
where a.Qty < a.IssQty
union all
select c.MoCode,b.SortSeq,b.InvCode,d.cInvName,a.InvCode as InvCode1, t.cInvName as cInvName1,t.cInvStd,a.Qty , a.IssQty ,'缺领' as error from mom_moallocate a WITH (NOLOCK)
left join mom_orderdetail b WITH (NOLOCK) on a.MoDId= b.MoDId
left join mom_order c WITH (NOLOCK) on b.MoId= c.MoId
left join Inventory d WITH (NOLOCK) on b.InvCode= d.cInvCode
left join Inventory t WITH (NOLOCK) on a.InvCode= t.cInvCode
where a.IssQty < a.Qty*(b.QualifiedInQty/b.qty)
) mm
";
List<string> where = new List<string>();
if (info.Ccode != null)
{
where.Add(" mm.MoCode in @Ccode");
}
if (info.error != null)
{
where.Add(" mm.error in @error");
}
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.Ccode, info.error });
}
}
}
}

View File

@@ -37,25 +37,24 @@ SELECT cinvcode,
),1 ,1, '') cPosName
FROM InvPositionSum b
GROUP BY cinvcode
select a.id AS ArrivalId,a.cCode as ArrivalCode,a.cpersoncode,a.cpersonname,A.cbustype AS busType,a.cptcode as PTCode,a.iTaxRate as TaxRate,a.iexchrate as Exchrate,cexch_name as ExchName,cVenCode as VenCode,a.dDate as ArrivalDate,A.cVenCode AS SupplierCode,
select a.id AS ArrivalId,a.cCode as ArrivalCode,a.cpersoncode,a.cpersonname,A.cbustype AS busType,a.cptcode as PTCode,a.iTaxRate as TaxRate,a.iexchrate as Exchrate,cexch_name as ExchName,cVenCode as VenCode, CONVERT(varchar(100), a.dDate, 23) as ArrivalDate,A.cVenCode AS SupplierCode,
B.Autoid as id,b.ID as ArrivalID,
b.cInvCode AS MaterialCode,
b.cInvCode AS MaterialCode,cinvname ,cinvstd,
b.cBatch AS BatchNo,
b.fvalidinquan as RealQuantity,
b.ccomunitcode AS UnitCode,b.ioricost as oricost,b.ioritaxcost as oritaxcost ,b.icost as cost,b.iorimoney as orimoney,b.ioritaxprice as oritaxprice,b.iorisum as orisum,b.isum as sum,
B.iQuantity as Quantity,b.iposid as PosId ,B.CORDERCODE as OrderCode,C.POID as Poid,b.iNum,b.ccomunitcode,b.cunitid,b.cinva_unit,b.cinvm_unit,b.inspecexchrate,
Pos.cPosName
FROM pu_ArrBody b , pu_ArrHead a
, (select cinvcode as cinvcode1,iId from inventory) inventory
, PO_Podetails C WITH (NOLOCK) ,
tempdb..tablearrive20210603 Pos -- on isnull (b.cInvCode,'')=isnull(Pos.cInvCode,'')
Where ( (1>0) AND (1>0) ) AND ( 1>0 ) and (isnull(cbustype,'')<>'委外加工') and isnull (b.cInvCode,'')=isnull(Pos.cInvCode,'')
FROM pu_ArrBody b left join tempdb..tablearrive20210603 Pos on isnull (b.cInvCode,'')=isnull(Pos.cInvCode,'') , pu_ArrHead a
, (select cinvcode as cinvcode1,iId from inventory WITH (NOLOCK) ) inventory
, 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 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
";
List<string> where = new List<string>();