跟单加默认查询
This commit is contained in:
@@ -123,10 +123,12 @@ namespace NX.ERP.U8.Pmc
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<object> Inventorymom(List<string> moCodes)
|
||||
public IEnumerable<NX.ERP.Model.PmcInventorymomRes> Inventorymom(List<string> moCodes)
|
||||
{
|
||||
string sql = $@"
|
||||
SELECT m..mocode, md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty, ma.InvCode invcode1,
|
||||
select *from (
|
||||
|
||||
SELECT m..mocode, md.SortSeq, md.InvCode, p.cInvName, p.cInvStd,KK.cComUnitName, md.Qty, md.QualifiedInQty, 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, ma.Qty qty1, ma.IssQty issqty,mdsss.mdqty, mas.wqty wqty, ISNULL(cs.qty, 0) cqty, ISNULL(misss.issqty, 0) issqtyxc,ISNULL(ds.qty, 0) dqty,isnull(prd.Rqty, 0) rqty,
|
||||
@@ -143,13 +145,13 @@ namespace NX.ERP.U8.Pmc
|
||||
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0
|
||||
GROUP BY ma.InvCode) mas ON ma.InvCode = mas.InvCode LEFT JOIN
|
||||
|
||||
(SELECT ma.invcode,SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) mdqty
|
||||
(SELECT mom.MoId, ma.invcode,SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) mdqty
|
||||
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
|
||||
|
||||
WHERE md.Status <> 4 and MoCode in @moCodes
|
||||
GROUP BY ma.InvCode) mdsss ON ma.InvCode = mdsss.InvCode LEFT JOIN
|
||||
WHERE md.Status <> 4
|
||||
GROUP BY ma.InvCode,mom.MoId) mdsss ON ma.InvCode = mdsss.InvCode and m.MoId=mdsss.MoId LEFT JOIN
|
||||
|
||||
(SELECT ma.invcode, SUM( isnull(issqty, 0)) issqty
|
||||
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
|
||||
@@ -204,13 +206,30 @@ namespace NX.ERP.U8.Pmc
|
||||
(select InvCode,sum(qty) as momqty from mom_orderdetail WITH (NOLOCK) where Status=3 group by InvCode) momq on MA.INVCODE = momq.InvCode
|
||||
left join ComputationUnit kk WITH (nolock) on p.cComUnitCode=kk.cComunitCode
|
||||
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
|
||||
WHERE md.Status <> 4 AND ma.Qty - IsNull(ma.IssQty, 0) > 0
|
||||
and m.mocode in @moCodes
|
||||
order by m.mocode,md.SortSeq, ma.InvCode
|
||||
where md.Status <> 4 AND ma.Qty - IsNull(ma.IssQty, 0) > 0 ) mmm
|
||||
";
|
||||
|
||||
List<string> where = new List<string>();
|
||||
|
||||
///处理-
|
||||
if (moCodes != null && moCodes.Count>0 )
|
||||
{
|
||||
where.Add(" mmm.mocode in @moCodes");
|
||||
}
|
||||
|
||||
|
||||
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 { moCodes = moCodes });
|
||||
return conn.Query<NX.ERP.Model.PmcInventorymomRes>(sql, new { moCodes = moCodes });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +372,7 @@ namespace NX.ERP.U8.Pmc
|
||||
public IEnumerable<object> Inventorysocode(NX.ERP.Model.Request.SaleOrderRequest info1)
|
||||
{
|
||||
string sql = $@"
|
||||
select j.cSTName,b.cSOCode,b.dDate,a.iRowNo,f.cCusAbbName,a.cInvCode,a.cInvName,g.cInvStd,a.iQuantity, h.dDate as fhdDate ,isnull(c.fqty,0)fqty,isnull(d.cqty,0)cqty
|
||||
select j.cSTName,b.cSOCode,CONVERT(varchar(100),b.dDate, 23) as dDate ,a.iRowNo,f.cCusAbbName,a.cInvCode,a.cInvName,g.cInvStd,a.iQuantity, CONVERT(varchar(100),a.dPreDate, 23) as dPreDate , CONVERT(varchar(100),h.dDate, 23) as fhdDate ,isnull(c.fqty,0)fqty,isnull(d.cqty,0)cqty
|
||||
,isnull(cs.qty,0)qty,isnull(momq.momqty,0)momqty
|
||||
from SO_SODetails a WITH (nolock) left join SO_SOMain b WITH (nolock) on a.ID=b.id
|
||||
LEFT JOIN
|
||||
@@ -375,6 +394,7 @@ namespace NX.ERP.U8.Pmc
|
||||
left join Inventory g WITH (nolock) on g.cInvCode=a.cInvCode
|
||||
left join DispatchList h WITH (nolock) on b.cSOCode =h.cSOCode
|
||||
left join SaleType j WITH (nolock) on j.cSTCode=b.cSTCode
|
||||
|
||||
|
||||
";
|
||||
|
||||
@@ -444,14 +464,22 @@ namespace NX.ERP.U8.Pmc
|
||||
sql = $@" Usp_BO_ExpandByParent_BU_20210513 ";
|
||||
}
|
||||
//var sql = $@"Usp_BO_ExpandByParent_BU_20210208 ";
|
||||
foreach (var item in info1.inumsc)
|
||||
if (info1.inumsc != null)
|
||||
{
|
||||
foreach (var item in info1.inumsc)
|
||||
{
|
||||
|
||||
sql = sql +"'"+ item + "'" + ","; }
|
||||
sql = sql.Substring(0, sql.Length - 1);
|
||||
sql = sql + "'" + item + "'" + ",";
|
||||
}
|
||||
sql = sql.Substring(0, sql.Length - 1);
|
||||
}
|
||||
else {
|
||||
sql = "";
|
||||
}
|
||||
try { return conn.Query<object>(sql, new { inumsc = info1.inumsc }); }
|
||||
catch { return null; }
|
||||
|
||||
|
||||
return conn.Query<object>(sql, new { inumsc = info1.inumsc });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user