From fef1a3906e5f487e5ec2bef547c228e8057c0b9c Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Wed, 4 Sep 2024 13:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2BOM=20=E5=8F=8A=E5=85=B6?= =?UTF-8?q?=E6=89=80=E9=9C=80=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MES/product/ProWorkorderController.cs | 17 +++++- DOAN.Model/MES/product/Dto/ProWorkorderDto.cs | 45 +++++++++++++-- .../product/IService/IProWorkorderService.cs | 2 + .../MES/product/ProWorkorderService.cs | 55 ++++++++++++++++--- 4 files changed, 105 insertions(+), 14 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs index 5c4ccd0..c51c254 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs @@ -272,6 +272,21 @@ namespace DOAN.Admin.WebApi.Controllers return SUCCESS(response); } + + //TODO 查询BOM 及其所需数量 + /// + /// 查询BOM 及其所需数量 + /// + /// 工单号 + /// + [HttpGet("search_BOM_num")] + public IActionResult SearchBOMNum(string workorder_num) { + if (string.IsNullOrEmpty(workorder_num)) { return SUCCESS(null); } + + var response = _ProWorkorderService.SearchBOMNum(workorder_num); + return SUCCESS(response); + + + } } } - \ No newline at end of file diff --git a/DOAN.Model/MES/product/Dto/ProWorkorderDto.cs b/DOAN.Model/MES/product/Dto/ProWorkorderDto.cs index 3e95dec..11fd843 100644 --- a/DOAN.Model/MES/product/Dto/ProWorkorderDto.cs +++ b/DOAN.Model/MES/product/Dto/ProWorkorderDto.cs @@ -26,7 +26,7 @@ namespace DOAN.Model.MES.product.Dto public class ProWorkorderQueryDto2 { - public DateTime WorkorderDate { get; set; } + public DateTime WorkorderDate { get; set; } } @@ -104,7 +104,7 @@ namespace DOAN.Model.MES.product.Dto /// /// 完成数量 /// - public int? FinishNum { get; set; } + public int? FinishNum { get; set; } public string Unit { get; set; } @@ -147,7 +147,7 @@ namespace DOAN.Model.MES.product.Dto /// /// 下一个工单号 /// - + public string next_id { get; set; } public string Id { get; set; } @@ -205,9 +205,9 @@ namespace DOAN.Model.MES.product.Dto /// /// 缺少物料 (物料清单不存在)存在为值 不存在为null /// - public string MaterialName { get; set; } - - public string Specification { get; set; } + public string MaterialName { get; set; } + + public string Specification { get; set; } /// /// 缺少工艺路线 (工艺路线)存在为值 不存在为0 /// @@ -260,6 +260,39 @@ namespace DOAN.Model.MES.product.Dto } + /// + /// 工单BOM 及其所需数量 + /// + + public class WorkOrderBom + { + + /// + /// 子件编码 + /// + + public string SubInvCode { get; set; } + + /// + /// 子件名称 + /// + + public string SubInvName { get; set; } + + /// + /// 使用数量 + /// + + public string Iusequantity { get; set; } + + /// + /// BOM版本号 + /// + + public string BOMVersion { get; set; } + + } + } \ No newline at end of file diff --git a/DOAN.Service/MES/product/IService/IProWorkorderService.cs b/DOAN.Service/MES/product/IService/IProWorkorderService.cs index 7e12b3d..b883022 100644 --- a/DOAN.Service/MES/product/IService/IProWorkorderService.cs +++ b/DOAN.Service/MES/product/IService/IProWorkorderService.cs @@ -48,5 +48,7 @@ namespace DOAN.Service.MES.product.IService List GetGroupList(string route_code); + List SearchBOMNum(string workorder_num); + } } diff --git a/DOAN.Service/MES/product/ProWorkorderService.cs b/DOAN.Service/MES/product/ProWorkorderService.cs index 069d7d8..ef88df9 100644 --- a/DOAN.Service/MES/product/ProWorkorderService.cs +++ b/DOAN.Service/MES/product/ProWorkorderService.cs @@ -29,6 +29,7 @@ using NPOI.Util; using DOAN.Model.MES.base_.Dto; using Aliyun.OSS; using DOAN.Model.MES.group; +using Mapster; namespace DOAN.Service.MES.product { @@ -73,7 +74,7 @@ namespace DOAN.Service.MES.product MaterialName = m.Name, Specification = m.Specification, - Unit = m.Unit, + Unit = q.Unit, }, true); var query2 = Context.Queryable(query1).LeftJoin((q, r) => q.RouteId == r.Code) .Select((q, r) => new ProWorkorderDto3() @@ -587,7 +588,7 @@ namespace DOAN.Service.MES.product // !string.IsNullOrEmpty(parm.CustomNo), // it => it.CustomName.Contains(parm.CustomNo) //) - .And(it => it.Status ==1); + .And(it => it.Status == 1); var response = Context.Queryable() .Where(predicate.ToExpression()) @@ -595,7 +596,7 @@ namespace DOAN.Service.MES.product .Take(20) .ToList(); return response; - + } @@ -607,11 +608,17 @@ namespace DOAN.Service.MES.product /// public List GetProcessRoute(DateTime dateTime) { - DateTime dataTO= dateTime.ToLocalTime().Date; - var query= Context.Queryable().Where(it => it.ScheduleDate == dataTO); + DateTime dataTO = dateTime.ToLocalTime().Date; + var query = Context.Queryable().Where(it => it.ScheduleDate == dataTO); - return Context.Queryable(query).LeftJoin((q, p) => q.FkBelongRouteCode == p.Code).Select((q, p) => p).Distinct().ToList(); + return Context + .Queryable(query) + .LeftJoin((q, p) => q.FkBelongRouteCode == p.Code) + .Select((q, p) => p) + .Distinct() + .ToList(); } + /// /// 获取班组 /// @@ -620,8 +627,42 @@ namespace DOAN.Service.MES.product public List GetGroupList(string route_code) { - return Context.Queryable().Where(it => it.FkBelongRouteCode == route_code).ToList(); + return Context.Queryable().Where(it => it.FkBelongRouteCode == route_code).ToList(); } + + + /// + /// 查询BOM 及其所需数量 + /// + /// + /// + public List SearchBOMNum(string workorder_num) + { + List baseMaterialBoms = null; + ProWorkorder proworkorder = Context.Queryable().Where(it => it.Workorder == workorder_num).First(); + if (proworkorder != null) + { + baseMaterialBoms = Context.Queryable().Where(it => it.InvCode == proworkorder.ProductionCode).ToList(); + + if (baseMaterialBoms != null && baseMaterialBoms + .Count() > 0) + { + foreach (var item in baseMaterialBoms) + { + float num = float.Parse(item.Iusequantity) * proworkorder.DeliveryNum.Value; + item.Iusequantity = num.ToString(); + } + + } + + + } + return baseMaterialBoms.Adapt>(); + + + } } + + } \ No newline at end of file