diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/MaterialSelectOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/MaterialSelectOutput.cs
new file mode 100644
index 00000000..76ee9199
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/MaterialSelectOutput.cs
@@ -0,0 +1,38 @@
+namespace Tnb.BasicData.Entities.Dto
+{
+ ///
+ /// 物料弹窗选择显示信息
+ ///
+ public class MaterialSelectOutput
+ {
+ ///
+ /// 物料id
+ ///
+ public string id { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string code { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string name { get; set; }
+
+ ///
+ /// 描述
+ ///
+ public string descrip { get; set; }
+
+ ///
+ /// 主单位id
+ ///
+ public string unit_id { get; set; }
+
+ ///
+ /// 主单位名称
+ ///
+ public string unit_name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/MaterialSelectQueryInput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/MaterialSelectQueryInput.cs
new file mode 100644
index 00000000..4ca42123
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/MaterialSelectQueryInput.cs
@@ -0,0 +1,25 @@
+namespace Tnb.BasicData.Entities.Dto
+{
+ public class MaterialSelectQueryInput
+ {
+ ///
+ /// 物料清单id
+ ///
+ public string ebom_id { get; set; }
+
+ ///
+ /// 物料编码名称查询
+ ///
+ public string material_info { get; set; }
+
+ ///
+ /// 当前页码:pageIndex.
+ ///
+ public virtual int currentPage { get; set; } = 1;
+
+ ///
+ /// 每页行数.
+ ///
+ public virtual int pageSize { get; set; } = 50;
+ }
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs
index 3fce3259..c27b3596 100644
--- a/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs
+++ b/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs
@@ -1,7 +1,9 @@
+using Tnb.BasicData.Entities.Dto;
+
namespace Tnb.BasicData.Interfaces
{
public interface IBasMaterialService
{
-
+ public Task GetMaterialSelectInfo(MaterialSelectQueryInput queryInput);
}
}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData/BasMaterialService.cs b/BasicData/Tnb.BasicData/BasMaterialService.cs
index c382baab..35a78ab4 100644
--- a/BasicData/Tnb.BasicData/BasMaterialService.cs
+++ b/BasicData/Tnb.BasicData/BasMaterialService.cs
@@ -1,11 +1,14 @@
using JNPF.Common.Core.Manager;
+using JNPF.Common.Filter;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
+using Tnb.BasicData.Entities.Dto;
using Tnb.BasicData.Interfaces;
namespace Tnb.BasicData
@@ -60,5 +63,57 @@ namespace Tnb.BasicData
return result.IsSuccess ? "复制成功" : result.ErrorMessage;
}
+
+ ///
+ /// 获取物料清单所有自己物料信息
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task GetMaterialSelectInfo(MaterialSelectQueryInput queryInput)
+ {
+ var db = _repository.AsSugarClient();
+ List ids = await GetAllChildrenMaterialId(queryInput.ebom_id);
+ var result = await db.Queryable()
+ .LeftJoin((a, b) => a.unit_id == b.EnCode)
+ .LeftJoin((a, b, c) => b.DictionaryTypeId == c.Id && c.EnCode == DictConst.MeasurementUnit && c.DeleteMark == null)
+ .WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
+ .WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id))
+ .Select((a, b, c) => new MaterialSelectOutput()
+ {
+ id = a.id,
+ code = a.code,
+ name = a.name,
+ descrip = a.descrip,
+ unit_id = a.unit_id,
+ unit_name = b.FullName,
+ }).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize);
+
+ return PageResult.SqlSugarPageResult(result);
+ }
+
+ ///
+ /// 获取物料清单下所子集物料id
+ ///
+ ///
+ private async Task> GetAllChildrenMaterialId(string ebomId)
+ {
+ if (string.IsNullOrEmpty(ebomId)) return new List();
+ List ids = new List();
+ var list = await _repository.AsSugarClient().Queryable().Where(x => x.ebom_id == ebomId)
+ .Select(x => x.material_id).ToListAsync();
+ if (list != null && list.Count > 0)
+ {
+ foreach (var id in list)
+ {
+ //获取最新创建的物料清单
+ var ebom = await _repository.AsSugarClient().Queryable().Where(x=>x.material_id==id).OrderByDescending(x=>x.create_time).FirstAsync();
+ ids.AddRange(await GetAllChildrenMaterialId(ebom?.id));
+ }
+ ids.AddRange(list);
+ }
+
+ return ids;
+ }
}
}
\ No newline at end of file