修改库存查询

This commit is contained in:
gongxh
2021-05-20 09:47:35 +08:00
parent d5d705ac8d
commit 38bc652cae
4 changed files with 58 additions and 33 deletions

View File

@@ -8,24 +8,42 @@ namespace NX.ERP.U8.Store
{
public class StockDAL
{
/// <summary>
///
/// </summary>
/// <param name="strwhere"></param>
/// <param name="Params"></param>
/// <returns></returns>
public IEnumerable<Model.Response.Store.Stock> GetList(string strwhere = "", object Params = null)
{
using (var conn = U8LoginContext.Instance.Connection)
{
var sql = @"select a.cInvCode as MaterialCode ,c.cPosName as BinName,(isnull(a.iQuantity,0)-isnull(b.iQuantity,0)) as Qty from (
select cInvCode,cPosCode , sum(iQuantity)as iQuantity from InvPosition where bRdFlag=1 group by cInvCode,cPosCode
)a full join (
select cInvCode,cPosCode , sum(iQuantity)as iQuantity from InvPosition where bRdFlag=0 group by cInvCode,cPosCode)
b on isnull(a.cInvCode,'')=isnull(b.cInvCode,'') and a.cPosCode=b.cPosCode
left join Position c on a.cPosCode=c.cPosCode
where a.cPosCode like '021%'";
select cInvCode,cPosCode , sum(iQuantity)as iQuantity from InvPosition where bRdFlag=1 group by cInvCode,cPosCode
)a full join (
select cInvCode,cPosCode , sum(iQuantity)as iQuantity from InvPosition where bRdFlag=0 group by cInvCode,cPosCode)
b on isnull(a.cInvCode,'')=isnull(b.cInvCode,'') and a.cPosCode=b.cPosCode
left join Position c on a.cPosCode=c.cPosCode where a.iQuantity<>b.iQuantity";
if (!string.IsNullOrEmpty(strwhere))
{
sql += $" where {strwhere}";
sql += $" and {strwhere}";
}
return conn.Query<Model.Response.Store.Stock>(sql, Params);
}
}
/// <summary>
///
/// </summary>
/// <param name="Code"></param>
/// <returns></returns>
public IEnumerable<Model.Response.Store.Stock> GetListByMaterialCode(string Code)
{
return this.GetList(" a.cInvCode like @Code", new { Code = $"%{Code}%" });
}
}
}