添加BOM查询接口

This commit is contained in:
gongxh
2021-05-15 14:01:12 +08:00
parent 242b0a28b4
commit 2b6ec892d8
6 changed files with 160 additions and 0 deletions

66
NX.ERP.U8/Mom/BomDAL.cs Normal file
View 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;
}
}
}
}

View File

@@ -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" />