添加BOM查询接口
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
<Compile Include="Request\Inventoryall.cs" />
|
||||
<Compile Include="Request\SnOrderRequest.cs" />
|
||||
<Compile Include="Request\SaleOrderRequest.cs" />
|
||||
<Compile Include="Response\MOM\Bom.cs" />
|
||||
<Compile Include="Response\Pmc\PmcInventoryallRes.cs" />
|
||||
<Compile Include="Response\Store\Stock.cs" />
|
||||
<Compile Include="TimestampConverter.cs" />
|
||||
|
||||
72
NX.ERP.Model/Response/MOM/Bom.cs
Normal file
72
NX.ERP.Model/Response/MOM/Bom.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NX.ERP.Model.Response.MOM
|
||||
{
|
||||
|
||||
// "Version": 10,
|
||||
// "VersionDesc": "数控四边锯2020"
|
||||
// "BomType": 1,
|
||||
// "ParentCode": "905001",
|
||||
// "bom_opcomponent": [
|
||||
// {
|
||||
// "SortSeq": "10",
|
||||
// "ComponentCode": "503001",
|
||||
// "BaseQtyN": "1",
|
||||
// "BaseQtyD": "1",
|
||||
// "WIPType": "4",
|
||||
// "EffBegDate": 2010-01-01 00:00:00.000,
|
||||
// "EffEndDate": 2099-12-31 00:00:00.000,
|
||||
|
||||
|
||||
// },
|
||||
// {
|
||||
//"SortSeq": "20",
|
||||
// "ComponentCode": "503002",
|
||||
// "BaseQtyN": "1",
|
||||
// "BaseQtyD": "1",
|
||||
// "WIPType": "4",
|
||||
// "EffBegDate": 2010 - 01 - 01 00:00:00.000,
|
||||
// "EffEndDate": 2099 - 12 - 31 00:00:00.000,
|
||||
|
||||
// }
|
||||
// ]
|
||||
|
||||
public class OptionComponent
|
||||
{
|
||||
public int BomId { get; set; }
|
||||
public string SortSeq { get; set; }
|
||||
public string ComponentCode { get; set; }
|
||||
public decimal BaseQtyN { get; set; }
|
||||
public decimal BaseQtyD { get; set; }
|
||||
public int WipType { get; set; }
|
||||
public DateTime EffBegDate { get; set; }
|
||||
public DateTime EffEndDate { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class Bom
|
||||
{
|
||||
|
||||
public int BomId { get; set; }
|
||||
public int Version { get; set; }
|
||||
public string VersionDesc { get; set; }
|
||||
|
||||
public int BomType { get; set; }
|
||||
|
||||
public string ParentCode { get; set; }
|
||||
public ICollection<OptionComponent> OptionComponents { get => optionComponents; set => optionComponents = value; }
|
||||
|
||||
private ICollection<OptionComponent> optionComponents = new List<OptionComponent>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
66
NX.ERP.U8/Mom/BomDAL.cs
Normal file
66
NX.ERP.U8/Mom/BomDAL.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dapper;
|
||||
namespace NX.ERP.U8.Mom
|
||||
{
|
||||
public class BomDAL
|
||||
{
|
||||
|
||||
public IEnumerable<NX.ERP.Model.Response.MOM.Bom> GetList(string strWhere="", object Params = null)
|
||||
{
|
||||
|
||||
|
||||
var strSQL = @"select a.BomId,a.Version, a.VersionDesc,a.BomType,c.InvCode as ParentCode ,' ' as id ,d.BomId, d.SortSeq,
|
||||
e.InvCode as ComponentCode ,d.BaseQtyN, d.BaseQtyD ,f.WIPType,d.EffBegDate,d.EffEndDate from bom_bom as a
|
||||
left join bom_parent as b on a.BomId=b.BomId
|
||||
left join bas_part as c on b.ParentId=c.PartId
|
||||
left join Inventory as x on c.InvCode=x.cInvCode
|
||||
left join bom_opcomponent as d on a.BomId=d.BomId
|
||||
left join bom_opcomponentopt as f on d.OpComponentId=f.OptionsId
|
||||
left join bas_part as e on d.ComponentId=e.PartId
|
||||
left join Inventory as y on e.InvCode=y.cInvCode";
|
||||
if (!string.IsNullOrEmpty(strWhere))
|
||||
{
|
||||
strSQL += $" where {strWhere} ";
|
||||
}
|
||||
|
||||
|
||||
using (var conn = U8LoginContext.Instance.Connection)
|
||||
{
|
||||
var lookup = new Dictionary<int, Model.Response.MOM.Bom>();
|
||||
conn.Query<Model.Response.MOM.Bom, Model.Response.MOM.OptionComponent, Model.Response.MOM.Bom>(strSQL, (bom, comp) =>
|
||||
{
|
||||
if (!lookup.TryGetValue(bom.BomId, out var _bom))
|
||||
{
|
||||
lookup.Add(bom.BomId, bom);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bom = _bom;
|
||||
}
|
||||
|
||||
bom.OptionComponents.Add(comp);
|
||||
|
||||
|
||||
|
||||
|
||||
return bom;
|
||||
|
||||
}, Params, null, true, "id", 10, System.Data.CommandType.Text); ;
|
||||
|
||||
return lookup.Values;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@
|
||||
<Compile Include="Base\MaterielTypeDAL.cs" />
|
||||
<Compile Include="FileHelp.cs" />
|
||||
<Compile Include="FormatHelp.cs" />
|
||||
<Compile Include="Mom\BomDAL.cs" />
|
||||
<Compile Include="Mom\MomOrderDAL.cs" />
|
||||
<Compile Include="Pmc\FinanceQuery.cs" />
|
||||
<Compile Include="Pmc\PmcQuery.cs" />
|
||||
|
||||
19
NX.ERP.WebAPi/Controllers/MOM/BomController.cs
Normal file
19
NX.ERP.WebAPi/Controllers/MOM/BomController.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace NX.ERP.WebAPi.Controllers.MOM
|
||||
{
|
||||
public class BomController : ApiController
|
||||
{
|
||||
[Route("api/Bom/List")]
|
||||
[HttpGet]
|
||||
|
||||
public IEnumerable<Model.Response.MOM.Bom> GetList()
|
||||
{
|
||||
return new NX.ERP.U8.Mom.BomDAL().GetList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,7 @@
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="App_Start\SwaggerConfig.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Controllers\MOM\BomController.cs" />
|
||||
<Compile Include="Controllers\MOM\MomOrderController.cs" />
|
||||
<Compile Include="Controllers\Pmc\FinanceController.cs" />
|
||||
<Compile Include="Controllers\Pmc\PmcController.cs" />
|
||||
|
||||
Reference in New Issue
Block a user