1
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// <summary>
|
||||
/// 物料型号
|
||||
/// </summary>
|
||||
public string material_category_code { get; set; }
|
||||
public string material_standard { get; set; }
|
||||
/// <summary>
|
||||
///输出数量
|
||||
/// </summary>
|
||||
@@ -44,6 +44,10 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工艺路线id
|
||||
/// </summary>
|
||||
public string route_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
@@ -56,5 +60,9 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// 工艺路线名称
|
||||
/// </summary>
|
||||
public string route_name { get; set; }
|
||||
/// <summary>
|
||||
/// 工序排序序号
|
||||
/// </summary>
|
||||
public long? ordinal { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,26 +155,51 @@ namespace Tnb.BasicData
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||
|
||||
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();
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||
.Where((a, b, c, d, e) => a.id == bomId)
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
{
|
||||
version = a.version,
|
||||
unit_id = a.unit_id,
|
||||
route_name = c.name,
|
||||
process_id = b.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_standard = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.material_standard),
|
||||
num = e.num,
|
||||
ordinal = d.ordinal,
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.ToListAsync();
|
||||
#region 注释代码
|
||||
//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_standard = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.material_standard),
|
||||
// num = e.num,
|
||||
// })
|
||||
// .Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
// .ToListAsync();
|
||||
#endregion
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -198,7 +223,6 @@ 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