diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRecordRepeatInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRecordRepeatInput.cs new file mode 100644 index 00000000..83b7df9a --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRecordRepeatInput.cs @@ -0,0 +1,13 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class MaintainRecordRepeatInput + { + public string id { get; set; } + + public string repeat_result { get; set; } + + public string repeat_remark { get; set; } + + public List> details { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRecordRepeatOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRecordRepeatOutput.cs new file mode 100644 index 00000000..d262d480 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRecordRepeatOutput.cs @@ -0,0 +1,9 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class MaintainRecordRepeatOutput + { + public EqpMaintainRecordH model { get; set; } + + public List details { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipScrap.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipScrap.cs new file mode 100644 index 00000000..faefe3ed --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipScrap.cs @@ -0,0 +1,82 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 设备报废表 +/// +[SugarTable("eqp_equip_scrap")] +public partial class EqpEquipScrap : BaseEntity +{ + public EqpEquipScrap() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 编码 + /// + public string code { get; set; } = string.Empty; + + /// + /// 报废时间 + /// + public DateTime scrap_time { get; set; } = DateTime.Now; + + /// + /// 设备id + /// + public string equip_id { get; set; } = string.Empty; + + /// + /// 负责人id + /// + public string charger_id { get; set; } = string.Empty; + + /// + /// 负责人姓名 + /// + public string charger_name { get; set; } = string.Empty; + + /// + /// 负责人电话 + /// + public string? charger_phone { 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 string? org_id { get; set; } + + /// + /// 附件 + /// + public string? attachment { get; set; } + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipScrapService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipScrapService.cs new file mode 100644 index 00000000..b349ec38 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipScrapService.cs @@ -0,0 +1,13 @@ +using Tnb.EquipMgr.Entities; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpEquipScrapService + { + /// + /// 设备报废 + /// + /// + public Task Scrap(EqpEquipScrap eqpEquipScrap); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs new file mode 100644 index 00000000..387129b3 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs @@ -0,0 +1,30 @@ +using JNPF.Common.Dtos.VisualDev; +using Tnb.EquipMgr.Entities.Dto; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpMaintainRecordService + { + /// + /// 执行设备保养计划 + /// + /// + /// + public Task ExecuteMaintain(SpotInsRecordExecuteInput input); + + /// + /// 获取设备保养计划复核信息 + /// + /// + /// + public Task GetMaintainRecordRepeatInfo(Dictionary dic); + + /// + /// 复核备保养计划 + /// + /// + /// + public Task RepeatMaintain(MaintainRecordRepeatInput input); + + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs new file mode 100644 index 00000000..0959a242 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs @@ -0,0 +1,58 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 设备保养计划执行管理 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpEquipScrapService : IEqpEquipScrapService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public EqpEquipScrapService(ISqlSugarRepository repository, + IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + // OverideFuncs.UpdateAsync = ExecuteSpotIns; + } + + + [HttpPost] + public async Task Scrap(EqpEquipScrap eqpEquipScrap) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + eqpEquipScrap.create_id = _userManager.UserId; + eqpEquipScrap.create_time = DateTime.Now; + + await _repository.InsertAsync(eqpEquipScrap); + + await db.Updateable().SetColumns(x => x.life == EquipmentLife.SCRAP) + .Where(x => x.id == eqpEquipScrap.equip_id).ExecuteCommandAsync(); + }); + if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + + return result.IsSuccess ? "报废成功" : result.ErrorMessage; + + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs new file mode 100644 index 00000000..0d526d9b --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs @@ -0,0 +1,146 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +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 EqpMaintainRecordService : IOverideVisualDevService, IEqpMaintainRecordService, IDynamicApiController, ITransient + { + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + private const string ModuleId = "26304609081109"; + private readonly ISqlSugarRepository _repository; + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + private readonly IUserManager _userManager; + + public EqpMaintainRecordService(ISqlSugarRepository repository, + IRunService runService, + IUserManager userManager, + IVisualDevService visualDevService) + { + _repository = repository; + _visualDevService = visualDevService; + _runService = runService; + _userManager = userManager; + // OverideFuncs.UpdateAsync = ExecuteSpotIns; + } + + /// + /// 执行设备保养计划 + /// + /// + /// + [HttpPost] + public async Task ExecuteMaintain(SpotInsRecordExecuteInput input) + { + DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => + { + EqpMaintainRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.id); + string status = ""; + if (eqpSpotInsRecordH.is_repeat == "1") + { + status = SpotInsRecordExecutionStatus.TOBECHECK; + } + else + { + status = SpotInsRecordExecutionStatus.COMPLETED; + } + await _repository.UpdateAsync(x => new EqpMaintainRecordH() + { + result = input.result, + attachment = input.attachment, + result_remark = input.result_remark, + status = status, + execute_time = DateTime.Now, + execute_user_id = _userManager.UserId + }, x => x.id == input.id); + + foreach (var item in input.details) + { + await _repository.AsSugarClient().Updateable() + .SetColumns(x=>x.result==item["result"]) + .SetColumns(x=>x.maintain_descrip==item["maintain_descrip"]) + .Where(x=>x.id==item["id"]) + .ExecuteCommandAsync(); + } + + + }); + + if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + return result.IsSuccess ? "执行成功" : result.ErrorMessage; + } + + /// + /// 获取设备保养计划复核信息 + /// + /// + /// + [HttpPost] + public async Task GetMaintainRecordRepeatInfo(Dictionary dic) + { + string id = dic["id"]; + EqpMaintainRecordH eqpSpotInsRecordH = await _repository.GetSingleAsync(x => x.id == id); + List eqpSpotInsRecordDs = await _repository.AsSugarClient().Queryable() + .Where(x => x.maintain_record_id == id).ToListAsync(); + MaintainRecordRepeatOutput output = new MaintainRecordRepeatOutput() + { + model = eqpSpotInsRecordH, + details = eqpSpotInsRecordDs, + }; + return output; + } + + /// + /// 复核设备保养计划 + /// + /// + /// + [HttpPost] + public async Task RepeatMaintain(MaintainRecordRepeatInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + + foreach (var item in input.details) + { + await db.Updateable() + .SetColumns(x => x.repeat_descrip == item["repeat_descrip"]) + .SetColumns(x => x.repeat_result == item["repeat_result"]) + .Where(x => x.id == item["id"]).ExecuteCommandAsync(); + } + + await _repository.UpdateAsync(x => new EqpMaintainRecordH() + { + repeat_result = input.repeat_result, + repeat_remark = input.repeat_remark, + repeat_user_id = _userManager.UserId, + repeat_time = DateTime.Now, + status = SpotInsRecordExecutionStatus.COMPLETED + }, x => x.id == input.id); + }); + + if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + return result.IsSuccess ? "复核成功" : result.ErrorMessage; + } + } +} \ No newline at end of file diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs index 2226d6eb..4cd3f922 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs @@ -32,7 +32,7 @@ namespace JNPF.TaskScheduler.Listener foreach (var item in eqpSpotInsTemEquipHsByOne) { - if (item.start_time.AddHours((double)item.plan_cycle).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) + if (item.start_time.AddDays((double)item.plan_cycle).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { tobeCreateTemplets.Add(item); }