This commit is contained in:
gongxh
2021-06-07 10:37:41 +08:00
parent f127eaea20
commit e924f18926
7 changed files with 121 additions and 29 deletions

View File

@@ -86,6 +86,7 @@
<Compile Include="Response\Pmc\PmcInventoryallRes.cs" /> <Compile Include="Response\Pmc\PmcInventoryallRes.cs" />
<Compile Include="Response\Pmc\PmcInventorymomRes.cs" /> <Compile Include="Response\Pmc\PmcInventorymomRes.cs" />
<Compile Include="Response\Store\MaterialApp.cs" /> <Compile Include="Response\Store\MaterialApp.cs" />
<Compile Include="Response\Store\BinStock.cs" />
<Compile Include="Response\Store\Stock.cs" /> <Compile Include="Response\Store\Stock.cs" />
<Compile Include="TimestampConverter.cs" /> <Compile Include="TimestampConverter.cs" />
<Compile Include="Request\Arrival.cs" /> <Compile Include="Request\Arrival.cs" />

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Response.Store
{
/// <summary>
/// 货位库存
/// </summary>
public class BinStock
{
//a.cInvCode,a.cPosCode,c.cPosName,(isnull(a.iQuantity,0)-isnull(b.iQuantity,0)) as iQuantity
private string materialCode;
private string binName;
private string _Qty;
private string materialName;
/// <summary>
///
/// </summary>
public string MaterialCode { get => materialCode; set => materialCode = value; }
public string BinCode { get => binName; set => binName = value; }
public string Qty { get => _Qty; set => _Qty = value; }
public string MaterialName { get => materialName; set => materialName = value; }
}
}

View File

@@ -5,22 +5,23 @@ using System.Text;
namespace NX.ERP.Model.Response.Store namespace NX.ERP.Model.Response.Store
{ {
/// <summary>
///
/// </summary>
public class Stock public class Stock
{ {
//a.cInvCode,a.cPosCode,c.cPosName,(isnull(a.iQuantity,0)-isnull(b.iQuantity,0)) as iQuantity
private string materialCode; private string materialCode;
private string binName; private decimal stockQty;
private string _Qty; private decimal arrivalQty;
private decimal poQty;
private string materialName;
public string MaterialCode { get => materialCode; set => materialCode = value; } public string MaterialCode { get => materialCode; set => materialCode = value; }
public string BinCode { get => binName; set => binName = value; }
public string Qty { get => _Qty; set => _Qty = value; }
public string MaterialName { get => materialName; set => materialName = value; } public string MaterialName { get; set; }
public decimal StockQty { get => stockQty; set => stockQty = value; }
public decimal ArrivalQty { get => arrivalQty; set => arrivalQty = value; }
public decimal PoQty { get => poQty; set => poQty = value; }
} }
} }

View File

@@ -257,8 +257,6 @@ namespace NX.ERP.U8.AP
try try
{ {
AddRdVoucher(voucherParameter); AddRdVoucher(voucherParameter);
///处理单号不增加的异常
var number = new NX.ERP.U8.VoucherHistory(); var number = new NX.ERP.U8.VoucherHistory();
number.IncNumber("P0", "单据日期", ApVouch.Date.ToString("yyyyMM")); number.IncNumber("P0", "单据日期", ApVouch.Date.ToString("yyyyMM"));
var strsql = "select Auto_ID from AP_ApVouch where cDefine10=@id"; var strsql = "select Auto_ID from AP_ApVouch where cDefine10=@id";
@@ -266,10 +264,7 @@ namespace NX.ERP.U8.AP
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection) using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
{ {
code = conn.ExecuteScalar<string>(strsql, new { id }, null, 30, System.Data.CommandType.Text); code = conn.ExecuteScalar<string>(strsql, new { id }, null, 30, System.Data.CommandType.Text);
} }
return code; return code;
} }
catch (Exception err) catch (Exception err)

View File

