diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Consts/SpotInsRecordExecutionStatus.cs b/EquipMgr/Tnb.EquipMgr.Entities/Consts/SpotInsRecordExecutionStatus.cs index f847477a..d774afae 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Consts/SpotInsRecordExecutionStatus.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Consts/SpotInsRecordExecutionStatus.cs @@ -13,11 +13,11 @@ namespace Tnb.EquipMgr /// /// 待复核 /// - public const string TOBECHECK = "1"; + public const string TOBECHECK = "2"; /// /// 已完成 /// - public const string COMPLETED = "1"; + public const string COMPLETED = "3"; } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/SpotInsTemPublishInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/SpotInsTemPublishInput.cs new file mode 100644 index 00000000..bc1bfaec --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/SpotInsTemPublishInput.cs @@ -0,0 +1,9 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class SpotInsTemPublishInput + { + public string id { get; set; } + + public string[] equipIds { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs index 3e7c12bc..431d5350 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs @@ -81,7 +81,7 @@ public partial class EqpSpotInsRecordD : BaseEntity /// Default: /// Nullable:True /// - public int? result { get; set; } + public string? result { get; set; } /// /// Desc:实际测量值 diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemD.cs new file mode 100644 index 00000000..3c2a82e5 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemD.cs @@ -0,0 +1,42 @@ +using System; +using System.Linq; +using System.Text; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities +{ + /// + ///点巡检模板子表 + /// + [SugarTable("eqp_spot_ins_tem_d")] + public partial class EqpSpotInsTemD + { + public EqpSpotInsTemD(){ + + + } + /// + /// Desc:编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} = SnowflakeIdHelper.NextId(); + + /// + /// Desc:模板id + /// Default:NULL::character varying + /// Nullable:True + /// + public string? spot_ins_tem_id {get;set;} + + /// + /// Desc:点巡检项id + /// Default:NULL::character varying + /// Nullable:True + /// + public string? spot_ins_item_id {get;set;} + + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemH.cs new file mode 100644 index 00000000..2970fa60 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemH.cs @@ -0,0 +1,181 @@ +using System; +using System.Linq; +using System.Text; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities +{ + /// + ///点巡检模板 + /// + [SugarTable("eqp_spot_ins_tem_h")] + public partial class EqpSpotInsTemH + { + public EqpSpotInsTemH() + { + } + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time { get; set; } + + /// + /// Desc:创建用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? create_id { get; set; } + + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time { get; set; } + + /// + /// Desc:修改用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? modify_id { get; set; } + + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true)] + public string id { get; set; } = SnowflakeIdHelper.NextId(); + + /// + /// Desc:设备类型id + /// Default:NULL::character varying + /// Nullable:True + /// + public string? equip_type_id { get; set; } + + /// + /// Desc:编码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? code { get; set; } + + /// + /// Desc:名称 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? name { get; set; } + + /// + /// Desc:周期 + /// Default: + /// Nullable:False + /// + public decimal plan_cycle { get; set; } + + /// + /// Desc:周期方式 1 单次 2 循环 + /// Default: + /// Nullable:False + /// + public string plan_cycle_unit { get; set; } = string.Empty; + + /// + /// Desc:计划执行通知提前量 + /// Default: + /// Nullable:True + /// + public int? plan_run_notice { get; set; } + + /// + /// Desc:计划执行通知提前量单位 1 小时 2 天 3 周 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? plan_run_notice_unit { get; set; } + + /// + /// Desc:执行滞后推送时间 + /// Default: + /// Nullable:True + /// + public int? plan_delay { get; set; } + + /// + /// Desc:执行滞后推送时间单位 1 小时 2 天 3 周 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? plan_delay_unit { get; set; } + + /// + /// Desc:启用时间 + /// Default: + /// Nullable:False + /// + public DateTime start_time { get; set; } + + /// + /// Desc:是否启用 + /// Default: + /// Nullable:False + /// + public int is_start { get; set; } + + /// + /// Desc:是否复核 + /// Default: + /// Nullable:False + /// + public int is_repeat { get; set; } + + /// + /// Desc:复核岗位id + /// Default:NULL::character varying + /// Nullable:True + /// + public string? repeat_post_info_user_id { get; set; } + + /// + /// Desc:责任岗位id + /// Default:NULL::character varying + /// Nullable:True + /// + public string? send_post_info_user_id { get; set; } + + /// + /// Desc:不合格推送 0 不推送 1 推送 + /// Default: + /// Nullable:False + /// + public int is_send { get; set; } + + /// + /// Desc:备注 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? remark { get; set; } + + /// + /// Desc:推送人id + /// Default:NULL::character varying + /// Nullable:True + /// + public string? send_post_id { get; set; } + + /// + /// Desc:所属组织 + /// Default:NULL::character varying + /// Nullable:True + /// + public string? org_id { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSpotInsTemService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSpotInsTemService.cs new file mode 100644 index 00000000..12bdb6e4 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSpotInsTemService.cs @@ -0,0 +1,12 @@ +using Tnb.EquipMgr.Entities.Dto; +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpSpotInsTemService + { + /// + /// 根据模板id发布到设备 + /// + /// + public Task Publish(SpotInsTemPublishInput input); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs new file mode 100644 index 00000000..887c7a87 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs @@ -0,0 +1,14 @@ +using JNPF.Common.Dtos.VisualDev; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEquSpotInsRecordService + { + /// + /// 执行点巡检 + /// + /// + /// + public Task ExecuteSpotIns(string id,VisualDevModelDataUpInput input); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpSpotInsTemService.cs b/EquipMgr/Tnb.EquipMgr/EqpSpotInsTemService.cs new file mode 100644 index 00000000..67d0f81c --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpSpotInsTemService.cs @@ -0,0 +1,111 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Interfaces; +using Tnb.EquipMgr.Entities.Dto; + +namespace Tnb.EquipMgr +{ + /// + /// 点巡检模板管理 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpSpotInsTemService : IEqpSpotInsTemService, IDynamicApiController, ITransient + { + private const string ModuleId = "26123080740885"; + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public EqpSpotInsTemService(ISqlSugarRepository repository, + IUserManager userManager, + IVisualDevService visualDevService) + { + _repository = repository; + _userManager = userManager; + } + + public async Task Publish(SpotInsTemPublishInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + EqpSpotInsTemH eqpSpotInsTemH = await _repository.GetSingleAsync(x => x.id == input.id); + List eqpSpotInsTemDs = await db.Queryable().Where(x=>x.spot_ins_item_id==input.id).ToListAsync(); + + if (input.equipIds != null && input.equipIds.Length > 0) + { + List insertEqpSpotInsTemEquipHs = new List(); + List insertEqpSpotInsTemEquipDs = new List(); + foreach (var equipId in input.equipIds) + { + string id = SnowflakeIdHelper.NextId(); + string code = $"{DateTime.Now.ToString("yyyy-MM-dd") + equipId}"; + EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH() + { + id = id, + code = code, + name = eqpSpotInsTemH.name+equipId, + plan_cycle = eqpSpotInsTemH.plan_cycle, + plan_cycle_unit = eqpSpotInsTemH.plan_cycle_unit, + plan_run_notice = eqpSpotInsTemH.plan_run_notice, + plan_delay = eqpSpotInsTemH.plan_delay, + start_time = eqpSpotInsTemH.start_time, + is_start = eqpSpotInsTemH.is_start.ToString(), + is_repeat = eqpSpotInsTemH.is_repeat.ToString(), + is_send = eqpSpotInsTemH.is_send, + spot_ins_tem_id = input.id, + equip_id = equipId, + remark = eqpSpotInsTemH.remark, + plan_run_notice_unit = eqpSpotInsTemH.plan_run_notice_unit, + plan_delay_unit = eqpSpotInsTemH.plan_delay_unit, + repeat_post_info_user_id = eqpSpotInsTemH.repeat_post_info_user_id, + send_post_info_user_id = eqpSpotInsTemH.send_post_info_user_id, + send_post_id = eqpSpotInsTemH.send_post_id, + org_id = eqpSpotInsTemH.org_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + }; + insertEqpSpotInsTemEquipHs.Add(eqpSpotInsTemEquipH); + + if (eqpSpotInsTemDs != null && eqpSpotInsTemDs.Count > 0) + { + foreach (var eqpSpotInsTem in eqpSpotInsTemDs) + { + EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD() + { + id = SnowflakeIdHelper.NextId(), + spot_ins_item_id = eqpSpotInsTem.id, + spot_ins_tem_equip_id = id, + }; + insertEqpSpotInsTemEquipDs.Add(eqpSpotInsTemEquipD); + } + } + } + + if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0) + { + await db.Insertable(insertEqpSpotInsTemEquipHs).ExecuteCommandAsync(); + } + + if (insertEqpSpotInsTemEquipDs != null && insertEqpSpotInsTemEquipDs.Count > 0) + { + await db.Insertable(insertEqpSpotInsTemEquipDs).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/EquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs new file mode 100644 index 00000000..6b752382 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs @@ -0,0 +1,82 @@ +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.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 点巡检执行管理 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class EquSpotInsRecordService : IOverideVisualDevService, IEquSpotInsRecordService, IDynamicApiController, ITransient + { + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + private const string ModuleId = "26123080740885"; + private readonly ISqlSugarRepository _repository; + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + private readonly IUserManager _userManager; + + public EquSpotInsRecordService(ISqlSugarRepository repository, + IRunService runService, + IUserManager userManager, + IVisualDevService visualDevService) + { + _repository = repository; + _visualDevService = visualDevService; + _runService = runService; + _userManager = userManager; + OverideFuncs.UpdateAsync = ExecuteSpotIns; + } + + public async Task ExecuteSpotIns(string id,[FromBody]VisualDevModelDataUpInput input) + { + DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => + { + //string attachment = JsonConvert.SerializeObject(input.data["attachment"]); + // _repository.UpdateAsync(x => new EqpSpotInsRecordH() + // { + // result = (int)input.data["result"], + // attachment = attachment, + // result_remark = input.data["result_remark"].ToString(), + // }, x => x.id == input.data["id"]); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Update(id,templateEntity, input); + + EqpSpotInsRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.data["id"].ToString()); + string status = ""; + if (eqpSpotInsRecordH.is_repeat == "1") + { + status = SpotInsRecordExecutionStatus.TOBECHECK; + } + else + { + status = SpotInsRecordExecutionStatus.COMPLETED; + } + _repository.UpdateAsync(x => new EqpSpotInsRecordH() + { + status = status, + spot_record_date_time = DateTime.Now, + spot_record_user_id = _userManager.UserId + }, x => x.id == input.data["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/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs index e4da44d1..fbce46ad 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs @@ -17,7 +17,7 @@ namespace JNPF.TaskScheduler.Listener // _repository = repository; // } - [SpareTime("0 0 0 * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)] + [SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)] public void GenerateSpotInspectionPlan(SpareTimer timer, long count) { Log.Information("----------------------开始生成点巡检计划----------------------"); @@ -100,6 +100,7 @@ namespace JNPF.TaskScheduler.Listener repeat_post_info_user_id = item.repeat_post_info_user_id, is_send = item.is_send, create_time = DateTime.Now, + status = Tnb.EquipMgr.SpotInsRecordExecutionStatus.TOBEEXECUTED }); } }