增加 子件领料报表

This commit is contained in:
杰 朱
2021-09-01 15:31:16 +08:00
parent 83eda2dd4b
commit 4e9d70775d
8 changed files with 672 additions and 2 deletions

View File

@@ -312,5 +312,117 @@ namespace NX.ERP.U8.Mom
return this.GetList("b.moid >= @id", new { Id });
}
public IEnumerable<NX.ERP.Model.PmcInventorymomRes> Pick(NX.ERP.Model.Request.MomOrderRequest info)
{
string sql = $@"
select *from (
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
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 '自制'
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, ma.Qty qty1, ma.IssQty issqty,(ma.Qty-ma.IssQty) as wll, motype.description,
CASE WHEN md.Status = 2 THEN '锁定' WHEN md.Status = 4 THEN '关闭' WHEN md.Status = 3 THEN '审核' ELSE '新建' END AS st, md.Status,ISNULL(ds.qty, 0) dqty,post.cPosName
FROM mom_order m WITH (NOLOCK) INNER JOIN
mom_orderdetail md WITH (NOLOCK) ON m.MoId = md.MoId INNER JOIN
mom_morder mor WITH (NOLOCK) ON md.MoDId = mor.MoDId INNER JOIN
mom_moallocate ma WITH (NOLOCK) ON md.MoDId = ma.MoDId
left JOIN
mom_motype motype WITH (NOLOCK) ON motype.MoTypeId = md.MoTypeId
LEFT JOIN
(SELECT cinvcode, SUM(iquantity) qty
FROM InvPositionSum WITH (NOLOCK) where cPosCode not in ('00701','00801','09001') and cWhCode not in (4,5)
GROUP BY cInvCode) ds ON ma.InvCode = ds.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 WITH (NOLOCK) where b.cPosCode not in ('00701','00801','09001') and b.cWhCode not in (4,5)
GROUP BY
cinvcode
) AS post ON ma.InvCode = post.cinvcode
INNER JOIN
Inventory p WITH (NOLOCK) ON md.InvCode = p.cInvCode INNER JOIN
Inventory c WITH (NOLOCK) ON ma.InvCode = c.cInvCode LEFT JOIN
ComputationUnit kk WITH (nolock) on p.cComUnitCode=kk.cComunitCode
left join ComputationUnit LL WITH (nolock) on c.cComUnitCode=LL.cComunitCode
) mmm
";
List<string> where = new List<string>();
///处理-
if (info.moCodes != null && info.moCodes.Count > 0)
{
where.Add(" mmm.mocode in @moCodes");
}
if (info.InvCodes != null)
{
where.Add(" mmm.InvCode in @invcode");
}
if (info.InvCodes1 != null)
{
where.Add(" mmm.invcode1 in @invcode1");
}
if (info.byFinish != null)
{
where.Add(" mmm.Status in @byFinish");
}
if (!info.byiss)
{
where.Add(" isnull(mmm.qty1,0)- isnull(mmm.issqty,0)> 0");
}
else { where.Add(" mmm.issqty > 0"); }
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<NX.ERP.Model.PmcInventorymomRes>(sql, new { moCodes = info.moCodes, invcode = info.InvCodes, invcode1 = info.InvCodes1, info.byFinish });
}
}
}
}