@@ -14,17 +14,17 @@ namespace NX.ERP.U8.Store
/// <param name="strwhere"></param> /// <param name="strwhere"></param>
/// <param name="Params"></param> /// <param name="Params"></param>
/// <returns></returns> /// <returns></returns>
public IEnumerable<Model.Response.Store.Stock> GetList(string strwhere = "", object Params = null) public IEnumerable<Model.Response.Store.BinStock> GetList(string strwhere = "", object Params = null)
{ {
using (var conn = U8LoginContext.Instance.Connection) using (var conn = U8LoginContext.Instance.Connection)
{ {
var sql = @" select a.cInvCode as MaterialCode ,cPosCode as BinCode,iQuantity as Qty,b.cInvName as MaterialName from InvPositionSum as a var sql = @" select a.cInvCode as MaterialCode ,cPosCode as BinCode,iQuantity as Qty,b.cInvName as MaterialName
left join Inventory as b on a.cInvCode=b.cInvCode where ISNULL(iQuantity,0)<>0"; from InvPositionSum as a left join Inventory as b on a.cInvCode=b.cInvCode where ISNULL(iQuantity,0)<>0";
if (!string.IsNullOrEmpty(strwhere)) if (!string.IsNullOrEmpty(strwhere))
{ {
sql += $" and {strwhere}"; sql += $" and {strwhere}";
} }
return conn.Query<Model.Response.Store.Stock>(sql, Params); return conn.Query<Model.Response.Store.BinStock>(sql, Params);
} }
} }
/// <summary> /// <summary>
@@ -32,14 +32,14 @@ left join Inventory as b on a.cInvCode=b.cInvCode where ISNULL(iQuantity,0)<>0";
/// </summary> /// </summary>
/// <param name="Code"></param> /// <param name="Code"></param>
/// <returns></returns> /// <returns></returns>
public IEnumerable<Model.Response.Store.Stock> GetListByMaterialCode(string Code) public IEnumerable<Model.Response.Store.BinStock> GetListByMaterialCode(string Code)
{ {
return this.GetList(" cInvCode like @Code", new { Code = $"%{Code}%" }); return this.GetList(" cInvCode like @Code", new { Code = $"%{Code}%" });
} }
public IEnumerable<Model.Response.Store.Stock> GetList(NX.ERP.Model.Request.Stock stock) public IEnumerable<Model.Response.Store.BinStock> GetList(NX.ERP.Model.Request.Stock stock)
{ {
List<string> where = new List<string>(); List<string> where = new List<string>();
if (!string.IsNullOrEmpty(stock.MaterialCode)) if (!string.IsNullOrEmpty(stock.MaterialCode))
@@ -68,6 +68,61 @@ left join Inventory as b on a.cInvCode=b.cInvCode where ISNULL(iQuantity,0)<>0";
/// <summary>
///
/// </summary>
/// <param name="strwhere"></param>
/// <param name="Params"></param>
/// <returns></returns>
public IEnumerable<Model.Response.Store.Stock> GetStock(string strwhere = "", object Params = null)
{
using (var conn = U8LoginContext.Instance.Connection)
{
var sql = @" select * from (select stock.cInvCode MaterialCode,stock.Qty as StockQty ,arrival.arrivalQty,d.cInvName as MaterialName,d.cInvStd as MaterialSpecsModel from (select cInvCode,SUM( iQuantity) as Qty from CurrentStock
group by cInvCode ) as stock
left join
(select cInvCode,SUM(iQuantity)-SUM(fRealQuantity) as arrivalQty from PU_ArrivalVouchs a,PU_ArrivalVouch b
where a.ID=b.ID and isnull(b.cverifier,'')<>'' and bNegative=0
group by cInvCode) as arrival on stock.cInvCode=arrival.cInvCode
left join Inventory as d on stock.cInvCode=d.cInvCode
) as tbl where (StockQty<>0 or arrivalQty<>0)
";
if (!string.IsNullOrEmpty(strwhere))
{
sql += $" and {strwhere}";
}
return conn.Query<Model.Response.Store.Stock>(sql, Params);
}
}
public IEnumerable<Model.Response.Store.Stock> GetStock(NX.ERP.Model.Request.Stock stock)
{
List<string> where = new List<string>();
if (!string.IsNullOrEmpty(stock.MaterialCode))
{
where.Add(" cInvCode = @MaterialCode ");
}
if (!string.IsNullOrEmpty(stock.MaterialName))
{
where.Add(" cInvName like @MaterialName ");
}
return this.GetStock(string.Join(" and ", where.ToArray()), new
{
MaterialCode = stock.MaterialCode,
MaterialName = $"%{stock.MaterialName}%",
}); ;
}
} }
} }

View File

@@ -19,7 +19,7 @@ namespace NX.ERP.WebAPi.Controllers.Store
[Obsolete] [Obsolete]
[HttpGet] [HttpGet]
[Route("api/Stock/GetStock")] [Route("api/Stock/GetStock")]
public IEnumerable<Model.Response.Store.Stock> GetList([FromUri]string Code) public IEnumerable<Model.Response.Store.BinStock> GetList([FromUri]string Code)
{ {
return new U8.Store.StockDAL().GetListByMaterialCode(Code); return new U8.Store.StockDAL().GetListByMaterialCode(Code);
} }
@@ -34,6 +34,15 @@ namespace NX.ERP.WebAPi.Controllers.Store
[HttpPost] [HttpPost]
[Route("api/Stock/Query")] [Route("api/Stock/Query")]
public IEnumerable<Model.Response.Store.Stock> GetList([FromBody] NX.ERP.Model.Request.Stock stock ) public IEnumerable<Model.Response.Store.Stock> GetList([FromBody] NX.ERP.Model.Request.Stock stock )
{
return new U8.Store.StockDAL().GetStock(stock);
}
[HttpPost]
[Route("api/Stock/QueryBinStock")]
public IEnumerable<Model.Response.Store.BinStock> GetBinList([FromBody] NX.ERP.Model.Request.Stock stock)
{ {
return new U8.Store.StockDAL().GetList(stock); return new U8.Store.StockDAL().GetList(stock);
} }

View File

@@ -5,8 +5,8 @@
--> -->
<configuration> <configuration>
<appSettings> <appSettings>
<add key="server" value="192.168.1.167" /> <add key="server" value="10.0.0.12" />
<add key="AccId" value="002" /> <add key="AccId" value="u8-2@002" />
<add key="UserId" value="wx995" /> <add key="UserId" value="wx995" />
<add key="Password" value="1" /> <add key="Password" value="1" />
<add key="EaiPort" value="80" /> <add key="EaiPort" value="80" />