diff --git a/Infrastructure/CustomException/ResultCode.cs b/Infrastructure/CustomException/ResultCode.cs index 58739e4c..95ad884b 100644 --- a/Infrastructure/CustomException/ResultCode.cs +++ b/Infrastructure/CustomException/ResultCode.cs @@ -7,7 +7,7 @@ namespace Infrastructure [Description("success")] SUCCESS = 200, - [Description("没有更多数据")] + [Description("传入参数为空")] NO_DATA = 210, [Description("参数错误")] diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs index 7164cd19..ec6ea1d0 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs @@ -53,8 +53,8 @@ namespace ZR.Admin.WebApi.Controllers { var response = _WmMaterialService.GetInfo(Id); - var info = response.Adapt(); - return SUCCESS(info); + + return SUCCESS(response); } /// @@ -101,7 +101,7 @@ namespace ZR.Admin.WebApi.Controllers if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } - var response = _WmMaterialService.Delete(idsArr); + var response = _WmMaterialService.Delete(idsArr); return ToResponse(response); } diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs new file mode 100644 index 00000000..bbb11512 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs @@ -0,0 +1,141 @@ +using Microsoft.AspNetCore.Mvc; +using ZR.Model.Dto; +using ZR.Admin.WebApi.Extensions; +using ZR.Admin.WebApi.Filters; +using ZR.Service.mes.wms.IService; +using ZR.Model.MES.wms.Dto; +using ZR.Model.MES.wms; +using ZR.Service.mes.wms; + +//创建时间:2024-03-18 +namespace ZR.Admin.WebApi.Controllers +{ + /// + /// 出货单(物料+客户) + /// + [Verify] + [Route("mes/wm/WmOutOrder")] + public class WmOutOrderController : BaseController + { + /// + /// 出货单(物料+客户)接口 + /// + private readonly IWmOutOrderService _WmOutOrderService; + + public WmOutOrderController(IWmOutOrderService WmOutOrderService) + { + _WmOutOrderService = WmOutOrderService; + } + + /// + /// 查询出货单(物料+客户)列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:wmoutorder:list")] + public IActionResult QueryWmOutOrder([FromQuery] WmOutOrderQueryDto parm) + { + var response = _WmOutOrderService.GetList(parm); + + return SUCCESS(response); + } + + + /// + /// 查询出货单(物料+客户)详情 + /// + /// + /// + [HttpGet("{ShipmentNum}")] + [ActionPermissionFilter(Permission = "business:wmoutorder:query")] + public IActionResult GetWmOutOrder(string ShipmentNum) + { + var response = _WmOutOrderService.GetInfo(ShipmentNum); + return SUCCESS(response); + } + + /// + /// 添加出货单(物料+客户) + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:wmoutorder:add")] + [Log(Title = "出货单(物料+客户)", BusinessType = BusinessType.INSERT)] + public IActionResult AddWmOutOrder([FromBody] WmOutOrder_materialDto parm) + { + if(parm == null) + { + return SUCCESS(null); + } + var modal = parm.ToCreate(HttpContext); + + var response = _WmOutOrderService.AddWmOutOrder(modal); + + return SUCCESS(response); + } + + /// + /// 更新出货单(物料+客户) + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:wmoutorder:edit")] + [Log(Title = "出货单(物料+客户)", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateWmOutOrder([FromBody] WmOutOrderDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _WmOutOrderService.UpdateWmOutOrder(modal); + + return ToResponse(response); + } + + /// + /// 删除出货单(物料+客户) + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:wmoutorder:delete")] + [Log(Title = "出货单(物料+客户)", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteWmOutOrder(string ids) + { + + if (string.IsNullOrEmpty(ids)) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + + var response = _WmOutOrderService.Delete(ids.Split(",")); + + return ToResponse(response); + } + + /// + /// 获取客户信息 + /// + /// + [HttpGet("getcustom_list")] + public IActionResult GetWmOutOrder() + { + List customs= _WmOutOrderService.GetCustominfo(); + + return SUCCESS(customs); + } + + /// + /// 查询物料记录表列表 + /// + /// + /// + [HttpGet("getmaterial_list")] + + public IActionResult QueryWmMaterial([FromQuery] WmMaterialQueryDto parm) + { + var response = _WmOutOrderService.GetmaterialList(parm); + return SUCCESS(response); + } + + + + + + } +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj index e4f213a0..986c743b 100644 --- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj +++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj @@ -48,6 +48,7 @@ + diff --git a/ZR.Admin.WebApi/appsettings.development.json b/ZR.Admin.WebApi/appsettings.development.json index 16cd819c..820527f3 100644 --- a/ZR.Admin.WebApi/appsettings.development.json +++ b/ZR.Admin.WebApi/appsettings.development.json @@ -11,7 +11,7 @@ { //外网连接服务器 - "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + "Conn": "Data Source=localhost;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", //外网连接服务器 //"Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", diff --git a/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-客户信息-0317153123.zip b/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-客户信息-0317153123.zip deleted file mode 100644 index 73777ba7..00000000 Binary files a/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-客户信息-0317153123.zip and /dev/null differ diff --git a/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-物料记录表-0316162215.zip b/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-物料记录表-0316162215.zip deleted file mode 100644 index 154e8f26..00000000 Binary files a/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-物料记录表-0316162215.zip and /dev/null differ diff --git a/ZR.Model/MES/wms/Dto/WmMaterialDto.cs b/ZR.Model/MES/wms/Dto/WmMaterialDto.cs index 630e54aa..5dfe2ab2 100644 --- a/ZR.Model/MES/wms/Dto/WmMaterialDto.cs +++ b/ZR.Model/MES/wms/Dto/WmMaterialDto.cs @@ -48,6 +48,38 @@ namespace ZR.Model.MES.wms.Dto public DateTime? UpdatedTime { get; set; } } + /// + /// 带库存记录的物料库存表 + /// + public class WmMaterialQuery_stockQuantityDto : WmMaterialQueryDto + { + /// + /// 库存数量 + /// + public int stockQuantity { get; set; } + + /// + /// 需要出货数量 + /// + public int requireOutNum { get; set; } + + } + + /// + /// 带需要出货数量的物料库存表 + /// + public class WmMaterialQuery_stockQuantityDto2 : WmMaterialQueryDto + { + + + /// + /// 需要出货数量 + /// + public int requireOutNum { get; set; } + + } + + /// /// 物料记录表输入输出对象 /// @@ -95,4 +127,7 @@ namespace ZR.Model.MES.wms.Dto } + + + } \ No newline at end of file diff --git a/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs b/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs new file mode 100644 index 00000000..71c71885 --- /dev/null +++ b/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs @@ -0,0 +1,71 @@ +using System.ComponentModel.DataAnnotations; + +namespace ZR.Model.MES.wms.Dto +{ + /// + /// 出货单(物料+客户)查询对象 + /// + public class WmOutOrderQueryDto : PagerInfo + { + } + + /// + /// 出货单(物料+客户)输入输出对象 + /// + public class WmOutOrderDto + { + + public string ShipmentNum { get; set; } + + public string CustomId { get; set; } + + public string CustomNo { get; set; } + + public string CustomName { get; set; } + + public string CustomAddress { get; set; } + + public string Remarks { get; set; } + + public int Type { get; set; } + + public int? Status { get; set; } + + public int? Year { get; set; } + + public int? Week { get; set; } + + public int? Date { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + + + } + /// + /// 出货单(物料+客户)输入输出对象 + /// + public class WmOutOrder_materialDto : WmOutOrderDto + { + //带出货数量的物料表 + public List MaterialList { get; set; } + + + } + /// + /// 出货单_物料——数量 + /// + public class WmOutOrder_material_num : WmOutOrderDto + { + //带出货数量的物料表 + public List MaterialList { get; set; } + + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/wms/WmGoodsNowProduction.cs b/ZR.Model/MES/wms/WmGoodsNowProduction.cs index 5d0d7d0f..38753efc 100644 --- a/ZR.Model/MES/wms/WmGoodsNowProduction.cs +++ b/ZR.Model/MES/wms/WmGoodsNowProduction.cs @@ -27,12 +27,19 @@ namespace ZR.Model.MES.wms public string PackageCodeClient { get; set; } /// - /// 箱子编号 (批次号) + /// 箱子编号 (原始) /// [SugarColumn(ColumnName = "package_code_original")] public string PackageCodeOriginal { get; set; } + /// + /// 零件号 + /// + [SugarColumn(ColumnName = "partnumber")] + public string Partnumber { get; set; } + + /// /// 库位编号 /// diff --git a/ZR.Model/MES/wms/WmMaterialOutorder.cs b/ZR.Model/MES/wms/WmMaterialOutorder.cs new file mode 100644 index 00000000..8451c663 --- /dev/null +++ b/ZR.Model/MES/wms/WmMaterialOutorder.cs @@ -0,0 +1,59 @@ +namespace ZR.Model.MES.wms +{ + /// + /// 物料表和出库单关联表 + /// + [SugarTable("wm_material_outorder")] + public class WmMaterialOutorder + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 物料表主键 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_material_id")] + public string FkMaterialId { get; set; } + + /// + /// 出货单id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_outorder_id")] + public string FkOutorderId { get; set; } + + + /// + /// 出货数量 + /// + [SugarColumn(ColumnName = "outhouse_num")] + public int OuthouseNum { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + + } +} diff --git a/ZR.Model/MES/wms/WmOutOrder.cs b/ZR.Model/MES/wms/WmOutOrder.cs index 8facbd8b..fb4e853e 100644 --- a/ZR.Model/MES/wms/WmOutOrder.cs +++ b/ZR.Model/MES/wms/WmOutOrder.cs @@ -1,129 +1,100 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using SqlSugar; + namespace ZR.Model.MES.wms { /// /// 出货单(物料+客户) - /// + /// [SugarTable("wm_out_order")] public class WmOutOrder { + + //[Navigate(NavigateType.OneToMany, nameof(WmMaterialOutorder.FkOutorderId))]//BookA表中的studenId + //public List Books { get; set; }//注意禁止给books手动赋值 + + /// - /// 主键G - /// - [SugarColumn(ColumnName="id" ,IsPrimaryKey = true )] - public string Id { get; set; } - /// - /// 出货单号(雪花算法) - /// - [SugarColumn(ColumnName="shipment_num" )] - public string ShipmentNum { get; set; } + /// 出库单号(EG+时间) + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "shipment_num")] + public string ShipmentNum { get; set; } + /// /// 客户id - /// - [SugarColumn(ColumnName="custom_id" )] - public string CustomId { get; set; } + /// + [SugarColumn(ColumnName = "custom_id")] + public string CustomId { get; set; } + /// /// 客户代码 - /// - [SugarColumn(ColumnName="custom_no" )] - public string CustomNo { get; set; } + /// + [SugarColumn(ColumnName = "custom_no")] + public string CustomNo { get; set; } + /// /// 客户名称 - /// - [SugarColumn(ColumnName="custom_name" )] - public string CustomName { get; set; } + /// + [SugarColumn(ColumnName = "custom_name")] + public string CustomName { get; set; } + /// /// 客户地址 - /// - [SugarColumn(ColumnName="custom_address" )] - public string CustomAddress { get; set; } - /// - /// 物料号(零件号) - /// - [SugarColumn(ColumnName="partnumber" )] - public string Partnumber { get; set; } - /// - /// 单位 - /// - [SugarColumn(ColumnName="unit" )] - public string Unit { get; set; } - /// - /// 产品描述(产品名称) - /// - [SugarColumn(ColumnName="product_name" )] - public string ProductName { get; set; } - /// - /// 产品颜色 - /// - [SugarColumn(ColumnName="color" )] - public string Color { get; set; } - /// - /// 规格(左右脚) - /// - [SugarColumn(ColumnName="specification" )] - public string Specification { get; set; } - /// - /// 显示描述(产品描述+颜色+规格) - /// - [SugarColumn(ColumnName="description" )] - public string Description { get; set; } - /// - /// 版本号 - /// - [SugarColumn(ColumnName="version" )] - public string Version { get; set; } + /// + [SugarColumn(ColumnName = "custom_address")] + public string CustomAddress { get; set; } + /// /// 备注 - /// - [SugarColumn(ColumnName="remarks" )] - public string Remarks { get; set; } + /// + public string Remarks { get; set; } + /// - /// 状态(0-不可见 1-可见) - /// - [SugarColumn(ColumnName="status" )] - public int? Status { get; set; } + /// 出库单状态(1-出库中 2-出库完成 3-弃用) + /// + public int Type { get; set; } + + /// + /// 状态(0-停用 1-启用) + /// + public int? Status { get; set; } + /// /// 年 - /// - [SugarColumn(ColumnName="year" )] - public int? Year { get; set; } + /// + public int? Year { get; set; } + /// /// 周 - /// - [SugarColumn(ColumnName="week" )] - public int? Week { get; set; } + /// + public int? Week { get; set; } + /// /// 日 - /// - [SugarColumn(ColumnName="date" )] - public int? Date { get; set; } - /// - /// 要货数量 - /// - [SugarColumn(ColumnName="number" )] - public int? Number { get; set; } + /// + public int? Date { 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; } + } -} +} \ No newline at end of file diff --git a/ZR.Service/mes/wms/IService/IWmOutOrderService.cs b/ZR.Service/mes/wms/IService/IWmOutOrderService.cs new file mode 100644 index 00000000..e7e2c98e --- /dev/null +++ b/ZR.Service/mes/wms/IService/IWmOutOrderService.cs @@ -0,0 +1,30 @@ +using System; +using ZR.Model; +using ZR.Model.Dto; + +using System.Collections.Generic; +using ZR.Model.MES.wms; +using ZR.Model.MES.wms.Dto; + +namespace ZR.Service.mes.wms.IService +{ + /// + /// 出货单(物料+客户)service接口 + /// + public interface IWmOutOrderService : IBaseService + { + PagedInfo GetList(WmOutOrderQueryDto parm); + + WmOutOrder_material_num GetInfo(string ShipmentNum); + + WmOutOrder AddWmOutOrder(WmOutOrder_materialDto parm); + + int UpdateWmOutOrder(WmOutOrder parm); + + + List GetCustominfo(); + + (List, int) GetmaterialList(WmMaterialQueryDto parm); + + } +} diff --git a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs index 85e55f47..9cfc528f 100644 --- a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs +++ b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs @@ -54,6 +54,7 @@ namespace ZR.Service.mes.wms wmGood.PackageCode = Getpack_no(resultionPackage.WorkoderID, flow_num.ToString("000")); wmGood.PackageCodeClient = resultionPackage.PatchCode; + wmGood.Partnumber = resultionPackage.PartNumner; wmGood.PackageCodeOriginal = resultionPackage.originalCode; wmGood.LocationCode = wmgoods.location; diff --git a/ZR.Service/mes/wms/WmOutOrderService.cs b/ZR.Service/mes/wms/WmOutOrderService.cs new file mode 100644 index 00000000..92d9850a --- /dev/null +++ b/ZR.Service/mes/wms/WmOutOrderService.cs @@ -0,0 +1,224 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using ZR.Model; +using ZR.Repository; +using ZR.Service.mes.wms.IService; +using ZR.Model.MES.wms; +using ZR.Model.MES.wms.Dto; +using Mapster; +using System.Collections.Generic; + +namespace ZR.Service.mes.wms +{ + /// + /// 出货单(物料+客户)Service业务层处理 + /// + [AppService(ServiceType = typeof(IWmOutOrderService), ServiceLifetime = LifeTime.Transient)] + public class WmOutOrderService : BaseService, IWmOutOrderService + { + /// + /// 查询出货单(物料+客户)列表 + /// + /// + /// + public PagedInfo GetList(WmOutOrderQueryDto parm) + { + var predicate = Expressionable.Create(); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public WmOutOrder_material_num GetInfo(string ShipmentNum) + { + + WmOutOrder WmOutOrderList = Context.Queryable() + .Where(it => it.ShipmentNum == ShipmentNum) + .First(); + + WmOutOrder_material_num wmOutOrderItem = null; + + if (WmOutOrderList != null) + { + wmOutOrderItem = WmOutOrderList.Adapt(); + + List moList = Context.Queryable() + .Where(it => it.FkOutorderId == WmOutOrderList.ShipmentNum) + .ToList(); + + if (moList != null && moList.Count > 0) + { + List Material_stock = new List(); + + foreach (var moItem in moList) + { + WmMaterial material = Context.Queryable().Where(it => it.Id == moItem.FkMaterialId).First(); + WmMaterialQuery_stockQuantityDto2 dto2 = material.Adapt(); + dto2.requireOutNum = moItem.OuthouseNum; + Material_stock.Add(dto2); + } + wmOutOrderItem.MaterialList = Material_stock; + } + } + + + + return wmOutOrderItem; + } + + /// + /// 添加出货单(物料+客户) + /// + /// + /// + public WmOutOrder AddWmOutOrder(WmOutOrder_materialDto model) + { + string today_id = "EG" + DateTime.Now.ToString("yyMMdd"); + string last_outorder_ShipmentNum = Context.Queryable().Where(it => it.ShipmentNum.StartsWith(today_id)).Max(it => it.ShipmentNum); + if (string.IsNullOrEmpty(last_outorder_ShipmentNum)) + { + model.ShipmentNum = today_id + "001"; + + } + else + { + int flow = int.Parse(last_outorder_ShipmentNum.Substring(last_outorder_ShipmentNum.Length - 3, 3)) + 1; + model.ShipmentNum = today_id + flow.ToString("000"); + + } + WmOutOrder wmOutOrder = model.Adapt(); + + // 关联表也要新增 + if (model.MaterialList != null) + { + if (model.MaterialList.Count > 0) + { + List materialOutorderList = new List(); + + foreach (var item in model.MaterialList) + { + WmMaterialOutorder materialOutorder = new WmMaterialOutorder(); + materialOutorder.FkMaterialId = item.Id; + materialOutorder.FkOutorderId = model.ShipmentNum; + materialOutorder.OuthouseNum = item.requireOutNum; + materialOutorder.CreatedBy = model.CreatedBy; + materialOutorder.CreatedTime = DateTime.Now; + materialOutorderList.Add(materialOutorder); + }; + int result = Context.Insertable(materialOutorderList).ExecuteCommand(); + } + + } + + return Context.Insertable(wmOutOrder).ExecuteReturnEntity(); + } + + /// + /// 修改出货单(物料+客户) + /// + /// + /// + public int UpdateWmOutOrder(WmOutOrder model) + { + //var response = Update(w => w.ShipmentNum == model.ShipmentNum, it => new WmOutOrder() + //{ + // CustomNo = model.CustomNo, + // CustomName = model.CustomName, + // CustomAddress = model.CustomAddress, + // Remarks = model.Remarks, + // Type = model.Type, + // Status = model.Status, + // Year = model.Year, + // Week = model.Week, + // Date = model.Date, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + + + + /// + /// 获取用户信息 + /// + /// + public List GetCustominfo() + { + + return Context.Queryable().ToList(); + + } + + /// + /// 查询物料记录表列表 + /// + /// + /// + public (List, int) GetmaterialList(WmMaterialQueryDto parm) + { + int total = 0; + var predicate = Expressionable.Create() + .AndIF(parm.Partnumber != null, it => it.Partnumber.Contains(parm.Partnumber)) + .AndIF(parm.U8InventoryCode != null, it => it.U8InventoryCode.Contains(parm.U8InventoryCode)) + .AndIF(parm.ProductName != null, it => it.ProductName.Contains(parm.ProductName)) + .AndIF(parm.Color != null, it => it.Color.Contains(parm.Color)) + .AndIF(parm.Specification != null, it => it.Specification.Contains(parm.Specification)) + .AndIF(parm.Description != null, it => it.Description.Contains(parm.Description)) + .AndIF(parm.Search1 != null, it => it.Search1.Contains(parm.Search1) || it.Search2.Contains(parm.Search1)) + .AndIF(parm.Status > -1, it => it.Status == parm.Status); + + + List materialList = Context.Queryable() + .Where(predicate.ToExpression()).OrderByDescending(it => it.CreatedTime) + .ToPageList(parm.PageNum, parm.PageSize, ref total); + + + List material_stockQuantity_list = new List(); + + + if (materialList.Count > 0) + { + foreach (WmMaterial item in materialList) + { + + WmMaterialQuery_stockQuantityDto wmMaterialQuery_Stock_item = item.Adapt(); + + int material_num = 0; + List productioList = Context + .Queryable() + .Where(it => it.Partnumber == item.Partnumber) + .ToList(); + + if (productioList.Count > 0) + { + foreach (var product in productioList) + { + material_num = material_num + (int)product.GoodsNumLogic; + } + } + wmMaterialQuery_Stock_item.stockQuantity = material_num; + material_stockQuantity_list.Add(wmMaterialQuery_Stock_item); + + + } + } + return (material_stockQuantity_list, total); + } + + } +} \ No newline at end of file