根据生产bom拆分子工单代码调整
This commit is contained in:
@@ -133,35 +133,51 @@ namespace Tnb.BasicData
|
||||
/// <summary>
|
||||
/// 根据bomid获取对应的子bom列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="bomId">bomId</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>{
|
||||
/// <br/> version:bom版本
|
||||
/// <br/> unit_id:单位id
|
||||
/// <br/> route_name:工艺路线名称
|
||||
/// <br/> process_id:工序id
|
||||
/// <br/> material_id:物料id
|
||||
/// <br/> material_code:物料编码
|
||||
/// <br/> material_name:物料名称
|
||||
/// <br/> material_category_code:类别code
|
||||
/// <br/> output_qty:输出参数
|
||||
/// <br/>}
|
||||
/// </remarks>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||
var result = await _db.Queryable<BasMbom>().LeftJoin<BasRouteD>((a, b) => a.route_id == b.route_id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => b.process_id == c.id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d) => c.id == d.process_id)
|
||||
.LeftJoin<BasMaterial>((a, b, c, d, e) => d.material_id == e.id)
|
||||
.LeftJoin<BasMaterialCategory>((a, b, c, d, e, f) => e.category_id == f.id)
|
||||
.Where((a, b, c, d, e, f) => a.id == bomId)
|
||||
.Select((a, b, c, d, e, f) => new SubBomListOutput
|
||||
{
|
||||
material_id = e.id,
|
||||
material_code = e.code,
|
||||
material_name = e.name,
|
||||
material_category_code = f.category_code,
|
||||
num = d.num
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
var result = await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasRouteH>((a, b) => a.route_id == b.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c) => b.id == c.route_id)
|
||||
.LeftJoin<BasMbomProcess>((a, b, c, d) => c.process_id == d.process_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
|
||||
.Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
{
|
||||
version = a.version,
|
||||
unit_id = a.unit_id,
|
||||
route_name = b.name,
|
||||
process_id = c.process_id,
|
||||
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||
material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
||||
material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
||||
material_category_code = "",
|
||||
num = e.num,
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据物料id获取生产bom
|
||||
/// </summary>
|
||||
@@ -182,6 +198,7 @@ namespace Tnb.BasicData
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetMBomListByMaterialId([FromRoute] string materialId)
|
||||
{
|
||||
|
||||
return await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
|
||||
Reference in New Issue
Block a user