This commit is contained in:
qianjiawei
2023-08-11 16:32:11 +08:00
parent b25ab2c526
commit 2afaa0cb24
3 changed files with 122 additions and 2 deletions

View File

@@ -21,6 +21,12 @@ using Tnb.ProductionMgr.Interfaces;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.BasicData;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
using JNPF.Common.Filter;
using JNPF.Common.Security;
namespace Tnb.ProductionMgr
{
@@ -29,11 +35,13 @@ namespace Tnb.ProductionMgr
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class PrdInstockService : IPrdInstockService, IDynamicApiController, ITransient
[OverideVisualDev(ModuleId)]
public class PrdInstockService : IPrdInstockService, IDynamicApiController, ITransient, IOverideVisualDevService
{
private readonly ISqlSugarRepository<PrdInstockH> _repository;
private readonly IUserManager _userManager;
private const string ModuleId = "25572529329173";
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdInstockService(
ISqlSugarRepository<PrdInstockH> repository,
@@ -42,6 +50,46 @@ namespace Tnb.ProductionMgr
{
_repository = repository;
_userManager = userManager;
OverideFuncs.GetListAsync = GetList;
}
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
{
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
string moCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
var list = await _repository.AsSugarClient().Queryable<PrdMoTask>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
.LeftJoin<EqpEquipment>((a, b, c, d) => a.eqp_id == d.id)
.WhereIF(!string.IsNullOrEmpty(moCode), (a, b, c, d) => a.mo_task_code!.Contains(moCode))
.Select((a, b, c, d) => new PrdMoTaskTreeOutput()
{
id = a.id,
parentId = string.IsNullOrEmpty(a.parent_id) ? "0" : a.parent_id,
mo_task_code = a.mo_task_code,
material_id = b.name,
material_id_id = b.id,
mold_id = c.mold_name,
mold_id_id = c.id,
eqp_id = d.name,
eqp_id_id = d.id,
estimated_start_date = a.estimated_start_date!.ToString(),
estimated_end_date = a.estimated_end_date.ToString(),
create_time = a.create_time.ToString()
}).ToListAsync();
var treeList = list.ToTree();
treeList= treeList.Skip((input.currentPage-1)* input.pageSize).Take(input.pageSize).ToList();
SqlSugarPagedList<PrdMoTaskTreeOutput> pagedList = new()
{
list = treeList,
pagination = new Pagination
{
CurrentPage = input.currentPage,
PageSize = input.pageSize,
Total = treeList.Count
}
};
return PageResult<PrdMoTaskTreeOutput>.SqlSugarPageResult(pagedList);
}
[HttpPost]