物料清单所有子物料查询接口
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料清单所有自己物料信息
|
||||
/// </summary>
|
||||
/// <param name="queryInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetMaterialSelectInfo(MaterialSelectQueryInput queryInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id);
|
||||
var result = await db.Queryable<BasMaterial>()
|
||||
.LeftJoin<DictionaryDataEntity>((a, b) => a.unit_id == b.EnCode)
|
||||
.LeftJoin<DictionaryTypeEntity>((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<MaterialSelectOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料清单下所子集物料id
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<List<string>> GetAllChildrenMaterialId(string ebomId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ebomId)) return new List<string>();
|
||||
List<string> ids = new List<string>();
|
||||
var list = await _repository.AsSugarClient().Queryable<BasEbomD>().Where(x => x.ebom_id == ebomId)
|
||||
.Select<string>(x => x.material_id).ToListAsync();
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
foreach (var id in list)
|
||||
{
|
||||
//获取最新创建的物料清单
|
||||
var ebom = await _repository.AsSugarClient().Queryable<BasEbomH>().Where(x=>x.material_id==id).OrderByDescending(x=>x.create_time).FirstAsync();
|
||||
ids.AddRange(await GetAllChildrenMaterialId(ebom?.id));
|
||||
}
|
||||
ids.AddRange(list);
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user