From 2afaa0cb248a7b7ba37f5147006a552d4297c814 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Fri, 11 Aug 2023 16:32:11 +0800 Subject: [PATCH] 1 --- .../Dto/PrdManage/PrdMoTaskOutput.cs | 39 ++++++++++++++ .../Tnb.ProductionMgr/PrdInstockService.cs | 52 ++++++++++++++++++- .../Permission/DepartmentService.cs | 33 ++++++++++++ 3 files changed, 122 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs index aa48d3b7..e3e66deb 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Security.Principal; using System.Text; using System.Threading.Tasks; +using JNPF.Common.Security; namespace Tnb.ProductionMgr.Entities.Dto.PrdManage { @@ -86,7 +87,45 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string process_name { get; set;} public string create_time { get; set; } + } + public class PrdMoTaskTreeOutput : TreeModel + { + /// + /// 生产任务单号 + /// + public string? mo_task_code { get; set; } + public string? material_id { get; set; } + public string? mold_id { get; set; } + public string? eqp_id { get; set; } + + /// + /// 物料 + /// + public string? material_id_id { get; set; } + /// + /// 模具 + /// + public string? mold_id_id { get; set; } + /// + /// 设备 + /// + public string? eqp_id_id { get; set; } + + /// + /// 预计开始时间 + /// + public string? estimated_start_date { get; set; } + + /// + /// 预计结束时间 + /// + public string? estimated_end_date { get; set; } + + /// + /// 创建时间 + /// + public string? create_time { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 2e0b5b3c..64429b5e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -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 /// [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 _repository; private readonly IUserManager _userManager; - + private const string ModuleId = "25572529329173"; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public PrdInstockService( ISqlSugarRepository repository, @@ -42,6 +50,46 @@ namespace Tnb.ProductionMgr { _repository = repository; _userManager = userManager; + OverideFuncs.GetListAsync = GetList; + } + + private async Task GetList(VisualDevModelListQueryInput input) + { + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + var list = await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => a.mold_id == c.id) + .LeftJoin((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 pagedList = new() + { + list = treeList, + pagination = new Pagination + { + CurrentPage = input.currentPage, + PageSize = input.pageSize, + Total = treeList.Count + } + }; + return PageResult.SqlSugarPageResult(pagedList); } [HttpPost] diff --git a/system/Tnb.Systems/Permission/DepartmentService.cs b/system/Tnb.Systems/Permission/DepartmentService.cs index 47949942..872c5ce1 100644 --- a/system/Tnb.Systems/Permission/DepartmentService.cs +++ b/system/Tnb.Systems/Permission/DepartmentService.cs @@ -536,6 +536,20 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync(); } } + await _repository.AsSugarClient().Deleteable(p => p.OrganizeId == id && p.ObjectType == "Eqp").ExecuteCommandAsync(); + var OrganizeRelationEntitys = new List(); + foreach (var item in eqpIds) + { + OrganizeRelationEntity organizeRelationEntity = new OrganizeRelationEntity(); + organizeRelationEntity.Id = SnowflakeIdHelper.NextId(); + organizeRelationEntity.OrganizeId = id; + organizeRelationEntity.ObjectType = "Eqp"; + organizeRelationEntity.ObjectId = item; + organizeRelationEntity.CreatorTime = DateTime.Now; + organizeRelationEntity.CreatorUserId = _userManager.UserId; + OrganizeRelationEntitys.Add(organizeRelationEntity); + } + await _repository.AsSugarClient().Insertable(OrganizeRelationEntitys).ExecuteCommandAsync(); } var processVal = jsonObj.GetValue("rowprocess"); if (processVal is not null) @@ -570,6 +584,25 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra isOK = await _repository.AsSugarClient().Updateable(it => new BasProcessStation { station_id = "", station_code = "" }).Where(it => curProcIds.Contains(it.process_id)).ExecuteCommandAsync(); } } + var correlation= jsonObj.GetValue("correlation"); + if (correlation is not null) + { + await _repository.AsSugarClient().Deleteable(p => p.OrganizeId == id && p.ObjectType == "User").ExecuteCommandAsync(); + var OrganizeRelationEntitys=new List(); + for (int i = 0; i < correlation.Count(); i++) + { + OrganizeRelationEntity organizeRelationEntity = new OrganizeRelationEntity(); + organizeRelationEntity.Id = SnowflakeIdHelper.NextId(); + organizeRelationEntity.OrganizeId = id; + organizeRelationEntity.ObjectType = "User"; + organizeRelationEntity.ObjectId = correlation[i].ToString(); + organizeRelationEntity.CreatorTime = DateTime.Now; + organizeRelationEntity.CreatorUserId = _userManager.UserId; + OrganizeRelationEntitys.Add(organizeRelationEntity); + } + await _repository.AsSugarClient().Insertable(OrganizeRelationEntitys).ExecuteCommandAsync(); + } + if (!(isOK > 0)) throw Oops.Oh(ErrorCode.COM1001); }