正向追溯接口
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单追溯一级列表输出类
|
||||
/// </summary>
|
||||
public class PrdMoFromOneListOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单id
|
||||
/// </summary>
|
||||
public string id { get; set; }
|
||||
|
||||
public string mo_code { get; set; }
|
||||
|
||||
public string material_id { get; set; }
|
||||
|
||||
public string material_code { get; set; }
|
||||
|
||||
public string material_name { get; set; }
|
||||
|
||||
public string? material_standard { get; set; }
|
||||
|
||||
public string? act_start_date { get; set; }
|
||||
|
||||
public string? act_end_date { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单追溯二级列表输出类
|
||||
/// </summary>
|
||||
public class PrdMoFromTwoListOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务单id
|
||||
/// </summary>
|
||||
public string id { get; set; }
|
||||
|
||||
public string mo_task_code { get; set; }
|
||||
|
||||
public string material_id { get; set; }
|
||||
|
||||
public string material_code { get; set; }
|
||||
|
||||
public string material_name { get; set; }
|
||||
|
||||
public string? material_standard { get; set; }
|
||||
|
||||
public string? act_start_date { get; set; }
|
||||
|
||||
public string? act_end_date { get; set; }
|
||||
|
||||
public string? workline_name { get; set; }
|
||||
|
||||
public string? mbom_version { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class PrdMoFromQueryInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前页码:pageIndex.
|
||||
/// </summary>
|
||||
public int currentPage { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 每页行数.
|
||||
/// </summary>
|
||||
public int pageSize { get; set; } = 50;
|
||||
|
||||
public string? mo_code { get; set; }
|
||||
|
||||
public string? mo_task_code { get; set; }
|
||||
|
||||
public string? batch { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
@@ -356,6 +357,92 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 工单追溯相关
|
||||
|
||||
/// <summary>
|
||||
/// 工单追溯一级列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromOneList(PrdMoFromQueryInput input)
|
||||
{
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids1 = new List<string>();
|
||||
List<string> ids2 = new List<string>();
|
||||
if (!string.IsNullOrEmpty(input.mo_task_code))
|
||||
{
|
||||
ids1 = await _db.Queryable<PrdMoTask>().Where(x => x.mo_task_code.Contains(x.mo_task_code)).Select(x => x.mo_id).ToListAsync();
|
||||
ids = ids1;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(input.batch))
|
||||
{
|
||||
ids2 = await _db.Queryable<PrdReport>()
|
||||
.LeftJoin<PrdMoTask>((a,b)=>a.mo_task_id==b.id)
|
||||
.Where((a,b) => a.batch.Contains(input.batch)).Select((a,b) => b.mo_id).ToListAsync();
|
||||
ids = ids2;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(input.mo_task_code) && !string.IsNullOrEmpty(input.batch))
|
||||
{
|
||||
ids = ids1.Intersect(ids2).ToList();
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMo>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mo_code),(a,b)=>a.mo_code.Contains(input.mo_code))
|
||||
.WhereIF(ids!=null && ids.Count>0,(a,b)=>ids.Contains(a.id))
|
||||
.Select((a, b) =>
|
||||
new PrdMoFromOneListOutput
|
||||
{
|
||||
id = a.id,
|
||||
mo_code = a.mo_code,
|
||||
material_id = a.material_id,
|
||||
material_code = b.code,
|
||||
material_name = b.name,
|
||||
material_standard = b.material_standard,
|
||||
act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
act_end_date = a.act_end_date==null ? "" : a.act_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<PrdMoFromOneListOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单追溯二级列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromTwoList(Dictionary<string,string> dic)
|
||||
{
|
||||
string mo_id = dic.ContainsKey("mo_id") ? dic["mo_id"] : "";
|
||||
return await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
||||
.LeftJoin<BasMbom>((a, b, c, d) => a.bom_id == d.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(mo_id),(a,b,c,d)=>a.mo_id==mo_id)
|
||||
.Select((a, b, c, d) =>
|
||||
new PrdMoFromTwoListOutput
|
||||
{
|
||||
id = a.id,
|
||||
mo_task_code = a.mo_task_code,
|
||||
material_id = a.material_id,
|
||||
material_code = b.code,
|
||||
material_name = b.name,
|
||||
material_standard = b.material_standard,
|
||||
act_start_date = a.act_start_date == null
|
||||
? ""
|
||||
: a.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
act_end_date = a.act_end_date == null
|
||||
? ""
|
||||
: a.act_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
workline_name = c.FullName,
|
||||
mbom_version = d.version
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user