diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index 7002212..7869ccc 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -67,6 +67,7 @@ + diff --git a/NX.ERP.Model/Response/MOM/Bom.cs b/NX.ERP.Model/Response/MOM/Bom.cs new file mode 100644 index 0000000..3f6cb6d --- /dev/null +++ b/NX.ERP.Model/Response/MOM/Bom.cs @@ -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 OptionComponents { get => optionComponents; set => optionComponents = value; } + + private ICollection optionComponents = new List(); + + + + + + + } +} diff --git a/NX.ERP.U8/Mom/BomDAL.cs b/NX.ERP.U8/Mom/BomDAL.cs new file mode 100644 index 0000000..5e88196 --- /dev/null +++ b/NX.ERP.U8/Mom/BomDAL.cs @@ -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 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(); + conn.Query(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; + + + + } + + + + } + + + } +} diff --git a/NX.ERP.U8/NX.ERP.U8.csproj b/NX.ERP.U8/NX.ERP.U8.csproj index c8541e6..e41f733 100644 --- a/NX.ERP.U8/NX.ERP.U8.csproj +++ b/NX.ERP.U8/NX.ERP.U8.csproj @@ -43,6 +43,7 @@ + diff --git a/NX.ERP.WebAPi/Controllers/MOM/BomController.cs b/NX.ERP.WebAPi/Controllers/MOM/BomController.cs new file mode 100644 index 0000000..b29f54a --- /dev/null +++ b/NX.ERP.WebAPi/Controllers/MOM/BomController.cs @@ -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 GetList() + { + return new NX.ERP.U8.Mom.BomDAL().GetList(); + } + } +} \ No newline at end of file diff --git a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj index 120e0bf..0cc9ea0 100644 --- a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj +++ b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj @@ -156,6 +156,7 @@ +