diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index ff2bfac8..3359147b 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -71,6 +71,14 @@ public static class DictConst /// 任务单状态-待排产 /// public const string ToBeScheduledEncode = "ToBeScheduled"; + /// + /// 模具维修状态码-待维修 + /// + public const string MaintainStatusDWXCode = "DWX"; + /// + /// 模具维修状态码-已完成 + /// + public const string MaintainStatusYWCCode = "YWC"; diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/BaseMoldMaintainInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/BaseMoldMaintainInput.cs index e34be422..8ec274d1 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/BaseMoldMaintainInput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/BaseMoldMaintainInput.cs @@ -8,7 +8,7 @@ namespace Tnb.EquipMgr.Entities.Dto { public class BaseMoldMaintainInput { - public string item_group_id { get; set; } + public string id { get; set; } public List ids { get; set; } } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/ClosedownEndListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ClosedownEndListOutput.cs new file mode 100644 index 00000000..7d9bd6a9 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ClosedownEndListOutput.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + public class ClosedownEndListOutput + { + public string id { get; set; } + /// + /// 生产场地 + /// + public string workshop_name { get; set; } + /// + /// 停机原因 + /// + public string reason { get; set; } + /// + /// 设备编号 + /// + public string eqp_code { get; set; } + /// + /// 设备型号 + /// + public string eqp_type_code { get; set; } + /// + /// 操作人 + /// + /// + /// + public string operator_name { get; set; } + /// + /// 备注 + /// + public string remark { get; set; } + /// + /// 停机开始时间 + /// + public DateTime? closeddown_start_time { get; set; } + + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs index c3d04d08..78acb766 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs @@ -19,10 +19,18 @@ namespace Tnb.EquipMgr.Entities.Dto /// /// 模具编码 /// - public string mold_code { get; set; } + public string? mold_code { get; set; } /// /// 模具名称 /// - public string mold_name { get;} + public string? mold_name { get; set; } + /// + /// 库房编码 + /// + public string? whcode { get; set; } + /// + /// 库位编码 + /// + public string? location_code { get; set; } } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainStatusUpInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainStatusUpInput.cs new file mode 100644 index 00000000..4fdf5b08 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainStatusUpInput.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + /// + /// 修改维修单任务状态输入参数 + /// + public class MaintainStatusUpInput + { + /// + /// 维修任务单id数组 + /// + public List ids { get; set; } + /// + /// 维修单状态 DWX(待维修)、WXZ(维修中)、YWC(已维修) + /// + public string status { get; set; } + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainUpInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainUpInput.cs new file mode 100644 index 00000000..01b9fb77 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainUpInput.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + public class MoldMaintainUpInput + { + /// + /// 维修任务Id数组 + /// + public List ids { get; set; } + /// + /// 维修状态 + /// + public string status{ get; set; } + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs index fe52805e..c071c729 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs @@ -183,5 +183,9 @@ public partial class EqpEquipment : BaseEntity /// 模具Id /// public string? mold_id { get; set; } + /// + /// 工位编码 + /// + public string station_code { get; set; } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainTask.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainTask.cs new file mode 100644 index 00000000..b077342b --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainTask.cs @@ -0,0 +1,56 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具维修任务表 +/// +[SugarTable("tool_mold_maintain_task")] +public partial class ToolMoldMaintainTask : BaseEntity +{ + public ToolMoldMaintainTask() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 维修单号 + /// + public string? code { get; set; } + + /// + /// 模具id + /// + public string? mold_id { get; set; } + + /// + /// 报修人 + /// + public string? create_id { get; set; } + + /// + /// 保修时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 维修人 + /// + public string? modify_id { get; set; } + + /// + /// 维修开始时间 + /// + public DateTime? modify_strat_time { get; set; } + + /// + /// 维修结束时间 + /// + public DateTime? modify_end_time { get; set; } + /// + /// 维修单状态 + /// + public string status { get; set; } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.part.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.part.cs new file mode 100644 index 00000000..d6d167ba --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.part.cs @@ -0,0 +1,22 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具信息表 +/// +public partial class ToolMolds +{ + /// + /// 库房编码 + /// + [SugarColumn(IsIgnore = true)] + public string whcode { get; set; } + /// + /// 库位编码 + /// + [SugarColumn(IsIgnore =true)] + public string location_code { get; set; } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Enums/MaintainStatus.cs b/EquipMgr/Tnb.EquipMgr.Entities/Enums/MaintainStatus.cs new file mode 100644 index 00000000..d17d7d50 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Enums/MaintainStatus.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Enums +{ + public enum MaintainStatus + { + /// + /// 待维修 + /// + DWX=1, + /// + /// 维修中 + /// + WXZ=2, + /// + /// 已完成 + /// + YWC=4, + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Mapper/Mapper.cs b/EquipMgr/Tnb.EquipMgr.Entities/Mapper/Mapper.cs index 3b575108..475faac8 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Mapper/Mapper.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Mapper/Mapper.cs @@ -12,6 +12,9 @@ namespace Tnb.EquipMgr.Entities.Mapper .Map(dest => dest.item_id, src => src.id); config.ForType() .Map(dest => dest.mold_id, src => src.id); + config.ForType() + .Map(dest => dest.mold_id, src => src.id); + //.Map(dest=>dest.mold_name,src=>src.mold_name); } } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldHouseService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldHouseService.cs new file mode 100644 index 00000000..221f05ea --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldHouseService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Interfaces +{ + /// + /// 目录库房服务接口 + /// + public interface IToolMoldHouseService + { + Task> GetHouseDictionary(); + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldLocationService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldLocationService.cs new file mode 100644 index 00000000..d788daca --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldLocationService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Interfaces +{ + /// + /// 模具库位服务接口 + /// + public interface IToolMoldLocationService + { + Task> GetLocationDictionary(); + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldMaintainTaskService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldMaintainTaskService.cs new file mode 100644 index 00000000..fa2181d5 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldMaintainTaskService.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tnb.EquipMgr.Entities; + +namespace Tnb.EquipMgr.Interfaces +{ + /// + /// 模具维修任务接口 + /// + public interface IToolMoldMaintainTaskService + { + /// + /// 创建模具维修任务 + /// + /// 维修任务记录 + /// + Task Create(ToolMoldMaintainTask entity); + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs index 18539dc2..83bd40e9 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; namespace Tnb.EquipMgr.Interfaces @@ -29,5 +31,22 @@ namespace Tnb.EquipMgr.Interfaces /// /// public Task DetachData(ToolMoldInput ToolMoldInput); + /// + /// 获取列表根据传入的Id集合 + /// + /// + public Task> GetListByIds(List ids); + /// + /// 根据设备ID获取模具信息 + /// + /// + /// + Task> GetListByEqpId([FromRoute] string eqpId); + /// + /// 根据模具id获取模具信息 + /// + /// + /// + Task GetListById(string moldId); } } diff --git a/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs b/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs index 965c764a..ce2313b9 100644 --- a/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs +++ b/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs @@ -37,8 +37,8 @@ namespace Tnb.EquipMgr protected async Task Relevance(TSrc input, string mColumnName, string name, Expression> deleleExp) where TDest : BaseEntity, new() where TSrc : BaseMoldMaintainInput { - await _db.Deleteable().Where(deleleExp).ExecuteCommandAsync(); if (input == null) throw new ArgumentNullException(nameof(input)); + await _db.Deleteable().Where(deleleExp).ExecuteCommandAsync(); var entities = new List(); if (input.ids?.Count > 0) { @@ -46,7 +46,7 @@ namespace Tnb.EquipMgr { var pk = id; TDest entity = new(); - entity.PropertySetValue(mColumnName, input.item_group_id); + entity.PropertySetValue(mColumnName, input.id); entity.PropertySetValue(name, pk); entities.Add(entity); } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldHouseService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldHouseService.cs new file mode 100644 index 00000000..f4c33e23 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldHouseService.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.ClayObject.Extensions; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 模具库房服务 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class ToolMoldHouseService : IToolMoldHouseService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + public ToolMoldHouseService(ISqlSugarRepository repository) + { + _db = repository.AsSugarClient(); + } + public async Task> GetHouseDictionary() + { + return await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.whcode); + } + } +} diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs new file mode 100644 index 00000000..bfc73a31 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 模具库位服务 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class ToolMoldLocationService : IToolMoldLocationService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + public ToolMoldLocationService(ISqlSugarRepository repository) + { + _db = repository.AsSugarClient(); + } + public async Task> GetLocationDictionary() + { + return await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.location_code); + } + } +} diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs index 1e0826ae..20d67e21 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs @@ -80,7 +80,7 @@ namespace Tnb.EquipMgr /// [HttpPost] public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input) => - await Relevance(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.item_group_id); + await Relevance(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id); /// /// 关联项目组与模具 @@ -89,7 +89,7 @@ namespace Tnb.EquipMgr /// [HttpPost] public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input) => - await Relevance(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.item_group_id); + await Relevance(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.id); /// /// 删除项目组与模具检查项信息 /// @@ -101,11 +101,11 @@ namespace Tnb.EquipMgr if (input.table_name == "item") { - await Delete(it => it.item_group_id == input.item_group_id && input.ids.Contains(it.item_id)); + await Delete(it => it.item_group_id == input.id && input.ids.Contains(it.item_id)); } else { - await Delete(it => it.item_group_id == input.item_group_id && input.ids.Contains(it.mold_id)); + await Delete(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id)); } } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs index d7a993ed..016c0aca 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs @@ -5,13 +5,16 @@ using System.Text; using System.Threading.Tasks; using Aspose.Cells.Drawing; using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Extension; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Logging; using JNPF.VisualDev; using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; +using Mapster; using Microsoft.AspNetCore.Mvc; +using Spire.Pdf.Widget; using SqlSugar; using Tnb.BasicData; using Tnb.EquipMgr.Entities; @@ -29,12 +32,29 @@ namespace Tnb.EquipMgr private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; + private readonly IToolMoldHouseService _moldHouseService; + private readonly IToolMoldLocationService _moldLocationService; + private readonly IToolMoldsService _moldService; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); - public ToolMoldMaintainPlanService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService) : base(repository.AsSugarClient()) + + private static Dictionary _dicHouse = new Dictionary(); + private static Dictionary _dicLocation = new Dictionary(); + + public ToolMoldMaintainPlanService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService, + IToolMoldHouseService moldHouseService, + IToolMoldLocationService moldLocationService, + IToolMoldsService moldService + ) : base(repository.AsSugarClient()) { _db = repository.AsSugarClient(); _runService = runService; _visualDevService = visualDevService; + _moldHouseService = moldHouseService; + _moldLocationService = moldLocationService; + _moldService = moldService; OverideFuncs.CreateAsync = Create; } @@ -54,20 +74,46 @@ namespace Tnb.EquipMgr } return await Task.FromResult("ok"); } - + /// + /// 根据规则id获取匹配的模具列表 + /// + /// 计划Id + /// [HttpGet] - public async Task GetMoldListByPlanId(RelevanceMoldFromPlanInput input) + public async Task GetMoldListByPlanId([FromRoute] string planId) { - var list = await _db.Queryable().Where(it => it.maintain_plan_id == input.item_group_id).ToListAsync(); + var result = new List(); + if (_dicHouse.Count < 1) + { + _dicHouse = await _moldHouseService.GetHouseDictionary(); + } + if (_dicLocation.Count < 1) + { + _dicLocation = await _moldLocationService.GetLocationDictionary(); + } + var list = await _db.Queryable().Where(it => it.maintain_plan_id == planId).ToListAsync(); if (list?.Count > 0) { var ids = list.Select(it => it.mold_id).Distinct().ToList(); if (ids?.Count > 0) { + var items = await _moldService.GetListByIds(ids); + _db.ThenMapper(items, it => + { + if (!it.warehosue_id!.IsNullOrEmpty()) + { + it.whcode = _dicHouse.ContainsKey(it.warehosue_id!) ? _dicHouse[it.warehosue_id!].ToString()! : ""; + } + if (!it.location_id!.IsNullOrEmpty()) + { + it.location_code = _dicLocation.ContainsKey(it.location_id!) ? _dicLocation[it.location_id!].ToString()! : ""; + } + }); + result = items.Adapt>(); } } - return null; + return result; } /// @@ -76,15 +122,15 @@ namespace Tnb.EquipMgr /// [HttpPost] public async Task RelevanceMoldFromPlan(RelevanceMoldFromPlanInput input) => - await Relevance(input, nameof(ToolMoldMaintainPlanRelation.maintain_plan_id), nameof(ToolMoldMaintainPlanRelation.mold_id), it => it.maintain_plan_id == input.item_group_id); + await Relevance(input, nameof(ToolMoldMaintainPlanRelation.maintain_plan_id), nameof(ToolMoldMaintainPlanRelation.mold_id), it => it.maintain_plan_id == input.id); /// /// 删除计划与模具关联关系 /// - /// + /// 输入参数 /// [HttpPost] public async Task DeleteMold(RelevanceMoldFromPlanInput input) => - await Delete(it => it.maintain_plan_id == input.item_group_id && input.ids.Contains(it.mold_id)); + await Delete(it => it.maintain_plan_id == input.id && input.ids.Contains(it.mold_id)); } } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainTaskService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainTaskService.cs new file mode 100644 index 00000000..73299f32 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainTaskService.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging.Abstractions; +using SqlSugar; +using Tnb.BasicData; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Entities.Enums; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 模具维修任务接口 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class ToolMoldMaintainTaskService : IOverideVisualDevService, IToolMoldMaintainTaskService, IDynamicApiController, ITransient + { + private const string ModuleId = "26189001337381"; + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private static Dictionary _dicMold = new Dictionary(); + public ToolMoldMaintainTaskService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService + ) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + OverideFuncs.GetListAsync = GetList; + } + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + + private async Task GetList(VisualDevModelListQueryInput input) + { + if (_dicMold.Count < 1) + { + var items = await _db.Queryable().ToListAsync(); + _dicMold = items?.ToDictionary(x => x.id, x => (x.mold_code, x.mold_name))!; + } + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + var data = await _runService.GetListResult(templateEntity, input); + if (data?.list.Count > 0) + { + foreach (var row in data.list) + { + var pair = row[nameof(ToolMoldMaintainTask.mold_id)]; + if (pair.IsNotEmptyOrNull()) + { + var multi = _dicMold[pair.ToString()!]; + row[nameof(ToolMoldMaintainTask.mold_id)] = $"{multi.code}/{multi.name}"; + } + } + } + return data!; + } + + public async Task Create(ToolMoldMaintainTask entity) + { + var row = await _db.Insertable(entity).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1000); + } + /// + /// 修改任务单状态 + /// + /// 输入参数 + /// + [HttpPost] + public async Task UpdateStatus(MaintainStatusUpInput input) + { + DateTime? beginTiem = DateTime.Now; + DateTime? endTime = null; + if (input.status.ToEnum() == MaintainStatus.YWC) + { + endTime = DateTime.Now; + } + var row = await _db.Updateable().SetColumns(it => new ToolMoldMaintainTask { status = input.status, modify_strat_time = beginTiem, modify_end_time = endTime }) + .Where(it => input.ids.Contains(it.id)).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + } + } +} diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs index 60fcf07d..d826c33b 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs @@ -34,6 +34,33 @@ namespace Tnb.EquipMgr _userManager = userManager; _repository = repository; } + + /// + /// 获取模具列表 + /// + /// + /// + [HttpGet] + public async Task> GetListByIds(List ids) + { + return await _repository.AsSugarClient().Queryable().Where(it => ids.Contains(it.id)).ToListAsync(); + } + /// + /// 根据设备id 获取匹配的模具列表 + /// + /// 设备Id + /// + [HttpGet] + public async Task> GetListByEqpId([FromRoute] string eqpId) + { + var db = _repository.AsSugarClient(); + var result = await db.Queryable().InnerJoin((a, b) => a.id == b.mold_id) + .Where((a, b) => b.equipment_id == eqpId) + .Select((a, b) => a) + .ToListAsync(); + return result; + } + /// /// 根据模具id获取设备集合 /// @@ -51,11 +78,12 @@ namespace Tnb.EquipMgr .Select((a, b) => new EquipmentListOutput { id = a.id, - eqp_code=a.code, - eqp_name=a.name + eqp_code = a.code, + eqp_name = a.name }).ToListAsync(); return list; } + /// /// 增加模具设备绑定 /// @@ -65,9 +93,9 @@ namespace Tnb.EquipMgr [HttpPost] public async Task SaveData(ToolMoldInput ToolMoldInput) { - DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => + DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { - var his= await _repository.AsSugarClient().Queryable().ToListAsync(); + var his = await _repository.AsSugarClient().Queryable().ToListAsync(); var list = new List(); foreach (var equip in ToolMoldInput.equipid) { @@ -104,5 +132,10 @@ namespace Tnb.EquipMgr if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); return result.IsSuccess ? "操作成功" : result.ErrorMessage; } + + public Task GetListById(string moldId) + { + return _repository.GetFirstAsync(it => it.id == moldId); + } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CloseDownStartInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CloseDownStartInput.cs new file mode 100644 index 00000000..52975ea2 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CloseDownStartInput.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 停机开始输入参数 + /// + public class CloseDownStartInput + { + /// + /// 设备id + /// + public string eqp_id { get; set; } + /// + /// 停机类别 + /// + public string category { get; set; } + /// + /// 停机原因 + /// + public string reason { get; set; } + /// + /// 备注 + /// + public string remark { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskFromEqpIdInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskFromEqpIdInput.cs new file mode 100644 index 00000000..207b3cc7 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskFromEqpIdInput.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 根据设备id 获取生产任务列表,输入参数 + /// + public class PrdMoTaskFromEqpIdInput + { + /// + /// 设备id + /// + public string eqp_id { get; set; } + /// + /// 生产状态 + /// + public string status { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedown.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedown.cs new file mode 100644 index 00000000..2df900ab --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedown.cs @@ -0,0 +1,64 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// +/// +[SugarTable("prd_cancel_closedown")] +public partial class PrdCancelClosedown : BaseEntity +{ + public PrdCancelClosedown() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 停机类别 + /// + public string? catetory { get; set; } + + /// + /// 停机原因 + /// + public string? reason { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + /// + /// 设备id + /// + public string eqp_id { get; set; } + + /// + /// 创建人 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改人 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + /// + /// 停机开始时间 + /// + public DateTime? closedown_start_time { get; set; } + /// + /// 停机结束时间 + /// + public DateTime? closedown_end_time { get; set; } + +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedownReason.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedownReason.cs new file mode 100644 index 00000000..5fb01ccc --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedownReason.cs @@ -0,0 +1,52 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// +/// +[SugarTable("prd_cancel_closedown_reason")] +public partial class PrdCancelClosedownReason : BaseEntity +{ + public PrdCancelClosedownReason() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 停机类别字典id + /// + public string? category_id { get; set; } + + /// + /// 停机原因编码 + /// + public string? reason_code { get; set; } + + /// + /// 停机原因 + /// + public string? reason { get; set; } + + /// + /// 创建人 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改人 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedownRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedownRecord.cs new file mode 100644 index 00000000..af59189b --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdCancelClosedownRecord.cs @@ -0,0 +1,62 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// 异常停机 +/// +[SugarTable("prd_cancel_closedown_record")] +public partial class PrdCancelClosedownRecord : BaseEntity +{ + public PrdCancelClosedownRecord() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 停机类别 + /// + public string? catetory { get; set; } + + /// + /// 停机原因 + /// + public string? reason { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 创建人 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改人 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 停机开始时间 + /// + public DateTime? closedown_start_time { get; set; } + + /// + /// 停机结束时间 + /// + public DateTime? closedown_end_time { get; set; } + +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdCancelCloseDownService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdCancelCloseDownService.cs new file mode 100644 index 00000000..3821ca14 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdCancelCloseDownService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Interfaces +{ + /// + /// 异常停机服务接口 + /// + public interface IPrdCancelCloseDownService + { + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskIssueService.cs similarity index 100% rename from ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs rename to ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskIssueService.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs index fc17ada1..16eca732 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; namespace Tnb.ProductionMgr.Interfaces { @@ -11,5 +13,11 @@ namespace Tnb.ProductionMgr.Interfaces /// public interface IPrdMoTaskService { + /// + /// 根据设备Id获取生产任务 + /// + /// + /// + Task> GetListByEqpId(string eqpId); } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs new file mode 100644 index 00000000..22bdcaf6 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs @@ -0,0 +1,241 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aop.Api.Domain; +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Logging; +using JNPF.Systems.Entitys.Permission; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Interfaces; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; +using Tnb.ProductionMgr.Interfaces; + +namespace Tnb.ProductionMgr +{ + /// + /// 业务实现:生产管理 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + + public class PrdCancelCloseDownService : IPrdCancelCloseDownService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + private readonly IToolMoldMaintainTaskService _maintainTaskService; + private readonly IToolMoldsService _moldService; + private readonly IPrdMoTaskService _prdMoTaskService; + private readonly IUserManager _userManager; + + private static Dictionary _dicWorkStationAndShopRelacion = new Dictionary(); + private static Dictionary _dicWorkShop = new Dictionary(); + + + + public PrdCancelCloseDownService( + ISqlSugarRepository repository, + IPrdMoTaskService prdMoTaskService, + IToolMoldsService moldsService, + IToolMoldMaintainTaskService maintainTaskService, + IUserManager userManager + ) + { + _prdMoTaskService = prdMoTaskService; + _maintainTaskService = maintainTaskService; + _moldService = moldsService; + _userManager = userManager; + _db = repository.AsSugarClient(); + } + /// + /// 根据设备ID获取异常关机信息 + /// + /// + /// + [HttpGet] + public async Task GetClosedownEndList([FromRoute] string eqpId) + { + if (_dicWorkShop.Count < 1) + { + var orgs = await _db.Queryable().Where(it => it.Category == "workstation").ToListAsync(); + if (orgs?.Count > 0) + { + var shopIds = orgs.Select(x => + { + var shopId = ""; + var orgTree = x.OrganizeIdTree.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + if (orgTree?.Length > 1) + { + shopId = orgTree[orgTree.Length - 2]; + _dicWorkStationAndShopRelacion[x.EnCode] = shopId; + } + return shopId; + }).Where(x => !x.IsNullOrEmpty()).ToList(); + if (shopIds?.Count > 0) + { + _dicWorkShop = await _db.Queryable().Where(it => it.Category == "department" && shopIds.Contains(it.Id)).ToDictionaryAsync(x => x.Id, x => x.FullName); + } + } + } + var result = new List(); + var closeDown = await _db.Queryable().FirstAsync(it => it.eqp_id == eqpId); + if (closeDown != null) + { + if (!closeDown.reason.IsNullOrEmpty()) + { + var eqp = await _db.Queryable().FirstAsync(it => it.id == eqpId); + EqpEquipType eqpTypeInfo = null; + if (eqp != null) + eqpTypeInfo = await _db.Queryable().FirstAsync(it => it.id == eqp.equip_type_id); + var reasonArr = closeDown.reason.Split(","); + foreach (var reason in reasonArr) + { + ClosedownEndListOutput ot = new(); + if (eqp != null) + { + if (_dicWorkStationAndShopRelacion.ContainsKey(eqp.station_code)) + { + var shopId = _dicWorkStationAndShopRelacion[eqp.station_code].ToString(); + ot.workshop_name = _dicWorkShop.ContainsKey(shopId) ? _dicWorkShop[shopId].ToString()! : ""; + } + } + ot.reason = reason; + ot.eqp_code = eqp?.code; + ot.eqp_type_code = eqpTypeInfo?.code; + ot.operator_name = _userManager.RealName; + ot.remark = closeDown.remark; + ot.closeddown_start_time = closeDown.closedown_start_time; + result.Add(ot); + } + } + } + if (result.Count < 1) + { + ClosedownEndListOutput output = new(); + result.Add(output); + } + return result; + } + + /// + /// 异常停机-开始 + /// + /// + /// + [HttpPost] + public async Task CloseDownStart(CloseDownStartInput input) + { + if (input == null) throw new ArgumentNullException("input"); + if (input.eqp_id.IsNullOrWhiteSpace()) throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty"); + try + { + await _db.Ado.BeginTranAsync(); + + var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id); + if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500); + if (moTaskList.Count > 0) + { + var cancelCloseDown = input.Adapt(); + cancelCloseDown.id = SnowflakeIdHelper.NextId(); + cancelCloseDown.eqp_id = input.eqp_id; + cancelCloseDown.create_id = _userManager.UserId; + cancelCloseDown.create_time = DateTime.Now; + cancelCloseDown.closedown_start_time = DateTime.Now; + + await _db.Insertable(cancelCloseDown).ExecuteCommandAsync(); + var record = cancelCloseDown.Adapt(); + await _db.Insertable(record).ExecuteCommandAsync(); + + var moldId = moTaskList.First().mold_id; + if (!moldId.IsNullOrEmpty()) + { + var mold = await _moldService.GetListById(moldId); + var maintaindTask = new ToolMoldMaintainTask(); + maintaindTask.mold_id = moldId; + maintaindTask.code = DictConst.MaintainStatusDWXCode; + maintaindTask.create_id = _userManager.UserId; + maintaindTask.create_time = DateTime.Now; + + await _maintainTaskService.Create(maintaindTask); + } + } + else throw Oops.Oh(ErrorCode.COM1001); + + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + Log.Error("停机开始失败", ex); + await _db.Ado.RollbackTranAsync(); + throw ex; + } + } + /// + /// 停机结束 + /// + /// + /// + [HttpPost] + public async Task CloseDownEnd(CloseDownStartInput input) + { + if (input == null) throw new ArgumentNullException("input"); + if (input.eqp_id.IsNullOrWhiteSpace()) throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty"); + try + { + await _db.Ado.BeginTranAsync(); + + var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id); + if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500); + + var cancelCloseDown = input.Adapt(); + cancelCloseDown.id = SnowflakeIdHelper.NextId(); + cancelCloseDown.create_id = _userManager.UserId; + cancelCloseDown.create_time = DateTime.Now; + cancelCloseDown.closedown_start_time = DateTime.Now; + + var row = await _db.Insertable(cancelCloseDown).ExecuteCommandAsync(); + + var moldId = moTaskList.First().mold_id; + if (moldId.IsNullOrEmpty()) + { + var mold = await _moldService.GetListById(moldId); + var maintaindTask = new ToolMoldMaintainTask(); + maintaindTask.mold_id = moldId; + maintaindTask.code = DictConst.MaintainStatusYWCCode; + maintaindTask.create_id = _userManager.UserId; + maintaindTask.create_time = DateTime.Now; + + + await _maintainTaskService.Create(maintaindTask); + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + Log.Error("停机开始失败", ex); + await _db.Ado.RollbackTranAsync(); + } + //var row = await _db.Updateable().SetColumns(c => new ToolMoldMaintainTask + //{ + // status = DictConst.MaintainStatusDWXCode, + // modify_id = _userManager.UserId, + // modify_end_time = DateTime.Now, + //}) + // .ExecuteCommandAsync(); + //if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index a00115da..88efe23f 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1185,5 +1185,9 @@ namespace Tnb.ProductionMgr } + public async Task> GetListByEqpId(string eqpId) + { + return await _db.Queryable().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync(); + } } } diff --git a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs index e2e2f6cf..1c1dc7b7 100644 --- a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs +++ b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs @@ -9,7 +9,7 @@ namespace JNPF.Common.Extension { public static class LambdaExpressionExtensions { - public static void PropertySetValue(this T instance, string propertyName,string value) + public static void PropertySetValue(this T instance, string propertyName, string value) { if (!PropertySet.ValueFactories.TryGetValue(propertyName, out Action setAction)) { diff --git a/system/Tnb.Systems/Permission/DepartmentService.cs b/system/Tnb.Systems/Permission/DepartmentService.cs index fc612ac7..3dc97348 100644 --- a/system/Tnb.Systems/Permission/DepartmentService.cs +++ b/system/Tnb.Systems/Permission/DepartmentService.cs @@ -455,17 +455,17 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra var eqpList = (jsonObj.Value("roweqp")); var eqpIds = eqpList.Select(x => x.Value("id")).ToList(); - //isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync(); - ////工位与设备解绑操作 - //var eqpEntities = await _repository.AsSugarClient().Queryable().Where(it => it.station_code == input.enCode).ToListAsync(); - //if (eqpEntities?.Count > 0) - //{ - // var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList(); - // if (unbindEqpIds?.Count > 0) - // { - // isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync(); - // } - //} + isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync(); + //工位与设备解绑操作 + var eqpEntities = await _repository.AsSugarClient().Queryable().Where(it => it.station_code == input.enCode).ToListAsync(); + if (eqpEntities?.Count > 0) + { + var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList(); + if (unbindEqpIds?.Count > 0) + { + isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync(); + } + } } var processVal = jsonObj.GetValue("rowprocess"); if (processVal is not null)