物料清单所有子物料查询接口
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
namespace Tnb.BasicData.Entities.Dto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料弹窗选择显示信息
|
||||||
|
/// </summary>
|
||||||
|
public class MaterialSelectOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编码
|
||||||
|
/// </summary>
|
||||||
|
public string code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public string descrip { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主单位id
|
||||||
|
/// </summary>
|
||||||
|
public string unit_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主单位名称
|
||||||
|
/// </summary>
|
||||||
|
public string unit_name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
namespace Tnb.BasicData.Entities.Dto
|
||||||
|
{
|
||||||
|
public class MaterialSelectQueryInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料清单id
|
||||||
|
/// </summary>
|
||||||
|
public string ebom_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编码名称查询
|
||||||
|
/// </summary>
|
||||||
|
public string material_info { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前页码:pageIndex.
|
||||||
|
/// </summary>
|
||||||
|
public virtual int currentPage { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每页行数.
|
||||||
|
/// </summary>
|
||||||
|
public virtual int pageSize { get; set; } = 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
using Tnb.BasicData.Entities.Dto;
|
||||||
|
|
||||||
namespace Tnb.BasicData.Interfaces
|
namespace Tnb.BasicData.Interfaces
|
||||||
{
|
{
|
||||||
public interface IBasMaterialService
|
public interface IBasMaterialService
|
||||||
{
|
{
|
||||||
|
public Task<dynamic> GetMaterialSelectInfo(MaterialSelectQueryInput queryInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Filter;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Systems.Entitys.System;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.BasicData.Entities.Dto;
|
||||||
using Tnb.BasicData.Interfaces;
|
using Tnb.BasicData.Interfaces;
|
||||||
|
|
||||||
namespace Tnb.BasicData
|
namespace Tnb.BasicData
|
||||||
@@ -60,5 +63,57 @@ namespace Tnb.BasicData
|
|||||||
|
|
||||||
return result.IsSuccess ? "复制成功" : result.ErrorMessage;
|
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