diff --git a/ZR.Admin.WebApi/Controllers/mes/md/MdBOMController.cs b/ZR.Admin.WebApi/Controllers/mes/md/MdBOMController.cs new file mode 100644 index 00000000..aecea8c0 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/md/MdBOMController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; +using ZR.Model.mes.md; +using ZR.Service.MES.md; +using ZR.Service.MES.md.IService; + +namespace ZR.Admin.WebApi.Controllers.MES.md +{ + [Route("mes/md/BOM")] + public class MdBOMController :BaseController + { + IMdBOMService mdBOMService; + public MdBOMController(IMdBOMService mdBOMService) + { + this.mdBOMService = mdBOMService; + } + + /// + /// 获取bom信息 + /// + /// 页数 + /// 页尺 + /// 产品code + /// 产品名称 + /// + [HttpGet("list")] + public IActionResult List(int pageNum, int pageSize, string productCode = "", string productName = "") + { + (int, List) data = mdBOMService.GetAll(productCode, productName, pageNum, pageSize); + + return ToResponse(new ApiResult(200, "success", data)); + } + } +} diff --git a/ZR.Admin.WebApi/Controllers/mes/md/MdWorklineController.cs b/ZR.Admin.WebApi/Controllers/mes/md/MdWorklineController.cs index bc017785..25614500 100644 --- a/ZR.Admin.WebApi/Controllers/mes/md/MdWorklineController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/md/MdWorklineController.cs @@ -21,7 +21,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.md /// - /// + /// 获取数据 /// /// /// diff --git a/ZR.Model/mes/md/MdBom.cs b/ZR.Model/mes/md/MdBom.cs index 148b4c02..13873c56 100644 --- a/ZR.Model/mes/md/MdBom.cs +++ b/ZR.Model/mes/md/MdBom.cs @@ -13,87 +13,84 @@ namespace ZR.Model.mes.md /// /// 流水号 /// - [SugarColumn(ColumnName="id" ,IsPrimaryKey = true ,IsIdentity = true )] - public int Id { get; set; } + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + /// - /// 父产品名称id + /// 父产品id /// - [SugarColumn(ColumnName="parent_id" )] - public int? ParentId { get; set; } + [SugarColumn(ColumnName = "parent_product_id")] + public int? ParentProductId { get; set; } + /// - /// 父产品名称code + /// 产品编号 /// - [SugarColumn(ColumnName="parent_code" )] - public string ParentCode { get; set; } + [SugarColumn(ColumnName = "product_code")] + public string ProductCode { get; set; } /// - /// 父产品名称name + /// 产品名称 /// - [SugarColumn(ColumnName="parent_name" )] - public string ParentName { get; set; } + [SugarColumn(ColumnName = "product_name")] + public string ProductName { get; set; } /// - /// 子项物料编号 + /// 零件类型 /// - [SugarColumn(ColumnName="material_code" )] - public string MaterialCode { get; set; } - /// - /// 子项物料名称 - /// - [SugarColumn(ColumnName="material_name" )] - public string MaterialName { get; set; } - /// - /// 类型(产品,物料) - /// - [SugarColumn(ColumnName="material_type" )] - public string MaterialType { get; set; } + [SugarColumn(ColumnName = "product_type")] + public string ProductType { get; set; } /// /// 安全库存 /// - [SugarColumn(ColumnName="safety_stock" )] - public int? SafetyStock { get; set; } + [SugarColumn(ColumnName = "safety_stock")] + public int? SafetyStock { get; set; } /// - /// 位置 + /// 位置/来源 /// - [SugarColumn(ColumnName="material_position" )] - public string MaterialPosition { get; set; } + [SugarColumn(ColumnName = "product_position")] + public string ProductPosition { get; set; } /// /// 需求数量 /// - [SugarColumn(ColumnName="requireNum" )] - public int? RequireNum { get; set; } + [SugarColumn(ColumnName = "requireNum")] + public int? RequireNum { get; set; } /// /// 子项单位id /// - [SugarColumn(ColumnName="unit_id" )] - public int? UnitId { get; set; } + [SugarColumn(ColumnName = "unit_id")] + public int? UnitId { get; set; } /// /// 租户号 /// - [SugarColumn(ColumnName="TENANT_ID" )] - public string TenantId { get; set; } + [SugarColumn(ColumnName = "TENANT_ID")] + public string TenantId { get; set; } /// /// 乐观锁 /// - [SugarColumn(ColumnName="REVISION" )] - public int? Revision { get; set; } + [SugarColumn(ColumnName = "REVISION")] + public int? Revision { get; set; } /// /// 创建人 /// - [SugarColumn(ColumnName="CREATED_BY" )] - public string CreatedBy { get; set; } + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } /// /// 创建时间 /// - [SugarColumn(ColumnName="CREATED_TIME" )] - public DateTime? CreatedTime { get; set; } + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime? CreatedTime { get; set; } /// /// 更新人 /// - [SugarColumn(ColumnName="UPDATED_BY" )] - public string UpdatedBy { get; set; } + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } /// /// 更新时间 /// - [SugarColumn(ColumnName="UPDATED_TIME" )] - public DateTime? UpdatedTime { get; set; } + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + + + [SqlSugar.SugarColumn(IsIgnore = true)] + public List Child { get; set; } + } } diff --git a/ZR.Service/mes/md/IService/IMdBOMService.cs b/ZR.Service/mes/md/IService/IMdBOMService.cs new file mode 100644 index 00000000..38c5229b --- /dev/null +++ b/ZR.Service/mes/md/IService/IMdBOMService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.mes.md; + +namespace ZR.Service.MES.md.IService +{ + public interface IMdBOMService + { + int AddWorkline(MdBom workline); + + public (int, List) GetAll(string productCode, string productName, int pageNum, int pageSize); + public int UpdateWorkline(MdBom workline); + + public int deleteWorkline(int[] ids); + + + } +} diff --git a/ZR.Service/mes/md/MdBOMService.cs b/ZR.Service/mes/md/MdBOMService.cs new file mode 100644 index 00000000..80e9bb9f --- /dev/null +++ b/ZR.Service/mes/md/MdBOMService.cs @@ -0,0 +1,93 @@ +using Infrastructure.Attribute; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.mes.md; +using ZR.Service.mes.md.IService; +using ZR.Service.MES.md.IService; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace ZR.Service.MES.md +{ + + [AppService(ServiceType = typeof(IMdBOMService), ServiceLifetime = LifeTime.Transient)] + public class MdBOMService : BaseService, IMdBOMService + { + int IMdBOMService.AddWorkline(MdBom workline) + { + throw new NotImplementedException(); + } + + int IMdBOMService.deleteWorkline(int[] ids) + { + throw new NotImplementedException(); + } + + (int, List) IMdBOMService.GetAll(string productCode, string productName, int pageNum, int pageSize) + { + int totalNum = 0; + + if (string.IsNullOrEmpty(productCode) && string.IsNullOrEmpty(productName)) + { + var data = Context.Queryable().ToPageList(pageNum, pageSize,ref totalNum); + return (totalNum, data); + } + else + { + //1. 查询本体 + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(productCode), it => it.ProductCode.Contains(productCode)) + .AndIF(!string.IsNullOrEmpty(productName), it => it.ProductName.Contains(productName)) + .ToExpression(); + List data = Context.Queryable().Where(predicate).ToList(); + + //2. 查询儿子 + if (data != null & data.Count > 0) + { + List data1 = new List(); + List data2 = new List(); + foreach (var item in data) + { + List dataItems = Context.Queryable().Where(it => it.ParentProductId == item.Id).ToList(); + data1.AddRange(dataItems); + dataItems.Clear(); + + // 3. 查询孙子 + if (data1 != null & data1.Count > 0) + { + foreach (var item1 in data1) + { + List dataItemss = Context.Queryable().Where(it1 => it1.ParentProductId == item1.Id).ToList(); + data2.AddRange(dataItemss); + dataItemss.Clear(); + } + } + } + + data.AddRange(data1); + data.AddRange(data2); + + } + return (data.Count(),data); + } + + + + + + + } + + + + int IMdBOMService.UpdateWorkline(MdBom workline) + { + throw new NotImplementedException(); + } + } +} diff --git a/ZR.Vue/src/api/basisManagement/bom.js b/ZR.Vue/src/api/basisManagement/bom.js new file mode 100644 index 00000000..2c6331fc --- /dev/null +++ b/ZR.Vue/src/api/basisManagement/bom.js @@ -0,0 +1,48 @@ +import request from '@/utils/request' +import { downFile } from '@/utils/request' + +export function getBomList(query) { + return request({ + url: '/mes/md/bom/list', + method: 'get', + params: query, + }) +} + +export function insertBom(data) { + return request({ + url: '/mes/md/Bom/addBom', + method: 'post', + data: data, + contextType:"application/json" + }) +} + + +export function updateBom(data) { + return request({ + url: '/mes/md/Bom/updateBom', + method: 'post', + data: data, + contextType:"application/json" + }) +} + + +export function delBom(data) { + return request({ + url: '/mes/md/Bom/delBom', + method: 'post', + data: data, + contextType:"application/json" + }) +} + +export function getWorkshopList(query) { + return request({ + url: '/mes/md/Bom/getWorkshopList', + method: 'get', + params: query, + }) + } + \ No newline at end of file diff --git a/ZR.Vue/src/views/basisManagement/BOM.vue b/ZR.Vue/src/views/basisManagement/BOM.vue index e69de29b..64fcd7c2 100644 --- a/ZR.Vue/src/views/basisManagement/BOM.vue +++ b/ZR.Vue/src/views/basisManagement/BOM.vue @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 修改 + 删除 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +